QTfrontend/model/MapModel.h
changeset 9744 1ee4842a9c86
parent 9080 9b42757d7e71
child 9998 736015b847e3
equal deleted inserted replaced
9743:6e505ea936ad 9744:1ee4842a9c86
    65             QString weapons; ///< Default weaponset name or "locked", for missions-maps.
    65             QString weapons; ///< Default weaponset name or "locked", for missions-maps.
    66             QString desc; ///< The brief 1-2 sentence description of the mission, for mission-maps.
    66             QString desc; ///< The brief 1-2 sentence description of the mission, for mission-maps.
    67             bool dlc; ///< True if this map was not packaged with the game
    67             bool dlc; ///< True if this map was not packaged with the game
    68         };
    68         };
    69 
    69 
       
    70         MapModel(MapType maptype, QObject *parent = 0);
       
    71 
    70         /**
    72         /**
    71          * @brief Searches maps in model to find out if one exists
    73          * @brief Searches maps in model to find out if one exists
    72          * @param map map of which to check existence
    74          * @param map map of which to check existence
    73          * @return true if it exists
    75          * @return true if it exists
    74          */
    76          */
    75         bool mapExists(const QString & map) const;
    77         bool mapExists(const QString & map);
    76 
    78 
    77         /**
    79         /**
    78          * @brief Finds a map index (column, row) for a map name
    80          * @brief Finds a map index (column, row) for a map name
    79          * @param map map of which to find index+column
    81          * @param map map of which to find index+column
    80          * @return QPair<int, int> with column, index, or (-1, -1) if map not found
    82          * @return QPair<int, int> with column, index, or (-1, -1) if map not found
    84         /**
    86         /**
    85          * @brief Finds a map index for a map name
    87          * @brief Finds a map index for a map name
    86          * @param map map of which to find index
    88          * @param map map of which to find index
    87          * @return int of index, or -1 if map not found
    89          * @return int of index, or -1 if map not found
    88          */
    90          */
    89         int findMap(const QString & map) const;
    91         int findMap(const QString & map);
    90 
    92 
    91         /**
    93         /**
    92          * @brief Finds and returns a map item for a map name
    94          * @brief Finds and returns a map item for a map name
    93          * @param map map
    95          * @param map map
    94          * @return QStandardItem of map, or NULL if map not found
    96          * @return QStandardItem of map, or NULL if map not found
    96         QStandardItem * getMap(const QString & map);
    98         QStandardItem * getMap(const QString & map);
    97 
    99 
    98         // Static MapInfos for drawn and generated maps
   100         // Static MapInfos for drawn and generated maps
    99         static MapInfo MapInfoRandom, MapInfoMaze, MapInfoDrawn;
   101         static MapInfo MapInfoRandom, MapInfoMaze, MapInfoDrawn;
   100 
   102 
   101     public slots:
   103         /// Loads the maps
   102         /// Reloads the maps using the DataManager.
   104         bool loadMaps();
   103         /// Accepts two map types: StaticMap or MissionMap.
       
   104         void loadMaps(MapType maptype);
       
   105 
   105 
   106 
   106 
   107     private:
   107     private:
   108         /// map index lookup table. QPair<int, int> contains: <column, index>
   108         /// map index lookup table. QPair<int, int> contains: <column, index>
   109         //QHash<QString, QPair<int, int> > m_mapIndexes;
   109         //QHash<QString, QPair<int, int> > m_mapIndexes;
   110         QHash<QString, int> m_mapIndexes;
   110         QHash<QString, int> m_mapIndexes;
       
   111         MapType m_maptype;
       
   112         bool m_loaded;
   111 
   113 
   112         /**
   114         /**
   113          * @brief Creates a QStandardItem, that holds the map info and item appearance.
   115          * @brief Creates a QStandardItem, that holds the map info and item appearance.
   114          * The used role for the data is Qt::UserRole + 1.
   116          * The used role for the data is Qt::UserRole + 1.
   115          * @param icon the icon to be displayed (can be an empty QIcon()).
   117          * @param icon the icon to be displayed (can be an empty QIcon()).