Run astyle-kdelibs on the source
This commit is contained in:
		
					parent
					
						
							
								4b85d63d68
							
						
					
				
			
			
				commit
				
					
						39aac8c95b
					
				
			
		
					 22 changed files with 1227 additions and 1264 deletions
				
			
		| 
						 | 
					@ -17,8 +17,6 @@
 | 
				
			||||||
 * along with Danbooru Client. If not, see <http://www.gnu.org/licenses/>.
 | 
					 * along with Danbooru Client. If not, see <http://www.gnu.org/licenses/>.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "danbooruclientview.h"
 | 
					#include "danbooruclientview.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Own
 | 
					// Own
 | 
				
			||||||
| 
						 | 
					@ -35,14 +33,15 @@
 | 
				
			||||||
#include <KRun>
 | 
					#include <KRun>
 | 
				
			||||||
#include <KFileDialog>
 | 
					#include <KFileDialog>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Danbooru {
 | 
					namespace Danbooru
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    DanbooruClientView::DanbooruClientView(QWidget * parent): QWidget(parent),
 | 
					DanbooruClientView::DanbooruClientView(QWidget *parent): QWidget(parent),
 | 
				
			||||||
    m_model(new DanbooruPostModel(this)),
 | 
					    m_model(new DanbooruPostModel(this)),
 | 
				
			||||||
    m_delegate(0),
 | 
					    m_delegate(0),
 | 
				
			||||||
    m_service(0),
 | 
					    m_service(0),
 | 
				
			||||||
    m_timer(0)
 | 
					    m_timer(0)
 | 
				
			||||||
    {
 | 
					{
 | 
				
			||||||
    setupUi(this);
 | 
					    setupUi(this);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    m_delegate = new DanbooruPostDelegate(m_listView);
 | 
					    m_delegate = new DanbooruPostDelegate(m_listView);
 | 
				
			||||||
| 
						 | 
					@ -51,7 +50,7 @@ namespace Danbooru {
 | 
				
			||||||
    m_listView->setResizeMode(QListView::Adjust);
 | 
					    m_listView->setResizeMode(QListView::Adjust);
 | 
				
			||||||
    m_listView->setWrapping(true);
 | 
					    m_listView->setWrapping(true);
 | 
				
			||||||
    m_listView->setViewMode(QListView::IconMode);
 | 
					    m_listView->setViewMode(QListView::IconMode);
 | 
				
			||||||
        m_listView->setGridSize(QSize(256,256));
 | 
					    m_listView->setGridSize(QSize(256, 256));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    m_listView->setModel(m_model);
 | 
					    m_listView->setModel(m_model);
 | 
				
			||||||
    m_listView->setItemDelegate(m_delegate);
 | 
					    m_listView->setItemDelegate(m_delegate);
 | 
				
			||||||
| 
						 | 
					@ -60,29 +59,27 @@ namespace Danbooru {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    connect(m_delegate, &DanbooruPostDelegate::postDownloadRequested, this, &DanbooruClientView::slotHandleDownload);
 | 
					    connect(m_delegate, &DanbooruPostDelegate::postDownloadRequested, this, &DanbooruClientView::slotHandleDownload);
 | 
				
			||||||
    connect(m_delegate, &DanbooruPostDelegate::postViewRequested, this, &DanbooruClientView::slotHandleView);
 | 
					    connect(m_delegate, &DanbooruPostDelegate::postViewRequested, this, &DanbooruClientView::slotHandleView);
 | 
				
			||||||
//         connect(m_listView, SIGNAL(clicked(const QModelIndex&)), parent(),
 | 
					//         connect(m_listView, SIGNAL(clicked(QModelIndex)), parent(),
 | 
				
			||||||
//             SLOT(displayInfo(const QModelIndex&));
 | 
					//             SLOT(displayInfo(QModelIndex));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					DanbooruClientView::~DanbooruClientView()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    DanbooruClientView::~DanbooruClientView()
 | 
					}
 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					void DanbooruClientView::slotHandleDownload(QUrl url)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
    void DanbooruClientView::slotHandleDownload(QUrl url)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
    // TODO
 | 
					    // TODO
 | 
				
			||||||
    Q_UNUSED(url)
 | 
					    Q_UNUSED(url)
 | 
				
			||||||
    }
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void DanbooruClientView::slotHandleView(QUrl url)
 | 
					void DanbooruClientView::slotHandleView(QUrl url)
 | 
				
			||||||
    {
 | 
					{
 | 
				
			||||||
        KRun* runViewer = new KRun(url, this /*window*/, true /*showProgressInfo*/,
 | 
					    KRun *runViewer = new KRun(url, this /*window*/, true /*showProgressInfo*/,
 | 
				
			||||||
                               "" /*asn*/);
 | 
					                               "" /*asn*/);
 | 
				
			||||||
    runViewer->setAutoDelete(true);
 | 
					    runViewer->setAutoDelete(true);
 | 
				
			||||||
    }
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
} // namespace Danbooru
 | 
					} // namespace Danbooru
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -28,13 +28,14 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class QTimer;
 | 
					class QTimer;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Danbooru {
 | 
					namespace Danbooru
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    class DanbooruPostModel;
 | 
					class DanbooruPostModel;
 | 
				
			||||||
    class DanbooruPostDelegate;
 | 
					class DanbooruPostDelegate;
 | 
				
			||||||
    class DanbooruService;
 | 
					class DanbooruService;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					/**
 | 
				
			||||||
 * This is the main view class for danbooru_client.  Most of the non-menu,
 | 
					 * This is the main view class for danbooru_client.  Most of the non-menu,
 | 
				
			||||||
 * non-toolbar, and non-statusbar (e.g., non frame) GUI code should go
 | 
					 * non-toolbar, and non-statusbar (e.g., non frame) GUI code should go
 | 
				
			||||||
 * here.
 | 
					 * here.
 | 
				
			||||||
| 
						 | 
					@ -44,31 +45,31 @@ namespace Danbooru {
 | 
				
			||||||
 * @version %{VERSION}
 | 
					 * @version %{VERSION}
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    class DanbooruClientView : public QWidget, public Ui::DanbooruClientView
 | 
					class DanbooruClientView : public QWidget, public Ui::DanbooruClientView
 | 
				
			||||||
    {
 | 
					{
 | 
				
			||||||
    Q_OBJECT
 | 
					    Q_OBJECT
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public:
 | 
					public:
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Default constructor
 | 
					     * Default constructor
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
        DanbooruClientView(QWidget *parent=0);
 | 
					    DanbooruClientView(QWidget *parent = 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Destructor
 | 
					     * Destructor
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    virtual ~DanbooruClientView();
 | 
					    virtual ~DanbooruClientView();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private Q_SLOTS:
 | 
					private Q_SLOTS:
 | 
				
			||||||
    void slotHandleDownload(QUrl);
 | 
					    void slotHandleDownload(QUrl);
 | 
				
			||||||
    void slotHandleView(QUrl);
 | 
					    void slotHandleView(QUrl);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private:
 | 
					private:
 | 
				
			||||||
        DanbooruPostModel* m_model;
 | 
					    DanbooruPostModel *m_model;
 | 
				
			||||||
        DanbooruPostDelegate* m_delegate;
 | 
					    DanbooruPostDelegate *m_delegate;
 | 
				
			||||||
        DanbooruService* m_service;
 | 
					    DanbooruService *m_service;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        QTimer* m_timer;
 | 
					    QTimer *m_timer;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -27,10 +27,10 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <KWallet>
 | 
					#include <KWallet>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
using KWallet::Wallet;
 | 
					using KWallet::Wallet;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Danbooru {
 | 
					namespace Danbooru
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const QMap< QUrl, QString > initBoardSalts()
 | 
					const QMap< QUrl, QString > initBoardSalts()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -52,7 +52,7 @@ const QMap< QUrl, QString > initBoardSalts()
 | 
				
			||||||
const QMap<QUrl, QString> DanbooruConnectWidget::boardSalts = initBoardSalts();
 | 
					const QMap<QUrl, QString> DanbooruConnectWidget::boardSalts = initBoardSalts();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
DanbooruConnectWidget::DanbooruConnectWidget(QVector< QUrl > urlList,
 | 
					DanbooruConnectWidget::DanbooruConnectWidget(QVector< QUrl > urlList,
 | 
				
			||||||
                                                       QWidget* parent):
 | 
					        QWidget *parent):
 | 
				
			||||||
    QWidget(parent),
 | 
					    QWidget(parent),
 | 
				
			||||||
    m_wallet(0)
 | 
					    m_wallet(0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -74,7 +74,7 @@ DanbooruConnectWidget::DanbooruConnectWidget(QVector< QUrl > urlList,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    danbooruUrlComboBox->clear();
 | 
					    danbooruUrlComboBox->clear();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for (auto item: urlList) {
 | 
					    for (auto item : urlList) {
 | 
				
			||||||
        danbooruUrlComboBox->insertUrl(urlList.indexOf(item), item);
 | 
					        danbooruUrlComboBox->insertUrl(urlList.indexOf(item), item);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -122,7 +122,6 @@ void DanbooruConnectWidget::getWalletData()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (m_wallet->hasEntry(key)) {
 | 
					    if (m_wallet->hasEntry(key)) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
        if (m_wallet->readMap(key, valueMap) != 0) {
 | 
					        if (m_wallet->readMap(key, valueMap) != 0) {
 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
| 
						 | 
					@ -133,7 +132,6 @@ void DanbooruConnectWidget::getWalletData()
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
void DanbooruConnectWidget::toggleLineEdits(int state)
 | 
					void DanbooruConnectWidget::toggleLineEdits(int state)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    if (state == Qt::Unchecked) {
 | 
					    if (state == Qt::Unchecked) {
 | 
				
			||||||
| 
						 | 
					@ -145,7 +143,6 @@ void DanbooruConnectWidget::toggleLineEdits(int state)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
void DanbooruConnectWidget::emitRejected()
 | 
					void DanbooruConnectWidget::emitRejected()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    Q_EMIT rejected();
 | 
					    Q_EMIT rejected();
 | 
				
			||||||
| 
						 | 
					@ -161,7 +158,6 @@ QString DanbooruConnectWidget::username() const
 | 
				
			||||||
    return m_username;
 | 
					    return m_username;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
QString DanbooruConnectWidget::password() const
 | 
					QString DanbooruConnectWidget::password() const
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    return m_password;
 | 
					    return m_password;
 | 
				
			||||||
| 
						 | 
					@ -178,7 +174,7 @@ void DanbooruConnectWidget::accept()
 | 
				
			||||||
    if (!m_username.isEmpty() && !m_password.isEmpty()) {
 | 
					    if (!m_username.isEmpty() && !m_password.isEmpty()) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (m_wallet && !m_wallet->hasEntry(m_boardUrl.url())) {
 | 
					        if (m_wallet && !m_wallet->hasEntry(m_boardUrl.url())) {
 | 
				
			||||||
            QMap<QString,QString> dataMap;
 | 
					            QMap<QString, QString> dataMap;
 | 
				
			||||||
            dataMap.insert(QLatin1String("username"), m_username);
 | 
					            dataMap.insert(QLatin1String("username"), m_username);
 | 
				
			||||||
            dataMap.insert(QLatin1String("password"), m_password);
 | 
					            dataMap.insert(QLatin1String("password"), m_password);
 | 
				
			||||||
            m_wallet->writeMap(m_boardUrl.url(), dataMap);
 | 
					            m_wallet->writeMap(m_boardUrl.url(), dataMap);
 | 
				
			||||||
| 
						 | 
					@ -190,12 +186,11 @@ void DanbooruConnectWidget::accept()
 | 
				
			||||||
                                                 ).toHex();
 | 
					                                                 ).toHex();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    DanbooruService* service = new DanbooruService(m_boardUrl, m_username,
 | 
					    DanbooruService *service = new DanbooruService(m_boardUrl, m_username,
 | 
				
			||||||
            hashedPassword);
 | 
					            hashedPassword);
 | 
				
			||||||
    Q_EMIT(connectionEstablished(service));
 | 
					    Q_EMIT(connectionEstablished(service));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    hide();
 | 
					    hide();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
}; // namespace Danbooru
 | 
					}; // namespace Danbooru
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -28,46 +28,48 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <QUrl>
 | 
					#include <QUrl>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace KWallet {
 | 
					namespace KWallet
 | 
				
			||||||
    class Wallet;
 | 
					{
 | 
				
			||||||
 | 
					class Wallet;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Danbooru {
 | 
					namespace Danbooru
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    class DanbooruService;
 | 
					class DanbooruService;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const QMap< QUrl, QString > initBoardSalts();
 | 
					const QMap< QUrl, QString > initBoardSalts();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    class DanbooruConnectWidget: public QWidget, public Ui::DanbooruConnectWidget {
 | 
					class DanbooruConnectWidget: public QWidget, public Ui::DanbooruConnectWidget
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
    Q_OBJECT
 | 
					    Q_OBJECT
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public:
 | 
					public:
 | 
				
			||||||
    explicit DanbooruConnectWidget(QVector<QUrl> urlList,
 | 
					    explicit DanbooruConnectWidget(QVector<QUrl> urlList,
 | 
				
			||||||
                                       QWidget* parent = 0);
 | 
					                                   QWidget *parent = 0);
 | 
				
			||||||
    ~DanbooruConnectWidget();
 | 
					    ~DanbooruConnectWidget();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    QString username() const;
 | 
					    QString username() const;
 | 
				
			||||||
    QString password() const;
 | 
					    QString password() const;
 | 
				
			||||||
    QUrl boardUrl() const;
 | 
					    QUrl boardUrl() const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private:
 | 
					private:
 | 
				
			||||||
    QUrl  m_boardUrl;
 | 
					    QUrl  m_boardUrl;
 | 
				
			||||||
    QString m_username;
 | 
					    QString m_username;
 | 
				
			||||||
    QString m_password;
 | 
					    QString m_password;
 | 
				
			||||||
        KWallet::Wallet* m_wallet;
 | 
					    KWallet::Wallet *m_wallet;
 | 
				
			||||||
    static const QMap<QUrl, QString> boardSalts;
 | 
					    static const QMap<QUrl, QString> boardSalts;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Q_SIGNALS:
 | 
					Q_SIGNALS:
 | 
				
			||||||
        void connectionEstablished(DanbooruService* service);
 | 
					    void connectionEstablished(DanbooruService *service);
 | 
				
			||||||
    void rejected();
 | 
					    void rejected();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					private Q_SLOTS:
 | 
				
			||||||
    private Q_SLOTS:
 | 
					 | 
				
			||||||
    void checkWallet(bool);
 | 
					    void checkWallet(bool);
 | 
				
			||||||
    void getWalletData();
 | 
					    void getWalletData();
 | 
				
			||||||
    void toggleLineEdits(int state);
 | 
					    void toggleLineEdits(int state);
 | 
				
			||||||
    void emitRejected();
 | 
					    void emitRejected();
 | 
				
			||||||
    void accept();
 | 
					    void accept();
 | 
				
			||||||
    };
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
} // namespace Danbooru
 | 
					} // namespace Danbooru
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -32,8 +32,8 @@
 | 
				
			||||||
 * @file danbooru.h
 | 
					 * @file danbooru.h
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 **/
 | 
					 **/
 | 
				
			||||||
namespace Danbooru {
 | 
					namespace Danbooru
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}; // namespace Danbooru
 | 
					}; // namespace Danbooru
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -22,9 +22,10 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "danboorupool.h"
 | 
					#include "danboorupool.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Danbooru {
 | 
					namespace Danbooru
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
DanbooruPool::DanbooruPool(const QVariantMap& postData, QObject* parent):
 | 
					DanbooruPool::DanbooruPool(const QVariantMap &postData, QObject *parent):
 | 
				
			||||||
    QObject(parent), m_posts(QList<int>())
 | 
					    QObject(parent), m_posts(QList<int>())
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    m_id = postData.value("id").toInt();
 | 
					    m_id = postData.value("id").toInt();
 | 
				
			||||||
| 
						 | 
					@ -68,13 +69,12 @@ void DanbooruPool::addPosts(QList< int > posts)
 | 
				
			||||||
    m_posts.append(posts);
 | 
					    m_posts.append(posts);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void DanbooruPool::addPosts(const QStringList& posts)
 | 
					void DanbooruPool::addPosts(const QStringList &posts)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for (auto post: posts) {
 | 
					    for (auto post : posts) {
 | 
				
			||||||
        m_posts.append(post.toInt());
 | 
					        m_posts.append(post.toInt());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
} // namespace Danbooru
 | 
					} // namespace Danbooru
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -37,9 +37,10 @@
 | 
				
			||||||
#include <QtCore/QStringList>
 | 
					#include <QtCore/QStringList>
 | 
				
			||||||
#include <QtXml/QXmlStreamAttributes>
 | 
					#include <QtXml/QXmlStreamAttributes>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Danbooru {
 | 
					namespace Danbooru
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					/**
 | 
				
			||||||
 * @brief Class representing a Danbooru pool.
 | 
					 * @brief Class representing a Danbooru pool.
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * Pools are organized groups of images, often by a common theme, for
 | 
					 * Pools are organized groups of images, often by a common theme, for
 | 
				
			||||||
| 
						 | 
					@ -50,19 +51,19 @@ namespace Danbooru {
 | 
				
			||||||
 * @author Luca Beltrame (lbeltrame@kde.org)
 | 
					 * @author Luca Beltrame (lbeltrame@kde.org)
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * **/
 | 
					 * **/
 | 
				
			||||||
    class DanbooruPool : public QObject
 | 
					class DanbooruPool : public QObject
 | 
				
			||||||
    {
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Q_OBJECT
 | 
					    Q_OBJECT
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private:
 | 
					private:
 | 
				
			||||||
    int m_id;
 | 
					    int m_id;
 | 
				
			||||||
    int m_postCount;
 | 
					    int m_postCount;
 | 
				
			||||||
    QString m_name;
 | 
					    QString m_name;
 | 
				
			||||||
    QString m_description;
 | 
					    QString m_description;
 | 
				
			||||||
    QList<int> m_posts;
 | 
					    QList<int> m_posts;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public:
 | 
					public:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * @brief Construct a Danbooru pool from a QVariantMap.
 | 
					     * @brief Construct a Danbooru pool from a QVariantMap.
 | 
				
			||||||
| 
						 | 
					@ -76,7 +77,7 @@ namespace Danbooru {
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
     **/
 | 
					     **/
 | 
				
			||||||
        DanbooruPool(const QVariantMap& postData, QObject* parent = 0);
 | 
					    DanbooruPool(const QVariantMap &postData, QObject *parent = 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * @brief Construct a Danbooru pool from a QVariantMap.
 | 
					     * @brief Construct a Danbooru pool from a QVariantMap.
 | 
				
			||||||
| 
						 | 
					@ -90,7 +91,7 @@ namespace Danbooru {
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
     **/
 | 
					     **/
 | 
				
			||||||
        DanbooruPool(const QXmlStreamAttributes& postData, QObject* parent=0);
 | 
					    DanbooruPool(const QXmlStreamAttributes &postData, QObject *parent = 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    int id() const;
 | 
					    int id() const;
 | 
				
			||||||
    int postCount() const;
 | 
					    int postCount() const;
 | 
				
			||||||
| 
						 | 
					@ -100,11 +101,11 @@ namespace Danbooru {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void addPost(int post);
 | 
					    void addPost(int post);
 | 
				
			||||||
    void addPosts(QList<int> posts);
 | 
					    void addPosts(QList<int> posts);
 | 
				
			||||||
        void addPosts(const QStringList& posts);
 | 
					    void addPosts(const QStringList &posts);
 | 
				
			||||||
    };
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}; // namespace Danbooru
 | 
					}; // namespace Danbooru
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Q_DECLARE_METATYPE(Danbooru::DanbooruPool*)
 | 
					Q_DECLARE_METATYPE(Danbooru::DanbooruPool *)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif // DANBOORUPOOL_H
 | 
					#endif // DANBOORUPOOL_H
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -33,14 +33,13 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "danboorupost.h"
 | 
					#include "danboorupost.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
namespace Danbooru
 | 
					namespace Danbooru
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const QMap<QString, DanbooruPost::Rating> DanbooruPost::RATING_MAP = initRatingMap();
 | 
					const QMap<QString, DanbooruPost::Rating> DanbooruPost::RATING_MAP = initRatingMap();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
DanbooruPost::DanbooruPost(QVariantMap postData, QPixmap pixmap,
 | 
					DanbooruPost::DanbooruPost(QVariantMap postData, QPixmap pixmap,
 | 
				
			||||||
                           QObject* parent):
 | 
					                           QObject *parent):
 | 
				
			||||||
    QObject(parent),
 | 
					    QObject(parent),
 | 
				
			||||||
    m_pixmap(pixmap)
 | 
					    m_pixmap(pixmap)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -57,7 +56,7 @@ DanbooruPost::DanbooruPost(QVariantMap postData, QPixmap pixmap,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
DanbooruPost::DanbooruPost(QXmlStreamAttributes& postData, QPixmap pixmap, QObject* parent):
 | 
					DanbooruPost::DanbooruPost(QXmlStreamAttributes &postData, QPixmap pixmap, QObject *parent):
 | 
				
			||||||
    QObject(parent),
 | 
					    QObject(parent),
 | 
				
			||||||
    m_pixmap(pixmap)
 | 
					    m_pixmap(pixmap)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -73,12 +72,10 @@ DanbooruPost::DanbooruPost(QXmlStreamAttributes& postData, QPixmap pixmap, QObje
 | 
				
			||||||
    m_rating = RATING_MAP.value(postData.value("rating").toString());
 | 
					    m_rating = RATING_MAP.value(postData.value("rating").toString());
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
DanbooruPost::~DanbooruPost()
 | 
					DanbooruPost::~DanbooruPost()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
const QMap< QString, DanbooruPost::Rating > DanbooruPost::initRatingMap()
 | 
					const QMap< QString, DanbooruPost::Rating > DanbooruPost::initRatingMap()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -91,13 +88,11 @@ const QMap< QString, DanbooruPost::Rating > DanbooruPost::initRatingMap()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool DanbooruPost::operator==(const Danbooru::DanbooruPost &other)
 | 
				
			||||||
bool DanbooruPost::operator==(const Danbooru::DanbooruPost& other)
 | 
					 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    return m_url == other.m_url && m_id == other.m_id;
 | 
					    return m_url == other.m_url && m_id == other.m_id;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
void DanbooruPost::setPixmap(const QPixmap &pixmap)
 | 
					void DanbooruPost::setPixmap(const QPixmap &pixmap)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    m_pixmap = pixmap;
 | 
					    m_pixmap = pixmap;
 | 
				
			||||||
| 
						 | 
					@ -155,7 +150,5 @@ Danbooru::DanbooruPost::Rating DanbooruPost::rating() const
 | 
				
			||||||
    return m_rating;
 | 
					    return m_rating;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
} // namespace Danbooru
 | 
					} // namespace Danbooru
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -45,10 +45,10 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "danbooru.h"
 | 
					#include "danbooru.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace Danbooru
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Danbooru {
 | 
					/**
 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
 * @brief A class representing a Danbooru post.
 | 
					 * @brief A class representing a Danbooru post.
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * A Danbooru post is an object that models the posts present in a
 | 
					 * A Danbooru post is an object that models the posts present in a
 | 
				
			||||||
| 
						 | 
					@ -65,8 +65,8 @@ namespace Danbooru {
 | 
				
			||||||
 * @see DanbooruService, DanbooruPool
 | 
					 * @see DanbooruService, DanbooruPool
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 **/
 | 
					 **/
 | 
				
			||||||
    class DanbooruPost : public QObject
 | 
					class DanbooruPost : public QObject
 | 
				
			||||||
    {
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Q_OBJECT
 | 
					    Q_OBJECT
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -76,7 +76,7 @@ namespace Danbooru {
 | 
				
			||||||
    Q_PROPERTY(QSet<QString> tags READ tags)
 | 
					    Q_PROPERTY(QSet<QString> tags READ tags)
 | 
				
			||||||
    Q_PROPERTY(QUrl thumbnailUrl READ thumbnailUrl)
 | 
					    Q_PROPERTY(QUrl thumbnailUrl READ thumbnailUrl)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public:
 | 
					public:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * @brief Ratings for a Danbooru item
 | 
					     * @brief Ratings for a Danbooru item
 | 
				
			||||||
| 
						 | 
					@ -91,8 +91,7 @@ namespace Danbooru {
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
    Q_DECLARE_FLAGS(Ratings, DanbooruPost::Rating)
 | 
					    Q_DECLARE_FLAGS(Ratings, DanbooruPost::Rating)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					private:
 | 
				
			||||||
    private:
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    QPixmap m_pixmap;
 | 
					    QPixmap m_pixmap;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -114,7 +113,7 @@ namespace Danbooru {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    static const QMap< QString, Rating > initRatingMap();
 | 
					    static const QMap< QString, Rating > initRatingMap();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public:
 | 
					public:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * @brief Construct a Danbooru post from a QVariantMap.
 | 
					     * @brief Construct a Danbooru post from a QVariantMap.
 | 
				
			||||||
| 
						 | 
					@ -130,7 +129,7 @@ namespace Danbooru {
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
     **/
 | 
					     **/
 | 
				
			||||||
    explicit DanbooruPost(QVariantMap postData, QPixmap pixmap = QPixmap(),
 | 
					    explicit DanbooruPost(QVariantMap postData, QPixmap pixmap = QPixmap(),
 | 
				
			||||||
                              QObject* parent = 0);
 | 
					                          QObject *parent = 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * @brief Construct a Danbooru post from XML attributes
 | 
					     * @brief Construct a Danbooru post from XML attributes
 | 
				
			||||||
| 
						 | 
					@ -146,10 +145,10 @@ namespace Danbooru {
 | 
				
			||||||
     * @param parent A pointer to the parent QObject.
 | 
					     * @param parent A pointer to the parent QObject.
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
     **/
 | 
					     **/
 | 
				
			||||||
        explicit DanbooruPost(QXmlStreamAttributes& postData,
 | 
					    explicit DanbooruPost(QXmlStreamAttributes &postData,
 | 
				
			||||||
                              QPixmap pixmap = QPixmap(),  QObject* parent =0);
 | 
					                          QPixmap pixmap = QPixmap(),  QObject *parent = 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        bool operator==(const DanbooruPost&);
 | 
					    bool operator==(const DanbooruPost &);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    ~DanbooruPost();
 | 
					    ~DanbooruPost();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -204,7 +203,7 @@ namespace Danbooru {
 | 
				
			||||||
     * Set the post's pixmap to a specific QPixmap instance's pointer.
 | 
					     * Set the post's pixmap to a specific QPixmap instance's pointer.
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
     **/
 | 
					     **/
 | 
				
			||||||
        void setPixmap(const QPixmap& pixmap);
 | 
					    void setPixmap(const QPixmap &pixmap);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * @return A string representation of the post.
 | 
					     * @return A string representation of the post.
 | 
				
			||||||
| 
						 | 
					@ -212,16 +211,13 @@ namespace Danbooru {
 | 
				
			||||||
     * **/
 | 
					     * **/
 | 
				
			||||||
    const QString toString();
 | 
					    const QString toString();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Q_DECLARE_OPERATORS_FOR_FLAGS(DanbooruPost::Ratings)
 | 
				
			||||||
    };
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    Q_DECLARE_OPERATORS_FOR_FLAGS(DanbooruPost::Ratings)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
}; // namespace Danbooru
 | 
					}; // namespace Danbooru
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Q_DECLARE_METATYPE(Danbooru::DanbooruPost*)
 | 
					Q_DECLARE_METATYPE(Danbooru::DanbooruPost *)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif // DANBOORUPOST_H
 | 
					#endif // DANBOORUPOST_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -53,9 +53,9 @@ const QString DanbooruService::ARTIST_URL = "artist/index.json";
 | 
				
			||||||
const QString DanbooruService::POOL_DATA_URL = "pool/show.xml";
 | 
					const QString DanbooruService::POOL_DATA_URL = "pool/show.xml";
 | 
				
			||||||
const QString DanbooruService::RELATED_TAG_URL = "tag/related.json";
 | 
					const QString DanbooruService::RELATED_TAG_URL = "tag/related.json";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
DanbooruService::DanbooruService(QUrl& boardUrl, QString username,
 | 
					DanbooruService::DanbooruService(QUrl &boardUrl, QString username,
 | 
				
			||||||
                                 QString password, KImageCache* cache,
 | 
					                                 QString password, KImageCache *cache,
 | 
				
			||||||
                                 QObject* parent):
 | 
					                                 QObject *parent):
 | 
				
			||||||
    QObject(parent),
 | 
					    QObject(parent),
 | 
				
			||||||
    m_url(boardUrl),
 | 
					    m_url(boardUrl),
 | 
				
			||||||
    m_username(username),
 | 
					    m_username(username),
 | 
				
			||||||
| 
						 | 
					@ -71,7 +71,6 @@ DanbooruService::~DanbooruService()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
void DanbooruService::getPostList(int page, QStringList tags, int limit)
 | 
					void DanbooruService::getPostList(int page, QStringList tags, int limit)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -89,7 +88,7 @@ void DanbooruService::getPostList(int page, QStringList tags, int limit)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//     qDebug() << "Final constructed post URL" << danbooruUrl.url();
 | 
					//     qDebug() << "Final constructed post URL" << danbooruUrl.url();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    KIO::StoredTransferJob* job = KIO::storedGet(danbooruUrl, KIO::NoReload,
 | 
					    KIO::StoredTransferJob *job = KIO::storedGet(danbooruUrl, KIO::NoReload,
 | 
				
			||||||
                                  KIO::HideProgressInfo);
 | 
					                                  KIO::HideProgressInfo);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // This job can use JSON data
 | 
					    // This job can use JSON data
 | 
				
			||||||
| 
						 | 
					@ -97,7 +96,6 @@ void DanbooruService::getPostList(int page, QStringList tags, int limit)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    connect(job, &KIO::StoredTransferJob::result, this, &DanbooruService::processPostList);
 | 
					    connect(job, &KIO::StoredTransferJob::result, this, &DanbooruService::processPostList);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void DanbooruService::getTagList(int limit, QString name)
 | 
					void DanbooruService::getTagList(int limit, QString name)
 | 
				
			||||||
| 
						 | 
					@ -114,17 +112,17 @@ void DanbooruService::getTagList(int limit, QString name)
 | 
				
			||||||
                                  parameters);
 | 
					                                  parameters);
 | 
				
			||||||
    //qDebug() << "Final constructed tag URL" << danbooruUrl.url();
 | 
					    //qDebug() << "Final constructed tag URL" << danbooruUrl.url();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    KIO::StoredTransferJob* job = KIO::storedGet(danbooruUrl, KIO::NoReload,
 | 
					    KIO::StoredTransferJob *job = KIO::storedGet(danbooruUrl, KIO::NoReload,
 | 
				
			||||||
                                  KIO::HideProgressInfo);
 | 
					                                  KIO::HideProgressInfo);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    connect(job, &KIO::StoredTransferJob::result, [this](KJob* job) {
 | 
					    connect(job, &KIO::StoredTransferJob::result, [this](KJob * job) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (job->error()) {
 | 
					        if (job->error()) {
 | 
				
			||||||
            Q_EMIT(downloadError(job->errorString()));
 | 
					            Q_EMIT(downloadError(job->errorString()));
 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            StoredTransferJob* jobResult = qobject_cast<StoredTransferJob*>(job);
 | 
					        StoredTransferJob *jobResult = qobject_cast<StoredTransferJob *>(job);
 | 
				
			||||||
        QByteArray data = jobResult->data();
 | 
					        QByteArray data = jobResult->data();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        bool ok;
 | 
					        bool ok;
 | 
				
			||||||
| 
						 | 
					@ -140,7 +138,7 @@ void DanbooruService::getTagList(int limit, QString name)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for (auto element : tagList) {
 | 
					        for (auto element : tagList) {
 | 
				
			||||||
            QVariantMap map = element.toMap();
 | 
					            QVariantMap map = element.toMap();
 | 
				
			||||||
                DanbooruTag* tag = new DanbooruTag(map);
 | 
					            DanbooruTag *tag = new DanbooruTag(map);
 | 
				
			||||||
            Q_EMIT(tagDownloaded(tag));
 | 
					            Q_EMIT(tagDownloaded(tag));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -164,8 +162,7 @@ void DanbooruService::getPool(int poolId, int page)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    //qDebug() << "Final constructed pool URL" << danbooruUrl.url();
 | 
					    //qDebug() << "Final constructed pool URL" << danbooruUrl.url();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    KIO::StoredTransferJob *job = KIO::storedGet(danbooruUrl, KIO::NoReload,
 | 
				
			||||||
    KIO::StoredTransferJob* job = KIO::storedGet(danbooruUrl, KIO::NoReload,
 | 
					 | 
				
			||||||
                                  KIO::HideProgressInfo);
 | 
					                                  KIO::HideProgressInfo);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    //HACK: Most Danbooru implementations don't provide valid data on
 | 
					    //HACK: Most Danbooru implementations don't provide valid data on
 | 
				
			||||||
| 
						 | 
					@ -194,21 +191,21 @@ void DanbooruService::getPoolList(int page)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    //qDebug() << "Final constructed pool list URL" << danbooruUrl.url();
 | 
					    //qDebug() << "Final constructed pool list URL" << danbooruUrl.url();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    KIO::StoredTransferJob* job = KIO::storedGet(danbooruUrl, KIO::NoReload,
 | 
					    KIO::StoredTransferJob *job = KIO::storedGet(danbooruUrl, KIO::NoReload,
 | 
				
			||||||
                                  KIO::HideProgressInfo);
 | 
					                                  KIO::HideProgressInfo);
 | 
				
			||||||
    // This job can use JSON data
 | 
					    // This job can use JSON data
 | 
				
			||||||
    job->setProperty("needsXML", false);
 | 
					    job->setProperty("needsXML", false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//     connect(job, &KIO::StoredTransferJob::result, this, &DanbooruService::processPoolList);
 | 
					//     connect(job, &KIO::StoredTransferJob::result, this, &DanbooruService::processPoolList);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    connect(job, &KIO::StoredTransferJob::result, [this] (KJob* job) {
 | 
					    connect(job, &KIO::StoredTransferJob::result, [this](KJob * job) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (job->error()) {
 | 
					        if (job->error()) {
 | 
				
			||||||
            Q_EMIT(downloadError(job->errorString()));
 | 
					            Q_EMIT(downloadError(job->errorString()));
 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        StoredTransferJob* jobResult = qobject_cast<StoredTransferJob*>(job);
 | 
					        StoredTransferJob *jobResult = qobject_cast<StoredTransferJob *>(job);
 | 
				
			||||||
        QByteArray data = jobResult->data();
 | 
					        QByteArray data = jobResult->data();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        bool ok;
 | 
					        bool ok;
 | 
				
			||||||
| 
						 | 
					@ -222,7 +219,7 @@ void DanbooruService::getPoolList(int page)
 | 
				
			||||||
        for (auto element : poolList) {
 | 
					        for (auto element : poolList) {
 | 
				
			||||||
            QVariantMap map = element.toMap();
 | 
					            QVariantMap map = element.toMap();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            DanbooruPool* pool = new DanbooruPool(map);
 | 
					            DanbooruPool *pool = new DanbooruPool(map);
 | 
				
			||||||
            Q_EMIT(poolDownloaded(pool));
 | 
					            Q_EMIT(poolDownloaded(pool));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -234,7 +231,7 @@ void DanbooruService::getPoolList(int page)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void DanbooruService::getRelatedTags(const QStringList& tags,
 | 
					void DanbooruService::getRelatedTags(const QStringList &tags,
 | 
				
			||||||
                                     DanbooruTag::TagType tagType)
 | 
					                                     DanbooruTag::TagType tagType)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -265,19 +262,19 @@ void DanbooruService::getRelatedTags(const QStringList& tags,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    //qDebug() << "Final constructed related tag URL" << danbooruUrl.url();
 | 
					    //qDebug() << "Final constructed related tag URL" << danbooruUrl.url();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    StoredTransferJob* job = KIO::storedGet(
 | 
					    StoredTransferJob *job = KIO::storedGet(
 | 
				
			||||||
                                 danbooruUrl, KIO::NoReload,
 | 
					                                 danbooruUrl, KIO::NoReload,
 | 
				
			||||||
                                 KIO::HideProgressInfo
 | 
					                                 KIO::HideProgressInfo
 | 
				
			||||||
                             );
 | 
					                             );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    connect(job, &StoredTransferJob::result, [this](KJob* job) {
 | 
					    connect(job, &StoredTransferJob::result, [this](KJob * job) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (job->error()) {
 | 
					        if (job->error()) {
 | 
				
			||||||
            Q_EMIT(downloadError(job->errorString()));
 | 
					            Q_EMIT(downloadError(job->errorString()));
 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        StoredTransferJob* jobResult = qobject_cast<StoredTransferJob*>(job);
 | 
					        StoredTransferJob *jobResult = qobject_cast<StoredTransferJob *>(job);
 | 
				
			||||||
        QByteArray data = jobResult->data();
 | 
					        QByteArray data = jobResult->data();
 | 
				
			||||||
        bool ok;
 | 
					        bool ok;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -320,7 +317,7 @@ void DanbooruService::getRelatedTags(const QStringList& tags,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Getters / setters
 | 
					// Getters / setters
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void DanbooruService::setBlacklist(const QSet< QString >& blacklist)
 | 
					void DanbooruService::setBlacklist(const QSet< QString > &blacklist)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!blacklist.isEmpty()) {
 | 
					    if (!blacklist.isEmpty()) {
 | 
				
			||||||
| 
						 | 
					@ -329,7 +326,6 @@ void DanbooruService::setBlacklist(const QSet< QString >& blacklist)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
const QSet< QString > DanbooruService::blacklist() const
 | 
					const QSet< QString > DanbooruService::blacklist() const
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    return m_blacklist;
 | 
					    return m_blacklist;
 | 
				
			||||||
| 
						 | 
					@ -384,7 +380,7 @@ const DanbooruPost::Ratings DanbooruService::maximumAllowedRating() const
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Slots
 | 
					// Slots
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void DanbooruService::processPostList(KJob* job)
 | 
					void DanbooruService::processPostList(KJob *job)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//     qDebug() << "Got post data OK";
 | 
					//     qDebug() << "Got post data OK";
 | 
				
			||||||
| 
						 | 
					@ -393,7 +389,7 @@ void DanbooruService::processPostList(KJob* job)
 | 
				
			||||||
        Q_EMIT(downloadError(job->errorString()));
 | 
					        Q_EMIT(downloadError(job->errorString()));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    StoredTransferJob* jobResult = qobject_cast<StoredTransferJob*>(job);
 | 
					    StoredTransferJob *jobResult = qobject_cast<StoredTransferJob *>(job);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (jobResult == 0) {
 | 
					    if (jobResult == 0) {
 | 
				
			||||||
        Q_EMIT(downloadError(QString("Internal error")));
 | 
					        Q_EMIT(downloadError(QString("Internal error")));
 | 
				
			||||||
| 
						 | 
					@ -427,7 +423,7 @@ void DanbooruService::processPostList(KJob* job)
 | 
				
			||||||
    for (auto element : postList) {
 | 
					    for (auto element : postList) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        QVariantMap map = element.toMap();
 | 
					        QVariantMap map = element.toMap();
 | 
				
			||||||
        DanbooruPost* post = new DanbooruPost(map);
 | 
					        DanbooruPost *post = new DanbooruPost(map);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Remove unwanted posts
 | 
					        // Remove unwanted posts
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -453,11 +449,11 @@ void DanbooruService::processPostList(KJob* job)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            StoredTransferJob* pixmapJob = KIO::storedGet(post->thumbnailUrl(),
 | 
					            StoredTransferJob *pixmapJob = KIO::storedGet(post->thumbnailUrl(),
 | 
				
			||||||
                                           KIO::NoReload, KIO::HideProgressInfo
 | 
					                                           KIO::NoReload, KIO::HideProgressInfo
 | 
				
			||||||
                                                         );
 | 
					                                                         );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            KIO::Scheduler::setJobPriority(static_cast<KIO::SimpleJob*>(job), 1);
 | 
					            KIO::Scheduler::setJobPriority(static_cast<KIO::SimpleJob *>(job), 1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            QVariant variant;
 | 
					            QVariant variant;
 | 
				
			||||||
            variant.setValue(post);
 | 
					            variant.setValue(post);
 | 
				
			||||||
| 
						 | 
					@ -467,23 +463,26 @@ void DanbooruService::processPostList(KJob* job)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            pixmapJob->setProperty("danbooruPost", variant);
 | 
					            pixmapJob->setProperty("danbooruPost", variant);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            connect(pixmapJob, &StoredTransferJob::result, [post, this, pix] (KJob* job) mutable {
 | 
					            connect(pixmapJob, &StoredTransferJob::result, [post, this, pix](KJob * job) mutable {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                if (job->error()) {
 | 
					                if (job->error())
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
                    Q_EMIT(downloadError(job->errorString()));
 | 
					                    Q_EMIT(downloadError(job->errorString()));
 | 
				
			||||||
                    return;
 | 
					                    return;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                StoredTransferJob* jobResult = qobject_cast<StoredTransferJob*>(job);
 | 
					                StoredTransferJob *jobResult = qobject_cast<StoredTransferJob *>(job);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                if (!pix.loadFromData(jobResult->data())) {
 | 
					                if (!pix.loadFromData(jobResult->data()))
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
                    Q_EMIT(downloadError(QString("Pixmap data could not be loaded")));
 | 
					                    Q_EMIT(downloadError(QString("Pixmap data could not be loaded")));
 | 
				
			||||||
                    return;
 | 
					                    return;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                post->setPixmap(pix);
 | 
					                post->setPixmap(pix);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                if (m_cache) {
 | 
					                if (m_cache)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
                    //qDebug() << "Inserting item in cache";
 | 
					                    //qDebug() << "Inserting item in cache";
 | 
				
			||||||
                    m_cache->insertPixmap(post->thumbnailUrl().url(), pix);
 | 
					                    m_cache->insertPixmap(post->thumbnailUrl().url(), pix);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
| 
						 | 
					@ -493,7 +492,8 @@ void DanbooruService::processPostList(KJob* job)
 | 
				
			||||||
                //qDebug() << "Current posts remaining" << m_currentPosts;
 | 
					                //qDebug() << "Current posts remaining" << m_currentPosts;
 | 
				
			||||||
                Q_EMIT(postDownloaded(post));
 | 
					                Q_EMIT(postDownloaded(post));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                if (m_postsToFetch == 0) {
 | 
					                if (m_postsToFetch == 0)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
                    qDebug() << "Post download finished";
 | 
					                    qDebug() << "Post download finished";
 | 
				
			||||||
                    Q_EMIT(postDownloadFinished());
 | 
					                    Q_EMIT(postDownloadFinished());
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
| 
						 | 
					@ -504,30 +504,26 @@ void DanbooruService::processPostList(KJob* job)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void DanbooruService::processTagList(KJob* job)
 | 
					void DanbooruService::processTagList(KJob *job)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void DanbooruService::processRelatedTagList(KJob *job)
 | 
				
			||||||
void DanbooruService::processRelatedTagList(KJob* job)
 | 
					 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void DanbooruService::processPoolList(KJob* job)
 | 
					void DanbooruService::processPoolList(KJob *job)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    if (job->error()) {
 | 
					    if (job->error()) {
 | 
				
			||||||
        Q_EMIT(downloadError(job->errorString()));
 | 
					        Q_EMIT(downloadError(job->errorString()));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    StoredTransferJob* jobResult = qobject_cast<StoredTransferJob*>(job);
 | 
					    StoredTransferJob *jobResult = qobject_cast<StoredTransferJob *>(job);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (jobResult == 0) {
 | 
					    if (jobResult == 0) {
 | 
				
			||||||
        Q_EMIT(downloadError(QString("Internal error")));
 | 
					        Q_EMIT(downloadError(QString("Internal error")));
 | 
				
			||||||
| 
						 | 
					@ -549,7 +545,7 @@ void DanbooruService::processPoolList(KJob* job)
 | 
				
			||||||
    for (auto element : poolList) {
 | 
					    for (auto element : poolList) {
 | 
				
			||||||
        QVariantMap map = element.toMap();
 | 
					        QVariantMap map = element.toMap();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        DanbooruPool* pool = new DanbooruPool(map);
 | 
					        DanbooruPool *pool = new DanbooruPool(map);
 | 
				
			||||||
        Q_EMIT(poolDownloaded(pool));
 | 
					        Q_EMIT(poolDownloaded(pool));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -558,12 +554,12 @@ void DanbooruService::processPoolList(KJob* job)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void DanbooruService::downloadAllTags(KJob* job)
 | 
					void DanbooruService::downloadAllTags(KJob *job)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    Q_UNUSED(job)
 | 
					    Q_UNUSED(job)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void DanbooruService::downloadThumbnail(KJob* job)
 | 
					void DanbooruService::downloadThumbnail(KJob *job)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (job->error()) {
 | 
					    if (job->error()) {
 | 
				
			||||||
| 
						 | 
					@ -572,11 +568,11 @@ void DanbooruService::downloadThumbnail(KJob* job)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    QVariant postData = job->property("danbooruPost");
 | 
					    QVariant postData = job->property("danbooruPost");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    DanbooruPost* post = postData.value<DanbooruPost*>();
 | 
					    DanbooruPost *post = postData.value<DanbooruPost *>();
 | 
				
			||||||
    QPixmap pix;
 | 
					    QPixmap pix;
 | 
				
			||||||
    // QPixmap* pix = new QPixmap();
 | 
					    // QPixmap* pix = new QPixmap();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    StoredTransferJob* jobResult = qobject_cast<StoredTransferJob*>(job);
 | 
					    StoredTransferJob *jobResult = qobject_cast<StoredTransferJob *>(job);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (jobResult == 0) {
 | 
					    if (jobResult == 0) {
 | 
				
			||||||
        Q_EMIT(downloadError(QString("Internal error")));
 | 
					        Q_EMIT(downloadError(QString("Internal error")));
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -24,7 +24,6 @@
 | 
				
			||||||
#ifndef DANBOORUSERVICE_H
 | 
					#ifndef DANBOORUSERVICE_H
 | 
				
			||||||
#define DANBOORUSERVICE_H
 | 
					#define DANBOORUSERVICE_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * @brief Classes to interact with Danbooru boards
 | 
					 * @brief Classes to interact with Danbooru boards
 | 
				
			||||||
 * @file danbooruservice.h
 | 
					 * @file danbooruservice.h
 | 
				
			||||||
| 
						 | 
					@ -56,13 +55,14 @@ class KJob;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
using Danbooru::DanbooruTag;
 | 
					using Danbooru::DanbooruTag;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Danbooru {
 | 
					namespace Danbooru
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    class DanbooruPool;
 | 
					class DanbooruPool;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    using KIO::StoredTransferJob;
 | 
					using KIO::StoredTransferJob;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					/**
 | 
				
			||||||
 * @brief A class which provides a wrapper around Danbooru's RESTful API.
 | 
					 * @brief A class which provides a wrapper around Danbooru's RESTful API.
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * This class provides access to Danbooru-based image boards
 | 
					 * This class provides access to Danbooru-based image boards
 | 
				
			||||||
| 
						 | 
					@ -73,11 +73,11 @@ namespace Danbooru {
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 **/
 | 
					 **/
 | 
				
			||||||
    class DanbooruService : public QObject
 | 
					class DanbooruService : public QObject
 | 
				
			||||||
    {
 | 
					{
 | 
				
			||||||
    Q_OBJECT
 | 
					    Q_OBJECT
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private:
 | 
					private:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // URL fragments
 | 
					    // URL fragments
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -98,9 +98,9 @@ namespace Danbooru {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    unsigned int m_postsToFetch; // To tell when to quit
 | 
					    unsigned int m_postsToFetch; // To tell when to quit
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        KImageCache* m_cache; // Pixmap cache
 | 
					    KImageCache *m_cache; // Pixmap cache
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public:
 | 
					public:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * @brief Construct a default instance of the service.
 | 
					     * @brief Construct a default instance of the service.
 | 
				
			||||||
| 
						 | 
					@ -113,9 +113,9 @@ namespace Danbooru {
 | 
				
			||||||
     * @param parent The parent QObject
 | 
					     * @param parent The parent QObject
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
     **/
 | 
					     **/
 | 
				
			||||||
        DanbooruService(QUrl& boardUrl, QString username = QString(),
 | 
					    DanbooruService(QUrl &boardUrl, QString username = QString(),
 | 
				
			||||||
                        QString password = QString(), KImageCache* cache = 0,
 | 
					                    QString password = QString(), KImageCache *cache = 0,
 | 
				
			||||||
                        QObject* parent = 0);
 | 
					                    QObject *parent = 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Default destructor.
 | 
					     * Default destructor.
 | 
				
			||||||
| 
						 | 
					@ -130,8 +130,8 @@ namespace Danbooru {
 | 
				
			||||||
     * @param limit The number of posts to fetch (maximum 100)
 | 
					     * @param limit The number of posts to fetch (maximum 100)
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
     **/
 | 
					     **/
 | 
				
			||||||
        void getPostList(int page=1, QStringList tags=QStringList(),
 | 
					    void getPostList(int page = 1, QStringList tags = QStringList(),
 | 
				
			||||||
                         int limit=100);
 | 
					                     int limit = 100);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * @brief Get a list of pools from the board.
 | 
					     * @brief Get a list of pools from the board.
 | 
				
			||||||
| 
						 | 
					@ -148,7 +148,7 @@ namespace Danbooru {
 | 
				
			||||||
     * @param page The page of the pool posts (if > 100)
 | 
					     * @param page The page of the pool posts (if > 100)
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
     **/
 | 
					     **/
 | 
				
			||||||
        void getPool(int poolId, int page=1);
 | 
					    void getPool(int poolId, int page = 1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * @brief Get a list of tags from the board
 | 
					     * @brief Get a list of tags from the board
 | 
				
			||||||
| 
						 | 
					@ -164,7 +164,7 @@ namespace Danbooru {
 | 
				
			||||||
     * @param name The name of the tag to retrieve, or an empty string
 | 
					     * @param name The name of the tag to retrieve, or an empty string
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
     **/
 | 
					     **/
 | 
				
			||||||
        void getTagList(int limit=10, QString name="");
 | 
					    void getTagList(int limit = 10, QString name = "");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * @brief Get tags related to a specific, user supplied list.
 | 
					     * @brief Get tags related to a specific, user supplied list.
 | 
				
			||||||
| 
						 | 
					@ -172,7 +172,7 @@ namespace Danbooru {
 | 
				
			||||||
     * @param tags The tags to query for related terms
 | 
					     * @param tags The tags to query for related terms
 | 
				
			||||||
     * @param tagType The type of tag to query for
 | 
					     * @param tagType The type of tag to query for
 | 
				
			||||||
     **/
 | 
					     **/
 | 
				
			||||||
        void getRelatedTags(const QStringList& tags, DanbooruTag::TagType tagType = DanbooruTag::General);
 | 
					    void getRelatedTags(const QStringList &tags, DanbooruTag::TagType tagType = DanbooruTag::General);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * @return The currently allowed ratings when downloading posts.
 | 
					     * @return The currently allowed ratings when downloading posts.
 | 
				
			||||||
| 
						 | 
					@ -189,7 +189,7 @@ namespace Danbooru {
 | 
				
			||||||
     **/
 | 
					     **/
 | 
				
			||||||
    const QSet<QString> blacklist() const;
 | 
					    const QSet<QString> blacklist() const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        void setBlacklist(const QSet<QString>& blacklist);
 | 
					    void setBlacklist(const QSet<QString> &blacklist);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * @brief Set the maximum allowed rating for the board.
 | 
					     * @brief Set the maximum allowed rating for the board.
 | 
				
			||||||
| 
						 | 
					@ -208,15 +208,15 @@ namespace Danbooru {
 | 
				
			||||||
     **/
 | 
					     **/
 | 
				
			||||||
    void setBlackList(QStringList blacklist);
 | 
					    void setBlackList(QStringList blacklist);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private Q_SLOTS:
 | 
					private Q_SLOTS:
 | 
				
			||||||
        void processPostList(KJob* job);
 | 
					    void processPostList(KJob *job);
 | 
				
			||||||
        void processPoolList(KJob* job);
 | 
					    void processPoolList(KJob *job);
 | 
				
			||||||
        void processTagList(KJob* job);
 | 
					    void processTagList(KJob *job);
 | 
				
			||||||
        void processRelatedTagList(KJob* job);
 | 
					    void processRelatedTagList(KJob *job);
 | 
				
			||||||
        void downloadThumbnail(KJob* job);
 | 
					    void downloadThumbnail(KJob *job);
 | 
				
			||||||
        void downloadAllTags(KJob* job);
 | 
					    void downloadAllTags(KJob *job);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Q_SIGNALS:
 | 
					Q_SIGNALS:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Emitted when there are no more posts to download.
 | 
					     * Emitted when there are no more posts to download.
 | 
				
			||||||
| 
						 | 
					@ -231,7 +231,6 @@ namespace Danbooru {
 | 
				
			||||||
     **/
 | 
					     **/
 | 
				
			||||||
    void poolDownloadFinished();
 | 
					    void poolDownloadFinished();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Emitted when a download error occurred.
 | 
					     * Emitted when a download error occurred.
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
| 
						 | 
					@ -246,7 +245,7 @@ namespace Danbooru {
 | 
				
			||||||
     * The parameter contains a pointer to the post that has been
 | 
					     * The parameter contains a pointer to the post that has been
 | 
				
			||||||
     * downloaded.
 | 
					     * downloaded.
 | 
				
			||||||
     **/
 | 
					     **/
 | 
				
			||||||
        void postDownloaded(Danbooru::DanbooruPost* post);
 | 
					    void postDownloaded(Danbooru::DanbooruPost *post);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Emitted when a pool has been downloaded.
 | 
					     * Emitted when a pool has been downloaded.
 | 
				
			||||||
| 
						 | 
					@ -254,7 +253,7 @@ namespace Danbooru {
 | 
				
			||||||
     * The parameter contains a pointer to the pool that has been
 | 
					     * The parameter contains a pointer to the pool that has been
 | 
				
			||||||
     * downloaded.
 | 
					     * downloaded.
 | 
				
			||||||
     **/
 | 
					     **/
 | 
				
			||||||
        void poolDownloaded(Danbooru::DanbooruPool* pool);
 | 
					    void poolDownloaded(Danbooru::DanbooruPool *pool);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Emitted when a tag has been downloaded.
 | 
					     * Emitted when a tag has been downloaded.
 | 
				
			||||||
| 
						 | 
					@ -262,8 +261,8 @@ namespace Danbooru {
 | 
				
			||||||
     * The parameter contains a pointer to the tag that has been
 | 
					     * The parameter contains a pointer to the tag that has been
 | 
				
			||||||
     * downloaded.
 | 
					     * downloaded.
 | 
				
			||||||
     **/
 | 
					     **/
 | 
				
			||||||
        void tagDownloaded(Danbooru::DanbooruTag* tag);
 | 
					    void tagDownloaded(Danbooru::DanbooruTag *tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    };
 | 
					};
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
#endif // DANBOORUSERVICE_H
 | 
					#endif // DANBOORUSERVICE_H
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -25,7 +25,7 @@
 | 
				
			||||||
namespace Danbooru
 | 
					namespace Danbooru
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
DanbooruTag::DanbooruTag(const QVariantMap& postData, QObject* parent):
 | 
					DanbooruTag::DanbooruTag(const QVariantMap &postData, QObject *parent):
 | 
				
			||||||
    QObject(parent)
 | 
					    QObject(parent)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    m_id = postData.value("id").toInt();
 | 
					    m_id = postData.value("id").toInt();
 | 
				
			||||||
| 
						 | 
					@ -82,5 +82,4 @@ Danbooru::DanbooruTag::TagType DanbooruTag::type() const
 | 
				
			||||||
    return m_tagType;
 | 
					    return m_tagType;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
}; // namespace Danbooru
 | 
					}; // namespace Danbooru
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -20,7 +20,6 @@
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifndef DANBOORUTAG_H
 | 
					#ifndef DANBOORUTAG_H
 | 
				
			||||||
#define DANBOORUTAG_H
 | 
					#define DANBOORUTAG_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -29,13 +28,14 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "danbooru.h"
 | 
					#include "danbooru.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Danbooru {
 | 
					namespace Danbooru
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    class DanbooruTag : public QObject
 | 
					class DanbooruTag : public QObject
 | 
				
			||||||
    {
 | 
					{
 | 
				
			||||||
    Q_OBJECT
 | 
					    Q_OBJECT
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public:
 | 
					public:
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
    * @brief Types of tags
 | 
					    * @brief Types of tags
 | 
				
			||||||
    *
 | 
					    *
 | 
				
			||||||
| 
						 | 
					@ -51,32 +51,32 @@ namespace Danbooru {
 | 
				
			||||||
        General = 1, /**< Generic tags **/
 | 
					        General = 1, /**< Generic tags **/
 | 
				
			||||||
        Artist = 2, /**< Tags related to artists **/
 | 
					        Artist = 2, /**< Tags related to artists **/
 | 
				
			||||||
        Copyright = 4, /**<Tags related to copyrights **/
 | 
					        Copyright = 4, /**<Tags related to copyrights **/
 | 
				
			||||||
        Character= 8, /**<Tags related to characters **/
 | 
					        Character = 8, /**<Tags related to characters **/
 | 
				
			||||||
        Unknown = 16 /**< Unknown tags **/
 | 
					        Unknown = 16 /**< Unknown tags **/
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private:
 | 
					private:
 | 
				
			||||||
    int m_id;
 | 
					    int m_id;
 | 
				
			||||||
    int m_count;
 | 
					    int m_count;
 | 
				
			||||||
    QString m_name;
 | 
					    QString m_name;
 | 
				
			||||||
    bool m_ambiguous;
 | 
					    bool m_ambiguous;
 | 
				
			||||||
    TagType m_tagType;
 | 
					    TagType m_tagType;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public:
 | 
					public:
 | 
				
			||||||
        DanbooruTag(const QVariantMap& postData, QObject* parent=0);
 | 
					    DanbooruTag(const QVariantMap &postData, QObject *parent = 0);
 | 
				
			||||||
    int id() const;
 | 
					    int id() const;
 | 
				
			||||||
    int count() const;
 | 
					    int count() const;
 | 
				
			||||||
    const QString name() const;
 | 
					    const QString name() const;
 | 
				
			||||||
    bool ambiguous() const;
 | 
					    bool ambiguous() const;
 | 
				
			||||||
    TagType type() const;
 | 
					    TagType type() const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    };
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Q_DECLARE_FLAGS(TagTypes, DanbooruTag::TagType)
 | 
					Q_DECLARE_FLAGS(TagTypes, DanbooruTag::TagType)
 | 
				
			||||||
    Q_DECLARE_OPERATORS_FOR_FLAGS(TagTypes)
 | 
					Q_DECLARE_OPERATORS_FOR_FLAGS(TagTypes)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}; // namespace  Danbooru
 | 
					}; // namespace  Danbooru
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Q_DECLARE_METATYPE(Danbooru::DanbooruTag*)
 | 
					Q_DECLARE_METATYPE(Danbooru::DanbooruTag *)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif // DANBOORUTAG_H
 | 
					#endif // DANBOORUTAG_H
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -34,12 +34,13 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <QDebug>
 | 
					#include <QDebug>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Danbooru {
 | 
					namespace Danbooru
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    QUrl requestUrl(QUrl& url, const QString& path,
 | 
					QUrl requestUrl(QUrl &url, const QString &path,
 | 
				
			||||||
                    const QString& username, const QString& password,
 | 
					                const QString &username, const QString &password,
 | 
				
			||||||
                    const dictMap& parameters, const QStringList& tags)
 | 
					                const dictMap ¶meters, const QStringList &tags)
 | 
				
			||||||
    {
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    QUrl danbooruUrl = QUrl(url);
 | 
					    QUrl danbooruUrl = QUrl(url);
 | 
				
			||||||
    danbooruUrl = danbooruUrl.adjusted(QUrl::StripTrailingSlash);
 | 
					    danbooruUrl = danbooruUrl.adjusted(QUrl::StripTrailingSlash);
 | 
				
			||||||
| 
						 | 
					@ -49,7 +50,7 @@ namespace Danbooru {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!parameters.isEmpty()) {
 | 
					    if (!parameters.isEmpty()) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            for (auto key: parameters.keys()) {
 | 
					        for (auto key : parameters.keys()) {
 | 
				
			||||||
            danbooruUrl.addQueryItem(key, parameters.value(key));
 | 
					            danbooruUrl.addQueryItem(key, parameters.value(key));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -68,11 +69,11 @@ namespace Danbooru {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return danbooruUrl;
 | 
					    return danbooruUrl;
 | 
				
			||||||
    }
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    QUrl requestUrl(QUrl& url, const QString& path, const QString& username,
 | 
					QUrl requestUrl(QUrl &url, const QString &path, const QString &username,
 | 
				
			||||||
                    const QString& password, const dictMap& parameters)
 | 
					                const QString &password, const dictMap ¶meters)
 | 
				
			||||||
    {
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    QUrl danbooruUrl = QUrl(url);
 | 
					    QUrl danbooruUrl = QUrl(url);
 | 
				
			||||||
    danbooruUrl = danbooruUrl.adjusted(QUrl::StripTrailingSlash);
 | 
					    danbooruUrl = danbooruUrl.adjusted(QUrl::StripTrailingSlash);
 | 
				
			||||||
| 
						 | 
					@ -82,7 +83,7 @@ namespace Danbooru {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!parameters.isEmpty()) {
 | 
					    if (!parameters.isEmpty()) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            for (auto key: parameters.keys()) {
 | 
					        for (auto key : parameters.keys()) {
 | 
				
			||||||
            danbooruUrl.addQueryItem(key, parameters.value(key));
 | 
					            danbooruUrl.addQueryItem(key, parameters.value(key));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -94,11 +95,11 @@ namespace Danbooru {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return danbooruUrl;
 | 
					    return danbooruUrl;
 | 
				
			||||||
    }
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    QUrl requestUrl(QUrl& url, const QString& path, const QString& username,
 | 
					QUrl requestUrl(QUrl &url, const QString &path, const QString &username,
 | 
				
			||||||
                    const QString& password)
 | 
					                const QString &password)
 | 
				
			||||||
    {
 | 
					{
 | 
				
			||||||
    QUrl danbooruUrl = QUrl(url);
 | 
					    QUrl danbooruUrl = QUrl(url);
 | 
				
			||||||
    danbooruUrl = danbooruUrl.adjusted(QUrl::StripTrailingSlash);
 | 
					    danbooruUrl = danbooruUrl.adjusted(QUrl::StripTrailingSlash);
 | 
				
			||||||
    danbooruUrl.setPath(danbooruUrl.path() + '/' + path);
 | 
					    danbooruUrl.setPath(danbooruUrl.path() + '/' + path);
 | 
				
			||||||
| 
						 | 
					@ -109,18 +110,18 @@ namespace Danbooru {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return danbooruUrl;
 | 
					    return danbooruUrl;
 | 
				
			||||||
    }
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    QList< QVariant > parseDanbooruResult(QByteArray data, QString elementName,
 | 
					QList< QVariant > parseDanbooruResult(QByteArray data, QString elementName,
 | 
				
			||||||
                                          bool* result)
 | 
					                                      bool *result)
 | 
				
			||||||
    {
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    QXmlStreamReader reader;
 | 
					    QXmlStreamReader reader;
 | 
				
			||||||
    reader.addData(data);
 | 
					    reader.addData(data);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    QList<QVariant> postData;
 | 
					    QList<QVariant> postData;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        while(!reader.atEnd() && !reader.hasError()) {
 | 
					    while (!reader.atEnd() && !reader.hasError()) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        QXmlStreamReader::TokenType token = reader.readNext();
 | 
					        QXmlStreamReader::TokenType token = reader.readNext();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -128,7 +129,7 @@ namespace Danbooru {
 | 
				
			||||||
            continue;
 | 
					            continue;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if(token == QXmlStreamReader::StartElement &&
 | 
					        if (token == QXmlStreamReader::StartElement &&
 | 
				
			||||||
                reader.name() == elementName)  {
 | 
					                reader.name() == elementName)  {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            QVariantMap values;
 | 
					            QVariantMap values;
 | 
				
			||||||
| 
						 | 
					@ -137,7 +138,7 @@ namespace Danbooru {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//                 qDebug() << attributes;
 | 
					//                 qDebug() << attributes;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                for (auto attribute: attributes) {
 | 
					            for (auto attribute : attributes) {
 | 
				
			||||||
                values.insert(attribute.name().toString(),
 | 
					                values.insert(attribute.name().toString(),
 | 
				
			||||||
                              attribute.value().toString());
 | 
					                              attribute.value().toString());
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
| 
						 | 
					@ -155,10 +156,10 @@ namespace Danbooru {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    *result = true;
 | 
					    *result = true;
 | 
				
			||||||
    return postData;
 | 
					    return postData;
 | 
				
			||||||
    }
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    QVariant parseDanbooruResult(QByteArray data, bool* result)
 | 
					QVariant parseDanbooruResult(QByteArray data, bool *result)
 | 
				
			||||||
    {
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    QJsonDocument parsed = QJsonDocument::fromJson(data);
 | 
					    QJsonDocument parsed = QJsonDocument::fromJson(data);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -171,16 +172,16 @@ namespace Danbooru {
 | 
				
			||||||
    *result = true;
 | 
					    *result = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return postData;
 | 
					    return postData;
 | 
				
			||||||
    }
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool isPostBlacklisted(DanbooruPost *post, QSet<QString> blacklist, DanbooruPost::Ratings maxRating)
 | 
				
			||||||
bool isPostBlacklisted(DanbooruPost *post, QSet<QString> blacklist, DanbooruPost::Ratings maxRating ) {
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (post->rating() > maxRating) {
 | 
					    if (post->rating() > maxRating) {
 | 
				
			||||||
        return true;
 | 
					        return true;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for (auto tag: post->tags()) {
 | 
					    for (auto tag : post->tags()) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (blacklist.contains(tag)) {
 | 
					        if (blacklist.contains(tag)) {
 | 
				
			||||||
            return true;
 | 
					            return true;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -39,11 +39,12 @@
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 **/
 | 
					 **/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Danbooru {
 | 
					namespace Danbooru
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    typedef QMap<QString,QString> dictMap;
 | 
					typedef QMap<QString, QString> dictMap;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /** @brief Generate a request URL for a Danbooru board.
 | 
					/** @brief Generate a request URL for a Danbooru board.
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * Given an URL and an API path, this function builds a
 | 
					 * Given an URL and an API path, this function builds a
 | 
				
			||||||
 * proper URL which is used for the specific API operation.
 | 
					 * proper URL which is used for the specific API operation.
 | 
				
			||||||
| 
						 | 
					@ -62,12 +63,11 @@ namespace Danbooru {
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 **/
 | 
					 **/
 | 
				
			||||||
    QUrl requestUrl(QUrl& url, const QString& path, const QString& username,
 | 
					QUrl requestUrl(QUrl &url, const QString &path, const QString &username,
 | 
				
			||||||
                    const QString& password, const dictMap& parameters,
 | 
					                const QString &password, const dictMap ¶meters,
 | 
				
			||||||
                    const QStringList& tags);
 | 
					                const QStringList &tags);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/** @brief Generate a request URL for a Danbooru board.
 | 
				
			||||||
    /** @brief Generate a request URL for a Danbooru board.
 | 
					 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * This is an overloaded function provided for convenience.
 | 
					 * This is an overloaded function provided for convenience.
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
| 
						 | 
					@ -84,11 +84,10 @@ namespace Danbooru {
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 **/
 | 
					 **/
 | 
				
			||||||
    QUrl requestUrl(QUrl& url, const QString& path, const QString& username,
 | 
					QUrl requestUrl(QUrl &url, const QString &path, const QString &username,
 | 
				
			||||||
                    const QString& password, const dictMap& parameters);
 | 
					                const QString &password, const dictMap ¶meters);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/** @brief Generate a request URL for a Danbooru board.
 | 
				
			||||||
    /** @brief Generate a request URL for a Danbooru board.
 | 
					 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * This is an overloaded function provided for convenience.
 | 
					 * This is an overloaded function provided for convenience.
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
| 
						 | 
					@ -102,15 +101,14 @@ namespace Danbooru {
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 **/
 | 
					 **/
 | 
				
			||||||
    QUrl requestUrl(QUrl& url, const QString& path, const QString& username,
 | 
					QUrl requestUrl(QUrl &url, const QString &path, const QString &username,
 | 
				
			||||||
                    const QString& password);
 | 
					                const QString &password);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					QList<QVariant> parseDanbooruResult(QByteArray data, QString xlmElement,
 | 
				
			||||||
 | 
					                                    bool *result);
 | 
				
			||||||
 | 
					QVariant parseDanbooruResult(QByteArray data, bool *result);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    QList<QVariant> parseDanbooruResult(QByteArray data, QString xlmElement,
 | 
					/**
 | 
				
			||||||
                                        bool* result);
 | 
					 | 
				
			||||||
    QVariant parseDanbooruResult(QByteArray data, bool* result);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
 * @brief Check if a post can be allowed.
 | 
					 * @brief Check if a post can be allowed.
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * This convenience function checks if a DanbooruPost is not allowed, either because it
 | 
					 * This convenience function checks if a DanbooruPost is not allowed, either because it
 | 
				
			||||||
| 
						 | 
					@ -122,7 +120,7 @@ namespace Danbooru {
 | 
				
			||||||
 * @return true if the post is unwanted, false otherwise.
 | 
					 * @return true if the post is unwanted, false otherwise.
 | 
				
			||||||
 * @author Luca Beltrame (lbeltrame@kde.org)
 | 
					 * @author Luca Beltrame (lbeltrame@kde.org)
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
    bool isPostBlacklisted(DanbooruPost *post, QSet<QString> blacklist, DanbooruPost::Ratings maxRating );
 | 
					bool isPostBlacklisted(DanbooruPost *post, QSet<QString> blacklist, DanbooruPost::Ratings maxRating);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
#endif // UTILS_H
 | 
					#endif // UTILS_H
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										21
									
								
								src/main.cpp
									
										
									
									
									
								
							
							
						
						
									
										21
									
								
								src/main.cpp
									
										
									
									
									
								
							| 
						 | 
					@ -37,7 +37,7 @@ int main(int argc, char **argv)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    K4AboutData about("danbooru_client", 0, ki18n("danbooru_client"), version, ki18n(description),
 | 
					    K4AboutData about("danbooru_client", 0, ki18n("danbooru_client"), version, ki18n(description),
 | 
				
			||||||
                      K4AboutData::License_GPL, ki18n("(C) %{CURRENT_YEAR} %{AUTHOR}"), KLocalizedString(), 0, "%{EMAIL}");
 | 
					                      K4AboutData::License_GPL, ki18n("(C) %{CURRENT_YEAR} %{AUTHOR}"), KLocalizedString(), 0, "%{EMAIL}");
 | 
				
			||||||
    about.addAuthor( ki18n("%{AUTHOR}"), KLocalizedString(), "%{EMAIL}" );
 | 
					    about.addAuthor(ki18n("%{AUTHOR}"), KLocalizedString(), "%{EMAIL}");
 | 
				
			||||||
    QApplication app(argc, argv);
 | 
					    QApplication app(argc, argv);
 | 
				
			||||||
    QCommandLineParser parser;
 | 
					    QCommandLineParser parser;
 | 
				
			||||||
    K4AboutData::setApplicationData(aboutData);
 | 
					    K4AboutData::setApplicationData(aboutData);
 | 
				
			||||||
| 
						 | 
					@ -48,28 +48,21 @@ int main(int argc, char **argv)
 | 
				
			||||||
    parser.process(app);
 | 
					    parser.process(app);
 | 
				
			||||||
    aboutData.processCommandLine(&parser);
 | 
					    aboutData.processCommandLine(&parser);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    parser.addOption(QCommandLineOption(QStringList() <<  QLatin1String("+[URL]"), i18n( "Document to open" )));
 | 
					    parser.addOption(QCommandLineOption(QStringList() <<  QLatin1String("+[URL]"), i18n("Document to open")));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    danbooru_client *widget = new danbooru_client;
 | 
					    danbooru_client *widget = new danbooru_client;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // see if we are starting with session management
 | 
					    // see if we are starting with session management
 | 
				
			||||||
    if (app.isSessionRestored())
 | 
					    if (app.isSessionRestored()) {
 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        RESTORE(danbooru_client);
 | 
					        RESTORE(danbooru_client);
 | 
				
			||||||
    }
 | 
					    } else {
 | 
				
			||||||
    else
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        // no session.. just start up normally
 | 
					        // no session.. just start up normally
 | 
				
			||||||
        if (parser.positionalArguments().count() == 0)
 | 
					        if (parser.positionalArguments().count() == 0) {
 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            //danbooru_client *widget = new danbooru_client;
 | 
					            //danbooru_client *widget = new danbooru_client;
 | 
				
			||||||
            widget->show();
 | 
					            widget->show();
 | 
				
			||||||
        }
 | 
					        } else {
 | 
				
			||||||
        else
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            int i = 0;
 | 
					            int i = 0;
 | 
				
			||||||
            for (; i < parser.positionalArguments().count(); i++)
 | 
					            for (; i < parser.positionalArguments().count(); i++) {
 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                //danbooru_client *widget = new danbooru_client;
 | 
					                //danbooru_client *widget = new danbooru_client;
 | 
				
			||||||
                widget->show();
 | 
					                widget->show();
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -30,14 +30,15 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <KLocale>
 | 
					#include <KLocale>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Danbooru {
 | 
					namespace Danbooru
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    DanbooruMainWindow::DanbooruMainWindow()
 | 
					DanbooruMainWindow::DanbooruMainWindow()
 | 
				
			||||||
    : KXmlGuiWindow(),
 | 
					    : KXmlGuiWindow(),
 | 
				
			||||||
      m_view(new DanbooruClientView(this)),
 | 
					      m_view(new DanbooruClientView(this)),
 | 
				
			||||||
      m_service(0),
 | 
					      m_service(0),
 | 
				
			||||||
      m_model(new(DanbooruPostModel(this)))
 | 
					      m_model(new(DanbooruPostModel(this)))
 | 
				
			||||||
    {
 | 
					{
 | 
				
			||||||
    // tell the KXmlGuiWindow that this is indeed the main widget
 | 
					    // tell the KXmlGuiWindow that this is indeed the main widget
 | 
				
			||||||
    setCentralWidget(m_view);
 | 
					    setCentralWidget(m_view);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -54,24 +55,21 @@ namespace Danbooru {
 | 
				
			||||||
    // toolbar position, icon size, etc.
 | 
					    // toolbar position, icon size, etc.
 | 
				
			||||||
    setupGUI();
 | 
					    setupGUI();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					DanbooruMainWindow::~DanbooruMainWindow()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    DanbooruMainWindow::~DanbooruMainWindow()
 | 
					void DanbooruMainWindow::setupActions()
 | 
				
			||||||
    {
 | 
					{
 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void DanbooruMainWindow::setupActions()
 | 
					    QAction *connectAction = new QAction(
 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    QAction * connectAction = new QAction(
 | 
					 | 
				
			||||||
        QIcon::fromTheme(QLatin1String("document-open-remote")),
 | 
					        QIcon::fromTheme(QLatin1String("document-open-remote")),
 | 
				
			||||||
        i18n("Connect..."),
 | 
					        i18n("Connect..."),
 | 
				
			||||||
        this);
 | 
					        this);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    QAction * fetchAction = new QAction(QIcon::fromTheme(QLatin1String("download")),
 | 
					    QAction *fetchAction = new QAction(QIcon::fromTheme(QLatin1String("download")),
 | 
				
			||||||
                                       i18n("Download"), this);
 | 
					                                       i18n("Download"), this);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    connectAction->setShortcut(KStandardShortcut::open());
 | 
					    connectAction->setShortcut(KStandardShortcut::open());
 | 
				
			||||||
| 
						 | 
					@ -86,29 +84,28 @@ namespace Danbooru {
 | 
				
			||||||
    connect(connectAction, &QAction::triggered, this, &DanbooruMainWindow::connectToBoard);
 | 
					    connect(connectAction, &QAction::triggered, this, &DanbooruMainWindow::connectToBoard);
 | 
				
			||||||
    connect(fetch, SIGNAL(triggered(bool)), this, SLOT(downloadPosts()));
 | 
					    connect(fetch, SIGNAL(triggered(bool)), this, SLOT(downloadPosts()));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void DanbooruMainWindow::connectToBoard()
 | 
					void DanbooruMainWindow::connectToBoard()
 | 
				
			||||||
    {
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!m_view) {
 | 
					    if (!m_view) {
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void DanbooruMainWindow::downloadPosts()
 | 
					void DanbooruMainWindow::downloadPosts()
 | 
				
			||||||
    {
 | 
					{
 | 
				
			||||||
    if (!m_service) {
 | 
					    if (!m_service) {
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    }
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void DanbooruMainWindow::optionsPreferences()
 | 
					void DanbooruMainWindow::optionsPreferences()
 | 
				
			||||||
    {
 | 
					{
 | 
				
			||||||
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
} // namespace Danbooru
 | 
					} // namespace Danbooru
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -23,17 +23,17 @@
 | 
				
			||||||
#ifndef DANBOORU_CLIENT_H
 | 
					#ifndef DANBOORU_CLIENT_H
 | 
				
			||||||
#define DANBOORU_CLIENT_H
 | 
					#define DANBOORU_CLIENT_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
#include <KXmlGuiWindow>
 | 
					#include <KXmlGuiWindow>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Danbooru {
 | 
					namespace Danbooru
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    class DanbooruClientView;
 | 
					class DanbooruClientView;
 | 
				
			||||||
    class DanbooruService;
 | 
					class DanbooruService;
 | 
				
			||||||
    class DanbooruPostModel;
 | 
					class DanbooruPostModel;
 | 
				
			||||||
    class DanbooruConnectWidget;
 | 
					class DanbooruConnectWidget;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					/**
 | 
				
			||||||
 * This class serves as the main window for danbooru_client.  It handles the
 | 
					 * This class serves as the main window for danbooru_client.  It handles the
 | 
				
			||||||
 * menus, toolbars and status bars.
 | 
					 * menus, toolbars and status bars.
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
| 
						 | 
					@ -41,10 +41,10 @@ namespace Danbooru {
 | 
				
			||||||
 * @author Luca Beltrame <lbeltrame@kde.org>
 | 
					 * @author Luca Beltrame <lbeltrame@kde.org>
 | 
				
			||||||
 * @version 0.01
 | 
					 * @version 0.01
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
    class DanbooruMainWindow : public KXmlGuiWindow
 | 
					class DanbooruMainWindow : public KXmlGuiWindow
 | 
				
			||||||
    {
 | 
					{
 | 
				
			||||||
    Q_OBJECT
 | 
					    Q_OBJECT
 | 
				
			||||||
    public:
 | 
					public:
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Default Constructor
 | 
					     * Default Constructor
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
| 
						 | 
					@ -55,23 +55,22 @@ namespace Danbooru {
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    virtual ~DanbooruMainWindow();
 | 
					    virtual ~DanbooruMainWindow();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private Q_SLOTS:
 | 
					private Q_SLOTS:
 | 
				
			||||||
    void connectToBoard();
 | 
					    void connectToBoard();
 | 
				
			||||||
    void downloadPosts();
 | 
					    void downloadPosts();
 | 
				
			||||||
    void optionsPreferences();
 | 
					    void optionsPreferences();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private:
 | 
					private:
 | 
				
			||||||
    void setupActions();
 | 
					    void setupActions();
 | 
				
			||||||
    void setupConnections();
 | 
					    void setupConnections();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private:
 | 
					private:
 | 
				
			||||||
    DanbooruClientView *m_view;
 | 
					    DanbooruClientView *m_view;
 | 
				
			||||||
        DanbooruPostModel* m_model;
 | 
					    DanbooruPostModel *m_model;
 | 
				
			||||||
        DanbooruService* m_service;
 | 
					    DanbooruService *m_service;
 | 
				
			||||||
        DanbooruConnectWidget* m_connectWidget;
 | 
					    DanbooruConnectWidget *m_connectWidget;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
    };
 | 
					 | 
				
			||||||
} // namespace Danbooru
 | 
					} // namespace Danbooru
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif // _DANBOORU_CLIENT_H_
 | 
					#endif // _DANBOORU_CLIENT_H_
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -39,14 +39,14 @@
 | 
				
			||||||
#include <KIconLoader>
 | 
					#include <KIconLoader>
 | 
				
			||||||
#include <KFormat>
 | 
					#include <KFormat>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace Danbooru
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Danbooru {
 | 
					const int DanbooruPostDelegate::MARGIN = 5;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const int DanbooruPostDelegate::MARGIN = 5;
 | 
					DanbooruPostDelegate::DanbooruPostDelegate(QListView *itemView): QStyledItemDelegate(itemView),
 | 
				
			||||||
 | 
					 | 
				
			||||||
    DanbooruPostDelegate::DanbooruPostDelegate(QListView* itemView):QStyledItemDelegate(itemView),
 | 
					 | 
				
			||||||
    m_itemView(itemView)
 | 
					    m_itemView(itemView)
 | 
				
			||||||
    {
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Get the sizes for the buttons
 | 
					    // Get the sizes for the buttons
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -78,12 +78,12 @@ namespace Danbooru {
 | 
				
			||||||
    connect(m_viewButton, &QPushButton::clicked, this, &DanbooruPostDelegate::viewButtonClicked);
 | 
					    connect(m_viewButton, &QPushButton::clicked, this, &DanbooruPostDelegate::viewButtonClicked);
 | 
				
			||||||
    connect(m_downloadButton, &QPushButton::clicked, this, &DanbooruPostDelegate::downloadButtonClicked);
 | 
					    connect(m_downloadButton, &QPushButton::clicked, this, &DanbooruPostDelegate::downloadButtonClicked);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void DanbooruPostDelegate::paint(QPainter* painter,
 | 
					void DanbooruPostDelegate::paint(QPainter *painter,
 | 
				
			||||||
                                     const QStyleOptionViewItem& option,
 | 
					                                 const QStyleOptionViewItem &option,
 | 
				
			||||||
                                     const QModelIndex& index) const
 | 
					                                 const QModelIndex &index) const
 | 
				
			||||||
    {
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!index.isValid()) {
 | 
					    if (!index.isValid()) {
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
| 
						 | 
					@ -124,7 +124,6 @@ namespace Danbooru {
 | 
				
			||||||
                           Qt::KeepAspectRatio,
 | 
					                           Qt::KeepAspectRatio,
 | 
				
			||||||
                           Qt::SmoothTransformation);
 | 
					                           Qt::SmoothTransformation);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    QRect pixRect = scaled.rect();
 | 
					    QRect pixRect = scaled.rect();
 | 
				
			||||||
    pixRect.moveCenter(rect.center());
 | 
					    pixRect.moveCenter(rect.center());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -161,7 +160,7 @@ namespace Danbooru {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Text
 | 
					    // Text
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        DanbooruPost* post = index.data().value<Danbooru::DanbooruPost*>();
 | 
					    DanbooruPost *post = index.data().value<Danbooru::DanbooruPost *>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    painter->save();
 | 
					    painter->save();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -203,11 +202,11 @@ namespace Danbooru {
 | 
				
			||||||
    painter->drawText(textRect, imageText);
 | 
					    painter->drawText(textRect, imageText);
 | 
				
			||||||
    painter->restore();
 | 
					    painter->restore();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    QSize DanbooruPostDelegate::sizeHint(const QStyleOptionViewItem& option,
 | 
					QSize DanbooruPostDelegate::sizeHint(const QStyleOptionViewItem &option,
 | 
				
			||||||
                                         const QModelIndex& index) const
 | 
					                                     const QModelIndex &index) const
 | 
				
			||||||
    {
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Q_UNUSED(option)
 | 
					    Q_UNUSED(option)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -217,16 +216,16 @@ namespace Danbooru {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return m_itemView->gridSize();
 | 
					    return m_itemView->gridSize();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    QModelIndex DanbooruPostDelegate::hoveredIndex() const
 | 
					QModelIndex DanbooruPostDelegate::hoveredIndex() const
 | 
				
			||||||
    {
 | 
					{
 | 
				
			||||||
    const QPoint pos = m_itemView->viewport()->mapFromGlobal(QCursor::pos());
 | 
					    const QPoint pos = m_itemView->viewport()->mapFromGlobal(QCursor::pos());
 | 
				
			||||||
    return m_itemView->indexAt(pos);
 | 
					    return m_itemView->indexAt(pos);
 | 
				
			||||||
    }
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void DanbooruPostDelegate::downloadButtonClicked()
 | 
					void DanbooruPostDelegate::downloadButtonClicked()
 | 
				
			||||||
    {
 | 
					{
 | 
				
			||||||
    QModelIndex index = hoveredIndex();
 | 
					    QModelIndex index = hoveredIndex();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!index.isValid()) {
 | 
					    if (!index.isValid()) {
 | 
				
			||||||
| 
						 | 
					@ -234,15 +233,15 @@ namespace Danbooru {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    QVariant data = index.data(Qt::DisplayRole);
 | 
					    QVariant data = index.data(Qt::DisplayRole);
 | 
				
			||||||
        const DanbooruPost* post = data.value<DanbooruPost*>();
 | 
					    const DanbooruPost *post = data.value<DanbooruPost *>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (post) {
 | 
					    if (post) {
 | 
				
			||||||
        Q_EMIT(postDownloadRequested(post->fileUrl()));
 | 
					        Q_EMIT(postDownloadRequested(post->fileUrl()));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    }
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void DanbooruPostDelegate::viewButtonClicked()
 | 
					void DanbooruPostDelegate::viewButtonClicked()
 | 
				
			||||||
    {
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    QModelIndex index = hoveredIndex();
 | 
					    QModelIndex index = hoveredIndex();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -251,11 +250,10 @@ namespace Danbooru {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    QVariant data = index.data(Qt::DisplayRole);
 | 
					    QVariant data = index.data(Qt::DisplayRole);
 | 
				
			||||||
        const DanbooruPost* post = data.value<DanbooruPost*>();
 | 
					    const DanbooruPost *post = data.value<DanbooruPost *>();
 | 
				
			||||||
    if (post) {
 | 
					    if (post) {
 | 
				
			||||||
        Q_EMIT(postViewRequested(post->fileUrl()));
 | 
					        Q_EMIT(postViewRequested(post->fileUrl()));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    }
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
} // namespace Danbooru
 | 
					} // namespace Danbooru
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -37,41 +37,41 @@ class QListView;
 | 
				
			||||||
class QPainter;
 | 
					class QPainter;
 | 
				
			||||||
class QPushButton;
 | 
					class QPushButton;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace Danbooru
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Danbooru {
 | 
					/**
 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
 * @brief Specific delegate for Danbooru items.
 | 
					 * @brief Specific delegate for Danbooru items.
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    class DanbooruPost;
 | 
					class DanbooruPost;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    class DanbooruPostDelegate : public QStyledItemDelegate
 | 
					class DanbooruPostDelegate : public QStyledItemDelegate
 | 
				
			||||||
    {
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Q_OBJECT
 | 
					    Q_OBJECT
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public:
 | 
					public:
 | 
				
			||||||
       DanbooruPostDelegate(QListView* itemView);
 | 
					    DanbooruPostDelegate(QListView *itemView);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
       void paint(QPainter* painter, const QStyleOptionViewItem& option,
 | 
					    void paint(QPainter *painter, const QStyleOptionViewItem &option,
 | 
				
			||||||
                   const QModelIndex& index) const;
 | 
					               const QModelIndex &index) const;
 | 
				
			||||||
       QSize sizeHint(const QStyleOptionViewItem& option,
 | 
					    QSize sizeHint(const QStyleOptionViewItem &option,
 | 
				
			||||||
                       const QModelIndex& index) const;
 | 
					                   const QModelIndex &index) const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    QModelIndex hoveredIndex() const;
 | 
					    QModelIndex hoveredIndex() const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private:
 | 
					private:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        QListView* m_itemView;
 | 
					    QListView *m_itemView;
 | 
				
			||||||
        QPushButton* m_downloadButton;
 | 
					    QPushButton *m_downloadButton;
 | 
				
			||||||
        QPushButton* m_viewButton;
 | 
					    QPushButton *m_viewButton;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    int m_buttonSize;
 | 
					    int m_buttonSize;
 | 
				
			||||||
    static const int MARGIN;
 | 
					    static const int MARGIN;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Q_SIGNALS:
 | 
					Q_SIGNALS:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * @brief Emitted when the view button is clicked.
 | 
					     * @brief Emitted when the view button is clicked.
 | 
				
			||||||
| 
						 | 
					@ -81,7 +81,6 @@ namespace Danbooru {
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    void postViewRequested(QUrl postUrl);
 | 
					    void postViewRequested(QUrl postUrl);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * @brief Emitted when the download button is clicked.
 | 
					     * @brief Emitted when the download button is clicked.
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
| 
						 | 
					@ -90,14 +89,11 @@ namespace Danbooru {
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    void postDownloadRequested(QUrl postUrl);
 | 
					    void postDownloadRequested(QUrl postUrl);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					private Q_SLOTS:
 | 
				
			||||||
    private Q_SLOTS:
 | 
					 | 
				
			||||||
    void viewButtonClicked();
 | 
					    void viewButtonClicked();
 | 
				
			||||||
    void downloadButtonClicked();
 | 
					    void downloadButtonClicked();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					 | 
				
			||||||
    };
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
} // namespace Danbooru
 | 
					} // namespace Danbooru
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -30,38 +30,39 @@
 | 
				
			||||||
#include <QDebug>
 | 
					#include <QDebug>
 | 
				
			||||||
#include <QPixmap>
 | 
					#include <QPixmap>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Danbooru {
 | 
					namespace Danbooru
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    DanbooruPostModel::DanbooruPostModel(QObject* parent): QAbstractListModel(parent)
 | 
					DanbooruPostModel::DanbooruPostModel(QObject *parent): QAbstractListModel(parent)
 | 
				
			||||||
    {
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    DanbooruPostModel::~DanbooruPostModel()
 | 
					DanbooruPostModel::~DanbooruPostModel()
 | 
				
			||||||
    {
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!m_items.isEmpty()) {
 | 
					    if (!m_items.isEmpty()) {
 | 
				
			||||||
        qDeleteAll(m_items);
 | 
					        qDeleteAll(m_items);
 | 
				
			||||||
        m_items.clear();
 | 
					        m_items.clear();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    }
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    int DanbooruPostModel::rowCount(const QModelIndex& parent) const
 | 
					int DanbooruPostModel::rowCount(const QModelIndex &parent) const
 | 
				
			||||||
    {
 | 
					{
 | 
				
			||||||
    Q_UNUSED(parent)
 | 
					    Q_UNUSED(parent)
 | 
				
			||||||
    return m_items.size();
 | 
					    return m_items.size();
 | 
				
			||||||
    }
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void DanbooruPostModel::addPost(Danbooru::DanbooruPost* post)
 | 
					void DanbooruPostModel::addPost(Danbooru::DanbooruPost *post)
 | 
				
			||||||
    {
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    beginInsertRows(QModelIndex(), m_items.size(), m_items.size());
 | 
					    beginInsertRows(QModelIndex(), m_items.size(), m_items.size());
 | 
				
			||||||
    m_items.append(post);
 | 
					    m_items.append(post);
 | 
				
			||||||
    endInsertRows();
 | 
					    endInsertRows();
 | 
				
			||||||
    }
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    QVariant DanbooruPostModel::data(const QModelIndex& index, int role) const
 | 
					QVariant DanbooruPostModel::data(const QModelIndex &index, int role) const
 | 
				
			||||||
    {
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!index.isValid()) {
 | 
					    if (!index.isValid()) {
 | 
				
			||||||
        return QVariant();
 | 
					        return QVariant();
 | 
				
			||||||
| 
						 | 
					@ -75,7 +76,7 @@ namespace Danbooru {
 | 
				
			||||||
        return QVariant();
 | 
					        return QVariant();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        DanbooruPost* post = m_items.at(index.row());
 | 
					    DanbooruPost *post = m_items.at(index.row());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!post) {
 | 
					    if (!post) {
 | 
				
			||||||
        return QVariant();
 | 
					        return QVariant();
 | 
				
			||||||
| 
						 | 
					@ -99,19 +100,20 @@ namespace Danbooru {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return QVariant();
 | 
					    return QVariant();
 | 
				
			||||||
    }
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void DanbooruPostModel::clear() {
 | 
					void DanbooruPostModel::clear()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (m_items.isEmpty()) {
 | 
					    if (m_items.isEmpty()) {
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        beginRemoveRows(QModelIndex(),0, m_items.size());
 | 
					    beginRemoveRows(QModelIndex(), 0, m_items.size());
 | 
				
			||||||
    qDeleteAll(m_items);
 | 
					    qDeleteAll(m_items);
 | 
				
			||||||
    m_items.clear();
 | 
					    m_items.clear();
 | 
				
			||||||
    endRemoveRows();
 | 
					    endRemoveRows();
 | 
				
			||||||
    reset();
 | 
					    reset();
 | 
				
			||||||
    }
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -32,11 +32,12 @@
 | 
				
			||||||
#include <QAbstractListModel>
 | 
					#include <QAbstractListModel>
 | 
				
			||||||
#include <QVector>
 | 
					#include <QVector>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Danbooru {
 | 
					namespace Danbooru
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    class DanbooruPost;
 | 
					class DanbooruPost;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					/**
 | 
				
			||||||
 * @brief A model to represent DanbooruItems
 | 
					 * @brief A model to represent DanbooruItems
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * Since items from a Danbooru service are sent by the service itself,
 | 
					 * Since items from a Danbooru service are sent by the service itself,
 | 
				
			||||||
| 
						 | 
					@ -46,23 +47,23 @@ namespace Danbooru {
 | 
				
			||||||
 * Items are added through the addPost() slot.
 | 
					 * Items are added through the addPost() slot.
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
    class DanbooruPostModel : public QAbstractListModel
 | 
					class DanbooruPostModel : public QAbstractListModel
 | 
				
			||||||
    {
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Q_OBJECT
 | 
					    Q_OBJECT
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public:
 | 
					public:
 | 
				
			||||||
        DanbooruPostModel(QObject* parent=0);
 | 
					    DanbooruPostModel(QObject *parent = 0);
 | 
				
			||||||
    ~DanbooruPostModel();
 | 
					    ~DanbooruPostModel();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        int rowCount(const QModelIndex& parent=QModelIndex()) const;
 | 
					    int rowCount(const QModelIndex &parent = QModelIndex()) const;
 | 
				
			||||||
        QVariant data(const QModelIndex& index, int role) const;
 | 
					    QVariant data(const QModelIndex &index, int role) const;
 | 
				
			||||||
    void clear();
 | 
					    void clear();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private:
 | 
					private:
 | 
				
			||||||
        QVector<DanbooruPost*> m_items;
 | 
					    QVector<DanbooruPost *> m_items;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public Q_SLOTS:
 | 
					public Q_SLOTS:
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * @brief Add a new post to the model
 | 
					     * @brief Add a new post to the model
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
| 
						 | 
					@ -71,10 +72,9 @@ namespace Danbooru {
 | 
				
			||||||
     * @param post A pointer to a DanbooruPost.
 | 
					     * @param post A pointer to a DanbooruPost.
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
        void addPost(Danbooru::DanbooruPost* post);
 | 
					    void addPost(Danbooru::DanbooruPost *post);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    };
 | 
					};
 | 
				
			||||||
}; // namespace Danbooru
 | 
					}; // namespace Danbooru
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
#endif // DANBOORUPOSTMODEL_H
 | 
					#endif // DANBOORUPOSTMODEL_H
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue