|
QtPass 2.0.0
Developer documentation
|
QSortFilterProxyModel for filtering and displaying password store. More...
#include <storemodel.h>
Public Member Functions | |
| StoreModel () | |
| Construct a StoreModel. | |
| void | setPass (Pass *pass) |
| Inject the Pass backend for drag-and-drop Move/Copy operations. | |
| auto | filterAcceptsRow (int source_row, const QModelIndex &source_parent) const -> bool override |
| Filter whether a row should be displayed. | |
| auto | showThis (const QModelIndex &index) const -> bool |
| Check if a specific index should be shown. | |
| void | setModelAndStore (QFileSystemModel *sourceModel, const QString &passStore) |
| Initialize model with source model and store path. | |
| auto | rootIndexFor (const QString &path) -> QModelIndex |
| Set the source filesystem root and map it to a proxy index. | |
| void | setStore (const QString &passStore) |
| Update the store path used for filtering without changing the source model. | |
| auto | data (const QModelIndex &index, int role) const -> QVariant override |
| Get display data for index. | |
| auto | lessThan (const QModelIndex &source_left, const QModelIndex &source_right) const -> bool override |
| Compare two indices for sorting. | |
| auto | getStore () const -> QString |
| Get the password store root path. | |
| auto | supportedDropActions () const -> Qt::DropActions override |
| Get supported drop actions. | |
| auto | supportedDragActions () const -> Qt::DropActions override |
| Get supported drag actions. | |
| auto | flags (const QModelIndex &index) const -> Qt::ItemFlags override |
| Get item flags for index. | |
| auto | mimeTypes () const -> QStringList override |
| Get supported MIME types for drag/drop. | |
| auto | mimeData (const QModelIndexList &indexes) const -> QMimeData *override |
| Create MIME data from indexes. | |
| auto | canDropMimeData (const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const -> bool override |
| Check if drop is possible. | |
| auto | dropMimeData (const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) -> bool override |
| Handle dropped MIME data. | |
Private Member Functions | |
| auto | executeDropAction (const StoreDragItem &info, Qt::DropAction action, const QModelIndex &parent) -> bool |
| Resolve a validated drop into a Move or Copy. | |
| auto | performDrop (const QString &cleanedSrc, const QString &cleanedDest, Qt::DropAction action, bool force) -> bool |
| Perform the actual Move/Copy for a validated drop. | |
Static Private Member Functions | |
| static auto | parseDropData (const QMimeData *data) -> std::optional< StoreDragItem > |
Decode the drag payload from data. | |
Private Attributes | |
| QFileSystemModel * | fs |
| The wrapped file system model, set by setModelAndStore(); null until then, which makes showThis() hide everything. | |
| QString | store |
| Store root used to make paths relative for filtering and for the drop boundary check. | |
| Pass * | m_pass {nullptr} |
| Backend that performs drag-and-drop Move/Copy; not owned, null until setPass(), in which case drops are refused. | |
QSortFilterProxyModel for filtering and displaying password store.
StoreModel wraps QFileSystemModel to provide password store-specific filtering and display functionality. It handles:
Definition at line 84 of file storemodel.h.
| StoreModel::StoreModel | ( | ) |
Construct a StoreModel.
Definition at line 45 of file storemodel.cpp.
|
override |
Check if drop is possible.
| data | MIME data to drop. |
| action | Drop action. |
| row | Target row. |
| column | Target column. |
| parent | Target parent index. |
Definition at line 178 of file storemodel.cpp.
|
nodiscardoverride |
Get display data for index.
| index | Model index. |
| role | Data role (e.g., Qt::DisplayRole). |
Definition at line 111 of file storemodel.cpp.
|
override |
Handle dropped MIME data.
| data | MIME data to drop. |
| action | Drop action. |
| row | Target row. |
| column | Target column. |
| parent | Target parent index. |
Definition at line 214 of file storemodel.cpp.
|
private |
Resolve a validated drop into a Move or Copy.
Both endpoints must resolve inside the store after symlink resolution (the payload could be crafted). A directory is dropped into the target folder; a file onto a folder goes into it, a file onto a file asks the user before overwriting.
| info | The decoded drag payload. |
| action | Qt::MoveAction or Qt::CopyAction. |
| parent | Proxy index of the drop target. |
Definition at line 255 of file storemodel.cpp.
|
nodiscardoverride |
Filter whether a row should be displayed.
| source_row | Row index in source model. |
| source_parent | Parent index in source model. |
Definition at line 49 of file storemodel.cpp.
|
nodiscardoverride |
Get item flags for index.
| index | Model index. |
Definition at line 136 of file storemodel.cpp.
|
inlinenodiscard |
|
nodiscardoverride |
Compare two indices for sorting.
| source_left | Left index to compare. |
| source_right | Right index to compare. |
Definition at line 318 of file storemodel.cpp.
|
nodiscardoverride |
Create MIME data from indexes.
| indexes | List of selected indexes. |
Definition at line 151 of file storemodel.cpp.
|
nodiscardoverride |
Get supported MIME types for drag/drop.
Definition at line 145 of file storemodel.cpp.
|
staticprivate |
Decode the drag payload from data.
| data | MIME data of the drop; may be null. |
data is null, carries no payload of ours, or the payload does not deserialise cleanly. Definition at line 237 of file storemodel.cpp.
|
private |
Perform the actual Move/Copy for a validated drop.
| cleanedSrc | Canonical source path (inside the store). |
| cleanedDest | Canonical destination path (inside the store). |
| action | Qt::MoveAction or Qt::CopyAction. |
| force | Overwrite an existing destination. |
Definition at line 304 of file storemodel.cpp.
| auto StoreModel::rootIndexFor | ( | const QString & | path | ) | -> QModelIndex |
Set the source filesystem root and map it to a proxy index.
Wraps the recurring mapFromSource(fs->setRootPath(path)) dance used to point the tree view at a directory, so callers don't reach through to the wrapped QFileSystemModel.
| path | Directory to make the source root. |
Definition at line 92 of file storemodel.cpp.
| void StoreModel::setModelAndStore | ( | QFileSystemModel * | sourceModel, |
| const QString & | passStore ) |
Initialize model with source model and store path.
| sourceModel | Filesystem model to wrap. |
| passStore | Root path of password store. |
Definition at line 85 of file storemodel.cpp.
| void StoreModel::setPass | ( | Pass * | pass | ) |
Inject the Pass backend for drag-and-drop Move/Copy operations.
| pass | Pass backend instance; must outlive this StoreModel. |
Definition at line 47 of file storemodel.cpp.
| void StoreModel::setStore | ( | const QString & | passStore | ) |
Update the store path used for filtering without changing the source model.
| passStore | New root path of password store. |
Definition at line 99 of file storemodel.cpp.
|
nodiscard |
Check if a specific index should be shown.
| index | Model index to check. |
Definition at line 56 of file storemodel.cpp.
|
nodiscardoverride |
Get supported drag actions.
Definition at line 132 of file storemodel.cpp.
|
nodiscardoverride |
Get supported drop actions.
Definition at line 128 of file storemodel.cpp.
|
private |
The wrapped file system model, set by setModelAndStore(); null until then, which makes showThis() hide everything.
Definition at line 92 of file storemodel.h.
|
private |
Backend that performs drag-and-drop Move/Copy; not owned, null until setPass(), in which case drops are refused.
Definition at line 102 of file storemodel.h.
|
private |
Store root used to make paths relative for filtering and for the drop boundary check.
Definition at line 97 of file storemodel.h.