# HG changeset patch # User unc0rr # Date 1236781948 0 # Node ID 40e59e9f82ce80ed6276f4e60e5ac11d70305e9c # Parent 7c7476f561142b46928746da5818001dbecb2a58 Continue work on new schemes implementation diff -r 7c7476f56114 -r 40e59e9f82ce QTfrontend/ammoSchemeModel.cpp --- a/QTfrontend/ammoSchemeModel.cpp Tue Mar 10 21:57:33 2009 +0000 +++ b/QTfrontend/ammoSchemeModel.cpp Wed Mar 11 14:32:28 2009 +0000 @@ -22,7 +22,16 @@ AmmoSchemeModel::AmmoSchemeModel(QObject* parent) : QAbstractTableModel(parent) { + defaultScheme + << "Default" + << "45" + << "0" + << "0" + << "0" + << "0" + ; + schemes.append(defaultScheme); } QVariant AmmoSchemeModel::headerData(int section, Qt::Orientation orientation, int role) const @@ -43,7 +52,7 @@ if (parent.isValid()) return 0; else - return 3; + return defaultScheme.size(); } Qt::ItemFlags AmmoSchemeModel::flags(const QModelIndex & index) const @@ -56,5 +65,42 @@ bool AmmoSchemeModel::setData(const QModelIndex & index, const QVariant & value, int role) { + if (!index.isValid() || index.row() < 0 + || index.row() >= schemes.size() + || index.column() >= defaultScheme.size() + || role != Qt::DisplayRole) + return false; + + schemes[index.row()][index.column()] = value.toString(); emit dataChanged(index, index); + return true; } + +bool AmmoSchemeModel::insertRows(int row, int count, const QModelIndex & parent) +{ + beginInsertRows(parent, row, row); + + schemes.insert(row, defaultScheme); + + endInsertRows(); +} + +bool AmmoSchemeModel::removeRows(int row, int count, const QModelIndex & parent) +{ + beginRemoveRows(parent, row, row); + + schemes.removeAt(row); + + endRemoveRows(); +} + +QVariant AmmoSchemeModel::data(const QModelIndex &index, int role) const +{ + if (!index.isValid() || index.row() < 0 + || index.row() >= schemes.size() + || index.column() >= defaultScheme.size() + || role != Qt::DisplayRole) + return QVariant(); + + return schemes[index.row()][index.column()]; +} diff -r 7c7476f56114 -r 40e59e9f82ce QTfrontend/ammoSchemeModel.h --- a/QTfrontend/ammoSchemeModel.h Tue Mar 10 21:57:33 2009 +0000 +++ b/QTfrontend/ammoSchemeModel.h Wed Mar 11 14:32:28 2009 +0000 @@ -34,12 +34,18 @@ int columnCount(const QModelIndex & parent) const; Qt::ItemFlags flags(const QModelIndex & index) const; bool setData(const QModelIndex & index, const QVariant & value, int role = Qt::EditRole); + bool insertRows(int row, int count, const QModelIndex & parent = QModelIndex()); + bool removeRows(int row, int count, const QModelIndex & parent = QModelIndex()); + QVariant data(const QModelIndex &index, int role) const; signals: void dataChanged(const QModelIndex & topLeft, const QModelIndex & bottomRight); protected: QList schemes; + +private: + QStringList defaultScheme; }; #endif // _AMMO_SCHEME_MODEL_INCLUDED diff -r 7c7476f56114 -r 40e59e9f82ce QTfrontend/gamecfgwidget.cpp --- a/QTfrontend/gamecfgwidget.cpp Tue Mar 10 21:57:33 2009 +0000 +++ b/QTfrontend/gamecfgwidget.cpp Wed Mar 11 14:32:28 2009 +0000 @@ -23,10 +23,12 @@ #include #include #include +#include #include "gamecfgwidget.h" #include "igbox.h" #include "hwconsts.h" +#include "ammoSchemeModel.h" GameCFGWidget::GameCFGWidget(QWidget* parent, bool externalControl) : QGroupBox(parent), mainLayout(this) @@ -42,10 +44,14 @@ mainLayout.addWidget(GBoxOptions); QGridLayout *GBoxOptionsLayout = new QGridLayout(GBoxOptions); + + QTableView * tv = new QTableView(this); + tv->setModel(new AmmoSchemeModel); + GBoxOptionsLayout->addWidget(tv, 0, 0, 1, 2); CB_mode_Forts = new QCheckBox(GBoxOptions); CB_mode_Forts->setText(QCheckBox::tr("Forts mode")); - GBoxOptionsLayout->addWidget(CB_mode_Forts, 0, 0, 1, 2); + GBoxOptionsLayout->addWidget(CB_mode_Forts, 9, 0, 1, 2); CB_teamsDivide = new QCheckBox(GBoxOptions); CB_teamsDivide->setText(QCheckBox::tr("Divide teams")); diff -r 7c7476f56114 -r 40e59e9f82ce QTfrontend/hwform.h --- a/QTfrontend/hwform.h Tue Mar 10 21:57:33 2009 +0000 +++ b/QTfrontend/hwform.h Wed Mar 11 14:32:28 2009 +0000 @@ -115,7 +115,8 @@ ID_PAGE_NETSERVER = 12, ID_PAGE_INGAME = 13, ID_PAGE_ROOMSLIST = 14, - ID_PAGE_CONNECTING = 15 + ID_PAGE_CONNECTING = 15, + ID_PAGE_SCHEME = 16 }; HWGame * game; HWTeam * editedTeam; diff -r 7c7476f56114 -r 40e59e9f82ce QTfrontend/pages.cpp --- a/QTfrontend/pages.cpp Tue Mar 10 21:57:33 2009 +0000 +++ b/QTfrontend/pages.cpp Wed Mar 11 14:32:28 2009 +0000 @@ -843,3 +843,9 @@ { QGridLayout * pageLayout = new QGridLayout(this); } + +PageScheme::PageScheme(QWidget* parent) : + AbstractPage(parent) +{ + QGridLayout * pageLayout = new QGridLayout(this); +} diff -r 7c7476f56114 -r 40e59e9f82ce QTfrontend/pages.h --- a/QTfrontend/pages.h Tue Mar 10 21:57:33 2009 +0000 +++ b/QTfrontend/pages.h Wed Mar 11 14:32:28 2009 +0000 @@ -395,4 +395,12 @@ PageConnecting(QWidget* parent = 0); }; +class PageScheme : public AbstractPage +{ + Q_OBJECT + +public: + PageScheme(QWidget* parent = 0); +}; + #endif // PAGES_H diff -r 7c7476f56114 -r 40e59e9f82ce QTfrontend/ui_hwform.cpp --- a/QTfrontend/ui_hwform.cpp Tue Mar 10 21:57:33 2009 +0000 +++ b/QTfrontend/ui_hwform.cpp Wed Mar 11 14:32:28 2009 +0000 @@ -103,4 +103,7 @@ pageConnecting = new PageConnecting(); Pages->addWidget(pageConnecting); + + pageScheme = new PageScheme(); + Pages->addWidget(pageScheme); } diff -r 7c7476f56114 -r 40e59e9f82ce QTfrontend/ui_hwform.h --- a/QTfrontend/ui_hwform.h Tue Mar 10 21:57:33 2009 +0000 +++ b/QTfrontend/ui_hwform.h Wed Mar 11 14:32:28 2009 +0000 @@ -36,6 +36,7 @@ class PageInGame; class PageRoomsList; class PageConnecting; +class PageScheme; class QStackedLayout; class QFont; class QWidget; @@ -63,6 +64,7 @@ PageInGame *pageInGame; PageRoomsList *pageRoomsList; PageConnecting *pageConnecting; + PageScheme *pageScheme; QStackedLayout *Pages; QFont *font14;