diff --git a/src/blacklistpage.cpp b/src/blacklistpage.cpp index b039b07..3e9de43 100644 --- a/src/blacklistpage.cpp +++ b/src/blacklistpage.cpp @@ -20,7 +20,8 @@ #include "blacklistpage.h" #include "danboorusettings.h" -namespace Danbooru { +namespace Danbooru +{ BlacklistPage::BlacklistPage(DanbooruSettings *preferences, QWidget *parent): QWidget(parent) { @@ -29,10 +30,8 @@ BlacklistPage::BlacklistPage(DanbooruSettings *preferences, QWidget *parent): QW } - BlacklistPage::~BlacklistPage() { } - } // namespace Danbooru \ No newline at end of file diff --git a/src/blacklistpage.h b/src/blacklistpage.h index 488d8ab..80aa164 100644 --- a/src/blacklistpage.h +++ b/src/blacklistpage.h @@ -22,22 +22,22 @@ #include "ui_blacklistpage.h" -namespace Danbooru { +namespace Danbooru +{ class DanbooruSettings; -class BlacklistPage: public QWidget, public Ui::BlacklistPage { +class BlacklistPage: public QWidget, public Ui::BlacklistPage +{ Q_OBJECT public: - explicit BlacklistPage(DanbooruSettings *preferences, QWidget* parent=0); + explicit BlacklistPage(DanbooruSettings *preferences, QWidget *parent = 0); ~BlacklistPage(); }; - } // namespace Danbooru - #endif diff --git a/src/danbooru_client.cpp b/src/danbooru_client.cpp index 1bbc56d..494d17c 100644 --- a/src/danbooru_client.cpp +++ b/src/danbooru_client.cpp @@ -51,8 +51,8 @@ int main(int argc, char *argv[]) ); aboutData.addAuthor(i18n("Luca Beltrame"), i18n("Developer"), - QLatin1String("lbeltrame@kde.org") - ); + QLatin1String("lbeltrame@kde.org") + ); KAboutData::setApplicationData(aboutData); @@ -63,7 +63,7 @@ int main(int argc, char *argv[]) cmdParser.process(app); aboutData.processCommandLine(&cmdParser); - Danbooru::DanbooruMainWindow* window = new Danbooru::DanbooruMainWindow(); + Danbooru::DanbooruMainWindow *window = new Danbooru::DanbooruMainWindow(); window->setObjectName("danbooruMainWindow"); window->show(); diff --git a/src/danbooru_client_debug.cpp b/src/danbooru_client_debug.cpp index 9e33a59..2ed67c1 100644 --- a/src/danbooru_client_debug.cpp +++ b/src/danbooru_client_debug.cpp @@ -20,4 +20,3 @@ #include "danbooru_client_debug.h" Q_LOGGING_CATEGORY(DANBOORU_CLIENT, "org.dennogumi.danbooru_client") - diff --git a/src/danbooruconnectwidget.cpp b/src/danbooruconnectwidget.cpp index ba7326f..f428317 100644 --- a/src/danbooruconnectwidget.cpp +++ b/src/danbooruconnectwidget.cpp @@ -89,7 +89,9 @@ DanbooruConnectWidget::DanbooruConnectWidget(QVector< QUrl > urlList, connect(anonCheckBox, &QCheckBox::stateChanged, this, &DanbooruConnectWidget::toggleLineEdits); 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 &urlList) { +void DanbooruConnectWidget::setBoards(const QVector &urlList) +{ danbooruUrlComboBox->clear(); @@ -187,8 +190,8 @@ void DanbooruConnectWidget::accept() QString currentBoard = danbooruUrlComboBox->currentText(); if (!userLineEdit->text().isEmpty() && - !passwdLineEdit->text().isEmpty() && - !anonCheckBox->isChecked()) { + !passwdLineEdit->text().isEmpty() && + !anonCheckBox->isChecked()) { if (m_wallet && !m_wallet->hasEntry(currentBoard)) { QMap dataMap; @@ -203,7 +206,7 @@ void DanbooruConnectWidget::accept() QString hashedPassword = boardSalts.value(danbooruUrlComboBox->currentText()); hashedPassword = hashedPassword.arg(currentBoard); hashedPassword = QCryptographicHash::hash(hashedPassword.toUtf8(), - QCryptographicHash::Sha1).toHex(); + QCryptographicHash::Sha1).toHex(); m_password = hashedPassword; } } @@ -212,7 +215,8 @@ void DanbooruConnectWidget::accept() Q_EMIT(accepted()); } -bool DanbooruConnectWidget::isAnonymous() const { +bool DanbooruConnectWidget::isAnonymous() const +{ return anonCheckBox->isChecked(); diff --git a/src/danboorusearchwidget.cpp b/src/danboorusearchwidget.cpp index 48e756e..371829f 100644 --- a/src/danboorusearchwidget.cpp +++ b/src/danboorusearchwidget.cpp @@ -22,15 +22,18 @@ #include #include -namespace Danbooru { +namespace Danbooru +{ -DanbooruSearchWidget::DanbooruSearchWidget(QWidget* parent): QWidget(parent) +DanbooruSearchWidget::DanbooruSearchWidget(QWidget *parent): QWidget(parent) { setupUi(this); connect(searchButton, &QPushButton::clicked, 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; } -void DanbooruSearchWidget::accept() { +void DanbooruSearchWidget::accept() +{ - if(tagLineEdit->text().isEmpty()) { + if (tagLineEdit->text().isEmpty()) { return; } @@ -53,5 +57,4 @@ void DanbooruSearchWidget::accept() { Q_EMIT(accepted()); } - } // namespace Danbooru \ No newline at end of file diff --git a/src/danboorusearchwidget.h b/src/danboorusearchwidget.h index 9813177..badf374 100644 --- a/src/danboorusearchwidget.h +++ b/src/danboorusearchwidget.h @@ -22,30 +22,31 @@ #include "ui_searchwidget.h" -namespace Danbooru { +namespace Danbooru +{ - class DanbooruSearchWidget: public QWidget, Ui::SearchWidget { +class DanbooruSearchWidget: public QWidget, Ui::SearchWidget +{ Q_OBJECT - public: - explicit DanbooruSearchWidget(QWidget *parent = 0); - ~DanbooruSearchWidget(); - QStringList selectedTags() const; +public: + explicit DanbooruSearchWidget(QWidget *parent = 0); + ~DanbooruSearchWidget(); + QStringList selectedTags() const; - private: - QStringList m_tags; +private: + QStringList m_tags; - private Q_SLOTS: - void accept(); +private Q_SLOTS: + void accept(); - Q_SIGNALS: - void accepted(); - void rejected(); +Q_SIGNALS: + void accepted(); + void rejected(); - }; +}; } // namespace Danbooru - #endif \ No newline at end of file diff --git a/src/danboorutagwidget.cpp b/src/danboorutagwidget.cpp index 8649507..df19c70 100644 --- a/src/danboorutagwidget.cpp +++ b/src/danboorutagwidget.cpp @@ -21,7 +21,8 @@ #include "model/danboorutagmodel.h" #include "libdanbooru/danboorutag.h" -namespace Danbooru { +namespace Danbooru +{ DanbooruTagWidget::DanbooruTagWidget(QWidget *parent): QListView(parent) { @@ -38,7 +39,7 @@ void DanbooruTagWidget::addTag(DanbooruTag *tag) return; } - qobject_cast(model())->addTag(tag); + qobject_cast(model())->addTag(tag); } diff --git a/src/danboorutagwidget.h b/src/danboorutagwidget.h index b8f285e..a8d51f1 100644 --- a/src/danboorutagwidget.h +++ b/src/danboorutagwidget.h @@ -23,22 +23,23 @@ #include #include -namespace Danbooru { +namespace Danbooru +{ class DanbooruTag; class DanbooruTagWidget: public QListView { -Q_OBJECT + Q_OBJECT private: QStringList m_blacklist; public: - explicit DanbooruTagWidget(QWidget *parent=0); + explicit DanbooruTagWidget(QWidget *parent = 0); ~DanbooruTagWidget(); - void setBlackList(const QStringList& blacklist); + void setBlackList(const QStringList &blacklist); public Q_SLOTS: void addTag(DanbooruTag *tag); diff --git a/src/generalpage.cpp b/src/generalpage.cpp index 12f0175..a6ceb71 100644 --- a/src/generalpage.cpp +++ b/src/generalpage.cpp @@ -27,14 +27,15 @@ 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); kcfg_Boards->insertStringList(preferences->boards()); QRegularExpression regex(urlRegex); - QRegularExpressionValidator* validator = new QRegularExpressionValidator(regex); + QRegularExpressionValidator *validator = new QRegularExpressionValidator(regex); kcfg_Boards->lineEdit()->setValidator(validator); kcfg_MaxRating->setCurrentIndex(preferences->maxRating()); @@ -44,5 +45,4 @@ GeneralPage::~GeneralPage() { } - } // namespace Danbooru diff --git a/src/generalpage.h b/src/generalpage.h index eb2c23c..8704a61 100644 --- a/src/generalpage.h +++ b/src/generalpage.h @@ -22,16 +22,18 @@ #include "ui_generalpage.h" -namespace Danbooru { +namespace Danbooru +{ class DanbooruSettings; -class GeneralPage: public QWidget, public Ui::GeneralPage { +class GeneralPage: public QWidget, public Ui::GeneralPage +{ -Q_OBJECT + Q_OBJECT public: - explicit GeneralPage(DanbooruSettings* preferences, QWidget* parent=0); + explicit GeneralPage(DanbooruSettings *preferences, QWidget *parent = 0); ~GeneralPage(); }; diff --git a/src/libdanbooru/danbooru.h b/src/libdanbooru/danbooru.h index 15dfe08..bc9a575 100644 --- a/src/libdanbooru/danbooru.h +++ b/src/libdanbooru/danbooru.h @@ -17,13 +17,11 @@ * along with Danbooru Client. If not, see . */ - #ifndef DANBOORU_H #define DANBOORU_H #include "libdanbooru_version.h" - /** * @brief The Danbooru namespace. * @file danbooru.h diff --git a/src/libdanbooru/danboorupool.cpp b/src/libdanbooru/danboorupool.cpp index 53b1f91..8814e99 100644 --- a/src/libdanbooru/danboorupool.cpp +++ b/src/libdanbooru/danboorupool.cpp @@ -17,7 +17,6 @@ * along with Danbooru Client. If not, see . */ - #include "danboorupool.h" namespace Danbooru diff --git a/src/libdanbooru/danboorupool.h b/src/libdanbooru/danboorupool.h index bbf1bcc..99fa623 100644 --- a/src/libdanbooru/danboorupool.h +++ b/src/libdanbooru/danboorupool.h @@ -17,7 +17,6 @@ * along with Danbooru Client. If not, see . */ - #ifndef DANBOORUPOOL_H #define DANBOORUPOOL_H @@ -104,6 +103,6 @@ public: } // namespace Danbooru -Q_DECLARE_METATYPE(Danbooru::DanbooruPool*) +Q_DECLARE_METATYPE(Danbooru::DanbooruPool *) #endif // DANBOORUPOOL_H diff --git a/src/libdanbooru/danboorupost.cpp b/src/libdanbooru/danboorupost.cpp index a3c2bce..9a19b2d 100644 --- a/src/libdanbooru/danboorupost.cpp +++ b/src/libdanbooru/danboorupost.cpp @@ -17,7 +17,6 @@ * along with Danbooru Client. If not, see . */ - // Qt #include @@ -36,7 +35,7 @@ namespace Danbooru const QMap DanbooruPost::RATING_MAP = initRatingMap(); -DanbooruPost::DanbooruPost(QObject* parent): QObject(parent) +DanbooruPost::DanbooruPost(QObject *parent): QObject(parent) { m_pixmap = QPixmap(); m_tags = QSet(); @@ -48,7 +47,6 @@ DanbooruPost::DanbooruPost(QObject* parent): QObject(parent) m_rating = Questionable; } - DanbooruPost::DanbooruPost(QVariantMap postData, QPixmap pixmap, QObject *parent): QObject(parent), @@ -149,7 +147,6 @@ const QUrl DanbooruPost::sampleUrl() const return m_sampleUrl; } - QPixmap DanbooruPost::pixmap() const { return m_pixmap; diff --git a/src/libdanbooru/danboorupost.h b/src/libdanbooru/danboorupost.h index 7481864..48ca73b 100644 --- a/src/libdanbooru/danboorupost.h +++ b/src/libdanbooru/danboorupost.h @@ -17,7 +17,6 @@ * along with Danbooru Client. If not, see . */ - #ifndef DANBOORUPOST_H #define DANBOORUPOST_H @@ -90,7 +89,6 @@ public: Q_DECLARE_FLAGS(Ratings, DanbooruPost::Rating) Q_ENUMS(Rating) - private: QPixmap m_pixmap; @@ -133,7 +131,7 @@ public: explicit DanbooruPost(QVariantMap postData, QPixmap pixmap = QPixmap(), QObject *parent = 0); - explicit DanbooruPost(QObject* parent = 0); + explicit DanbooruPost(QObject *parent = 0); /** * @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(QSet) - #endif // DANBOORUPOST_H diff --git a/src/libdanbooru/danbooruservice.cpp b/src/libdanbooru/danbooruservice.cpp index 040b896..fdab09e 100644 --- a/src/libdanbooru/danbooruservice.cpp +++ b/src/libdanbooru/danbooruservice.cpp @@ -17,7 +17,6 @@ * along with Danbooru Client. If not, see . */ - // STL #include @@ -100,7 +99,6 @@ void DanbooruService::getPostList() } - void DanbooruService::getTagList(int limit, QString name) { QMap parameters; @@ -202,7 +200,7 @@ void DanbooruService::getPoolList() Q_EMIT(poolDownloadFinished()); } - ); + ); } @@ -237,7 +235,6 @@ void DanbooruService::getRelatedTags(const QStringList &tags, // qCDebug(LIBDANBOORU) << "Final constructed related tag URL" << danbooruUrl; - StoredTransferJob *job = KIO::storedGet( danbooruUrl, KIO::NoReload, KIO::HideProgressInfo @@ -291,7 +288,6 @@ void DanbooruService::getRelatedTags(const QStringList &tags, } - const QSet< QString > DanbooruService::blacklist() const { return m_blacklist; @@ -322,7 +318,6 @@ int DanbooruService::currentPage() const return m_currentPage; } - const DanbooruPost::Ratings DanbooruService::maximumAllowedRating() const { @@ -347,7 +342,6 @@ void DanbooruService::nextPoolPage() getPoolList(); } - QStringList DanbooruService::postTags() const { return m_tags; @@ -362,7 +356,8 @@ void DanbooruService::reset() // Slots -void DanbooruService::processTagList(KJob *job) { +void DanbooruService::processTagList(KJob *job) +{ if (job->error()) { Q_EMIT(downloadError(job->errorString())); @@ -387,7 +382,7 @@ void DanbooruService::processTagList(KJob *job) { QVariantMap map = element.toMap(); DanbooruTag *tag = new DanbooruTag(map); - if(!tag) { + if (!tag) { continue; } @@ -437,7 +432,6 @@ void DanbooruService::processPostList(KJob *job) for (auto element : postList) { - QVariantMap map = element.toMap(); DanbooruPost *post = new DanbooruPost(map); @@ -469,7 +463,6 @@ void DanbooruService::processPostList(KJob *job) StoredTransferJob *pixmapJob = KIO::storedGet(post->thumbnailUrl(), KIO::NoReload, KIO::HideProgressInfo); - // We don't want to overload the servers, so set some rational // priority @@ -523,7 +516,6 @@ void DanbooruService::processPostList(KJob *job) } - void DanbooruService::downloadAllTags(KJob *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; } @@ -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()) { return; @@ -587,34 +579,36 @@ void DanbooruService::setUserName(const QString& username) m_username = username; } -void DanbooruService::setPassword(const QString& password) +void DanbooruService::setPassword(const QString &password) { - if(password.isEmpty()) { + if (password.isEmpty()) { return; } m_password = password; } -void DanbooruService::setPostTags(const QStringList& tags) +void DanbooruService::setPostTags(const QStringList &tags) { if (!tags.isEmpty()) { m_tags = tags; } } -void DanbooruService::setImageCache(KImageCache* cache) +void DanbooruService::setImageCache(KImageCache *cache) { m_cache = cache; } -void DanbooruService::setMaxPosts(int number) { +void DanbooruService::setMaxPosts(int number) +{ m_maxPosts = number < 100 ? number : 100; } -void DanbooruService::setCurrentPage(int page) { +void DanbooruService::setCurrentPage(int page) +{ m_currentPage = page; } diff --git a/src/libdanbooru/danbooruservice.h b/src/libdanbooru/danbooruservice.h index 1b9bd3b..0dea146 100644 --- a/src/libdanbooru/danbooruservice.h +++ b/src/libdanbooru/danbooruservice.h @@ -17,7 +17,6 @@ * along with Danbooru Client. If not, see . */ - #ifndef DANBOORUSERVICE_H #define DANBOORUSERVICE_H @@ -102,7 +101,6 @@ private: public: - /** * @brief Construct a default instance of the service. * @@ -114,7 +112,7 @@ public: * @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, QObject *parent = 0); @@ -222,16 +220,16 @@ public: * @param blacklist A QSet including unwanted tags. * **/ - void setBlacklist(const QStringList& blacklist); + void setBlacklist(const QStringList &blacklist); - /** - * @brief Set the tag blacklist. - * - * If a tag is in the blacklist, posts tagged with it will not be downloaded. - * - **/ + /** + * @brief Set the tag blacklist. + * + * If a tag is in the blacklist, posts tagged with it will not be downloaded. + * + **/ - void setBlacklist(const QSet& blacklist); + void setBlacklist(const QSet &blacklist); /** * @brief Set the maximum allowed rating for the board. @@ -248,7 +246,7 @@ public: * @param url The URL to connect to. * @return void */ - void setBoardUrl(const QUrl& url); + void setBoardUrl(const QUrl &url); /** * @brief Set an image cache to use. @@ -264,7 +262,7 @@ public: * @param username The username to use. * **/ - void setUserName(const QString& username); + void setUserName(const QString &username); /** * @brief Set the password used for login. @@ -276,14 +274,13 @@ public: * @param password The salted password to use. * **/ - void setPassword(const QString& password); + void setPassword(const QString &password); void setMaxPosts(int number); void setCurrentPage(int page); - void setPostTags(const QStringList& tags); - + void setPostTags(const QStringList &tags); private Q_SLOTS: void processPostList(KJob *job); diff --git a/src/libdanbooru/danboorutag.cpp b/src/libdanbooru/danboorutag.cpp index 2afb9ed..f91d2ec 100644 --- a/src/libdanbooru/danboorutag.cpp +++ b/src/libdanbooru/danboorutag.cpp @@ -17,7 +17,6 @@ * along with Danbooru Client. If not, see . */ - #include "danboorutag.h" namespace Danbooru diff --git a/src/libdanbooru/danboorutag.h b/src/libdanbooru/danboorutag.h index 701f1fa..f49c675 100644 --- a/src/libdanbooru/danboorutag.h +++ b/src/libdanbooru/danboorutag.h @@ -17,7 +17,6 @@ * along with Danbooru Client. If not, see . */ - #ifndef DANBOORUTAG_H #define DANBOORUTAG_H @@ -78,5 +77,4 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(TagTypes) Q_DECLARE_METATYPE(Danbooru::DanbooruTag *) - #endif // DANBOORUTAG_H diff --git a/src/libdanbooru/libdanbooru_debug.cpp b/src/libdanbooru/libdanbooru_debug.cpp index 9309775..67eca45 100644 --- a/src/libdanbooru/libdanbooru_debug.cpp +++ b/src/libdanbooru/libdanbooru_debug.cpp @@ -20,4 +20,3 @@ #include "libdanbooru_debug.h" Q_LOGGING_CATEGORY(LIBDANBOORU, "org.dennogumi.libdanbooru") - diff --git a/src/libdanbooru/utils.cpp b/src/libdanbooru/utils.cpp index 0aa2e83..9e1a0b5 100644 --- a/src/libdanbooru/utils.cpp +++ b/src/libdanbooru/utils.cpp @@ -17,7 +17,6 @@ * along with Danbooru Client. If not, see . */ - // Own #include "utils.h" @@ -69,7 +68,6 @@ QUrl requestUrl(QUrl &url, const QString &path, danbooruUrl.setPassword(password); } - return danbooruUrl; } @@ -118,7 +116,7 @@ QUrl requestUrl(QUrl &url, const QString &path, const QString &username, return danbooruUrl; } -QList< QVariant > parseDanbooruResult(QByteArray data, QString xlmElement, bool* result) +QList< QVariant > parseDanbooruResult(QByteArray data, QString xlmElement, bool *result) { QXmlStreamReader reader; diff --git a/src/libdanbooru/utils.h b/src/libdanbooru/utils.h index 8bf7b39..279fd67 100644 --- a/src/libdanbooru/utils.h +++ b/src/libdanbooru/utils.h @@ -17,7 +17,6 @@ * along with Danbooru Client. If not, see . */ - #ifndef UTILS_H #define UTILS_H diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index f7ad46d..bba0fd9 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -108,7 +108,6 @@ DanbooruMainWindow::DanbooruMainWindow(QWidget *parent) m_tableView->setModel(m_poolModel); m_tagWidget->setModel(m_proxyModel); - // Set up declarative bindings for the QQuickWidget m_view->setResizeMode(QQuickWidget::SizeRootObjectToView); @@ -117,7 +116,7 @@ DanbooruMainWindow::DanbooruMainWindow(QWidget *parent) declarative.setupBindings(); auto qmlViewPath = QStandardPaths::locate(QStandardPaths::GenericDataLocation, - qApp->applicationName() + QLatin1String("/danbooruimageview.qml")); + qApp->applicationName() + QLatin1String("/danbooruimageview.qml")); QQmlContext *ctxt = m_view->rootContext(); ctxt->setContextProperty("danbooruModel", m_model); @@ -136,7 +135,7 @@ DanbooruMainWindow::DanbooruMainWindow(QWidget *parent) // then, setup our actions setupActions(); - setupGUI(KXmlGuiWindow::ToolBar|Keys|Save|Create, "danbooru-clientui.rc"); + setupGUI(KXmlGuiWindow::ToolBar | Keys | Save | Create, "danbooru-clientui.rc"); // connections @@ -144,7 +143,7 @@ DanbooruMainWindow::DanbooruMainWindow(QWidget *parent) m_service->setBoardUrl(m_connectWidget->boardUrl()); if (!m_connectWidget->isAnonymous() && !m_connectWidget->username().isEmpty() - && !m_connectWidget->password().isEmpty()) { + && !m_connectWidget->password().isEmpty()) { m_service->setUserName(m_connectWidget->username()); m_service->setPassword(m_connectWidget->password()); @@ -178,8 +177,8 @@ DanbooruMainWindow::DanbooruMainWindow(QWidget *parent) &DanbooruTagModel::addTag); connect(m_service, &Danbooru::DanbooruService::poolDownloadFinished, [this]() { m_tableView->resizeColumnsToContents(); - } - ); + } + ); connect(m_tableView, &QTableView::doubleClicked, [this](QModelIndex index) { auto pool = m_poolModel->poolAt(index.row()); @@ -192,15 +191,15 @@ DanbooruMainWindow::DanbooruMainWindow(QWidget *parent) connect(m_searchWidget, &DanbooruSearchWidget::accepted, [this]() { - QDockWidget* searchDockWidget = findChild(QLatin1String("SearchView")); - searchDockWidget->hide(); + QDockWidget *searchDockWidget = findChild(QLatin1String("SearchView")); + searchDockWidget->hide(); - handlePostDownload(m_searchWidget->selectedTags(), true /* relatedTags */); + handlePostDownload(m_searchWidget->selectedTags(), true /* relatedTags */); }); connect(m_searchWidget, &DanbooruSearchWidget::rejected, [this]() { - QDockWidget* searchDockWidget = findChild(QLatin1String("SearchView")); + QDockWidget *searchDockWidget = findChild(QLatin1String("SearchView")); searchDockWidget->hide(); }); @@ -208,7 +207,7 @@ DanbooruMainWindow::DanbooruMainWindow(QWidget *parent) if (m_tagModel->rowCount() == 0) { // 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); } } @@ -216,8 +215,8 @@ DanbooruMainWindow::DanbooruMainWindow(QWidget *parent) }); - connect(m_view->rootObject(), SIGNAL(downloadRequested(const QUrl&, QVariant)), this, - SLOT(slotHandleDownload(const QUrl&, QVariant))); + connect(m_view->rootObject(), SIGNAL(downloadRequested(QUrl,QVariant)), this, + SLOT(slotHandleDownload(QUrl,QVariant))); connect(m_tagWidget, &QListView::doubleClicked, this, &DanbooruMainWindow::searchTag); @@ -240,9 +239,9 @@ void DanbooruMainWindow::loadSettings() QStringList::const_iterator it; - for(it = DanbooruSettings::self()->boards().constBegin(); - it != DanbooruSettings::self()->boards().constEnd(); - ++it) { + for (it = DanbooruSettings::self()->boards().constBegin(); + it != DanbooruSettings::self()->boards().constEnd(); + ++it) { boardsList.append(QUrl::fromUserInput(*it)); @@ -257,11 +256,10 @@ void DanbooruMainWindow::loadSettings() m_tagWidget->setBlackList(DanbooruSettings::self()->tagBlacklist()); m_view->rootContext()->setContextProperty("infiniteScroll", - DanbooruSettings::self()->infiniteScrolling()); + DanbooruSettings::self()->infiniteScrolling()); } - void DanbooruMainWindow::setupActions() { @@ -273,15 +271,15 @@ void DanbooruMainWindow::setupActions() QAction *fetchAction = new QAction(QIcon::fromTheme(QLatin1String("download")), i18n("Download"), this); KToggleAction *findAction = new KToggleAction(QIcon::fromTheme(QLatin1String("edit-find")), - i18n("Search"), this); + i18n("Search"), this); KToggleAction *poolAction = new KToggleAction(QIcon::fromTheme(QLatin1String("image-x-generic")), - i18n("Pools"), this); + i18n("Pools"), this); QAction *nextPageAction = new QAction(QIcon::fromTheme(QLatin1String("go-next")), i18n("More posts"), this); QAction *nextPoolAction = new QAction(QIcon::fromTheme(QLatin1String("go-next")), 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"))); fetchAction->setEnabled(false); @@ -316,7 +314,7 @@ void DanbooruMainWindow::setupActions() return; } - QDockWidget* poolDockWidget = findChild(QLatin1String("PoolView")); + QDockWidget *poolDockWidget = findChild(QLatin1String("PoolView")); if (checked) { @@ -329,7 +327,6 @@ void DanbooruMainWindow::setupActions() actionCollection()->action(QLatin1String("morePools"))->setEnabled(true); m_tableView->show(); - } else { poolDockWidget->hide(); actionCollection()->action(QLatin1String("morePools"))->setEnabled(false); @@ -339,7 +336,7 @@ void DanbooruMainWindow::setupActions() connect(findAction, &KToggleAction::toggled, [this](bool checked) { - QDockWidget* searchDockWidget = findChild(QLatin1String("SearchView")); + QDockWidget *searchDockWidget = findChild(QLatin1String("SearchView")); if (checked) { searchDockWidget->show(); @@ -353,7 +350,7 @@ void DanbooruMainWindow::setupActions() connect(tagAction, &KDualAction::activeChanged, [this](bool checked) { - QDockWidget* tagDockWidget = findChild(QLatin1String("TagView")); + QDockWidget *tagDockWidget = findChild(QLatin1String("TagView")); if (checked) { tagDockWidget->show(); @@ -373,21 +370,21 @@ void DanbooruMainWindow::setupActions() QMetaObject::invokeMethod(m_view->rootObject(), "downloadStarted"); m_service->nextPostPage(); - } - ); + } + ); connect(nextPoolAction, &QAction::triggered, [this]() { m_service->nextPoolPage(); - } - ); + } + ); } - -void DanbooruMainWindow::setupDockWidgets() { +void DanbooruMainWindow::setupDockWidgets() +{ // Set up PoolWidget - QDockWidget* poolDockWidget = new QDockWidget(i18n("Pools"), this); + QDockWidget *poolDockWidget = new QDockWidget(i18n("Pools"), this); poolDockWidget->setAllowedAreas(Qt::BottomDockWidgetArea); poolDockWidget->setWidget(m_tableView); poolDockWidget->setObjectName("PoolView"); @@ -433,7 +430,7 @@ void DanbooruMainWindow::setupDockWidgets() { }); connect(tagDockWidget, &QDockWidget::visibilityChanged, [this](bool visible) { - qobject_cast(actionCollection()->action(QLatin1String("tags")))->setActive(visible); + qobject_cast(actionCollection()->action(QLatin1String("tags")))->setActive(visible); }); } @@ -459,30 +456,29 @@ void DanbooruMainWindow::downloadPosts() return; } - handlePostDownload(QStringList(), false); } void DanbooruMainWindow::optionsPreferences() { - KConfigDialog* dialog = new KConfigDialog(this, "danboorusettings", - DanbooruSettings::self()); + KConfigDialog *dialog = new KConfigDialog(this, "danboorusettings", + DanbooruSettings::self()); dialog->addPage(new GeneralPage(DanbooruSettings::self(), this), i18n("General"), - "table"); + "table"); dialog->addPage(new BlacklistPage(DanbooruSettings::self(), this), i18n("Tag blacklist"), "configure"); connect(dialog, &KConfigDialog::settingsChanged, this, &DanbooruMainWindow::loadSettings); dialog->show(); } -void DanbooruMainWindow::slotHandleDownload(const QUrl &url, const QVariant tags) { - +void DanbooruMainWindow::slotHandleDownload(const QUrl &url, const QVariant tags) +{ QStringList tagList = tags.toStringList(); - KIO::MimetypeJob* mimeJob = KIO::mimetype(url, KIO::HideProgressInfo); + KIO::MimetypeJob *mimeJob = KIO::mimetype(url, KIO::HideProgressInfo); QString filters; QString remoteFile = url.fileName(); @@ -498,14 +494,13 @@ void DanbooruMainWindow::slotHandleDownload(const QUrl &url, const QVariant tags remoteFile.replace(":", "_"); } - QUrl localFile = QFileDialog::getSaveFileUrl( - this, - i18n("Save file"), - QDir::homePath() + QLatin1Char('/') + remoteFile, - filters - - ); + QUrl localFile = QFileDialog::getSaveFileUrl( + this, + i18n("Save file"), + QDir::homePath() + QLatin1Char('/') + remoteFile, + filters + ); // TODO: Remember last user directory - settings? @@ -513,17 +508,17 @@ void DanbooruMainWindow::slotHandleDownload(const QUrl &url, const QVariant tags 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()) { return; } - #ifdef WITH_KFILEMETADATA +#ifdef WITH_KFILEMETADATA qCDebug(DANBOORU_CLIENT) << "Local file" << localFile.toLocalFile(); KFileMetaData::UserMetaData meta(localFile.toLocalFile()); meta.setTags(tagList); - #endif +#endif }); @@ -554,14 +549,13 @@ void DanbooruMainWindow::clearModels() } - void DanbooruMainWindow::handlePostDownload(const QStringList &tags, bool relatedTags) { clearModels(); m_view->rootObject()->setProperty("poolMode", QVariant(false)); m_service->setPostTags(tags); - if(relatedTags) { + if (relatedTags) { m_service->getRelatedTags(tags); } diff --git a/src/mainwindow.h b/src/mainwindow.h index 5657fe9..8792c8f 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -32,12 +32,9 @@ #include #include - - class QQuickWidget; class QSortFilterProxyModel; - namespace Danbooru { @@ -81,7 +78,7 @@ public: /** * Default Constructor */ - DanbooruMainWindow(QWidget* parent=0); + DanbooruMainWindow(QWidget *parent = 0); /** * Default Destructor @@ -93,7 +90,7 @@ private: void setupDockWidgets(); void setupConnections(); void clearModels(); - void handlePostDownload(const QStringList& tags = QStringList(), bool relatedTags = false); + void handlePostDownload(const QStringList &tags = QStringList(), bool relatedTags = false); private Q_SLOTS: void connectToBoard(); diff --git a/src/model/danboorupoolmodel.cpp b/src/model/danboorupoolmodel.cpp index 236db8c..43653e8 100644 --- a/src/model/danboorupoolmodel.cpp +++ b/src/model/danboorupoolmodel.cpp @@ -24,14 +24,16 @@ #include -namespace Danbooru { +namespace Danbooru +{ -DanbooruPoolModel::DanbooruPoolModel(QObject* parent): QAbstractTableModel(parent) +DanbooruPoolModel::DanbooruPoolModel(QObject *parent): QAbstractTableModel(parent) { } const QStringList DanbooruPoolModel::m_headerNames = { i18n("ID"), - i18n("Name"), i18n("Posts"), i18n("Description") }; + i18n("Name"), i18n("Posts"), i18n("Description") + }; DanbooruPoolModel::~DanbooruPoolModel() { @@ -60,7 +62,7 @@ int DanbooruPoolModel::columnCount(const QModelIndex &parent) const return 4; } -QVariant DanbooruPoolModel::data(const QModelIndex& index, int role) const +QVariant DanbooruPoolModel::data(const QModelIndex &index, int role) const { if (!index.isValid()) { return QVariant(); @@ -74,7 +76,7 @@ QVariant DanbooruPoolModel::data(const QModelIndex& index, int role) const return QVariant(); } - DanbooruPool* pool = m_items.at(index.row()); + DanbooruPool *pool = m_items.at(index.row()); if (role == Qt::DisplayRole) { @@ -105,7 +107,7 @@ QVariant DanbooruPoolModel::headerData(int section, Qt::Orientation orientation, void DanbooruPoolModel::clear() { - if (m_items.isEmpty()) { + if (m_items.isEmpty()) { return; } @@ -115,11 +117,9 @@ void DanbooruPoolModel::clear() endResetModel(); } -DanbooruPool* DanbooruPoolModel::poolAt(int index) const +DanbooruPool *DanbooruPoolModel::poolAt(int index) const { return m_items.at(index); } - - } // namespace Danbooru \ No newline at end of file diff --git a/src/model/danboorupoolmodel.h b/src/model/danboorupoolmodel.h index 44d6d5d..2e0fab8 100644 --- a/src/model/danboorupoolmodel.h +++ b/src/model/danboorupoolmodel.h @@ -23,7 +23,8 @@ #include #include -namespace Danbooru { +namespace Danbooru +{ class DanbooruPool; @@ -32,7 +33,7 @@ class DanbooruPoolModel: public QAbstractTableModel Q_OBJECT public: - DanbooruPoolModel(QObject* parent=0); + DanbooruPoolModel(QObject *parent = 0); ~DanbooruPoolModel(); 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 headerData(int section, Qt::Orientation orientation, int role) const Q_DECL_OVERRIDE; void clear(); - DanbooruPool* poolAt(int index) const; - + DanbooruPool *poolAt(int index) const; private: QVector m_items; @@ -52,9 +52,6 @@ public Q_SLOTS: }; - } // namespace Danbooru - - #endif \ No newline at end of file diff --git a/src/model/danboorupostmodel.cpp b/src/model/danboorupostmodel.cpp index 7c24fed..6588c39 100644 --- a/src/model/danboorupostmodel.cpp +++ b/src/model/danboorupostmodel.cpp @@ -17,7 +17,6 @@ * along with Danbooru Client. If not, see . */ - // Own #include "danboorupostmodel.h" @@ -80,41 +79,38 @@ QVariant DanbooruPostModel::data(const QModelIndex &index, int role) const return QVariant(); } - switch(role) { - case Qt::DisplayRole: - { - QVariant variant; - variant.setValue(post); + switch (role) { + case Qt::DisplayRole: { + QVariant variant; + variant.setValue(post); - return variant; - } + return variant; + } - case Qt::DecorationRole: - { - const QPixmap pixmap = post->pixmap(); - return pixmap; - } - case Qt::ToolTipRole: - return post->fileUrl().fileName(); - case FileUrlRole: - return post->fileUrl(); - case ThumbUrlRole: - return post->thumbnailUrl(); - case SizeRole: - return post->size(); - case ResolutionRole: - return QSize(post->width(), post->height()); - case RatingRole: - return post->rating(); - case TagRole: - { - QStringList tagList = post->tags().toList(); - return tagList; - } - case SampleUrlRole: - return post->sampleUrl(); - default: - return QVariant(); + case Qt::DecorationRole: { + const QPixmap pixmap = post->pixmap(); + return pixmap; + } + case Qt::ToolTipRole: + return post->fileUrl().fileName(); + case FileUrlRole: + return post->fileUrl(); + case ThumbUrlRole: + return post->thumbnailUrl(); + case SizeRole: + return post->size(); + case ResolutionRole: + return QSize(post->width(), post->height()); + case RatingRole: + return post->rating(); + case TagRole: { + QStringList tagList = post->tags().toList(); + return tagList; + } + case SampleUrlRole: + return post->sampleUrl(); + default: + return QVariant(); } return QVariant(); diff --git a/src/model/danboorupostmodel.h b/src/model/danboorupostmodel.h index d10328b..d82f56c 100644 --- a/src/model/danboorupostmodel.h +++ b/src/model/danboorupostmodel.h @@ -17,7 +17,6 @@ * along with Danbooru Client. If not, see . */ - #ifndef DANBOORUPOSTMODEL_H #define DANBOORUPOSTMODEL_H diff --git a/src/model/danboorutagmodel.cpp b/src/model/danboorutagmodel.cpp index 06aee1b..8990e9a 100644 --- a/src/model/danboorutagmodel.cpp +++ b/src/model/danboorutagmodel.cpp @@ -17,14 +17,14 @@ * along with Danbooru Client. If not, see . */ - #include "danboorutagmodel.h" #include "libdanbooru/danboorutag.h" #include "danbooru_client_debug.h" #include -namespace Danbooru { +namespace Danbooru +{ DanbooruTagModel::DanbooruTagModel(QObject *parent): QAbstractListModel(parent) { @@ -38,7 +38,6 @@ DanbooruTagModel::~DanbooruTagModel() } } - int DanbooruTagModel::rowCount(const QModelIndex &parent) const { Q_UNUSED(parent); @@ -51,7 +50,7 @@ QVariant DanbooruTagModel::data(const QModelIndex &index, int role) const return QVariant(); } - DanbooruTag* tag = m_items.at(index.row()); + DanbooruTag *tag = m_items.at(index.row()); if (role == Qt::DisplayRole) { 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(); } -DanbooruTag* DanbooruTagModel::itemAt(int index) const +DanbooruTag *DanbooruTagModel::itemAt(int index) const { return m_items.at(index); } -void DanbooruTagModel::addTag(DanbooruTag* tag) +void DanbooruTagModel::addTag(DanbooruTag *tag) { if (!tag) { return; } - if(tag->count() == 0) { + if (tag->count() == 0) { return; } @@ -86,9 +85,10 @@ void DanbooruTagModel::addTag(DanbooruTag* tag) endInsertRows(); } -void DanbooruTagModel::clear() { +void DanbooruTagModel::clear() +{ - if (m_items.isEmpty()) { + if (m_items.isEmpty()) { return; } diff --git a/src/model/danboorutagmodel.h b/src/model/danboorutagmodel.h index e532889..0b1c8b8 100644 --- a/src/model/danboorutagmodel.h +++ b/src/model/danboorutagmodel.h @@ -23,22 +23,23 @@ #include #include -namespace Danbooru { +namespace Danbooru +{ class DanbooruTag; class DanbooruTagModel: public QAbstractListModel { -Q_OBJECT + Q_OBJECT public: - explicit DanbooruTagModel(QObject* parent=0); + explicit DanbooruTagModel(QObject *parent = 0); ~DanbooruTagModel(); int rowCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE; QVariant data(const QModelIndex &index, int role) const Q_DECL_OVERRIDE; void clear(); - DanbooruTag* itemAt(int index) const; + DanbooruTag *itemAt(int index) const; enum TagRoles { // Needed for sorting through the proxy model @@ -46,14 +47,13 @@ public: }; private: - QVector m_items; + QVector m_items; public Q_SLOTS: - void addTag(Danbooru::DanbooruTag* tag); + void addTag(Danbooru::DanbooruTag *tag); }; - } // namespace Danbooru #endif \ No newline at end of file