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>
/**
* @class DeckSyncProfile
* @struct DeckSyncProfile
* @brief Identifies which server and login a sync sidecar belongs to.
*
* 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
* switching servers never mixes up remote deck ids.
*/
class DeckSyncProfile
struct DeckSyncProfile
{
public:
QString host; ///< Server hostname as entered by the user.
int port = 0; ///< Server port.
QString username; ///< Login name on that server.

View file

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

View file

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