|
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. | |
| auto | hasChildren (const QModelIndex &parent=QModelIndex()) const -> bool override |
| No children for a link inside the store: it is listed by name but never entered, so the view shows no expand arrow. | |
| auto | canFetchMore (const QModelIndex &parent) const -> bool override |
| Nothing to fetch under a link inside the store, so the file system model never lists what the link points to. | |
| void | fetchMore (const QModelIndex &parent) override |
| Fetch more rows, except under a link inside the store. | |
| 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. | |
Static Public Member Functions | |
| static auto | wordsFilter (const QString &query) -> QRegularExpression |
| The tree filter for what is typed in the search box. | |
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. | |
| auto | isLinkInStore (const QModelIndex &proxyIndex) const -> bool |
| Whether a proxy index is a link (or junction) inside the store, the store root excluded. | |
| auto | pathOf (const QModelIndex &sourceIndex) const -> QString |
| The path of a file system model index, as the node keeps it. | |
| auto | showsFolder (const QModelIndex &index, const QString &path, bool inside, bool outside) const -> bool |
| showThis() for a folder with rows: shown when any of them is, or, in a search, when its own name matches. | |
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 85 of file storemodel.h.
| StoreModel::StoreModel | ( | ) |
Construct a StoreModel.
Definition at line 46 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 265 of file storemodel.cpp.
|
nodiscardoverride |
Nothing to fetch under a link inside the store, so the file system model never lists what the link points to.
| parent | Proxy index. |
Definition at line 159 of file storemodel.cpp.
|
nodiscardoverride |
Get display data for index.
| index | Model index. |
| role | Data role (e.g., Qt::DisplayRole). |
Definition at line 195 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 301 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 342 of file storemodel.cpp.
|
override |
Fetch more rows, except under a link inside the store.
| parent | Proxy index. |
Definition at line 163 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 50 of file storemodel.cpp.
|
nodiscardoverride |
Get item flags for index.
| index | Model index. |
Definition at line 223 of file storemodel.cpp.
|
inlinenodiscard |
Get the password store root path.
Definition at line 288 of file storemodel.h.
|
nodiscardoverride |
No children for a link inside the store: it is listed by name but never entered, so the view shows no expand arrow.
| parent | Proxy index. |
Definition at line 155 of file storemodel.cpp.
|
nodiscardprivate |
Whether a proxy index is a link (or junction) inside the store, the store root excluded.
| proxyIndex | Index in this model. |
Definition at line 132 of file storemodel.cpp.
|
nodiscardoverride |
Compare two indices for sorting.
| source_left | Left index to compare. |
| source_right | Right index to compare. |
Definition at line 416 of file storemodel.cpp.
|
nodiscardoverride |
Create MIME data from indexes.
| indexes | List of selected indexes. |
Definition at line 238 of file storemodel.cpp.
|
nodiscardoverride |
Get supported MIME types for drag/drop.
Definition at line 232 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 324 of file storemodel.cpp.
|
nodiscardprivate |
The path of a file system model index, as the node keeps it.
Not QFileSystemModel::filePath(): that rebuilds the path through parent(), which looks each folder up among all its siblings, and on Windows it gives a resolved link's target instead of the link.
| sourceIndex | Index in the file system model; fs must be set. |
Definition at line 147 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 393 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 176 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 169 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 48 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 183 of file storemodel.cpp.
|
nodiscardprivate |
showThis() for a folder with rows: shown when any of them is, or, in a search, when its own name matches.
| index | The folder's index in the source model. |
| path | Its path relative to the store. |
| inside | Whether it lies inside the store, below its root. |
| outside | Whether it lies outside the store. |
Definition at line 95 of file storemodel.cpp.
|
nodiscard |
Check if a specific index should be shown.
| index | Model index to check. |
Definition at line 57 of file storemodel.cpp.
|
nodiscardoverride |
Get supported drag actions.
Definition at line 219 of file storemodel.cpp.
|
nodiscardoverride |
Get supported drop actions.
Definition at line 215 of file storemodel.cpp.
|
staticnodiscard |
The tree filter for what is typed in the search box.
The words, split at spaces, are matched literally and in order, with anything in between: "work vpn" finds work/acme/vpn. Each word is taken at its first place after the one before, which is where an in-order match can always continue, and the pattern is anchored with atomic groups, so a path is searched once: a greedy .* join backtracked through every repeat of a word in a long path.
| query | The search box text, with slashes as separators. |
Definition at line 115 of file storemodel.cpp.
|
private |
The wrapped file system model, set by setModelAndStore(); null until then, which makes showThis() hide everything.
Definition at line 93 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 103 of file storemodel.h.
|
private |
Store root used to make paths relative for filtering and for the drop boundary check.
Definition at line 98 of file storemodel.h.