![]() |
LeechCraft 0.6.70-19424-g027e980fd1
Modular cross-platform feature rich live environment.
|
#include "flattofoldersproxymodel.h"
Classes | |
| struct | Config |
Public Member Functions | |
| FlatToFoldersProxyModel (Config, QObject *=nullptr) | |
| int | columnCount (const QModelIndex &={}) const override |
| QVariant | data (const QModelIndex &, int=Qt::DisplayRole) const override |
| QVariant | headerData (int, Qt::Orientation, int) const override |
| Qt::ItemFlags | flags (const QModelIndex &) const override |
| bool | setData (const QModelIndex &, const QVariant &, int=Qt::EditRole) override |
| QModelIndex | index (int, int, const QModelIndex &={}) const override |
| QModelIndex | parent (const QModelIndex &) const override |
| int | rowCount (const QModelIndex &={}) const override |
| Qt::DropActions | supportedDropActions () const override |
| QStringList | mimeTypes () const override |
| QMimeData * | mimeData (const QModelIndexList &indexes) const override |
| bool | dropMimeData (const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override |
| void | SetSourceModel (QAbstractItemModel *) |
| QAbstractItemModel * | GetSourceModel () const |
| QModelIndex | MapToSource (const QModelIndex &) const |
| QList< QModelIndex > | MapFromSource (const QModelIndex &) const |
| bool | IsFolder (const QModelIndex &) const |
| QList< QModelIndex > | GetChildren (const QModelIndex &) const |
| QList< QVariant > | GetChildrenData (const QModelIndex &index, int role) const |
| template<typename T> | |
| QList< T > | GetChildrenData (const QModelIndex &index, int role) const |
| void | ReplaceKey (const QString &old, const QStringList &newKeys) |
| Updates the folders after the key old was replaced with newKeys on every row that had it, the other keys of the rows being unchanged. | |
Groups the rows of a flat source model into folders by key.
Config::KeysOf_ yields the keys of a source row from its column 0 index, and the row appears under the folder of each of them, a key listed twice counting once. Rows with no keys go into a single unkeyed folder. A folder shows its key as Qt::DisplayRole, the unkeyed one shows Config::UnkeyedLabel_. Leaves expose the columns of their source rows and map back via MapToSource().
A drop onto a folder reaches the source model's dropMimeData() with the folder's key under the Config::DropFormat_ format, empty for the unkeyed folder.
When the keys of the rows change without the source announcing it, ReplaceKey() moves the rows along.
The source must be flat, and its layout changes must move rows as units, as every row sort does. Layout changes of the source are not forwarded, and a source rearranging cells independently of each other is not supported.
Definition at line 46 of file flattofoldersproxymodel.h.
|
explicit |
Definition at line 72 of file flattofoldersproxymodel.cpp.
References LC::Util::InstallModelSanitizer(), and parent().
Referenced by LC::Util::TagsFoldersProxyModel::TagsFoldersProxyModel().
|
override |
Definition at line 80 of file flattofoldersproxymodel.cpp.
|
override |
Definition at line 87 of file flattofoldersproxymodel.cpp.
References LC::Util::FlatTreeItem::Folder, index(), and LC::Util::FlatTreeItem::Item.
Referenced by dropMimeData().
|
override |
Definition at line 210 of file flattofoldersproxymodel.cpp.
References data(), and parent().
|
override |
Definition at line 114 of file flattofoldersproxymodel.cpp.
References index(), and LC::Util::FlatTreeItem::Item.
| QList< QModelIndex > LC::Util::FlatToFoldersProxyModel::GetChildren | ( | const QModelIndex & | index | ) | const |
Definition at line 301 of file flattofoldersproxymodel.cpp.
References index(), and IsFolder().
Referenced by GetChildrenData().
|
inline |
Definition at line 91 of file flattofoldersproxymodel.h.
References GetChildrenData(), and index().
| QList< QVariant > LC::Util::FlatToFoldersProxyModel::GetChildrenData | ( | const QModelIndex & | index, |
| int | role ) const |
Definition at line 314 of file flattofoldersproxymodel.cpp.
References GetChildren(), and index().
Referenced by GetChildrenData().
| QAbstractItemModel * LC::Util::FlatToFoldersProxyModel::GetSourceModel | ( | ) | const |
Definition at line 266 of file flattofoldersproxymodel.cpp.
Referenced by MapToSource().
|
override |
Definition at line 106 of file flattofoldersproxymodel.cpp.
|
override |
Definition at line 145 of file flattofoldersproxymodel.cpp.
References parent().
Referenced by data(), flags(), GetChildren(), GetChildrenData(), IsFolder(), mimeData(), parent(), rowCount(), and setData().
| bool LC::Util::FlatToFoldersProxyModel::IsFolder | ( | const QModelIndex & | index | ) | const |
Definition at line 295 of file flattofoldersproxymodel.cpp.
References LC::Util::FlatTreeItem::Folder, and index().
Referenced by GetChildren().
| QList< QModelIndex > LC::Util::FlatToFoldersProxyModel::MapFromSource | ( | const QModelIndex & | source | ) | const |
Definition at line 287 of file flattofoldersproxymodel.cpp.
| QModelIndex LC::Util::FlatToFoldersProxyModel::MapToSource | ( | const QModelIndex & | proxy | ) | const |
Definition at line 271 of file flattofoldersproxymodel.cpp.
References GetSourceModel(), and LC::Util::FlatTreeItem::Item.
Referenced by mimeData().
|
override |
Definition at line 184 of file flattofoldersproxymodel.cpp.
References LC::Util::FlatTreeItem::Folder, index(), LC::Util::FlatTreeItem::Item, and MapToSource().
|
override |
Definition at line 177 of file flattofoldersproxymodel.cpp.
|
override |
Definition at line 153 of file flattofoldersproxymodel.cpp.
References index(), parent(), and LC::Util::FlatTreeItem::Root.
Referenced by FlatToFoldersProxyModel(), LC::Util::TagsFoldersProxyModel::TagsFoldersProxyModel(), dropMimeData(), index(), and parent().
| void LC::Util::FlatToFoldersProxyModel::ReplaceKey | ( | const QString & | old, |
| const QStringList & | newKeys ) |
Updates the folders after the key old was replaced with newKeys on every row that had it, the other keys of the rows being unchanged.
A single new key without a folder yet renames the folder of old in place, keeping its rows; otherwise the rows move to the folders of newKeys.
Definition at line 413 of file flattofoldersproxymodel.cpp.
Referenced by LC::Util::TagsFoldersProxyModel::TagsFoldersProxyModel().
|
override |
Definition at line 162 of file flattofoldersproxymodel.cpp.
References index().
|
override |
Definition at line 132 of file flattofoldersproxymodel.cpp.
References index(), and LC::Util::FlatTreeItem::Item.
| void LC::Util::FlatToFoldersProxyModel::SetSourceModel | ( | QAbstractItemModel * | model | ) |
Definition at line 225 of file flattofoldersproxymodel.cpp.
|
override |
Definition at line 170 of file flattofoldersproxymodel.cpp.