Commit d7d741a0 authored by Alexander Lohnau's avatar Alexander Lohnau 💬
Browse files

Run clang-format

If you want git blame to ignore formatting revisions run:
git config blame.ignoreRevsFile .git-blame-ignore-revs
parent 78134c26
...@@ -26,8 +26,9 @@ ...@@ -26,8 +26,9 @@
using namespace Milou; using namespace Milou;
DragHelper::DragHelper(QObject* parent) : QObject(parent) DragHelper::DragHelper(QObject *parent)
, m_dragIconSize(32) : QObject(parent)
, m_dragIconSize(32)
{ {
} }
...@@ -58,9 +59,10 @@ void DragHelper::startDrag(QQuickItem *item, QMimeData *mimeData, const QIcon &i ...@@ -58,9 +59,10 @@ void DragHelper::startDrag(QQuickItem *item, QMimeData *mimeData, const QIcon &i
{ {
// This allows the caller to return, making sure we don't crash if // This allows the caller to return, making sure we don't crash if
// the caller is destroyed mid-drag // the caller is destroyed mid-drag
// clang-format off
QMetaObject::invokeMethod(this, "doDrag", Qt::QueuedConnection, QMetaObject::invokeMethod(this, "doDrag", Qt::QueuedConnection,
Q_ARG(QQuickItem*, item), Q_ARG(QMimeData*, mimeData), Q_ARG(QIcon, icon)); Q_ARG(QQuickItem*, item), Q_ARG(QMimeData*, mimeData), Q_ARG(QIcon, icon));
// clang-format on
} }
void DragHelper::startDrag(QQuickItem *item, QMimeData *mimeData, const QString &iconName) void DragHelper::startDrag(QQuickItem *item, QMimeData *mimeData, const QString &iconName)
...@@ -81,4 +83,3 @@ void DragHelper::doDrag(QQuickItem *item, QMimeData *mimeData, const QIcon &icon ...@@ -81,4 +83,3 @@ void DragHelper::doDrag(QQuickItem *item, QMimeData *mimeData, const QIcon &icon
Q_EMIT dropped(); Q_EMIT dropped();
} }
...@@ -20,40 +20,40 @@ ...@@ -20,40 +20,40 @@
#ifndef DRAGHELPER_H #ifndef DRAGHELPER_H
#define DRAGHELPER_H #define DRAGHELPER_H
#include <QObject>
#include <QIcon> #include <QIcon>
#include <QObject>
#include "milou_export.h" #include "milou_export.h"
class QQuickItem; class QQuickItem;
class QMimeData; class QMimeData;
namespace Milou { namespace Milou
{
class MILOU_EXPORT DragHelper : public QObject class MILOU_EXPORT DragHelper : public QObject
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY(int dragIconSize READ dragIconSize WRITE setDragIconSize NOTIFY dragIconSizeChanged) Q_PROPERTY(int dragIconSize READ dragIconSize WRITE setDragIconSize NOTIFY dragIconSizeChanged)
public: public:
explicit DragHelper(QObject *parent = nullptr); explicit DragHelper(QObject *parent = nullptr);
~DragHelper() override; ~DragHelper() override;
int dragIconSize() const; int dragIconSize() const;
void setDragIconSize(int size); void setDragIconSize(int size);
Q_INVOKABLE bool isDrag(int oldX, int oldY, int newX, int newY) const; Q_INVOKABLE bool isDrag(int oldX, int oldY, int newX, int newY) const;
// TODO KF6 merge the two // TODO KF6 merge the two
Q_INVOKABLE void startDrag(QQuickItem* item, QMimeData *mimeData, const QIcon &icon = QIcon()); Q_INVOKABLE void startDrag(QQuickItem *item, QMimeData *mimeData, const QIcon &icon = QIcon());
Q_INVOKABLE void startDrag(QQuickItem* item, QMimeData *mimeData, const QString &iconName); Q_INVOKABLE void startDrag(QQuickItem *item, QMimeData *mimeData, const QString &iconName);
Q_SIGNALS: Q_SIGNALS:
void dragIconSizeChanged(); void dragIconSizeChanged();
void dropped(); void dropped();
private: private:
int m_dragIconSize; int m_dragIconSize;
Q_INVOKABLE void doDrag(QQuickItem* item, QMimeData *mimeData, const QIcon &icon = QIcon()); Q_INVOKABLE void doDrag(QQuickItem *item, QMimeData *mimeData, const QIcon &icon = QIcon());
}; };
} }
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
using namespace Milou; using namespace Milou;
MouseHelper::MouseHelper(QObject* parent) MouseHelper::MouseHelper(QObject *parent)
: QObject(parent) : QObject(parent)
{ {
} }
......
...@@ -27,14 +27,14 @@ ...@@ -27,14 +27,14 @@
#include "milou_export.h" #include "milou_export.h"
namespace Milou { namespace Milou
{
class MILOU_EXPORT MouseHelper : public QObject class MILOU_EXPORT MouseHelper : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit MouseHelper(QObject* parent = nullptr); explicit MouseHelper(QObject *parent = nullptr);
~MouseHelper() override; ~MouseHelper() override;
Q_INVOKABLE QPointF globalMousePosition() const; Q_INVOKABLE QPointF globalMousePosition() const;
......
...@@ -33,21 +33,21 @@ ...@@ -33,21 +33,21 @@
using namespace Milou; using namespace Milou;
Preview::Preview(QQuickItem* parent) Preview::Preview(QQuickItem *parent)
: QQuickItem(parent) : QQuickItem(parent)
, m_loaded(false) , m_loaded(false)
, m_declarativeItem(nullptr) , m_declarativeItem(nullptr)
, m_filePlugin(nullptr) , m_filePlugin(nullptr)
{ {
//setFlag(QGraphicsItem::ItemHasNoContents, false); // setFlag(QGraphicsItem::ItemHasNoContents, false);
m_plugins = allPlugins(); m_plugins = allPlugins();
for (PreviewPlugin* plugin : qAsConst(m_plugins)) { for (PreviewPlugin *plugin : qAsConst(m_plugins)) {
connect(plugin, &PreviewPlugin::previewGenerated, connect(plugin, &PreviewPlugin::previewGenerated, this, &Preview::slotPreviewGenerated);
this, &Preview::slotPreviewGenerated);
if (plugin->mimetypes().contains(QStringLiteral("file"))) if (plugin->mimetypes().contains(QStringLiteral("file"))) {
m_filePlugin = plugin; m_filePlugin = plugin;
}
} }
// When the object is created, it doesn't have a QQmlContext // When the object is created, it doesn't have a QQmlContext
...@@ -56,8 +56,8 @@ Preview::Preview(QQuickItem* parent) ...@@ -56,8 +56,8 @@ Preview::Preview(QQuickItem* parent)
void Preview::setPluginContexts() void Preview::setPluginContexts()
{ {
QQmlContext* context = qmlContext(parentItem()); QQmlContext *context = qmlContext(parentItem());
for (PreviewPlugin* plugin : qAsConst(m_plugins)) { for (PreviewPlugin *plugin : qAsConst(m_plugins)) {
plugin->setContext(context); plugin->setContext(context);
} }
} }
...@@ -69,8 +69,9 @@ Preview::~Preview() ...@@ -69,8 +69,9 @@ Preview::~Preview()
void Preview::refresh() void Preview::refresh()
{ {
if (m_oldUrl == m_url && m_oldMimetype == m_mimetype) { if (m_oldUrl == m_url && m_oldMimetype == m_mimetype) {
if (m_declarativeItem) if (m_declarativeItem) {
Q_EMIT loadingFinished(); Q_EMIT loadingFinished();
}
return; return;
} }
...@@ -78,7 +79,7 @@ void Preview::refresh() ...@@ -78,7 +79,7 @@ void Preview::refresh()
bool foundPlugin = false; bool foundPlugin = false;
QUrl url = QUrl::fromLocalFile(m_url); QUrl url = QUrl::fromLocalFile(m_url);
for (PreviewPlugin* plugin : qAsConst(m_plugins)) { for (PreviewPlugin *plugin : qAsConst(m_plugins)) {
const QStringList mimeTypes = plugin->mimetypes(); const QStringList mimeTypes = plugin->mimetypes();
for (const QString &mime : mimeTypes) { for (const QString &mime : mimeTypes) {
if (m_mimetype.startsWith(mime)) { if (m_mimetype.startsWith(mime)) {
...@@ -101,7 +102,7 @@ void Preview::refresh() ...@@ -101,7 +102,7 @@ void Preview::refresh()
} }
} }
void Preview::slotPreviewGenerated(QQuickItem* item) void Preview::slotPreviewGenerated(QQuickItem *item)
{ {
clear(); clear();
...@@ -128,7 +129,7 @@ QString Preview::mimetype() const ...@@ -128,7 +129,7 @@ QString Preview::mimetype() const
return m_mimetype; return m_mimetype;
} }
void Preview::setMimetype(const QString& mime) void Preview::setMimetype(const QString &mime)
{ {
if (m_mimetype != mime) { if (m_mimetype != mime) {
m_oldMimetype = m_mimetype; m_oldMimetype = m_mimetype;
...@@ -136,7 +137,7 @@ void Preview::setMimetype(const QString& mime) ...@@ -136,7 +137,7 @@ void Preview::setMimetype(const QString& mime)
} }
} }
void Preview::setUrl(const QString& url) void Preview::setUrl(const QString &url)
{ {
if (m_url != url) { if (m_url != url) {
m_oldUrl = m_url; m_oldUrl = m_url;
...@@ -149,7 +150,7 @@ QString Preview::url() const ...@@ -149,7 +150,7 @@ QString Preview::url() const
return m_url; return m_url;
} }
void Preview::setHighlight(const QString& highlight) void Preview::setHighlight(const QString &highlight)
{ {
m_highlight = highlight; m_highlight = highlight;
} }
...@@ -159,18 +160,18 @@ QString Preview::highlight() const ...@@ -159,18 +160,18 @@ QString Preview::highlight() const
return m_highlight; return m_highlight;
} }
QList<PreviewPlugin*> Preview::allPlugins() QList<PreviewPlugin *> Preview::allPlugins()
{ {
KService::List serviceList = KServiceTypeTrader::self()->query(QStringLiteral("MilouPreviewPlugin")); KService::List serviceList = KServiceTypeTrader::self()->query(QStringLiteral("MilouPreviewPlugin"));
QList<PreviewPlugin*> plugins; QList<PreviewPlugin *> plugins;
KService::List::const_iterator it; KService::List::const_iterator it;
for (it = serviceList.constBegin(); it != serviceList.constEnd(); it++) { for (it = serviceList.constBegin(); it != serviceList.constEnd(); it++) {
KService::Ptr service = *it; KService::Ptr service = *it;
QString error; QString error;
PreviewPlugin* p = service->createInstance<PreviewPlugin>(this, QVariantList(), &error); PreviewPlugin *p = service->createInstance<PreviewPlugin>(this, QVariantList(), &error);
if(!p) { if (!p) {
qWarning() << "Could not create PreviewPlugin:" << service->library(); qWarning() << "Could not create PreviewPlugin:" << service->library();
qWarning() << error; qWarning() << error;
continue; continue;
......
...@@ -23,11 +23,11 @@ ...@@ -23,11 +23,11 @@
#ifndef PREVIEW_H #ifndef PREVIEW_H
#define PREVIEW_H #define PREVIEW_H
#include <QQuickItem>
#include "milou_export.h" #include "milou_export.h"
#include <QQuickItem>
namespace Milou { namespace Milou
{
class PreviewPlugin; class PreviewPlugin;
class MILOU_EXPORT Preview : public QQuickItem class MILOU_EXPORT Preview : public QQuickItem
...@@ -39,19 +39,22 @@ class MILOU_EXPORT Preview : public QQuickItem ...@@ -39,19 +39,22 @@ class MILOU_EXPORT Preview : public QQuickItem
Q_PROPERTY(bool loaded READ loaded) Q_PROPERTY(bool loaded READ loaded)
public: public:
explicit Preview(QQuickItem* parent = nullptr); explicit Preview(QQuickItem *parent = nullptr);
~Preview() override; ~Preview() override;
QString mimetype() const; QString mimetype() const;
void setMimetype(const QString& mime); void setMimetype(const QString &mime);
QString url() const; QString url() const;
void setUrl(const QString& url); void setUrl(const QString &url);
QString highlight() const; QString highlight() const;
void setHighlight(const QString& highlight); void setHighlight(const QString &highlight);
bool loaded() const { return m_loaded; } bool loaded() const
{
return m_loaded;
}
Q_SIGNALS: Q_SIGNALS:
void loadingFinished(); void loadingFinished();
...@@ -61,7 +64,7 @@ public Q_SLOTS: ...@@ -61,7 +64,7 @@ public Q_SLOTS:
void clear(); void clear();
private Q_SLOTS: private Q_SLOTS:
void slotPreviewGenerated(QQuickItem* item); void slotPreviewGenerated(QQuickItem *item);
void setPluginContexts(); void setPluginContexts();
...@@ -74,11 +77,11 @@ private: ...@@ -74,11 +77,11 @@ private:
QString m_oldMimetype; QString m_oldMimetype;
QString m_oldUrl; QString m_oldUrl;
QQuickItem* m_declarativeItem; QQuickItem *m_declarativeItem;
QList<Milou::PreviewPlugin*> m_plugins; QList<Milou::PreviewPlugin *> m_plugins;
QList<Milou::PreviewPlugin*> allPlugins(); QList<Milou::PreviewPlugin *> allPlugins();
PreviewPlugin* m_filePlugin; PreviewPlugin *m_filePlugin;
}; };
} }
......
...@@ -26,18 +26,17 @@ ...@@ -26,18 +26,17 @@
using namespace Milou; using namespace Milou;
PreviewPlugin::PreviewPlugin(QObject* parent) PreviewPlugin::PreviewPlugin(QObject *parent)
: QObject(parent) : QObject(parent)
, m_context(nullptr) , m_context(nullptr)
{ {
} }
PreviewPlugin::~PreviewPlugin() PreviewPlugin::~PreviewPlugin()
{ {
} }
void PreviewPlugin::setUrl(const QUrl& url) void PreviewPlugin::setUrl(const QUrl &url)
{ {
m_url = url; m_url = url;
} }
...@@ -47,7 +46,7 @@ QUrl PreviewPlugin::url() const ...@@ -47,7 +46,7 @@ QUrl PreviewPlugin::url() const
return m_url; return m_url;
} }
void PreviewPlugin::setMimetype(const QString& mimetype) void PreviewPlugin::setMimetype(const QString &mimetype)
{ {
m_mimetype = mimetype; m_mimetype = mimetype;
} }
...@@ -57,7 +56,7 @@ QString PreviewPlugin::mimetype() const ...@@ -57,7 +56,7 @@ QString PreviewPlugin::mimetype() const
return m_mimetype; return m_mimetype;
} }
void PreviewPlugin::setHighlight(const QString& term) void PreviewPlugin::setHighlight(const QString &term)
{ {
m_highlight = term; m_highlight = term;
} }
...@@ -67,26 +66,27 @@ QString PreviewPlugin::highlight() const ...@@ -67,26 +66,27 @@ QString PreviewPlugin::highlight() const
return m_highlight; return m_highlight;
} }
void PreviewPlugin::setContext(QQmlContext* context) void PreviewPlugin::setContext(QQmlContext *context)
{ {
m_context = context; m_context = context;
} }
QQmlContext* PreviewPlugin::context() QQmlContext *PreviewPlugin::context()
{ {
Q_ASSERT(m_context); Q_ASSERT(m_context);
return m_context; return m_context;
} }
void PreviewPlugin::highlight(const QTextDocument* doc) const void PreviewPlugin::highlight(const QTextDocument *doc) const
{ {
QTextCursor cursor; QTextCursor cursor;
const QStringList highlights = highlight().split(QLatin1Char(' '), Qt::SkipEmptyParts); const QStringList highlights = highlight().split(QLatin1Char(' '), Qt::SkipEmptyParts);
for (const QString &text : highlights) { for (const QString &text : highlights) {
while (1) { while (1) {
cursor = doc->find(text, cursor); cursor = doc->find(text, cursor);
if (cursor.isNull()) if (cursor.isNull()) {
break; break;
}
QString selection = cursor.selectedText(); QString selection = cursor.selectedText();
......
...@@ -23,19 +23,19 @@ ...@@ -23,19 +23,19 @@
#ifndef MILOU_PREVIEWPLUGIN_H #ifndef MILOU_PREVIEWPLUGIN_H
#define MILOU_PREVIEWPLUGIN_H #define MILOU_PREVIEWPLUGIN_H
#include "milou_export.h"
#include <KService> #include <KService>
#include <QQuickItem> #include <QQuickItem>
#include "milou_export.h"
#include <QTextDocument> #include <QTextDocument>
namespace Milou { namespace Milou
{
class MILOU_EXPORT PreviewPlugin : public QObject class MILOU_EXPORT PreviewPlugin : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit PreviewPlugin(QObject* parent); explicit PreviewPlugin(QObject *parent);
~PreviewPlugin() override; ~PreviewPlugin() override;
/** /**
...@@ -57,42 +57,43 @@ public: ...@@ -57,42 +57,43 @@ public:
* Retrieve the context, this allows you to create * Retrieve the context, this allows you to create
* your own preview plugins in QML * your own preview plugins in QML
*/ */
QQmlContext* context(); QQmlContext *context();
void setContext(QQmlContext* context); void setContext(QQmlContext *context);
/** /**
* The url of the preview being generated * The url of the preview being generated
*/ */
QUrl url() const; QUrl url() const;
void setUrl(const QUrl& url); void setUrl(const QUrl &url);
/** /**
* The mimetype of the url for whcih the preview * The mimetype of the url for whcih the preview
* should be generated * should be generated
*/ */
QString mimetype() const; QString mimetype() const;
void setMimetype(const QString& mimetype); void setMimetype(const QString &mimetype);
/** /**
* A term that should be highlighted in the preview * A term that should be highlighted in the preview
* that is generated * that is generated
*/ */
QString highlight() const; QString highlight() const;
void setHighlight(const QString& term); void setHighlight(const QString &term);
Q_SIGNALS: Q_SIGNALS:
void previewGenerated(QQuickItem* graphicsItem); void previewGenerated(QQuickItem *graphicsItem);
protected: protected:
/** /**
* Highlights all the occurrences of highlight in the document * Highlights all the occurrences of highlight in the document
*/ */
void highlight(const QTextDocument* doc) const; void highlight(const QTextDocument *doc) const;
bool onHighDPI() const; bool onHighDPI() const;