Initial experimental work for multiple Danbooru APIs
This commit is contained in:
		
					parent
					
						
							
								18e49e8388
							
						
					
				
			
			
				commit
				
					
						615e594e39
					
				
			
		
					 2 changed files with 134 additions and 0 deletions
				
			
		
							
								
								
									
										1
									
								
								src/libdanbooru/servicebase.cpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								src/libdanbooru/servicebase.cpp
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1 @@
 | 
			
		|||
 | 
			
		||||
							
								
								
									
										133
									
								
								src/libdanbooru/servicebase.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										133
									
								
								src/libdanbooru/servicebase.h
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,133 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright 2015 Luca Beltrame <lbeltrame@kde.org>
 | 
			
		||||
 *
 | 
			
		||||
 * This file is part of Danbooru Client.
 | 
			
		||||
 *
 | 
			
		||||
 * Danbooru Client is free software: you can redistribute it and/or modify
 | 
			
		||||
 * it under the terms of the GNU General Public License as published by
 | 
			
		||||
 * the Free Software Foundation, either version 3 of the License, or
 | 
			
		||||
 * (at your option) any later version.
 | 
			
		||||
 *
 | 
			
		||||
 * Danbooru Client is distributed in the hope that it will be useful,
 | 
			
		||||
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
			
		||||
 * GNU General Public License for more details.
 | 
			
		||||
 *
 | 
			
		||||
 * You should have received a copy of the GNU General Public License
 | 
			
		||||
 * along with Danbooru Client. If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#ifndef DANBOORU_SERVICEBASE_H
 | 
			
		||||
#define DANBOORU_SERVICEBASE_H
 | 
			
		||||
 | 
			
		||||
// Qt
 | 
			
		||||
 | 
			
		||||
#include <QObject>
 | 
			
		||||
#include <QString>
 | 
			
		||||
#include <QStringList>
 | 
			
		||||
#include <QSet>
 | 
			
		||||
 | 
			
		||||
// KF5
 | 
			
		||||
 | 
			
		||||
#include <KImageCache>
 | 
			
		||||
 | 
			
		||||
// Own
 | 
			
		||||
 | 
			
		||||
#include "danbooru.h"
 | 
			
		||||
#include "danboorupost.h"
 | 
			
		||||
#include "danboorutag.h"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
namespace Danbooru
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
class DanbooruServiceBase: public QObject
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
Q_OBJECT
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
 | 
			
		||||
    explicit DanbooruServiceBase();
 | 
			
		||||
    ~DanbooruServiceBase();
 | 
			
		||||
 | 
			
		||||
    const QStringList allowedRatings() const;
 | 
			
		||||
    const int apiVersion() const;
 | 
			
		||||
    const QSet<QString> blacklist() const;
 | 
			
		||||
    int currentPage() const;
 | 
			
		||||
 | 
			
		||||
    virtual void getPostList() = 0;
 | 
			
		||||
    virtual void getPoolList() = 0;
 | 
			
		||||
    virtual void getPool(int poolId, int page = 1) = 0;
 | 
			
		||||
    virtual void getTagList(int limit = 10, QString name = "") = 0;
 | 
			
		||||
    virtual void getRelatedTags(const QStringList &tags,
 | 
			
		||||
                                DanbooruTag::TagType tagType = DanbooruTag::General) = 0;
 | 
			
		||||
 | 
			
		||||
    const DanbooruPost::Ratings maximumAllowedRating() const;
 | 
			
		||||
    Q_INVOKABLE void nextPostPage();
 | 
			
		||||
    Q_INVOKABLE void nextPoolPage();
 | 
			
		||||
    QStringList postTags() const;
 | 
			
		||||
    void reset();
 | 
			
		||||
 | 
			
		||||
    void setBlacklist(const QStringList &blacklist);
 | 
			
		||||
    void setBoardUrl(const QUrl &url);
 | 
			
		||||
    void setCurrentPage(int page);
 | 
			
		||||
    void setImageCache(KImageCache *cache);
 | 
			
		||||
    void setMaximumAllowedRating(DanbooruPost::Rating rating);
 | 
			
		||||
    void setMaxPosts(int number);
 | 
			
		||||
    void setPassword(const QString &password);
 | 
			
		||||
    void setPostTags(const QStringList &tags);
 | 
			
		||||
    void setUserName(const QString &username);
 | 
			
		||||
 | 
			
		||||
Q_SIGNALS:
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Emitted when there are no more posts to download.
 | 
			
		||||
     *
 | 
			
		||||
     * Connect to this signal to know when downloading is complete.
 | 
			
		||||
     *
 | 
			
		||||
     **/
 | 
			
		||||
    void postDownloadFinished();
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Emitted when there are no more pools to download.
 | 
			
		||||
     **/
 | 
			
		||||
    void poolDownloadFinished();
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Emitted when a download error occurred.
 | 
			
		||||
     *
 | 
			
		||||
     * The parameter contains the error string.
 | 
			
		||||
     *
 | 
			
		||||
     **/
 | 
			
		||||
    void downloadError(QString error);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Emitted when a post has been downloaded.
 | 
			
		||||
     *
 | 
			
		||||
     * The parameter contains a pointer to the post that has been
 | 
			
		||||
     * downloaded.
 | 
			
		||||
     **/
 | 
			
		||||
    void postDownloaded(Danbooru::DanbooruPost *post);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Emitted when a pool has been downloaded.
 | 
			
		||||
     *
 | 
			
		||||
     * The parameter contains a pointer to the pool that has been
 | 
			
		||||
     * downloaded.
 | 
			
		||||
     **/
 | 
			
		||||
    void poolDownloaded(Danbooru::DanbooruPool *pool);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Emitted when a tag has been downloaded.
 | 
			
		||||
     *
 | 
			
		||||
     * The parameter contains a pointer to the tag that has been
 | 
			
		||||
     * downloaded.
 | 
			
		||||
     **/
 | 
			
		||||
    void tagDownloaded(Danbooru::DanbooruTag *tag);
 | 
			
		||||
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue