Use kdelibs coding style
This commit is contained in:
		
					parent
					
						
							
								0084798a2c
							
						
					
				
			
			
				commit
				
					
						d965371d23
					
				
			
		
					 31 changed files with 201 additions and 234 deletions
				
			
		| 
						 | 
					@ -20,7 +20,8 @@
 | 
				
			||||||
#include "blacklistpage.h"
 | 
					#include "blacklistpage.h"
 | 
				
			||||||
#include "danboorusettings.h"
 | 
					#include "danboorusettings.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Danbooru {
 | 
					namespace Danbooru
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
BlacklistPage::BlacklistPage(DanbooruSettings *preferences, QWidget *parent): QWidget(parent)
 | 
					BlacklistPage::BlacklistPage(DanbooruSettings *preferences, QWidget *parent): QWidget(parent)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -29,10 +30,8 @@ BlacklistPage::BlacklistPage(DanbooruSettings *preferences, QWidget *parent): QW
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
BlacklistPage::~BlacklistPage()
 | 
					BlacklistPage::~BlacklistPage()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
} // namespace Danbooru
 | 
					} // namespace Danbooru
 | 
				
			||||||
| 
						 | 
					@ -22,22 +22,22 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "ui_blacklistpage.h"
 | 
					#include "ui_blacklistpage.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Danbooru {
 | 
					namespace Danbooru
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class DanbooruSettings;
 | 
					class DanbooruSettings;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class BlacklistPage: public QWidget, public Ui::BlacklistPage {
 | 
					class BlacklistPage: public QWidget, public Ui::BlacklistPage
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Q_OBJECT
 | 
					    Q_OBJECT
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
    explicit BlacklistPage(DanbooruSettings *preferences, QWidget* parent=0);
 | 
					    explicit BlacklistPage(DanbooruSettings *preferences, QWidget *parent = 0);
 | 
				
			||||||
    ~BlacklistPage();
 | 
					    ~BlacklistPage();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
} // namespace Danbooru
 | 
					} // namespace Danbooru
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -63,7 +63,7 @@ int main(int argc, char *argv[])
 | 
				
			||||||
    cmdParser.process(app);
 | 
					    cmdParser.process(app);
 | 
				
			||||||
    aboutData.processCommandLine(&cmdParser);
 | 
					    aboutData.processCommandLine(&cmdParser);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Danbooru::DanbooruMainWindow* window = new Danbooru::DanbooruMainWindow();
 | 
					    Danbooru::DanbooruMainWindow *window = new Danbooru::DanbooruMainWindow();
 | 
				
			||||||
    window->setObjectName("danbooruMainWindow");
 | 
					    window->setObjectName("danbooruMainWindow");
 | 
				
			||||||
    window->show();
 | 
					    window->show();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -20,4 +20,3 @@
 | 
				
			||||||
#include "danbooru_client_debug.h"
 | 
					#include "danbooru_client_debug.h"
 | 
				
			||||||
