X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=bs%2Fbsview.cpp;h=b5e25b0a2c88fe8d21c46ea1faa9af4c7973625d;hb=935b6de2d1428854d76acc20b1727eb4a30f9273;hp=9212fb166c4295cad4be300ebe67186993f4a51b;hpb=e0be1e6e8f7a246acf49e1f315c8d5bc5a65bfa3;p=hbs.git diff --git a/bs/bsview.cpp b/bs/bsview.cpp index 9212fb1..b5e25b0 100644 --- a/bs/bsview.cpp +++ b/bs/bsview.cpp @@ -28,6 +28,8 @@ using namespace std; //QT includes #include #include +#include +#include #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); @@ -174,6 +185,7 @@ void BSView::slotDocumentChanged() } m_InfoView->setBattles(battlenames); updateInfoView(); + setCurrentListViewItem(); updateFleetView(); } @@ -185,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); @@ -203,7 +234,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 +486,99 @@ 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(fl); + if (pl) + { + cerr << "generating....." << endl; + ReportList report = pl->report(); + QString t; + + t.append("\n"); + + + for (ReportList::iterator i = report.begin(); i != report.end(); ++i) + { + t.append(QString("Tick number: %0\n").arg(i->first)); + t.append("
    \n"); + for(map > > >::iterator j = i->second.begin(); j != i->second.end(); ++j) + { + t.append(QString("
  • Now handling initiative: %0\n").arg(j->first)); + t.append("
      \n"); + + for(map > >::iterator k = j->second.begin(); k != j->second.end(); ++k) + { + for(map >::iterator l = k->second.begin(); l != k->second.end(); ++l) + { + t.append(QString("
    • %0 %1 %2 killing/blocking at: \n").arg(l->second["000"]).arg(k->first.c_str()).arg(l->first.c_str())); + t.append("
        \n"); + + for(map::iterator m = l->second.begin(); m != l->second.end(); ++m) + { + if (m->first != "000") + t.append(QString("
      • %0 %1
      • ").arg(m->second).arg(m->first.c_str())); + } + + t.append("
      \n"); + t.append("
    • \n"); + } + } + t.append("
    \n"); + t.append("
  • \n"); + } + t.append("
\n"); + + t.append("
\n"); + } + t.append("
\n"); + //cerr << t.latin1(); + //m_Report->clear(); + m_Report->setText(t); + + } + //m_Report->append("test\n"); +} + +////////////////////////////////////////////////////////////////////////// +// +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()); +}