Fix version select dialog filtering

This commit is contained in:
Petr Mrázek 2014-05-04 13:20:42 +02:00
parent de48f102bd
commit 0902fd5bec
5 changed files with 13 additions and 19 deletions

View File

@ -1433,7 +1433,7 @@ void MainWindow::on_actionChangeInstMCVersion_triggered()
VersionSelectDialog vselect(m_selectedInstance->versionList().get(),
tr("Change Minecraft version"), this);
vselect.setFilter(1, "OneSix");
vselect.setFuzzyFilter(1, "*OneSix*");
if (!vselect.exec() || !vselect.selectedVersion())
return;

View File

@ -208,7 +208,7 @@ void LegacyModEditDialog::on_addCoreBtn_clicked()
void LegacyModEditDialog::on_addForgeBtn_clicked()
{
VersionSelectDialog vselect(MMC->forgelist().get(), tr("Select Forge version"), this);
vselect.setFilter(1, m_inst->intendedVersionId());
vselect.setExactFilter(1, m_inst->intendedVersionId());
if (vselect.exec() && vselect.selectedVersion())
{
ForgeVersionPtr forge =

View File

@ -222,7 +222,7 @@ void OneSixModEditDialog::on_forgeBtn_clicked()
reloadInstanceVersion();
}
VersionSelectDialog vselect(MMC->forgelist().get(), tr("Select Forge version"), this);
vselect.setFilter(1, m_inst->currentVersionId());
vselect.setExactFilter(1, m_inst->currentVersionId());
vselect.setEmptyString(tr("No Forge versions are currently available for Minecraft ") +
m_inst->currentVersionId());
if (vselect.exec() && vselect.selectedVersion())
@ -258,7 +258,7 @@ void OneSixModEditDialog::on_liteloaderBtn_clicked()
}
VersionSelectDialog vselect(MMC->liteloaderlist().get(), tr("Select LiteLoader version"),
this);
vselect.setFilter(1, m_inst->currentVersionId());
vselect.setExactFilter(1, m_inst->currentVersionId());
vselect.setEmptyString(tr("No LiteLoader versions are currently available for Minecraft ") +
m_inst->currentVersionId());
if (vselect.exec() && vselect.selectedVersion())

View File

@ -97,23 +97,16 @@ void VersionSelectDialog::on_refreshButton_clicked()
loadList();
}
void VersionSelectDialog::setFilter(int column, QString filter)
void VersionSelectDialog::setExactFilter(int column, QString filter)
{
m_proxyModel->setFilterKeyColumn(column);
// m_proxyModel->setFilterFixedString(filter);
m_proxyModel->setFilterRegExp(QRegExp(QString("^%1$").arg(filter.replace(".", "\\.")),
Qt::CaseInsensitive, QRegExp::RegExp));
/*
QStringList filteredTypes;
if (!ui->filterSnapshotsCheckbox->isChecked())
filteredTypes += "Snapshot";
if (!ui->filterMCNostalgiaCheckbox->isChecked())
filteredTypes += "Nostalgia";
QString regexStr = "^.*$";
if (filteredTypes.length() > 0)
regexStr = QString("^((?!%1).)*$").arg(filteredTypes.join('|'));
QLOG_DEBUG() << "Filter:" << regexStr;
*/
}
void VersionSelectDialog::setFuzzyFilter(int column, QString filter)
{
m_proxyModel->setFilterKeyColumn(column);
m_proxyModel->setFilterWildcard(filter);
}

View File

@ -43,7 +43,8 @@ public:
BaseVersionPtr selectedVersion() const;
void setFilter(int column, QString filter);
void setFuzzyFilter(int column, QString filter);
void setExactFilter(int column, QString filter);
void setEmptyString(QString emptyString);
void setResizeOn(int column);