Q_LOGGING_CATEGORY(DANBOORU_CLIENT, "org.dennogumi.danbooru_client")
 | 
					Q_LOGGING_CATEGORY(DANBOORU_CLIENT, "org.dennogumi.danbooru_client")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -89,7 +89,9 @@ DanbooruConnectWidget::DanbooruConnectWidget(QVector< QUrl > urlList,
 | 
				
			||||||
    connect(anonCheckBox, &QCheckBox::stateChanged, this, &DanbooruConnectWidget::toggleLineEdits);
 | 
					    connect(anonCheckBox, &QCheckBox::stateChanged, this, &DanbooruConnectWidget::toggleLineEdits);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    connect(buttonBox, &QDialogButtonBox::accepted, this, &DanbooruConnectWidget::accept);
 | 
					    connect(buttonBox, &QDialogButtonBox::accepted, this, &DanbooruConnectWidget::accept);
 | 
				
			||||||
    connect(closeButton, &QPushButton::clicked, [this]() {Q_EMIT(rejected());} );
 | 
					    connect(closeButton, &QPushButton::clicked, [this]() {
 | 
				
			||||||
 | 
					        Q_EMIT(rejected());
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -155,7 +157,8 @@ void DanbooruConnectWidget::toggleLineEdits(int state)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void DanbooruConnectWidget::setBoards(const QVector<QUrl> &urlList) {
 | 
					void DanbooruConnectWidget::setBoards(const QVector<QUrl> &urlList)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    danbooruUrlComboBox->clear();
 | 
					    danbooruUrlComboBox->clear();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -212,7 +215,8 @@ void DanbooruConnectWidget::accept()
 | 
				
			||||||
    Q_EMIT(accepted());
 | 
					    Q_EMIT(accepted());
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool DanbooruConnectWidget::isAnonymous() const {
 | 
					bool DanbooruConnectWidget::isAnonymous() const
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return anonCheckBox->isChecked();
 | 
					    return anonCheckBox->isChecked();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -22,15 +22,18 @@
 | 
				
			||||||
#include <QPushButton>
 | 
					#include <QPushButton>
 | 
				
			||||||
#include <QLineEdit>
 | 
					#include <QLineEdit>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Danbooru {
 | 
					namespace Danbooru
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
DanbooruSearchWidget::DanbooruSearchWidget(QWidget* parent): QWidget(parent)
 | 
					DanbooruSearchWidget::DanbooruSearchWidget(QWidget *parent): QWidget(parent)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    setupUi(this);
 | 
					    setupUi(this);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    connect(searchButton, &QPushButton::clicked, this, &DanbooruSearchWidget::accept);
 | 
					    connect(searchButton, &QPushButton::clicked, this, &DanbooruSearchWidget::accept);
 | 
				
			||||||
    connect(tagLineEdit, &QLineEdit::returnPressed, this, &DanbooruSearchWidget::accept);
 | 
					    connect(tagLineEdit, &QLineEdit::returnPressed, this, &DanbooruSearchWidget::accept);
 | 
				
			||||||
    connect(closeButton, &QPushButton::clicked, [this]() { Q_EMIT(rejected()); });
 | 
					    connect(closeButton, &QPushButton::clicked, [this]() {
 | 
				
			||||||
 | 
					        Q_EMIT(rejected());
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -43,9 +46,10 @@ QStringList DanbooruSearchWidget::selectedTags() const
 | 
				
			||||||
    return m_tags;
 | 
					    return m_tags;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void DanbooruSearchWidget::accept() {
 | 
					void DanbooruSearchWidget::accept()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if(tagLineEdit->text().isEmpty()) {
 | 
					    if (tagLineEdit->text().isEmpty()) {
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -53,5 +57,4 @@ void DanbooruSearchWidget::accept() {
 | 
				
			||||||
    Q_EMIT(accepted());
 | 
					    Q_EMIT(accepted());
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
} // namespace Danbooru
 | 
					} // namespace Danbooru
 | 
				
			||||||
| 
						 | 
					@ -22,30 +22,31 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "ui_searchwidget.h"
 | 
					#include "ui_searchwidget.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Danbooru {
 | 
					namespace Danbooru
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    class DanbooruSearchWidget: public QWidget, Ui::SearchWidget {
 | 
					class DanbooruSearchWidget: public QWidget, Ui::SearchWidget
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Q_OBJECT
 | 
					    Q_OBJECT
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public:
 | 
					public:
 | 
				
			||||||
    explicit DanbooruSearchWidget(QWidget *parent = 0);
 | 
					    explicit DanbooruSearchWidget(QWidget *parent = 0);
 | 
				
			||||||
    ~DanbooruSearchWidget();
 | 
					    ~DanbooruSearchWidget();
 | 
				
			||||||
    QStringList selectedTags() const;
 | 
					    QStringList selectedTags() const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private:
 | 
					private:
 | 
				
			||||||
    QStringList m_tags;
 | 
					    QStringList m_tags;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private Q_SLOTS:
 | 
					private Q_SLOTS:
 | 
				
			||||||
    void accept();
 | 
					    void accept();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Q_SIGNALS:
 | 
					Q_SIGNALS:
 | 
				
			||||||
    void accepted();
 | 
					    void accepted();
 | 
				
			||||||
    void rejected();
 | 
					    void rejected();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    };
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
} // namespace Danbooru
 | 
					} // namespace Danbooru
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					@ -21,7 +21,8 @@
 | 
				
			||||||
#include "model/danboorutagmodel.h"
 | 
					#include "model/danboorutagmodel.h"
 | 
				
			||||||
#include "libdanbooru/danboorutag.h"
 | 
					#include "libdanbooru/danboorutag.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Danbooru {
 | 
					namespace Danbooru
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
DanbooruTagWidget::DanbooruTagWidget(QWidget *parent): QListView(parent)
 | 
					DanbooruTagWidget::DanbooruTagWidget(QWidget *parent): QListView(parent)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -38,7 +39,7 @@ void DanbooruTagWidget::addTag(DanbooruTag *tag)
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    qobject_cast<DanbooruTagModel*>(model())->addTag(tag);
 | 
					    qobject_cast<DanbooruTagModel *>(model())->addTag(tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -23,22 +23,23 @@
 | 
				
			||||||
#include <QListView>
 | 
					#include <QListView>
 | 
				
			||||||
#include <QStringList>
 | 
					#include <QStringList>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Danbooru {
 | 
					namespace Danbooru
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class DanbooruTag;
 | 
					class DanbooruTag;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class DanbooruTagWidget: public QListView
 | 
					class DanbooruTagWidget: public QListView
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Q_OBJECT
 | 
					    Q_OBJECT
 | 
				
			||||||
 | 
					
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
    QStringList m_blacklist;
 | 
					    QStringList m_blacklist;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
    explicit DanbooruTagWidget(QWidget *parent=0);
 | 
					    explicit DanbooruTagWidget(QWidget *parent = 0);
 | 
				
			||||||
    ~DanbooruTagWidget();
 | 
					    ~DanbooruTagWidget();
 | 
				
			||||||
    void setBlackList(const QStringList& blacklist);
 | 
					    void setBlackList(const QStringList &blacklist);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public Q_SLOTS:
 | 
					public Q_SLOTS:
 | 
				
			||||||
    void addTag(DanbooruTag *tag);
 | 
					    void addTag(DanbooruTag *tag);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -27,14 +27,15 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static QLatin1String urlRegex("(http|https):\\/\\/[\\w\\-_]+(\\.[\\w\\-_]+)+([\\w\\-\\.,@?^=%&:/~\\+#]*[\\w\\-\\@?^=%&/~\\+#])?");
 | 
					static QLatin1String urlRegex("(http|https):\\/\\/[\\w\\-_]+(\\.[\\w\\-_]+)+([\\w\\-\\.,@?^=%&:/~\\+#]*[\\w\\-\\@?^=%&/~\\+#])?");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Danbooru {
 | 
					namespace Danbooru
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
GeneralPage::GeneralPage(DanbooruSettings* preferences, QWidget* parent): QWidget(parent)
 | 
					GeneralPage::GeneralPage(DanbooruSettings *preferences, QWidget *parent): QWidget(parent)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    setupUi(this);
 | 
					    setupUi(this);
 | 
				
			||||||
    kcfg_Boards->insertStringList(preferences->boards());
 | 
					    kcfg_Boards->insertStringList(preferences->boards());
 | 
				
			||||||
    QRegularExpression regex(urlRegex);
 | 
					    QRegularExpression regex(urlRegex);
 | 
				
			||||||
    QRegularExpressionValidator* validator = new QRegularExpressionValidator(regex);
 | 
					    QRegularExpressionValidator *validator = new QRegularExpressionValidator(regex);
 | 
				
			||||||
    kcfg_Boards->lineEdit()->setValidator(validator);
 | 
					    kcfg_Boards->lineEdit()->setValidator(validator);
 | 
				
			||||||
    kcfg_MaxRating->setCurrentIndex(preferences->maxRating());
 | 
					    kcfg_MaxRating->setCurrentIndex(preferences->maxRating());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -44,5 +45,4 @@ GeneralPage::~GeneralPage()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
} // namespace Danbooru
 | 
					} // namespace Danbooru
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -22,16 +22,18 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "ui_generalpage.h"
 | 
					#include "ui_generalpage.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Danbooru {
 | 
					namespace Danbooru
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class DanbooruSettings;
 | 
					class DanbooruSettings;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class GeneralPage: public QWidget, public Ui::GeneralPage {
 | 
					class GeneralPage: public QWidget, public Ui::GeneralPage
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Q_OBJECT
 | 
					    Q_OBJECT
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
    explicit GeneralPage(DanbooruSettings* preferences, QWidget* parent=0);
 | 
					    explicit GeneralPage(DanbooruSettings *preferences, QWidget *parent = 0);
 | 
				
			||||||
    ~GeneralPage();
 | 
					    ~GeneralPage();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -17,13 +17,11 @@
 | 
				
			||||||
 * along with Danbooru Client. If not, see <http://www.gnu.org/licenses/>.
 | 
					 * along with Danbooru Client. If not, see <http://www.gnu.org/licenses/>.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifndef DANBOORU_H
 | 
					#ifndef DANBOORU_H
 | 
				
			||||||
#define DANBOORU_H
 | 
					#define DANBOORU_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "libdanbooru_version.h"
 | 
					#include "libdanbooru_version.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * @brief The Danbooru namespace.
 | 
					 * @brief The Danbooru namespace.
 | 
				
			||||||
 * @file danbooru.h
 | 
					 * @file danbooru.h
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -17,7 +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 "danboorupool.h"
 | 
					#include "danboorupool.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Danbooru
 | 
					namespace Danbooru
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -17,7 +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/>.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifndef DANBOORUPOOL_H
 | 
					#ifndef DANBOORUPOOL_H
 | 
				
			||||||
#define DANBOORUPOOL_H
 | 
					#define DANBOORUPOOL_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -104,6 +103,6 @@ public:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
} // namespace Danbooru
 | 
					} // namespace Danbooru
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Q_DECLARE_METATYPE(Danbooru::DanbooruPool*)
 | 
					Q_DECLARE_METATYPE(Danbooru::DanbooruPool *)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif // DANBOORUPOOL_H
 | 
					#endif // DANBOORUPOOL_H
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -17,7 +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/>.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
// Qt
 | 
					// Qt
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <QtCore/QString>
 | 
					#include <QtCore/QString>
 | 
				
			||||||
| 
						 | 
					@ -36,7 +35,7 @@ namespace Danbooru
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const QMap<QString, DanbooruPost::Rating> DanbooruPost::RATING_MAP = initRatingMap();
 | 
					const QMap<QString, DanbooruPost::Rating> DanbooruPost::RATING_MAP = initRatingMap();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
DanbooruPost::DanbooruPost(QObject* parent): QObject(parent)
 | 
					DanbooruPost::DanbooruPost(QObject *parent): QObject(parent)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    m_pixmap = QPixmap();
 | 
					    m_pixmap = QPixmap();
 | 
				
			||||||
    m_tags = QSet<QString>();
 | 
					    m_tags = QSet<QString>();
 | 
				
			||||||
| 
						 | 
					@ -48,7 +47,6 @@ DanbooruPost::DanbooruPost(QObject* parent): QObject(parent)
 | 
				
			||||||
    m_rating = Questionable;
 | 
					    m_rating = Questionable;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
DanbooruPost::DanbooruPost(QVariantMap postData, QPixmap pixmap,
 | 
					DanbooruPost::DanbooruPost(QVariantMap postData, QPixmap pixmap,
 | 
				
			||||||
                           QObject *parent):
 | 
					                           QObject *parent):
 | 
				
			||||||
    QObject(parent),
 | 
					    QObject(parent),
 | 
				
			||||||
| 
						 | 
					@ -149,7 +147,6 @@ const QUrl DanbooruPost::sampleUrl() const
 | 
				
			||||||
    return m_sampleUrl;
 | 
					    return m_sampleUrl;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
QPixmap DanbooruPost::pixmap() const
 | 
					QPixmap DanbooruPost::pixmap() const
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    return m_pixmap;
 | 
					    return m_pixmap;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -17,7 +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/>.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifndef DANBOORUPOST_H
 | 
					#ifndef DANBOORUPOST_H
 | 
				
			||||||
#define DANBOORUPOST_H
 | 
					#define DANBOORUPOST_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -90,7 +89,6 @@ public:
 | 
				
			||||||
    Q_DECLARE_FLAGS(Ratings, DanbooruPost::Rating)
 | 
					    Q_DECLARE_FLAGS(Ratings, DanbooruPost::Rating)
 | 
				
			||||||
    Q_ENUMS(Rating)
 | 
					    Q_ENUMS(Rating)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    QPixmap m_pixmap;
 | 
					    QPixmap m_pixmap;
 | 
				
			||||||
| 
						 | 
					@ -133,7 +131,7 @@ public:
 | 
				
			||||||
    explicit DanbooruPost(QVariantMap postData, QPixmap pixmap = QPixmap(),
 | 
					    explicit DanbooruPost(QVariantMap postData, QPixmap pixmap = QPixmap(),
 | 
				
			||||||
                          QObject *parent = 0);
 | 
					                          QObject *parent = 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    explicit DanbooruPost(QObject* parent = 0);
 | 
					    explicit DanbooruPost(QObject *parent = 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * @brief Construct a Danbooru post from XML attributes
 | 
					     * @brief Construct a Danbooru post from XML attributes
 | 
				
			||||||
| 
						 | 
					@ -227,6 +225,5 @@ Q_DECLARE_METATYPE(Danbooru::DanbooruPost *)
 | 
				
			||||||
Q_DECLARE_METATYPE(Danbooru::DanbooruPost::Rating)
 | 
					Q_DECLARE_METATYPE(Danbooru::DanbooruPost::Rating)
 | 
				
			||||||
Q_DECLARE_METATYPE(QSet<QString>)
 | 
					Q_DECLARE_METATYPE(QSet<QString>)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
#endif // DANBOORUPOST_H
 | 
					#endif // DANBOORUPOST_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -17,7 +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/>.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
// STL
 | 
					// STL
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <algorithm>
 | 
					#include <algorithm>
 | 
				
			||||||
| 
						 | 
					@ -100,7 +99,6 @@ void DanbooruService::getPostList()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
void DanbooruService::getTagList(int limit, QString name)
 | 
					void DanbooruService::getTagList(int limit, QString name)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    QMap<QString, QString> parameters;
 | 
					    QMap<QString, QString> parameters;
 | 
				
			||||||
| 
						 | 
					@ -237,7 +235,6 @@ void DanbooruService::getRelatedTags(const QStringList &tags,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // qCDebug(LIBDANBOORU) << "Final constructed related tag URL" << danbooruUrl;
 | 
					    // qCDebug(LIBDANBOORU) << "Final constructed related tag URL" << danbooruUrl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    StoredTransferJob *job = KIO::storedGet(
 | 
					    StoredTransferJob *job = KIO::storedGet(
 | 
				
			||||||
                                 danbooruUrl, KIO::NoReload,
 | 
					                                 danbooruUrl, KIO::NoReload,
 | 
				
			||||||
                                 KIO::HideProgressInfo
 | 
					                                 KIO::HideProgressInfo
 | 
				
			||||||
| 
						 | 
					@ -291,7 +288,6 @@ void DanbooruService::getRelatedTags(const QStringList &tags,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
const QSet< QString > DanbooruService::blacklist() const
 | 
					const QSet< QString > DanbooruService::blacklist() const
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    return m_blacklist;
 | 
					    return m_blacklist;
 | 
				
			||||||
| 
						 | 
					@ -322,7 +318,6 @@ int DanbooruService::currentPage() const
 | 
				
			||||||
    return m_currentPage;
 | 
					    return m_currentPage;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
const DanbooruPost::Ratings DanbooruService::maximumAllowedRating() const
 | 
					const DanbooruPost::Ratings DanbooruService::maximumAllowedRating() const
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -347,7 +342,6 @@ void DanbooruService::nextPoolPage()
 | 
				
			||||||
    getPoolList();
 | 
					    getPoolList();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
QStringList DanbooruService::postTags() const
 | 
					QStringList DanbooruService::postTags() const
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    return m_tags;
 | 
					    return m_tags;
 | 
				
			||||||
| 
						 | 
					@ -362,7 +356,8 @@ void DanbooruService::reset()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Slots
 | 
					// Slots
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void DanbooruService::processTagList(KJob *job) {
 | 
					void DanbooruService::processTagList(KJob *job)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (job->error()) {
 | 
					    if (job->error()) {
 | 
				
			||||||
        Q_EMIT(downloadError(job->errorString()));
 | 
					        Q_EMIT(downloadError(job->errorString()));
 | 
				
			||||||
| 
						 | 
					@ -387,7 +382,7 @@ void DanbooruService::processTagList(KJob *job) {
 | 
				
			||||||
        QVariantMap map = element.toMap();
 | 
					        QVariantMap map = element.toMap();
 | 
				
			||||||
        DanbooruTag *tag = new DanbooruTag(map);
 | 
					        DanbooruTag *tag = new DanbooruTag(map);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(!tag) {
 | 
					        if (!tag) {
 | 
				
			||||||
            continue;
 | 
					            continue;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -437,7 +432,6 @@ 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);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -469,7 +463,6 @@ void DanbooruService::processPostList(KJob *job)
 | 
				
			||||||
            StoredTransferJob *pixmapJob = KIO::storedGet(post->thumbnailUrl(),
 | 
					            StoredTransferJob *pixmapJob = KIO::storedGet(post->thumbnailUrl(),
 | 
				
			||||||
                                           KIO::NoReload, KIO::HideProgressInfo);
 | 
					                                           KIO::NoReload, KIO::HideProgressInfo);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
            // We don't want to overload the servers, so set some rational
 | 
					            // We don't want to overload the servers, so set some rational
 | 
				
			||||||
            // priority
 | 
					            // priority
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -523,7 +516,6 @@ void DanbooruService::processPostList(KJob *job)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
void DanbooruService::downloadAllTags(KJob *job)
 | 
					void DanbooruService::downloadAllTags(KJob *job)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    Q_UNUSED(job)
 | 
					    Q_UNUSED(job)
 | 
				
			||||||
| 
						 | 
					@ -554,7 +546,7 @@ void DanbooruService::setBlacklist(const QStringList &blacklist)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void DanbooruService::setBoardUrl(const QUrl& url)
 | 
					void DanbooruService::setBoardUrl(const QUrl &url)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    m_url = url;
 | 
					    m_url = url;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -579,7 +571,7 @@ void DanbooruService::setMaximumAllowedRating(DanbooruPost::Rating rating)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void DanbooruService::setUserName(const QString& username)
 | 
					void DanbooruService::setUserName(const QString &username)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    if (username.isEmpty()) {
 | 
					    if (username.isEmpty()) {
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
| 
						 | 
					@ -587,34 +579,36 @@ void DanbooruService::setUserName(const QString& username)
 | 
				
			||||||
    m_username = username;
 | 
					    m_username = username;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void DanbooruService::setPassword(const QString& password)
 | 
					void DanbooruService::setPassword(const QString &password)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    if(password.isEmpty()) {
 | 
					    if (password.isEmpty()) {
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    m_password = password;
 | 
					    m_password = password;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void DanbooruService::setPostTags(const QStringList& tags)
 | 
					void DanbooruService::setPostTags(const QStringList &tags)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    if (!tags.isEmpty()) {
 | 
					    if (!tags.isEmpty()) {
 | 
				
			||||||
        m_tags = tags;
 | 
					        m_tags = tags;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void DanbooruService::setImageCache(KImageCache* cache)
 | 
					void DanbooruService::setImageCache(KImageCache *cache)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    m_cache = cache;
 | 
					    m_cache = cache;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void DanbooruService::setMaxPosts(int number) {
 | 
					void DanbooruService::setMaxPosts(int number)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    m_maxPosts = number < 100 ? number : 100;
 | 
					    m_maxPosts = number < 100 ? number : 100;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void DanbooruService::setCurrentPage(int page) {
 | 
					void DanbooruService::setCurrentPage(int page)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
    m_currentPage = page;
 | 
					    m_currentPage = page;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -17,7 +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/>.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifndef DANBOORUSERVICE_H
 | 
					#ifndef DANBOORUSERVICE_H
 | 
				
			||||||
#define DANBOORUSERVICE_H
 | 
					#define DANBOORUSERVICE_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -102,7 +101,6 @@ private:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * @brief Construct a default instance of the service.
 | 
					     * @brief Construct a default instance of the service.
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
| 
						 | 
					@ -114,7 +112,7 @@ public:
 | 
				
			||||||
     * @param parent The parent QObject
 | 
					     * @param parent The parent QObject
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
     **/
 | 
					     **/
 | 
				
			||||||
    DanbooruService(QUrl boardUrl=QUrl(), QString username = QString(),
 | 
					    DanbooruService(QUrl boardUrl = QUrl(), QString username = QString(),
 | 
				
			||||||
                    QString password = QString(), KImageCache *cache = 0,
 | 
					                    QString password = QString(), KImageCache *cache = 0,
 | 
				
			||||||
                    QObject *parent = 0);
 | 
					                    QObject *parent = 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -222,7 +220,7 @@ public:
 | 
				
			||||||
     * @param blacklist A QSet<QString> including unwanted tags.
 | 
					     * @param blacklist A QSet<QString> including unwanted tags.
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
     **/
 | 
					     **/
 | 
				
			||||||
    void setBlacklist(const QStringList& blacklist);
 | 
					    void setBlacklist(const QStringList &blacklist);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
    * @brief Set the tag blacklist.
 | 
					    * @brief Set the tag blacklist.
 | 
				
			||||||
| 
						 | 
					@ -231,7 +229,7 @@ public:
 | 
				
			||||||
    *
 | 
					    *
 | 
				
			||||||
    **/
 | 
					    **/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    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.
 | 
				
			||||||
| 
						 | 
					@ -248,7 +246,7 @@ public:
 | 
				
			||||||
     * @param url The URL to connect to.
 | 
					     * @param url The URL to connect to.
 | 
				
			||||||
     * @return void
 | 
					     * @return void
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    void setBoardUrl(const QUrl& url);
 | 
					    void setBoardUrl(const QUrl &url);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * @brief Set an image cache to use.
 | 
					     * @brief Set an image cache to use.
 | 
				
			||||||
| 
						 | 
					@ -264,7 +262,7 @@ public:
 | 
				
			||||||
     * @param username The username to use.
 | 
					     * @param username The username to use.
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
     **/
 | 
					     **/
 | 
				
			||||||
    void setUserName(const QString& username);
 | 
					    void setUserName(const QString &username);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * @brief Set the password used for login.
 | 
					     * @brief Set the password used for login.
 | 
				
			||||||
| 
						 | 
					@ -276,14 +274,13 @@ public:
 | 
				
			||||||
     * @param password The salted password to use.
 | 
					     * @param password The salted password to use.
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
     **/
 | 
					     **/
 | 
				
			||||||
    void setPassword(const QString& password);
 | 
					    void setPassword(const QString &password);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void setMaxPosts(int number);
 | 
					    void setMaxPosts(int number);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void setCurrentPage(int page);
 | 
					    void setCurrentPage(int page);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void setPostTags(const QStringList& tags);
 | 
					    void setPostTags(const QStringList &tags);
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
private Q_SLOTS:
 | 
					private Q_SLOTS:
 | 
				
			||||||
    void processPostList(KJob *job);
 | 
					    void processPostList(KJob *job);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -17,7 +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 "danboorutag.h"
 | 
					#include "danboorutag.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Danbooru
 | 
					namespace Danbooru
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -17,7 +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/>.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifndef DANBOORUTAG_H
 | 
					#ifndef DANBOORUTAG_H
 | 
				
			||||||
#define DANBOORUTAG_H
 | 
					#define DANBOORUTAG_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -78,5 +77,4 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(TagTypes)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Q_DECLARE_METATYPE(Danbooru::DanbooruTag *)
 | 
					Q_DECLARE_METATYPE(Danbooru::DanbooruTag *)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
#endif // DANBOORUTAG_H
 | 
					#endif // DANBOORUTAG_H
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -20,4 +20,3 @@
 | 
				
			||||||
#include "libdanbooru_debug.h"
 | 
					#include "libdanbooru_debug.h"
 | 
				
			||||||
Q_LOGGING_CATEGORY(LIBDANBOORU, "org.dennogumi.libdanbooru")
 | 
					Q_LOGGING_CATEGORY(LIBDANBOORU, "org.dennogumi.libdanbooru")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -17,7 +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/>.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
// Own
 | 
					// Own
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "utils.h"
 | 
					#include "utils.h"
 | 
				
			||||||
| 
						 | 
					@ -69,7 +68,6 @@ QUrl requestUrl(QUrl &url, const QString &path,
 | 
				
			||||||
        danbooruUrl.setPassword(password);
 | 
					        danbooruUrl.setPassword(password);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    return danbooruUrl;
 | 
					    return danbooruUrl;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -118,7 +116,7 @@ QUrl requestUrl(QUrl &url, const QString &path, const QString &username,
 | 
				
			||||||
    return danbooruUrl;
 | 
					    return danbooruUrl;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
QList< QVariant > parseDanbooruResult(QByteArray data, QString xlmElement, bool* result)
 | 
					QList< QVariant > parseDanbooruResult(QByteArray data, QString xlmElement, bool *result)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    QXmlStreamReader reader;
 | 
					    QXmlStreamReader reader;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -17,7 +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/>.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifndef UTILS_H
 | 
					#ifndef UTILS_H
 | 
				
			||||||
#define UTILS_H
 | 
					#define UTILS_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -108,7 +108,6 @@ DanbooruMainWindow::DanbooruMainWindow(QWidget *parent)
 | 
				
			||||||
    m_tableView->setModel(m_poolModel);
 | 
					    m_tableView->setModel(m_poolModel);
 | 
				
			||||||
    m_tagWidget->setModel(m_proxyModel);
 | 
					    m_tagWidget->setModel(m_proxyModel);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    // Set up declarative bindings for the QQuickWidget
 | 
					    // Set up declarative bindings for the QQuickWidget
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    m_view->setResizeMode(QQuickWidget::SizeRootObjectToView);
 | 
					    m_view->setResizeMode(QQuickWidget::SizeRootObjectToView);
 | 
				
			||||||
| 
						 | 
					@ -136,7 +135,7 @@ DanbooruMainWindow::DanbooruMainWindow(QWidget *parent)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // then, setup our actions
 | 
					    // then, setup our actions
 | 
				
			||||||
    setupActions();
 | 
					    setupActions();
 | 
				
			||||||
    setupGUI(KXmlGuiWindow::ToolBar|Keys|Save|Create, "danbooru-clientui.rc");
 | 
					    setupGUI(KXmlGuiWindow::ToolBar | Keys | Save | Create, "danbooru-clientui.rc");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // connections
 | 
					    // connections
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -192,7 +191,7 @@ DanbooruMainWindow::DanbooruMainWindow(QWidget *parent)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    connect(m_searchWidget, &DanbooruSearchWidget::accepted, [this]() {
 | 
					    connect(m_searchWidget, &DanbooruSearchWidget::accepted, [this]() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
       QDockWidget* searchDockWidget = findChild<QDockWidget*>(QLatin1String("SearchView"));
 | 
					        QDockWidget *searchDockWidget = findChild<QDockWidget *>(QLatin1String("SearchView"));
 | 
				
			||||||
        searchDockWidget->hide();
 | 
					        searchDockWidget->hide();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        handlePostDownload(m_searchWidget->selectedTags(), true /* relatedTags */);
 | 
					        handlePostDownload(m_searchWidget->selectedTags(), true /* relatedTags */);
 | 
				
			||||||
| 
						 | 
					@ -200,7 +199,7 @@ DanbooruMainWindow::DanbooruMainWindow(QWidget *parent)
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    connect(m_searchWidget, &DanbooruSearchWidget::rejected, [this]() {
 | 
					    connect(m_searchWidget, &DanbooruSearchWidget::rejected, [this]() {
 | 
				
			||||||
        QDockWidget* searchDockWidget = findChild<QDockWidget*>(QLatin1String("SearchView"));
 | 
					        QDockWidget *searchDockWidget = findChild<QDockWidget *>(QLatin1String("SearchView"));
 | 
				
			||||||
        searchDockWidget->hide();
 | 
					        searchDockWidget->hide();
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -208,7 +207,7 @@ DanbooruMainWindow::DanbooruMainWindow(QWidget *parent)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (m_tagModel->rowCount() == 0) {
 | 
					        if (m_tagModel->rowCount() == 0) {
 | 
				
			||||||
            // Only get tags if we don't have any already
 | 
					            // Only get tags if we don't have any already
 | 
				
			||||||
            for (auto tag: m_model->postTags()) {
 | 
					            for (auto tag : m_model->postTags()) {
 | 
				
			||||||
                m_service->getTagList(1, tag);
 | 
					                m_service->getTagList(1, tag);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
| 
						 | 
					@ -216,8 +215,8 @@ DanbooruMainWindow::DanbooruMainWindow(QWidget *parent)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    connect(m_view->rootObject(), SIGNAL(downloadRequested(const QUrl&, QVariant)), this,
 | 
					    connect(m_view->rootObject(), SIGNAL(downloadRequested(QUrl,QVariant)), this,
 | 
				
			||||||
            SLOT(slotHandleDownload(const QUrl&, QVariant)));
 | 
					            SLOT(slotHandleDownload(QUrl,QVariant)));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    connect(m_tagWidget, &QListView::doubleClicked, this, &DanbooruMainWindow::searchTag);
 | 
					    connect(m_tagWidget, &QListView::doubleClicked, this, &DanbooruMainWindow::searchTag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -240,7 +239,7 @@ void DanbooruMainWindow::loadSettings()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    QStringList::const_iterator it;
 | 
					    QStringList::const_iterator it;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for(it = DanbooruSettings::self()->boards().constBegin();
 | 
					    for (it = DanbooruSettings::self()->boards().constBegin();
 | 
				
			||||||
            it != DanbooruSettings::self()->boards().constEnd();
 | 
					            it != DanbooruSettings::self()->boards().constEnd();
 | 
				
			||||||
            ++it) {
 | 
					            ++it) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -261,7 +260,6 @@ void DanbooruMainWindow::loadSettings()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
void DanbooruMainWindow::setupActions()
 | 
					void DanbooruMainWindow::setupActions()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -281,7 +279,7 @@ void DanbooruMainWindow::setupActions()
 | 
				
			||||||
    QAction *nextPoolAction = new QAction(QIcon::fromTheme(QLatin1String("go-next")),
 | 
					    QAction *nextPoolAction = new QAction(QIcon::fromTheme(QLatin1String("go-next")),
 | 
				
			||||||
                                          i18n("More pools"), this);
 | 
					                                          i18n("More pools"), this);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    KDualAction* tagAction = new KDualAction(i18n("Show tags"), i18n("Hide tags"), this);
 | 
					    KDualAction *tagAction = new KDualAction(i18n("Show tags"), i18n("Hide tags"), this);
 | 
				
			||||||
    tagAction->setIconForStates(QIcon::fromTheme(QLatin1String("tag")));
 | 
					    tagAction->setIconForStates(QIcon::fromTheme(QLatin1String("tag")));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    fetchAction->setEnabled(false);
 | 
					    fetchAction->setEnabled(false);
 | 
				
			||||||
| 
						 | 
					@ -316,7 +314,7 @@ void DanbooruMainWindow::setupActions()
 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        QDockWidget* poolDockWidget = findChild<QDockWidget*>(QLatin1String("PoolView"));
 | 
					        QDockWidget *poolDockWidget = findChild<QDockWidget *>(QLatin1String("PoolView"));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (checked) {
 | 
					        if (checked) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -329,7 +327,6 @@ void DanbooruMainWindow::setupActions()
 | 
				
			||||||
            actionCollection()->action(QLatin1String("morePools"))->setEnabled(true);
 | 
					            actionCollection()->action(QLatin1String("morePools"))->setEnabled(true);
 | 
				
			||||||
            m_tableView->show();
 | 
					            m_tableView->show();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            poolDockWidget->hide();
 | 
					            poolDockWidget->hide();
 | 
				
			||||||
            actionCollection()->action(QLatin1String("morePools"))->setEnabled(false);
 | 
					            actionCollection()->action(QLatin1String("morePools"))->setEnabled(false);
 | 
				
			||||||
| 
						 | 
					@ -339,7 +336,7 @@ void DanbooruMainWindow::setupActions()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    connect(findAction, &KToggleAction::toggled, [this](bool checked) {
 | 
					    connect(findAction, &KToggleAction::toggled, [this](bool checked) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        QDockWidget* searchDockWidget = findChild<QDockWidget*>(QLatin1String("SearchView"));
 | 
					        QDockWidget *searchDockWidget = findChild<QDockWidget *>(QLatin1String("SearchView"));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (checked) {
 | 
					        if (checked) {
 | 
				
			||||||
            searchDockWidget->show();
 | 
					            searchDockWidget->show();
 | 
				
			||||||
| 
						 | 
					@ -353,7 +350,7 @@ void DanbooruMainWindow::setupActions()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    connect(tagAction, &KDualAction::activeChanged, [this](bool checked) {
 | 
					    connect(tagAction, &KDualAction::activeChanged, [this](bool checked) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        QDockWidget* tagDockWidget = findChild<QDockWidget*>(QLatin1String("TagView"));
 | 
					        QDockWidget *tagDockWidget = findChild<QDockWidget *>(QLatin1String("TagView"));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (checked) {
 | 
					        if (checked) {
 | 
				
			||||||
            tagDockWidget->show();
 | 
					            tagDockWidget->show();
 | 
				
			||||||
| 
						 | 
					@ -382,12 +379,12 @@ void DanbooruMainWindow::setupActions()
 | 
				
			||||||
           );
 | 
					           );
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void DanbooruMainWindow::setupDockWidgets()
 | 
				
			||||||
void DanbooruMainWindow::setupDockWidgets() {
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Set up PoolWidget
 | 
					    // Set up PoolWidget
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    QDockWidget* poolDockWidget = new QDockWidget(i18n("Pools"), this);
 | 
					    QDockWidget *poolDockWidget = new QDockWidget(i18n("Pools"), this);
 | 
				
			||||||
    poolDockWidget->setAllowedAreas(Qt::BottomDockWidgetArea);
 | 
					    poolDockWidget->setAllowedAreas(Qt::BottomDockWidgetArea);
 | 
				
			||||||
    poolDockWidget->setWidget(m_tableView);
 | 
					    poolDockWidget->setWidget(m_tableView);
 | 
				
			||||||
    poolDockWidget->setObjectName("PoolView");
 | 
					    poolDockWidget->setObjectName("PoolView");
 | 
				
			||||||
| 
						 | 
					@ -433,7 +430,7 @@ void DanbooruMainWindow::setupDockWidgets() {
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    connect(tagDockWidget, &QDockWidget::visibilityChanged, [this](bool visible) {
 | 
					    connect(tagDockWidget, &QDockWidget::visibilityChanged, [this](bool visible) {
 | 
				
			||||||
        qobject_cast<KDualAction*>(actionCollection()->action(QLatin1String("tags")))->setActive(visible);
 | 
					        qobject_cast<KDualAction *>(actionCollection()->action(QLatin1String("tags")))->setActive(visible);
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -459,14 +456,13 @@ void DanbooruMainWindow::downloadPosts()
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    handlePostDownload(QStringList(), false);
 | 
					    handlePostDownload(QStringList(), false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void DanbooruMainWindow::optionsPreferences()
 | 
					void DanbooruMainWindow::optionsPreferences()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    KConfigDialog* dialog = new KConfigDialog(this, "danboorusettings",
 | 
					    KConfigDialog *dialog = new KConfigDialog(this, "danboorusettings",
 | 
				
			||||||
            DanbooruSettings::self());
 | 
					            DanbooruSettings::self());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    dialog->addPage(new GeneralPage(DanbooruSettings::self(), this), i18n("General"),
 | 
					    dialog->addPage(new GeneralPage(DanbooruSettings::self(), this), i18n("General"),
 | 
				
			||||||
| 
						 | 
					@ -477,12 +473,12 @@ void DanbooruMainWindow::optionsPreferences()
 | 
				
			||||||
    dialog->show();
 | 
					    dialog->show();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void DanbooruMainWindow::slotHandleDownload(const QUrl &url, const QVariant tags) {
 | 
					void DanbooruMainWindow::slotHandleDownload(const QUrl &url, const QVariant tags)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    QStringList tagList = tags.toStringList();
 | 
					    QStringList tagList = tags.toStringList();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    KIO::MimetypeJob* mimeJob = KIO::mimetype(url, KIO::HideProgressInfo);
 | 
					    KIO::MimetypeJob *mimeJob = KIO::mimetype(url, KIO::HideProgressInfo);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    QString filters;
 | 
					    QString filters;
 | 
				
			||||||
    QString remoteFile = url.fileName();
 | 
					    QString remoteFile = url.fileName();
 | 
				
			||||||
| 
						 | 
					@ -506,24 +502,23 @@ void DanbooruMainWindow::slotHandleDownload(const QUrl &url, const QVariant tags
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                     );
 | 
					                     );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    // TODO: Remember last user directory - settings?
 | 
					    // TODO: Remember last user directory - settings?
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!localFile.isEmpty()) {
 | 
					    if (!localFile.isEmpty()) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        KIO::FileCopyJob *job = KIO::file_copy(url, localFile, -1, KIO::DefaultFlags);
 | 
					        KIO::FileCopyJob *job = KIO::file_copy(url, localFile, -1, KIO::DefaultFlags);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        connect(job, &KIO::Job::result, [this, localFile, tagList](KJob  *job) {
 | 
					        connect(job, &KIO::Job::result, [this, localFile, tagList](KJob  * job) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (job->error()) {
 | 
					            if (job->error()) {
 | 
				
			||||||
                return;
 | 
					                return;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            #ifdef WITH_KFILEMETADATA
 | 
					#ifdef WITH_KFILEMETADATA
 | 
				
			||||||
            qCDebug(DANBOORU_CLIENT) << "Local file" << localFile.toLocalFile();
 | 
					            qCDebug(DANBOORU_CLIENT) << "Local file" << localFile.toLocalFile();
 | 
				
			||||||
            KFileMetaData::UserMetaData meta(localFile.toLocalFile());
 | 
					            KFileMetaData::UserMetaData meta(localFile.toLocalFile());
 | 
				
			||||||
            meta.setTags(tagList);
 | 
					            meta.setTags(tagList);
 | 
				
			||||||
            #endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -554,14 +549,13 @@ void DanbooruMainWindow::clearModels()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
void DanbooruMainWindow::handlePostDownload(const QStringList &tags, bool relatedTags)
 | 
					void DanbooruMainWindow::handlePostDownload(const QStringList &tags, bool relatedTags)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    clearModels();
 | 
					    clearModels();
 | 
				
			||||||
    m_view->rootObject()->setProperty("poolMode", QVariant(false));
 | 
					    m_view->rootObject()->setProperty("poolMode", QVariant(false));
 | 
				
			||||||
    m_service->setPostTags(tags);
 | 
					    m_service->setPostTags(tags);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if(relatedTags) {
 | 
					    if (relatedTags) {
 | 
				
			||||||
        m_service->getRelatedTags(tags);
 | 
					        m_service->getRelatedTags(tags);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -32,12 +32,9 @@
 | 
				
			||||||
#include <KSharedDataCache>
 | 
					#include <KSharedDataCache>
 | 
				
			||||||
#include <KImageCache>
 | 
					#include <KImageCache>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
class QQuickWidget;
 | 
					class QQuickWidget;
 | 
				
			||||||
class QSortFilterProxyModel;
 | 
					class QSortFilterProxyModel;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
namespace Danbooru
 | 
					namespace Danbooru
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -81,7 +78,7 @@ public:
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Default Constructor
 | 
					     * Default Constructor
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    DanbooruMainWindow(QWidget* parent=0);
 | 
					    DanbooruMainWindow(QWidget *parent = 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Default Destructor
 | 
					     * Default Destructor
 | 
				
			||||||
| 
						 | 
					@ -93,7 +90,7 @@ private:
 | 
				
			||||||
    void setupDockWidgets();
 | 
					    void setupDockWidgets();
 | 
				
			||||||
    void setupConnections();
 | 
					    void setupConnections();
 | 
				
			||||||
    void clearModels();
 | 
					    void clearModels();
 | 
				
			||||||
    void handlePostDownload(const QStringList& tags = QStringList(), bool relatedTags = false);
 | 
					    void handlePostDownload(const QStringList &tags = QStringList(), bool relatedTags = false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
private Q_SLOTS:
 | 
					private Q_SLOTS:
 | 
				
			||||||
    void connectToBoard();
 | 
					    void connectToBoard();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -24,14 +24,16 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <KLocalizedString>
 | 
					#include <KLocalizedString>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Danbooru {
 | 
					namespace Danbooru
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
DanbooruPoolModel::DanbooruPoolModel(QObject* parent): QAbstractTableModel(parent)
 | 
					DanbooruPoolModel::DanbooruPoolModel(QObject *parent): QAbstractTableModel(parent)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const QStringList DanbooruPoolModel::m_headerNames = { i18n("ID"),
 | 
					const QStringList DanbooruPoolModel::m_headerNames = { i18n("ID"),
 | 
				
			||||||
    i18n("Name"), i18n("Posts"), i18n("Description") };
 | 
					                                                       i18n("Name"), i18n("Posts"), i18n("Description")
 | 
				
			||||||
 | 
					                                                     };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
DanbooruPoolModel::~DanbooruPoolModel()
 | 
					DanbooruPoolModel::~DanbooruPoolModel()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -60,7 +62,7 @@ int DanbooruPoolModel::columnCount(const QModelIndex &parent) const
 | 
				
			||||||
    return 4;
 | 
					    return 4;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
QVariant DanbooruPoolModel::data(const QModelIndex& index, int role) const
 | 
					QVariant DanbooruPoolModel::data(const QModelIndex &index, int role) const
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    if (!index.isValid()) {
 | 
					    if (!index.isValid()) {
 | 
				
			||||||
        return QVariant();
 | 
					        return QVariant();
 | 
				
			||||||
| 
						 | 
					@ -74,7 +76,7 @@ QVariant DanbooruPoolModel::data(const QModelIndex& index, int role) const
 | 
				
			||||||
        return QVariant();
 | 
					        return QVariant();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    DanbooruPool* pool = m_items.at(index.row());
 | 
					    DanbooruPool *pool = m_items.at(index.row());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (role == Qt::DisplayRole) {
 | 
					    if (role == Qt::DisplayRole) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -115,11 +117,9 @@ void DanbooruPoolModel::clear()
 | 
				
			||||||
    endResetModel();
 | 
					    endResetModel();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
DanbooruPool* DanbooruPoolModel::poolAt(int index) const
 | 
					DanbooruPool *DanbooruPoolModel::poolAt(int index) const
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    return m_items.at(index);
 | 
					    return m_items.at(index);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
} // namespace Danbooru
 | 
					} // namespace Danbooru
 | 
				
			||||||
| 
						 | 
					@ -23,7 +23,8 @@
 | 
				
			||||||
#include <QVector>
 | 
					#include <QVector>
 | 
				
			||||||
#include <QAbstractTableModel>
 | 
					#include <QAbstractTableModel>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Danbooru {
 | 
					namespace Danbooru
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class DanbooruPool;
 | 
					class DanbooruPool;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -32,7 +33,7 @@ class DanbooruPoolModel: public QAbstractTableModel
 | 
				
			||||||
    Q_OBJECT
 | 
					    Q_OBJECT
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
    DanbooruPoolModel(QObject* parent=0);
 | 
					    DanbooruPoolModel(QObject *parent = 0);
 | 
				
			||||||
    ~DanbooruPoolModel();
 | 
					    ~DanbooruPoolModel();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    int rowCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
 | 
					    int rowCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
 | 
				
			||||||
| 
						 | 
					@ -40,8 +41,7 @@ public:
 | 
				
			||||||
    QVariant data(const QModelIndex &index, int role) const Q_DECL_OVERRIDE;
 | 
					    QVariant data(const QModelIndex &index, int role) const Q_DECL_OVERRIDE;
 | 
				
			||||||
    QVariant headerData(int section, Qt::Orientation orientation, int role) const Q_DECL_OVERRIDE;
 | 
					    QVariant headerData(int section, Qt::Orientation orientation, int role) const Q_DECL_OVERRIDE;
 | 
				
			||||||
    void clear();
 | 
					    void clear();
 | 
				
			||||||
    DanbooruPool* poolAt(int index) const;
 | 
					    DanbooruPool *poolAt(int index) const;
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
    QVector<DanbooruPool *> m_items;
 | 
					    QVector<DanbooruPool *> m_items;
 | 
				
			||||||
| 
						 | 
					@ -52,9 +52,6 @@ public Q_SLOTS:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
} // namespace Danbooru
 | 
					} // namespace Danbooru
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					@ -17,7 +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/>.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
// Own
 | 
					// Own
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "danboorupostmodel.h"
 | 
					#include "danboorupostmodel.h"
 | 
				
			||||||
| 
						 | 
					@ -80,17 +79,15 @@ QVariant DanbooruPostModel::data(const QModelIndex &index, int role) const
 | 
				
			||||||
        return QVariant();
 | 
					        return QVariant();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    switch(role) {
 | 
					    switch (role) {
 | 
				
			||||||
        case Qt::DisplayRole:
 | 
					    case Qt::DisplayRole: {
 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
        QVariant variant;
 | 
					        QVariant variant;
 | 
				
			||||||
        variant.setValue(post);
 | 
					        variant.setValue(post);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return variant;
 | 
					        return variant;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        case Qt::DecorationRole:
 | 
					    case Qt::DecorationRole: {
 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
        const QPixmap pixmap = post->pixmap();
 | 
					        const QPixmap pixmap = post->pixmap();
 | 
				
			||||||
        return pixmap;
 | 
					        return pixmap;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					@ -106,8 +103,7 @@ QVariant DanbooruPostModel::data(const QModelIndex &index, int role) const
 | 
				
			||||||
        return QSize(post->width(), post->height());
 | 
					        return QSize(post->width(), post->height());
 | 
				
			||||||
    case RatingRole:
 | 
					    case RatingRole:
 | 
				
			||||||
        return post->rating();
 | 
					        return post->rating();
 | 
				
			||||||
        case TagRole:
 | 
					    case TagRole: {
 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
        QStringList tagList = post->tags().toList();
 | 
					        QStringList tagList = post->tags().toList();
 | 
				
			||||||
        return tagList;
 | 
					        return tagList;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -17,7 +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/>.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifndef DANBOORUPOSTMODEL_H
 | 
					#ifndef DANBOORUPOSTMODEL_H
 | 
				
			||||||
#define DANBOORUPOSTMODEL_H
 | 
					#define DANBOORUPOSTMODEL_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -17,14 +17,14 @@
 | 
				
			||||||
 * 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 "danboorutagmodel.h"
 | 
					#include "danboorutagmodel.h"
 | 
				
			||||||
#include "libdanbooru/danboorutag.h"
 | 
					#include "libdanbooru/danboorutag.h"
 | 
				
			||||||
#include "danbooru_client_debug.h"
 | 
					#include "danbooru_client_debug.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <KLocalizedString>
 | 
					#include <KLocalizedString>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Danbooru {
 | 
					namespace Danbooru
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
DanbooruTagModel::DanbooruTagModel(QObject *parent): QAbstractListModel(parent)
 | 
					DanbooruTagModel::DanbooruTagModel(QObject *parent): QAbstractListModel(parent)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -38,7 +38,6 @@ DanbooruTagModel::~DanbooruTagModel()
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
int DanbooruTagModel::rowCount(const QModelIndex &parent) const
 | 
					int DanbooruTagModel::rowCount(const QModelIndex &parent) const
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    Q_UNUSED(parent);
 | 
					    Q_UNUSED(parent);
 | 
				
			||||||
| 
						 | 
					@ -51,7 +50,7 @@ QVariant DanbooruTagModel::data(const QModelIndex &index, int role) const
 | 
				
			||||||
        return QVariant();
 | 
					        return QVariant();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    DanbooruTag* tag = m_items.at(index.row());
 | 
					    DanbooruTag *tag = m_items.at(index.row());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (role == Qt::DisplayRole) {
 | 
					    if (role == Qt::DisplayRole) {
 | 
				
			||||||
        return i18np("%1 (%2 post)", "%1 (%2 posts)", tag->name(), tag->count());
 | 
					        return i18np("%1 (%2 post)", "%1 (%2 posts)", tag->name(), tag->count());
 | 
				
			||||||
| 
						 | 
					@ -66,18 +65,18 @@ QVariant DanbooruTagModel::data(const QModelIndex &index, int role) const
 | 
				
			||||||
    return QVariant();
 | 
					    return QVariant();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
DanbooruTag* DanbooruTagModel::itemAt(int index) const
 | 
					DanbooruTag *DanbooruTagModel::itemAt(int index) const
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    return m_items.at(index);
 | 
					    return m_items.at(index);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void DanbooruTagModel::addTag(DanbooruTag* tag)
 | 
					void DanbooruTagModel::addTag(DanbooruTag *tag)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    if (!tag) {
 | 
					    if (!tag) {
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if(tag->count() == 0) {
 | 
					    if (tag->count() == 0) {
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -86,7 +85,8 @@ void DanbooruTagModel::addTag(DanbooruTag* tag)
 | 
				
			||||||
    endInsertRows();
 | 
					    endInsertRows();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void DanbooruTagModel::clear() {
 | 
					void DanbooruTagModel::clear()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (m_items.isEmpty()) {
 | 
					    if (m_items.isEmpty()) {
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -23,22 +23,23 @@
 | 
				
			||||||
#include <QAbstractListModel>
 | 
					#include <QAbstractListModel>
 | 
				
			||||||
#include <QVector>
 | 
					#include <QVector>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Danbooru {
 | 
					namespace Danbooru
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class DanbooruTag;
 | 
					class DanbooruTag;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class DanbooruTagModel: public QAbstractListModel
 | 
					class DanbooruTagModel: public QAbstractListModel
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Q_OBJECT
 | 
					    Q_OBJECT
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
    explicit DanbooruTagModel(QObject* parent=0);
 | 
					    explicit DanbooruTagModel(QObject *parent = 0);
 | 
				
			||||||
    ~DanbooruTagModel();
 | 
					    ~DanbooruTagModel();
 | 
				
			||||||
    int rowCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
 | 
					    int rowCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
 | 
				
			||||||
    QVariant data(const QModelIndex &index, int role) const Q_DECL_OVERRIDE;
 | 
					    QVariant data(const QModelIndex &index, int role) const Q_DECL_OVERRIDE;
 | 
				
			||||||
    void clear();
 | 
					    void clear();
 | 
				
			||||||
    DanbooruTag* itemAt(int index) const;
 | 
					    DanbooruTag *itemAt(int index) const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    enum TagRoles {
 | 
					    enum TagRoles {
 | 
				
			||||||
        // Needed for sorting through the proxy model
 | 
					        // Needed for sorting through the proxy model
 | 
				
			||||||
| 
						 | 
					@ -46,14 +47,13 @@ public:
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
    QVector<DanbooruTag*> m_items;
 | 
					    QVector<DanbooruTag *> m_items;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public Q_SLOTS:
 | 
					public Q_SLOTS:
 | 
				
			||||||
    void addTag(Danbooru::DanbooruTag* tag);
 | 
					    void addTag(Danbooru::DanbooruTag *tag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
} // namespace Danbooru
 | 
					} // namespace Danbooru
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue