--- a/QTfrontend/model/MapModel.cpp Tue Dec 03 18:09:54 2013 +0100
+++ b/QTfrontend/model/MapModel.cpp Tue Dec 03 23:54:58 2013 +0400
@@ -32,8 +32,22 @@
MapModel::MapInfo MapModel::MapInfoMaze = {MapModel::GeneratedMaze, "+maze+", "", 0, "", "", "", false};
MapModel::MapInfo MapModel::MapInfoDrawn = {MapModel::HandDrawnMap, "+drawn+", "", 0, "", "", "", false};
-void MapModel::loadMaps(MapType maptype)
+
+MapModel::MapModel(MapType maptype, QObject *parent) : QStandardItemModel(parent)
{
+ m_maptype = maptype;
+ m_loaded = false;
+}
+
+bool MapModel::loadMaps()
+{
+ if(m_loaded)
+ return false;
+
+ m_loaded = true;
+
+ qDebug("[LAZINESS] MapModel::loadMaps()");
+
// this method resets the contents of this model (important to know for views).
beginResetModel();
@@ -75,7 +89,7 @@
MapType type = isMission ? MissionMap : StaticMap;
// if we're supposed to ignore this type, continue
- if (type != maptype) continue;
+ if (type != m_maptype) continue;
// load map info from file
QTextStream input(&mapCfgFile);
@@ -149,15 +163,19 @@
QStandardItemModel::appendColumn(mapList);
endResetModel();
+
+ return true;
}
-bool MapModel::mapExists(const QString & map) const
+bool MapModel::mapExists(const QString & map)
{
return findMap(map) >= 0;
}
-int MapModel::findMap(const QString & map) const
+int MapModel::findMap(const QString & map)
{
+ loadMaps();
+
return m_mapIndexes.value(map, -1);
}