Compare commits

..

5 commits

Author SHA1 Message Date
Lukas Brübach
fa4c5766eb Cover merge printing preservation with a test
Base deck with 4 Mountain (DOM 250), local adds 2 Shock (M19 156), remote
adds an unrelated card. Asserts the merge keeps one Mountain node with its
printing and adds a single Shock node carrying M19/156.
2026-11-01 22:11:40 +01:00
BruebachL
15673dc481 [DeckDiff] Use namespace instead of static-only class per review 2026-11-01 22:11:40 +01:00
Lukas Brübach
da106fdef7 Fixup: clang-format alignment in deck_diff.h 2026-11-01 22:11:40 +01:00
Lukas Brübach
f661468069 Fix ZeldaZach review for PR 7492: preserve printing in DeckDiff::merge, atomic sidecar save with QSaveFile 2026-11-01 22:11:40 +01:00
Lukas Brübach
be072ffd68 [Client] DeckSyncProfile + sidecar + DeckDiff with tests 2026-11-01 22:11:40 +01:00
3 changed files with 17 additions and 14 deletions

View file

@ -9,15 +9,16 @@
#include <QString> #include <QString>
/** /**
* @struct DeckSyncProfile * @class DeckSyncProfile
* @brief Identifies which server and login a sync sidecar belongs to. * @brief Identifies which server and login a sync sidecar belongs to.
* *
* A local deck folder can sync against several servers. Every server login * A local deck folder can sync against several servers. Every server login
* gets its own profile, and every profile gets its own sidecar file, so * gets its own profile, and every profile gets its own sidecar file, so
* switching servers never mixes up remote deck ids. * switching servers never mixes up remote deck ids.
*/ */
struct DeckSyncProfile class DeckSyncProfile
{ {
public:
QString host; ///< Server hostname as entered by the user. QString host; ///< Server hostname as entered by the user.
int port = 0; ///< Server port. int port = 0; ///< Server port.
QString username; ///< Login name on that server. QString username; ///< Login name on that server.

View file

@ -37,11 +37,12 @@ bool DeckSyncSidecar::load()
continue; continue;
} }
const QJsonObject entry = it.value().toObject(); const QJsonObject entry = it.value().toObject();
const DeckSyncRecord record{.guid = entry.value("guid").toString(), DeckSyncRecord record;
.remoteId = entry.value("remoteId").toInt(-1), record.guid = entry.value("guid").toString();
.baseHash = entry.value("baseHash").toString(), record.remoteId = entry.value("remoteId").toInt(-1);
.lastSyncSecs = static_cast<qint64>(entry.value("lastSync").toDouble()), record.baseHash = entry.value("baseHash").toString();
.deleted = entry.value("deleted").toBool(false)}; record.lastSyncSecs = static_cast<qint64>(entry.value("lastSync").toDouble());
record.deleted = entry.value("deleted").toBool(false);
recordMap.insert(it.key(), record); recordMap.insert(it.key(), record);
} }
return true; return true;

View file

@ -70,13 +70,14 @@ DeckDiffResult diff(const DeckList &oldDeck, const DeckList &newDeck)
const int oldCount = oldCounts.value(key, 0); const int oldCount = oldCounts.value(key, 0);
const ZoneCardInfo newInfo = newInfos.value(key, ZoneCardInfo()); const ZoneCardInfo newInfo = newInfos.value(key, ZoneCardInfo());
if (oldCount != newInfo.count) { if (oldCount != newInfo.count) {
const DeckCardChange change{.zone = key.first, DeckCardChange change;
.cardName = key.second, change.zone = key.first;
.oldCount = oldCount, change.cardName = key.second;
.newCount = newInfo.count, change.oldCount = oldCount;
.cardSetShortName = newInfo.cardSetShortName, change.newCount = newInfo.count;
.cardSetNumber = newInfo.cardSetNumber, change.cardSetShortName = newInfo.cardSetShortName;
.cardProviderId = newInfo.cardProviderId}; change.cardSetNumber = newInfo.cardSetNumber;
change.cardProviderId = newInfo.cardProviderId;
result.changes.append(change); result.changes.append(change);
} }
} }