]> ruin.nu Git - hbs.git/blobdiff - bs/bsview.cpp
the battlereport works now..
[hbs.git] / bs / bsview.cpp
index c6fcc46efe831d4f2975572ff26626a0589be94c..b5e25b0a2c88fe8d21c46ea1faa9af4c7973625d 100644 (file)
@@ -185,6 +185,7 @@ void BSView::slotDocumentChanged()
        }
        m_InfoView->setBattles(battlenames);
        updateInfoView();
+       setCurrentListViewItem();
        updateFleetView();
 }
 
@@ -196,9 +197,28 @@ void BSView::slotFleetSelection(QListViewItem *lvi)
        if (lvi->parent() == '\0')
        {
                m_FleetViews->raiseWidget(0);
+               m_sFleet = QString::null;
+               m_sGroup = QString::null;
+               QString temp = lvi->text(0);
+
+               if (temp != m_sBattle)
+               {
+                       m_sBattle = temp;
+                       slotGenerateReport();
+               }
        }
        else if (lvi->parent()->parent() == '\0')
        {
+               m_sFleet = QString::null;
+               m_sGroup = lvi->text(0);
+               QString temp = lvi->parent()->text(0);
+
+               if (temp != m_sBattle)
+               {
+                       m_sBattle = temp;
+                       slotGenerateReport();
+               }
+
                if (lvi->text(0) == tr("Friendly"))
                {
        //                      m_FleetView->slotAttacker(false);
@@ -477,6 +497,7 @@ void BSView::slotGenerateReport()
        const Planet* pl = dynamic_cast<const Planet*>(fl);
        if (pl)
        {
+               cerr << "generating....." << endl;
                ReportList report = pl->report();
                QString t;
                
@@ -491,6 +512,7 @@ void BSView::slotGenerateReport()
                        {
                                t.append(QString("<li>Now handling initiative: %0\n").arg(j->first));
                                t.append("<ul type=circle>\n");
+
                                for(map<string, map<string, map<string, int> > >::iterator k = j->second.begin(); k != j->second.end(); ++k)
                                {
                                        for(map<string, map<string, int> >::iterator l = k->second.begin(); l != k->second.end(); ++l)
@@ -498,6 +520,12 @@ void BSView::slotGenerateReport()
                                                t.append(QString("<li>%0 %1 %2 killing/blocking at: \n").arg(l->second["000"]).arg(k->first.c_str()).arg(l->first.c_str()));
                                                t.append("<ul type=square>\n");
 
+                                               for(map<string, int>::iterator m = l->second.begin(); m != l->second.end(); ++m)
+                                               {
+                                                       if (m->first != "000")
+                                                               t.append(QString("<li>%0 %1</li>").arg(m->second).arg(m->first.c_str()));
+                                               }
+
                                                t.append("</ul>\n");
                                                t.append("</li>\n");
                                        }
@@ -511,9 +539,46 @@ void BSView::slotGenerateReport()
                }
                t.append("</qt>\n");
                //cerr << t.latin1();
-               m_Report->clear();
+               //m_Report->clear();
                m_Report->setText(t);
 
        }
        //m_Report->append("<b>test\n<b>");
 }
+
+//////////////////////////////////////////////////////////////////////////
+//
+void BSView::setCurrentListViewItem()
+{
+       QListViewItemIterator i(m_NumberView);
+       while ( i.current() != 0)
+       {
+               QListViewItem* lvi = i.current();
+               if (lvi->parent() == '\0')
+               {
+                       if (m_sFleet.isNull() && m_sGroup.isNull() && m_sBattle == lvi->text(0))
+                       {
+                               m_NumberView->setCurrentItem(lvi);
+                               return;
+                       }
+               }
+               else if (lvi->parent()->parent() == '\0')
+               {
+                       if (m_sFleet.isNull() && m_sGroup == lvi->text(0) && m_sBattle == lvi->parent()->text(0))
+                       {
+                               m_NumberView->setCurrentItem(lvi);
+                               return;
+                       }
+               }
+               else 
+               {
+                       if (m_sFleet == lvi->text(0) && m_sGroup == lvi->parent()->text(0) && m_sBattle == lvi->parent()->parent()->text(0))
+                       {
+                               m_NumberView->setCurrentItem(lvi);
+                               return;
+                       }
+               }
+               ++i;    
+       }
+       m_NumberView->setCurrentItem(m_NumberView->firstChild());
+}