DeckListModel::DeckListModel(QObject *parent) : QAbstractItemModel(parent) { deckList = new DeckList; connect(deckList, SIGNAL(deckLoaded()), this, SLOT(rebuildTree())); root = new InnerDecklistNode; }
bool DeckLoader::loadFromFile(const QString &fileName, FileFormat fmt) { QFile file(fileName); if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) return false; bool result = false; switch (fmt) { case PlainTextFormat: result = loadFromFile_Plain(&file); break; case CockatriceFormat: result = loadFromFile_Native(&file); qDebug() << "Loaded from" << fileName << "-" << result; if (!result) { qDebug() << "Retying as plain format"; file.seek(0); result = loadFromFile_Plain(&file); fmt = PlainTextFormat; } break; } if (result) { lastFileName = fileName; lastFileFormat = fmt; emit deckLoaded(); } qDebug() << "Deck was loaded -" << result; return result; }
void DeckListModel::setDeckList(DeckLoader *_deck) { delete deckList; deckList = _deck; connect(deckList, SIGNAL(deckLoaded()), this, SLOT(rebuildTree())); connect(deckList, SIGNAL(deckHashChanged()), this, SIGNAL(deckHashChanged())); rebuildTree(); }
DeckListModel::DeckListModel(QObject *parent) : QAbstractItemModel(parent), lastKnownColumn(1), lastKnownOrder(Qt::AscendingOrder) { deckList = new DeckLoader; connect(deckList, SIGNAL(deckLoaded()), this, SLOT(rebuildTree())); connect(deckList, SIGNAL(deckHashChanged()), this, SIGNAL(deckHashChanged())); root = new InnerDecklistNode; }
bool DeckLoader::loadFromRemote(const QString &nativeString, int remoteDeckId) { bool result = loadFromString_Native(nativeString); if (result) { lastFileName = QString(); lastFileFormat = CockatriceFormat; lastRemoteDeckId = remoteDeckId; emit deckLoaded(); } return result; }
bool DeckLoader::loadFromFile(const QString &fileName, FileFormat fmt) { QFile file(fileName); if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) return false; bool result = false; switch (fmt) { case PlainTextFormat: result = loadFromFile_Plain(&file); break; case CockatriceFormat: result = loadFromFile_Native(&file); break; } if (result) { lastFileName = fileName; lastFileFormat = fmt; emit deckLoaded(); } return result; }