mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-01-09 03:42:58 -08:00
Visual deck storage v2 (#5427)
* Restore some button states (ready/sideboard locked) to sensible defaults when unloading a deck. * Update last loaded timestamp in decklist file and then restore original last modified timestamp if a user requests a deck load. * Add some todos. * Loading a deck from local file dialog should swap out scenes, enable unload button. * Lint. * Shuffle some classes and signals around. * More sort options, sort widgets directly. * Banner cards should respect providerIds. * Properly updateSortOrder on load. * Add the color identity to the Deck Preview Widget. * Properly set sort indices. * Change replace visualDeckStorageWidget with deckView to be in deckSelectFinished so that it also works on remote deck load. * Include settings for unused color identities display. * Change opacity scaling. * Overload for Qt. * Lint. * Lint. * Include QMouseEvent * Template because MacOs. * Include a quick filter for color identities. * Include a quick filter for color identities. * Save some space. * Refactor DeckPreviewWidgets to reside in their own folder. * Add Deck Loader logging category. * Introduce a tagging system. * Add some more default tags. * Even more default tags. * Lint. * Lint a comma. * Remove extra set of braces. * Lint some stuff. * Refresh banner cards when tags are added. * Lint. * Wrestle with Qt Checkboxes. * Lint. * Adjust some sizes, relayout. * Address comments. * Lint. * Reorder kindred types. * Add a search bar for tags. * Remove close button (for now) and change "Add tags ..." to "Edit tags ..." * Retranslate window title for Deck Tag Manager Dialog. * Style tag addition widget to be consistent. * Lint. * Override paintEvent. * Override sizeHint --------- Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
@@ -368,7 +368,8 @@ DeckList::DeckList()
|
||||
|
||||
// TODO: https://qt-project.org/doc/qt-4.8/qobject.html#no-copy-constructor-or-assignment-operator
|
||||
DeckList::DeckList(const DeckList &other)
|
||||
: QObject(), name(other.name), comments(other.comments), bannerCard(other.bannerCard), deckHash(other.deckHash)
|
||||
: QObject(), name(other.name), comments(other.comments), bannerCard(other.bannerCard), deckHash(other.deckHash),
|
||||
lastLoadedTimestamp(other.lastLoadedTimestamp)
|
||||
{
|
||||
root = new InnerDecklistNode(other.getRoot());
|
||||
|
||||
@@ -419,25 +420,37 @@ bool DeckList::readElement(QXmlStreamReader *xml)
|
||||
{
|
||||
const QString childName = xml->name().toString();
|
||||
if (xml->isStartElement()) {
|
||||
if (childName == "deckname")
|
||||
if (childName == "lastLoadedTimestamp") {
|
||||
lastLoadedTimestamp = xml->readElementText();
|
||||
} else if (childName == "deckname") {
|
||||
name = xml->readElementText();
|
||||
else if (childName == "comments")
|
||||
} else if (childName == "comments") {
|
||||
comments = xml->readElementText();
|
||||
else if (childName == "bannerCard") {
|
||||
bannerCard = xml->readElementText();
|
||||
qDebug() << "Deckloader found the banner card " << bannerCard;
|
||||
} else if (childName == "bannerCard") {
|
||||
QString providerId = xml->attributes().value("providerId").toString();
|
||||
QString cardName = xml->readElementText();
|
||||
bannerCard = QPair<QString, QString>(cardName, providerId);
|
||||
} else if (childName == "tags") {
|
||||
tags.clear(); // Clear existing tags
|
||||
while (xml->readNextStartElement()) {
|
||||
if (xml->name().toString() == "tag") {
|
||||
tags.append(xml->readElementText());
|
||||
}
|
||||
}
|
||||
} else if (childName == "zone") {
|
||||
InnerDecklistNode *newZone = getZoneObjFromName(xml->attributes().value("name").toString());
|
||||
newZone->readElement(xml);
|
||||
} else if (childName == "sideboard_plan") {
|
||||
SideboardPlan *newSideboardPlan = new SideboardPlan;
|
||||
if (newSideboardPlan->readElement(xml))
|
||||
if (newSideboardPlan->readElement(xml)) {
|
||||
sideboardPlans.insert(newSideboardPlan->getName(), newSideboardPlan);
|
||||
else
|
||||
} else {
|
||||
delete newSideboardPlan;
|
||||
}
|
||||
}
|
||||
} else if (xml->isEndElement() && (childName == "cockatrice_deck"))
|
||||
} else if (xml->isEndElement() && (childName == "cockatrice_deck")) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -445,17 +458,33 @@ void DeckList::write(QXmlStreamWriter *xml)
|
||||
{
|
||||
xml->writeStartElement("cockatrice_deck");
|
||||
xml->writeAttribute("version", "1");
|
||||
xml->writeTextElement("lastLoadedTimestamp", lastLoadedTimestamp);
|
||||
xml->writeTextElement("deckname", name);
|
||||
xml->writeTextElement("comments", comments);
|
||||
xml->writeTextElement("bannerCard", bannerCard);
|
||||
|
||||
for (int i = 0; i < root->size(); i++)
|
||||
root->at(i)->writeElement(xml);
|
||||
|
||||
QMapIterator<QString, SideboardPlan *> i(sideboardPlans);
|
||||
while (i.hasNext())
|
||||
i.next().value()->write(xml);
|
||||
xml->writeStartElement("bannerCard");
|
||||
xml->writeAttribute("providerId", bannerCard.second);
|
||||
xml->writeCharacters(bannerCard.first);
|
||||
xml->writeEndElement();
|
||||
xml->writeTextElement("comments", comments);
|
||||
|
||||
// Write tags
|
||||
xml->writeStartElement("tags");
|
||||
for (const QString &tag : tags) {
|
||||
xml->writeTextElement("tag", tag);
|
||||
}
|
||||
xml->writeEndElement();
|
||||
|
||||
// Write zones
|
||||
for (int i = 0; i < root->size(); i++) {
|
||||
root->at(i)->writeElement(xml);
|
||||
}
|
||||
|
||||
// Write sideboard plans
|
||||
QMapIterator<QString, SideboardPlan *> i(sideboardPlans);
|
||||
while (i.hasNext()) {
|
||||
i.next().value()->write(xml);
|
||||
}
|
||||
|
||||
xml->writeEndElement(); // Close "cockatrice_deck"
|
||||
}
|
||||
|
||||
bool DeckList::loadFromXml(QXmlStreamReader *xml)
|
||||
|
||||
Reference in New Issue
Block a user