Skip to content

Commit 1cea8a1

Browse files
committed
Run Clang format script over the codebase
Column length is increased to 100 as 80 is just too short Also add a git-blame-ignore-revs file which ignores the formatting revisions while git-blaming
1 parent 5a4fe8f commit 1cea8a1

File tree

151 files changed

+5851
-8942
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

151 files changed

+5851
-8942
lines changed

.clang-format

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ BreakConstructorInitializersBeforeComma: false
5050
BreakConstructorInitializers: BeforeColon
5151
BreakAfterJavaFieldAnnotations: false
5252
BreakStringLiterals: true
53-
ColumnLimit: 80
53+
ColumnLimit: 100
5454
CommentPragmas: '^ IWYU pragma:'
5555
CompactNamespaces: false
5656
ConstructorInitializerAllOnOneLineOrOnePerLine: true

.git-blame-ignore-revs

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
ee2b94b4dd6ae24077da9ed9bf54b2162f578518
2+
232056ddbd0d78196ea1d3091a07b94ab672a479
3+
18a3d6f5060b89a7217dd23e0bc2d956084bd34b

src/api/noteapi.cpp

+4-8
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ bool NoteApi::removeTag(QString tagName) {
132132
* @param newName new file name (without file-extension)
133133
* @return true if the note was renamed
134134
*/
135-
bool NoteApi::renameNoteFile(const QString &newName) {
135+
bool NoteApi::renameNoteFile(const QString& newName) {
136136
Note note = Note::fetch(_id);
137137

138138
if (note.isFetched()) {
@@ -147,9 +147,7 @@ bool NoteApi::renameNoteFile(const QString &newName) {
147147
*
148148
* @return bool
149149
*/
150-
bool NoteApi::allowDifferentFileName() {
151-
return Note::allowDifferentFileName();
152-
}
150+
bool NoteApi::allowDifferentFileName() { return Note::allowDifferentFileName(); }
153151

154152
/**
155153
* Fetches all notes
@@ -181,8 +179,7 @@ QQmlListProperty<NoteApi> NoteApi::fetchAll(int limit, int offset) {
181179
* @return
182180
*/
183181
QString NoteApi::toMarkdownHtml(bool forExport) {
184-
return _note.toMarkdownHtml(NoteFolder::currentLocalPath(), 980, forExport,
185-
true, true);
182+
return _note.toMarkdownHtml(NoteFolder::currentLocalPath(), 980, forExport, true, true);
186183
}
187184

188185
/**
@@ -195,8 +192,7 @@ QString NoteApi::getFileURLFromFileName(const QString& localFileName) {
195192
return _note.getFileURLFromFileName(localFileName);
196193
}
197194

198-
void NoteApi::copy(const Note &note)
199-
{
195+
void NoteApi::copy(const Note& note) {
200196
_note = note;
201197

202198
if (_note.isFetched()) {

src/api/noteapi.h

+2-4
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ class NoteApi : public QObject, public Note {
1919
Q_PROPERTY(QString relativeNoteFileDirPath READ relativeNoteSubFolderPath() CONSTANT)
2020
Q_PROPERTY(int noteSubFolderId READ getNoteSubFolderId() CONSTANT)
2121
Q_PROPERTY(QString noteText READ getNoteText() WRITE setNoteText())
22-
Q_PROPERTY(QString decryptedNoteText READ fetchDecryptedNoteText()
23-
WRITE setDecryptedNoteText())
22+
Q_PROPERTY(QString decryptedNoteText READ fetchDecryptedNoteText() WRITE setDecryptedNoteText())
2423
Q_PROPERTY(QDateTime fileCreated READ getFileCreated() CONSTANT)
2524
Q_PROPERTY(QDateTime fileLastModified READ getFileLastModified() CONSTANT)
2625
Q_PROPERTY(bool hasDirtyData READ getHasDirtyData() CONSTANT)
@@ -40,8 +39,7 @@ class NoteApi : public QObject, public Note {
4039
Q_INVOKABLE bool addTag(const QString &tagName);
4140
Q_INVOKABLE bool removeTag(QString tagName);
4241
Q_INVOKABLE bool renameNoteFile(const QString &newName);
43-
Q_INVOKABLE QQmlListProperty<NoteApi> fetchAll(int limit = -1,
44-
int offset = -1);
42+
Q_INVOKABLE QQmlListProperty<NoteApi> fetchAll(int limit = -1, int offset = -1);
4543
Q_INVOKABLE QString toMarkdownHtml(bool forExport = true);
4644
Q_INVOKABLE QString getFileURLFromFileName(const QString &localFileName);
4745
Q_INVOKABLE static bool allowDifferentFileName();

src/api/notesubfolderapi.cpp

+6-12
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ NoteSubFolderApi *NoteSubFolderApi::fetch(int id) {
1818
}
1919

2020
NoteSubFolderApi *NoteSubFolderApi::fromNoteSubFolder(const NoteSubFolder &noteSubFolder) {
21-
auto* noteSubFolderApi = new NoteSubFolderApi();
21+
auto *noteSubFolderApi = new NoteSubFolderApi();
2222
noteSubFolderApi->fetch(noteSubFolder.getId());
2323
return noteSubFolderApi;
2424
}
@@ -36,7 +36,7 @@ QQmlListProperty<NoteApi> NoteSubFolderApi::notes() {
3636
while (itr.hasNext()) {
3737
Note note = itr.next();
3838

39-
auto* noteApi = new NoteApi();
39+
auto *noteApi = new NoteApi();
4040
noteApi->fetch(note.getId());
4141
_notes.append(noteApi);
4242
}
@@ -54,8 +54,7 @@ QQmlListProperty<NoteApi> NoteSubFolderApi::notes() {
5454
* @param id int the id of the note subfolder
5555
* @return NoteSubFolderApi*
5656
*/
57-
NoteSubFolderApi *NoteSubFolderApi::fetchNoteSubFolderById(int id)
58-
{
57+
NoteSubFolderApi *NoteSubFolderApi::fetchNoteSubFolderById(int id) {
5958
auto *noteSubFolder = new NoteSubFolderApi();
6059
noteSubFolder->fetch(id);
6160
return noteSubFolder;
@@ -67,8 +66,7 @@ NoteSubFolderApi *NoteSubFolderApi::fetchNoteSubFolderById(int id)
6766
* @param parentId int the id of the parent note subfolder
6867
* @return QList<QObject*>
6968
*/
70-
QList<QObject*> NoteSubFolderApi::fetchNoteSubFoldersByParentId(int parentId)
71-
{
69+
QList<QObject *> NoteSubFolderApi::fetchNoteSubFoldersByParentId(int parentId) {
7270
QList<QObject *> noteSubFolderApis;
7371

7472
const auto noteSubFolders = NoteSubFolder::fetchAllByParentId(parentId);
@@ -83,10 +81,6 @@ NoteSubFolderApi *NoteSubFolderApi::activeNoteSubFolder() {
8381
return fetchNoteSubFolderById(NoteSubFolder::activeNoteSubFolderId());
8482
}
8583

86-
QString NoteSubFolderApi::relativePath() {
87-
return _noteSubFolder.relativePath();
88-
}
84+
QString NoteSubFolderApi::relativePath() { return _noteSubFolder.relativePath(); }
8985

90-
QString NoteSubFolderApi::fullPath() {
91-
return _noteSubFolder.fullPath();
92-
}
86+
QString NoteSubFolderApi::fullPath() { return _noteSubFolder.fullPath(); }

src/api/notesubfolderapi.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class NoteSubFolderApi : public QObject, public NoteSubFolder {
2424

2525
Q_INVOKABLE static NoteSubFolderApi *fetchNoteSubFolderById(int id);
2626
Q_INVOKABLE static NoteSubFolderApi *activeNoteSubFolder();
27-
Q_INVOKABLE static QList<QObject*> fetchNoteSubFoldersByParentId(int parentId);
27+
Q_INVOKABLE static QList<QObject *> fetchNoteSubFoldersByParentId(int parentId);
2828

2929
Q_INVOKABLE QQmlListProperty<NoteApi> notes();
3030
Q_INVOKABLE QString relativePath();

src/api/tagapi.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ TagApi* TagApi::fromTag(const Tag& tag) {
4040
return tagApi;
4141
}
4242

43-
void TagApi::copy(const Tag &tag)
44-
{
43+
void TagApi::copy(const Tag& tag) {
4544
this->_id = tag.getId();
4645
_name = tag.getName();
4746
_parentId = tag.getParentId();
@@ -53,7 +52,7 @@ void TagApi::copy(const Tag &tag)
5352
*/
5453
QQmlListProperty<NoteApi> TagApi::notes() {
5554
_notes.clear();
56-
55+
5756
Tag tag = Tag::fetch(_id);
5857
QVector<Note> notes = tag.fetchAllLinkedNotes();
5958

src/api/tagapi.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ class TagApi : public QObject, public Tag {
2020
Q_INVOKABLE TagApi *fetchByName(const QString &name, int parentId = 0);
2121
Q_INVOKABLE QStringList getParentTagNames();
2222
Q_INVOKABLE QQmlListProperty<NoteApi> notes();
23-
static TagApi* fromTag(const Tag& tag);
24-
void copy(const Tag& t);
23+
static TagApi *fromTag(const Tag &tag);
24+
void copy(const Tag &t);
2525
};

src/dialogs/aboutdialog.cpp

+4-8
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
#include "ui_aboutdialog.h"
1212
#include "version.h"
1313

14-
AboutDialog::AboutDialog(QWidget *parent)
15-
: MasterDialog(parent), ui(new Ui::AboutDialog) {
14+
AboutDialog::AboutDialog(QWidget *parent) : MasterDialog(parent), ui(new Ui::AboutDialog) {
1615
ui->setupUi(this);
1716

1817
// load the about.html
@@ -28,17 +27,14 @@ AboutDialog::AboutDialog(QWidget *parent)
2827
}
2928

3029
// fill in the variables
31-
html.replace(QLatin1String("QT_VERSION_STR"),
32-
QStringLiteral(QT_VERSION_STR));
30+
html.replace(QLatin1String("QT_VERSION_STR"), QStringLiteral(QT_VERSION_STR));
3331
html.replace(QLatin1String("BUILD_NUMBER"), QString::number(BUILD));
3432
html.replace(QLatin1String("BUILD_DATE"), __DATE__);
3533
html.replace(QLatin1String("VERSION"), QStringLiteral(VERSION));
3634
html.replace(QLatin1String("RELEASE"), release);
37-
html.replace(QLatin1String("CURRENT_YEAR"),
38-
QString::number(date.year()));
35+
html.replace(QLatin1String("CURRENT_YEAR"), QString::number(date.year()));
3936

40-
ui->textBrowser->document()->setDefaultStyleSheet(
41-
Utils::Misc::genericCSS());
37+
ui->textBrowser->document()->setDefaultStyleSheet(Utils::Misc::genericCSS());
4238

4339
// put the html to the text browser in the about dialog
4440
ui->textBrowser->setHtml(html);

src/dialogs/actiondialog.cpp

+13-17
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#include "actiondialog.h"
2-
//#include <QDebug>
2+
// #include <QDebug>
33
#include <utils/gui.h>
44

5-
#include <QMenuBar>
65
#include <QKeyEvent>
6+
#include <QMenuBar>
77
#include <QTreeWidgetItem>
88

99
#include "ui_actiondialog.h"
@@ -27,7 +27,9 @@ void ActionDialog::refreshUi() {
2727
QList<QMenu *> menuList =
2828
_menuBar->findChildren<QMenu *>(QString(), Qt::FindDirectChildrenOnly);
2929

30-
Q_FOREACH (QMenu *menu, menuList) { buildActionTreeForMenu(menu); }
30+
Q_FOREACH (QMenu *menu, menuList) {
31+
buildActionTreeForMenu(menu);
32+
}
3133

3234
ui->actionTreeWidget->setRootIsDecorated(false);
3335
ui->actionTreeWidget->expandAll();
@@ -42,8 +44,7 @@ void ActionDialog::refreshUi() {
4244
* @param menu
4345
* @param parentItem
4446
*/
45-
void ActionDialog::buildActionTreeForMenu(QMenu *menu,
46-
QTreeWidgetItem *parentItem) {
47+
void ActionDialog::buildActionTreeForMenu(QMenu *menu, QTreeWidgetItem *parentItem) {
4748
QString menuText = menu->title().remove(QStringLiteral("&"));
4849

4950
if (menuText.isEmpty()) {
@@ -60,8 +61,7 @@ void ActionDialog::buildActionTreeForMenu(QMenu *menu,
6061
}
6162

6263
// search for sub-menus in the menu
63-
QList<QMenu *> menuList =
64-
menu->findChildren<QMenu *>(QString(), Qt::FindDirectChildrenOnly);
64+
QList<QMenu *> menuList = menu->findChildren<QMenu *>(QString(), Qt::FindDirectChildrenOnly);
6565

6666
// build the tree for that sub-menu
6767
Q_FOREACH (QMenu *subMenu, menuList) {
@@ -103,8 +103,7 @@ ActionDialog::~ActionDialog() { delete ui; }
103103
* @param item
104104
* @param column
105105
*/
106-
void ActionDialog::on_actionTreeWidget_itemDoubleClicked(QTreeWidgetItem *item,
107-
int column) {
106+
void ActionDialog::on_actionTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column) {
108107
Q_UNUSED(column);
109108

110109
if (item == nullptr) {
@@ -119,8 +118,7 @@ void ActionDialog::on_actionTreeWidget_itemDoubleClicked(QTreeWidgetItem *item,
119118

120119
// search for actions in the parent of the menu bar
121120
// for some reasons not all actions are children of the menu bar
122-
QList<QAction *> actionList =
123-
_menuBar->parent()->findChildren<QAction *>(objectName);
121+
QList<QAction *> actionList = _menuBar->parent()->findChildren<QAction *>(objectName);
124122

125123
// close the dialog
126124
close();
@@ -140,10 +138,9 @@ void ActionDialog::on_actionLineEdit_textChanged(const QString &arg1) {
140138
// search for the text
141139
Utils::Gui::searchForTextInTreeWidget(
142140
ui->actionTreeWidget, arg1,
143-
Utils::Gui::TreeWidgetSearchFlags(
144-
Utils::Gui::TreeWidgetSearchFlag::TooltipSearch |
145-
Utils::Gui::TreeWidgetSearchFlag::AllColumnsSearch |
146-
Utils::Gui::TreeWidgetSearchFlag::EveryWordSearch));
141+
Utils::Gui::TreeWidgetSearchFlags(Utils::Gui::TreeWidgetSearchFlag::TooltipSearch |
142+
Utils::Gui::TreeWidgetSearchFlag::AllColumnsSearch |
143+
Utils::Gui::TreeWidgetSearchFlag::EveryWordSearch));
147144
}
148145

149146
/**
@@ -169,8 +166,7 @@ bool ActionDialog::eventFilter(QObject *obj, QEvent *event) {
169166
} else if (obj == ui->actionTreeWidget) {
170167
// trigger the action if return was pressed in the tree widget
171168
if (keyEvent->key() == Qt::Key_Return) {
172-
on_actionTreeWidget_itemDoubleClicked(
173-
ui->actionTreeWidget->currentItem(), 0);
169+
on_actionTreeWidget_itemDoubleClicked(ui->actionTreeWidget->currentItem(), 0);
174170
return true;
175171
}
176172

src/dialogs/actiondialog.h

+2-4
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ class ActionDialog : public MasterDialog {
1818
void refreshUi();
1919

2020
private slots:
21-
void on_actionTreeWidget_itemDoubleClicked(QTreeWidgetItem *item,
22-
int column);
21+
void on_actionTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column);
2322

2423
void on_actionLineEdit_textChanged(const QString &arg1);
2524

@@ -30,6 +29,5 @@ class ActionDialog : public MasterDialog {
3029
Ui::ActionDialog *ui;
3130
QMenuBar *_menuBar;
3231

33-
void buildActionTreeForMenu(QMenu *menu,
34-
QTreeWidgetItem *parentItem = nullptr);
32+
void buildActionTreeForMenu(QMenu *menu, QTreeWidgetItem *parentItem = nullptr);
3533
};

src/dialogs/attachmentdialog.cpp

+16-25
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@ void AttachmentDialog::on_fileEdit_textChanged(const QString &arg1) {
6161
return;
6262
}
6363

64-
ui->downloadButton->setVisible(
65-
url.scheme().startsWith(QLatin1String("http")));
64+
ui->downloadButton->setVisible(url.scheme().startsWith(QLatin1String("http")));
6665

6766
if (url.scheme() == QLatin1String("file")) {
6867
ui->fileEdit->setText(url.toLocalFile());
@@ -73,9 +72,8 @@ void AttachmentDialog::on_fileEdit_textChanged(const QString &arg1) {
7372
QMimeDatabase db;
7473
QMimeType type = db.mimeTypeForFile(arg1);
7574

76-
ui->infoLabel->setText(
77-
Utils::Misc::toHumanReadableByteSize(fileInfo.size()) + " - " +
78-
type.comment());
75+
ui->infoLabel->setText(Utils::Misc::toHumanReadableByteSize(fileInfo.size()) + " - " +
76+
type.comment());
7977
}
8078
}
8179

@@ -89,8 +87,7 @@ void AttachmentDialog::on_downloadButton_clicked() {
8987
QNetworkRequest networkRequest(url);
9088

9189
#if QT_VERSION < QT_VERSION_CHECK(5, 9, 0)
92-
networkRequest.setAttribute(QNetworkRequest::FollowRedirectsAttribute,
93-
true);
90+
networkRequest.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true);
9491
#else
9592
networkRequest.setAttribute(QNetworkRequest::RedirectPolicyAttribute, true);
9693
#endif
@@ -110,13 +107,11 @@ void AttachmentDialog::on_downloadButton_clicked() {
110107
/**
111108
* Shows the download progress
112109
*/
113-
void AttachmentDialog::downloadProgress(qint64 bytesReceived,
114-
qint64 bytesTotal) {
110+
void AttachmentDialog::downloadProgress(qint64 bytesReceived, qint64 bytesTotal) {
115111
ui->downloadProgressBar->setMaximum(static_cast<int>(bytesTotal));
116112
ui->downloadProgressBar->setValue(static_cast<int>(bytesReceived));
117-
ui->downloadSizeLabel->setText(
118-
Utils::Misc::toHumanReadableByteSize(bytesReceived) + " / " +
119-
Utils::Misc::toHumanReadableByteSize(bytesTotal));
113+
ui->downloadSizeLabel->setText(Utils::Misc::toHumanReadableByteSize(bytesReceived) + " / " +
114+
Utils::Misc::toHumanReadableByteSize(bytesTotal));
120115
}
121116

122117
/**
@@ -140,12 +135,10 @@ void AttachmentDialog::slotReplyFinished(QNetworkReply *reply) {
140135
if (reply->error() != QNetworkReply::NoError &&
141136
reply->error() != QNetworkReply::OperationCanceledError) {
142137
_accept = false;
143-
QMessageBox::critical(
144-
nullptr, tr("Download error"),
145-
tr("Error while downloading:\n%1").arg(reply->errorString()));
138+
QMessageBox::critical(nullptr, tr("Download error"),
139+
tr("Error while downloading:\n%1").arg(reply->errorString()));
146140

147-
qWarning()
148-
<< QStringLiteral("Network error: %1").arg(reply->errorString());
141+
qWarning() << QStringLiteral("Network error: %1").arg(reply->errorString());
149142

150143
return;
151144
}
@@ -162,17 +155,16 @@ void AttachmentDialog::slotReplyFinished(QNetworkReply *reply) {
162155
}
163156
}
164157

165-
auto *tempFile =
166-
new QTemporaryFile(QDir::tempPath() + "/QOwnNotes-XXXXXX." + suffix);
158+
auto *tempFile = new QTemporaryFile(QDir::tempPath() + "/QOwnNotes-XXXXXX." + suffix);
167159

168160
// we want to keep the file to be used in the update process
169161
tempFile->setAutoRemove(false);
170162

171163
// get a temporary file
172164
if (!tempFile->open()) {
173-
QMessageBox::critical(nullptr, tr("File error"),
174-
tr("Could not open temporary file:\n%1")
175-
.arg(tempFile->errorString()));
165+
QMessageBox::critical(
166+
nullptr, tr("File error"),
167+
tr("Could not open temporary file:\n%1").arg(tempFile->errorString()));
176168
return;
177169
}
178170

@@ -193,9 +185,8 @@ void AttachmentDialog::slotReplyFinished(QNetworkReply *reply) {
193185
QFile file(filePath);
194186

195187
if (!file.open(QIODevice::WriteOnly)) {
196-
QMessageBox::critical(
197-
nullptr, tr("File error"),
198-
tr("Could not store downloaded file:\n%1").arg(file.errorString()));
188+
QMessageBox::critical(nullptr, tr("File error"),
189+
tr("Could not store downloaded file:\n%1").arg(file.errorString()));
199190
return;
200191
}
201192

0 commit comments

Comments
 (0)