13#ifndef VISUAL_DECK_STORAGE_MODEL_H
14#define VISUAL_DECK_STORAGE_MODEL_H
19#include <QAbstractListModel>
27#include <qnamespace.h>
28#include <qtmetamacros.h>
110 [[nodiscard]]
int rowCount(
const QModelIndex &parent = QModelIndex())
const override;
111 [[nodiscard]] QVariant
data(
const QModelIndex &index,
int role)
const override;
149 bool renameDeck(
int row,
const QString &newName);
150 bool renameFile(
int row,
const QString &newBaseName);
152 bool setTags(
int row,
const QStringList &tags);
Definition mana_curve_category_widget.h:11
Definition remote_connection_controller.h:20
VisualDeckStorageModel(QObject *parent=nullptr)
Definition visual_deck_storage_model.cpp:136
QList< DeckPreviewData > decks
Definition visual_deck_storage_model.h:186
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:179
void beginLoad(int row)
Definition visual_deck_storage_model.cpp:276
QString deckPath
Definition visual_deck_storage_model.h:185
QStringList folderPaths
All subdirectories of the deck folder, sorted.
Definition visual_deck_storage_model.h:188
int scanGeneration
Bumped on every scan so stale results are ignored.
Definition visual_deck_storage_model.h:189
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:135
void schedulePendingLoadDrain()
Definition visual_deck_storage_model.cpp:326
void reindexFilePaths()
Rebuilds the file path -> row index from scratch after bulk changes.
Definition visual_deck_storage_model.cpp:216
const LoadedDeck & deckForRow(int row) const
Definition visual_deck_storage_model.cpp:203
QHash< QString, int > rowByFilePath
Maps each deck's file path to its row for O(1) lookups.
Definition visual_deck_storage_model.h:187
void startScan()
Definition visual_deck_storage_model.cpp:228
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:140
bool renameFile(int row, const QString &newBaseName)
Definition visual_deck_storage_model.cpp:432
bool convertToCockatriceFormat(int row)
Definition visual_deck_storage_model.cpp:523
bool setBannerCard(int row, const CardRef &cardRef)
Definition visual_deck_storage_model.cpp:505
bool reloadIfModified(int row)
Definition visual_deck_storage_model.cpp:546
bool renameDeck(int row, const QString &newName)
Definition visual_deck_storage_model.cpp:415
int rowForFilePath(const QString &filePath) const
Definition visual_deck_storage_model.cpp:208
QVector< PendingDeckLoad > pendingLoads
Finished background loads waiting to be applied.
Definition visual_deck_storage_model.h:190
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:385
void setFilePathForRow(int row, const QString &newFilePath)
Definition visual_deck_storage_model.cpp:399
QVariant data(const QModelIndex &index, int role) const override
Definition visual_deck_storage_model.cpp:145
bool drainScheduled
Whether a queued drain pass is already pending.
Definition visual_deck_storage_model.h:191
const DeckPreviewData & dataForRow(int row) const
Definition visual_deck_storage_model.cpp:194
bool setTags(int row, const QStringList &tags)
Definition visual_deck_storage_model.cpp:488
QString getDeckPath() const
Definition visual_deck_storage_model.h:126
bool deleteFile(int row)
Definition visual_deck_storage_model.cpp:464
void refresh()
Re-scans the current deck folder, reloading every deck file.
Definition visual_deck_storage_model.cpp:189
void drainPendingLoads()
Definition visual_deck_storage_model.cpp:335
void deckFilePathChanged(const QString &oldFilePath, const QString &newFilePath)
Emitted when a deck's file path changes (rename file, conversion).
Definition visual_deck_storage_model.h:33
@ RelativeFilePathRole
Definition visual_deck_storage_model.h:40
@ ColorIdentityRole
Definition visual_deck_storage_model.h:44
@ FilterMatchRole
Whether the row passes the proxy's current search / tag / color filters.
Definition visual_deck_storage_model.h:55
@ DisplayNameRole
Definition visual_deck_storage_model.h:42
@ BannerCardProviderIdRole
Definition visual_deck_storage_model.h:48
@ BannerCardNameRole
Definition visual_deck_storage_model.h:47
@ LastLoadedRole
Definition visual_deck_storage_model.h:46
@ FolderPathRole
Definition visual_deck_storage_model.h:41
@ FilePathRole
Definition visual_deck_storage_model.h:39
@ LastModifiedRole
Definition visual_deck_storage_model.h:45
@ TagsRole
Definition visual_deck_storage_model.h:43
One deck file as seen by the Visual Deck Storage.
Definition visual_deck_storage_model.h:66
QString deckName
The deck name as stored in the file (may be empty).
Definition visual_deck_storage_model.h:70
bool loadInProgress
Whether the deck file is currently being loaded.
Definition visual_deck_storage_model.h:79
QDateTime lastModified
File modification time at last check.
Definition visual_deck_storage_model.h:74
QString folderPath
Directory relative to the deck folder ("" for the deck folder itself).
Definition visual_deck_storage_model.h:69
bool loadSucceeded
Whether the deck file finished loading successfully.
Definition visual_deck_storage_model.h:78
QDateTime lastLoaded
When the deck was last loaded from the file.
Definition visual_deck_storage_model.h:75
QStringList tags
The deck's tags.
Definition visual_deck_storage_model.h:72
QString displayName
Deck name, or the file name if the deck has no name.
Definition visual_deck_storage_model.h:71
LoadedDeck deck
The parsed deck; empty until the file has been loaded.
Definition visual_deck_storage_model.h:77
QString colorIdentity
The deck's color identity in WUBRG order.
Definition visual_deck_storage_model.h:73
QString relativeFilePath
File path relative to the deck folder.
Definition visual_deck_storage_model.h:68
CardRef bannerCard
The deck's banner card (name + provider id).
Definition visual_deck_storage_model.h:76
QString filePath
Absolute file path.
Definition visual_deck_storage_model.h:67
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:86
QString filePath
Identifies the row the result belongs to.
Definition visual_deck_storage_model.h:87
QDateTime lastModified
File modification time at load, valid when ok.
Definition visual_deck_storage_model.h:91
QString colorIdentity
WUBRG color identity computed off the UI thread, valid when ok.
Definition visual_deck_storage_model.h:92
int generation
Scan generation the load was started in.
Definition visual_deck_storage_model.h:88
bool ok
Whether the file parsed successfully.
Definition visual_deck_storage_model.h:89
LoadedDeck deck
The parsed deck, valid when ok.
Definition visual_deck_storage_model.h:90