mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-10 08:14:47 -07:00
oracle update
This commit is contained in:
parent
bd434437ad
commit
a018819a37
4 changed files with 8 additions and 356 deletions
|
|
@ -5,7 +5,7 @@ int main(int argc, char *argv[])
|
|||
{
|
||||
QApplication app(argc, argv);
|
||||
|
||||
OracleImporter importer;
|
||||
OracleImporter importer("../oracle");
|
||||
importer.downloadNextFile();
|
||||
|
||||
return app.exec();
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@
|
|||
#include <QtNetwork>
|
||||
#include <QXmlStreamReader>
|
||||
|
||||
OracleImporter::OracleImporter()
|
||||
: setIndex(-1)
|
||||
OracleImporter::OracleImporter(const QString &_dataDir)
|
||||
: dataDir(_dataDir), setIndex(-1)
|
||||
{
|
||||
QFile setsFile("sets.xml");
|
||||
QFile setsFile(dataDir + "/sets.xml");
|
||||
setsFile.open(QIODevice::ReadOnly | QIODevice::Text);
|
||||
QXmlStreamReader xml(&setsFile);
|
||||
QString edition;
|
||||
|
|
@ -159,7 +159,7 @@ void OracleImporter::downloadNextFile()
|
|||
buffer->open(QIODevice::ReadWrite | QIODevice::Text);
|
||||
reqId = http->get(QUrl::toPercentEncoding(url.path(), "!$&'()*+,;=:@/"), buffer);
|
||||
} else {
|
||||
QFile file(urlString);
|
||||
QFile file(dataDir + "/" + urlString);
|
||||
file.open(QIODevice::ReadOnly | QIODevice::Text);
|
||||
|
||||
buffer->close();
|
||||
|
|
@ -188,7 +188,7 @@ void OracleImporter::httpRequestFinished(int requestId, bool error)
|
|||
if (setIndex == setsToDownload.size()) {
|
||||
QMessageBox::information(0, tr("Import finished"), tr("Total: %1 cards imported").arg(cardHash.size()));
|
||||
setIndex = -1;
|
||||
saveToFile("cards.xml");
|
||||
saveToFile(dataDir + "/cards.xml");
|
||||
qApp->quit();
|
||||
} else
|
||||
downloadNextFile();
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ class OracleImporter : public CardDatabase {
|
|||
private:
|
||||
QList<SetToDownload> setsToDownload;
|
||||
QString pictureUrl;
|
||||
QString dataDir;
|
||||
int setIndex;
|
||||
int reqId;
|
||||
QBuffer *buffer;
|
||||
|
|
@ -34,7 +35,7 @@ private slots:
|
|||
void httpRequestFinished(int requestId, bool error);
|
||||
void readResponseHeader(const QHttpResponseHeader &responseHeader);
|
||||
public:
|
||||
OracleImporter();
|
||||
OracleImporter(const QString &_dataDir);
|
||||
void importOracleFile(CardSet *set);
|
||||
void downloadNextFile();
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue