# HG changeset patch # User unc0rr # Date 1339955149 -14400 # Node ID 722e8a0d89dc71d0d708beb937ac69ee166bedd0 # Parent 5b97b9946cdeb09de888daf11f60d628e230146f - Move colorsModel to appropriate place - Less includes in DataManager.h diff -r 5b97b9946cde -r 722e8a0d89dc QTfrontend/game.cpp --- a/QTfrontend/game.cpp Sun Jun 17 16:32:44 2012 +0200 +++ b/QTfrontend/game.cpp Sun Jun 17 21:45:49 2012 +0400 @@ -21,6 +21,7 @@ #include #include #include +#include #include "game.h" #include "hwconsts.h" @@ -29,8 +30,7 @@ #include "teamselect.h" #include "KB.h" #include "proto.h" - -#include +#include "ThemeModel.h" QString training, campaign; // TODO: Cleaner solution? diff -r 5b97b9946cde -r 722e8a0d89dc QTfrontend/hwconsts.cpp.in --- a/QTfrontend/hwconsts.cpp.in Sun Jun 17 16:32:44 2012 +0200 +++ b/QTfrontend/hwconsts.cpp.in Sun Jun 17 21:45:49 2012 +0400 @@ -72,19 +72,3 @@ int season = SEASON_NONE; int years_since_foundation = 0; - -QStandardItemModel * colorsModel; - -void hwConstsInit() -{ - colorsModel = new QStandardItemModel(); - - int i = 0; - while(colors[i]) - { - QStandardItem * item = new QStandardItem(); - item->setData(QColor(colors[i])); - colorsModel->appendRow(item); - ++i; - } -} diff -r 5b97b9946cde -r 722e8a0d89dc QTfrontend/hwconsts.h --- a/QTfrontend/hwconsts.h Sun Jun 17 16:32:44 2012 +0200 +++ b/QTfrontend/hwconsts.h Sun Jun 17 21:45:49 2012 +0400 @@ -44,8 +44,7 @@ extern int cAmmoNumber; extern QList< QPair > cDefaultAmmos; -//extern unsigned int colors[]; -extern QStandardItemModel * colorsModel; +extern unsigned int colors[]; extern QString * netHost; extern quint16 netPort; @@ -60,8 +59,6 @@ //Could be used to implement a text/graphic like "This is the xxth birthday of hedgewars" or similar extern int years_since_foundation; -void hwConstsInit(); - #endif #define HEDGEHOGS_PER_TEAM 8 diff -r 5b97b9946cde -r 722e8a0d89dc QTfrontend/main.cpp --- a/QTfrontend/main.cpp Sun Jun 17 16:32:44 2012 +0200 +++ b/QTfrontend/main.cpp Sun Jun 17 21:45:49 2012 +0400 @@ -104,8 +104,6 @@ { HWApplication app(argc, argv); - hwConstsInit(); - app.setAttribute(Qt::AA_DontShowIconsInMenus,false); QStringList arguments = app.arguments(); diff -r 5b97b9946cde -r 722e8a0d89dc QTfrontend/model/GameStyleModel.cpp --- a/QTfrontend/model/GameStyleModel.cpp Sun Jun 17 16:32:44 2012 +0200 +++ b/QTfrontend/model/GameStyleModel.cpp Sun Jun 17 21:45:49 2012 +0400 @@ -21,6 +21,8 @@ * @brief GameStyleModel class implementation */ +#include + #include "GameStyleModel.h" diff -r 5b97b9946cde -r 722e8a0d89dc QTfrontend/model/roomslistmodel.cpp --- a/QTfrontend/model/roomslistmodel.cpp Sun Jun 17 16:32:44 2012 +0200 +++ b/QTfrontend/model/roomslistmodel.cpp Sun Jun 17 21:45:49 2012 +0400 @@ -21,12 +21,13 @@ * @brief RoomsListModel class implementation */ -#include "roomslistmodel.h" - #include #include #include +#include "roomslistmodel.h" +#include "MapModel.h" + RoomsListModel::RoomsListModel(QObject *parent) : QAbstractTableModel(parent), c_nColumns(8) diff -r 5b97b9946cde -r 722e8a0d89dc QTfrontend/team.cpp --- a/QTfrontend/team.cpp Sun Jun 17 16:32:44 2012 +0200 +++ b/QTfrontend/team.cpp Sun Jun 17 21:45:49 2012 +0400 @@ -26,6 +26,7 @@ #include "team.h" #include "hwform.h" +#include "DataManager.h" HWTeam::HWTeam(const QString & teamname) : QObject(0) @@ -351,12 +352,12 @@ QColor HWTeam::qcolor() const { - return colorsModel->item(m_color)->data().value(); + return DataManager::instance().colorsModel()->item(m_color)->data().value(); } void HWTeam::setColor(int color) { - m_color = color % colorsModel->rowCount(); + m_color = color % DataManager::instance().colorsModel()->rowCount(); } diff -r 5b97b9946cde -r 722e8a0d89dc QTfrontend/ui/page/pageeditteam.cpp --- a/QTfrontend/ui/page/pageeditteam.cpp Sun Jun 17 16:32:44 2012 +0200 +++ b/QTfrontend/ui/page/pageeditteam.cpp Sun Jun 17 21:45:49 2012 +0400 @@ -32,6 +32,7 @@ #include "HWApplication.h" #include "DataManager.h" +#include "HatModel.h" #include "pageeditteam.h" diff -r 5b97b9946cde -r 722e8a0d89dc QTfrontend/ui/widget/frameTeam.cpp --- a/QTfrontend/ui/widget/frameTeam.cpp Sun Jun 17 16:32:44 2012 +0200 +++ b/QTfrontend/ui/widget/frameTeam.cpp Sun Jun 17 21:45:49 2012 +0400 @@ -25,6 +25,7 @@ #include "frameTeam.h" #include "teamselhelper.h" #include "hwconsts.h" +#include "DataManager.h" FrameTeams::FrameTeams(QWidget* parent) : QFrame(parent), maxHedgehogsPerGame(48), overallHedgehogs(0), mainLayout(this), nonInteractive(false) @@ -54,12 +55,12 @@ void FrameTeams::resetColors() { - currentColor = colorsModel->rowCount() - 1; // ensure next color is the first one + currentColor = DataManager::instance().colorsModel()->rowCount() - 1; // ensure next color is the first one } int FrameTeams::getNextColor() { - currentColor = (currentColor + 1) % colorsModel->rowCount(); + currentColor = (currentColor + 1) % DataManager::instance().colorsModel()->rowCount(); return currentColor; } diff -r 5b97b9946cde -r 722e8a0d89dc QTfrontend/ui/widget/gamecfgwidget.cpp --- a/QTfrontend/ui/widget/gamecfgwidget.cpp Sun Jun 17 16:32:44 2012 +0200 +++ b/QTfrontend/ui/widget/gamecfgwidget.cpp Sun Jun 17 21:45:49 2012 +0400 @@ -32,6 +32,7 @@ #include "hwconsts.h" #include "ammoSchemeModel.h" #include "proto.h" +#include "GameStyleModel.h" GameCFGWidget::GameCFGWidget(QWidget* parent) : QGroupBox(parent) diff -r 5b97b9946cde -r 722e8a0d89dc QTfrontend/ui/widget/mapContainer.cpp --- a/QTfrontend/ui/widget/mapContainer.cpp Sun Jun 17 16:32:44 2012 +0200 +++ b/QTfrontend/ui/widget/mapContainer.cpp Sun Jun 17 21:45:49 2012 +0400 @@ -36,6 +36,7 @@ #include "mapContainer.h" #include "igbox.h" #include "HWApplication.h" +#include "ThemeModel.h" HWMapContainer::HWMapContainer(QWidget * parent) : QWidget(parent), diff -r 5b97b9946cde -r 722e8a0d89dc QTfrontend/ui/widget/mapContainer.h --- a/QTfrontend/ui/widget/mapContainer.h Sun Jun 17 16:32:44 2012 +0200 +++ b/QTfrontend/ui/widget/mapContainer.h Sun Jun 17 21:45:49 2012 +0400 @@ -31,6 +31,7 @@ #include "hwmap.h" #include "drawmapscene.h" +#include "MapModel.h" class QPushButton; class IconedGroupBox; diff -r 5b97b9946cde -r 722e8a0d89dc QTfrontend/ui/widget/teamselhelper.cpp --- a/QTfrontend/ui/widget/teamselhelper.cpp Sun Jun 17 16:32:44 2012 +0200 +++ b/QTfrontend/ui/widget/teamselhelper.cpp Sun Jun 17 21:45:49 2012 +0400 @@ -28,6 +28,7 @@ #include "hwconsts.h" #include "frameTeam.h" #include "colorwidget.h" +#include "DataManager.h" void TeamLabel::teamButtonClicked() { @@ -69,7 +70,7 @@ if(m_isPlaying) { // team color - colorWidget = new ColorWidget(colorsModel, this); + colorWidget = new ColorWidget(DataManager::instance().colorsModel(), this); colorWidget->setMinimumWidth(26); colorWidget->setMaximumWidth(26); colorWidget->setMinimumHeight(26); diff -r 5b97b9946cde -r 722e8a0d89dc QTfrontend/util/DataManager.cpp --- a/QTfrontend/util/DataManager.cpp Sun Jun 17 16:32:44 2012 +0200 +++ b/QTfrontend/util/DataManager.cpp Sun Jun 17 21:45:49 2012 +0400 @@ -23,13 +23,17 @@ #include #include - +#include #include #include "hwconsts.h" #include "DataManager.h" +#include "GameStyleModel.h" +#include "HatModel.h" +#include "MapModel.h" +#include "ThemeModel.h" DataManager::DataManager() { @@ -42,6 +46,7 @@ m_hatModel = NULL; m_mapModel = NULL; m_themeModel = NULL; + m_colorsModel = NULL; } @@ -154,6 +159,25 @@ return m_themeModel; } +QStandardItemModel * DataManager::colorsModel() +{ + if(m_colorsModel == NULL) + { + m_colorsModel = new QStandardItemModel(); + + int i = 0; + while(colors[i]) + { + QStandardItem * item = new QStandardItem(); + item->setData(QColor(colors[i])); + m_colorsModel->appendRow(item); + ++i; + } + } + + return m_colorsModel; +} + void DataManager::reload() { m_gameStyleModel->loadGameStyles(); diff -r 5b97b9946cde -r 722e8a0d89dc QTfrontend/util/DataManager.h --- a/QTfrontend/util/DataManager.h Sun Jun 17 16:32:44 2012 +0200 +++ b/QTfrontend/util/DataManager.h Sun Jun 17 21:45:49 2012 +0400 @@ -26,21 +26,13 @@ #include #include - #include -#include "GameStyleModel.h" -#include "HatModel.h" -#include "MapModel.h" -#include "ThemeModel.h" - -class QDir; -class QFile; -class QStringList; class GameStyleModel; class HatModel; class MapModel; class ThemeModel; +class QStandardItemModel; /** * @brief Offers access to the data files of hedgewars. @@ -135,6 +127,8 @@ */ ThemeModel * themeModel(); + QStandardItemModel * colorsModel(); + public slots: /// Reloads data from storage. void reload(); @@ -163,6 +157,7 @@ HatModel * m_hatModel; ///< hat model instance MapModel * m_mapModel; ///< map model instance ThemeModel * m_themeModel; ///< theme model instance + QStandardItemModel * m_colorsModel; }; #endif // HEDGEWARS_DATAMANAGER_H