1
#include "levelselector.h"
9
#include <qpushbutton.h>
11
LevelSelector::LevelSelector(bool ro, QWidget *parent, const char *name)
12
: QDialog(parent, name, true)
16
QPushButton *ok, *cancel;
18
combo = new QComboBox(this);
19
//if(ro) combo->setReadOnly(true);
21
desc = new QTextEdit(this);
22
desc->setReadOnly(true);
24
if(!ro) ok = new QPushButton(i18n("Play"), this);
25
else ok = new QPushButton(i18n("Close"), this);
26
if(!ro) cancel = new QPushButton(i18n("Cancel"), this);
29
lay = new QVBoxLayout(this, 5);
32
lay2 = new QHBoxLayout(lay, 5);
34
if(!ro) lay2->add(cancel);
36
if(!ro) connect(ok, SIGNAL(clicked()), SLOT(accept()));
37
else connect(ok, SIGNAL(clicked()), SLOT(close()));
38
if(!ro) connect(cancel, SIGNAL(clicked()), SLOT(reject()));
39
connect(combo, SIGNAL(activated(int)), SLOT(slotActivated(int)));
41
if(!ro) setCaption(i18n("Select a level"));
42
else setCaption(i18n("Level information"));
45
LevelSelector::~LevelSelector()
49
void LevelSelector::accept()
55
void LevelSelector::slotActivated(int id)
57
QString level, author, version;
58
int width, height, players;
61
level = combo->currentText();
68
for(Level *l = m_levels.first(); l; l = m_levels.next())
69
if(l->title() == level)
72
version = l->version();
75
players = l->players();
78
text = i18n("Level: <i>%1</i><br>Author: <i>%2</i><br>Version: <i>%3</i><br>").arg(level).arg(author).arg(version);
79
text += i18n("Width: <i>%1</i><br>Height: <i>%2</i><br>Players: <i>%3</i>").arg(width).arg(height).arg(players);
84
void LevelSelector::addLevel(Level *level)
86
combo->insertItem(level->title());
87
m_levels.append(level);
92
QString LevelSelector::level()
94
return combo->currentText();