Commit 23e8b596 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

run git clang-format

parent 0b94f746
......@@ -15,22 +15,19 @@
#include <Kdelibs4ConfigMigrator>
#include <QDBusConnection>
#include <KWindowSystem>
#include <QDBusConnection>
NotesAgent::NotesAgent(const QString &id)
: Akonadi::AgentBase(id)
{
Kdelibs4ConfigMigrator migrate(QStringLiteral("notesagent"));
migrate.setConfigFiles(QStringList()
<< QStringLiteral("akonadi_notes_agentrc")
<< QStringLiteral("akonadi_notes_agent.notifyrc"));
migrate.setConfigFiles(QStringList() << QStringLiteral("akonadi_notes_agentrc") << QStringLiteral("akonadi_notes_agent.notifyrc"));
migrate.migrate();
mNotesManager = new NotesManager(this);
new NotesAgentAdaptor(this);
QDBusConnection::sessionBus().registerObject(QStringLiteral("/NotesAgent"),
this, QDBusConnection::ExportAdaptors);
QDBusConnection::sessionBus().registerObject(QStringLiteral("/NotesAgent"), this, QDBusConnection::ExportAdaptors);
setNeedsNetwork(true);
......
......@@ -4,11 +4,11 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "notesagentalarmdialog.h"
#include "notesagentnotedialog.h"
#include "widget/notelistwidget.h"
#include "attributes/notealarmattribute.h"
#include "alarms/notealarmdialog.h"
#include "attributes/notealarmattribute.h"
#include "notesagent_debug.h"
#include "notesagentnotedialog.h"
#include "widget/notelistwidget.h"
#include <KMime/KMimeMessage>
#include <ItemFetchJob>
......@@ -16,21 +16,21 @@
#include <ItemModifyJob>
#include <KLocalizedString>
#include <QDateTime>
#include <QMenu>
#include <QAction>
#include <KMessageBox>
#include <QAction>
#include <QDateTime>
#include <QIcon>
#include <QMenu>
#include <QListWidget>
#include <QLabel>
#include <QVBoxLayout>
#include <QPointer>
#include <KConfigGroup>
#include <KSharedConfig>
#include <QDialogButtonBox>
#include <KConfigGroup>
#include <QPushButton>
#include <QLabel>
#include <QListWidget>
#include <QLocale>
#include <QPointer>
#include <QPushButton>
#include <QVBoxLayout>
NotesAgentAlarmDialog::NotesAgentAlarmDialog(QWidget *parent)
: QDialog(parent)
......@@ -131,7 +131,7 @@ void NotesAgentAlarmDialog::slotItemDoubleClicked(QListWidgetItem *item)
void NotesAgentAlarmDialog::slotShowNote()
{
//deleted on close
// deleted on close
const Akonadi::Item::Id id = mListWidget->currentItemId();
if (id != -1) {
auto *dlg = new NotesAgentNoteDialog;
......
......@@ -5,12 +5,13 @@
*/
#ifndef NOTESAGENTALARMDIALOG_H
#define NOTESAGENTALARMDIALOG_H
#include <QDialog>
#include <Item>
#include <QDialog>
class QListWidget;
class QLabel;
class QListWidgetItem;
namespace NoteShared {
namespace NoteShared
{
class NoteListWidget;
}
class KJob;
......
......@@ -4,12 +4,12 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "notesagentnotedialog.h"
#include "attributes/notedisplayattribute.h"
#include "notesagent_debug.h"
#include <ItemFetchJob>
#include <ItemFetchScope>
#include "attributes/notedisplayattribute.h"
#include <KPIMTextEdit/RichTextEditorWidget>
#include <KPIMTextEdit/RichTextEditor>
#include <KPIMTextEdit/RichTextEditorWidget>
#include <KSharedConfig>
......@@ -17,11 +17,11 @@
#include <QIcon>
#include <QLineEdit>
#include <QVBoxLayout>
#include <QDialogButtonBox>
#include <KConfigGroup>
#include <QDialogButtonBox>
#include <QLineEdit>
#include <QPushButton>
#include <QVBoxLayout>
NotesAgentNoteDialog::NotesAgentNoteDialog(QWidget *parent)
: QDialog(parent)
......@@ -55,7 +55,7 @@ void NotesAgentNoteDialog::setNoteId(Akonadi::Item::Id id)
Akonadi::Item item(id);
auto *job = new Akonadi::ItemFetchJob(item, this);
job->fetchScope().fetchFullPayload(true);
job->fetchScope().fetchAttribute< NoteShared::NoteDisplayAttribute >();
job->fetchScope().fetchAttribute<NoteShared::NoteDisplayAttribute>();
connect(job, &Akonadi::ItemFetchJob::result, this, &NotesAgentNoteDialog::slotFetchItem);
}
......@@ -87,7 +87,7 @@ void NotesAgentNoteDialog::slotFetchItem(KJob *job)
const auto *attr = item.attribute<NoteShared::NoteDisplayAttribute>();
if (attr) {
mNote->editor()->setTextColor(attr->backgroundColor());
//TODO add background color.
// TODO add background color.
}
}
}
......
......@@ -6,11 +6,12 @@
#ifndef NOTESAGENTNOTEDIALOG_H
#define NOTESAGENTNOTEDIALOG_H
#include <QDialog>
#include <Item>
#include <QDialog>
class QLineEdit;
class KJob;
namespace KPIMTextEdit {
namespace KPIMTextEdit
{
class RichTextEditorWidget;
}
class NotesAgentNoteDialog : public QDialog
......
......@@ -6,20 +6,20 @@
#include "notesagentsettingsdialog.h"
#include "knotes-version.h"
#include <QMenu>
#include <KAboutData>
#include <KHelpMenu>
#include <KLocalizedString>
#include <QIcon>
#include <KAboutData>
#include <KNotifyConfigWidget>
#include <QIcon>
#include <QMenu>
#include <QTabWidget>
#include <KConfigGroup>
#include <KSharedConfig>
#include <QApplication>
#include <QDialogButtonBox>
#include <KConfigGroup>
#include <QPushButton>
#include <QTabWidget>
#include <QVBoxLayout>
#include <QApplication>
#include <config/notenetworkconfig.h>
......@@ -52,23 +52,20 @@ NotesAgentSettingsDialog::NotesAgentSettingsDialog(QWidget *parent)
mainLayout->addWidget(buttonBox);
readConfig();
KAboutData aboutData = KAboutData(
QStringLiteral("notesagent"),
i18n("Notes Agent"),
QStringLiteral(KNOTES_VERSION),
i18n("Notes Agent."),
KAboutLicense::GPL_V2,
i18n("Copyright (C) 2013-2020 Laurent Montel"));
KAboutData aboutData = KAboutData(QStringLiteral("notesagent"),
i18n("Notes Agent"),
QStringLiteral(KNOTES_VERSION),
i18n("Notes Agent."),
KAboutLicense::GPL_V2,
i18n("Copyright (C) 2013-2020 Laurent Montel"));
aboutData.addAuthor(i18n("Laurent Montel"),
i18n("Maintainer"), QStringLiteral("montel@kde.org"));
aboutData.addAuthor(i18n("Laurent Montel"), i18n("Maintainer"), QStringLiteral("montel@kde.org"));
QApplication::setWindowIcon(QIcon::fromTheme(QStringLiteral("knotes")));
aboutData.setTranslator(i18nc("NAME OF TRANSLATORS", "Your names"),
i18nc("EMAIL OF TRANSLATORS", "Your emails"));
aboutData.setTranslator(i18nc("NAME OF TRANSLATORS", "Your names"), i18nc("EMAIL OF TRANSLATORS", "Your emails"));
auto *helpMenu = new KHelpMenu(this, aboutData, true);
//Initialize menu
// Initialize menu
QMenu *menu = helpMenu->menu();
helpMenu->action(KHelpMenu::menuAboutApp)->setIcon(QIcon::fromTheme(QStringLiteral("knotes")));
buttonBox->button(QDialogButtonBox::Help)->setMenu(menu);
......
......@@ -9,7 +9,8 @@
#include <QDialog>
class KNotifyConfigWidget;
namespace NoteShared {
namespace NoteShared
{
class NoteNetworkConfigWidget;
}
class NotesAgentSettingsDialog : public QDialog
......
......@@ -4,28 +4,28 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "notesmanager.h"
#include "notesharedglobalconfig.h"
#include "network/notesnetworkreceiver.h"
#include "job/createnewnotejob.h"
#include "akonadi/noteschangerecorder.h"
#include "attributes/notealarmattribute.h"
#include "attributes/notedisplayattribute.h"
#include "attributes/notelockattribute.h"
#include "job/createnewnotejob.h"
#include "network/notesnetworkreceiver.h"
#include "notesharedglobalconfig.h"
#include <AkonadiCore/Session>
#include <Akonadi/Notes/NoteUtils>
#include <AkonadiCore/ChangeRecorder>
#include <AkonadiCore/Collection>
#include <AkonadiCore/CollectionFetchJob>
#include <AkonadiCore/CollectionFetchScope>
#include <AkonadiCore/Item>
#include <AkonadiCore/ChangeRecorder>
#include <AkonadiCore/ItemFetchJob>
#include <AkonadiCore/ItemFetchScope>
#include <AkonadiCore/CollectionFetchJob>
#include <AkonadiCore/CollectionFetchScope>
#include <Akonadi/Notes/NoteUtils>
#include <AkonadiCore/Session>
#include <KMime/KMimeMessage>
#include <KNotification>
#include <KLocalizedString>
#include <KNotification>
#include <QDateTime>
#include <QTcpServer>
......@@ -37,20 +37,14 @@ NotesManager::NotesManager(QObject *parent)
mSession = new Akonadi::Session("KNotes Session", this);
mNoteRecorder = new NoteShared::NotesChangeRecorder(this);
mNoteRecorder->changeRecorder()->setSession(mSession);
connect(mNoteRecorder->changeRecorder(), &Akonadi::Monitor::itemAdded,
this, &NotesManager::slotItemAdded);
connect(mNoteRecorder->changeRecorder(), &Akonadi::Monitor::itemChanged,
this, &NotesManager::slotItemChanged);
connect(mNoteRecorder->changeRecorder(), &Akonadi::Monitor::itemRemoved,
this, &NotesManager::slotItemRemoved);
auto job = new Akonadi::CollectionFetchJob(Akonadi::Collection::root(),
Akonadi::CollectionFetchJob::Recursive,
mSession);
job->fetchScope().setContentMimeTypes({ Akonadi::NoteUtils::noteMimeType() });
connect(mNoteRecorder->changeRecorder(), &Akonadi::Monitor::itemAdded, this, &NotesManager::slotItemAdded);
connect(mNoteRecorder->changeRecorder(), &Akonadi::Monitor::itemChanged, this, &NotesManager::slotItemChanged);
connect(mNoteRecorder->changeRecorder(), &Akonadi::Monitor::itemRemoved, this, &NotesManager::slotItemRemoved);
auto job = new Akonadi::CollectionFetchJob(Akonadi::Collection::root(), Akonadi::CollectionFetchJob::Recursive, mSession);
job->fetchScope().setContentMimeTypes({Akonadi::NoteUtils::noteMimeType()});
job->fetchScope().setFetchIdOnly(true);
connect(job, &Akonadi::CollectionFetchJob::collectionsReceived,
this, &NotesManager::slotCollectionsReceived);
connect(job, &Akonadi::CollectionFetchJob::collectionsReceived, this, &NotesManager::slotCollectionsReceived);
}
NotesManager::~NotesManager()
......@@ -80,8 +74,7 @@ void NotesManager::slotCollectionsReceived(const Akonadi::Collection::List &coll
job->fetchScope().fetchAttribute<NoteShared::NoteDisplayAttribute>();
job->fetchScope().fetchAttribute<NoteShared::NoteAlarmAttribute>();
job->fetchScope().fetchFullPayload(true);
connect(job, &Akonadi::ItemFetchJob::itemsReceived,
this, [this](const Akonadi::Item::List &items) {
connect(job, &Akonadi::ItemFetchJob::itemsReceived, this, [this](const Akonadi::Item::List &items) {
for (const Akonadi::Item &item : items) {
slotItemAdded(item);
}
......@@ -184,7 +177,7 @@ void NotesManager::slotNewNote(const QString &name, const QString &text)
KNotification::CloseOnTimeout,
QStringLiteral("akonadi_notes_agent"));
auto *job = new NoteShared::CreateNewNoteJob(this, nullptr);
//For the moment it doesn't support richtext.
// For the moment it doesn't support richtext.
job->setRichText(false);
job->setNote(name, text);
job->start();
......
......@@ -14,11 +14,13 @@
#include <QPointer>
class QTcpServer;
class QTimer;
namespace NoteShared {
namespace NoteShared
{
class NotesChangeRecorder;
}
namespace Akonadi {
namespace Akonadi
{
class Session;
}
......@@ -45,6 +47,7 @@ private Q_SLOTS:
void slotItemChanged(const Akonadi::Item &item, const QSet<QByteArray> &set);
void slotCollectionsReceived(const Akonadi::Collection::List &collections);
private:
void clear();
Akonadi::Item::List mListItem;
......
......@@ -25,8 +25,8 @@ void NoteEditorUtilsTest::testAddCheckmark_data()
{
QTest::addColumn<QString>("input");
QTest::addColumn<int>("position");
QTest::newRow("standard") << QStringLiteral("foo") << 0;
QTest::newRow("emptyline") << QString() << 0;
QTest::newRow("standard") << QStringLiteral("foo") << 0;
QTest::newRow("emptyline") << QString() << 0;
}
void NoteEditorUtilsTest::testAddCheckmark()
......@@ -51,7 +51,7 @@ void NoteEditorUtilsTest::testAddCheckmark()
noteUtils.addCheckmark(textCursor);
QCOMPARE(textCursor.document()->toPlainText(), QString(checkMark + input));
//QCOMPARE(textCursor.position(), position + checkMark.size());
// QCOMPARE(textCursor.position(), position + checkMark.size());
delete document;
}
......
......@@ -20,10 +20,10 @@ void NoteUtilsTest::testExtractNoteText_data()
QTest::addColumn<QString>("noteText");
QTest::addColumn<QString>("resultNoteTitle");
QTest::addColumn<QString>("resultNoteText");
QTest::newRow("empty") << QString() << QString() << QString() << QString();
QTest::newRow("test1") << QStringLiteral("foo") << QStringLiteral("bla\r\nfoo") << QStringLiteral("blafoo") << QStringLiteral("foo");
QTest::newRow("test2") << QString() << QStringLiteral("bla\r\nfoo") << QStringLiteral("bla") << QStringLiteral("foo");
QTest::newRow("test3") << QString() << QStringLiteral("blafoo") << QStringLiteral("blafoo") << QStringLiteral("blafoo");
QTest::newRow("empty") << QString() << QString() << QString() << QString();
QTest::newRow("test1") << QStringLiteral("foo") << QStringLiteral("bla\r\nfoo") << QStringLiteral("blafoo") << QStringLiteral("foo");
QTest::newRow("test2") << QString() << QStringLiteral("bla\r\nfoo") << QStringLiteral("bla") << QStringLiteral("foo");
QTest::newRow("test3") << QString() << QStringLiteral("blafoo") << QStringLiteral("blafoo") << QStringLiteral("blafoo");
}
void NoteUtilsTest::testExtractNoteText()
......
......@@ -6,14 +6,16 @@
#ifndef NOTESAKONADITREEMODEL_H
#define NOTESAKONADITREEMODEL_H
#include <AkonadiCore/EntityTreeModel>
#include "noteshared_export.h"
#include <AkonadiCore/EntityTreeModel>
namespace Akonadi {
namespace Akonadi
{
class ChangeRecorder;
}
namespace NoteShared {
namespace NoteShared
{
class NOTESHARED_EXPORT NotesAkonadiTreeModel : public Akonadi::EntityTreeModel
{
Q_OBJECT
......
......@@ -5,14 +5,14 @@
*/
#include "noteschangerecorder.h"
#include <Akonadi/Notes/NoteUtils>
#include <AkonadiCore/ChangeRecorder>
#include <AkonadiCore/CollectionFetchScope>
#include <AkonadiCore/ItemFetchScope>
#include <Akonadi/Notes/NoteUtils>
#include "attributes/notealarmattribute.h"
#include "attributes/notelockattribute.h"
#include "attributes/notedisplayattribute.h"
#include "attributes/notelockattribute.h"
using namespace NoteShared;
......@@ -31,10 +31,10 @@ NotesChangeRecorder::NotesChangeRecorder(QObject *parent)
, d(new NoteShared::NotesChangeRecorderPrivate)
{
Akonadi::ItemFetchScope scope;
scope.fetchFullPayload(true); // Need to have full item when adding it to the internal data structure
scope.fetchAttribute< NoteShared::NoteLockAttribute >();
scope.fetchAttribute< NoteShared::NoteDisplayAttribute >();
scope.fetchAttribute< NoteShared::NoteAlarmAttribute >();
scope.fetchFullPayload(true); // Need to have full item when adding it to the internal data structure
scope.fetchAttribute<NoteShared::NoteLockAttribute>();
scope.fetchAttribute<NoteShared::NoteDisplayAttribute>();
scope.fetchAttribute<NoteShared::NoteAlarmAttribute>();
d->mChangeRecorder = new Akonadi::ChangeRecorder(this);
d->mChangeRecorder->setItemFetchScope(scope);
......
......@@ -6,12 +6,14 @@
#ifndef NOTESCHANGERECORDER_H
#define NOTESCHANGERECORDER_H
#include <QObject>
#include "noteshared_export.h"
namespace Akonadi {
#include <QObject>
namespace Akonadi
{
class ChangeRecorder;
}
namespace NoteShared {
namespace NoteShared
{
class NotesChangeRecorderPrivate;
class NOTESHARED_EXPORT NotesChangeRecorder : public QObject
{
......
......@@ -11,15 +11,15 @@
#include <KDateComboBox>
#include <KLocalizedString>
#include <KTimeComboBox>
#include <QVBoxLayout>
#include <QDateTime>
#include <QVBoxLayout>
#include <QButtonGroup>
#include <QDialogButtonBox>
#include <QGroupBox>
#include <QRadioButton>
#include <QHBoxLayout>
#include <QDialogButtonBox>
#include <QPushButton>
#include <QRadioButton>
using namespace NoteShared;
......
......@@ -9,11 +9,12 @@
#ifndef NOTEALARMDIALOG_H
#define NOTEALARMDIALOG_H
#include <QDialog>
#include "noteshared_export.h"
#include <QDialog>
class QDateTime;
class QAbstractButton;
namespace NoteShared {
namespace NoteShared
{
class NoteAlarmDialogPrivate;
class NOTESHARED_EXPORT NoteAlarmDialog : public QDialog
{
......
......@@ -10,7 +10,8 @@
#include <AkonadiCore/attributefactory.h>
namespace {
namespace
{
// Anonymous namespace; function is invisible outside this file.
bool dummy()
{
......
......@@ -5,8 +5,8 @@
*/
#include "notealarmattribute.h"
#include <QDataStream>
#include <QByteArray>
#include <QDataStream>
using namespace NoteShared;
NoteAlarmAttribute::NoteAlarmAttribute()
......@@ -55,7 +55,7 @@ QDateTime NoteAlarmAttribute::dateTime() const
return mDateTime;
}
bool NoteAlarmAttribute::operator ==(const NoteAlarmAttribute &other) const
bool NoteAlarmAttribute::operator==(const NoteAlarmAttribute &other) const
{
return mDateTime == other.dateTime();
}
......@@ -10,7 +10,8 @@
#include <AkonadiCore/Attribute>
#include <QDateTime>
namespace NoteShared {
namespace NoteShared
{
class NOTESHARED_EXPORT NoteAlarmAttribute : public Akonadi::Attribute
{
public:
......@@ -28,7 +29,8 @@ public:
void setDateTime(const QDateTime &dateTime);
Q_REQUIRED_RESULT QDateTime dateTime() const;
Q_REQUIRED_RESULT bool operator ==(const NoteAlarmAttribute &other) const;
Q_REQUIRED_RESULT bool operator==(const NoteAlarmAttribute &other) const;
private:
QDateTime mDateTime;
};
......
......@@ -248,20 +248,10 @@ bool NoteDisplayAttribute::keepBelow() const
return mKeepBelow;
}
bool NoteDisplayAttribute::operator ==(const NoteDisplayAttribute &other) const
{
return (backgroundColor() == other.backgroundColor())
&& (foregroundColor() == other.foregroundColor())
&& (size() == other.size())
&& (rememberDesktop() == other.rememberDesktop())
&& (tabSize() == other.tabSize())
&& (font() == other.font())
&& (titleFont() == other.titleFont())
&& (desktop() == other.desktop())
&& (isHidden() == other.isHidden())
&& (position() == other.position())
&& (showInTaskbar() == other.showInTaskbar())
&& (keepAbove() == other.keepAbove())
&& (keepBelow() == other.keepBelow())
&& (autoIndent() == other.autoIndent());
bool NoteDisplayAttribute::operator==(const NoteDisplayAttribute &other) const
{
return (backgroundColor() == other.backgroundColor()) && (foregroundColor() == other.foregroundColor()) && (size() == other.size())
&& (rememberDesktop() == other.rememberDesktop()) && (tabSize() == other.tabSize()) && (font() == other.font()) && (titleFont() == other.titleFont())
&& (desktop() == other.desktop()) && (isHidden() == other.isHidden()) && (position() == other.position()) && (showInTaskbar() == other.showInTaskbar())
&& (keepAbove() == other.keepAbove()) && (keepBelow() == other.keepBelow()) && (autoIndent() == other.autoIndent());
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment