Moved init code to master / plugin proxy classes

actorid
graffy76 12 years ago
parent 7389507eb5
commit 4c8c6d6971

@ -15,6 +15,7 @@
#include <components/fileorderlist/utils/naturalsort.hpp>
#include <components/fileorderlist/utils/profilescombobox.hpp>
#include <components/fileorderlist/masterproxymodel.hpp>"a.out.h"
#include "settings/gamesettings.hpp"
#include "settings/launchersettings.hpp"
@ -29,19 +30,11 @@ DataFilesPage::DataFilesPage(Files::ConfigurationManager &cfg, GameSettings &gam
setupUi(this);
// Models
mDataFilesModel = new DataFilesModel(this);
mMastersProxyModel = new QSortFilterProxyModel();
mMastersProxyModel->setFilterRegExp(QString("game")); //QString("^.*\\.esm"));
mMastersProxyModel->setFilterRole (Qt::UserRole);
mMastersProxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
mMastersProxyModel->setSourceModel(mDataFilesModel);
mPluginsProxyModel = new PluginsProxyModel();
mPluginsProxyModel->setFilterRegExp(QString("addon")); //^.*\\.esp"));
mPluginsProxyModel->setFilterRole (Qt::UserRole);
mPluginsProxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
mPluginsProxyModel->setSourceModel(mDataFilesModel);
mDataFilesModel = new DataFilesModel (this);
mMastersProxyModel = new MasterProxyModel (this, mDataFilesModel);
mPluginsProxyModel = new PluginsProxyModel (this, mDataFilesModel);
mFilterProxyModel = new QSortFilterProxyModel();
mFilterProxyModel->setDynamicSortFilter(true);

@ -24,25 +24,19 @@ FileDialog::FileDialog(QWidget *parent) :
setupUi(this);
// Models
mDataFilesModel = new DataFilesModel(this);
mDataFilesModel = new DataFilesModel (this);
mMastersProxyModel = new MasterProxyModel();
mMastersProxyModel->setFilterRegExp("game"); //QString("^.*\\.esm"));
mMastersProxyModel->setFilterRole (Qt::UserRole);
mMastersProxyModel->setSourceModel(mDataFilesModel);
mMastersProxyModel = new MasterProxyModel (this, mDataFilesModel);
mPluginsProxyModel = new PluginsProxyModel (this, mDataFilesModel);
mPluginsProxyModel = new PluginsProxyModel();
mPluginsProxyModel->setFilterRegExp("addon"); //QString("^.*\\.esp"));
mPluginsProxyModel->setFilterRole (Qt::UserRole);
mPluginsProxyModel->setSourceModel(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);
@ -70,10 +64,10 @@ FileDialog::FileDialog(QWidget *parent) :
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();

@ -1,8 +1,13 @@
#include "masterproxymodel.hpp"
MasterProxyModel::MasterProxyModel(QObject *parent) :
MasterProxyModel::MasterProxyModel(QObject *parent, QAbstractTableModel* model) :
QSortFilterProxyModel(parent)
{
setFilterRegExp(QString("game"));
setFilterRole (Qt::UserRole);
if (model)
setSourceModel (model);
}
QVariant MasterProxyModel::data(const QModelIndex &index, int role) const

@ -3,11 +3,13 @@
#include <QSortFilterProxyModel>
class QAbstractTableModel;
class MasterProxyModel : public QSortFilterProxyModel
{
Q_OBJECT
public:
explicit MasterProxyModel(QObject *parent = 0);
explicit MasterProxyModel(QObject *parent = 0, QAbstractTableModel *model = 0);
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
signals:

@ -1,8 +1,13 @@
#include "pluginsproxymodel.hpp"
PluginsProxyModel::PluginsProxyModel(QObject *parent) :
PluginsProxyModel::PluginsProxyModel(QObject *parent, QAbstractTableModel *model) :
QSortFilterProxyModel(parent)
{
setFilterRegExp(QString("addon"));
setFilterRole (Qt::UserRole);
if (model)
setSourceModel (model);
}
PluginsProxyModel::~PluginsProxyModel()

@ -4,12 +4,13 @@
#include <QSortFilterProxyModel>
class QVariant;
class QAbstractTableModel;
class PluginsProxyModel : public QSortFilterProxyModel
{
Q_OBJECT
public:
explicit PluginsProxyModel(QObject *parent = 0);
explicit PluginsProxyModel(QObject *parent = 0, QAbstractTableModel *model = 0);
~PluginsProxyModel();
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;

Loading…
Cancel
Save