Load hats into the model lazily
authorunc0rr
Mon, 02 Dec 2013 23:20:07 +0400
changeset 9738 18bb6d1fc9d9
parent 9737 f0769402350c
child 9739 c2c9dd2544b8
Load hats into the model lazily
QTfrontend/model/HatModel.cpp
QTfrontend/ui/page/pageeditteam.cpp
QTfrontend/ui/page/pageroomslist.cpp
QTfrontend/ui/page/pageroomslist.h
QTfrontend/ui/widget/hatbutton.cpp
QTfrontend/ui/widget/hatbutton.h
--- a/QTfrontend/model/HatModel.cpp	Mon Dec 02 17:13:22 2013 +0100
+++ b/QTfrontend/model/HatModel.cpp	Mon Dec 02 23:20:07 2013 +0400
@@ -37,6 +37,8 @@
 
 void HatModel::loadHats()
 {
+    qDebug("HatModel::loadHats()");
+
     // this method resets the contents of this model (important to know for views).
     QStandardItemModel::beginResetModel();
     QStandardItemModel::clear();
--- a/QTfrontend/ui/page/pageeditteam.cpp	Mon Dec 02 17:13:22 2013 +0100
+++ b/QTfrontend/ui/page/pageeditteam.cpp	Mon Dec 02 23:20:07 2013 +0400
@@ -211,7 +211,12 @@
 {
     if(m_loaded) return;
     m_loaded = true;
-    qDebug("[LAZYNESS] PageEditTeam::lazyLoad()");
+    qDebug("[LAZINESS] PageEditTeam::lazyLoad()");
+
+    HatModel * hatsModel = DataManager::instance().hatModel();
+    for(int i = 0; i < HEDGEHOGS_PER_TEAM; i++)
+        HHHats[i]->setModel(hatsModel);
+
 
     QRegExp pngSuffix("\\.png$");
     DataManager & dataMgr = DataManager::instance();
--- a/QTfrontend/ui/page/pageroomslist.cpp	Mon Dec 02 17:13:22 2013 +0100
+++ b/QTfrontend/ui/page/pageroomslist.cpp	Mon Dec 02 23:20:07 2013 +0400
@@ -169,11 +169,6 @@
     stateMenu->addAction(showGamesInProgress);
     btnState->setMenu(stateMenu);
 
-    // Clear filters button
-
-    BtnClear = addButton(tr("Clear filters"), filterLayout, 0);
-    BtnClear->setStyleSheet("padding: 4px;");
-
     // Lobby chat
 
     chatWidget = new HWChatWidget(this, false);
@@ -199,7 +194,6 @@
 
     connect(BtnCreate, SIGNAL(clicked()), this, SLOT(onCreateClick()));
     connect(BtnJoin, SIGNAL(clicked()), this, SLOT(onJoinClick()));
-    connect(BtnClear, SIGNAL(clicked()), this, SLOT(onClearClick()));
     connect(searchText, SIGNAL(moveUp()), this, SLOT(moveSelectionUp()));
     connect(searchText, SIGNAL(moveDown()), this, SLOT(moveSelectionDown()));
     connect(searchText, SIGNAL(returnPressed()), this, SLOT(onJoinClick()));
@@ -531,14 +525,6 @@
     emit askForRoomList();
 }
 
-void PageRoomsList::onClearClick()
-{
-    showGamesInLobby->setChecked(true);
-    showGamesInProgress->setChecked(true);
-    searchText->clear();
-    searchText->setFocus();
-}
-
 void PageRoomsList::onJoinConfirmation(const QString & room)
 {
 
--- a/QTfrontend/ui/page/pageroomslist.h	Mon Dec 02 17:13:22 2013 +0100
+++ b/QTfrontend/ui/page/pageroomslist.h	Mon Dec 02 23:20:07 2013 +0400
@@ -55,7 +55,6 @@
         QPushButton * BtnCreate;
         QPushButton * BtnJoin;
         QPushButton * BtnAdmin;
-        QPushButton * BtnClear;
         QComboBox * CBState;
         HWChatWidget * chatWidget;
         QLabel * lblCount;
@@ -82,7 +81,6 @@
         void onCreateClick();
         void onJoinClick();
         void onRefreshClick();
-        void onClearClick();
         void onJoinConfirmation(const QString &);
         void onSortIndicatorChanged(int logicalIndex, Qt::SortOrder order);
         void onFilterChanged();
--- a/QTfrontend/ui/widget/hatbutton.cpp	Mon Dec 02 17:13:22 2013 +0100
+++ b/QTfrontend/ui/widget/hatbutton.cpp	Mon Dec 02 23:20:07 2013 +0400
@@ -19,7 +19,6 @@
 #include <QDebug>
 
 #include "hatprompt.h"
-#include "DataManager.h"
 #include "HatModel.h"
 #include "hatbutton.h"
 
@@ -28,8 +27,13 @@
     setIconSize(QSize(32, 37));
     setFixedSize(44, 44);
 
-    m_hatModel = DataManager::instance().hatModel();
+    m_hatModel = 0;
     connect(this, SIGNAL(clicked()), this, SLOT(showPrompt()));
+}
+
+void HatButton::setModel(HatModel *model)
+{
+    m_hatModel = model;
 
     setCurrentIndex(0);
 }
--- a/QTfrontend/ui/widget/hatbutton.h	Mon Dec 02 17:13:22 2013 +0100
+++ b/QTfrontend/ui/widget/hatbutton.h	Mon Dec 02 23:20:07 2013 +0400
@@ -35,6 +35,7 @@
         HatButton(QWidget* parent);
         int currentIndex();
         QString currentHat() const;
+        void setModel(HatModel * model);
 
     private:
         QModelIndex m_hat;