QTfrontend/model/ThemeModel.cpp
changeset 9745 258c320256dc
parent 9080 9b42757d7e71
child 9815 d4621fb76284
--- a/QTfrontend/model/ThemeModel.cpp	Tue Dec 03 23:54:58 2013 +0400
+++ b/QTfrontend/model/ThemeModel.cpp	Wed Dec 04 00:19:42 2013 +0400
@@ -29,6 +29,8 @@
     QAbstractListModel(parent)
 {
     m_data = QList<QMap<int, QVariant> >();
+
+    m_themesLoaded = false;
 }
 
 int ThemeModel::rowCount(const QModelIndex &parent) const
@@ -36,7 +38,11 @@
     if(parent.isValid())
         return 0;
     else
+    {
+        if(!m_themesLoaded)
+            loadThemes();
         return m_data.size();
+    }
 }
 
 
@@ -45,13 +51,21 @@
     if(index.column() > 0 || index.row() >= m_data.size())
         return QVariant();
     else
+    {
+        if(!m_themesLoaded)
+            loadThemes();
+
         return m_data.at(index.row()).value(role);
+    }
 }
 
 
-void ThemeModel::loadThemes()
+void ThemeModel::loadThemes() const
 {
-    beginResetModel();
+    qDebug("[LAZINESS ThemeModel::loadThemes()]");
+
+    m_themesLoaded = true;
+
 
     DataManager & datamgr = DataManager::instance();
 
@@ -94,7 +108,4 @@
 
         m_data.append(dataset);
     }
-
-
-    endResetModel();
 }