QTfrontend/model/ThemeModel.h
author sheepluva
Thu, 26 Apr 2012 16:15:37 +0200
changeset 6937 7f77fa908a4e
parent 6616 QTfrontend/model/themesmodel.h@f77bb02b669f
child 6948 7271ce89950f
permissions -rw-r--r--
messing with the theme model a bit (gets now auto-updated after DLC download too)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6937
7f77fa908a4e messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents: 6616
diff changeset
     1
/*
7f77fa908a4e messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents: 6616
diff changeset
     2
 * Hedgewars, a free turn based strategy game
7f77fa908a4e messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents: 6616
diff changeset
     3
 * Copyright (c) 2006-2007 Igor Ulyanov <iulyanov@gmail.com>
7f77fa908a4e messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents: 6616
diff changeset
     4
 * Copyright (c) 2007-2012 Andrey Korotaev <unC0Rr@gmail.com>
7f77fa908a4e messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents: 6616
diff changeset
     5
 *
7f77fa908a4e messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents: 6616
diff changeset
     6
 * This program is free software; you can redistribute it and/or modify
7f77fa908a4e messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents: 6616
diff changeset
     7
 * it under the terms of the GNU General Public License as published by
7f77fa908a4e messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents: 6616
diff changeset
     8
 * the Free Software Foundation; version 2 of the License
7f77fa908a4e messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents: 6616
diff changeset
     9
 *
7f77fa908a4e messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents: 6616
diff changeset
    10
 * This program is distributed in the hope that it will be useful,
7f77fa908a4e messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents: 6616
diff changeset
    11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
7f77fa908a4e messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents: 6616
diff changeset
    12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
7f77fa908a4e messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents: 6616
diff changeset
    13
 * GNU General Public License for more details.
7f77fa908a4e messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents: 6616
diff changeset
    14
 *
7f77fa908a4e messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents: 6616
diff changeset
    15
 * You should have received a copy of the GNU General Public License
7f77fa908a4e messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents: 6616
diff changeset
    16
 * along with this program; if not, write to the Free Software
7f77fa908a4e messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents: 6616
diff changeset
    17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
7f77fa908a4e messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents: 6616
diff changeset
    18
 */
7f77fa908a4e messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents: 6616
diff changeset
    19
7f77fa908a4e messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents: 6616
diff changeset
    20
/**
7f77fa908a4e messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents: 6616
diff changeset
    21
 * @file
7f77fa908a4e messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents: 6616
diff changeset
    22
 * @brief ThemeModel class definition
7f77fa908a4e messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents: 6616
diff changeset
    23
 */
7f77fa908a4e messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents: 6616
diff changeset
    24
7f77fa908a4e messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents: 6616
diff changeset
    25
#ifndef HEDGEWARS_THEMEMODEL_H
7f77fa908a4e messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents: 6616
diff changeset
    26
#define HEDGEWARS_THEMEMODEL_H
5289
9d18b61bd3eb - Implement ThemesModel (load theme icons once, store in memory, don't reload from disk every time selection changes)
unc0rr
parents:
diff changeset
    27
9d18b61bd3eb - Implement ThemesModel (load theme icons once, store in memory, don't reload from disk every time selection changes)
unc0rr
parents:
diff changeset
    28
#include <QAbstractListModel>
9d18b61bd3eb - Implement ThemesModel (load theme icons once, store in memory, don't reload from disk every time selection changes)
unc0rr
parents:
diff changeset
    29
#include <QStringList>
6937
7f77fa908a4e messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents: 6616
diff changeset
    30
#include <QMap>
7f77fa908a4e messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents: 6616
diff changeset
    31
#include <QIcon>
7f77fa908a4e messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents: 6616
diff changeset
    32
7f77fa908a4e messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents: 6616
diff changeset
    33
#include "DataManager.h"
5289
9d18b61bd3eb - Implement ThemesModel (load theme icons once, store in memory, don't reload from disk every time selection changes)
unc0rr
parents:
diff changeset
    34
6937
7f77fa908a4e messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents: 6616
diff changeset
    35
/**
7f77fa908a4e messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents: 6616
diff changeset
    36
 * @brief A model listing available themes
7f77fa908a4e messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents: 6616
diff changeset
    37
 */
7f77fa908a4e messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents: 6616
diff changeset
    38
class ThemeModel : public QAbstractListModel
5289
9d18b61bd3eb - Implement ThemesModel (load theme icons once, store in memory, don't reload from disk every time selection changes)
unc0rr
parents:
diff changeset
    39
{
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6061
diff changeset
    40
        Q_OBJECT
6937
7f77fa908a4e messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents: 6616
diff changeset
    41
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6061
diff changeset
    42
    public:
6937
7f77fa908a4e messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents: 6616
diff changeset
    43
        explicit ThemeModel(QObject *parent = 0);
5289
9d18b61bd3eb - Implement ThemesModel (load theme icons once, store in memory, don't reload from disk every time selection changes)
unc0rr
parents:
diff changeset
    44
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6061
diff changeset
    45
        int rowCount(const QModelIndex &parent = QModelIndex()) const;
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6061
diff changeset
    46
        QVariant data(const QModelIndex &index, int role) const;
5289
9d18b61bd3eb - Implement ThemesModel (load theme icons once, store in memory, don't reload from disk every time selection changes)
unc0rr
parents:
diff changeset
    47
9d18b61bd3eb - Implement ThemesModel (load theme icons once, store in memory, don't reload from disk every time selection changes)
unc0rr
parents:
diff changeset
    48
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6061
diff changeset
    49
    public slots:
6937
7f77fa908a4e messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents: 6616
diff changeset
    50
        /// reloads the themes from the DataManager
7f77fa908a4e messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents: 6616
diff changeset
    51
        void loadThemes();
7f77fa908a4e messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents: 6616
diff changeset
    52
5289
9d18b61bd3eb - Implement ThemesModel (load theme icons once, store in memory, don't reload from disk every time selection changes)
unc0rr
parents:
diff changeset
    53
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6061
diff changeset
    54
    private:
6937
7f77fa908a4e messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents: 6616
diff changeset
    55
        QList<QMap<int, QVariant> > m_data;
5289
9d18b61bd3eb - Implement ThemesModel (load theme icons once, store in memory, don't reload from disk every time selection changes)
unc0rr
parents:
diff changeset
    56
};
9d18b61bd3eb - Implement ThemesModel (load theme icons once, store in memory, don't reload from disk every time selection changes)
unc0rr
parents:
diff changeset
    57
6937
7f77fa908a4e messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents: 6616
diff changeset
    58
#endif // HEDGEWARS_THEMEMODEL_H