NOISSUE remove obsolete EnabledItemFilter model

This commit is contained in:
Petr Mrázek 2015-04-02 20:18:06 +02:00
parent 04b45f3629
commit 5359f4499a
9 changed files with 2 additions and 90 deletions

View File

@ -416,8 +416,6 @@ SET(MULTIMC_SOURCES
logic/SkinUtils.cpp logic/SkinUtils.cpp
# misc model filter # misc model filter
logic/EnabledItemFilter.h
logic/EnabledItemFilter.cpp
# JSON parsing helpers # JSON parsing helpers
logic/MMCJson.h logic/MMCJson.h

View File

@ -22,7 +22,6 @@
#include "BasePage.h" #include "BasePage.h"
#include <MultiMC.h> #include <MultiMC.h>
class EnabledItemFilter;
namespace Ui namespace Ui
{ {
class LegacyUpgradePage; class LegacyUpgradePage;

View File

@ -23,8 +23,6 @@
#include "BasePage.h" #include "BasePage.h"
#include <MultiMC.h> #include <MultiMC.h>
class EnabledItemFilter;
class MinecraftProcess;
namespace Ui namespace Ui
{ {
class LogPage; class LogPage;

View File

@ -22,7 +22,6 @@
#include "BasePage.h" #include "BasePage.h"
#include <MultiMC.h> #include <MultiMC.h>
class EnabledItemFilter;
class ModList; class ModList;
namespace Ui namespace Ui
{ {

View File

@ -22,7 +22,6 @@
#include "BasePage.h" #include "BasePage.h"
#include <MultiMC.h> #include <MultiMC.h>
class EnabledItemFilter;
namespace Ui namespace Ui
{ {
class NotesPage; class NotesPage;

View File

@ -39,7 +39,6 @@
#include "logic/ModList.h" #include "logic/ModList.h"
#include "logic/minecraft/MinecraftProfile.h" #include "logic/minecraft/MinecraftProfile.h"
#include "logic/EnabledItemFilter.h"
#include "logic/forge/ForgeVersionList.h" #include "logic/forge/ForgeVersionList.h"
#include "logic/forge/ForgeInstaller.h" #include "logic/forge/ForgeInstaller.h"
#include "logic/liteloader/LiteLoaderVersionList.h" #include "logic/liteloader/LiteLoaderVersionList.h"
@ -68,17 +67,14 @@ VersionPage::VersionPage(OneSixInstance *inst, QWidget *parent)
m_version = m_inst->getMinecraftProfile(); m_version = m_inst->getMinecraftProfile();
if (m_version) if (m_version)
{ {
main_model = new EnabledItemFilter(this); ui->libraryTreeView->setModel(m_version.get());
main_model->setActive(true);
main_model->setSourceModel(m_version.get());
ui->libraryTreeView->setModel(main_model);
ui->libraryTreeView->installEventFilter(this); ui->libraryTreeView->installEventFilter(this);
ui->libraryTreeView->setSelectionMode(QAbstractItemView::SingleSelection); ui->libraryTreeView->setSelectionMode(QAbstractItemView::SingleSelection);
connect(ui->libraryTreeView->selectionModel(), &QItemSelectionModel::currentChanged, connect(ui->libraryTreeView->selectionModel(), &QItemSelectionModel::currentChanged,
this, &VersionPage::versionCurrent); this, &VersionPage::versionCurrent);
updateVersionControls(); updateVersionControls();
// select first item. // select first item.
auto index = main_model->index(0,0); auto index = ui->libraryTreeView->model()->index(0,0);
if(index.isValid()) if(index.isValid())
ui->libraryTreeView->setCurrentIndex(index); ui->libraryTreeView->setCurrentIndex(index);
} }

View File

@ -21,7 +21,6 @@
#include "logic/net/NetJob.h" #include "logic/net/NetJob.h"
#include "BasePage.h" #include "BasePage.h"
class EnabledItemFilter;
namespace Ui namespace Ui
{ {
class VersionPage; class VersionPage;
@ -72,7 +71,6 @@ protected:
private: private:
Ui::VersionPage *ui; Ui::VersionPage *ui;
std::shared_ptr<MinecraftProfile> m_version; std::shared_ptr<MinecraftProfile> m_version;
EnabledItemFilter *main_model;
OneSixInstance *m_inst; OneSixInstance *m_inst;
NetJobPtr forgeJob; NetJobPtr forgeJob;

View File

@ -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);
}

View File

@ -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 <QSortFilterProxyModel>
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;
};