QtPass 2.0.0
Developer documentation
Loading...
Searching...
No Matches
StoreTree Class Reference

The password store as shown in the tree: the QFileSystemModel, the StoreModel proxy on top of it and the QTreeView they drive, with the path questions the main window keeps asking. More...

#include <storetree.h>

Inheritance diagram for StoreTree:
Collaboration diagram for StoreTree:

Public Member Functions

 StoreTree (QTreeView *view, QObject *parent=nullptr)
 Attach the proxy model to the view and set its look: hidden header, indentation, scroll bars, context-menu policy. Column hiding and sorting need a source model and happen in setStore().
void setStore (const QString &path)
 Point everything at path: file system root, proxy store and view root index. Also drops a search filter.
void setPass (Pass *pass)
 Hand the proxy the backend it drops onto.
void setFilter (const QRegularExpression &pattern)
 Filter the visible entries.
auto dirFor (const QModelIndex &index, bool forPass) const -> QString
 The folder an index stands for.
auto currentDir (bool forPass) const -> QString
 dirFor() applied to the view's current index.
auto fileFor (const QModelIndex &index, bool forPass) const -> QString
 The entry an index stands for.
auto currentFile (bool forPass) const -> QString
 fileFor() applied to the view's current index.
auto fileInfo (const QModelIndex &index) const -> QFileInfo
 File system information for a view index.
auto indexFor (const QString &path) const -> QModelIndex
 The view index for an absolute path, or invalid when the file system model does not (yet) know it.
auto rootIndex () -> QModelIndex
 The proxy's root index for the current store.
auto currentIndex () const -> QModelIndex
 The view's current index.
auto store () const -> QString
auto proxy () -> StoreModel &
auto fileSystem () -> QFileSystemModel &
auto view () const -> QTreeView *

Private Attributes

QTreeView * m_view
 The tree view this object drives; owned by the main window.
QFileSystemModel m_fs
 Source model over the store directory, filtered to *.gpg; re-rooted by setStore().
StoreModel m_proxy
 Proxy the view shows: hides .git, strips .gpg, applies the search filter and handles drag and drop.
QString m_store
 Absolute store directory last passed to setStore().

Detailed Description

The password store as shown in the tree: the QFileSystemModel, the StoreModel proxy on top of it and the QTreeView they drive, with the path questions the main window keeps asking.

Owns the two models. setStore() is the one place that re-roots the file system model, the proxy and the view together (this sequence used to be spelled out five times); dirFor()/fileFor() are the two path mappings that were duplicated across MainWindow and Util.

Definition at line 33 of file storetree.h.

Constructor & Destructor Documentation

◆ StoreTree()

StoreTree::StoreTree ( QTreeView * view,
QObject * parent = nullptr )
explicit

Attach the proxy model to the view and set its look: hidden header, indentation, scroll bars, context-menu policy. Column hiding and sorting need a source model and happen in setStore().

Parameters
viewThe tree view to drive.
parentOwner.

Definition at line 14 of file storetree.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Function Documentation

◆ currentDir()

auto StoreTree::currentDir ( bool forPass) const -> QString
nodiscard

dirFor() applied to the view's current index.

Parameters
forPassAs in dirFor().
Returns
Folder path.

Definition at line 71 of file storetree.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ currentFile()

auto StoreTree::currentFile ( bool forPass) const -> QString
nodiscard

fileFor() applied to the view's current index.

Parameters
forPassAs in fileFor().
Returns
Entry name or path.

Definition at line 88 of file storetree.cpp.

Here is the call graph for this function:

◆ currentIndex()

auto StoreTree::currentIndex ( ) const -> QModelIndex
nodiscard

The view's current index.

Returns
Proxy index, possibly invalid.

Definition at line 105 of file storetree.cpp.

◆ dirFor()

auto StoreTree::dirFor ( const QModelIndex & index,
bool forPass ) const -> QString
nodiscard

The folder an index stands for.

Parameters
indexView index; a file maps to its folder, an invalid index to the store root.
forPasstrue for a store-relative path ("" for the root), false for an absolute one.
Returns
Folder path ending in the native separator (see forPass).

Definition at line 55 of file storetree.cpp.

Here is the caller graph for this function:

◆ fileFor()

auto StoreTree::fileFor ( const QModelIndex & index,
bool forPass ) const -> QString
nodiscard

The entry an index stands for.

Parameters
indexView index; folders and invalid indexes yield an empty string.
forPasstrue for the pass name (store-relative, no .gpg), false for the absolute .gpg path.
Returns
Entry name or path, empty when index is not a file.

Definition at line 75 of file storetree.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fileInfo()

auto StoreTree::fileInfo ( const QModelIndex & index) const -> QFileInfo
nodiscard

File system information for a view index.

Parameters
indexView index.
Returns
QFileInfo of the underlying path.

Definition at line 92 of file storetree.cpp.

Here is the caller graph for this function:

◆ fileSystem()

auto StoreTree::fileSystem ( ) -> QFileSystemModel &
inlinenodiscard
Returns
The file system model under the proxy.

Definition at line 134 of file storetree.h.

Here is the caller graph for this function:

◆ indexFor()

auto StoreTree::indexFor ( const QString & path) const -> QModelIndex
nodiscard

The view index for an absolute path, or invalid when the file system model does not (yet) know it.

Parameters
pathAbsolute path inside the store.
Returns
Proxy index.

Definition at line 96 of file storetree.cpp.

Here is the caller graph for this function:

◆ proxy()

auto StoreTree::proxy ( ) -> StoreModel &
inlinenodiscard
Returns
The proxy the view shows.

Definition at line 132 of file storetree.h.

Here is the caller graph for this function:

◆ rootIndex()

auto StoreTree::rootIndex ( ) -> QModelIndex
nodiscard

The proxy's root index for the current store.

Returns
Proxy index of the store root.

Definition at line 101 of file storetree.cpp.

Here is the caller graph for this function:

◆ setFilter()

void StoreTree::setFilter ( const QRegularExpression & pattern)

Filter the visible entries.

Parameters
patternRegular expression matched against entry names; an invalid or empty one shows everything.

Definition at line 49 of file storetree.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setPass()

void StoreTree::setPass ( Pass * pass)

Hand the proxy the backend it drops onto.

Parameters
passActive backend (not owned).

Definition at line 47 of file storetree.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setStore()

void StoreTree::setStore ( const QString & path)

Point everything at path: file system root, proxy store and view root index. Also drops a search filter.

Parameters
pathPassword store directory.

Definition at line 26 of file storetree.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ store()

auto StoreTree::store ( ) const -> QString
inlinenodiscard
Returns
The store directory set with setStore().

Definition at line 130 of file storetree.h.

◆ view()

auto StoreTree::view ( ) const -> QTreeView *
inlinenodiscard
Returns
The tree view.

Definition at line 136 of file storetree.h.

Here is the caller graph for this function:

Member Data Documentation

◆ m_fs

QFileSystemModel StoreTree::m_fs
private

Source model over the store directory, filtered to *.gpg; re-rooted by setStore().

Definition at line 145 of file storetree.h.

◆ m_proxy

StoreModel StoreTree::m_proxy
private

Proxy the view shows: hides .git, strips .gpg, applies the search filter and handles drag and drop.

Definition at line 150 of file storetree.h.

◆ m_store

QString StoreTree::m_store
private

Absolute store directory last passed to setStore().

Definition at line 152 of file storetree.h.

◆ m_view

QTreeView* StoreTree::m_view
private

The tree view this object drives; owned by the main window.

Definition at line 140 of file storetree.h.


The documentation for this class was generated from the following files: