rollback last commit (bad approach, as item index confusion can happen)
authorsheepluva
Thu, 28 Apr 2016 15:23:02 +0200
changeset 11759 2e4f0d0fec99
parent 11758 5c192a4751d8
child 11760 ae881363fc64
rollback last commit (bad approach, as item index confusion can happen)
QTfrontend/model/ThemeModel.cpp
QTfrontend/model/ThemeModel.h
QTfrontend/ui/widget/mapContainer.cpp
--- a/QTfrontend/model/ThemeModel.cpp	Thu Apr 28 02:06:35 2016 +0200
+++ b/QTfrontend/model/ThemeModel.cpp	Thu Apr 28 15:23:02 2016 +0200
@@ -31,21 +31,6 @@
     m_data = QList<QMap<int, QVariant> >();
 
     m_themesLoaded = false;
-
-    m_filteredNoDLC = NULL;
-}
-
-QSortFilterProxyModel * ThemeModel::withoutDLC()
-{
-    if (m_filteredNoDLC == NULL)
-    {
-        m_filteredNoDLC = new QSortFilterProxyModel(this);
-        m_filteredNoDLC->setSourceModel(this);
-        // filtering based on IsDlcRole would be nicer
-        // but seems this model can only do string-based filtering :|
-        m_filteredNoDLC->setFilterRegExp(QRegExp("^[^*]"));
-    }
-    return m_filteredNoDLC;
 }
 
 int ThemeModel::rowCount(const QModelIndex &parent) const
--- a/QTfrontend/model/ThemeModel.h	Thu Apr 28 02:06:35 2016 +0200
+++ b/QTfrontend/model/ThemeModel.h	Thu Apr 28 15:23:02 2016 +0200
@@ -25,7 +25,6 @@
 #define HEDGEWARS_THEMEMODEL_H
 
 #include <QAbstractListModel>
-#include <QSortFilterProxyModel>
 #include <QStringList>
 #include <QMap>
 #include <QIcon>
@@ -45,12 +44,10 @@
 
         int rowCount(const QModelIndex &parent = QModelIndex()) const;
         QVariant data(const QModelIndex &index, int role) const;
-        QSortFilterProxyModel * withoutDLC();
 
     private:
         mutable QList<QMap<int, QVariant> > m_data;
         mutable bool m_themesLoaded;
-        mutable QSortFilterProxyModel * m_filteredNoDLC;
 
         void loadThemes() const;
 };
--- a/QTfrontend/ui/widget/mapContainer.cpp	Thu Apr 28 02:06:35 2016 +0200
+++ b/QTfrontend/ui/widget/mapContainer.cpp	Thu Apr 28 15:23:02 2016 +0200
@@ -527,10 +527,9 @@
 
 void HWMapContainer::setRandomTheme()
 {
-    QAbstractItemModel * tmodel = m_themeModel->withoutDLC();
-    if(!tmodel->rowCount()) return;
-    quint32 themeNum = rand() % tmodel->rowCount();
-    updateTheme(tmodel->index(themeNum,0));
+    if(!m_themeModel->rowCount()) return;
+    quint32 themeNum = rand() % m_themeModel->rowCount();
+    updateTheme(m_themeModel->index(themeNum));
     emit themeChanged(m_theme);
 }