mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-21 11:39:44 +00:00
Began migrating code to ContentSelector base
This commit is contained in:
parent
4c8c6d6971
commit
61602789e1
9 changed files with 232 additions and 129 deletions
|
@ -15,7 +15,7 @@
|
||||||
#include <components/fileorderlist/utils/naturalsort.hpp>
|
#include <components/fileorderlist/utils/naturalsort.hpp>
|
||||||
#include <components/fileorderlist/utils/profilescombobox.hpp>
|
#include <components/fileorderlist/utils/profilescombobox.hpp>
|
||||||
|
|
||||||
#include <components/fileorderlist/masterproxymodel.hpp>"a.out.h"
|
#include "components/fileorderlist/masterproxymodel.hpp"
|
||||||
#include "settings/gamesettings.hpp"
|
#include "settings/gamesettings.hpp"
|
||||||
#include "settings/launchersettings.hpp"
|
#include "settings/launchersettings.hpp"
|
||||||
|
|
||||||
|
@ -25,10 +25,11 @@ DataFilesPage::DataFilesPage(Files::ConfigurationManager &cfg, GameSettings &gam
|
||||||
: mCfgMgr(cfg)
|
: mCfgMgr(cfg)
|
||||||
, mGameSettings(gameSettings)
|
, mGameSettings(gameSettings)
|
||||||
, mLauncherSettings(launcherSettings)
|
, mLauncherSettings(launcherSettings)
|
||||||
, QWidget(parent)
|
, ContentSelector(parent)
|
||||||
{
|
{
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
|
buildModelsAndViews();
|
||||||
|
/*
|
||||||
// Models
|
// Models
|
||||||
mDataFilesModel = new DataFilesModel (this);
|
mDataFilesModel = new DataFilesModel (this);
|
||||||
|
|
||||||
|
@ -41,11 +42,11 @@ DataFilesPage::DataFilesPage(Files::ConfigurationManager &cfg, GameSettings &gam
|
||||||
mFilterProxyModel->setSourceModel(mPluginsProxyModel);
|
mFilterProxyModel->setSourceModel(mPluginsProxyModel);
|
||||||
|
|
||||||
masterView->setModel (mMastersProxyModel);
|
masterView->setModel (mMastersProxyModel);
|
||||||
/*
|
|
||||||
QCheckBox checkBox;
|
//QCheckBox checkBox;
|
||||||
unsigned int height = checkBox.sizeHint().height() + 4;
|
// unsigned int height = checkBox.sizeHint().height() + 4;
|
||||||
*/
|
|
||||||
/*
|
|
||||||
mastersTable->setModel(mMastersProxyModel);
|
mastersTable->setModel(mMastersProxyModel);
|
||||||
mastersTable->setObjectName("MastersTable");
|
mastersTable->setObjectName("MastersTable");
|
||||||
mastersTable->setContextMenuPolicy(Qt::CustomContextMenu);
|
mastersTable->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
|
@ -61,7 +62,7 @@ DataFilesPage::DataFilesPage(Files::ConfigurationManager &cfg, GameSettings &gam
|
||||||
mastersTable->verticalHeader()->setDefaultSectionSize(height);
|
mastersTable->verticalHeader()->setDefaultSectionSize(height);
|
||||||
mastersTable->verticalHeader()->setResizeMode(QHeaderView::Fixed);
|
mastersTable->verticalHeader()->setResizeMode(QHeaderView::Fixed);
|
||||||
mastersTable->verticalHeader()->hide();
|
mastersTable->verticalHeader()->hide();
|
||||||
*/
|
|
||||||
pluginsTable->setModel(mFilterProxyModel);
|
pluginsTable->setModel(mFilterProxyModel);
|
||||||
pluginsTable->setObjectName("PluginsTable");
|
pluginsTable->setObjectName("PluginsTable");
|
||||||
pluginsTable->setContextMenuPolicy(Qt::CustomContextMenu);
|
pluginsTable->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
|
@ -76,7 +77,7 @@ DataFilesPage::DataFilesPage(Files::ConfigurationManager &cfg, GameSettings &gam
|
||||||
|
|
||||||
//pluginsTable->verticalHeader()->setDefaultSectionSize(height);
|
//pluginsTable->verticalHeader()->setDefaultSectionSize(height);
|
||||||
//pluginsTable->verticalHeader()->setResizeMode(QHeaderView::Fixed);
|
//pluginsTable->verticalHeader()->setResizeMode(QHeaderView::Fixed);
|
||||||
|
*/
|
||||||
// Adjust the tableview widths inside the splitter
|
// Adjust the tableview widths inside the splitter
|
||||||
QList<int> sizeList;
|
QList<int> sizeList;
|
||||||
sizeList << mLauncherSettings.value(QString("General/MastersTable/width"), QString("200")).toInt();
|
sizeList << mLauncherSettings.value(QString("General/MastersTable/width"), QString("200")).toInt();
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include <QModelIndex>
|
#include <QModelIndex>
|
||||||
|
|
||||||
#include "ui_datafilespage.h"
|
#include "ui_datafilespage.h"
|
||||||
|
#include "components/fileorderlist/contentselector.hpp"
|
||||||
|
|
||||||
class QSortFilterProxyModel;
|
class QSortFilterProxyModel;
|
||||||
class QAbstractItemModel;
|
class QAbstractItemModel;
|
||||||
|
@ -19,10 +20,9 @@ class PluginsProxyModel;
|
||||||
|
|
||||||
namespace Files { struct ConfigurationManager; }
|
namespace Files { struct ConfigurationManager; }
|
||||||
|
|
||||||
class DataFilesPage : public QWidget, private Ui::DataFilesPage
|
class DataFilesPage : public FileOrderList::ContentSelector
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DataFilesPage(Files::ConfigurationManager &cfg, GameSettings &gameSettings, LauncherSettings &launcherSettings, QWidget *parent = 0);
|
DataFilesPage(Files::ConfigurationManager &cfg, GameSettings &gameSettings, LauncherSettings &launcherSettings, QWidget *parent = 0);
|
||||||
|
|
||||||
|
|
|
@ -19,10 +19,11 @@
|
||||||
#include "components/fileorderlist/masterproxymodel.hpp"
|
#include "components/fileorderlist/masterproxymodel.hpp"
|
||||||
|
|
||||||
FileDialog::FileDialog(QWidget *parent) :
|
FileDialog::FileDialog(QWidget *parent) :
|
||||||
QDialog(parent)
|
ContentSelector(parent)
|
||||||
{
|
{
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
|
buildModelsAndViews();
|
||||||
|
/*
|
||||||
// Models
|
// Models
|
||||||
mDataFilesModel = new DataFilesModel (this);
|
mDataFilesModel = new DataFilesModel (this);
|
||||||
|
|
||||||
|
@ -33,12 +34,12 @@ FileDialog::FileDialog(QWidget *parent) :
|
||||||
mFilterProxyModel = new QSortFilterProxyModel();
|
mFilterProxyModel = new QSortFilterProxyModel();
|
||||||
mFilterProxyModel->setDynamicSortFilter(true);
|
mFilterProxyModel->setDynamicSortFilter(true);
|
||||||
mFilterProxyModel->setSourceModel(mPluginsProxyModel);
|
mFilterProxyModel->setSourceModel(mPluginsProxyModel);
|
||||||
/*
|
|
||||||
QCheckBox checkBox;
|
// QCheckBox checkBox;
|
||||||
unsigned int height = checkBox.sizeHint().height() + 4;
|
// unsigned int height = checkBox.sizeHint().height() + 4;
|
||||||
*/
|
|
||||||
masterView->setModel(mMastersProxyModel);
|
masterView->setModel(mMastersProxyModel);
|
||||||
/*
|
|
||||||
mastersTable->setModel(mMastersProxyModel);
|
mastersTable->setModel(mMastersProxyModel);
|
||||||
mastersTable->setObjectName("MastersTable");
|
mastersTable->setObjectName("MastersTable");
|
||||||
mastersTable->setContextMenuPolicy(Qt::CustomContextMenu);
|
mastersTable->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
|
@ -53,7 +54,7 @@ FileDialog::FileDialog(QWidget *parent) :
|
||||||
mastersTable->verticalHeader()->setDefaultSectionSize(height);
|
mastersTable->verticalHeader()->setDefaultSectionSize(height);
|
||||||
mastersTable->verticalHeader()->setResizeMode(QHeaderView::Fixed);
|
mastersTable->verticalHeader()->setResizeMode(QHeaderView::Fixed);
|
||||||
mastersTable->verticalHeader()->hide();
|
mastersTable->verticalHeader()->hide();
|
||||||
*/
|
|
||||||
pluginsTable->setModel(mFilterProxyModel);
|
pluginsTable->setModel(mFilterProxyModel);
|
||||||
pluginsTable->setObjectName("PluginsTable");
|
pluginsTable->setObjectName("PluginsTable");
|
||||||
pluginsTable->setContextMenuPolicy(Qt::CustomContextMenu);
|
pluginsTable->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
|
@ -64,10 +65,11 @@ FileDialog::FileDialog(QWidget *parent) :
|
||||||
pluginsTable->setAlternatingRowColors(true);
|
pluginsTable->setAlternatingRowColors(true);
|
||||||
pluginsTable->setVerticalScrollMode(QAbstractItemView::ScrollPerItem);
|
pluginsTable->setVerticalScrollMode(QAbstractItemView::ScrollPerItem);
|
||||||
pluginsTable->horizontalHeader()->setStretchLastSection(true);
|
pluginsTable->horizontalHeader()->setStretchLastSection(true);
|
||||||
/*
|
|
||||||
pluginsTable->verticalHeader()->setDefaultSectionSize(height);
|
// pluginsTable->verticalHeader()->setDefaultSectionSize(height);
|
||||||
pluginsTable->verticalHeader()->setResizeMode(QHeaderView::Fixed);
|
// pluginsTable->verticalHeader()->setResizeMode(QHeaderView::Fixed);
|
||||||
*/
|
|
||||||
|
*/
|
||||||
// Hide the profile elements
|
// Hide the profile elements
|
||||||
profileLabel->hide();
|
profileLabel->hide();
|
||||||
profilesComboBox->hide();
|
profilesComboBox->hide();
|
||||||
|
@ -105,43 +107,19 @@ FileDialog::FileDialog(QWidget *parent) :
|
||||||
|
|
||||||
resize(600, 400);
|
resize(600, 400);
|
||||||
|
|
||||||
connect(mDataFilesModel, SIGNAL(layoutChanged()), this, SLOT(updateViews()));
|
//
|
||||||
connect(mDataFilesModel, SIGNAL(checkedItemsChanged(QStringList)), this, SLOT(updateOpenButton(QStringList)));
|
// connect(mDataFilesModel, SIGNAL(checkedItemsChanged(QStringList)), this, SLOT(updateOpenButton(QStringList)));
|
||||||
//connect(mNameLineEdit, SIGNAL(textChanged(QString)), this, SLOT(updateCreateButton(QString)));
|
//connect(mNameLineEdit, SIGNAL(textChanged(QString)), this, SLOT(updateCreateButton(QString)));
|
||||||
|
|
||||||
//connect(filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterChanged(QString)));
|
//connect(filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterChanged(QString)));
|
||||||
|
|
||||||
connect(pluginsTable, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(setCheckState(QModelIndex)));
|
// connect(pluginsTable, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(setCheckState(QModelIndex)));
|
||||||
//connect(mastersTable, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(setCheckState(QModelIndex)));
|
//connect(mastersTable, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(setCheckState(QModelIndex)));
|
||||||
|
|
||||||
connect(mCreateButton, SIGNAL(clicked()), this, SLOT(createButtonClicked()));
|
// connect(mCreateButton, SIGNAL(clicked()), this, SLOT(createButtonClicked()));
|
||||||
|
|
||||||
connect(mButtonBox, SIGNAL(accepted()), this, SLOT(accept()));
|
|
||||||
connect(mButtonBox, SIGNAL(rejected()), this, SLOT(reject()));
|
|
||||||
}
|
|
||||||
|
|
||||||
void FileDialog::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);
|
|
||||||
pluginsTable->setColumnHidden(5, true);
|
|
||||||
pluginsTable->setColumnHidden(6, true);
|
|
||||||
pluginsTable->setColumnHidden(7, true);
|
|
||||||
pluginsTable->setColumnHidden(8, true);
|
|
||||||
pluginsTable->resizeColumnsToContents();
|
|
||||||
|
|
||||||
|
// connect(mButtonBox, SIGNAL(accepted()), this, SLOT(accept()));
|
||||||
|
// connect(mButtonBox, SIGNAL(rejected()), this, SLOT(reject()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileDialog::updateOpenButton(const QStringList &items)
|
void FileDialog::updateOpenButton(const QStringList &items)
|
||||||
|
@ -161,64 +139,13 @@ void FileDialog::updateCreateButton(const QString &name)
|
||||||
|
|
||||||
mCreateButton->setEnabled(!name.isEmpty());
|
mCreateButton->setEnabled(!name.isEmpty());
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
void FileDialog::filterChanged(const QString &filter)
|
void FileDialog::filterChanged(const QString &filter)
|
||||||
{
|
{
|
||||||
QRegExp filterRe(filter, Qt::CaseInsensitive, QRegExp::FixedString);
|
QRegExp filterRe(filter, Qt::CaseInsensitive, QRegExp::FixedString);
|
||||||
mFilterProxyModel->setFilterRegExp(filterRe);
|
mFilterProxyModel->setFilterRegExp(filterRe);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
void FileDialog::addFiles(const QString &path)
|
|
||||||
{
|
|
||||||
mDataFilesModel->addFiles(path);
|
|
||||||
mDataFilesModel->sort(3); // Sort by date accessed
|
|
||||||
}
|
|
||||||
|
|
||||||
void FileDialog::setEncoding(const QString &encoding)
|
|
||||||
{
|
|
||||||
mDataFilesModel->setEncoding(encoding);
|
|
||||||
}
|
|
||||||
|
|
||||||
void FileDialog::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;
|
|
||||||
}
|
|
||||||
|
|
||||||
QStringList FileDialog::checkedItemsPaths()
|
|
||||||
{
|
|
||||||
return mDataFilesModel->checkedItemsPaths();
|
|
||||||
}
|
|
||||||
|
|
||||||
QString FileDialog::fileName()
|
QString FileDialog::fileName()
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QModelIndex>
|
#include <QModelIndex>
|
||||||
|
|
||||||
|
#include "components/fileorderlist/contentselector.hpp"
|
||||||
#include "ui_datafilespage.h"
|
#include "ui_datafilespage.h"
|
||||||
|
|
||||||
class QDialogButtonBox;
|
class QDialogButtonBox;
|
||||||
|
@ -17,19 +18,16 @@ class QMenu;
|
||||||
class DataFilesModel;
|
class DataFilesModel;
|
||||||
class PluginsProxyModel;
|
class PluginsProxyModel;
|
||||||
|
|
||||||
class FileDialog : public QDialog, private Ui::DataFilesPage
|
class FileDialog : public FileOrderList::ContentSelector
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit FileDialog(QWidget *parent = 0);
|
explicit FileDialog(QWidget *parent = 0);
|
||||||
void addFiles(const QString &path);
|
|
||||||
void setEncoding(const QString &encoding);
|
|
||||||
|
|
||||||
void openFile();
|
void openFile();
|
||||||
void newFile();
|
void newFile();
|
||||||
void accepted();
|
void accepted();
|
||||||
|
|
||||||
QStringList checkedItemsPaths();
|
|
||||||
QString fileName();
|
QString fileName();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
@ -40,12 +38,12 @@ public slots:
|
||||||
void accept();
|
void accept();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void updateViews();
|
//void updateViews();
|
||||||
void updateOpenButton(const QStringList &items);
|
void updateOpenButton(const QStringList &items);
|
||||||
void updateCreateButton(const QString &name);
|
void updateCreateButton(const QString &name);
|
||||||
void setCheckState(QModelIndex index);
|
|
||||||
|
|
||||||
void filterChanged(const QString &filter);
|
|
||||||
|
//void filterChanged(const QString &filter);
|
||||||
|
|
||||||
void createButtonClicked();
|
void createButtonClicked();
|
||||||
|
|
||||||
|
|
|
@ -66,22 +66,25 @@ add_component_dir (translation
|
||||||
translation
|
translation
|
||||||
)
|
)
|
||||||
|
|
||||||
|
set (ESM_UI ${CMAKE_SOURCE_DIR}/files/ui/datafilespage.ui
|
||||||
|
)
|
||||||
find_package(Qt4 COMPONENTS QtCore QtGui)
|
find_package(Qt4 COMPONENTS QtCore QtGui)
|
||||||
|
|
||||||
if(QT_QTGUI_LIBRARY AND QT_QTCORE_LIBRARY)
|
if(QT_QTGUI_LIBRARY AND QT_QTCORE_LIBRARY)
|
||||||
add_component_qt_dir (fileorderlist
|
add_component_qt_dir (fileorderlist
|
||||||
masterproxymodel
|
masterproxymodel contentselector
|
||||||
model/modelitem model/datafilesmodel model/pluginsproxymodel model/esm/esmfile
|
model/modelitem model/datafilesmodel model/pluginsproxymodel model/esm/esmfile
|
||||||
utils/profilescombobox utils/comboboxlineedit utils/lineedit utils/naturalsort
|
utils/profilescombobox utils/comboboxlineedit utils/lineedit utils/naturalsort
|
||||||
)
|
)
|
||||||
|
|
||||||
include(${QT_USE_FILE})
|
include(${QT_USE_FILE})
|
||||||
|
QT4_WRAP_UI(ESM_UI_HDR ${ESM_UI})
|
||||||
QT4_WRAP_CPP(MOC_SRCS ${COMPONENT_MOC_FILES})
|
QT4_WRAP_CPP(MOC_SRCS ${COMPONENT_MOC_FILES})
|
||||||
endif(QT_QTGUI_LIBRARY AND QT_QTCORE_LIBRARY)
|
endif(QT_QTGUI_LIBRARY AND QT_QTCORE_LIBRARY)
|
||||||
|
|
||||||
include_directories(${BULLET_INCLUDE_DIRS})
|
include_directories(${BULLET_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
|
||||||
add_library(components STATIC ${COMPONENT_FILES} ${MOC_SRCS})
|
add_library(components STATIC ${COMPONENT_FILES} ${MOC_SRCS} ${ESM_UI_HDR})
|
||||||
|
|
||||||
target_link_libraries(components ${Boost_LIBRARIES} ${OGRE_LIBRARIES})
|
target_link_libraries(components ${Boost_LIBRARIES} ${OGRE_LIBRARIES})
|
||||||
|
|
||||||
|
|
132
components/fileorderlist/contentselector.cpp
Normal file
132
components/fileorderlist/contentselector.cpp
Normal file
|
@ -0,0 +1,132 @@
|
||||||
|
#include "contentselector.hpp"
|
||||||
|
|
||||||
|
#include "model/datafilesmodel.hpp"
|
||||||
|
#include "masterproxymodel.hpp"
|
||||||
|
#include "model/pluginsproxymodel.hpp"
|
||||||
|
|
||||||
|
#include <QSortFilterProxyModel>
|
||||||
|
|
||||||
|
FileOrderList::ContentSelector::ContentSelector(QWidget *parent) :
|
||||||
|
QWidget(parent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void FileOrderList::ContentSelector::buildModelsAndViews()
|
||||||
|
{
|
||||||
|
// Models
|
||||||
|
mDataFilesModel = new DataFilesModel (this);
|
||||||
|
|
||||||
|
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);
|
||||||
|
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);
|
||||||
|
|
||||||
|
connect(mDataFilesModel, SIGNAL(layoutChanged()), this, SLOT(updateViews()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void FileOrderList::ContentSelector::addFiles(const QString &path)
|
||||||
|
{
|
||||||
|
mDataFilesModel->addFiles(path);
|
||||||
|
mDataFilesModel->sort(3); // Sort by date accessed
|
||||||
|
}
|
||||||
|
|
||||||
|
void FileOrderList::ContentSelector::setEncoding(const QString &encoding)
|
||||||
|
{
|
||||||
|
mDataFilesModel->setEncoding(encoding);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FileOrderList::ContentSelector::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 = mMasterProxyModel->mapToSource(index);
|
||||||
|
|
||||||
|
if (sourceIndex.isValid()) {
|
||||||
|
(mDataFilesModel->checkState(sourceIndex) == Qt::Checked)
|
||||||
|
? mDataFilesModel->setCheckState(sourceIndex, Qt::Unchecked)
|
||||||
|
: mDataFilesModel->setCheckState(sourceIndex, Qt::Checked);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList FileOrderList::ContentSelector::checkedItemsPaths()
|
||||||
|
{
|
||||||
|
return mDataFilesModel->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);
|
||||||
|
pluginsTable->setColumnHidden(5, true);
|
||||||
|
pluginsTable->setColumnHidden(6, true);
|
||||||
|
pluginsTable->setColumnHidden(7, true);
|
||||||
|
pluginsTable->setColumnHidden(8, true);
|
||||||
|
pluginsTable->resizeColumnsToContents();
|
||||||
|
|
||||||
|
}
|
40
components/fileorderlist/contentselector.hpp
Normal file
40
components/fileorderlist/contentselector.hpp
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
#ifndef CONTENTSELECTOR_HPP
|
||||||
|
#define CONTENTSELECTOR_HPP
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
|
#include "ui_datafilespage.h"
|
||||||
|
|
||||||
|
class DataFilesModel;
|
||||||
|
class PluginsProxyModel;
|
||||||
|
class QSortFilterProxyModel;
|
||||||
|
|
||||||
|
namespace FileOrderList
|
||||||
|
{
|
||||||
|
class MasterProxyModel;
|
||||||
|
|
||||||
|
class ContentSelector : public QWidget, protected Ui::DataFilesPage
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
DataFilesModel *mDataFilesModel;
|
||||||
|
MasterProxyModel *mMasterProxyModel;
|
||||||
|
PluginsProxyModel *mPluginsProxyModel;
|
||||||
|
QSortFilterProxyModel *mFilterProxyModel;
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit ContentSelector(QWidget *parent = 0);
|
||||||
|
|
||||||
|
void buildModelsAndViews();
|
||||||
|
|
||||||
|
void addFiles(const QString &path);
|
||||||
|
void setEncoding(const QString &encoding);
|
||||||
|
void setCheckState(QModelIndex index);
|
||||||
|
QStringList checkedItemsPaths();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void updateViews();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // CONTENTSELECTOR_HPP
|
|
@ -1,6 +1,6 @@
|
||||||
#include "masterproxymodel.hpp"
|
#include "masterproxymodel.hpp"
|
||||||
|
|
||||||
MasterProxyModel::MasterProxyModel(QObject *parent, QAbstractTableModel* model) :
|
FileOrderList::MasterProxyModel::MasterProxyModel(QObject *parent, QAbstractTableModel* model) :
|
||||||
QSortFilterProxyModel(parent)
|
QSortFilterProxyModel(parent)
|
||||||
{
|
{
|
||||||
setFilterRegExp(QString("game"));
|
setFilterRegExp(QString("game"));
|
||||||
|
@ -10,7 +10,7 @@ MasterProxyModel::MasterProxyModel(QObject *parent, QAbstractTableModel* model)
|
||||||
setSourceModel (model);
|
setSourceModel (model);
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant MasterProxyModel::data(const QModelIndex &index, int role) const
|
QVariant FileOrderList::MasterProxyModel::data(const QModelIndex &index, int role) const
|
||||||
{
|
{
|
||||||
return QSortFilterProxyModel::data (index, role);
|
return QSortFilterProxyModel::data (index, role);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,17 +5,19 @@
|
||||||
|
|
||||||
class QAbstractTableModel;
|
class QAbstractTableModel;
|
||||||
|
|
||||||
class MasterProxyModel : public QSortFilterProxyModel
|
namespace FileOrderList
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
class MasterProxyModel : public QSortFilterProxyModel
|
||||||
public:
|
{
|
||||||
explicit MasterProxyModel(QObject *parent = 0, QAbstractTableModel *model = 0);
|
Q_OBJECT
|
||||||
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
|
public:
|
||||||
|
explicit MasterProxyModel(QObject *parent = 0, QAbstractTableModel *model = 0);
|
||||||
|
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
public slots:
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
#endif // MASTERPROXYMODEL_HPP
|
#endif // MASTERPROXYMODEL_HPP
|
||||||
|
|
Loading…
Reference in a new issue