1 /***************************************************************************
2 bcview.cpp - description
4 begin : Sun Jun 17 19:19:58 CEST 2001
5 copyright : (C) 2001 by Michael Andreen
7 ***************************************************************************/
9 /***************************************************************************
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
16 ***************************************************************************/
20 #include "battlesum.h"
22 #include "ui/infoview.h"
24 #include "ui/fleetviewbase.h"
27 #include <qlistview.h>
28 #include <qwidgetstack.h>
33 BSView::BSView(QWidget *parent, BSDoc *doc) : QSplitter(parent)
35 /** connect doc with the view*/
36 connect(doc, SIGNAL(documentChanged()), this, SLOT(slotDocumentChanged()));
39 m_LeftSplit = new QSplitter(QSplitter::Vertical, this);
40 m_RightSplit = new QSplitter(QSplitter::Vertical, this);
42 //setting up the listview
43 m_NumberView = new QListView(m_LeftSplit);
44 m_NumberView->addColumn("Name");
45 m_NumberView->addColumn("Number");
46 m_NumberView->addColumn("ETA");
49 m_InfoView = new InfoView(m_LeftSplit);
52 m_TickView = new TickView(m_RightSplit);
53 m_FleetViews = new QWidgetStack(m_RightSplit);
54 m_ScanView = new ScanView(m_RightSplit);
57 m_BattleSum = new BattleSum();
58 m_FleetViews->addWidget(m_BattleSum, 0);
59 m_FleetView = new FleetViewBase();
60 m_FleetViews->addWidget(m_FleetView, 1);
62 //m_FleetViews->raiseWidget(0);
63 connect(m_NumberView, SIGNAL(selectionChanged(QListViewItem *)), SLOT(slotFleetSelection(QListViewItem *)));
70 void BSView::addBattle(QString name)
72 QListViewItem* battle = new QListViewItem(m_NumberView, name);
73 QListViewItem* def = new QListViewItem(battle, tr("Defenders"),"", "","1");
74 (void) new QListViewItem(battle, tr("Attackers"),"", "","2");
75 (void) new QListViewItem(def, tr("Home Planet"), "","","1");
78 void BSView::slotDocumentChanged()
80 //TODO update the view
83 /** No descriptions */
84 void BSView::slotFleetSelection(QListViewItem *lvi)
86 //cout << lvi->parent()->text(2).toLocal8bit() << endl;
87 // for (int i = 0; i < 5; i++)
88 // cout << lvi->text(i).local8Bit() << endl;
91 if (lvi->parent() == '\0')
93 m_FleetViews->raiseWidget(0);
95 else if (lvi->parent()->parent() == '\0')
97 m_FleetView->slotHomePlanet(false);
98 if (lvi->text(3) == "1")
100 m_FleetView->slotAttacker(false);
104 m_FleetView->slotAttacker(true);
106 m_FleetViews->raiseWidget(1);
111 if (lvi->parent()->text(3) == "1")
113 m_FleetView->slotAttacker(false);
114 m_FleetView->slotHomePlanet(false);
115 if (lvi->text(3) == "1")
117 m_FleetView->slotHomePlanet(true);
122 m_FleetView->slotAttacker(true);
123 m_FleetView->slotHomePlanet(false);
125 m_FleetViews->raiseWidget(1);