diff --git a/launcher/ui/widgets/CheckComboBox.cpp b/launcher/ui/widgets/CheckComboBox.cpp index 9c9006c74..f826c1afe 100644 --- a/launcher/ui/widgets/CheckComboBox.cpp +++ b/launcher/ui/widgets/CheckComboBox.cpp @@ -39,17 +39,17 @@ class CheckComboModel : public QIdentityProxyModel { virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const { if (role == Qt::CheckStateRole) { - auto txt = QIdentityProxyModel::data(index, BaseVersionList::VersionIdRole).toString(); + auto txt = QIdentityProxyModel::data(index, Qt::DisplayRole).toString(); return checked.contains(txt) ? Qt::Checked : Qt::Unchecked; } if (role == Qt::DisplayRole) - return QIdentityProxyModel::data(index, BaseVersionList::VersionIdRole); + return QIdentityProxyModel::data(index, Qt::DisplayRole); return {}; } virtual bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) { if (role == Qt::CheckStateRole) { - auto txt = QIdentityProxyModel::data(index, BaseVersionList::VersionIdRole).toString(); + auto txt = QIdentityProxyModel::data(index, Qt::DisplayRole).toString(); if (checked.contains(txt)) { checked.removeOne(txt); } else { @@ -72,11 +72,10 @@ class CheckComboModel : public QIdentityProxyModel { CheckComboBox::CheckComboBox(QWidget* parent) : QComboBox(parent), m_separator(",") { - // read-only contents - // QLineEdit* lineEdit = new QLineEdit(this); - // lineEdit->setReadOnly(false); - // setLineEdit(lineEdit); - // lineEdit->disconnect(this); + QLineEdit* lineEdit = new QLineEdit(this); + lineEdit->setReadOnly(false); + setLineEdit(lineEdit); + lineEdit->disconnect(this); setInsertPolicy(QComboBox::NoInsert); view()->installEventFilter(this); @@ -150,7 +149,6 @@ bool CheckComboBox::eventFilter(QObject* receiver, QEvent* event) showPopup(); return true; } else if (keyEvent->key() == Qt::Key_Enter || keyEvent->key() == Qt::Key_Return || keyEvent->key() == Qt::Key_Escape) { - // it is important to call QComboBox implementation QComboBox::hidePopup(); return (keyEvent->key() != Qt::Key_Escape); } diff --git a/launcher/ui/widgets/ModFilterWidget.cpp b/launcher/ui/widgets/ModFilterWidget.cpp index 5ed2e34f6..5a67757b5 100644 --- a/launcher/ui/widgets/ModFilterWidget.cpp +++ b/launcher/ui/widgets/ModFilterWidget.cpp @@ -14,6 +14,20 @@ unique_qobject_ptr ModFilterWidget::create(MinecraftInstance* i return unique_qobject_ptr(new ModFilterWidget(instance, parent)); } +class VersionBasicModel : public QIdentityProxyModel { + Q_OBJECT + + public: + explicit VersionBasicModel(QObject* parent = nullptr) : QIdentityProxyModel(parent) {} + + virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override + { + if (role == Qt::DisplayRole) + return QIdentityProxyModel::data(index, BaseVersionList::VersionIdRole); + return {}; + } +}; + ModFilterWidget::ModFilterWidget(MinecraftInstance* instance, QWidget* parent) : QTabWidget(parent), ui(new Ui::ModFilterWidget), m_instance(instance), m_filter(new Filter()) { @@ -21,7 +35,10 @@ ModFilterWidget::ModFilterWidget(MinecraftInstance* instance, QWidget* parent) m_versions_proxy = new VersionProxyModel(this); - ui->versionsCb->setModel(m_versions_proxy); + auto proxy = new VersionBasicModel(this); + proxy->setSourceModel(m_versions_proxy); + ui->versionsCb->setModel(proxy); + ui->versionsCb->setSeparator("| "); m_versions_proxy->setFilter(BaseVersionList::TypeRole, new RegexpFilter("(release)", false)); @@ -177,4 +194,6 @@ void ModFilterWidget::onHideInstalledFilterChanged() emit filterChanged(); else emit filterUnchanged(); -} \ No newline at end of file +} + +#include "ModFilterWidget.moc"