QTfrontend/model/MapModel.h
changeset 6938 217ed62e872c
child 6939 970389573788
equal deleted inserted replaced
6937:7f77fa908a4e 6938:217ed62e872c
       
     1 /*
       
     2  * Hedgewars, a free turn based strategy game
       
     3  * Copyright (c) 2006-2007 Igor Ulyanov <iulyanov@gmail.com>
       
     4  * Copyright (c) 2007-2012 Andrey Korotaev <unC0Rr@gmail.com>
       
     5  *
       
     6  * This program is free software; you can redistribute it and/or modify
       
     7  * it under the terms of the GNU General Public License as published by
       
     8  * the Free Software Foundation; version 2 of the License
       
     9  *
       
    10  * This program is distributed in the hope that it will be useful,
       
    11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    13  * GNU General Public License for more details.
       
    14  *
       
    15  * You should have received a copy of the GNU General Public License
       
    16  * along with this program; if not, write to the Free Software
       
    17  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
       
    18  */
       
    19 
       
    20 /**
       
    21  * @file
       
    22  * @brief MapModel class definition
       
    23  */
       
    24 
       
    25 #ifndef HEDGEWARS_MAPMODEL_H
       
    26 #define HEDGEWARS_MAPMODEL_H
       
    27 
       
    28 #include <QAbstractListModel>
       
    29 #include <QStringList>
       
    30 #include <QTextStream>
       
    31 #include <QMap>
       
    32 #include <QIcon>
       
    33 #include <QComboBox>
       
    34 
       
    35 #include "DataManager.h"
       
    36 
       
    37 /**
       
    38  * @brief A model listing available themes
       
    39  *
       
    40  * @author sheepluva
       
    41  * @since 0.9.18
       
    42  */
       
    43 class MapModel : public QAbstractListModel
       
    44 {
       
    45         Q_OBJECT
       
    46 
       
    47     public:
       
    48         enum MapType {
       
    49             Invalid,
       
    50             GeneratedMap,
       
    51             GeneratedMaze,
       
    52             HandDrawnMap,
       
    53             MissionMap,
       
    54             StaticMap
       
    55         };
       
    56 
       
    57         struct MapInfo
       
    58         {
       
    59             MapType type;
       
    60             QString name;
       
    61             QString theme;
       
    62             quint32 limit;
       
    63             QString scheme;
       
    64             QString weapons;
       
    65         };
       
    66 
       
    67         static MapInfo mapInfoFromData(const QVariant data); 
       
    68 
       
    69         explicit MapModel(QObject *parent = 0);
       
    70 
       
    71         int rowCount(const QModelIndex &parent = QModelIndex()) const;
       
    72         QVariant data(const QModelIndex &index, int role) const;
       
    73         int generatorCount() const;
       
    74         int missionCount() const;
       
    75 
       
    76 
       
    77     public slots:
       
    78         /// reloads the maps from the DataManager
       
    79         void loadMaps();
       
    80 
       
    81 
       
    82     private:
       
    83         QList<QMap<int, QVariant> > m_data;
       
    84         int m_nGenerators;
       
    85         int m_nMissions;
       
    86 };
       
    87 
       
    88 #endif // HEDGEWARS_MAPMODEL_H