mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2025-12-23 07:28:24 -08:00
minor oracle improvement
This commit is contained in:
@@ -460,7 +460,8 @@ bool CardDatabase::loadFromFile(const QString &fileName)
|
|||||||
bool CardDatabase::saveToFile(const QString &fileName)
|
bool CardDatabase::saveToFile(const QString &fileName)
|
||||||
{
|
{
|
||||||
QFile file(fileName);
|
QFile file(fileName);
|
||||||
file.open(QIODevice::WriteOnly);
|
if (!file.open(QIODevice::WriteOnly))
|
||||||
|
return false;
|
||||||
QXmlStreamWriter xml(&file);
|
QXmlStreamWriter xml(&file);
|
||||||
|
|
||||||
xml.setAutoFormatting(true);
|
xml.setAutoFormatting(true);
|
||||||
|
|||||||
@@ -266,7 +266,6 @@ void OracleImporter::httpRequestFinished(int requestId, bool error)
|
|||||||
++setIndex;
|
++setIndex;
|
||||||
|
|
||||||
if (setIndex == setsToDownload.size()) {
|
if (setIndex == setsToDownload.size()) {
|
||||||
saveToFile(dataDir + "/cards.xml");
|
|
||||||
emit setIndexChanged(cards, setIndex, QString());
|
emit setIndexChanged(cards, setIndex, QString());
|
||||||
setIndex = -1;
|
setIndex = -1;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ public:
|
|||||||
int startDownload();
|
int startDownload();
|
||||||
int importTextSpoiler(CardSet *set, const QByteArray &data);
|
int importTextSpoiler(CardSet *set, const QByteArray &data);
|
||||||
QList<SetToDownload> &getSets() { return allSets; }
|
QList<SetToDownload> &getSets() { return allSets; }
|
||||||
|
const QString &getDataDir() const { return dataDir; }
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -153,6 +153,23 @@ void WindowMain::updateTotalProgress(int cardsImported, int setIndex, const QStr
|
|||||||
totalProgressBar->setValue(setIndex);
|
totalProgressBar->setValue(setIndex);
|
||||||
if (nextSetName.isEmpty()) {
|
if (nextSetName.isEmpty()) {
|
||||||
QMessageBox::information(this, tr("Oracle importer"), tr("Import finished: %1 cards.").arg(importer->getCardList().size()));
|
QMessageBox::information(this, tr("Oracle importer"), tr("Import finished: %1 cards.").arg(importer->getCardList().size()));
|
||||||
|
bool ok = false;
|
||||||
|
QString savePath = importer->getDataDir() + "/cards.xml";
|
||||||
|
do {
|
||||||
|
QString fileName;
|
||||||
|
if (savePath.isEmpty())
|
||||||
|
fileName = QFileDialog::getSaveFileName(this, tr("Save card database"), importer->getDataDir() + "/cards.xml", tr("XML card database (*.xml)"));
|
||||||
|
else {
|
||||||
|
fileName = savePath;
|
||||||
|
savePath.clear();
|
||||||
|
}
|
||||||
|
if (fileName.isEmpty())
|
||||||
|
qApp->quit();
|
||||||
|
if (importer->saveToFile(fileName))
|
||||||
|
ok = true;
|
||||||
|
else
|
||||||
|
QMessageBox::critical(this, tr("Error"), tr("The file could not be saved to the desired location."));
|
||||||
|
} while (!ok);
|
||||||
qApp->quit();
|
qApp->quit();
|
||||||
} else {
|
} else {
|
||||||
nextSetLabel2->setText(nextSetName);
|
nextSetLabel2->setText(nextSetName);
|
||||||
|
|||||||
Reference in New Issue
Block a user