You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
89 lines
2.7 KiB
89 lines
2.7 KiB
13 years ago
|
#include <tqlayout.h>
|
||
12 years ago
|
#include <tdeapplication.h>
|
||
12 years ago
|
#include <tdelocale.h>
|
||
15 years ago
|
#include <math.h>
|
||
12 years ago
|
#include <tdeglobal.h>
|
||
15 years ago
|
#include <kpushbutton.h>
|
||
|
#include <kstdguiitem.h>
|
||
|
|
||
|
#include "fleetdlg.h"
|
||
|
|
||
14 years ago
|
FleetDlgListViewItem::FleetDlgListViewItem(TQListView *parent, TQString s1, TQString s2, TQString s3, TQString s4, TQString s5) : TQListViewItem(parent, s1, s2, s3, s4, s5)
|
||
15 years ago
|
{
|
||
|
}
|
||
|
|
||
15 years ago
|
int FleetDlgListViewItem::compare(TQListViewItem *i, int col, bool) const
|
||
15 years ago
|
{
|
||
|
if (col == 1)
|
||
|
{
|
||
|
if (text(col) > i -> text(col)) return 1;
|
||
|
else if (text(col) < i -> text(col)) return -1;
|
||
|
else return compare(i, 0, true);
|
||
|
}
|
||
|
else if (col == 3)
|
||
|
{
|
||
|
if (text(col).toDouble() > i -> text(col).toDouble()) return 1;
|
||
|
else if (text(col).toDouble() < i -> text(col).toDouble()) return -1;
|
||
|
else return compare(i, 0, true);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
if (text(col).toInt() > i -> text(col).toInt()) return 1;
|
||
|
else if (text(col).toInt() < i -> text(col).toInt()) return -1;
|
||
|
else return compare(i, 0, true);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
14 years ago
|
FleetDlg::FleetDlg( TQWidget *parent, AttackFleetList *fleets )
|
||
|
: TQDialog(parent, "FleetDlg", true ), fleetList(fleets)
|
||
15 years ago
|
{
|
||
|
setCaption( kapp->makeStdCaption(i18n("Fleet Overview")) );
|
||
|
|
||
12 years ago
|
fleetTable = new TDEListView( this, 0 );
|
||
15 years ago
|
fleetTable->addColumn(i18n("Fleet No."));
|
||
|
fleetTable->addColumn(i18n("Destination"));
|
||
|
fleetTable->addColumn(i18n("Ships"));
|
||
|
fleetTable->addColumn(i18n("Kill Percentage"));
|
||
|
fleetTable->addColumn(i18n("Arrival Turn"));
|
||
13 years ago
|
fleetTable->setMinimumSize( fleetTable->sizeHint() );
|
||
15 years ago
|
|
||
|
KPushButton *okButton = new KPushButton( KStdGuiItem::ok(), this );
|
||
13 years ago
|
okButton->setMinimumSize( okButton->sizeHint() );
|
||
15 years ago
|
okButton->setDefault(true);
|
||
|
|
||
13 years ago
|
TQVBoxLayout *layout1 = new TQVBoxLayout( this );
|
||
|
TQHBoxLayout *layout2 = new TQHBoxLayout;
|
||
15 years ago
|
|
||
13 years ago
|
layout1->addWidget( fleetTable, 1 );
|
||
|
layout1->addLayout( layout2 );
|
||
15 years ago
|
|
||
13 years ago
|
layout2->addStretch( 2 );
|
||
|
layout2->addWidget( okButton );
|
||
|
layout2->addStretch( 2 );
|
||
15 years ago
|
|
||
15 years ago
|
connect( okButton, TQT_SIGNAL(clicked()), this, TQT_SLOT(accept()) );
|
||
15 years ago
|
|
||
|
init();
|
||
|
|
||
|
resize( 580, 140 );
|
||
|
}
|
||
|
|
||
|
void
|
||
|
FleetDlg::init()
|
||
|
{
|
||
|
AttackFleet *curFleet;
|
||
|
AttackFleetListIterator nextFleet( *fleetList );
|
||
|
int fleetNumber = 0;
|
||
|
|
||
|
while( (curFleet = nextFleet())) {
|
||
|
fleetNumber++;
|
||
|
new FleetDlgListViewItem(fleetTable,
|
||
13 years ago
|
TQString("%1").arg(fleetNumber),
|
||
15 years ago
|
curFleet->destination->getName(),
|
||
13 years ago
|
TQString("%1").arg(curFleet->getShipCount()),
|
||
12 years ago
|
TQString("%1").arg(TDEGlobal::locale()->formatNumber(curFleet->killPercentage, 3)),
|
||
13 years ago
|
TQString("%1").arg((int)ceil(curFleet->arrivalTurn)));
|
||
15 years ago
|
}
|
||
|
}
|