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.
tdegames/konquest/scoredlg.cc

81 lines
2.5 KiB

#include <tqlayout.h>
#include <kapplication.h>
#include <klocale.h>
#include <kpushbutton.h>
#include <kstdguiitem.h>
#include "scoredlg.h"
ScoreDlgListViewItem::ScoreDlgListViewItem(TQListView *tqparent, TQString s1, TQString s2, TQString s3, TQString s4, TQString s5, TQString s6) : TQListViewItem(tqparent, s1, s2, s3, s4, s5, s6)
{
}
int ScoreDlgListViewItem::compare(TQListViewItem *i, int col, bool) const
{
if (col == 0)
{
if (text(col) > i -> text(col)) return 1;
else if (text(col) < i -> text(col)) return -1;
else return 0;
}
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);
}
}
ScoreDlg::ScoreDlg( TQWidget *tqparent, const TQString& title, PlayerList *players )
: TQDialog(tqparent, "ScoreDlg", true ), plrList(players)
{
setCaption( kapp->makeStdCaption(title) );
scoreTable = new KListView( this, 0 );
scoreTable->addColumn(i18n("Player"));
scoreTable->addColumn(i18n("Ships Built"));
scoreTable->addColumn(i18n("Planets Conquered"));
scoreTable->addColumn(i18n("Fleets Launched"));
scoreTable->addColumn(i18n("Fleets Destroyed"));
scoreTable->addColumn(i18n("Ships Destroyed"));
scoreTable->setMinimumSize( scoreTable->tqsizeHint() );
KPushButton *okButton = new KPushButton( KStdGuiItem::ok(), this );
okButton->setMinimumSize( okButton->tqsizeHint() );
okButton->setDefault(true);
TQVBoxLayout *tqlayout1 = new TQVBoxLayout( this );
TQHBoxLayout *tqlayout2 = new TQHBoxLayout;
tqlayout1->addWidget( scoreTable, 1 );
tqlayout1->addLayout( tqlayout2 );
tqlayout2->addStretch( 2 );
tqlayout2->addWidget( okButton );
tqlayout2->addStretch( 2 );
connect( okButton, TQT_SIGNAL(clicked()), this, TQT_SLOT(accept()) );
init();
resize( 580, 140 );
}
void
ScoreDlg::init()
{
Player *curPlayer;
PlayerListIterator itr( *plrList );
for( ;(curPlayer = itr()); )
new ScoreDlgListViewItem(scoreTable,
curPlayer->getName(),
TQString("%1").tqarg(curPlayer->getShipsBuilt()),
TQString("%1").tqarg(curPlayer->getPlanetsConquered()),
TQString("%1").tqarg(curPlayer->getFleetsLaunched()),
TQString("%1").tqarg(curPlayer->getEnemyFleetsDestroyed()),
TQString("%1").tqarg(curPlayer->getEnemyShipsDestroyed()));
}