1#include "SortFilterProxyModel.h"
3#include <QAbstractItemModel>
4#include <QIdentityProxyModel>
7#include <QPersistentModelIndex>
8#include <QSortFilterProxyModel>
9#include <QStandardItem>
12#include "ProjectItem.h"
13#include "ProjectItemModel.h"
17 SortFilterProxyModel::SortFilterProxyModel(
QObject *parent) :
22 void SortFilterProxyModel::setSelectedItems(QList<ProjectItem *> selected){
24 QList<QModelIndex> selIx;
26 selIx.append(item->index() );
30 foreach(QModelIndex ix,selIx) {
31 selectedIndexRows.append(ix.row() );
34 selectedIndices=selIx;
38 void SortFilterProxyModel::setSourceModel(
ProjectItemModel *newSourceModel) {
40 QPersistentModelIndex persistentIndex(newSourceModel->index(0,0,QModelIndex()));
44 if (persistentIndex.isValid()) {
46 m_root = persistentIndex;
50 m_root = QPersistentModelIndex(QModelIndex());
53 baseModel = newSourceModel;
54 QSortFilterProxyModel::setSourceModel(newSourceModel);
58 bool SortFilterProxyModel::setRoot(
const QStandardItem *item) {
60 m_root = QPersistentModelIndex(item->index());
67 bool SortFilterProxyModel::filterAcceptsRow(
int sourceRow,
68 const QModelIndex &sourceParent)
const {
71 if (selectedIndices.count() == 0) {
75 if (this->sourceModel()!=
nullptr) {
76 QModelIndex ix = this->sourceModel()->index( sourceRow, 0, sourceParent );
79 if (selectedIndices.contains(ix) ) {
82 if (item->text() ==
"Images" ) {
Represents an item of a ProjectItemModel in Qt's model-view framework.
Provides access to data stored in a Project through Qt's model-view framework.
ProjectItem * itemFromIndex(const QModelIndex &index)
Returns the ProjectItem corresponding to a given QModelIndex.
This is free and unencumbered software released into the public domain.