Run astyle-kdelibs on the source

This commit is contained in:
Luca Beltrame 2014-10-05 09:53:19 +02:00
parent 4b85d63d68
commit 39aac8c95b
22 changed files with 1227 additions and 1264 deletions

View file

@ -17,8 +17,6 @@
* along with Danbooru Client. If not, see <http://www.gnu.org/licenses/>. * along with Danbooru Client. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "danbooruclientview.h" #include "danbooruclientview.h"
// Own // Own
@ -35,7 +33,8 @@
#include <KRun> #include <KRun>
#include <KFileDialog> #include <KFileDialog>
namespace Danbooru { namespace Danbooru
{
DanbooruClientView::DanbooruClientView(QWidget *parent): QWidget(parent), DanbooruClientView::DanbooruClientView(QWidget *parent): QWidget(parent),
m_model(new DanbooruPostModel(this)), m_model(new DanbooruPostModel(this)),
@ -60,9 +59,8 @@ namespace Danbooru {
connect(m_delegate, &DanbooruPostDelegate::postDownloadRequested, this, &DanbooruClientView::slotHandleDownload); connect(m_delegate, &DanbooruPostDelegate::postDownloadRequested, this, &DanbooruClientView::slotHandleDownload);
connect(m_delegate, &DanbooruPostDelegate::postViewRequested, this, &DanbooruClientView::slotHandleView); connect(m_delegate, &DanbooruPostDelegate::postViewRequested, this, &DanbooruClientView::slotHandleView);
// connect(m_listView, SIGNAL(clicked(const QModelIndex&)), parent(), // connect(m_listView, SIGNAL(clicked(QModelIndex)), parent(),
// SLOT(displayInfo(const QModelIndex&)); // SLOT(displayInfo(QModelIndex));
} }
@ -84,5 +82,4 @@ namespace Danbooru {
runViewer->setAutoDelete(true); runViewer->setAutoDelete(true);
} }
} // namespace Danbooru } // namespace Danbooru

View file

