GH-3033 Add filtering for version components
This commit is contained in:
parent
cb22d5fb09
commit
c0f72488d0
@ -120,7 +120,15 @@ VersionPage::VersionPage(MinecraftInstance *inst, QWidget *parent)
|
|||||||
|
|
||||||
auto proxy = new IconProxy(ui->packageView);
|
auto proxy = new IconProxy(ui->packageView);
|
||||||
proxy->setSourceModel(m_profile.get());
|
proxy->setSourceModel(m_profile.get());
|
||||||
ui->packageView->setModel(proxy);
|
|
||||||
|
m_filterModel = new QSortFilterProxyModel();
|
||||||
|
m_filterModel->setDynamicSortFilter(true);
|
||||||
|
m_filterModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
|
||||||
|
m_filterModel->setSortCaseSensitivity(Qt::CaseInsensitive);
|
||||||
|
m_filterModel->setSourceModel(proxy);
|
||||||
|
m_filterModel->setFilterKeyColumn(-1);
|
||||||
|
|
||||||
|
ui->packageView->setModel(m_filterModel);
|
||||||
ui->packageView->installEventFilter(this);
|
ui->packageView->installEventFilter(this);
|
||||||
ui->packageView->setSelectionMode(QAbstractItemView::SingleSelection);
|
ui->packageView->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||||
ui->packageView->setContextMenuPolicy(Qt::CustomContextMenu);
|
ui->packageView->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
@ -134,7 +142,8 @@ VersionPage::VersionPage(MinecraftInstance *inst, QWidget *parent)
|
|||||||
updateVersionControls();
|
updateVersionControls();
|
||||||
preselect(0);
|
preselect(0);
|
||||||
connect(m_inst, &BaseInstance::runningStatusChanged, this, &VersionPage::updateRunningStatus);
|
connect(m_inst, &BaseInstance::runningStatusChanged, this, &VersionPage::updateRunningStatus);
|
||||||
connect(ui->packageView, &ModListView::customContextMenuRequested, this, &VersionPage::ShowContextMenu);
|
connect(ui->packageView, &ModListView::customContextMenuRequested, this, &VersionPage::showContextMenu);
|
||||||
|
connect(ui->filterEdit, &QLineEdit::textChanged, this, &VersionPage::onFilterTextChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
VersionPage::~VersionPage()
|
VersionPage::~VersionPage()
|
||||||
@ -142,7 +151,7 @@ VersionPage::~VersionPage()
|
|||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VersionPage::ShowContextMenu(const QPoint& pos)
|
void VersionPage::showContextMenu(const QPoint& pos)
|
||||||
{
|
{
|
||||||
auto menu = ui->toolBar->createContextMenu(this, tr("Context menu"));
|
auto menu = ui->toolBar->createContextMenu(this, tr("Context menu"));
|
||||||
menu->exec(ui->packageView->mapToGlobal(pos));
|
menu->exec(ui->packageView->mapToGlobal(pos));
|
||||||
@ -620,5 +629,10 @@ void VersionPage::on_actionRevert_triggered()
|
|||||||
m_container->refreshContainer();
|
m_container->refreshContainer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VersionPage::onFilterTextChanged(const QString &newContents)
|
||||||
|
{
|
||||||
|
m_filterModel->setFilterFixedString(newContents);
|
||||||
|
}
|
||||||
|
|
||||||
#include "VersionPage.moc"
|
#include "VersionPage.moc"
|
||||||
|
|
||||||
|
@ -86,6 +86,7 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::VersionPage *ui;
|
Ui::VersionPage *ui;
|
||||||
|
QSortFilterProxyModel *m_filterModel;
|
||||||
std::shared_ptr<PackProfile> m_profile;
|
std::shared_ptr<PackProfile> m_profile;
|
||||||
MinecraftInstance *m_inst;
|
MinecraftInstance *m_inst;
|
||||||
int currentIdx = 0;
|
int currentIdx = 0;
|
||||||
@ -98,5 +99,6 @@ private slots:
|
|||||||
void updateRunningStatus(bool running);
|
void updateRunningStatus(bool running);
|
||||||
void onGameUpdateError(QString error);
|
void onGameUpdateError(QString error);
|
||||||
void packageCurrent(const QModelIndex ¤t, const QModelIndex &previous);
|
void packageCurrent(const QModelIndex ¤t, const QModelIndex &previous);
|
||||||
void ShowContextMenu(const QPoint &pos);
|
void showContextMenu(const QPoint &pos);
|
||||||
|
void onFilterTextChanged(const QString & newContents);
|
||||||
};
|
};
|
||||||
|
@ -45,6 +45,24 @@
|
|||||||
</attribute>
|
</attribute>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QLineEdit" name="filterEdit">
|
||||||
|
<property name="clearButtonEnabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="filterLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Filter:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="MCModInfoFrame" name="frame">
|
<widget class="MCModInfoFrame" name="frame">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
|
Loading…
Reference in New Issue
Block a user