34 : QSortFilterProxyModel(parent)
42 setDynamicSortFilter(
true);
43 setSortCaseSensitivity(Qt::CaseInsensitive);
64 if (!child.isValid())
return {};
66 QModelIndex sourceParent =
m_model->
parent(mapToSource(child));
67 if (!sourceParent.isValid())
return {};
69 return mapFromSource(sourceParent);
80 return QSortFilterProxyModel::filterAcceptsRow(sourceRow, sourceParent);
92 if (leftType == rightType)
94 const QString strL = left.data().toString();
95 const QString strR = right.data().toString();
106 return QSortFilterProxyModel::lessThan(left, right);
112 for (
int i = 0; i < rowCount(); ++i)
113 setData(index(i, 0), Qt::Checked, Qt::CheckStateRole);
115 emit dataChanged(index(0, 0), index((rowCount() - 1), (columnCount() - 1)));
120 for (
int i = 0; i < rowCount(); ++i)
121 setData(index(i, 0), Qt::Unchecked, Qt::CheckStateRole);
123 emit dataChanged(index(0, 0), index((rowCount() - 1), (columnCount() - 1)));
130 QString name = folder.data().toString();
131 if (name.contains(filterRegularExpression()))
135 QModelIndex childIndex =
m_model->
index(child, 0, folder);
136 if (
m_model->hasChildren(childIndex))
142 name = childIndex.data().toString();
143 if (name.contains(filterRegularExpression()))
void filteredFilesChanged()
TorrentContentFilterModel(QObject *parent=nullptr)
TorrentContentModelItem::ItemType itemType(const QModelIndex &index) const
TorrentContentModel * model() const
Utils::Compare::NaturalLessThan< Qt::CaseInsensitive > m_naturalLessThan
int getFileIndex(const QModelIndex &index) const
bool hasFiltered(const QModelIndex &folder) const
QModelIndex parent(const QModelIndex &child) const override
TorrentContentModel * m_model
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override
void filteredFilesChanged()
TorrentContentModelItem::ItemType itemType(const QModelIndex &index) const
QModelIndex index(int row, int column, const QModelIndex &parent={}) const override
int getFileIndex(const QModelIndex &index)
QModelIndex parent(const QModelIndex &index) const override
int rowCount(const QModelIndex &parent={}) const override