[libdanbooru/danbooruservice] Fixup types and flags
This commit is contained in:
		
					parent
					
						
							
								324bacda52
							
						
					
				
			
			
				commit
				
					
						ce6a1cbcff
					
				
			
		
					 2 changed files with 17 additions and 16 deletions
				
			
		| 
						 | 
				
			
			@ -235,15 +235,15 @@ const QStringList DanbooruService::allowedRatings() const
 | 
			
		|||
{
 | 
			
		||||
    QStringList ratings;
 | 
			
		||||
 | 
			
		||||
    if (m_maxRating.testFlag(Safe)) {
 | 
			
		||||
    if (m_maxRating.testFlag(DanbooruPost::Safe)) {
 | 
			
		||||
        ratings.append("Safe");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (m_maxRating.testFlag(Questionable)) {
 | 
			
		||||
    if (m_maxRating.testFlag(DanbooruPost::Questionable)) {
 | 
			
		||||
        ratings.append("Questionable");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (m_maxRating.testFlag(Explicit)) {
 | 
			
		||||
    if (m_maxRating.testFlag(DanbooruPost::Explicit)) {
 | 
			
		||||
        ratings.append("Explicit");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -251,9 +251,9 @@ const QStringList DanbooruService::allowedRatings() const
 | 
			
		|||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void DanbooruService::setMaximumAllowedRating(const DanbooruPost::Rating& rating)
 | 
			
		||||
void DanbooruService::setMaximumAllowedRating(DanbooruPost::Rating rating)
 | 
			
		||||
{
 | 
			
		||||
    DanbooruPost::Rating flags;
 | 
			
		||||
    DanbooruPost::Ratings flags;
 | 
			
		||||
 | 
			
		||||
    switch (rating) {
 | 
			
		||||
    case DanbooruPost::Safe:
 | 
			
		||||
| 
						 | 
				
			
			@ -271,7 +271,7 @@ void DanbooruService::setMaximumAllowedRating(const DanbooruPost::Rating& rating
 | 
			
		|||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const Ratings DanbooruService::maximumAllowedRating() const
 | 
			
		||||
const DanbooruPost::Ratings DanbooruService::maximumAllowedRating() const
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
    return m_maxRating;
 | 
			
		||||
| 
						 | 
				
			
			@ -349,12 +349,13 @@ void DanbooruService::processPostList(KJob* job)
 | 
			
		|||
            continue;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        QPixmap* pix = new QPixmap();
 | 
			
		||||
        QPixmap pix;
 | 
			
		||||
        // QPixmap* pix = new QPixmap();
 | 
			
		||||
        bool result;
 | 
			
		||||
 | 
			
		||||
        if (m_cache) {
 | 
			
		||||
            result = m_cache->findPixmap(post->thumbnailUrl().url(),
 | 
			
		||||
                                         pix);
 | 
			
		||||
                                         &pix);
 | 
			
		||||
        } else {
 | 
			
		||||
            result = false;
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			@ -375,7 +376,6 @@ void DanbooruService::processPostList(KJob* job)
 | 
			
		|||
 | 
			
		||||
        } else {
 | 
			
		||||
 | 
			
		||||
            delete pix;
 | 
			
		||||
 | 
			
		||||
            StoredTransferJob* pixmapJob = KIO::storedGet(
 | 
			
		||||
                                               post->thumbnailUrl(),
 | 
			
		||||
| 
						 | 
				
			
			@ -544,7 +544,8 @@ void DanbooruService::downloadThumbnail(KJob* job)
 | 
			
		|||
    QVariant postData = job->property("danbooruPost");
 | 
			
		||||
 | 
			
		||||
    DanbooruPost* post = postData.value<DanbooruPost*>();
 | 
			
		||||
    QPixmap* pix = new QPixmap();
 | 
			
		||||
    QPixmap pix;
 | 
			
		||||
    // QPixmap* pix = new QPixmap();
 | 
			
		||||
 | 
			
		||||
    StoredTransferJob* jobResult = qobject_cast<StoredTransferJob*>(job);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -554,7 +555,7 @@ void DanbooruService::downloadThumbnail(KJob* job)
 | 
			
		|||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    bool ok = pix->loadFromData(jobResult->data());
 | 
			
		||||
    bool ok = pix.loadFromData(jobResult->data());
 | 
			
		||||
 | 
			
		||||
    if (!ok) {
 | 
			
		||||
        Q_EMIT(downloadError(QString("Pixmap data could not be loaded")));
 | 
			
		||||
| 
						 | 
				
			
			@ -565,7 +566,7 @@ void DanbooruService::downloadThumbnail(KJob* job)
 | 
			
		|||
 | 
			
		||||
    if (m_cache) {
 | 
			
		||||
        //qDebug() << "Inserting item in cache";
 | 
			
		||||
        m_cache->insertPixmap(post->thumbnailUrl().url(), *pix);
 | 
			
		||||
        m_cache->insertPixmap(post->thumbnailUrl().url(), pix);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    m_currentPosts--; // One less post to do
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -42,6 +42,7 @@
 | 
			
		|||
 | 
			
		||||
#include <QUrl>
 | 
			
		||||
#include <kio/storedtransferjob.h>
 | 
			
		||||
#include <KImageCache>
 | 
			
		||||
 | 
			
		||||
// Own
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -52,7 +53,6 @@
 | 
			
		|||
class QPixmap;
 | 
			
		||||
class QUrl;
 | 
			
		||||
class KJob;
 | 
			
		||||
class KImageCache;
 | 
			
		||||
 | 
			
		||||
using Danbooru::DanbooruTag;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -94,7 +94,7 @@ namespace Danbooru {
 | 
			
		|||
        QString m_username;
 | 
			
		||||
        QString m_password;
 | 
			
		||||
        QSet<QString> m_blacklist;
 | 
			
		||||
        Danbooru::DanbooruPost::Rating m_maxRating;
 | 
			
		||||
        DanbooruPost::Ratings m_maxRating;
 | 
			
		||||
 | 
			
		||||
        unsigned int m_currentPosts; // To tell when to quit
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -182,7 +182,7 @@ namespace Danbooru {
 | 
			
		|||
        /**
 | 
			
		||||
         * @return The maximum allowed rating for a post.
 | 
			
		||||
         **/
 | 
			
		||||
        const Ratings maximumAllowedRating() const;
 | 
			
		||||
        const DanbooruPost::Ratings maximumAllowedRating() const;
 | 
			
		||||
 | 
			
		||||
        /**
 | 
			
		||||
         * @return The currently blacklisted tags.
 | 
			
		||||
| 
						 | 
				
			
			@ -198,7 +198,7 @@ namespace Danbooru {
 | 
			
		|||
         * downloaded.
 | 
			
		||||
         *
 | 
			
		||||
         **/
 | 
			
		||||
        void setMaximumAllowedRating(const Ratings& rating);
 | 
			
		||||
        void setMaximumAllowedRating(DanbooruPost::Rating rating);
 | 
			
		||||
 | 
			
		||||
        /**
 | 
			
		||||
         * @brief Set the tag blacklist.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue