8#ifndef SRC_STOREMODEL_H_
9#define SRC_STOREMODEL_H_
12#include <QSortFilterProxyModel>
16class QFileSystemModel;
68inline constexpr QLatin1StringView
69 kStoreDragMimeType(
"application/vnd.qtpass.store-item");
111 -> std::optional<StoreDragItem>;
127 const QModelIndex &parent) -> bool;
136 auto performDrop(
const QString &cleanedSrc,
const QString &cleanedDest,
137 Qt::DropAction action,
bool force) -> bool;
158 const QModelIndex &source_parent)
const
166 [[nodiscard]]
auto showThis(
const QModelIndex &index)
const -> bool;
174 const QString &passStore);
193 void setStore(
const QString &passStore);
201 [[nodiscard]]
auto data(
const QModelIndex &index,
int role)
const
202 -> QVariant
override;
210 [[nodiscard]]
auto lessThan(
const QModelIndex &source_left,
211 const QModelIndex &source_right)
const
239 [[nodiscard]] auto
flags(const QModelIndex &index) const
240 -> Qt::ItemFlags override;
246 [[nodiscard]] auto
mimeTypes() const -> QStringList override;
253 [[nodiscard]] auto
mimeData(const QModelIndexList &indexes) const
254 -> QMimeData * override;
266 int column, const QModelIndex &parent) const
279 int column, const QModelIndex &parent) ->
bool override;
Abstract base class for password store operations.
auto filterAcceptsRow(int source_row, const QModelIndex &source_parent) const -> bool override
Filter whether a row should be displayed.
auto getStore() const -> QString
Get the password store root path.
auto data(const QModelIndex &index, int role) const -> QVariant override
Get display data for index.
StoreModel()
Construct a StoreModel.
static auto parseDropData(const QMimeData *data) -> std::optional< StoreDragItem >
Decode the drag payload from data.
auto showThis(const QModelIndex &index) const -> bool
Check if a specific index should be shown.
auto mimeTypes() const -> QStringList override
Get supported MIME types for drag/drop.
Pass * m_pass
Backend that performs drag-and-drop Move/Copy; not owned, null until setPass(), in which case drops a...
void setModelAndStore(QFileSystemModel *sourceModel, const QString &passStore)
Initialize model with source model and store path.
auto dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) -> bool override
Handle dropped MIME data.
void setStore(const QString &passStore)
Update the store path used for filtering without changing the source model.
auto mimeData(const QModelIndexList &indexes) const -> QMimeData *override
Create MIME data from indexes.
auto executeDropAction(const StoreDragItem &info, Qt::DropAction action, const QModelIndex &parent) -> bool
Resolve a validated drop into a Move or Copy.
void setPass(Pass *pass)
Inject the Pass backend for drag-and-drop Move/Copy operations.
auto rootIndexFor(const QString &path) -> QModelIndex
Set the source filesystem root and map it to a proxy index.
QString store
Store root used to make paths relative for filtering and for the drop boundary check.
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 performDrop(const QString &cleanedSrc, const QString &cleanedDest, Qt::DropAction action, bool force) -> bool
Perform the actual Move/Copy for a validated drop.
auto canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const -> bool override
Check if drop is possible.
auto lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const -> bool override
Compare two indices for sorting.
QFileSystemModel * fs
The wrapped file system model, set by setModelAndStore(); null until then, which makes showThis() hid...
auto supportedDropActions() const -> Qt::DropActions override
Get supported drop actions.
auto operator>>(QDataStream &in, StoreDragItem &item) -> QDataStream &
Deserialize a StoreDragItem from the QtPass MIME type.
auto operator<<(QDataStream &out, const StoreDragItem &item) -> QDataStream &
Serialize a StoreDragItem for the QtPass MIME type.
What a drag from the store tree carries: the kind of the dragged item and its path.
ItemKind
Type of the dragged item.