mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-12 17:14:52 -07:00
oracle importer changes
This commit is contained in:
parent
03132e2edd
commit
40fc77c646
9 changed files with 183 additions and 58 deletions
|
|
@ -232,7 +232,7 @@ QXmlStreamWriter &operator<<(QXmlStreamWriter &xml, const CardInfo *info)
|
|||
}
|
||||
|
||||
CardDatabase::CardDatabase(QObject *parent)
|
||||
: QObject(parent), noCard(0)
|
||||
: QObject(parent), downloadRunning(false), loadSuccess(false), noCard(0)
|
||||
{
|
||||
connect(settingsCache, SIGNAL(picsPathChanged()), this, SLOT(clearPixmapCache()));
|
||||
connect(settingsCache, SIGNAL(cardDatabasePathChanged()), this, SLOT(loadCardDatabase()));
|
||||
|
|
@ -428,12 +428,12 @@ void CardDatabase::loadCardsFromXml(QXmlStreamReader &xml)
|
|||
}
|
||||
}
|
||||
|
||||
int CardDatabase::loadFromFile(const QString &fileName)
|
||||
bool CardDatabase::loadFromFile(const QString &fileName)
|
||||
{
|
||||
QFile file(fileName);
|
||||
file.open(QIODevice::ReadOnly);
|
||||
if (!file.isOpen())
|
||||
return -1;
|
||||
return false;
|
||||
QXmlStreamReader xml(&file);
|
||||
clear();
|
||||
while (!xml.atEnd()) {
|
||||
|
|
@ -451,7 +451,7 @@ int CardDatabase::loadFromFile(const QString &fileName)
|
|||
}
|
||||
}
|
||||
qDebug(QString("%1 cards in %2 sets loaded").arg(cardHash.size()).arg(setHash.size()).toLatin1());
|
||||
return cardHash.size();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CardDatabase::saveToFile(const QString &fileName)
|
||||
|
|
@ -492,11 +492,13 @@ void CardDatabase::picDownloadChanged()
|
|||
}
|
||||
}
|
||||
|
||||
void CardDatabase::loadCardDatabase()
|
||||
bool CardDatabase::loadCardDatabase()
|
||||
{
|
||||
QString cardDatabasePath = settingsCache->getCardDatabasePath();
|
||||
if (!cardDatabasePath.isEmpty())
|
||||
loadFromFile(cardDatabasePath);
|
||||
loadSuccess = loadFromFile(cardDatabasePath);
|
||||
else loadSuccess = false;
|
||||
return loadSuccess;
|
||||
}
|
||||
|
||||
QStringList CardDatabase::getAllColors() const
|
||||
|
|
|
|||
|
|
@ -99,6 +99,7 @@ protected:
|
|||
QList<CardInfo *> cardsToDownload;
|
||||
CardInfo *cardBeingDownloaded;
|
||||
bool downloadRunning;
|
||||
bool loadSuccess;
|
||||
CardInfo *noCard;
|
||||
private:
|
||||
void loadCardsFromXml(QXmlStreamReader &xml);
|
||||
|
|
@ -112,16 +113,17 @@ public:
|
|||
CardSet *getSet(const QString &setName);
|
||||
QList<CardInfo *> getCardList() const { return cardHash.values(); }
|
||||
SetList getSetList() const;
|
||||
int loadFromFile(const QString &fileName);
|
||||
bool loadFromFile(const QString &fileName);
|
||||
bool saveToFile(const QString &fileName);
|
||||
void startPicDownload(CardInfo *card);
|
||||
QStringList getAllColors() const;
|
||||
QStringList getAllMainCardTypes() const;
|
||||
bool getLoadSuccess() const { return loadSuccess; }
|
||||
public slots:
|
||||
void clearPixmapCache();
|
||||
private slots:
|
||||
void picDownloadFinished(QNetworkReply *reply);
|
||||
void loadCardDatabase();
|
||||
bool loadCardDatabase();
|
||||
void picDownloadChanged();
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -454,6 +454,21 @@ void DlgSettings::changeEvent(QEvent *event)
|
|||
QDialog::changeEvent(event);
|
||||
}
|
||||
|
||||
void DlgSettings::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
if (!db->getLoadSuccess()) {
|
||||
QMessageBox::critical(this, tr("Error"), tr("Your card database is invalid. Please check if the path is set correctly."));
|
||||
event->ignore();
|
||||
} else if (!QDir(settingsCache->getDeckPath()).exists()) {
|
||||
QMessageBox::critical(this, tr("Error"), tr("The path to your deck directory is invalid."));
|
||||
event->ignore();
|
||||
} else if (!QDir(settingsCache->getPicsPath()).exists()) {
|
||||
QMessageBox::critical(this, tr("Error"), tr("The path to your card pictures directory is invalid."));
|
||||
event->ignore();
|
||||
} else
|
||||
event->accept();
|
||||
}
|
||||
|
||||
void DlgSettings::retranslateUi()
|
||||
{
|
||||
setWindowTitle(tr("Settings"));
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ class QComboBox;
|
|||
class QGroupBox;
|
||||
class QCheckBox;
|
||||
class QLabel;
|
||||
class QCloseEvent;
|
||||
|
||||
class AbstractSettingsPage : public QWidget {
|
||||
public:
|
||||
|
|
@ -107,6 +108,7 @@ private:
|
|||
void retranslateUi();
|
||||
protected:
|
||||
void changeEvent(QEvent *event);
|
||||
void closeEvent(QCloseEvent *event);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -26,10 +26,12 @@
|
|||
#include <QDateTime>
|
||||
#include <QSettings>
|
||||
#include <QIcon>
|
||||
#include <QDir>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "main.h"
|
||||
#include "window_main.h"
|
||||
#include "dlg_settings.h"
|
||||
#include "carddatabase.h"
|
||||
#include "settingscache.h"
|
||||
#include "pingpixmapgenerator.h"
|
||||
|
|
@ -80,20 +82,30 @@ int main(int argc, char *argv[])
|
|||
|
||||
qsrand(QDateTime::currentDateTime().toTime_t());
|
||||
|
||||
MainWindow ui;
|
||||
qDebug("main(): MainWindow constructor finished");
|
||||
bool startMainProgram = true;
|
||||
if (!db->getLoadSuccess() || !QDir(settingsCache->getDeckPath()).exists() || !QDir(settingsCache->getPicsPath()).exists()) {
|
||||
DlgSettings dlgSettings;
|
||||
dlgSettings.show();
|
||||
app.exec();
|
||||
startMainProgram = (db->getLoadSuccess() && QDir(settingsCache->getDeckPath()).exists() && QDir(settingsCache->getPicsPath()).exists());
|
||||
}
|
||||
|
||||
QIcon icon(":/resources/appicon.svg");
|
||||
ui.setWindowIcon(icon);
|
||||
|
||||
ui.show();
|
||||
qDebug("main(): ui.show() finished");
|
||||
|
||||
int retval = app.exec();
|
||||
if (startMainProgram) {
|
||||
MainWindow ui;
|
||||
qDebug("main(): MainWindow constructor finished");
|
||||
|
||||
QIcon icon(":/resources/appicon.svg");
|
||||
ui.setWindowIcon(icon);
|
||||
|
||||
ui.show();
|
||||
qDebug("main(): ui.show() finished");
|
||||
|
||||
app.exec();
|
||||
}
|
||||
|
||||
delete pingPixmapGenerator;
|
||||
delete db;
|
||||
delete settingsCache;
|
||||
|
||||
return retval;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue