Update last loaded timestamp in decklist file and then restore original last modified timestamp if a user requests a deck load.

This commit is contained in:
Lukas Brübach 2025-01-06 11:08:15 +01:00
parent 132159c7f6
commit f5dcf522f1
8 changed files with 82 additions and 12 deletions

View file

@ -368,7 +368,8 @@ DeckList::DeckList()
// TODO: https://qt-project.org/doc/qt-4.8/qobject.html#no-copy-constructor-or-assignment-operator
DeckList::DeckList(const DeckList &other)
: QObject(), name(other.name), comments(other.comments), bannerCard(other.bannerCard), deckHash(other.deckHash)
: QObject(), name(other.name), comments(other.comments), bannerCard(other.bannerCard), deckHash(other.deckHash),
lastLoadedTimestamp(other.lastLoadedTimestamp)
{
root = new InnerDecklistNode(other.getRoot());
@ -419,13 +420,14 @@ bool DeckList::readElement(QXmlStreamReader *xml)
{
const QString childName = xml->name().toString();
if (xml->isStartElement()) {
if (childName == "deckname")
if (childName == "lastLoadedTimestamp") {
lastLoadedTimestamp = xml->readElementText();
} else if (childName == "deckname")
name = xml->readElementText();
else if (childName == "comments")
comments = xml->readElementText();
else if (childName == "bannerCard") {
bannerCard = xml->readElementText();
qDebug() << "Deckloader found the banner card " << bannerCard;
} else if (childName == "zone") {
InnerDecklistNode *newZone = getZoneObjFromName(xml->attributes().value("name").toString());
newZone->readElement(xml);
@ -445,6 +447,7 @@ void DeckList::write(QXmlStreamWriter *xml)
{
xml->writeStartElement("cockatrice_deck");
xml->writeAttribute("version", "1");
xml->writeTextElement("lastLoadedTimestamp", lastLoadedTimestamp);
xml->writeTextElement("deckname", name);
xml->writeTextElement("comments", comments);
xml->writeTextElement("bannerCard", bannerCard);

View file

@ -252,6 +252,7 @@ class DeckList : public QObject
private:
QString name, comments, bannerCard;
QString deckHash;
QString lastLoadedTimestamp;
QMap<QString, SideboardPlan *> sideboardPlans;
InnerDecklistNode *root;
void getCardListHelper(InnerDecklistNode *node, QSet<QString> &result) const;
@ -283,6 +284,10 @@ public slots:
{
bannerCard = _bannerCard;
}
void setLastLoadedTimestamp(const QString &_lastLoadedTimestamp = QString())
{
lastLoadedTimestamp = _lastLoadedTimestamp;
}
public:
explicit DeckList();
@ -301,6 +306,10 @@ public:
{
return bannerCard;
}
QString getLastLoadedTimestamp() const
{
return lastLoadedTimestamp;
}
QList<MoveCard_ToZone> getCurrentSideboardPlan();
void setCurrentSideboardPlan(const QList<MoveCard_ToZone> &plan);
const QMap<QString, SideboardPlan *> &getSideboardPlans() const