Compare commits

..

5 commits

Author SHA1 Message Date
Lukas Brübach
0c6d64c565 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-05 12:50:48 +01:00
BruebachL
507a80f0b2 [DeckDiff] Use namespace instead of static-only class per review 2026-11-05 12:50:48 +01:00
Lukas Brübach
02ccad2374 Fixup: clang-format alignment in deck_diff.h 2026-11-05 12:50:48 +01:00
Lukas Brübach
473b255959 Fix ZeldaZach review for PR 7492: preserve printing in DeckDiff::merge, atomic sidecar save with QSaveFile 2026-11-05 12:50:48 +01:00
Lukas Brübach
1e97ab086b [Client] DeckSyncProfile + sidecar + DeckDiff with tests 2026-11-05 12:50:48 +01:00
3 changed files with 14 additions and 17 deletions

View file

@ -9,16 +9,15 @@
#include <QString> #include <QString>
/** /**
* @class DeckSyncProfile * @struct 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.
*/ */
class DeckSyncProfile struct 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,12 +37,11 @@ bool DeckSyncSidecar::load()
continue; continue;
} }
const QJsonObject entry = it.value().toObject(); const QJsonObject entry = it.value().toObject();
DeckSyncRecord record; const DeckSyncRecord record{.guid = entry.value("guid").toString(),
record.guid = entry.value("guid").toString(); .remoteId = entry.value("remoteId").toInt(-1),
record.remoteId = entry.value("remoteId").toInt(-1); .baseHash = entry.value("baseHash").toString(),
record.baseHash = entry.value("baseHash").toString(); .lastSyncSecs = static_cast<qint64>(entry.value("lastSync").toDouble()),
record.lastSyncSecs = static_cast<qint64>(entry.value("lastSync").toDouble()); .deleted = entry.value("deleted").toBool(false)};
record.deleted = entry.value("deleted").toBool(false);
recordMap.insert(it.key(), record); recordMap.insert(it.key(), record);
} }
return true; return true;

View file

@ -70,14 +70,13 @@ 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) {
DeckCardChange change; const DeckCardChange change{.zone = key.first,
change.zone = key.first; .cardName = key.second,
change.cardName = key.second; .oldCount = oldCount,
change.oldCount = oldCount; .newCount = newInfo.count,
change.newCount = newInfo.count; .cardSetShortName = newInfo.cardSetShortName,
change.cardSetShortName = newInfo.cardSetShortName; .cardSetNumber = newInfo.cardSetNumber,
change.cardSetNumber = newInfo.cardSetNumber; .cardProviderId = newInfo.cardProviderId};
change.cardProviderId = newInfo.cardProviderId;
result.changes.append(change); result.changes.append(change);
} }
} }