示例#1
0
DeckListModel::DeckListModel(QObject *parent)
	: QAbstractItemModel(parent)
{
	deckList = new DeckList;
	connect(deckList, SIGNAL(deckLoaded()), this, SLOT(rebuildTree()));
	root = new InnerDecklistNode;
}
示例#2
0
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;
}
示例#3
0
void DeckListModel::setDeckList(DeckLoader *_deck)
{
    delete deckList;
    deckList = _deck;
    connect(deckList, SIGNAL(deckLoaded()), this, SLOT(rebuildTree()));
    connect(deckList, SIGNAL(deckHashChanged()), this, SIGNAL(deckHashChanged()));
    rebuildTree();
}
示例#4
0
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;
}
示例#5
0
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;
}
示例#6
0
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;
}