Merge pull request #280 from pliu037/remove-.full-req
Support images without .full suffix
This commit is contained in:
commit
b32aeb2211
2 changed files with 17 additions and 17 deletions
|
@ -76,8 +76,8 @@ void SetList::sortByKey()
|
||||||
qSort(begin(), end(), CompareFunctor());
|
qSort(begin(), end(), CompareFunctor());
|
||||||
}
|
}
|
||||||
|
|
||||||
PictureToLoad::PictureToLoad(CardInfo *_card, bool _stripped, bool _hq)
|
PictureToLoad::PictureToLoad(CardInfo *_card, bool _hq)
|
||||||
: card(_card), stripped(_stripped), setIndex(0), hq(_hq)
|
: card(_card), setIndex(0), hq(_hq)
|
||||||
{
|
{
|
||||||
if (card) {
|
if (card) {
|
||||||
sortedSets = card->getSets();
|
sortedSets = card->getSets();
|
||||||
|
@ -135,14 +135,14 @@ void PictureLoader::processLoadQueue()
|
||||||
mutex.unlock();
|
mutex.unlock();
|
||||||
|
|
||||||
//The list of paths to the folders in which to search for images
|
//The list of paths to the folders in which to search for images
|
||||||
QList<QString> picsPaths = QList<QString>() << _picsPath + "/CUSTOM/" + ptl.getCard()->getCorrectedName() + ".full";
|
QList<QString> picsPaths = QList<QString>() << _picsPath + "/CUSTOM/" + ptl.getCard()->getCorrectedName();
|
||||||
|
|
||||||
|
|
||||||
QString setName=ptl.getSetName();
|
QString setName=ptl.getSetName();
|
||||||
if(!setName.isEmpty())
|
if(!setName.isEmpty())
|
||||||
{
|
{
|
||||||
picsPaths << _picsPath + "/" + setName + "/" + ptl.getCard()->getCorrectedName() + ".full"
|
picsPaths << _picsPath + "/" + setName + "/" + ptl.getCard()->getCorrectedName()
|
||||||
<< _picsPath + "/downloadedPics/" + setName + "/" + ptl.getCard()->getCorrectedName() + ".full";
|
<< _picsPath + "/downloadedPics/" + setName + "/" + ptl.getCard()->getCorrectedName();
|
||||||
}
|
}
|
||||||
|
|
||||||
QImage image;
|
QImage image;
|
||||||
|
@ -153,6 +153,12 @@ void PictureLoader::processLoadQueue()
|
||||||
//Iterates through the list of paths, searching for images with the desired name with any QImageReader-supported extension
|
//Iterates through the list of paths, searching for images with the desired name with any QImageReader-supported extension
|
||||||
for (int i = 0; i < picsPaths.length() && !found; i ++) {
|
for (int i = 0; i < picsPaths.length() && !found; i ++) {
|
||||||
imgReader.setFileName(picsPaths.at(i));
|
imgReader.setFileName(picsPaths.at(i));
|
||||||
|
if (imgReader.read(&image)) {
|
||||||
|
emit imageLoaded(ptl.getCard(), image);
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
imgReader.setFileName(picsPaths.at(i) + ".full");
|
||||||
if (imgReader.read(&image)) {
|
if (imgReader.read(&image)) {
|
||||||
emit imageLoaded(ptl.getCard(), image);
|
emit imageLoaded(ptl.getCard(), image);
|
||||||
found = true;
|
found = true;
|
||||||
|
@ -274,11 +280,7 @@ void PictureLoader::picDownloadFinished(QNetworkReply *reply)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString suffix;
|
QFile newPic(picsPath + "/downloadedPics/" + setName + "/" + cardBeingDownloaded.getCard()->getCorrectedName() + extension);
|
||||||
if (!cardBeingDownloaded.getStripped())
|
|
||||||
suffix = ".full";
|
|
||||||
|
|
||||||
QFile newPic(picsPath + "/downloadedPics/" + setName + "/" + cardBeingDownloaded.getCard()->getCorrectedName() + suffix + extension);
|
|
||||||
if (!newPic.open(QIODevice::WriteOnly))
|
if (!newPic.open(QIODevice::WriteOnly))
|
||||||
return;
|
return;
|
||||||
newPic.write(picData);
|
newPic.write(picData);
|
||||||
|
@ -306,11 +308,11 @@ void PictureLoader::picDownloadFinished(QNetworkReply *reply)
|
||||||
startNextPicDownload();
|
startNextPicDownload();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PictureLoader::loadImage(CardInfo *card, bool stripped)
|
void PictureLoader::loadImage(CardInfo *card)
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&mutex);
|
QMutexLocker locker(&mutex);
|
||||||
|
|
||||||
loadQueue.append(PictureToLoad(card, stripped));
|
loadQueue.append(PictureToLoad(card));
|
||||||
emit startLoadQueue();
|
emit startLoadQueue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -936,7 +938,7 @@ void CardDatabase::cacheCardPixmaps(const QStringList &cardNames)
|
||||||
|
|
||||||
void CardDatabase::loadImage(CardInfo *card)
|
void CardDatabase::loadImage(CardInfo *card)
|
||||||
{
|
{
|
||||||
pictureLoader->loadImage(card, false);
|
pictureLoader->loadImage(card);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CardDatabase::imageLoaded(CardInfo *card, QImage image)
|
void CardDatabase::imageLoaded(CardInfo *card, QImage image)
|
||||||
|
|
|
@ -47,14 +47,12 @@ public:
|
||||||
class PictureToLoad {
|
class PictureToLoad {
|
||||||
private:
|
private:
|
||||||
CardInfo *card;
|
CardInfo *card;
|
||||||
bool stripped;
|
|
||||||
SetList sortedSets;
|
SetList sortedSets;
|
||||||
int setIndex;
|
int setIndex;
|
||||||
bool hq;
|
bool hq;
|
||||||
public:
|
public:
|
||||||
PictureToLoad(CardInfo *_card = 0, bool _stripped = false, bool _hq = true);
|
PictureToLoad(CardInfo *_card = 0, bool _hq = true);
|
||||||
CardInfo *getCard() const { return card; }
|
CardInfo *getCard() const { return card; }
|
||||||
bool getStripped() const { return stripped; }
|
|
||||||
QString getSetName() const;
|
QString getSetName() const;
|
||||||
bool nextSet();
|
bool nextSet();
|
||||||
bool getHq() const { return hq; }
|
bool getHq() const { return hq; }
|
||||||
|
@ -79,7 +77,7 @@ public:
|
||||||
void setPicsPath(const QString &path);
|
void setPicsPath(const QString &path);
|
||||||
void setPicDownload(bool _picDownload);
|
void setPicDownload(bool _picDownload);
|
||||||
void setPicDownloadHq(bool _picDownloadHq);
|
void setPicDownloadHq(bool _picDownloadHq);
|
||||||
void loadImage(CardInfo *card, bool stripped);
|
void loadImage(CardInfo *card);
|
||||||
private slots:
|
private slots:
|
||||||
void picDownloadFinished(QNetworkReply *reply);
|
void picDownloadFinished(QNetworkReply *reply);
|
||||||
public slots:
|
public slots:
|
||||||
|
|
Loading…
Reference in a new issue