QtPass 1.6.0
Multi-platform GUI for pass, the standard unix password manager.
Loading...
Searching...
No Matches
StoreModel Class Reference

QSortFilterProxyModel for filtering and displaying password store. More...

#include <storemodel.h>

Inheritance diagram for StoreModel:
Collaboration diagram for StoreModel:

Public Member Functions

 StoreModel ()
 Construct a StoreModel.
auto filterAcceptsRow (int, const QModelIndex &) const -> bool override
 Filter whether a row should be displayed.
auto showThis (const QModelIndex) const -> bool
 Check if a specific index should be shown.
void setModelAndStore (QFileSystemModel *sourceModel, QString passStore)
 Initialize model with source model and store path.
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.

Detailed Description

QSortFilterProxyModel for filtering and displaying password store.

StoreModel wraps QFileSystemModel to provide password store-specific filtering and display functionality. It handles:

  • Hiding .gpg-id files from display
  • Removing .gpg extension from file names
  • Supporting drag and drop operations
  • Custom sorting (directories before files)
Examples
/home/annejan/Projects/QtPass/src/util.cpp.

Definition at line 31 of file storemodel.h.

Constructor & Destructor Documentation

◆ StoreModel()

StoreModel::StoreModel ( )

Construct a StoreModel.

StoreModel::StoreModel SubClass of QSortFilterProxyModel via http://www.qtcentre.org/threads/46471-QTreeView-Filter.

Definition at line 37 of file storemodel.cpp.

Member Function Documentation

◆ canDropMimeData()

auto StoreModel::canDropMimeData ( const QMimeData * data,
Qt::DropAction action,
int row,
int column,
const QModelIndex & parent ) const -> bool
override

Check if drop is possible.

StoreModel::canDropMimeData.

Parameters
dataMIME data to drop.
actionDrop action.
rowTarget row.
columnTarget column.
parentTarget parent index.
Returns
true if drop is possible.
Parameters
data
action
row
column
parent
Returns

Definition at line 200 of file storemodel.cpp.

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

◆ data()

auto StoreModel::data ( const QModelIndex & index,
int role ) const -> QVariant
nodiscardoverride

Get display data for index.

StoreModel::data don't show the .gpg at the end of a file.

Parameters
indexModel index.
roleData role (e.g., Qt::DisplayRole).
Returns
Display data for the role.
Parameters
index
role
Returns

Definition at line 107 of file storemodel.cpp.

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

◆ dropMimeData()

auto StoreModel::dropMimeData ( const QMimeData * data,
Qt::DropAction action,
int row,
int column,
const QModelIndex & parent ) -> bool
override

Handle dropped MIME data.

StoreModel::dropMimeData.

Parameters
dataMIME data to drop.
actionDrop action.
rowTarget row.
columnTarget column.
parentTarget parent index.
Returns
true if drop was handled.
Parameters
data
action
row
column
parent
Returns

Definition at line 250 of file storemodel.cpp.

Here is the call graph for this function:

◆ filterAcceptsRow()

auto StoreModel::filterAcceptsRow ( int sourceRow,
const QModelIndex & sourceParent ) const -> bool
nodiscardoverride

Filter whether a row should be displayed.

StoreModel::filterAcceptsRow should row be shown, wrapper for StoreModel::showThis method.

Parameters
source_rowRow index in source model.
source_parentParent index in source model.
Returns
true if row should be displayed.
Parameters
sourceRow
sourceParent
Returns

Definition at line 46 of file storemodel.cpp.

Here is the call graph for this function:

◆ flags()

auto StoreModel::flags ( const QModelIndex & index) const -> Qt::ItemFlags
nodiscardoverride

Get item flags for index.

StoreModel::flags.

Parameters
indexModel index.
Returns
Item flags.
Parameters
index
Returns

Definition at line 145 of file storemodel.cpp.

◆ getStore()

auto StoreModel::getStore ( ) const -> QString
inlinenodiscard

Get the password store root path.

Returns
Store path.

Definition at line 90 of file storemodel.h.

◆ lessThan()

auto StoreModel::lessThan ( const QModelIndex & source_left,
const QModelIndex & source_right ) const -> bool
nodiscardoverride

Compare two indices for sorting.

StoreModel::lessThan.

Parameters
source_leftLeft index to compare.
source_rightRight index to compare.
Returns
true if left < right.
Parameters
source_left
source_right
Returns

Definition at line 314 of file storemodel.cpp.

◆ mimeData()

auto StoreModel::mimeData ( const QModelIndexList & indexes) const -> QMimeData *
nodiscardoverride

Create MIME data from indexes.

StoreModel::mimeData.

Parameters
indexesList of selected indexes.
Returns
MIME data object.
Parameters
indexes
Returns

Definition at line 169 of file storemodel.cpp.

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

◆ mimeTypes()

auto StoreModel::mimeTypes ( ) const -> QStringList
nodiscardoverride

Get supported MIME types for drag/drop.

StoreModel::mimeTypes.

Returns
List of MIME type strings.

Definition at line 158 of file storemodel.cpp.

◆ setModelAndStore()

void StoreModel::setModelAndStore ( QFileSystemModel * sourceModel,
QString passStore )

Initialize model with source model and store path.

StoreModel::setModelAndStore update the source model and store.

Parameters
sourceModelFilesystem model to wrap.
passStoreRoot path of password store.
sourceModel
passStore

Definition at line 94 of file storemodel.cpp.

◆ showThis()

auto StoreModel::showThis ( const QModelIndex index) const -> bool
nodiscard

Check if a specific index should be shown.

StoreModel::showThis should a row be shown, based on our search criteria.

Parameters
indexModel index to check.
Returns
true if index should be visible.
Parameters
index
Returns

Definition at line 59 of file storemodel.cpp.

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

◆ supportedDragActions()

auto StoreModel::supportedDragActions ( ) const -> Qt::DropActions
nodiscardoverride

Get supported drag actions.

StoreModel::supportedDragActions enable drag.

Returns
Supported Qt::DropActions.

Definition at line 136 of file storemodel.cpp.

◆ supportedDropActions()

auto StoreModel::supportedDropActions ( ) const -> Qt::DropActions
nodiscardoverride

Get supported drop actions.

StoreModel::supportedDropActions enable drop.

Returns
Supported Qt::DropActions.

Definition at line 128 of file storemodel.cpp.


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