QTfrontend/ui/page/pageeditteam.cpp
changeset 9511 1be565d7b4b7
parent 9080 9b42757d7e71
child 9738 18bb6d1fc9d9
--- a/QTfrontend/ui/page/pageeditteam.cpp	Wed Oct 09 20:25:16 2013 -0400
+++ b/QTfrontend/ui/page/pageeditteam.cpp	Thu Oct 10 15:05:51 2013 +0400
@@ -203,12 +203,18 @@
 {
     initPage();
 
-    QRegExp pngSuffix("\\.png$");
+    m_playerHash = "0000000000000000000000000000000000000000";
+    m_loaded = false;
+}
 
-    m_playerHash = "0000000000000000000000000000000000000000";
+void PageEditTeam::lazyLoad()
+{
+    if(m_loaded) return;
+    m_loaded = true;
+    qDebug("[LAZYNESS] PageEditTeam::lazyLoad()");
 
+    QRegExp pngSuffix("\\.png$");
     DataManager & dataMgr = DataManager::instance();
-
     QStringList list;
 
 
@@ -236,7 +242,7 @@
             pix = pix.copy(0, 0, 32, 32);
         QIcon icon(pix);
 
-        QString grave = QString(file).remove(pngSuffix);
+        QString grave = file.remove(pngSuffix);
 
         CBGrave->addItem(icon, grave);
     }
@@ -327,6 +333,8 @@
 void PageEditTeam::createTeam(const QString & name, const QString & playerHash)
 {
     m_playerHash = playerHash;
+    lazyLoad();
+
     HWTeam newTeam(name);
     loadTeam(newTeam);
 }
@@ -334,6 +342,8 @@
 void PageEditTeam::editTeam(const QString & name, const QString & playerHash)
 {
     m_playerHash = playerHash;
+    lazyLoad();
+
     HWTeam team(name);
     team.loadFromFile();
     loadTeam(team);