@ -28,7 +28,8 @@
class QTimer; class QTimer;
namespace Danbooru { namespace Danbooru
{
class DanbooruPostModel; class DanbooruPostModel;
class DanbooruPostDelegate; class DanbooruPostDelegate;

View file

@ -27,10 +27,10 @@
#include <KWallet> #include <KWallet>
using KWallet::Wallet; using KWallet::Wallet;
namespace Danbooru { namespace Danbooru
{
const QMap< QUrl, QString > initBoardSalts() const QMap< QUrl, QString > initBoardSalts()
{ {
@ -122,7 +122,6 @@ void DanbooruConnectWidget::getWalletData()
if (m_wallet->hasEntry(key)) { if (m_wallet->hasEntry(key)) {
if (m_wallet->readMap(key, valueMap) != 0) { if (m_wallet->readMap(key, valueMap) != 0) {
return; return;
} }
@ -133,7 +132,6 @@ void DanbooruConnectWidget::getWalletData()
} }
} }
void DanbooruConnectWidget::toggleLineEdits(int state) void DanbooruConnectWidget::toggleLineEdits(int state)
{ {
if (state == Qt::Unchecked) { if (state == Qt::Unchecked) {
@ -145,7 +143,6 @@ void DanbooruConnectWidget::toggleLineEdits(int state)
} }
} }
void DanbooruConnectWidget::emitRejected() void DanbooruConnectWidget::emitRejected()
{ {
Q_EMIT rejected(); Q_EMIT rejected();
@ -161,7 +158,6 @@ QString DanbooruConnectWidget::username() const
return m_username; return m_username;
} }
QString DanbooruConnectWidget::password() const QString DanbooruConnectWidget::password() const
{ {
return m_password; return m_password;
@ -197,5 +193,4 @@ void DanbooruConnectWidget::accept()
hide(); hide();
} }
}; // namespace Danbooru }; // namespace Danbooru

View file

@ -28,17 +28,20 @@
#include <QUrl> #include <QUrl>
namespace KWallet { namespace KWallet
{
class Wallet; class Wallet;
} }
namespace Danbooru { namespace Danbooru
{
class DanbooruService; class DanbooruService;
const QMap< QUrl, QString > initBoardSalts(); const QMap< QUrl, QString > initBoardSalts();
class DanbooruConnectWidget: public QWidget, public Ui::DanbooruConnectWidget { class DanbooruConnectWidget: public QWidget, public Ui::DanbooruConnectWidget
{
Q_OBJECT Q_OBJECT
public: public:
@ -61,7 +64,6 @@ namespace Danbooru {
void connectionEstablished(DanbooruService *service); void connectionEstablished(DanbooruService *service);
void rejected(); void rejected();
private Q_SLOTS: private Q_SLOTS:
void checkWallet(bool); void checkWallet(bool);
void getWalletData(); void getWalletData();

View file

@ -32,8 +32,8 @@
* @file danbooru.h * @file danbooru.h
* *
**/ **/
namespace Danbooru { namespace Danbooru
{
}; // namespace Danbooru }; // namespace Danbooru

View file

@ -22,7 +22,8 @@
#include "danboorupool.h" #include "danboorupool.h"
namespace Danbooru { namespace Danbooru
{
DanbooruPool::DanbooruPool(const QVariantMap &postData, QObject *parent): DanbooruPool::DanbooruPool(const QVariantMap &postData, QObject *parent):
QObject(parent), m_posts(QList<int>()) QObject(parent), m_posts(QList<int>())
@ -76,5 +77,4 @@ void DanbooruPool::addPosts(const QStringList& posts)
} }
} }
} // namespace Danbooru } // namespace Danbooru

View file

@ -37,7 +37,8 @@
#include <QtCore/QStringList> #include <QtCore/QStringList>
#include <QtXml/QXmlStreamAttributes> #include <QtXml/QXmlStreamAttributes>
namespace Danbooru { namespace Danbooru
{
/** /**
* @brief Class representing a Danbooru pool. * @brief Class representing a Danbooru pool.

View file

@ -33,7 +33,6 @@
#include "danboorupost.h" #include "danboorupost.h"
namespace Danbooru namespace Danbooru
{ {
@ -73,12 +72,10 @@ DanbooruPost::DanbooruPost(QXmlStreamAttributes& postData, QPixmap pixmap, QObje
m_rating = RATING_MAP.value(postData.value("rating").toString()); m_rating = RATING_MAP.value(postData.value("rating").toString());
} }
DanbooruPost::~DanbooruPost() DanbooruPost::~DanbooruPost()
{ {
} }
const QMap< QString, DanbooruPost::Rating > DanbooruPost::initRatingMap() const QMap< QString, DanbooruPost::Rating > DanbooruPost::initRatingMap()
{ {
@ -91,13 +88,11 @@ const QMap< QString, DanbooruPost::Rating > DanbooruPost::initRatingMap()
} }
bool DanbooruPost::operator==(const Danbooru::DanbooruPost &other) bool DanbooruPost::operator==(const Danbooru::DanbooruPost &other)
{ {
return m_url == other.m_url && m_id == other.m_id; return m_url == other.m_url && m_id == other.m_id;
} }
void DanbooruPost::setPixmap(const QPixmap &pixmap) void DanbooruPost::setPixmap(const QPixmap &pixmap)
{ {
m_pixmap = pixmap; m_pixmap = pixmap;
@ -155,7 +150,5 @@ Danbooru::DanbooruPost::Rating DanbooruPost::rating() const
return m_rating; return m_rating;
} }
} // namespace Danbooru } // namespace Danbooru

View file

@ -45,8 +45,8 @@
#include "danbooru.h" #include "danbooru.h"
namespace Danbooru
namespace Danbooru { {
/** /**
* @brief A class representing a Danbooru post. * @brief A class representing a Danbooru post.
@ -91,7 +91,6 @@ namespace Danbooru {
}; };
Q_DECLARE_FLAGS(Ratings, DanbooruPost::Rating) Q_DECLARE_FLAGS(Ratings, DanbooruPost::Rating)
private: private:
QPixmap m_pixmap; QPixmap m_pixmap;
@ -212,11 +211,8 @@ namespace Danbooru {
* **/ * **/
const QString toString(); const QString toString();
}; };
Q_DECLARE_OPERATORS_FOR_FLAGS(DanbooruPost::Ratings) Q_DECLARE_OPERATORS_FOR_FLAGS(DanbooruPost::Ratings)
}; // namespace Danbooru }; // namespace Danbooru

View file

@ -71,7 +71,6 @@ DanbooruService::~DanbooruService()
} }
void DanbooruService::getPostList(int page, QStringList tags, int limit) void DanbooruService::getPostList(int page, QStringList tags, int limit)
{ {
@ -97,7 +96,6 @@ void DanbooruService::getPostList(int page, QStringList tags, int limit)
connect(job, &KIO::StoredTransferJob::result, this, &DanbooruService::processPostList); connect(job, &KIO::StoredTransferJob::result, this, &DanbooruService::processPostList);
} }
void DanbooruService::getTagList(int limit, QString name) void DanbooruService::getTagList(int limit, QString name)
@ -164,7 +162,6 @@ void DanbooruService::getPool(int poolId, int page)
//qDebug() << "Final constructed pool URL" << danbooruUrl.url(); //qDebug() << "Final constructed pool URL" << danbooruUrl.url();
KIO::StoredTransferJob *job = KIO::storedGet(danbooruUrl, KIO::NoReload, KIO::StoredTransferJob *job = KIO::storedGet(danbooruUrl, KIO::NoReload,
KIO::HideProgressInfo); KIO::HideProgressInfo);
@ -329,7 +326,6 @@ void DanbooruService::setBlacklist(const QSet< QString >& blacklist)
} }
const QSet< QString > DanbooruService::blacklist() const const QSet< QString > DanbooruService::blacklist() const
{ {
return m_blacklist; return m_blacklist;
@ -469,21 +465,24 @@ void DanbooruService::processPostList(KJob* job)
connect(pixmapJob, &StoredTransferJob::result, [post, this, pix](KJob * job) mutable { connect(pixmapJob, &StoredTransferJob::result, [post, this, pix](KJob * job) mutable {
if (job->error()) { if (job->error())
{
Q_EMIT(downloadError(job->errorString())); Q_EMIT(downloadError(job->errorString()));
return; return;
} }
StoredTransferJob *jobResult = qobject_cast<StoredTransferJob *>(job); StoredTransferJob *jobResult = qobject_cast<StoredTransferJob *>(job);
if (!pix.loadFromData(jobResult->data())) { if (!pix.loadFromData(jobResult->data()))
{
Q_EMIT(downloadError(QString("Pixmap data could not be loaded"))); Q_EMIT(downloadError(QString("Pixmap data could not be loaded")));
return; return;
} }
post->setPixmap(pix); post->setPixmap(pix);
if (m_cache) { if (m_cache)
{
//qDebug() << "Inserting item in cache"; //qDebug() << "Inserting item in cache";
m_cache->insertPixmap(post->thumbnailUrl().url(), pix); m_cache->insertPixmap(post->thumbnailUrl().url(), pix);
} }
@ -493,7 +492,8 @@ void DanbooruService::processPostList(KJob* job)
//qDebug() << "Current posts remaining" << m_currentPosts; //qDebug() << "Current posts remaining" << m_currentPosts;
Q_EMIT(postDownloaded(post)); Q_EMIT(postDownloaded(post));
if (m_postsToFetch == 0) { if (m_postsToFetch == 0)
{
qDebug() << "Post download finished"; qDebug() << "Post download finished";
Q_EMIT(postDownloadFinished()); Q_EMIT(postDownloadFinished());
} }
@ -504,8 +504,6 @@ void DanbooruService::processPostList(KJob* job)
} }
} }
void DanbooruService::processTagList(KJob *job) void DanbooruService::processTagList(KJob *job)
@ -513,7 +511,6 @@ void DanbooruService::processTagList(KJob* job)
} }
void DanbooruService::processRelatedTagList(KJob *job) void DanbooruService::processRelatedTagList(KJob *job)
{ {
@ -522,7 +519,6 @@ void DanbooruService::processRelatedTagList(KJob* job)
void DanbooruService::processPoolList(KJob *job) void DanbooruService::processPoolList(KJob *job)
{ {
if (job->error()) { if (job->error()) {
Q_EMIT(downloadError(job->errorString())); Q_EMIT(downloadError(job->errorString()));
} }

View file

@ -24,7 +24,6 @@
#ifndef DANBOORUSERVICE_H #ifndef DANBOORUSERVICE_H
#define DANBOORUSERVICE_H #define DANBOORUSERVICE_H
/** /**
* @brief Classes to interact with Danbooru boards * @brief Classes to interact with Danbooru boards
* @file danbooruservice.h * @file danbooruservice.h
@ -56,7 +55,8 @@ class KJob;
using Danbooru::DanbooruTag; using Danbooru::DanbooruTag;
namespace Danbooru { namespace Danbooru
{
class DanbooruPool; class DanbooruPool;
@ -231,7 +231,6 @@ namespace Danbooru {
**/ **/
void poolDownloadFinished(); void poolDownloadFinished();
/** /**
* Emitted when a download error occurred. * Emitted when a download error occurred.
* *

View file

@ -82,5 +82,4 @@ Danbooru::DanbooruTag::TagType DanbooruTag::type() const
return m_tagType; return m_tagType;
} }
}; // namespace Danbooru }; // namespace Danbooru

View file

@ -20,7 +20,6 @@
* *
*/ */
#ifndef DANBOORUTAG_H #ifndef DANBOORUTAG_H
#define DANBOORUTAG_H #define DANBOORUTAG_H
@ -29,7 +28,8 @@
#include "danbooru.h" #include "danbooru.h"
namespace Danbooru { namespace Danbooru
{
class DanbooruTag : public QObject class DanbooruTag : public QObject
{ {

View file

@ -34,7 +34,8 @@
#include <QDebug> #include <QDebug>
namespace Danbooru { namespace Danbooru
{
QUrl requestUrl(QUrl &url, const QString &path, QUrl requestUrl(QUrl &url, const QString &path,
const QString &username, const QString &password, const QString &username, const QString &password,
@ -173,8 +174,8 @@ namespace Danbooru {
return postData; return postData;
} }
bool isPostBlacklisted(DanbooruPost *post, QSet<QString> blacklist, DanbooruPost::Ratings maxRating)
bool isPostBlacklisted(DanbooruPost *post, QSet<QString> blacklist, DanbooruPost::Ratings maxRating ) { {
if (post->rating() > maxRating) { if (post->rating() > maxRating) {
return true; return true;

View file

@ -39,7 +39,8 @@
* *
**/ **/
namespace Danbooru { namespace Danbooru
{
typedef QMap<QString, QString> dictMap; typedef QMap<QString, QString> dictMap;
@ -66,7 +67,6 @@ namespace Danbooru {
const QString &password, const dictMap &parameters, const QString &password, const dictMap &parameters,
const QStringList &tags); const QStringList &tags);
/** @brief Generate a request URL for a Danbooru board. /** @brief Generate a request URL for a Danbooru board.
* *
* This is an overloaded function provided for convenience. * This is an overloaded function provided for convenience.
@ -87,7 +87,6 @@ namespace Danbooru {
QUrl requestUrl(QUrl &url, const QString &path, const QString &username, QUrl requestUrl(QUrl &url, const QString &path, const QString &username,
const QString &password, const dictMap &parameters); const QString &password, const dictMap &parameters);
/** @brief Generate a request URL for a Danbooru board. /** @brief Generate a request URL for a Danbooru board.
* *
* This is an overloaded function provided for convenience. * This is an overloaded function provided for convenience.
@ -105,7 +104,6 @@ namespace Danbooru {
QUrl requestUrl(QUrl &url, const QString &path, const QString &username, QUrl requestUrl(QUrl &url, const QString &path, const QString &username,
const QString &password); const QString &password);
QList<QVariant> parseDanbooruResult(QByteArray data, QString xlmElement, QList<QVariant> parseDanbooruResult(QByteArray data, QString xlmElement,
bool *result); bool *result);
QVariant parseDanbooruResult(QByteArray data, bool *result); QVariant parseDanbooruResult(QByteArray data, bool *result);

View file

@ -53,23 +53,16 @@ int main(int argc, char **argv)
danbooru_client *widget = new danbooru_client; danbooru_client *widget = new danbooru_client;
// see if we are starting with session management // see if we are starting with session management
if (app.isSessionRestored()) if (app.isSessionRestored()) {
{
RESTORE(danbooru_client); RESTORE(danbooru_client);
} } else {
else
{
// no session.. just start up normally // no session.. just start up normally
if (parser.positionalArguments().count() == 0) if (parser.positionalArguments().count() == 0) {
{
//danbooru_client *widget = new danbooru_client; //danbooru_client *widget = new danbooru_client;
widget->show(); widget->show();
} } else {
else
{
int i = 0; int i = 0;
for (; i < parser.positionalArguments().count(); i++) for (; i < parser.positionalArguments().count(); i++) {
{
//danbooru_client *widget = new danbooru_client; //danbooru_client *widget = new danbooru_client;
widget->show(); widget->show();
} }

View file

@ -30,7 +30,8 @@
#include <KLocale> #include <KLocale>
namespace Danbooru { namespace Danbooru
{
DanbooruMainWindow::DanbooruMainWindow() DanbooruMainWindow::DanbooruMainWindow()
: KXmlGuiWindow(), : KXmlGuiWindow(),
@ -54,7 +55,6 @@ namespace Danbooru {
// toolbar position, icon size, etc. // toolbar position, icon size, etc.
setupGUI(); setupGUI();
} }
DanbooruMainWindow::~DanbooruMainWindow() DanbooruMainWindow::~DanbooruMainWindow()
@ -64,8 +64,6 @@ namespace Danbooru {
void DanbooruMainWindow::setupActions() void DanbooruMainWindow::setupActions()
{ {
QAction *connectAction = new QAction( QAction *connectAction = new QAction(
QIcon::fromTheme(QLatin1String("document-open-remote")), QIcon::fromTheme(QLatin1String("document-open-remote")),
i18n("Connect..."), i18n("Connect..."),
@ -109,7 +107,6 @@ namespace Danbooru {
} }
} // namespace Danbooru } // namespace Danbooru
#include "DanbooruMainWindow.moc" #include "DanbooruMainWindow.moc"

View file

@ -23,10 +23,10 @@
#ifndef DANBOORU_CLIENT_H #ifndef DANBOORU_CLIENT_H
#define DANBOORU_CLIENT_H #define DANBOORU_CLIENT_H
#include <KXmlGuiWindow> #include <KXmlGuiWindow>
namespace Danbooru { namespace Danbooru
{
class DanbooruClientView; class DanbooruClientView;
class DanbooruService; class DanbooruService;
@ -70,7 +70,6 @@ namespace Danbooru {
DanbooruService *m_service; DanbooruService *m_service;
DanbooruConnectWidget *m_connectWidget; DanbooruConnectWidget *m_connectWidget;
}; };
} // namespace Danbooru } // namespace Danbooru

View file

@ -39,8 +39,8 @@
#include <KIconLoader> #include <KIconLoader>
#include <KFormat> #include <KFormat>
namespace Danbooru
namespace Danbooru { {
const int DanbooruPostDelegate::MARGIN = 5; const int DanbooruPostDelegate::MARGIN = 5;
@ -124,7 +124,6 @@ namespace Danbooru {
Qt::KeepAspectRatio, Qt::KeepAspectRatio,
Qt::SmoothTransformation); Qt::SmoothTransformation);
QRect pixRect = scaled.rect(); QRect pixRect = scaled.rect();
pixRect.moveCenter(rect.center()); pixRect.moveCenter(rect.center());
@ -257,5 +256,4 @@ namespace Danbooru {
} }
} }
} // namespace Danbooru } // namespace Danbooru

View file

@ -37,8 +37,8 @@ class QListView;
class QPainter; class QPainter;
class QPushButton; class QPushButton;
namespace Danbooru
namespace Danbooru { {
/** /**
* @brief Specific delegate for Danbooru items. * @brief Specific delegate for Danbooru items.
@ -81,7 +81,6 @@ namespace Danbooru {
*/ */
void postViewRequested(QUrl postUrl); void postViewRequested(QUrl postUrl);
/** /**
* @brief Emitted when the download button is clicked. * @brief Emitted when the download button is clicked.
* *
@ -90,13 +89,10 @@ namespace Danbooru {
*/ */
void postDownloadRequested(QUrl postUrl); void postDownloadRequested(QUrl postUrl);
private Q_SLOTS: private Q_SLOTS:
void viewButtonClicked(); void viewButtonClicked();
void downloadButtonClicked(); void downloadButtonClicked();
}; };
} // namespace Danbooru } // namespace Danbooru

View file

@ -30,7 +30,8 @@
#include <QDebug> #include <QDebug>
#include <QPixmap> #include <QPixmap>
namespace Danbooru { namespace Danbooru
{
DanbooruPostModel::DanbooruPostModel(QObject *parent): QAbstractListModel(parent) DanbooruPostModel::DanbooruPostModel(QObject *parent): QAbstractListModel(parent)
{ {
@ -101,7 +102,8 @@ namespace Danbooru {
return QVariant(); return QVariant();
} }
void DanbooruPostModel::clear() { void DanbooruPostModel::clear()
{
if (m_items.isEmpty()) { if (m_items.isEmpty()) {
return; return;

View file

@ -32,7 +32,8 @@
#include <QAbstractListModel> #include <QAbstractListModel>
#include <QVector> #include <QVector>
namespace Danbooru { namespace Danbooru
{
class DanbooruPost; class DanbooruPost;
@ -76,5 +77,4 @@ namespace Danbooru {
}; };
}; // namespace Danbooru }; // namespace Danbooru
#endif // DANBOORUPOSTMODEL_H #endif // DANBOORUPOSTMODEL_H