QTfrontend/model/MapModel.h
changeset 6983 ede55af89e78
parent 6952 7f70f37bbf08
child 8377 869f80966a77
equal deleted inserted replaced
6982:8d41d22a291d 6983:ede55af89e78
    25 #define HEDGEWARS_MAPMODEL_H
    25 #define HEDGEWARS_MAPMODEL_H
    26 
    26 
    27 #include <QStandardItemModel>
    27 #include <QStandardItemModel>
    28 #include <QStringList>
    28 #include <QStringList>
    29 #include <QTextStream>
    29 #include <QTextStream>
       
    30 #include <QHash>
    30 #include <QMap>
    31 #include <QMap>
    31 #include <QIcon>
    32 #include <QIcon>
    32 #include <QComboBox>
    33 #include <QComboBox>
    33 
    34 
    34 #include "DataManager.h"
    35 #include "DataManager.h"
    63             QString scheme; ///< Default scheme name or "locked", for mission-maps.
    64             QString scheme; ///< Default scheme name or "locked", for mission-maps.
    64             QString weapons; ///< Default weaponset name or "locked", for missions-maps.
    65             QString weapons; ///< Default weaponset name or "locked", for missions-maps.
    65         };
    66         };
    66 
    67 
    67         /**
    68         /**
    68          * @brief Returns the number of available maps of a specified type.
    69          * @brief Returns the row-index of the given map.
    69          * @param type map type to get the count of.
    70          * @param map map of which to get the row-index of.
    70          * @return count of maps that have the specified type.
    71          * @return row-index of map or -1 if not available.
    71          */
    72          */
    72         int mapCount(MapType type) const;
    73         int indexOf(const QString & map) const;
    73 
    74 
    74         /**
    75         /**
    75          * @brief Returns the row-index of a random map with a specified type.
    76          * @brief Returns the row-index of a random map with a specified type.
    76          * @param type desired type of map.
    77          * @param type desired type of map.
    77          * @return row-index of a map with the desired type, -1 if none found.
    78          * @return row-index of a map with the desired type, -1 if none found.
    78          */
    79          */
    79         int randomMap(MapType type) const;
    80         int randomMap(MapType type) const;
    80 
    81 
    81 
       
    82     public slots:
    82     public slots:
    83         /// Reloads the maps using the DataManager.
    83         /// Reloads the maps using the DataManager.
    84         void loadMaps();
    84         void loadMaps();
    85 
    85 
    86 
    86 
    87     private:
    87     private:
    88         /// start-index and map count for each map-type.
    88         /// start-index and map count for each map-type.
    89         QMap<MapType, QPair<int,int> > typeLoc;
    89         QMap<MapType, QPair<int,int> > m_typeLoc;
       
    90 
       
    91         /// map index lookup table
       
    92         QHash<QString, int> m_mapIndexes;
    90 
    93 
    91         /**
    94         /**
    92          * @brief Creates a QStandardItem, that holds the map info and item appearance.
    95          * @brief Creates a QStandardItem, that holds the map info and item appearance.
    93          * The used role for the data is Qt::UserRole + 1.
    96          * The used role for the data is Qt::UserRole + 1.
    94          * @param icon the icon to be displayed (can be an empty QIcon()).
    97          * @param icon the icon to be displayed (can be an empty QIcon()).