Continued migration of code to ContentSelector

This commit is contained in:
graffy76 2013-08-17 05:55:43 -05:00
parent 0087b0d67c
commit b24dd5c6ac
7 changed files with 17 additions and 185 deletions

View file

@ -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);

View file

@ -17,10 +17,11 @@ namespace FileOrderList
{
Q_OBJECT
protected:
DataFilesModel *mDataFilesModel;
MasterProxyModel *mMasterProxyModel;
PluginsProxyModel *mPluginsProxyModel;
QSortFilterProxyModel *mFilterProxyModel;
public:
explicit ContentSelector(QWidget *parent = 0);

View file

@ -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);