From cb370738289567829e37b28174a929b4339e1ed1 Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Mon, 10 Nov 2014 16:22:46 +0100 Subject: [PATCH 1/6] Oracle: fetch release date and set type and save them in cards.xml --- cockatrice/src/carddatabase.cpp | 15 +++++++++++---- cockatrice/src/carddatabase.h | 7 ++++++- oracle/src/oracleimporter.cpp | 12 ++++++++---- oracle/src/oracleimporter.h | 8 ++++++-- 4 files changed, 31 insertions(+), 11 deletions(-) diff --git a/cockatrice/src/carddatabase.cpp b/cockatrice/src/carddatabase.cpp index 25886d182..0ca8e565a 100644 --- a/cockatrice/src/carddatabase.cpp +++ b/cockatrice/src/carddatabase.cpp @@ -22,13 +22,15 @@ static QXmlStreamWriter &operator<<(QXmlStreamWriter &xml, const CardSet *set) xml.writeStartElement("set"); xml.writeTextElement("name", set->getShortName()); xml.writeTextElement("longname", set->getLongName()); + xml.writeTextElement("settype", set->getSetType()); + xml.writeTextElement("releasedate", set->getReleaseDate().toString(Qt::ISODate)); xml.writeEndElement(); return xml; } -CardSet::CardSet(const QString &_shortName, const QString &_longName) - : shortName(_shortName), longName(_longName) +CardSet::CardSet(const QString &_shortName, const QString &_longName, const QString &_setType, const QDate &_releaseDate) + : shortName(_shortName), longName(_longName), setType(_setType), releaseDate(_releaseDate) { updateSortKey(); } @@ -703,7 +705,8 @@ void CardDatabase::loadSetsFromXml(QXmlStreamReader &xml) if (xml.readNext() == QXmlStreamReader::EndElement) break; if (xml.name() == "set") { - QString shortName, longName; + QString shortName, longName, setType; + QDate releaseDate; while (!xml.atEnd()) { if (xml.readNext() == QXmlStreamReader::EndElement) break; @@ -711,8 +714,12 @@ void CardDatabase::loadSetsFromXml(QXmlStreamReader &xml) shortName = xml.readElementText(); else if (xml.name() == "longname") longName = xml.readElementText(); + else if (xml.name() == "settype") + setType = xml.readElementText(); + else if (xml.name() == "releasedate") + releaseDate = QDate::fromString(xml.readElementText(), Qt::ISODate); } - sets.insert(shortName, new CardSet(shortName, longName)); + sets.insert(shortName, new CardSet(shortName, longName, setType, releaseDate)); } } } diff --git a/cockatrice/src/carddatabase.h b/cockatrice/src/carddatabase.h index af5a16f1e..60b8006b4 100644 --- a/cockatrice/src/carddatabase.h +++ b/cockatrice/src/carddatabase.h @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -27,11 +28,15 @@ class CardSet : public QList { private: QString shortName, longName; unsigned int sortKey; + QDate releaseDate; + QString setType; public: - CardSet(const QString &_shortName = QString(), const QString &_longName = QString()); + CardSet(const QString &_shortName = QString(), const QString &_longName = QString(), const QString &_setType = QString(), const QDate &_releaseDate = QDate()); QString getCorrectedShortName() const; QString getShortName() const { return shortName; } QString getLongName() const { return longName; } + QString getSetType() const { return setType; } + QDate getReleaseDate() const { return releaseDate; } int getSortKey() const { return sortKey; } void setSortKey(unsigned int _sortKey); void updateSortKey(); diff --git a/oracle/src/oracleimporter.cpp b/oracle/src/oracleimporter.cpp index 48172c487..1b552aa7a 100644 --- a/oracle/src/oracleimporter.cpp +++ b/oracle/src/oracleimporter.cpp @@ -30,6 +30,8 @@ bool OracleImporter::readSetsFromByteArray(const QByteArray &data) QString edition; QString editionLong; QVariant editionCards; + QString setType; + QDate releaseDate; bool import; while (it.hasNext()) { @@ -37,12 +39,14 @@ bool OracleImporter::readSetsFromByteArray(const QByteArray &data) edition = map.value("code").toString(); editionLong = map.value("name").toString(); editionCards = map.value("cards"); + setType = map.value("type").toString(); + releaseDate = map.value("releaseDate").toDate(); // core and expansion sets are marked to be imported by default - import = (0 == QString::compare(map.value("type").toString(), QString("core"), Qt::CaseInsensitive) || - 0 == QString::compare(map.value("type").toString(), QString("expansion"), Qt::CaseInsensitive)); + import = (0 == QString::compare(setType, QString("core"), Qt::CaseInsensitive) || + 0 == QString::compare(setType, QString("expansion"), Qt::CaseInsensitive)); - newSetList.append(SetToDownload(edition, editionLong, editionCards, import)); + newSetList.append(SetToDownload(edition, editionLong, editionCards, import, setType, releaseDate)); } qSort(newSetList); @@ -237,7 +241,7 @@ int OracleImporter::startImport() if(!curSet->getImport()) continue; - CardSet *set = new CardSet(curSet->getShortName(), curSet->getLongName()); + CardSet *set = new CardSet(curSet->getShortName(), curSet->getLongName(), curSet->getSetType(), curSet->getReleaseDate()); if (!sets.contains(set->getShortName())) sets.insert(set->getShortName(), set); diff --git a/oracle/src/oracleimporter.h b/oracle/src/oracleimporter.h index 4c36a211c..261bf62b5 100644 --- a/oracle/src/oracleimporter.h +++ b/oracle/src/oracleimporter.h @@ -10,14 +10,18 @@ private: QString shortName, longName; bool import; QVariant cards; + QDate releaseDate; + QString setType; public: const QString &getShortName() const { return shortName; } const QString &getLongName() const { return longName; } const QVariant &getCards() const { return cards; } + const QString &getSetType() const { return setType; } + const QDate &getReleaseDate() const { return releaseDate; } bool getImport() const { return import; } void setImport(bool _import) { import = _import; } - SetToDownload(const QString &_shortName, const QString &_longName, const QVariant &_cards, bool _import) - : shortName(_shortName), longName(_longName), import(_import), cards(_cards) { } + SetToDownload(const QString &_shortName, const QString &_longName, const QVariant &_cards, bool _import, const QString &_setType = QString(), const QDate &_releaseDate = QDate()) + : shortName(_shortName), longName(_longName), import(_import), cards(_cards), setType(_setType), releaseDate(_releaseDate) { } bool operator<(const SetToDownload &set) const { return longName.compare(set.longName, Qt::CaseInsensitive) < 0; } }; From 8542d875d338f86e815651b0d12ecbc3d59af7f5 Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Wed, 19 Nov 2014 18:09:37 +0100 Subject: [PATCH 2/6] Sets dialog: new columns and sorting Added "order key", "set type" and "release date" columns Use a proxy model to sort the table made the dialog wider accordingly --- cockatrice/src/setsmodel.cpp | 23 ++++++++++++++++++----- cockatrice/src/setsmodel.h | 15 ++++++++++++--- cockatrice/src/window_sets.cpp | 15 +++++++++++++-- cockatrice/src/window_sets.h | 2 ++ 4 files changed, 45 insertions(+), 10 deletions(-) diff --git a/cockatrice/src/setsmodel.cpp b/cockatrice/src/setsmodel.cpp index f11d73c4b..ca1be306c 100644 --- a/cockatrice/src/setsmodel.cpp +++ b/cockatrice/src/setsmodel.cpp @@ -20,13 +20,16 @@ int SetsModel::rowCount(const QModelIndex &parent) const QVariant SetsModel::data(const QModelIndex &index, int role) const { - if (!index.isValid() || (index.column() >= 2) || (index.row() >= rowCount()) || (role != Qt::DisplayRole)) + if (!index.isValid() || (index.column() >= NUM_COLS) || (index.row() >= rowCount()) || (role != Qt::DisplayRole)) return QVariant(); CardSet *set = sets[index.row()]; switch (index.column()) { - case 0: return set->getShortName(); - case 1: return set->getLongName(); + case SortKeyCol: return set->getSortKey(); + case SetTypeCol: return set->getSetType(); + case ShortNameCol: return set->getShortName(); + case LongNameCol: return set->getLongName(); + case ReleaseDateCol: return set->getReleaseDate(); default: return QVariant(); } } @@ -36,8 +39,11 @@ QVariant SetsModel::headerData(int section, Qt::Orientation orientation, int rol if ((role != Qt::DisplayRole) || (orientation != Qt::Horizontal)) return QVariant(); switch (section) { - case 0: return tr("Short name"); - case 1: return tr("Long name"); + case SortKeyCol: return tr("Key"); + case SetTypeCol: return tr("Set type"); + case ShortNameCol: return tr("Short name"); + case LongNameCol: return tr("Long name"); + case ReleaseDateCol: return tr("Release date"); default: return QVariant(); } } @@ -91,3 +97,10 @@ QStringList SetsModel::mimeTypes() const { return QStringList() << "application/x-cockatricecardset"; } + +SetsProxyModel::SetsProxyModel(QObject *parent) + : QSortFilterProxyModel(parent) +{ + setDynamicSortFilter(true); +} + diff --git a/cockatrice/src/setsmodel.h b/cockatrice/src/setsmodel.h index 74d294431..eaf7d89bc 100644 --- a/cockatrice/src/setsmodel.h +++ b/cockatrice/src/setsmodel.h @@ -2,6 +2,7 @@ #define SETSMODEL_H #include +#include #include #include "carddatabase.h" @@ -17,11 +18,16 @@ public: class SetsModel : public QAbstractTableModel { Q_OBJECT +private: + static const int NUM_COLS = 5; + SetList sets; public: + enum SetsColumns { SortKeyCol, SetTypeCol, ShortNameCol, LongNameCol, ReleaseDateCol }; + SetsModel(CardDatabase *_db, QObject *parent = 0); ~SetsModel(); int rowCount(const QModelIndex &parent = QModelIndex()) const; - int columnCount(const QModelIndex &/*parent*/) const { return 2; } + int columnCount(const QModelIndex &parent = QModelIndex()) const { return NUM_COLS; } QVariant data(const QModelIndex &index, int role) const; QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; Qt::ItemFlags flags(const QModelIndex &index) const; @@ -30,8 +36,11 @@ public: QMimeData *mimeData(const QModelIndexList &indexes) const; bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent); QStringList mimeTypes() const; -private: - SetList sets; }; +class SetsProxyModel : public QSortFilterProxyModel { + Q_OBJECT +public: + SetsProxyModel(QObject *parent = 0); +}; #endif diff --git a/cockatrice/src/window_sets.cpp b/cockatrice/src/window_sets.cpp index 668b36e0e..d56f34872 100644 --- a/cockatrice/src/window_sets.cpp +++ b/cockatrice/src/window_sets.cpp @@ -3,21 +3,32 @@ #include "main.h" #include #include +#include WndSets::WndSets(QWidget *parent) : QMainWindow(parent) { model = new SetsModel(db, this); + proxyModel = new SetsProxyModel(this); + proxyModel->setSourceModel(model); + proxyModel->setSortCaseSensitivity(Qt::CaseInsensitive); view = new QTreeView; - view->setModel(model); + view->setModel(proxyModel); view->setAlternatingRowColors(true); view->setUniformRowHeights(true); view->setAllColumnsShowFocus(true); + view->setSortingEnabled(true); + view->sortByColumn(SetsModel::SortKeyCol, Qt::AscendingOrder); view->setDragEnabled(true); view->setAcceptDrops(true); view->setDropIndicatorShown(true); view->setDragDropMode(QAbstractItemView::InternalMove); +#if QT_VERSION < 0x050000 + view->header()->setResizeMode(SetsModel::LongNameCol, QHeaderView::ResizeToContents); +#else + view->header()->setSectionResizeMode(SetsModel::LongNameCol, QHeaderView::ResizeToContents); +#endif QHBoxLayout *mainLayout = new QHBoxLayout; mainLayout->addWidget(view); @@ -27,7 +38,7 @@ WndSets::WndSets(QWidget *parent) setCentralWidget(centralWidget); setWindowTitle(tr("Edit sets")); - resize(400, 400); + resize(700, 400); } WndSets::~WndSets() diff --git a/cockatrice/src/window_sets.h b/cockatrice/src/window_sets.h index ce7cb6228..45317dd6b 100644 --- a/cockatrice/src/window_sets.h +++ b/cockatrice/src/window_sets.h @@ -4,6 +4,7 @@ #include class SetsModel; +class SetsProxyModel; class QTreeView; class CardDatabase; @@ -11,6 +12,7 @@ class WndSets : public QMainWindow { Q_OBJECT private: SetsModel *model; + SetsProxyModel *proxyModel; QTreeView *view; public: WndSets(QWidget *parent = 0); From ac43fa23b940dc444698ab1f368bc61e62f43e36 Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Wed, 19 Nov 2014 19:44:54 +0100 Subject: [PATCH 3/6] Better handle the TK set used for tokens MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Let oracle add a basic TK set in cards.xml Unify all the code previously using the string literal “TK” --- cockatrice/src/carddatabase.cpp | 3 ++- cockatrice/src/carddatabase.h | 2 ++ cockatrice/src/dlg_edit_tokens.cpp | 2 +- oracle/src/oracleimporter.cpp | 4 ++++ 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/cockatrice/src/carddatabase.cpp b/cockatrice/src/carddatabase.cpp index 0ca8e565a..9fc0295b8 100644 --- a/cockatrice/src/carddatabase.cpp +++ b/cockatrice/src/carddatabase.cpp @@ -16,6 +16,7 @@ #include const int CardDatabase::versionNeeded = 3; +const char* CardDatabase::TOKENS_SETNAME = "TK"; static QXmlStreamWriter &operator<<(QXmlStreamWriter &xml, const CardSet *set) { @@ -791,7 +792,7 @@ CardInfo *CardDatabase::getCardFromMap(CardNameMap &cardMap, const QString &card return cardMap.value(cardName); else if (createIfNotFound) { CardInfo *newCard = new CardInfo(this, cardName, true); - newCard->addToSet(getSet("TK")); + newCard->addToSet(getSet(CardDatabase::TOKENS_SETNAME)); cardMap.insert(cardName, newCard); return newCard; } else diff --git a/cockatrice/src/carddatabase.h b/cockatrice/src/carddatabase.h index 60b8006b4..e9b693f8b 100644 --- a/cockatrice/src/carddatabase.h +++ b/cockatrice/src/carddatabase.h @@ -218,6 +218,8 @@ private: CardInfo *getCardFromMap(CardNameMap &cardMap, const QString &cardName, bool createIfNotFound); public: + static const char* TOKENS_SETNAME; + CardDatabase(QObject *parent = 0); ~CardDatabase(); void clear(); diff --git a/cockatrice/src/dlg_edit_tokens.cpp b/cockatrice/src/dlg_edit_tokens.cpp index e2de2cd4b..2d272a6d5 100644 --- a/cockatrice/src/dlg_edit_tokens.cpp +++ b/cockatrice/src/dlg_edit_tokens.cpp @@ -146,7 +146,7 @@ void DlgEditTokens::actAddToken() return; CardInfo *card = new CardInfo(cardDatabaseModel->getDatabase(), name, true); - card->addToSet(cardDatabaseModel->getDatabase()->getSet("TK")); + card->addToSet(cardDatabaseModel->getDatabase()->getSet(CardDatabase::TOKENS_SETNAME)); card->setCardType("Token"); cardDatabaseModel->getDatabase()->addCard(card); } diff --git a/oracle/src/oracleimporter.cpp b/oracle/src/oracleimporter.cpp index 1b552aa7a..273203c7c 100644 --- a/oracle/src/oracleimporter.cpp +++ b/oracle/src/oracleimporter.cpp @@ -235,6 +235,10 @@ int OracleImporter::startImport() QListIterator it(allSets); const SetToDownload * curSet; + // add an empty set for tokens + CardSet *tokenSet = new CardSet(TOKENS_SETNAME, tr("Dummy set containing tokens"), "tokens"); + sets.insert(TOKENS_SETNAME, tokenSet); + while (it.hasNext()) { curSet = & it.next(); From f48f386f35f6c31ada36746d2c102ea31b1bd956 Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Wed, 19 Nov 2014 22:18:41 +0100 Subject: [PATCH 4/6] Sets window: implemented save and restore buttons --- cockatrice/src/setsmodel.cpp | 18 ++++++++++++++++++ cockatrice/src/setsmodel.h | 4 ++++ cockatrice/src/window_sets.cpp | 24 +++++++++++++++++++++--- cockatrice/src/window_sets.h | 5 +++++ 4 files changed, 48 insertions(+), 3 deletions(-) diff --git a/cockatrice/src/setsmodel.cpp b/cockatrice/src/setsmodel.cpp index ca1be306c..206932c4d 100644 --- a/cockatrice/src/setsmodel.cpp +++ b/cockatrice/src/setsmodel.cpp @@ -90,6 +90,10 @@ bool SetsModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int r for (int i = 0; i < sets.size(); i++) sets[i]->setSortKey(i); + sets.sortByKey(); + + emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1)); + return true; } @@ -104,3 +108,17 @@ SetsProxyModel::SetsProxyModel(QObject *parent) setDynamicSortFilter(true); } +void SetsProxyModel::saveOrder() +{ + int numRows = rowCount(); + SetsModel * model = (SetsModel*) sourceModel(); + for(int row = 0; row < numRows; ++row) { + QModelIndex idx = index(row, 0); + int oldRow = data(idx, Qt::DisplayRole).toInt(); + CardSet *temp = model->sets.at(oldRow); + temp->setSortKey(row); + } + model->sets.sortByKey(); + + emit model->dataChanged(model->index(0, 0), model->index(model->rowCount() - 1, model->columnCount() - 1)); +} diff --git a/cockatrice/src/setsmodel.h b/cockatrice/src/setsmodel.h index eaf7d89bc..69f693435 100644 --- a/cockatrice/src/setsmodel.h +++ b/cockatrice/src/setsmodel.h @@ -6,6 +6,8 @@ #include #include "carddatabase.h" +class SetsProxyModel; + class SetsMimeData : public QMimeData { Q_OBJECT private: @@ -18,6 +20,7 @@ public: class SetsModel : public QAbstractTableModel { Q_OBJECT + friend class SetsProxyModel; private: static const int NUM_COLS = 5; SetList sets; @@ -42,5 +45,6 @@ class SetsProxyModel : public QSortFilterProxyModel { Q_OBJECT public: SetsProxyModel(QObject *parent = 0); + void saveOrder(); }; #endif diff --git a/cockatrice/src/window_sets.cpp b/cockatrice/src/window_sets.cpp index d56f34872..c0fbb8f80 100644 --- a/cockatrice/src/window_sets.cpp +++ b/cockatrice/src/window_sets.cpp @@ -2,8 +2,9 @@ #include "setsmodel.h" #include "main.h" #include -#include +#include #include +#include WndSets::WndSets(QWidget *parent) : QMainWindow(parent) @@ -30,8 +31,15 @@ WndSets::WndSets(QWidget *parent) view->header()->setSectionResizeMode(SetsModel::LongNameCol, QHeaderView::ResizeToContents); #endif - QHBoxLayout *mainLayout = new QHBoxLayout; - mainLayout->addWidget(view); + saveButton = new QPushButton(tr("Save sets order")); + connect(saveButton, SIGNAL(clicked()), this, SLOT(actSave())); + restoreButton = new QPushButton(tr("Restore saved sets order")); + connect(restoreButton, SIGNAL(clicked()), this, SLOT(actRestore())); + + QGridLayout *mainLayout = new QGridLayout; + mainLayout->addWidget(view, 0, 0, 1, 2); + mainLayout->addWidget(saveButton, 1, 0, 1, 1); + mainLayout->addWidget(restoreButton, 1, 1, 1, 1); QWidget *centralWidget = new QWidget; centralWidget->setLayout(mainLayout); @@ -44,3 +52,13 @@ WndSets::WndSets(QWidget *parent) WndSets::~WndSets() { } + +void WndSets::actSave() +{ + proxyModel->saveOrder(); +} + +void WndSets::actRestore() +{ + view->sortByColumn(SetsModel::SortKeyCol, Qt::AscendingOrder); +} diff --git a/cockatrice/src/window_sets.h b/cockatrice/src/window_sets.h index 45317dd6b..465705191 100644 --- a/cockatrice/src/window_sets.h +++ b/cockatrice/src/window_sets.h @@ -6,6 +6,7 @@ class SetsModel; class SetsProxyModel; class QTreeView; +class QPushButton; class CardDatabase; class WndSets : public QMainWindow { @@ -14,9 +15,13 @@ private: SetsModel *model; SetsProxyModel *proxyModel; QTreeView *view; + QPushButton *saveButton, *restoreButton; public: WndSets(QWidget *parent = 0); ~WndSets(); +private slots: + void actSave(); + void actRestore(); }; #endif From ee3731717c3e6615b3a86aa3d2b129412bcc7ec8 Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Thu, 20 Nov 2014 09:15:58 +0100 Subject: [PATCH 5/6] Fixed button labels --- cockatrice/src/window_sets.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cockatrice/src/window_sets.cpp b/cockatrice/src/window_sets.cpp index c0fbb8f80..d37d370a2 100644 --- a/cockatrice/src/window_sets.cpp +++ b/cockatrice/src/window_sets.cpp @@ -31,9 +31,9 @@ WndSets::WndSets(QWidget *parent) view->header()->setSectionResizeMode(SetsModel::LongNameCol, QHeaderView::ResizeToContents); #endif - saveButton = new QPushButton(tr("Save sets order")); + saveButton = new QPushButton(tr("Save set ordering")); connect(saveButton, SIGNAL(clicked()), this, SLOT(actSave())); - restoreButton = new QPushButton(tr("Restore saved sets order")); + restoreButton = new QPushButton(tr("Restore saved set ordering")); connect(restoreButton, SIGNAL(clicked()), this, SLOT(actRestore())); QGridLayout *mainLayout = new QGridLayout; From 859adca0c7e1eb46be5ccfc61add8f12c1e0c261 Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Thu, 20 Nov 2014 09:16:30 +0100 Subject: [PATCH 6/6] Fixed indentation --- oracle/src/oracleimporter.h | 54 ++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/oracle/src/oracleimporter.h b/oracle/src/oracleimporter.h index 261bf62b5..e8fe9e9db 100644 --- a/oracle/src/oracleimporter.h +++ b/oracle/src/oracleimporter.h @@ -7,42 +7,42 @@ class SetToDownload { private: - QString shortName, longName; - bool import; - QVariant cards; + QString shortName, longName; + bool import; + QVariant cards; QDate releaseDate; QString setType; public: - const QString &getShortName() const { return shortName; } - const QString &getLongName() const { return longName; } - const QVariant &getCards() const { return cards; } - const QString &getSetType() const { return setType; } - const QDate &getReleaseDate() const { return releaseDate; } - bool getImport() const { return import; } - void setImport(bool _import) { import = _import; } - SetToDownload(const QString &_shortName, const QString &_longName, const QVariant &_cards, bool _import, const QString &_setType = QString(), const QDate &_releaseDate = QDate()) - : shortName(_shortName), longName(_longName), import(_import), cards(_cards), setType(_setType), releaseDate(_releaseDate) { } - bool operator<(const SetToDownload &set) const { return longName.compare(set.longName, Qt::CaseInsensitive) < 0; } + const QString &getShortName() const { return shortName; } + const QString &getLongName() const { return longName; } + const QVariant &getCards() const { return cards; } + const QString &getSetType() const { return setType; } + const QDate &getReleaseDate() const { return releaseDate; } + bool getImport() const { return import; } + void setImport(bool _import) { import = _import; } + SetToDownload(const QString &_shortName, const QString &_longName, const QVariant &_cards, bool _import, const QString &_setType = QString(), const QDate &_releaseDate = QDate()) + : shortName(_shortName), longName(_longName), import(_import), cards(_cards), setType(_setType), releaseDate(_releaseDate) { } + bool operator<(const SetToDownload &set) const { return longName.compare(set.longName, Qt::CaseInsensitive) < 0; } }; class OracleImporter : public CardDatabase { - Q_OBJECT + Q_OBJECT private: - QList allSets; - QVariantMap setsMap; - QString dataDir; - - CardInfo *addCard(const QString &setName, QString cardName, bool isToken, int cardId, QString &cardCost, const QString &cardType, const QString &cardPT, int cardLoyalty, const QStringList &cardText); + QList allSets; + QVariantMap setsMap; + QString dataDir; + + CardInfo *addCard(const QString &setName, QString cardName, bool isToken, int cardId, QString &cardCost, const QString &cardType, const QString &cardPT, int cardLoyalty, const QStringList &cardText); signals: - void setIndexChanged(int cardsImported, int setIndex, const QString &setName); - void dataReadProgress(int bytesRead, int totalBytes); + void setIndexChanged(int cardsImported, int setIndex, const QString &setName); + void dataReadProgress(int bytesRead, int totalBytes); public: - OracleImporter(const QString &_dataDir, QObject *parent = 0); - bool readSetsFromByteArray(const QByteArray &data); - int startImport(); - int importTextSpoiler(CardSet *set, const QVariant &data); - QList &getSets() { return allSets; } - const QString &getDataDir() const { return dataDir; } + OracleImporter(const QString &_dataDir, QObject *parent = 0); + bool readSetsFromByteArray(const QByteArray &data); + int startImport(); + int importTextSpoiler(CardSet *set, const QVariant &data); + QList &getSets() { return allSets; } + const QString &getDataDir() const { return dataDir; } }; #endif