From 5359f4499a298f8997d839804cc2497882551125 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Thu, 2 Apr 2015 20:18:06 +0200 Subject: NOISSUE remove obsolete EnabledItemFilter model --- CMakeLists.txt | 2 -- gui/pages/LegacyUpgradePage.h | 1 - gui/pages/LogPage.h | 2 -- gui/pages/ModFolderPage.h | 1 - gui/pages/NotesPage.h | 1 - gui/pages/VersionPage.cpp | 8 ++------ gui/pages/VersionPage.h | 2 -- logic/EnabledItemFilter.cpp | 43 ------------------------------------------- logic/EnabledItemFilter.h | 32 -------------------------------- 9 files changed, 2 insertions(+), 90 deletions(-) delete mode 100644 logic/EnabledItemFilter.cpp delete mode 100644 logic/EnabledItemFilter.h diff --git a/CMakeLists.txt b/CMakeLists.txt index bc2d9daf..b6230766 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -416,8 +416,6 @@ SET(MULTIMC_SOURCES logic/SkinUtils.cpp # misc model filter - logic/EnabledItemFilter.h - logic/EnabledItemFilter.cpp # JSON parsing helpers logic/MMCJson.h diff --git a/gui/pages/LegacyUpgradePage.h b/gui/pages/LegacyUpgradePage.h index 969b5440..25782aae 100644 --- a/gui/pages/LegacyUpgradePage.h +++ b/gui/pages/LegacyUpgradePage.h @@ -22,7 +22,6 @@ #include "BasePage.h" #include -class EnabledItemFilter; namespace Ui { class LegacyUpgradePage; diff --git a/gui/pages/LogPage.h b/gui/pages/LogPage.h index 3d5580dc..fea438c0 100644 --- a/gui/pages/LogPage.h +++ b/gui/pages/LogPage.h @@ -23,8 +23,6 @@ #include "BasePage.h" #include -class EnabledItemFilter; -class MinecraftProcess; namespace Ui { class LogPage; diff --git a/gui/pages/ModFolderPage.h b/gui/pages/ModFolderPage.h index 8859ad99..d2452ff6 100644 --- a/gui/pages/ModFolderPage.h +++ b/gui/pages/ModFolderPage.h @@ -22,7 +22,6 @@ #include "BasePage.h" #include -class EnabledItemFilter; class ModList; namespace Ui { diff --git a/gui/pages/NotesPage.h b/gui/pages/NotesPage.h index f77ea530..6dcdce32 100644 --- a/gui/pages/NotesPage.h +++ b/gui/pages/NotesPage.h @@ -22,7 +22,6 @@ #include "BasePage.h" #include -class EnabledItemFilter; namespace Ui { class NotesPage; diff --git a/gui/pages/VersionPage.cpp b/gui/pages/VersionPage.cpp index 17869589..61253c1b 100644 --- a/gui/pages/VersionPage.cpp +++ b/gui/pages/VersionPage.cpp @@ -39,7 +39,6 @@ #include "logic/ModList.h" #include "logic/minecraft/MinecraftProfile.h" -#include "logic/EnabledItemFilter.h" #include "logic/forge/ForgeVersionList.h" #include "logic/forge/ForgeInstaller.h" #include "logic/liteloader/LiteLoaderVersionList.h" @@ -68,17 +67,14 @@ VersionPage::VersionPage(OneSixInstance *inst, QWidget *parent) m_version = m_inst->getMinecraftProfile(); if (m_version) { - main_model = new EnabledItemFilter(this); - main_model->setActive(true); - main_model->setSourceModel(m_version.get()); - ui->libraryTreeView->setModel(main_model); + ui->libraryTreeView->setModel(m_version.get()); ui->libraryTreeView->installEventFilter(this); ui->libraryTreeView->setSelectionMode(QAbstractItemView::SingleSelection); connect(ui->libraryTreeView->selectionModel(), &QItemSelectionModel::currentChanged, this, &VersionPage::versionCurrent); updateVersionControls(); // select first item. - auto index = main_model->index(0,0); + auto index = ui->libraryTreeView->model()->index(0,0); if(index.isValid()) ui->libraryTreeView->setCurrentIndex(index); } diff --git a/gui/pages/VersionPage.h b/gui/pages/VersionPage.h index f1b98dbe..0354c886 100644 --- a/gui/pages/VersionPage.h +++ b/gui/pages/VersionPage.h @@ -21,7 +21,6 @@ #include "logic/net/NetJob.h" #include "BasePage.h" -class EnabledItemFilter; namespace Ui { class VersionPage; @@ -72,7 +71,6 @@ protected: private: Ui::VersionPage *ui; std::shared_ptr m_version; - EnabledItemFilter *main_model; OneSixInstance *m_inst; NetJobPtr forgeJob; diff --git a/logic/EnabledItemFilter.cpp b/logic/EnabledItemFilter.cpp deleted file mode 100644 index 17e122a8..00000000 --- a/logic/EnabledItemFilter.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/* Copyright 2013-2015 MultiMC Contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "EnabledItemFilter.h" - -EnabledItemFilter::EnabledItemFilter(QObject *parent) : QSortFilterProxyModel(parent) -{ -} - -void EnabledItemFilter::setActive(bool active) -{ - m_active = active; - invalidateFilter(); -} - -bool EnabledItemFilter::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const -{ - if (!m_active) - return true; - QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent); - if (sourceModel()->flags(index) & Qt::ItemIsEnabled) - { - return true; - } - return false; -} - -bool EnabledItemFilter::lessThan(const QModelIndex &left, const QModelIndex &right) const -{ - return QSortFilterProxyModel::lessThan(left, right); -} diff --git a/logic/EnabledItemFilter.h b/logic/EnabledItemFilter.h deleted file mode 100644 index b5ae5738..00000000 --- a/logic/EnabledItemFilter.h +++ /dev/null @@ -1,32 +0,0 @@ -/* Copyright 2013-2015 MultiMC Contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once -#include - -class EnabledItemFilter : public QSortFilterProxyModel -{ - Q_OBJECT -public: - EnabledItemFilter(QObject *parent = 0); - void setActive(bool active); - -protected: - bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const; - bool lessThan(const QModelIndex &left, const QModelIndex &right) const; - -private: - bool m_active = false; -}; \ No newline at end of file -- cgit v1.2.3