QTfrontend/model/gameSchemeModel.h
branchhedgeroid
changeset 15515 7030706266df
parent 13559 a5a8488e2485
equal deleted inserted replaced
7861:bc7b6aa5d67a 15515:7030706266df
       
     1 /*
       
     2  * Hedgewars, a free turn based strategy game
       
     3  * Copyright (c) 2004-2015 Andrey Korotaev <unC0Rr@gmail.com>
       
     4  *
       
     5  * This program is free software; you can redistribute it and/or modify
       
     6  * it under the terms of the GNU General Public License as published by
       
     7  * the Free Software Foundation; version 2 of the License
       
     8  *
       
     9  * This program is distributed in the hope that it will be useful,
       
    10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    12  * GNU General Public License for more details.
       
    13  *
       
    14  * You should have received a copy of the GNU General Public License
       
    15  * along with this program; if not, write to the Free Software
       
    16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
       
    17  */
       
    18 
       
    19 #ifndef _GAME_SCHEME_MODEL_INCLUDED
       
    20 #define _GAME_SCHEME_MODEL_INCLUDED
       
    21 
       
    22 #include <QAbstractTableModel>
       
    23 #include <QStringList>
       
    24 #include <QList>
       
    25 
       
    26 class GameSchemeModel : public QAbstractTableModel
       
    27 {
       
    28         Q_OBJECT
       
    29 
       
    30     public:
       
    31         GameSchemeModel(QObject * parent, const QString & fileName);
       
    32 
       
    33         QVariant headerData(int section, Qt::Orientation orientation, int role) const;
       
    34         int rowCount(const QModelIndex & parent) const;
       
    35         int columnCount(const QModelIndex & parent) const;
       
    36         bool hasScheme(QString name);
       
    37         bool hasScheme(QString name, int ignoreID);
       
    38         bool renameScheme(int index, QString newName);
       
    39         Qt::ItemFlags flags(const QModelIndex & index) const;
       
    40         bool setData(const QModelIndex & index, const QVariant & value, int role = Qt::EditRole);
       
    41         bool insertRows(int row, int count, const QModelIndex & parent = QModelIndex());
       
    42         bool removeRows(int row, int count, const QModelIndex & parent = QModelIndex());
       
    43         QVariant data(const QModelIndex &index, int role) const;
       
    44 
       
    45         int numberOfDefaultSchemes;
       
    46         QStringList predefSchemesNames;
       
    47         QStringList spNames;
       
    48 
       
    49     public slots:
       
    50         void Save();
       
    51 
       
    52     signals:
       
    53         void dataChanged(const QModelIndex &topLeft, const QModelIndex& bottomRight);
       
    54 
       
    55     protected:
       
    56         QList< QList<QVariant> > schemes;
       
    57 };
       
    58 
       
    59 class NetGameSchemeModel : public QAbstractTableModel
       
    60 {
       
    61         Q_OBJECT
       
    62 
       
    63     public:
       
    64         NetGameSchemeModel(QObject * parent);
       
    65 
       
    66         QVariant headerData(int section, Qt::Orientation orientation, int role) const;
       
    67         int rowCount(const QModelIndex & parent) const;
       
    68         int columnCount(const QModelIndex & parent) const;
       
    69         QVariant data(const QModelIndex &index, int role) const;
       
    70 
       
    71     public slots:
       
    72         void setNetSchemeConfig(QStringList cfg);
       
    73 
       
    74     private:
       
    75         QList<QVariant> netScheme;
       
    76 };
       
    77 
       
    78 #endif // _GAME_SCHEME_MODEL_INCLUDED