Skip to content

Commit

Permalink
style: format code using clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
pbek committed Jan 1, 2024
1 parent b8f4ff1 commit 964acf6
Show file tree
Hide file tree
Showing 12 changed files with 62 additions and 36 deletions.
8 changes: 6 additions & 2 deletions src/dialogs/actiondialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ void ActionDialog::refreshUi() {
QList<QMenu *> menuList =
_menuBar->findChildren<QMenu *>(QString(), Qt::FindDirectChildrenOnly);

Q_FOREACH (QMenu *menu, menuList) { buildActionTreeForMenu(menu); }
Q_FOREACH (QMenu *menu, menuList) {
buildActionTreeForMenu(menu);
}

ui->actionTreeWidget->setRootIsDecorated(false);
ui->actionTreeWidget->expandAll();
Expand Down Expand Up @@ -62,7 +64,9 @@ void ActionDialog::buildActionTreeForMenu(QMenu *menu, QTreeWidgetItem *parentIt
QList<QMenu *> menuList = menu->findChildren<QMenu *>(QString(), Qt::FindDirectChildrenOnly);

// build the tree for that sub-menu
Q_FOREACH (QMenu *subMenu, menuList) { buildActionTreeForMenu(subMenu, menuItem); }
Q_FOREACH (QMenu *subMenu, menuList) {
buildActionTreeForMenu(subMenu, menuItem);
}

// add all actions to the tree widget item
Q_FOREACH (QAction *action, menu->actions()) {
Expand Down
6 changes: 2 additions & 4 deletions src/dialogs/scriptrepositorydialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ void ScriptRepositoryDialog::addScriptTreeWidgetItem(const ScriptInfoJson &scrip
ui->scriptTreeWidget->resizeColumnToContents(0);
}

void ScriptRepositoryDialog::searchForUpdatesForScripts(const QList<Script>& scripts) {
void ScriptRepositoryDialog::searchForUpdatesForScripts(const QList<Script> &scripts) {
ui->searchScriptEdit->hide();
setWindowTitle(tr("Script updates"));
ui->overviewLabel->setText(tr("All scripts are up-to-date."));
Expand Down Expand Up @@ -176,9 +176,7 @@ void ScriptRepositoryDialog::searchForUpdatesForScripts(const QList<Script>& scr
/**
* Searches for script updates
*/
void ScriptRepositoryDialog::searchForUpdates() {
searchForUpdatesForScripts(Script::fetchAll());
}
void ScriptRepositoryDialog::searchForUpdates() { searchForUpdatesForScripts(Script::fetchAll()); }

void ScriptRepositoryDialog::parseScriptRepositoryMetaData(const QByteArray &arr) {
QJsonDocument doc = QJsonDocument::fromJson(arr);
Expand Down
2 changes: 1 addition & 1 deletion src/dialogs/scriptrepositorydialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class ScriptRepositoryDialog : public MasterDialog {
Script getLastInstalledScript();

void searchForUpdates();
void searchForUpdatesForScripts(const QList<Script>& scripts);
void searchForUpdatesForScripts(const QList<Script> &scripts);

signals:
void updateFound();
Expand Down
20 changes: 15 additions & 5 deletions src/dialogs/settingsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1375,7 +1375,9 @@ void SettingsDialog::loadInterfaceStyleComboBox() const {
ui->interfaceStyleComboBox->clear();
ui->interfaceStyleComboBox->addItem(tr("Automatic (needs restart)"));

Q_FOREACH (QString style, QStyleFactory::keys()) { ui->interfaceStyleComboBox->addItem(style); }
Q_FOREACH (QString style, QStyleFactory::keys()) {
ui->interfaceStyleComboBox->addItem(style);
}

QSettings settings;
QString interfaceStyle = settings.value(QStringLiteral("interfaceStyle")).toString();
Expand Down Expand Up @@ -2960,7 +2962,9 @@ void SettingsDialog::reloadCurrentScriptPage() {
// scriptSettingsFrame
QList<ScriptSettingWidget *> widgets =
ui->scriptSettingsFrame->findChildren<ScriptSettingWidget *>();
Q_FOREACH (ScriptSettingWidget *widget, widgets) { delete widget; }
Q_FOREACH (ScriptSettingWidget *widget, widgets) {
delete widget;
}

foreach (QVariant variable, variables) {
QMap<QString, QVariant> varMap = variable.toMap();
Expand Down Expand Up @@ -3247,7 +3251,9 @@ void SettingsDialog::on_shortcutSearchLineEdit_textChanged(const QString &arg1)
}
} else {
// show all items otherwise
Q_FOREACH (QTreeWidgetItem *item, allItems) { item->setHidden(false); }
Q_FOREACH (QTreeWidgetItem *item, allItems) {
item->setHidden(false);
}
}
}

Expand Down Expand Up @@ -3576,7 +3582,9 @@ void SettingsDialog::on_searchLineEdit_textChanged(const QString &arg1) {
}
} else {
// show all items otherwise
Q_FOREACH (QTreeWidgetItem *item, allItems) { item->setHidden(false); }
Q_FOREACH (QTreeWidgetItem *item, allItems) {
item->setHidden(false);
}
}
}

Expand Down Expand Up @@ -3835,7 +3843,9 @@ void SettingsDialog::on_exportSettingsButton_clicked() {
QSettings settings;

const QStringList keys = settings.allKeys();
Q_FOREACH (QString key, keys) { exportSettings.setValue(key, settings.value(key)); }
Q_FOREACH (QString key, keys) {
exportSettings.setValue(key, settings.value(key));
}
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/dialogs/tododialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,9 @@ void TodoDialog::on_newItemEdit_textChanged() {
}
} else {
// show all items otherwise
Q_FOREACH (QTreeWidgetItem *item, allItems) { item->setHidden(false); }
Q_FOREACH (QTreeWidgetItem *item, allItems) {
item->setHidden(false);
}
}

// let's highlight the text from the search line edit
Expand Down
3 changes: 1 addition & 2 deletions src/helpers/toolbarcontainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@

ToolbarContainer::ToolbarContainer(QToolBar *toolbar)
: name(toolbar->objectName()), title(toolbar->windowTitle()) {
foreach (QAction *a, toolbar->actions())
actions.push_back(a->objectName());
foreach (QAction *a, toolbar->actions()) actions.push_back(a->objectName());
}

QToolBar *ToolbarContainer::create(QMainWindow *w) const {
Expand Down
23 changes: 13 additions & 10 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
#include <widgets/notetreewidgetitem.h>

#include <QAbstractEventDispatcher>
#include <QtConcurrent>
#include <QActionGroup>
#include <QClipboard>
#include <QColorDialog>
Expand Down Expand Up @@ -91,6 +90,7 @@
#include <QTreeWidgetItem>
#include <QUuid>
#include <QWidgetAction>
#include <QtConcurrent>
#include <libraries/qttoolbareditor/src/toolbar_editor.hpp>
#include <memory>
#include <utility>
Expand Down Expand Up @@ -508,8 +508,10 @@ void MainWindow::initTreeWidgets() {
connect(ui->noteSubFolderTreeWidget, &NoteSubFolderTree::currentSubFolderChanged, this,
&MainWindow::onCurrentSubFolderChanged);
if (NoteFolder::isCurrentNoteTreeEnabled()) {
connect(ui->noteTreeWidget, &QTreeWidget::itemExpanded, ui->noteSubFolderTreeWidget, &NoteSubFolderTree::onItemExpanded);
connect(ui->noteTreeWidget, &QTreeWidget::itemCollapsed, ui->noteSubFolderTreeWidget, &NoteSubFolderTree::onItemExpanded);
connect(ui->noteTreeWidget, &QTreeWidget::itemExpanded, ui->noteSubFolderTreeWidget,
&NoteSubFolderTree::onItemExpanded);
connect(ui->noteTreeWidget, &QTreeWidget::itemCollapsed, ui->noteSubFolderTreeWidget,
&NoteSubFolderTree::onItemExpanded);
}
}

Expand Down Expand Up @@ -640,7 +642,9 @@ void MainWindow::triggerStartupMenuAction() {
*/
void MainWindow::initGlobalKeyboardShortcuts() {
// deleting old global shortcut assignments
foreach (QHotkey *hotKey, _globalShortcuts) { delete hotKey; }
foreach (QHotkey *hotKey, _globalShortcuts) {
delete hotKey;
}

_globalShortcuts.clear();
QSettings settings;
Expand Down Expand Up @@ -6788,8 +6792,7 @@ void MainWindow::storeNoteBookmark(int slot) {
NoteHistoryItem item = NoteHistoryItem(&currentNote, ui->noteTextEdit);
noteBookmarks[slot] = item;

QSettings().setValue(QStringLiteral("NoteBookmark%1").arg(slot),
QVariant::fromValue(item));
QSettings().setValue(QStringLiteral("NoteBookmark%1").arg(slot), QVariant::fromValue(item));

showStatusBarMessage(tr("Bookmarked note position at slot %1").arg(QString::number(slot)),
3000);
Expand Down Expand Up @@ -10966,7 +10969,7 @@ void MainWindow::automaticScriptUpdateCheck() {
// We need to do that in a slot, because you can't use a timer in a separate thread
QObject::connect(dialog, &ScriptRepositoryDialog::noUpdateFound, this, [this, dialog]() {
showStatusBarMessage(tr("No script updates were found"), 3000);
delete(dialog);
delete (dialog);
});

// Show a dialog once if a script update was found
Expand All @@ -10978,7 +10981,7 @@ void MainWindow::automaticScriptUpdateCheck() {

_scriptUpdateFound = true;
showStatusBarMessage(tr("A script update was found!"), 4000);
delete(dialog);
delete (dialog);

if (Utils::Gui::question(this, tr("Script updates"),
tr("Updates to your scripts were found in the script "
Expand All @@ -10989,8 +10992,8 @@ void MainWindow::automaticScriptUpdateCheck() {
});

// Search for script updates in the background after the "updateFound" signal was connected
// We must not do a `delete (dialog)` in the new thread, that was causing a crash on some systems
// See https://github.com/pbek/QOwnNotes/issues/2937
// We must not do a `delete (dialog)` in the new thread, that was causing a crash on some
// systems, see https://github.com/pbek/QOwnNotes/issues/2937
QFuture<void> future = QtConcurrent::run([this, dialog, scripts]() {
qDebug() << "start searchForUpdates";
dialog->searchForUpdatesForScripts(scripts);
Expand Down
4 changes: 3 additions & 1 deletion src/services/scriptingservice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1950,7 +1950,9 @@ QList<int> ScriptingService::selectedNotesIds() const {
MainWindow *mainWindow = MainWindow::instance();

if (mainWindow != nullptr) {
Q_FOREACH (Note note, mainWindow->selectedNotes()) { selectedNotesIds << note.getId(); }
Q_FOREACH (Note note, mainWindow->selectedNotes()) {
selectedNotesIds << note.getId();
}
}
#endif

Expand Down
8 changes: 6 additions & 2 deletions src/utils/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,9 @@ void Utils::Gui::searchForTextInTreeWidget(QTreeWidget *treeWidget, const QStrin
}
} else {
// show all items otherwise
Q_FOREACH (QTreeWidgetItem *item, allItems) { item->setHidden(false); }
Q_FOREACH (QTreeWidgetItem *item, allItems) {
item->setHidden(false);
}
}
}

Expand All @@ -150,7 +152,9 @@ void Utils::Gui::searchForTextInListWidget(QListWidget *listWidget, const QStrin
}
} else {
// show all items otherwise
Q_FOREACH (QListWidgetItem *item, allItems) { item->setHidden(false); }
Q_FOREACH (QListWidgetItem *item, allItems) {
item->setHidden(false);
}
}
}

Expand Down
7 changes: 4 additions & 3 deletions src/utils/urlhandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,10 @@ void UrlHandler::handleNoteUrl(QString urlString, const QString &fragment) {
if (!fragment.isEmpty()) {
// Search with a regular expression for the fragment to make sure
// we are searching for the full heading
auto searchTerm = QStringLiteral("## ") + QRegularExpression::escape(fragment) +
QStringLiteral("$");
mw->activeNoteTextEdit()->doSearch(searchTerm, QPlainTextEditSearchWidget::RegularExpressionMode);
auto searchTerm =
QStringLiteral("## ") + QRegularExpression::escape(fragment) + QStringLiteral("$");
mw->activeNoteTextEdit()->doSearch(searchTerm,
QPlainTextEditSearchWidget::RegularExpressionMode);
mw->activeNoteTextEdit()->searchWidget()->deactivate();
}
} else {
Expand Down
4 changes: 3 additions & 1 deletion src/widgets/logwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,9 @@ void LogWidget::log(LogWidget::LogType logType, const QString &text) {
text.contains(QLatin1String("[Botan Error] Invalid CBC padding")) ||
text.contains(QLatin1String("Invalid version or not a cyphertext")) ||
text.contains(QLatin1String("QTextCursor::setPosition: Position")) ||
text.contains(QLatin1String("QFont::setPointSizeF: Point size <= 0")) || // we don't even use that method directly
text.contains(
QLatin1String("QFont::setPointSizeF: Point size <= 0")) || // we don't even use that
// method directly
text.contains(QLatin1String(
"scroll event from unregistered device")) || // when YubiKey is plugged in or out
text.contains(QLatin1String("QFileSystemWatcher::removePaths: list is empty")))) {
Expand Down
9 changes: 5 additions & 4 deletions src/widgets/passwordlineedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@
*/

#include "passwordlineedit.h"

#include <QAction>

PasswordLineEdit::PasswordLineEdit(QWidget *parent) : QLineEdit(parent) {
setEchoMode(QLineEdit::Password);

static const auto visibleIcon = QIcon::fromTheme(QStringLiteral("view-visible"),
QIcon(":/icons/breeze-qownnotes/16x16/view-visible.svg"));
static const auto hiddenIcon = QIcon::fromTheme(QStringLiteral("view-hidden"),
QIcon(":/icons/breeze-qownnotes/16x16/view-hidden.svg"));
static const auto visibleIcon = QIcon::fromTheme(
QStringLiteral("view-visible"), QIcon(":/icons/breeze-qownnotes/16x16/view-visible.svg"));
static const auto hiddenIcon = QIcon::fromTheme(
QStringLiteral("view-hidden"), QIcon(":/icons/breeze-qownnotes/16x16/view-hidden.svg"));
static const auto visibleText = tr("Show password");
static const auto hiddenText = tr("Hide password");

Expand Down

0 comments on commit 964acf6

Please sign in to comment.