mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-25 06:35:30 +00:00
Continued migration of code to ContentSelector
This commit is contained in:
parent
0087b0d67c
commit
b24dd5c6ac
@ -21,63 +21,14 @@
|
||||
|
||||
#include "utils/textinputdialog.hpp"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
DataFilesPage::DataFilesPage(Files::ConfigurationManager &cfg, GameSettings &gameSettings, LauncherSettings &launcherSettings, QWidget *parent)
|
||||
: mCfgMgr(cfg)
|
||||
, mGameSettings(gameSettings)
|
||||
, mLauncherSettings(launcherSettings)
|
||||
, ContentSelector(parent)
|
||||
{
|
||||
setupUi(this);
|
||||
buildModelsAndViews();
|
||||
/*
|
||||
// Models
|
||||
mDataFilesModel = new DataFilesModel (this);
|
||||
|
||||
mMastersProxyModel = new MasterProxyModel (this, mDataFilesModel);
|
||||
|
||||
mPluginsProxyModel = new PluginsProxyModel (this, mDataFilesModel);
|
||||
|
||||
mFilterProxyModel = new QSortFilterProxyModel();
|
||||
mFilterProxyModel->setDynamicSortFilter(true);
|
||||
mFilterProxyModel->setSourceModel(mPluginsProxyModel);
|
||||
|
||||
masterView->setModel (mMastersProxyModel);
|
||||
|
||||
//QCheckBox checkBox;
|
||||
// unsigned int height = checkBox.sizeHint().height() + 4;
|
||||
|
||||
|
||||
mastersTable->setModel(mMastersProxyModel);
|
||||
mastersTable->setObjectName("MastersTable");
|
||||
mastersTable->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
mastersTable->setSortingEnabled(false);
|
||||
mastersTable->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||
mastersTable->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||
mastersTable->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
||||
mastersTable->setAlternatingRowColors(true);
|
||||
mastersTable->horizontalHeader()->setStretchLastSection(true);
|
||||
mastersTable->horizontalHeader()->hide();
|
||||
|
||||
// Set the row height to the size of the checkboxes
|
||||
mastersTable->verticalHeader()->setDefaultSectionSize(height);
|
||||
mastersTable->verticalHeader()->setResizeMode(QHeaderView::Fixed);
|
||||
mastersTable->verticalHeader()->hide();
|
||||
|
||||
pluginsTable->setModel(mFilterProxyModel);
|
||||
pluginsTable->setObjectName("PluginsTable");
|
||||
pluginsTable->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
pluginsTable->setSortingEnabled(false);
|
||||
pluginsTable->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||
pluginsTable->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||
pluginsTable->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
||||
pluginsTable->setAlternatingRowColors(true);
|
||||
pluginsTable->setVerticalScrollMode(QAbstractItemView::ScrollPerItem);
|
||||
pluginsTable->horizontalHeader()->setStretchLastSection(true);
|
||||
pluginsTable->horizontalHeader()->hide();
|
||||
|
||||
//pluginsTable->verticalHeader()->setDefaultSectionSize(height);
|
||||
//pluginsTable->verticalHeader()->setResizeMode(QHeaderView::Fixed);
|
||||
*/
|
||||
// Adjust the tableview widths inside the splitter
|
||||
QList<int> sizeList;
|
||||
sizeList << mLauncherSettings.value(QString("General/MastersTable/width"), QString("200")).toInt();
|
||||
@ -98,8 +49,6 @@ DataFilesPage::DataFilesPage(Files::ConfigurationManager &cfg, GameSettings &gam
|
||||
connect(pluginsTable, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showContextMenu(QPoint)));
|
||||
//connect(mastersTable, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showContextMenu(QPoint)));
|
||||
|
||||
connect(mDataFilesModel, SIGNAL(layoutChanged()), this, SLOT(updateViews()));
|
||||
|
||||
//connect(filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterChanged(QString)));
|
||||
|
||||
connect(splitter, SIGNAL(splitterMoved(int,int)), this, SLOT(updateSplitter()));
|
||||
@ -123,6 +72,9 @@ void DataFilesPage::createActions()
|
||||
|
||||
void DataFilesPage::setupDataFiles()
|
||||
{
|
||||
if (!mDataFilesModel)
|
||||
qDebug() << "data files model undefined";
|
||||
|
||||
// Set the encoding to the one found in openmw.cfg or the default
|
||||
mDataFilesModel->setEncoding(mGameSettings.value(QString("encoding"), QString("win1252")));
|
||||
|
||||
@ -384,8 +336,7 @@ void DataFilesPage::setPluginsCheckstates(Qt::CheckState state)
|
||||
if (!index.isValid())
|
||||
return;
|
||||
|
||||
QModelIndex sourceIndex = mPluginsProxyModel->mapToSource(
|
||||
mFilterProxyModel->mapToSource(index));
|
||||
QModelIndex sourceIndex = mPluginsProxyModel->mapToSource(index);
|
||||
|
||||
if (!sourceIndex.isValid())
|
||||
return;
|
||||
@ -394,48 +345,6 @@ void DataFilesPage::setPluginsCheckstates(Qt::CheckState state)
|
||||
}
|
||||
}
|
||||
|
||||
void DataFilesPage::setCheckState(QModelIndex index)
|
||||
{
|
||||
if (!index.isValid())
|
||||
return;
|
||||
|
||||
QObject *object = QObject::sender();
|
||||
|
||||
// Not a signal-slot call
|
||||
if (!object)
|
||||
return;
|
||||
|
||||
|
||||
if (object->objectName() == QLatin1String("PluginsTable")) {
|
||||
QModelIndex sourceIndex = mPluginsProxyModel->mapToSource(
|
||||
mFilterProxyModel->mapToSource(index));
|
||||
|
||||
if (sourceIndex.isValid()) {
|
||||
(mDataFilesModel->checkState(sourceIndex) == Qt::Checked)
|
||||
? mDataFilesModel->setCheckState(sourceIndex, Qt::Unchecked)
|
||||
: mDataFilesModel->setCheckState(sourceIndex, Qt::Checked);
|
||||
}
|
||||
}
|
||||
|
||||
if (object->objectName() == QLatin1String("MastersTable")) {
|
||||
QModelIndex sourceIndex = mMastersProxyModel->mapToSource(index);
|
||||
|
||||
if (sourceIndex.isValid()) {
|
||||
(mDataFilesModel->checkState(sourceIndex) == Qt::Checked)
|
||||
? mDataFilesModel->setCheckState(sourceIndex, Qt::Unchecked)
|
||||
: mDataFilesModel->setCheckState(sourceIndex, Qt::Checked);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void DataFilesPage::filterChanged(const QString filter)
|
||||
{
|
||||
QRegExp regExp(filter, Qt::CaseInsensitive, QRegExp::FixedString);
|
||||
mFilterProxyModel->setFilterRegExp(regExp);
|
||||
}
|
||||
|
||||
void DataFilesPage::profileChanged(const QString &previous, const QString ¤t)
|
||||
{
|
||||
// Prevent the deletion of the default profile
|
||||
@ -505,8 +414,7 @@ void DataFilesPage::showContextMenu(const QPoint &point)
|
||||
if (!index.isValid())
|
||||
return;
|
||||
|
||||
QModelIndex sourceIndex = mPluginsProxyModel->mapToSource(
|
||||
mFilterProxyModel->mapToSource(index));
|
||||
QModelIndex sourceIndex = mPluginsProxyModel->mapToSource(index);
|
||||
|
||||
if (!sourceIndex.isValid())
|
||||
return;
|
||||
|
@ -36,10 +36,8 @@ signals:
|
||||
void profileChanged(int index);
|
||||
|
||||
public slots:
|
||||
void setCheckState(QModelIndex index);
|
||||
void setProfilesComboBoxIndex(int index);
|
||||
|
||||
void filterChanged(const QString filter);
|
||||
void showContextMenu(const QPoint &point);
|
||||
void profileChanged(const QString &previous, const QString ¤t);
|
||||
void profileRenamed(const QString &previous, const QString ¤t);
|
||||
@ -57,12 +55,6 @@ private slots:
|
||||
void slotCurrentIndexChanged(int index);
|
||||
|
||||
private:
|
||||
DataFilesModel *mDataFilesModel;
|
||||
|
||||
PluginsProxyModel *mPluginsProxyModel;
|
||||
QSortFilterProxyModel *mMastersProxyModel;
|
||||
|
||||
QSortFilterProxyModel *mFilterProxyModel;
|
||||
|
||||
QMenu *mContextMenu;
|
||||
|
||||
|
@ -21,55 +21,6 @@
|
||||
FileDialog::FileDialog(QWidget *parent) :
|
||||
ContentSelector(parent)
|
||||
{
|
||||
setupUi(this);
|
||||
buildModelsAndViews();
|
||||
/*
|
||||
// Models
|
||||
mDataFilesModel = new DataFilesModel (this);
|
||||
|
||||
mMastersProxyModel = new MasterProxyModel (this, mDataFilesModel);
|
||||
mPluginsProxyModel = new PluginsProxyModel (this, mDataFilesModel);
|
||||
|
||||
|
||||
mFilterProxyModel = new QSortFilterProxyModel();
|
||||
mFilterProxyModel->setDynamicSortFilter(true);
|
||||
mFilterProxyModel->setSourceModel(mPluginsProxyModel);
|
||||
|
||||
// QCheckBox checkBox;
|
||||
// unsigned int height = checkBox.sizeHint().height() + 4;
|
||||
|
||||
masterView->setModel(mMastersProxyModel);
|
||||
|
||||
mastersTable->setModel(mMastersProxyModel);
|
||||
mastersTable->setObjectName("MastersTable");
|
||||
mastersTable->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
mastersTable->setSortingEnabled(false);
|
||||
mastersTable->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||
mastersTable->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||
mastersTable->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
||||
mastersTable->setAlternatingRowColors(true);
|
||||
mastersTable->horizontalHeader()->setStretchLastSection(true);
|
||||
|
||||
// Set the row height to the size of the checkboxes
|
||||
mastersTable->verticalHeader()->setDefaultSectionSize(height);
|
||||
mastersTable->verticalHeader()->setResizeMode(QHeaderView::Fixed);
|
||||
mastersTable->verticalHeader()->hide();
|
||||
|
||||
pluginsTable->setModel(mFilterProxyModel);
|
||||
pluginsTable->setObjectName("PluginsTable");
|
||||
pluginsTable->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
pluginsTable->setSortingEnabled(false);
|
||||
pluginsTable->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||
pluginsTable->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||
pluginsTable->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
||||
pluginsTable->setAlternatingRowColors(true);
|
||||
pluginsTable->setVerticalScrollMode(QAbstractItemView::ScrollPerItem);
|
||||
pluginsTable->horizontalHeader()->setStretchLastSection(true);
|
||||
|
||||
// pluginsTable->verticalHeader()->setDefaultSectionSize(height);
|
||||
// pluginsTable->verticalHeader()->setResizeMode(QHeaderView::Fixed);
|
||||
|
||||
*/
|
||||
// Hide the profile elements
|
||||
profileLabel->hide();
|
||||
profilesComboBox->hide();
|
||||
@ -107,7 +58,6 @@ FileDialog::FileDialog(QWidget *parent) :
|
||||
|
||||
resize(600, 400);
|
||||
|
||||
//
|
||||
// connect(mDataFilesModel, SIGNAL(checkedItemsChanged(QStringList)), this, SLOT(updateOpenButton(QStringList)));
|
||||
//connect(mNameLineEdit, SIGNAL(textChanged(QString)), this, SLOT(updateCreateButton(QString)));
|
||||
|
||||
|
@ -53,12 +53,6 @@ private:
|
||||
|
||||
QPushButton *mCreateButton;
|
||||
QDialogButtonBox *mButtonBox;
|
||||
|
||||
DataFilesModel *mDataFilesModel;
|
||||
|
||||
PluginsProxyModel *mPluginsProxyModel;
|
||||
QSortFilterProxyModel *mMastersProxyModel;
|
||||
QSortFilterProxyModel *mFilterProxyModel;
|
||||
};
|
||||
|
||||
#endif // FILEDIALOG_HPP
|
||||
|
@ -9,6 +9,8 @@
|
||||
FileOrderList::ContentSelector::ContentSelector(QWidget *parent) :
|
||||
QWidget(parent)
|
||||
{
|
||||
setupUi(this);
|
||||
buildModelsAndViews();
|
||||
}
|
||||
|
||||
void FileOrderList::ContentSelector::buildModelsAndViews()
|
||||
@ -19,11 +21,6 @@ void FileOrderList::ContentSelector::buildModelsAndViews()
|
||||
mMasterProxyModel = new FileOrderList::MasterProxyModel (this, mDataFilesModel);
|
||||
mPluginsProxyModel = new PluginsProxyModel (this, mDataFilesModel);
|
||||
|
||||
|
||||
mFilterProxyModel = new QSortFilterProxyModel();
|
||||
mFilterProxyModel->setDynamicSortFilter(true);
|
||||
mFilterProxyModel->setSourceModel(mPluginsProxyModel);
|
||||
|
||||
masterView->setModel(mMasterProxyModel);
|
||||
/*
|
||||
mastersTable->setModel(mMastersProxyModel);
|
||||
@ -41,7 +38,7 @@ void FileOrderList::ContentSelector::buildModelsAndViews()
|
||||
mastersTable->verticalHeader()->setResizeMode(QHeaderView::Fixed);
|
||||
mastersTable->verticalHeader()->hide();
|
||||
*/
|
||||
pluginsTable->setModel(mFilterProxyModel);
|
||||
pluginsTable->setModel(mPluginsProxyModel);
|
||||
pluginsTable->setObjectName("PluginsTable");
|
||||
pluginsTable->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
pluginsTable->setSortingEnabled(false);
|
||||
@ -79,8 +76,7 @@ void FileOrderList::ContentSelector::setCheckState(QModelIndex index)
|
||||
|
||||
|
||||
if (object->objectName() == QLatin1String("PluginsTable")) {
|
||||
QModelIndex sourceIndex = mPluginsProxyModel->mapToSource(
|
||||
mFilterProxyModel->mapToSource(index));
|
||||
QModelIndex sourceIndex = mPluginsProxyModel->mapToSource(index);
|
||||
|
||||
if (sourceIndex.isValid()) {
|
||||
(mDataFilesModel->checkState(sourceIndex) == Qt::Checked)
|
||||
@ -88,7 +84,7 @@ void FileOrderList::ContentSelector::setCheckState(QModelIndex index)
|
||||
: mDataFilesModel->setCheckState(sourceIndex, Qt::Checked);
|
||||
}
|
||||
}
|
||||
/*
|
||||
|
||||
if (object->objectName() == QLatin1String("MastersTable")) {
|
||||
QModelIndex sourceIndex = mMasterProxyModel->mapToSource(index);
|
||||
|
||||
@ -98,7 +94,7 @@ void FileOrderList::ContentSelector::setCheckState(QModelIndex index)
|
||||
: mDataFilesModel->setCheckState(sourceIndex, Qt::Checked);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -110,16 +106,6 @@ QStringList FileOrderList::ContentSelector::checkedItemsPaths()
|
||||
void FileOrderList::ContentSelector::updateViews()
|
||||
{
|
||||
// Ensure the columns are hidden because sort() re-enables them
|
||||
/*
|
||||
mastersTable->setColumnHidden(1, true);
|
||||
mastersTable->setColumnHidden(3, true);
|
||||
mastersTable->setColumnHidden(4, true);
|
||||
mastersTable->setColumnHidden(5, true);
|
||||
mastersTable->setColumnHidden(6, true);
|
||||
mastersTable->setColumnHidden(7, true);
|
||||
mastersTable->setColumnHidden(8, true);
|
||||
mastersTable->resizeColumnsToContents();
|
||||
*/
|
||||
pluginsTable->setColumnHidden(1, true);
|
||||
pluginsTable->setColumnHidden(3, true);
|
||||
pluginsTable->setColumnHidden(4, true);
|
||||
|
@ -17,10 +17,11 @@ namespace FileOrderList
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
protected:
|
||||
|
||||
DataFilesModel *mDataFilesModel;
|
||||
MasterProxyModel *mMasterProxyModel;
|
||||
PluginsProxyModel *mPluginsProxyModel;
|
||||
QSortFilterProxyModel *mFilterProxyModel;
|
||||
|
||||
public:
|
||||
explicit ContentSelector(QWidget *parent = 0);
|
||||
|
@ -4,8 +4,9 @@
|
||||
PluginsProxyModel::PluginsProxyModel(QObject *parent, DataFilesModel *model) :
|
||||
QSortFilterProxyModel(parent), mSourceModel (model)
|
||||
{
|
||||
setFilterRegExp(QString("addon"));
|
||||
setFilterRegExp (QString("addon"));
|
||||
setFilterRole (Qt::UserRole);
|
||||
setDynamicSortFilter (true);
|
||||
|
||||
if (model)
|
||||
setSourceModel (model);
|
||||
|
Loading…
x
Reference in New Issue
Block a user