QTfrontend/model/MapModel.h
changeset 8377 869f80966a77
parent 6983 ede55af89e78
child 8419 d99f46b676b5
equal deleted inserted replaced
8376:c11cc7246df7 8377:869f80966a77
    61             QString name; ///< The internal name.
    61             QString name; ///< The internal name.
    62             QString theme; ///< The theme to be used. (can be empty)
    62             QString theme; ///< The theme to be used. (can be empty)
    63             quint32 limit; ///< The maximum allowed number of hedgehogs.
    63             quint32 limit; ///< The maximum allowed number of hedgehogs.
    64             QString scheme; ///< Default scheme name or "locked", for mission-maps.
    64             QString scheme; ///< Default scheme name or "locked", for mission-maps.
    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         };
    67         };
    67 
    68 
    68         /**
    69         /**
    69          * @brief Returns the row-index of the given map.
    70          * @brief Searches maps in model to find out if one exists
    70          * @param map map of which to get the row-index of.
    71          * @param map map of which to check existence
    71          * @return row-index of map or -1 if not available.
    72          * @return true if it exists
    72          */
    73          */
    73         int indexOf(const QString & map) const;
    74         bool mapExists(const QString & map) const;
    74 
    75 
    75         /**
    76         /**
    76          * @brief Returns the row-index of a random map with a specified type.
    77          * @brief Finds a map index (column, row) for a map name
    77          * @param type desired type of map.
    78          * @param map map of which to find index+column
    78          * @return row-index of a map with the desired type, -1 if none found.
    79          * @return QPair<int, int> with column, index, or (-1, -1) if map not found
    79          */
    80          */
    80         int randomMap(MapType type) const;
    81         //QPair<int, int> findMap(const QString & map) const;
       
    82 
       
    83         /**
       
    84          * @brief Finds a map index for a map name
       
    85          * @param map map of which to find index
       
    86          * @return int of index, or -1 if map not found
       
    87          */
       
    88         int findMap(const QString & map) const;
       
    89 
       
    90         /**
       
    91          * @brief Finds and returns a map item for a map name
       
    92          * @param map map
       
    93          * @return QStandardItem of map, or NULL if map not found
       
    94          */
       
    95         QStandardItem * getMap(const QString & map);
       
    96 
       
    97         // Static MapInfos for drawn and generated maps
       
    98         static MapInfo MapInfoRandom, MapInfoMaze, MapInfoDrawn;
    81 
    99 
    82     public slots:
   100     public slots:
    83         /// Reloads the maps using the DataManager.
   101         /// Reloads the maps using the DataManager.
    84         void loadMaps();
   102         /// Accepts two map types: StaticMap or MissionMap.
       
   103         void loadMaps(MapType maptype);
    85 
   104 
    86 
   105 
    87     private:
   106     private:
    88         /// start-index and map count for each map-type.
   107         /// map index lookup table. QPair<int, int> contains: <column, index>
    89         QMap<MapType, QPair<int,int> > m_typeLoc;
   108         //QHash<QString, QPair<int, int> > m_mapIndexes;
    90 
       
    91         /// map index lookup table
       
    92         QHash<QString, int> m_mapIndexes;
   109         QHash<QString, int> m_mapIndexes;
    93 
   110 
    94         /**
   111         /**
    95          * @brief Creates a QStandardItem, that holds the map info and item appearance.
   112          * @brief Creates a QStandardItem, that holds the map info and item appearance.
    96          * The used role for the data is Qt::UserRole + 1.
   113          * The used role for the data is Qt::UserRole + 1.
   100          * @param name the internal name of the map.
   117          * @param name the internal name of the map.
   101          * @param theme the theme of the map (or empty if none).
   118          * @param theme the theme of the map (or empty if none).
   102          * @param limit the hedgehog limit of the map.
   119          * @param limit the hedgehog limit of the map.
   103          * @param scheme mission map: default scheme name or "locked".
   120          * @param scheme mission map: default scheme name or "locked".
   104          * @param weapons mission map: default weaponset name or "locked".
   121          * @param weapons mission map: default weaponset name or "locked".
       
   122          * @param desc mission map: description of mission.
   105          * @return pointer to item representing the map info: at Qt::UserRole + 1.
   123          * @return pointer to item representing the map info: at Qt::UserRole + 1.
   106          */
   124          */
   107         QStandardItem * infoToItem(
   125         static QStandardItem * infoToItem(
   108             const QIcon & icon,
   126             const QIcon & icon,
   109             const QString caption,
   127             const QString caption,
   110             MapType type = Invalid,
   128             MapType type = Invalid,
   111             QString name = "",
   129             QString name = "",
   112             QString theme = "",
   130             QString theme = "",
   113             quint32 limit = 0,
   131             quint32 limit = 0,
   114             QString scheme = "",
   132             QString scheme = "",
   115             QString weapons = "") const;
   133             QString weapons = "",
       
   134             QString desc = "");
   116 };
   135 };
   117 
   136 
   118 Q_DECLARE_METATYPE(MapModel::MapInfo)
   137 Q_DECLARE_METATYPE(MapModel::MapInfo)
   119 
   138 
   120 #endif // HEDGEWARS_MAPMODEL_H
   139 #endif // HEDGEWARS_MAPMODEL_H