13#ifndef VISUAL_DECK_STORAGE_MODEL_H
14#define VISUAL_DECK_STORAGE_MODEL_H
18#include <QAbstractListModel>
104 [[nodiscard]]
int rowCount(
const QModelIndex &parent = QModelIndex())
const override;
105 [[nodiscard]] QVariant
data(
const QModelIndex &index,
int role)
const override;
143 bool renameDeck(
int row,
const QString &newName);
144 bool renameFile(
int row,
const QString &newBaseName);
146 bool setTags(
int row,
const QStringList &tags);
VisualDeckStorageModel(QObject *parent=nullptr)
Definition visual_deck_storage_model.cpp:124
QList< DeckPreviewData > decks
Definition visual_deck_storage_model.h:180
void setDeckPath(const QString &path)
Sets the folder to scan for deck files and starts (re)loading. Clears the model immediately (modelRes...
Definition visual_deck_storage_model.cpp:167
void beginLoad(int row)
Definition visual_deck_storage_model.cpp:264
QString deckPath
Definition visual_deck_storage_model.h:179
QStringList folderPaths
All subdirectories of the deck folder, sorted.
Definition visual_deck_storage_model.h:182
int scanGeneration
Bumped on every scan so stale results are ignored.
Definition visual_deck_storage_model.h:183
QStringList getFolderPaths() const
The relative paths of all subdirectories of the deck folder, one level at a time. Used by the view to...
Definition visual_deck_storage_model.h:129
void schedulePendingLoadDrain()
Definition visual_deck_storage_model.cpp:314
void reindexFilePaths()
Rebuilds the file path -> row index from scratch after bulk changes.
Definition visual_deck_storage_model.cpp:204
const LoadedDeck & deckForRow(int row) const
Definition visual_deck_storage_model.cpp:191
QHash< QString, int > rowByFilePath
Maps each deck's file path to its row for O(1) lookups.
Definition visual_deck_storage_model.h:181
void startScan()
Definition visual_deck_storage_model.cpp:216
void deckLoaded(int row)
Emitted when a deck file finishes loading.
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Definition visual_deck_storage_model.cpp:128
bool renameFile(int row, const QString &newBaseName)
Definition visual_deck_storage_model.cpp:454
bool convertToCockatriceFormat(int row)
Definition visual_deck_storage_model.cpp:545
bool setBannerCard(int row, const CardRef &cardRef)
Definition visual_deck_storage_model.cpp:527
bool reloadIfModified(int row)
Definition visual_deck_storage_model.cpp:568
bool renameDeck(int row, const QString &newName)
Definition visual_deck_storage_model.cpp:437
int rowForFilePath(const QString &filePath) const
Definition visual_deck_storage_model.cpp:196
QVector< PendingDeckLoad > pendingLoads
Finished background loads waiting to be applied.
Definition visual_deck_storage_model.h:184
static void recomputeDeckMetadata(DeckPreviewData &data, bool recomputeColorIdentity=true)
Recomputes all derived metadata of a row from its loaded deck.
Definition visual_deck_storage_model.cpp:407
void setFilePathForRow(int row, const QString &newFilePath)
Definition visual_deck_storage_model.cpp:421
QVariant data(const QModelIndex &index, int role) const override
Definition visual_deck_storage_model.cpp:133
bool drainScheduled
Whether a queued drain pass is already pending.
Definition visual_deck_storage_model.h:185
const DeckPreviewData & dataForRow(int row) const
Definition visual_deck_storage_model.cpp:182
bool setTags(int row, const QStringList &tags)
Definition visual_deck_storage_model.cpp:510
QString getDeckPath() const
Definition visual_deck_storage_model.h:120
bool deleteFile(int row)
Definition visual_deck_storage_model.cpp:486
void refresh()
Re-scans the current deck folder, reloading every deck file.
Definition visual_deck_storage_model.cpp:177
void drainPendingLoads()
Definition visual_deck_storage_model.cpp:323
void deckFilePathChanged(const QString &oldFilePath, const QString &newFilePath)
Emitted when a deck's file path changes (rename file, conversion).
Defines the DeckList class, which manages a full deck structure including cards, zones,...
Definition visual_deck_storage_model.h:27
@ RelativeFilePathRole
Definition visual_deck_storage_model.h:34
@ ColorIdentityRole
Definition visual_deck_storage_model.h:38
@ FilterMatchRole
Whether the row passes the proxy's current search / tag / color filters.
Definition visual_deck_storage_model.h:49
@ DisplayNameRole
Definition visual_deck_storage_model.h:36
@ BannerCardProviderIdRole
Definition visual_deck_storage_model.h:42
@ BannerCardNameRole
Definition visual_deck_storage_model.h:41
@ LastLoadedRole
Definition visual_deck_storage_model.h:40
@ FolderPathRole
Definition visual_deck_storage_model.h:35
@ FilePathRole
Definition visual_deck_storage_model.h:33
@ LastModifiedRole
Definition visual_deck_storage_model.h:39
@ TagsRole
Definition visual_deck_storage_model.h:37
One deck file as seen by the Visual Deck Storage.
Definition visual_deck_storage_model.h:60
QString deckName
The deck name as stored in the file (may be empty).
Definition visual_deck_storage_model.h:64
bool loadInProgress
Whether the deck file is currently being loaded.
Definition visual_deck_storage_model.h:73
QDateTime lastModified
File modification time at last check.
Definition visual_deck_storage_model.h:68
QString folderPath
Directory relative to the deck folder ("" for the deck folder itself).
Definition visual_deck_storage_model.h:63
bool loadSucceeded
Whether the deck file finished loading successfully.
Definition visual_deck_storage_model.h:72
QDateTime lastLoaded
When the deck was last loaded from the file.
Definition visual_deck_storage_model.h:69
QStringList tags
The deck's tags.
Definition visual_deck_storage_model.h:66
QString displayName
Deck name, or the file name if the deck has no name.
Definition visual_deck_storage_model.h:65
LoadedDeck deck
The parsed deck; empty until the file has been loaded.
Definition visual_deck_storage_model.h:71
QString colorIdentity
The deck's color identity in WUBRG order.
Definition visual_deck_storage_model.h:67
QString relativeFilePath
File path relative to the deck folder.
Definition visual_deck_storage_model.h:62
CardRef bannerCard
The deck's banner card (name + provider id).
Definition visual_deck_storage_model.h:70
QString filePath
Absolute file path.
Definition visual_deck_storage_model.h:61
Represents a deck that was loaded from somewhere. Contains the DeckList itself, as well as info about...
Definition loaded_deck.h:14
One finished background deck load that has not been applied to the model yet.
Definition visual_deck_storage_model.h:80
QString filePath
Identifies the row the result belongs to.
Definition visual_deck_storage_model.h:81
QDateTime lastModified
File modification time at load, valid when ok.
Definition visual_deck_storage_model.h:85
QString colorIdentity
WUBRG color identity computed off the UI thread, valid when ok.
Definition visual_deck_storage_model.h:86
int generation
Scan generation the load was started in.
Definition visual_deck_storage_model.h:82
bool ok
Whether the file parsed successfully.
Definition visual_deck_storage_model.h:83
LoadedDeck deck
The parsed deck, valid when ok.
Definition visual_deck_storage_model.h:84