23 #include "maplistpanel.h"
24 #include "ui_maplistpanel.h"
27 #include "plugins/engineplugin.h"
28 #include "serverapi/gamecreateparams.h"
29 #include "commongui.h"
30 #include <QStandardItemModel>
32 DClass<MapListPanel> :
public Ui::MapListPanel
42 d->lstMaplist->setModel(
new QStandardItemModel(
this));
43 this->connect(QApplication::instance(), SIGNAL(focusChanged(QWidget*, QWidget*)),
44 SLOT(onFocusChanged(QWidget*, QWidget*)));
47 MapListPanel::~MapListPanel()
51 void MapListPanel::addMapFromEditBoxToList()
53 addMapToMaplist(d->leMapname->text().trimmed());
56 void MapListPanel::addMapToMaplist(
const QString &map)
62 QStandardItemModel* model =
static_cast<QStandardItemModel*
>(d->lstMaplist->model());
63 QStandardItem* it =
new QStandardItem(map);
64 it->setDragEnabled(
true);
65 it->setDropEnabled(
false);
69 void MapListPanel::onFocusChanged(QWidget* old, QWidget* now)
71 if (now == d->leMapname)
73 d->btnAddMapToMaplist->setDefault(
true);
75 else if (old == d->leMapname)
77 d->btnAddMapToMaplist->setDefault(
false);
81 void MapListPanel::removeSelectedFromList()
83 const bool bSelectNextLowest =
true;
90 params.setRandomMapRotation(d->cbRandomMapRotation->isChecked());
93 void MapListPanel::loadConfig(
Ini &config)
96 QStringList stringList = section[
"maplist"].valueString().split(
";");
97 QAbstractItemModel *model = d->lstMaplist->model();
98 model->removeRows(0, model->rowCount());
99 foreach(QString s, stringList)
103 d->cbRandomMapRotation->setChecked(section[
"randomMapRotation"]);
106 void MapListPanel::saveConfig(
Ini &config)
110 section[
"maplist"] = stringList.join(
";");
111 section[
"randomMapRotation"] = d->cbRandomMapRotation->isChecked();
114 void MapListPanel::setupForEngine(
const EnginePlugin *engine)
116 d->cbRandomMapRotation->setVisible(engine->data()->supportsRandomMapRotation);
static QStringList listViewStandardItemsToStringList(QListView *listview)
Reads items from a QListView that uses QStandardItemModel and puts texts of these items into a list o...
Game parametrization data used when creating new games.
static void removeSelectedRowsFromStandardItemView(QAbstractItemView *view, bool bSelectNextItem=false)
Removes all selected rows from a QAbstractItemView.
INI section representation.
IniSection section(const QString &name)
Access configuration file section.