mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 21:53:51 +00:00
Implemented filter function for the plugin list
This commit is contained in:
parent
9b439d74da
commit
d3143c6e52
2 changed files with 18 additions and 3 deletions
|
@ -15,6 +15,11 @@ DataFilesPage::DataFilesPage(QWidget *parent) : QWidget(parent)
|
|||
mDataFilesModel = new QStandardItemModel(); // Contains all plugins with masters
|
||||
mPluginsModel = new QStandardItemModel(); // Contains selectable plugins
|
||||
|
||||
mPluginsProxyModel = new QSortFilterProxyModel();
|
||||
mPluginsProxyModel->setDynamicSortFilter(true);
|
||||
mPluginsProxyModel->setSourceModel(mPluginsModel);
|
||||
|
||||
// TODO: decide what to do with the selection model
|
||||
mPluginsSelectModel = new QItemSelectionModel(mPluginsModel);
|
||||
|
||||
QLabel *filterLabel = new QLabel(tr("Filter:"), this);
|
||||
|
@ -40,7 +45,7 @@ DataFilesPage::DataFilesPage(QWidget *parent) : QWidget(parent)
|
|||
mMastersWidget->verticalHeader()->hide();
|
||||
mMastersWidget->insertColumn(0);
|
||||
|
||||
mPluginsTable->setModel(mPluginsModel);
|
||||
mPluginsTable->setModel(mPluginsProxyModel);
|
||||
mPluginsTable->setSelectionModel(mPluginsSelectModel);
|
||||
mPluginsTable->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||
mPluginsTable->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||
|
@ -113,6 +118,8 @@ DataFilesPage::DataFilesPage(QWidget *parent) : QWidget(parent)
|
|||
SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)),
|
||||
this, SLOT(masterSelectionChanged(const QItemSelection&, const QItemSelection&)));
|
||||
|
||||
connect(filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterChanged(const QString)));
|
||||
|
||||
connect(mPluginsTable, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(setCheckstate(QModelIndex)));
|
||||
connect(mPluginsModel, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)), this, SLOT(resizeRows()));
|
||||
|
||||
|
@ -531,6 +538,13 @@ void DataFilesPage::resizeRows()
|
|||
mPluginsTable->resizeRowsToContents();
|
||||
}
|
||||
|
||||
void DataFilesPage::filterChanged(const QString filter)
|
||||
{
|
||||
QRegExp regExp(filter, Qt::CaseInsensitive, QRegExp::FixedString);
|
||||
mPluginsProxyModel->setFilterRegExp(regExp);
|
||||
|
||||
}
|
||||
|
||||
void DataFilesPage::profileChanged(const QString &previous, const QString ¤t)
|
||||
{
|
||||
qDebug() << "Profile changed " << current << previous;
|
||||
|
@ -544,7 +558,6 @@ void DataFilesPage::profileChanged(const QString &previous, const QString &curre
|
|||
// Deselect the masters
|
||||
mMastersWidget->selectionModel()->clearSelection();
|
||||
readConfig();
|
||||
|
||||
}
|
||||
|
||||
void DataFilesPage::readConfig()
|
||||
|
|
|
@ -11,6 +11,7 @@ class ComboBox;
|
|||
class QStandardItemModel;
|
||||
class QItemSelection;
|
||||
class QItemSelectionModel;
|
||||
class QSortFilterProxyModel;
|
||||
class QStringListModel;
|
||||
class QSettings;
|
||||
class QPushButton;
|
||||
|
@ -23,7 +24,6 @@ public:
|
|||
DataFilesPage(QWidget *parent = 0);
|
||||
|
||||
ComboBox *mProfilesComboBox;
|
||||
//QStringListModel *mProfilesModel;
|
||||
QSettings *mLauncherConfig;
|
||||
|
||||
const QStringList checkedPlugins();
|
||||
|
@ -38,6 +38,7 @@ public slots:
|
|||
void masterSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
|
||||
void setCheckstate(QModelIndex index);
|
||||
void resizeRows();
|
||||
void filterChanged(const QString filter);
|
||||
void profileChanged(const QString &previous, const QString ¤t);
|
||||
void newProfile();
|
||||
void copyProfile();
|
||||
|
@ -50,6 +51,7 @@ private:
|
|||
QStandardItemModel *mDataFilesModel;
|
||||
QStandardItemModel *mPluginsModel;
|
||||
|
||||
QSortFilterProxyModel *mPluginsProxyModel;
|
||||
QItemSelectionModel *mPluginsSelectModel;
|
||||
|
||||
QPushButton *mNewProfileButton;
|
||||
|
|
Loading…
Reference in a new issue