QTfrontend/model/ammoSchemeModel.h
branchios-develop
changeset 13413 ba39a1d396c0
parent 13411 6e8b807bda4b
parent 13412 236cc4cf2448
equal deleted inserted replaced
13411:6e8b807bda4b 13413:ba39a1d396c0
     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 _AMMO_SCHEME_MODEL_INCLUDED
       
    20 #define _AMMO_SCHEME_MODEL_INCLUDED
       
    21 
       
    22 #include <QSettings>
       
    23 #include <QAbstractTableModel>
       
    24 #include <QStringList>
       
    25 #include <QList>
       
    26 
       
    27 class AmmoSchemeModel : public QAbstractTableModel
       
    28 {
       
    29         Q_OBJECT
       
    30 
       
    31     public:
       
    32         AmmoSchemeModel(QObject * parent, const QString & fileName);
       
    33 
       
    34         QVariant headerData(int section, Qt::Orientation orientation, int role) const;
       
    35         int rowCount(const QModelIndex & parent) const;
       
    36         int columnCount(const QModelIndex & parent) const;
       
    37         bool hasScheme(QString name);
       
    38         Qt::ItemFlags flags(const QModelIndex & index) const;
       
    39         bool setData(const QModelIndex & index, const QVariant & value, int role = Qt::EditRole);
       
    40         bool insertRows(int row, int count, const QModelIndex & parent = QModelIndex());
       
    41         bool removeRows(int row, int count, const QModelIndex & parent = QModelIndex());
       
    42         QVariant data(const QModelIndex &index, int role) const;
       
    43 
       
    44         int numberOfDefaultSchemes;
       
    45         QStringList predefSchemesNames;
       
    46         QStringList spNames;
       
    47 
       
    48     public slots:
       
    49         void Save();
       
    50 
       
    51 //    signals:
       
    52 //        void dataChanged(const QModelIndex & topLeft, const QModelIndex & bottomRight);
       
    53 
       
    54     protected:
       
    55         QList< QList<QVariant> > schemes;
       
    56 
       
    57     private:
       
    58         QSettings fileConfig;
       
    59 };
       
    60 
       
    61 class NetAmmoSchemeModel : public QAbstractTableModel
       
    62 {
       
    63         Q_OBJECT
       
    64 
       
    65     public:
       
    66         NetAmmoSchemeModel(QObject * parent);
       
    67 
       
    68         QVariant headerData(int section, Qt::Orientation orientation, int role) const;
       
    69         int rowCount(const QModelIndex & parent) const;
       
    70         int columnCount(const QModelIndex & parent) const;
       
    71         QVariant data(const QModelIndex &index, int role) const;
       
    72 
       
    73     public slots:
       
    74         void setNetSchemeConfig(QStringList cfg);
       
    75 
       
    76     private:
       
    77         QList<QVariant> netScheme;
       
    78 };
       
    79 
       
    80 #endif // _AMMO_SCHEME_MODEL_INCLUDED