int BSDoc::newBattle(QString name)
{
- m_Battles[name]["Friendly"]["Home Planet"];
+ m_Battles[name]["Friendly"]["Home Planet"].setRace("Planet");
+ m_Battles[name]["Friendly"]["Home Fleet"];
m_Battles[name]["Hostile"];
modified = true;
BSView::BSView(QWidget *parent, BSDoc *doc) : QSplitter(parent)
{
/** connect doc with the view*/
- connect(doc, SIGNAL(documentChanged()), this, SLOT(slotDocumentChanged()));
+ connect(doc, SIGNAL(documentChanged()), this, SLOT(slotDocumentChanged()));
m_doc = doc;
m_NumberView->addColumn("ETA");
//addBattle("NO BATTLES");
+
+
+ connect(m_NumberView, SIGNAL(expanded(QListViewItem*)), SLOT(slotItemExpanded(QListViewItem*)));
+ connect(m_NumberView, SIGNAL(collapsed(QListViewItem*)), SLOT(slotItemCollapsed(QListViewItem*)));
+
m_InfoView = new InfoView(m_LeftSplit);
+
+ vector<QString> raceNames;
+ const map<string, vector<int> >& races = Fleet::Races();
+ for(map<string, vector<int> >::const_iterator i = races.begin(); i != races.end(); ++i)
+ {
+ raceNames.push_back(i->first.c_str());
+ }
+ m_InfoView->setRaces(raceNames);
//the right side
m_TickView = new TickView(m_RightSplit);
m_FleetViews = new QWidgetStack(m_RightSplit);
m_ScanView = new ScanView(m_RightSplit);
+ Fleet fl1;
+ //fl1.setRace(tr("Terran").latin1());
+ fl1.setRace("Terran");
+ Fleet fl2;
+ fl2.setRace(tr("Generic").latin1());
+
//the widget stack
m_BattleSum = new BattleSum();
m_FleetViews->addWidget(m_BattleSum, 0);
- m_FleetView = new FleetView(Fleet(), true, true);
+ m_FleetView = new FleetView(fl1, true, true);
m_FleetViews->addWidget(m_FleetView, 1);
-
+ m_GenericFleetView = new FleetView(fl2, true, false);
+ m_FleetViews->addWidget(m_GenericFleetView, 2);
//m_FleetViews->raiseWidget(0);
connect(m_NumberView, SIGNAL(selectionChanged(QListViewItem *)), SLOT(slotFleetSelection(QListViewItem *)));
}
{
QString b = (*i).first;
QListViewItem* battle = new QListViewItem(m_NumberView, b);
+ battle->setOpen(m_TreeExpanded[b]["--"]);
+
for (map<QString, map<QString, Fleet> >::const_iterator j = i->second.begin(); j != i->second.end(); ++j)
{
QString g = (*j).first;
QListViewItem* group = new QListViewItem(battle, g);
int groupShips = 0;
+ group->setOpen(m_TreeExpanded[b][g]);
for (map<QString, Fleet>::const_iterator k = j->second.begin(); k != j->second.end(); ++k)
{
{
// m_FleetView->slotAttacker(true);
}
- m_FleetViews->raiseWidget(1);
+ m_FleetViews->raiseWidget(2);
}
else
}
}
Fleet fl = m_doc->specificFleet(battle, group, fleet);
- if (fl.Race() == m_FleetView->fleet().Race() &&
- m_FleetView->isHome() == home)
+ m_InfoView->setRace(fl.Race().c_str());
+ m_InfoView->setFleetName(fleet);
+ m_InfoView->setEta(fl.ETA());
+ if (fl.Race() == tr("Generic").latin1())
{
- m_FleetView->viewFleet(fl, friendly);
+ m_GenericFleetView->viewFleet(fl, friendly);
+ m_FleetViews->raiseWidget(2);
+
}
- else
+ else
{
- m_FleetViews->removeWidget(m_FleetView);
- m_FleetView = new FleetView(fl, friendly, home);
- m_FleetViews->addWidget(m_FleetView, 1);
+ if (fl.Race() == m_FleetView->fleet().Race() &&
+ m_FleetView->isHome() == home)
+ {
+ m_FleetView->viewFleet(fl, friendly);
+ }
+ else
+ {
+ m_FleetViews->removeWidget(m_FleetView);
+ m_FleetView = new FleetView(fl, friendly, home);
+ m_FleetViews->addWidget(m_FleetView, 1);
+ }
+ m_FleetViews->raiseWidget(1);
}
- m_FleetViews->raiseWidget(1);
}
+}
-
+//////////////////////////////////////////////////////////////////////////
+//
+void BSView::slotItemExpanded(QListViewItem *lvi)
+{
+ if (lvi->parent() == '\0')
+ {
+ m_TreeExpanded[lvi->text(0)]["--"] = true;
+ }
+ else if (lvi->parent()->parent() == '\0')
+ {
+ m_TreeExpanded[lvi->parent()->text(0)][lvi->text(0)] = true;
+ }
}
+
+//////////////////////////////////////////////////////////////////////////
+//
+void BSView::slotItemCollapsed(QListViewItem *lvi)
+{
+ if (lvi->parent() == '\0')
+ {
+ m_TreeExpanded[lvi->text(0)]["--"] = false;
+ }
+ else if (lvi->parent()->parent() == '\0')
+ {
+ m_TreeExpanded[lvi->parent()->text(0)][lvi->text(0)] = false;
+ }
+}
+
// include files for QT
#include <qsplitter.h>
+//Standard includes
+#include <map>
+
// application specific includes
#include "bsdoc.h"
InfoView *m_InfoView;
TickView *m_TickView;
QWidgetStack *m_FleetViews;
- FleetView *m_FleetView;
+ FleetView *m_FleetView;
+ FleetView *m_GenericFleetView;
BSDoc *m_doc;
+ std::map<QString, std::map<QString, bool> > m_TreeExpanded;
public slots: // Public slots
/** No descriptions */
void slotFleetSelection(QListViewItem *lvi);
+ void slotItemExpanded(QListViewItem *lvi);
+ void slotItemCollapsed(QListViewItem *lvi);
};
#endif
Fleet::Fleet()
{
m_iETA = 0;
- m_sRace = "Generic";
+ m_sRace = "Cathaar";
}
Fleet::~Fleet(){
}
Cathaar 0 2
Xandathrii 0 3
Zikonian 0 4
+Planet 5
4 Bs Fr Co Fi 40 5 30 40 6 400 90 76000 800 5 Normal
Astro Pod
0 Fr -- -- -- 48 20 0 0 0 10 55 3700 125 4 Special
+Mesonic Cutter
+5 Co Fi Co -- 49 25 40 1 3 50 N/A 1600 0 0 PDS
+Tachyon Beamer
+5 Fr Fr Co -- 50 20 35 1 10 75 N/A 3000 0 0 PDS
+Pulse Cannon
+5 De De Fr All 51 15 30 1 20 150 N/A 8500 0 0 PDS
+Hadron Turret
+5 Cr Cr De All 52 10 25 1 30 225 N/A 18000 0 0 PDS
+Ion Launcher
+5 Bs Bs Cr All 53 5 20 1 60 350 N/A 36000 0 0 PDS
<!DOCTYPE UI><UI version="3.0" stdsetdef="1">
<class>InfoView</class>
-<layoutdefaults spacing="0" margin="0"/>
<widget class="QWidget">
<property name="name">
<cstring>InfoView</cstring>
<rect>
<x>0</x>
<y>0</y>
- <width>192</width>
- <height>144</height>
+ <width>263</width>
+ <height>117</height>
</rect>
</property>
+ <property name="maximumSize">
+ <size>
+ <width>32767</width>
+ <height>150</height>
+ </size>
+ </property>
<property name="caption">
<string>Form2</string>
</property>
- <grid>
+ <vbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<property name="margin">
- <number>1</number>
+ <number>0</number>
</property>
<property name="spacing">
- <number>1</number>
+ <number>0</number>
</property>
- <widget class="QLayoutWidget" row="0" column="0">
+ <widget class="QLayoutWidget">
<property name="name">
- <cstring>Layout11</cstring>
+ <cstring>Layout7</cstring>
</property>
- <hbox>
+ <grid>
<property name="name">
<cstring>unnamed</cstring>
</property>
<number>0</number>
</property>
<property name="spacing">
- <number>6</number>
+ <number>0</number>
</property>
- <widget class="QLayoutWidget">
+ <widget class="QLabel" row="2" column="0">
<property name="name">
- <cstring>Layout10</cstring>
- </property>
- <vbox>
- <property name="name">
- <cstring>unnamed</cstring>
- </property>
- <property name="margin">
- <number>0</number>
- </property>
- <property name="spacing">
- <number>6</number>
- </property>
- <widget class="QLabel">
- <property name="name">
- <cstring>TextLabel3</cstring>
- </property>
- <property name="text">
- <string>Name</string>
- </property>
- </widget>
- <widget class="QLabel">
- <property name="name">
- <cstring>TextLabel1</cstring>
- </property>
- <property name="text">
- <string>Eta</string>
- </property>
- </widget>
- <widget class="QLabel">
- <property name="name">
- <cstring>TextLabel2</cstring>
- </property>
- <property name="text">
- <string>Planet score</string>
- </property>
- </widget>
- </vbox>
+ <cstring>RaceLabel</cstring>
+ </property>
+ <property name="text">
+ <string>&Race</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>RaceCombo</cstring>
+ </property>
</widget>
- <widget class="QLayoutWidget">
+ <widget class="QComboBox" row="2" column="1">
<property name="name">
- <cstring>Layout9</cstring>
- </property>
- <vbox>
- <property name="name">
- <cstring>unnamed</cstring>
- </property>
- <property name="margin">
- <number>0</number>
- </property>
- <property name="spacing">
- <number>6</number>
- </property>
- <widget class="QLineEdit">
- <property name="name">
- <cstring>LineEdit5</cstring>
- </property>
- </widget>
- <widget class="QLineEdit">
- <property name="name">
- <cstring>LineEdit3</cstring>
- </property>
- </widget>
- <widget class="QLineEdit">
- <property name="name">
- <cstring>LineEdit4</cstring>
- </property>
- </widget>
- </vbox>
+ <cstring>RaceCombo</cstring>
+ </property>
</widget>
- </hbox>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>EtaLabel</cstring>
+ </property>
+ <property name="text">
+ <string>&Eta</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>EtaSpin</cstring>
+ </property>
+ </widget>
+ <widget class="QSpinBox" row="1" column="1">
+ <property name="name">
+ <cstring>EtaSpin</cstring>
+ </property>
+ </widget>
+ <widget class="QLineEdit" row="0" column="1">
+ <property name="name">
+ <cstring>NameLine</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>NameLabel</cstring>
+ </property>
+ <property name="text">
+ <string>&Name</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>NameLine</cstring>
+ </property>
+ </widget>
+ </grid>
</widget>
- <widget class="QLayoutWidget" row="1" column="0">
+ <widget class="QLayoutWidget">
<property name="name">
<cstring>Layout13</cstring>
</property>
</property>
<widget class="QPushButton">
<property name="name">
- <cstring>PushButton1</cstring>
+ <cstring>ApplyButton</cstring>
</property>
<property name="text">
- <string>Apply</string>
+ <string>&Apply</string>
</property>
</widget>
<widget class="QPushButton">
<property name="name">
- <cstring>PushButton2</cstring>
+ <cstring>CancelButton</cstring>
</property>
<property name="text">
- <string>Cancel</string>
+ <string>&Cancel</string>
</property>
</widget>
<spacer>
- <property name="name">
+ <property name="name" stdset="0">
<cstring>Spacer1</cstring>
</property>
<property name="orientation">
</spacer>
<widget class="QPushButton">
<property name="name">
- <cstring>PushButton3</cstring>
+ <cstring>NewButton</cstring>
</property>
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
- <string>New</string>
+ <string>&New</string>
</property>
</widget>
<widget class="QPushButton">
<property name="name">
- <cstring>PushButton4</cstring>
+ <cstring>RemoveButton</cstring>
</property>
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
- <string>Remove</string>
+ <string>&Remove</string>
</property>
</widget>
</hbox>
</widget>
- </grid>
+ </vbox>
</widget>
<connections>
- <slot access="protected" language="C++" returnType="void">init()</slot>
- <slot access="protected" language="C++" returnType="void">destroy()</slot>
+ <connection>
+ <sender>ApplyButton</sender>
+ <signal>clicked()</signal>
+ <receiver>InfoView</receiver>
+ <slot>ApplyButton_clicked()</slot>
+ </connection>
+ <connection>
+ <sender>CancelButton</sender>
+ <signal>clicked()</signal>
+ <receiver>InfoView</receiver>
+ <slot>CancelButton_clicked()</slot>
+ </connection>
+ <connection>
+ <sender>NewButton</sender>
+ <signal>clicked()</signal>
+ <receiver>InfoView</receiver>
+ <slot>NewButton_clicked()</slot>
+ </connection>
+ <connection>
+ <sender>RemoveButton</sender>
+ <signal>clicked()</signal>
+ <receiver>InfoView</receiver>
+ <slot>RemoveButton_clicked()</slot>
+ </connection>
</connections>
-<functions>
- <function name="init()" >{
-
-}</function>
- <function name="destroy()" >{
-
-}</function>
-</functions>
+<includes>
+ <include location="global" impldecl="in declaration">vector</include>
+ <include location="local" impldecl="in implementation">infoview.ui.h</include>
+</includes>
+<signals>
+ <signal>remove()</signal>
+ <signal>cancel()</signal>
+ <signal>apply()</signal>
+ <signal>add()</signal>
+</signals>
+<slots>
+ <slot access="protected">init()</slot>
+ <slot access="protected">destroy()</slot>
+ <slot>setRaces( std::vector<QString> races )</slot>
+ <slot>setEta( int eta )</slot>
+ <slot>setFleetName( QString name )</slot>
+ <slot>setRace( QString name )</slot>
+ <slot>InfoView_destroyed( QObject * )</slot>
+ <slot>ApplyButton_clicked()</slot>
+ <slot>CancelButton_clicked()</slot>
+ <slot>NewButton_clicked()</slot>
+ <slot>RemoveButton_clicked()</slot>
+</slots>
+<layoutdefaults spacing="0" margin="0"/>
</UI>
<height>75</height>
</rect>
</property>
+ <property name="maximumSize">
+ <size>
+ <width>32767</width>
+ <height>90</height>
+ </size>
+ </property>
<property name="caption">
<string>QGroupBoxForm</string>
</property>
<property name="name">
<cstring>UninitLine</cstring>
</property>
+ <property name="focusPolicy">
+ <enum>NoFocus</enum>
+ </property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</grid>
</widget>
+<includes>
+ <include location="local" impldecl="in implementation">resourceview.ui.h</include>
+</includes>
<pixmapinproject/>
<layoutdefaults spacing="6" margin="11"/>
</UI>
<height>100</height>
</rect>
</property>
+ <property name="maximumSize">
+ <size>
+ <width>32767</width>
+ <height>110</height>
+ </size>
+ </property>
<property name="caption">
<string>Roids</string>
</property>
<property name="name">
<cstring>LineEdit27</cstring>
</property>
+ <property name="focusPolicy">
+ <enum>NoFocus</enum>
+ </property>
<property name="readOnly">
<bool>true</bool>
</property>
<property name="name">
<cstring>LineEdit28</cstring>
</property>
+ <property name="focusPolicy">
+ <enum>NoFocus</enum>
+ </property>
<property name="readOnly">
<bool>true</bool>
</property>
<property name="name">
<cstring>LineEdit30</cstring>
</property>
+ <property name="focusPolicy">
+ <enum>NoFocus</enum>
+ </property>
<property name="readOnly">
<bool>true</bool>
</property>
<property name="name">
<cstring>LineEdit33</cstring>
</property>
+ <property name="focusPolicy">
+ <enum>NoFocus</enum>
+ </property>
<property name="readOnly">
<bool>true</bool>
</property>