mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-21 00:55:09 -07:00
Some checks failed
Build Desktop / Configure (push) Has been cancelled
Build Docker Image / amd64 & arm64 (push) Has been cancelled
Build Desktop / Debian 13 (push) Has been cancelled
Build Desktop / Debian 12 (push) Has been cancelled
Build Desktop / Fedora 44 (push) Has been cancelled
Build Desktop / Fedora 43 (push) Has been cancelled
Build Desktop / Servatrice_Debian 12 (push) Has been cancelled
Build Desktop / Ubuntu 26.04 (push) Has been cancelled
Build Desktop / Ubuntu 24.04 (push) Has been cancelled
Build Desktop / Arch (push) Has been cancelled
Build Desktop / macOS 14 (push) Has been cancelled
Build Desktop / macOS 15 (push) Has been cancelled
Build Desktop / macOS 13 Intel (push) Has been cancelled
Build Desktop / macOS 15 Debug (push) Has been cancelled
Build Desktop / Windows 10 (push) Has been cancelled
* [CardInfo] use QString QHash instead of QVariantHash for properties * bump CACHE_VERSION * cleanups
57 lines
1.3 KiB
C++
57 lines
1.3 KiB
C++
#include "printing_info.h"
|
|
|
|
#include "../set/card_set.h"
|
|
|
|
#include <QDataStream>
|
|
#include <QIODevice>
|
|
|
|
PrintingInfo::PrintingInfo(const CardSetPtr &_set) : set(_set)
|
|
{
|
|
}
|
|
|
|
void PrintingInfo::ensurePropertiesLoaded() const
|
|
{
|
|
QMutexLocker lock(propertiesMutex.data());
|
|
if (propertiesLoaded) {
|
|
return;
|
|
}
|
|
propertiesCache.clear();
|
|
if (!propertiesBlob.isEmpty()) {
|
|
QDataStream in(propertiesBlob);
|
|
in.setVersion(QDataStream::Qt_6_4);
|
|
in >> propertiesCache;
|
|
}
|
|
propertiesLoaded = true;
|
|
}
|
|
|
|
void PrintingInfo::setProperty(const QString &_name, const QString &_value)
|
|
{
|
|
ensurePropertiesLoaded();
|
|
if (propertiesCache.value(_name) == _value) {
|
|
return;
|
|
}
|
|
propertiesCache.insert(_name, _value);
|
|
setProperties(propertiesCache);
|
|
}
|
|
|
|
void PrintingInfo::setProperties(const QHash<QString, QString> &_props)
|
|
{
|
|
ensurePropertiesLoaded();
|
|
propertiesCache = _props;
|
|
QDataStream out(&propertiesBlob, QIODevice::WriteOnly);
|
|
out.setVersion(QDataStream::Qt_6_4);
|
|
out << propertiesCache;
|
|
}
|
|
|
|
/**
|
|
* Gets the uuid property of the printing, or an empty string if the property isn't present
|
|
*/
|
|
QString PrintingInfo::getUuid() const
|
|
{
|
|
return getPropertiesHash().value("uuid");
|
|
}
|
|
|
|
QString PrintingInfo::getFlavorName() const
|
|
{
|
|
return getPropertiesHash().value("flavorName");
|
|
}
|