mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-21 06:53:53 +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
|
mDataFilesModel = new QStandardItemModel(); // Contains all plugins with masters
|
||||||
mPluginsModel = new QStandardItemModel(); // Contains selectable plugins
|
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);
|
mPluginsSelectModel = new QItemSelectionModel(mPluginsModel);
|
||||||
|
|
||||||
QLabel *filterLabel = new QLabel(tr("Filter:"), this);
|
QLabel *filterLabel = new QLabel(tr("Filter:"), this);
|
||||||
|
@ -40,7 +45,7 @@ DataFilesPage::DataFilesPage(QWidget *parent) : QWidget(parent)
|
||||||
mMastersWidget->verticalHeader()->hide();
|
mMastersWidget->verticalHeader()->hide();
|
||||||
mMastersWidget->insertColumn(0);
|
mMastersWidget->insertColumn(0);
|
||||||
|
|
||||||
mPluginsTable->setModel(mPluginsModel);
|
mPluginsTable->setModel(mPluginsProxyModel);
|
||||||
mPluginsTable->setSelectionModel(mPluginsSelectModel);
|
mPluginsTable->setSelectionModel(mPluginsSelectModel);
|
||||||
mPluginsTable->setSelectionBehavior(QAbstractItemView::SelectRows);
|
mPluginsTable->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||||
mPluginsTable->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
mPluginsTable->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||||
|
@ -113,6 +118,8 @@ DataFilesPage::DataFilesPage(QWidget *parent) : QWidget(parent)
|
||||||
SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)),
|
SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)),
|
||||||
this, SLOT(masterSelectionChanged(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(mPluginsTable, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(setCheckstate(QModelIndex)));
|
||||||
connect(mPluginsModel, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)), this, SLOT(resizeRows()));
|
connect(mPluginsModel, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)), this, SLOT(resizeRows()));
|
||||||
|
|
||||||
|
@ -531,6 +538,13 @@ void DataFilesPage::resizeRows()
|
||||||
mPluginsTable->resizeRowsToContents();
|
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)
|
void DataFilesPage::profileChanged(const QString &previous, const QString ¤t)
|
||||||
{
|
{
|
||||||
qDebug() << "Profile changed " << current << previous;
|
qDebug() << "Profile changed " << current << previous;
|
||||||
|
@ -544,7 +558,6 @@ void DataFilesPage::profileChanged(const QString &previous, const QString &curre
|
||||||
// Deselect the masters
|
// Deselect the masters
|
||||||
mMastersWidget->selectionModel()->clearSelection();
|
mMastersWidget->selectionModel()->clearSelection();
|
||||||
readConfig();
|
readConfig();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataFilesPage::readConfig()
|
void DataFilesPage::readConfig()
|
||||||
|
|
|
@ -11,6 +11,7 @@ class ComboBox;
|
||||||
class QStandardItemModel;
|
class QStandardItemModel;
|
||||||
class QItemSelection;
|
class QItemSelection;
|
||||||
class QItemSelectionModel;
|
class QItemSelectionModel;
|
||||||
|
class QSortFilterProxyModel;
|
||||||
class QStringListModel;
|
class QStringListModel;
|
||||||
class QSettings;
|
class QSettings;
|
||||||
class QPushButton;
|
class QPushButton;
|
||||||
|
@ -23,7 +24,6 @@ public:
|
||||||
DataFilesPage(QWidget *parent = 0);
|
DataFilesPage(QWidget *parent = 0);
|
||||||
|
|
||||||
ComboBox *mProfilesComboBox;
|
ComboBox *mProfilesComboBox;
|
||||||
//QStringListModel *mProfilesModel;
|
|
||||||
QSettings *mLauncherConfig;
|
QSettings *mLauncherConfig;
|
||||||
|
|
||||||
const QStringList checkedPlugins();
|
const QStringList checkedPlugins();
|
||||||
|
@ -38,6 +38,7 @@ public slots:
|
||||||
void masterSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
|
void masterSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
|
||||||
void setCheckstate(QModelIndex index);
|
void setCheckstate(QModelIndex index);
|
||||||
void resizeRows();
|
void resizeRows();
|
||||||
|
void filterChanged(const QString filter);
|
||||||
void profileChanged(const QString &previous, const QString ¤t);
|
void profileChanged(const QString &previous, const QString ¤t);
|
||||||
void newProfile();
|
void newProfile();
|
||||||
void copyProfile();
|
void copyProfile();
|
||||||
|
@ -50,6 +51,7 @@ private:
|
||||||
QStandardItemModel *mDataFilesModel;
|
QStandardItemModel *mDataFilesModel;
|
||||||
QStandardItemModel *mPluginsModel;
|
QStandardItemModel *mPluginsModel;
|
||||||
|
|
||||||
|
QSortFilterProxyModel *mPluginsProxyModel;
|
||||||
QItemSelectionModel *mPluginsSelectModel;
|
QItemSelectionModel *mPluginsSelectModel;
|
||||||
|
|
||||||
QPushButton *mNewProfileButton;
|
QPushButton *mNewProfileButton;
|
||||||
|
|
Loading…
Reference in a new issue