mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-28 20:00:24 -07:00
* [Card Database] Improve loading times through binary cache Took 10 minutes Took 9 minutes Took 16 seconds * [Card Database] Remove lib qt include Took 18 minutes Took 14 seconds * Downgrade to 6.3 datastream Took 5 minutes * go up to 6.4 datastream Took 1 minute * Address comments * Small bug fixes Took 20 minutes Took 10 seconds * More fixes. Took 4 minutes Took 4 seconds * Even more fixes. Took 11 minutes Took 4 seconds * More fixes. Took 6 minutes Took 26 seconds Took 8 minutes * Namespace instead of class Took 6 minutes --------- Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
57 lines
No EOL
1.3 KiB
C++
57 lines
No EOL
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).toString() == _value) {
|
|
return;
|
|
}
|
|
propertiesCache.insert(_name, _value);
|
|
setProperties(propertiesCache);
|
|
}
|
|
|
|
void PrintingInfo::setProperties(const QVariantHash &_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").toString();
|
|
}
|
|
|
|
QString PrintingInfo::getFlavorName() const
|
|
{
|
|
return getPropertiesHash().value("flavorName").toString();
|
|
} |