carddb thread fix; added VG, AE, PCH to sets
This commit is contained in:
parent
acac5addd6
commit
1151077c1e
3 changed files with 29 additions and 5 deletions
|
@ -223,7 +223,6 @@ void PictureLoader::setPicDownload(bool _picDownload)
|
|||
PictureLoadingThread::PictureLoadingThread(const QString &_picsPath, bool _picDownload, QObject *parent)
|
||||
: QThread(parent), picsPath(_picsPath), picDownload(_picDownload)
|
||||
{
|
||||
initMutex.lock();
|
||||
}
|
||||
|
||||
PictureLoadingThread::~PictureLoadingThread()
|
||||
|
@ -239,12 +238,22 @@ void PictureLoadingThread::run()
|
|||
pictureLoader->setPicsPath(picsPath);
|
||||
pictureLoader->setPicDownload(picDownload);
|
||||
|
||||
initMutex.unlock();
|
||||
usleep(100);
|
||||
initWaitCondition.wakeAll();
|
||||
|
||||
exec();
|
||||
|
||||
delete pictureLoader;
|
||||
}
|
||||
|
||||
void PictureLoadingThread::waitForInit()
|
||||
{
|
||||
QMutex mutex;
|
||||
mutex.lock();
|
||||
initWaitCondition.wait(&mutex);
|
||||
mutex.unlock();
|
||||
}
|
||||
|
||||
CardInfo::CardInfo(CardDatabase *_db, const QString &_name, const QString &_manacost, const QString &_cardtype, const QString &_powtough, const QString &_text, const QStringList &_colors, bool _cipt, int _tableRow, const SetList &_sets, const QMap<QString, QString> &_picURLs, const QMap<QString, QString> &_picURLsHq, const QMap<QString, QString> &_picURLsSt)
|
||||
: db(_db), name(_name), sets(_sets), manacost(_manacost), cardtype(_cardtype), powtough(_powtough), text(_text), colors(_colors), picURLs(_picURLs), picURLsHq(_picURLsHq), picURLsSt(_picURLsSt), cipt(_cipt), tableRow(_tableRow), pixmap(NULL)
|
||||
{
|
||||
|
@ -427,6 +436,7 @@ CardDatabase::CardDatabase(QObject *parent)
|
|||
loadingThread = new PictureLoadingThread(settingsCache->getPicsPath(), settingsCache->getPicDownload(), this);
|
||||
connect(loadingThread, SIGNAL(imageLoaded(CardInfo *, QImage)), this, SLOT(imageLoaded(CardInfo *, QImage)));
|
||||
loadingThread->start(QThread::LowPriority);
|
||||
loadingThread->waitForInit();
|
||||
|
||||
noCard = new CardInfo(this);
|
||||
noCard->loadPixmap(); // cache pixmap for card back
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include <QNetworkRequest>
|
||||
#include <QThread>
|
||||
#include <QMutex>
|
||||
#include <QWaitCondition>
|
||||
|
||||
class CardDatabase;
|
||||
class CardInfo;
|
||||
|
@ -87,13 +88,14 @@ private:
|
|||
QString picsPath;
|
||||
bool picDownload;
|
||||
PictureLoader *pictureLoader;
|
||||
mutable QMutex initMutex;
|
||||
QWaitCondition initWaitCondition;
|
||||
protected:
|
||||
void run();
|
||||
public:
|
||||
PictureLoadingThread(const QString &_picsPath, bool _picDownload, QObject *parent);
|
||||
~PictureLoadingThread();
|
||||
PictureLoader *getPictureLoader() const { QMutexLocker locker(&initMutex); return pictureLoader; }
|
||||
PictureLoader *getPictureLoader() const { return pictureLoader; }
|
||||
void waitForInit();
|
||||
signals:
|
||||
void imageLoaded(CardInfo *card, const QImage &image);
|
||||
};
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<picture_url>http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=!cardid!&type=card</picture_url>
|
||||
<picture_url_hq>http://mtgpics.chutography.com/!set!/!name!.full.jpg</picture_url_hq>
|
||||
<picture_url_st>http://mtgpics.chutography.com/!set!/!name!.jpg</picture_url_st>
|
||||
<set_url>http://gatherer.wizards.com/Pages/Search/Default.aspx?output=spoiler&method=text&set=["!longname!"]</set_url>
|
||||
<set_url>http://gatherer.wizards.com/Pages/Search/Default.aspx?output=spoiler&method=text&set=["!longname!"]&special=true</set_url>
|
||||
<set import="1">
|
||||
<name>ARB</name>
|
||||
<longname>Alara Reborn</longname>
|
||||
|
@ -24,6 +24,10 @@
|
|||
<name>AN</name>
|
||||
<longname>Arabian Nights</longname>
|
||||
</set>
|
||||
<set import="0">
|
||||
<name>AE</name>
|
||||
<longname>Archenemy</longname>
|
||||
</set>
|
||||
<set import="1">
|
||||
<name>BOK</name>
|
||||
<longname>Betrayers of Kamigawa</longname>
|
||||
|
@ -176,6 +180,10 @@
|
|||
<name>PLC</name>
|
||||
<longname>Planar Chaos</longname>
|
||||
</set>
|
||||
<set import="0">
|
||||
<name>PCH</name>
|
||||
<longname>Planechase</longname>
|
||||
</set>
|
||||
<set import="1">
|
||||
<name>PS</name>
|
||||
<longname>Planeshift</longname>
|
||||
|
@ -296,6 +304,10 @@
|
|||
<name>US</name>
|
||||
<longname>Urza's Saga</longname>
|
||||
</set>
|
||||
<set import="0">
|
||||
<name>VG</name>
|
||||
<longname>Vanguard</longname>
|
||||
</set>
|
||||
<set import="1">
|
||||
<name>VI</name>
|
||||
<longname>Visions</longname>
|
||||
|
|
Loading…
Reference in a new issue