]> ruin.nu Git - hbs.git/blobdiff - bs/bsview.cpp
started to work on the battle report.. almost there =)
[hbs.git] / bs / bsview.cpp
index 9212fb166c4295cad4be300ebe67186993f4a51b..c6fcc46efe831d4f2975572ff26626a0589be94c 100644 (file)
@@ -28,6 +28,8 @@ using namespace std;
 //QT includes
 #include <qlistview.h>
 #include <qwidgetstack.h>
+#include <qtabwidget.h>
+#include <qtextedit.h>
 
 #include "battlesum.h"
 #include "scanview.h"
@@ -51,7 +53,16 @@ BSView::BSView(QWidget *parent, BSDoc *doc) : QSplitter(parent)
        m_doc = doc;
        
        m_LeftSplit = new QSplitter(QSplitter::Vertical, this);
-       m_RightSplit = new QSplitter(QSplitter::Vertical, this);
+
+       m_Pages = new QTabWidget(this);
+
+       m_RightSplit = new QSplitter(QSplitter::Vertical);
+       m_Pages->addTab(m_RightSplit, tr("Units"));
+       
+       m_Report = new QTextEdit();
+       m_Report->setReadOnly(true);
+       m_Pages->addTab(m_Report, tr("Report"));
+
 
        //setting up the listview
        m_NumberView = new QListView(m_LeftSplit);
@@ -203,7 +214,13 @@ void BSView::slotFleetSelection(QListViewItem *lvi)
        {
                m_sFleet = lvi->text(0);
                m_sGroup = lvi->parent()->text(0);
-               m_sBattle = lvi->parent()->parent()->text(0);
+               QString temp = lvi->parent()->parent()->text(0);
+
+               if (temp != m_sBattle)
+               {
+                       m_sBattle = temp;
+                       slotGenerateReport();
+               }
 
                updateInfoView();
                updateFleetView();
@@ -449,3 +466,54 @@ void BSView::slotUseScan(int action, QString text, int fleets)
        cerr << "Text: " << text.latin1() << endl;
        cerr << "Fleets: " << fleets << endl;
 }
+
+
+//////////////////////////////////////////////////////////////////////////
+//
+void BSView::slotGenerateReport()
+{
+       const Fleet *fl = m_doc->specificFleet(m_sBattle, "Friendly", "Home Planet");
+       
+       const Planet* pl = dynamic_cast<const Planet*>(fl);
+       if (pl)
+       {
+               ReportList report = pl->report();
+               QString t;
+               
+               t.append("<qt>\n");
+               
+
+               for (ReportList::iterator i = report.begin(); i != report.end(); ++i)
+               {
+                       t.append(QString("Tick number: %0\n").arg(i->first));
+                       t.append("<ul>\n");
+                       for(map<int, map<string, map<string, map<string, int> > > >::iterator j = i->second.begin(); j != i->second.end(); ++j)
+                       {
+                               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)
+                                       {
+                                               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");
+
+                                               t.append("</ul>\n");
+                                               t.append("</li>\n");
+                                       }
+                               }
+                               t.append("</ul>\n");
+                               t.append("</li>\n");
+                       }
+                       t.append("</ul>\n");
+
+                       t.append("<hr>\n");
+               }
+               t.append("</qt>\n");
+               //cerr << t.latin1();
+               m_Report->clear();
+               m_Report->setText(t);
+
+       }
+       //m_Report->append("<b>test\n<b>");
+}