#include "bsview.h"
-#include "battlesum.h"
-#include "scanview.h"
-#include "ui/infoview.h"
-#include "tickview.h"
-#include "ui/fleetviewbase.h"
+//standard library
+#include <iostream>
+#include <map>
+#include <vector>
+#include <string>
+
+using namespace std;
//QT includes
#include <qlistview.h>
#include <qwidgetstack.h>
-#include <iostream>
-using namespace std;
+#include "battlesum.h"
+#include "scanview.h"
+#include "ui/infoview.h"
+#include "tickview.h"
+#include "ui/fleetviewbase.h"
+#include "fleet.h"
BSView::BSView(QWidget *parent, BSDoc *doc) : QSplitter(parent)
{
/** connect doc with the view*/
connect(doc, SIGNAL(documentChanged()), this, SLOT(slotDocumentChanged()));
+ m_doc = doc;
m_LeftSplit = new QSplitter(QSplitter::Vertical, this);
m_RightSplit = new QSplitter(QSplitter::Vertical, this);
{
}
+//////////////////////////////////////////////////////////////////////////
+//
void BSView::addBattle(QString name)
{
QListViewItem* battle = new QListViewItem(m_NumberView, name);
(void) new QListViewItem(def, tr("Home Planet"), "","","1");
}
+///////////////////////////////////////////////////////////////////////////////
+//
+/***This function clears the listview and then iterates through the battles
+ * and recreates the listview hierarchy.
+ */
void BSView::slotDocumentChanged()
{
- //TODO update the view
+ m_NumberView->clear();
+
+ map<QString, map<QString, map<QString, Fleet> > >& battles = m_doc->Battles();
+
+ for (map<QString, map<QString, map<QString, Fleet> > >::iterator i = battles.begin(); i != battles.end(); i++)
+ {
+ QString b = (*i).first;
+ QListViewItem* battle = new QListViewItem(m_NumberView, b);
+ for (map<QString, map<QString, Fleet> >::iterator j = battles[b].begin(); j != battles[b].end(); j++)
+ {
+ QString g = (*j).first;
+ QListViewItem* group = new QListViewItem(battle, g);
+
+ for (map<QString, Fleet>::iterator k = battles[b][g].begin(); k != battles[b][g].end(); k++)
+ {
+ (void) new QListViewItem(group, (*k).first);
+ }
+ }
+ }
}
-/** No descriptions */
+
+//////////////////////////////////////////////////////////////////////////////
+//
void BSView::slotFleetSelection(QListViewItem *lvi)
{
//cout << lvi->parent()->text(2).toLocal8bit() << endl;
else if (lvi->parent()->parent() == '\0')
{
m_FleetView->slotHomePlanet(false);
- if (lvi->text(3) == "1")
+ if (lvi->text(0) == tr("Friendly"))
{
m_FleetView->slotAttacker(false);
}
}
else
{
- if (lvi->parent()->text(3) == "1")
+ if (lvi->parent()->text(0) == tr("Friendly"))
{
m_FleetView->slotAttacker(false);
m_FleetView->slotHomePlanet(false);
- if (lvi->text(3) == "1")
+ if (lvi->text(0) == tr("Home Planet"))
{
m_FleetView->slotHomePlanet(true);
}