aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2018-01-07 23:28:42 +0100
committerAqua-sama <aqua@iserlohn-fortress.net>2018-01-07 23:28:42 +0100
commitb984992fc92b6dd607732d6dad1c533b36f1ba3a (patch)
tree984c5ede072c2ebb10ad32acb5d5928162feb97f /lib
parentSearching through BookmarkModel elements (diff)
downloadsmolbote-b984992fc92b6dd607732d6dad1c533b36f1ba3a.tar.xz
Added .clang-format
Diffstat (limited to 'lib')
-rw-r--r--lib/bookmarks/bookmarkitem.cpp2
-rw-r--r--lib/bookmarks/bookmarkitem.h8
-rw-r--r--lib/bookmarks/bookmarksmodel.cpp18
-rw-r--r--lib/bookmarks/bookmarksmodel.h3
-rw-r--r--lib/bookmarks/bookmarkswidget.cpp6
-rw-r--r--lib/bookmarks/bookmarkswidget.h10
-rw-r--r--lib/bookmarks/xbel.cpp1
-rw-r--r--lib/bookmarks/xbel.h2
-rw-r--r--lib/downloads/downloadswidget.cpp18
-rw-r--r--lib/downloads/downloadswidget.h3
-rw-r--r--lib/downloads/widgets/downloaditemwidget.cpp8
-rw-r--r--lib/downloads/widgets/downloaditemwidget.h5
-rw-r--r--lib/downloads/widgets/elidedlabel.h6
-rw-r--r--lib/navigation/navigationbutton.cpp16
-rw-r--r--lib/navigation/navigationbutton.h3
-rw-r--r--lib/navigation/urllineedit.cpp12
-rw-r--r--lib/navigation/urllineedit.h2
-rw-r--r--lib/settings/configuration.cpp54
-rw-r--r--lib/settings/configuration.h35
-rw-r--r--lib/settings/settingsdialog.cpp14
-rw-r--r--lib/settings/settingsdialog.h3
21 files changed, 115 insertions, 114 deletions
diff --git a/lib/bookmarks/bookmarkitem.cpp b/lib/bookmarks/bookmarkitem.cpp
index 14ad197..875ccc6 100644
--- a/lib/bookmarks/bookmarkitem.cpp
+++ b/lib/bookmarks/bookmarkitem.cpp
@@ -48,7 +48,7 @@ int BookmarkItem::childCount() const
int BookmarkItem::row() const
{
if(m_parentItem) {
- return m_parentItem->m_childItems.indexOf(const_cast<BookmarkItem*>(this));
+ return m_parentItem->m_childItems.indexOf(const_cast<BookmarkItem *>(this));
}
// no parent item, we are root
diff --git a/lib/bookmarks/bookmarkitem.h b/lib/bookmarks/bookmarkitem.h
index 839f10e..1b9223e 100644
--- a/lib/bookmarks/bookmarkitem.h
+++ b/lib/bookmarks/bookmarkitem.h
@@ -29,10 +29,12 @@ public:
int childIndex(BookmarkItem *item) const;
int childCount() const;
- BookmarkItemType type() const {
+ BookmarkItemType type() const
+ {
return m_type;
};
- int columnCount() const {
+ int columnCount() const
+ {
return 2;
};
@@ -47,7 +49,7 @@ public:
private:
BookmarkItemType m_type;
BookmarkItem *m_parentItem;
- QVector<BookmarkItem*> m_childItems;
+ QVector<BookmarkItem *> m_childItems;
};
#endif //BOOKMARKITEM_H
diff --git a/lib/bookmarks/bookmarksmodel.cpp b/lib/bookmarks/bookmarksmodel.cpp
index 757612e..7e0c35b 100644
--- a/lib/bookmarks/bookmarksmodel.cpp
+++ b/lib/bookmarks/bookmarksmodel.cpp
@@ -9,7 +9,8 @@
#include "bookmarksmodel.h"
#include <QStyle>
-BookmarksModel::BookmarksModel(QStyle *style, QObject *parent) : QAbstractItemModel(parent)
+BookmarksModel::BookmarksModel(QStyle *style, QObject *parent)
+ : QAbstractItemModel(parent)
{
folderIcon.addPixmap(style->standardPixmap(QStyle::SP_DirOpenIcon), QIcon::Normal, QIcon::On);
folderIcon.addPixmap(style->standardPixmap(QStyle::SP_DirClosedIcon), QIcon::Normal, QIcon::Off);
@@ -62,14 +63,14 @@ QModelIndex BookmarksModel::index(BookmarkItem *node, int column) const
QModelIndex BookmarksModel::index(int row, int column, const QModelIndex &parent) const
{
// invalid item requested
- if (!hasIndex(row, column, parent)) {
+ if(!hasIndex(row, column, parent)) {
return QModelIndex();
}
// index exists
BookmarkItem *parentItem;
if(parent.isValid()) {
- parentItem = static_cast<BookmarkItem*>(parent.internalPointer());
+ parentItem = static_cast<BookmarkItem *>(parent.internalPointer());
} else {
parentItem = m_rootItem;
}
@@ -87,7 +88,7 @@ QModelIndex BookmarksModel::parent(const QModelIndex &index) const
return QModelIndex();
}
- BookmarkItem *childItem = static_cast<BookmarkItem*>(index.internalPointer());
+ BookmarkItem *childItem = static_cast<BookmarkItem *>(index.internalPointer());
BookmarkItem *parentItem = childItem->parentItem();
if(parentItem == m_rootItem) {
@@ -107,7 +108,7 @@ int BookmarksModel::rowCount(const QModelIndex &parent) const
if(!parent.isValid()) {
parentItem = m_rootItem;
} else {
- parentItem = static_cast<BookmarkItem*>(parent.internalPointer());
+ parentItem = static_cast<BookmarkItem *>(parent.internalPointer());
}
return parentItem->childCount();
@@ -116,7 +117,7 @@ int BookmarksModel::rowCount(const QModelIndex &parent) const
int BookmarksModel::columnCount(const QModelIndex &parent) const
{
if(parent.isValid()) {
- return static_cast<BookmarkItem*>(parent.internalPointer())->columnCount();
+ return static_cast<BookmarkItem *>(parent.internalPointer())->columnCount();
} else {
return m_rootItem->columnCount();
}
@@ -125,12 +126,12 @@ int BookmarksModel::columnCount(const QModelIndex &parent) const
QVariant BookmarksModel::data(const QModelIndex &index, int role) const
{
// get data of invalid index?
- if (!index.isValid()) {
+ if(!index.isValid()) {
return QVariant();
}
const BookmarkItem *item = static_cast<BookmarkItem *>(index.internalPointer());
- switch (role) {
+ switch(role) {
case Qt::DisplayRole:
case Qt::EditRole:
if(index.column() == 0) {
@@ -200,6 +201,5 @@ QModelIndexList BookmarksModel::match(const QModelIndex &start, int role, const
}
}
-
return list;
}
diff --git a/lib/bookmarks/bookmarksmodel.h b/lib/bookmarks/bookmarksmodel.h
index 9d884fb..baf2ba9 100644
--- a/lib/bookmarks/bookmarksmodel.h
+++ b/lib/bookmarks/bookmarksmodel.h
@@ -6,9 +6,9 @@
* SPDX-License-Identifier: GPL-3.0
*/
+#include "bookmarkitem.h"
#include <QAbstractItemModel>
#include <QIcon>
-#include "bookmarkitem.h"
#ifndef BOOKMARKSMODEL_H
#define BOOKMARKSMODEL_H
@@ -46,7 +46,6 @@ private:
QIcon bookmarkIcon;
BookmarkItem *m_rootItem;
-
};
#endif //BOOKMARKSMODEL_H
diff --git a/lib/bookmarks/bookmarkswidget.cpp b/lib/bookmarks/bookmarkswidget.cpp
index daec3f4..8aafe37 100644
--- a/lib/bookmarks/bookmarkswidget.cpp
+++ b/lib/bookmarks/bookmarkswidget.cpp
@@ -10,9 +10,9 @@
#include "ui_bookmarksform.h"
#include <QUrl>
-BookmarksWidget::BookmarksWidget(const QString &path, QWidget *parent) :
- QWidget(parent),
- ui(new Ui::BookmarksDialog)
+BookmarksWidget::BookmarksWidget(const QString &path, QWidget *parent)
+ : QWidget(parent)
+ , ui(new Ui::BookmarksDialog)
{
// make sure this dialog does not get deleted on close
setAttribute(Qt::WA_DeleteOnClose, false);
diff --git a/lib/bookmarks/bookmarkswidget.h b/lib/bookmarks/bookmarkswidget.h
index cdc013e..f82a512 100644
--- a/lib/bookmarks/bookmarkswidget.h
+++ b/lib/bookmarks/bookmarkswidget.h
@@ -9,11 +9,12 @@
#ifndef BOOKMARKSDIALOG_H
#define BOOKMARKSDIALOG_H
-#include <QWidget>
-#include "xbel.h"
#include "bookmarksmodel.h"
+#include "xbel.h"
+#include <QWidget>
-namespace Ui {
+namespace Ui
+{
class BookmarksDialog;
}
@@ -23,7 +24,7 @@ class BookmarksWidget : public QWidget
public:
explicit BookmarksWidget(const QString &path, QWidget *parent = 0);
- ~BookmarksWidget() override ;
+ ~BookmarksWidget() override;
void save();
QAbstractItemModel *model() const;
@@ -31,7 +32,6 @@ public:
signals:
void openUrl(const QUrl &url);
-
private:
void expandNodes(BookmarkItem *node);
diff --git a/lib/bookmarks/xbel.cpp b/lib/bookmarks/xbel.cpp
index eeb019a..7a7632c 100644
--- a/lib/bookmarks/xbel.cpp
+++ b/lib/bookmarks/xbel.cpp
@@ -46,7 +46,6 @@ BookmarkItem *Xbel::read()
return root;
}
-
void Xbel::readChildElements(QXmlStreamReader &reader, BookmarkItem *parentItem)
{
while(reader.readNextStartElement()) {
diff --git a/lib/bookmarks/xbel.h b/lib/bookmarks/xbel.h
index 1c03b74..c425cc5 100644
--- a/lib/bookmarks/xbel.h
+++ b/lib/bookmarks/xbel.h
@@ -9,9 +9,9 @@
#ifndef XBELREADER_H
#define XBELREADER_H
+#include "bookmarkitem.h"
#include <QString>
#include <QXmlStreamReader>
-#include "bookmarkitem.h"
class Xbel
{
diff --git a/lib/downloads/downloadswidget.cpp b/lib/downloads/downloadswidget.cpp
index 1a5f268..b3bad67 100644
--- a/lib/downloads/downloadswidget.cpp
+++ b/lib/downloads/downloadswidget.cpp
@@ -9,14 +9,14 @@
#include "downloadswidget.h"
#include "ui_downloadsform.h"
-#include <QWebEngineDownloadItem>
+#include "widgets/downloaditemwidget.h"
#include <QFileDialog>
#include <QListWidget>
-#include "widgets/downloaditemwidget.h"
+#include <QWebEngineDownloadItem>
-DownloadsWidget::DownloadsWidget(const QString &downloadPath, QWidget *parent) :
- QDialog(parent),
- ui(new Ui::DownloadDialog)
+DownloadsWidget::DownloadsWidget(const QString &downloadPath, QWidget *parent)
+ : QDialog(parent)
+ , ui(new Ui::DownloadDialog)
{
// make sure this dialog does not get deleted on close
setAttribute(Qt::WA_DeleteOnClose, false);
@@ -27,13 +27,13 @@ DownloadsWidget::DownloadsWidget(const QString &downloadPath, QWidget *parent) :
m_downloadPath = downloadPath;
connect(ui->listWidget, &QListWidget::currentItemChanged, this, [this](QListWidgetItem *current, QListWidgetItem *previous) {
- DownloadItemWidget *currentWidget = qobject_cast<DownloadItemWidget*>(ui->listWidget->itemWidget(current));
+ DownloadItemWidget *currentWidget = qobject_cast<DownloadItemWidget *>(ui->listWidget->itemWidget(current));
currentWidget->showDetails();
currentWidget->setFixedWidth(ui->listWidget->viewport()->width());
currentWidget->adjustSize();
current->setSizeHint(currentWidget->size());
- DownloadItemWidget *previousWidget = qobject_cast<DownloadItemWidget*>(ui->listWidget->itemWidget(previous));
+ DownloadItemWidget *previousWidget = qobject_cast<DownloadItemWidget *>(ui->listWidget->itemWidget(previous));
if(previousWidget != nullptr) {
previousWidget->hideDetails();
previousWidget->setFixedWidth(ui->listWidget->viewport()->width());
@@ -53,8 +53,8 @@ void DownloadsWidget::addDownload(QWebEngineDownloadItem *item)
this->show();
QString filepath = QFileDialog::getSaveFileName(this,
- tr("Save"),
- m_downloadPath + "/" + QFileInfo(item->path()).fileName());
+ tr("Save"),
+ m_downloadPath + "/" + QFileInfo(item->path()).fileName());
if(filepath.isEmpty()) {
// user cancelled the save dialog
diff --git a/lib/downloads/downloadswidget.h b/lib/downloads/downloadswidget.h
index 8c9ea21..d724e08 100644
--- a/lib/downloads/downloadswidget.h
+++ b/lib/downloads/downloadswidget.h
@@ -11,7 +11,8 @@
#include <QDialog>
-namespace Ui {
+namespace Ui
+{
class DownloadDialog;
}
diff --git a/lib/downloads/widgets/downloaditemwidget.cpp b/lib/downloads/widgets/downloaditemwidget.cpp
index a51275e..6860c16 100644
--- a/lib/downloads/widgets/downloaditemwidget.cpp
+++ b/lib/downloads/widgets/downloaditemwidget.cpp
@@ -11,9 +11,9 @@
#include <QUrl>
-DownloadItemWidget::DownloadItemWidget(QWebEngineDownloadItem *item, QWidget *parent) :
- QWidget(parent),
- ui(new Ui::DownloadItemForm)
+DownloadItemWidget::DownloadItemWidget(QWebEngineDownloadItem *item, QWidget *parent)
+ : QWidget(parent)
+ , ui(new Ui::DownloadItemForm)
{
m_item = item;
@@ -68,7 +68,7 @@ QString DownloadItemWidget::sizeString(int size) const
void DownloadItemWidget::updateState(QWebEngineDownloadItem::DownloadState state)
{
- switch (state) {
+ switch(state) {
case QWebEngineDownloadItem::DownloadRequested:
ui->status_label->setText(tr("Requested"));
break;
diff --git a/lib/downloads/widgets/downloaditemwidget.h b/lib/downloads/widgets/downloaditemwidget.h
index c6246da..09a7370 100644
--- a/lib/downloads/widgets/downloaditemwidget.h
+++ b/lib/downloads/widgets/downloaditemwidget.h
@@ -9,10 +9,11 @@
#ifndef DOWNLOADITEMFORM_H
#define DOWNLOADITEMFORM_H
-#include <QWidget>
#include <QWebEngineDownloadItem>
+#include <QWidget>
-namespace Ui {
+namespace Ui
+{
class DownloadItemForm;
}
diff --git a/lib/downloads/widgets/elidedlabel.h b/lib/downloads/widgets/elidedlabel.h
index d0f6221..d6c06c5 100644
--- a/lib/downloads/widgets/elidedlabel.h
+++ b/lib/downloads/widgets/elidedlabel.h
@@ -67,10 +67,12 @@ public:
explicit ElidedLabel(QWidget *parent = nullptr);
void setContent(const QString &text);
- const QString & text() const {
+ const QString &text() const
+ {
return content;
}
- bool isElided() const {
+ bool isElided() const
+ {
return elided;
}
diff --git a/lib/navigation/navigationbutton.cpp b/lib/navigation/navigationbutton.cpp
index ecf7c81..577c291 100644
--- a/lib/navigation/navigationbutton.cpp
+++ b/lib/navigation/navigationbutton.cpp
@@ -11,13 +11,13 @@
#include <QStyle>
#include <QWebEngineHistory>
-NavigationButton::NavigationButton(Type type, QWidget *parent) :
- QToolButton(parent)
+NavigationButton::NavigationButton(Type type, QWidget *parent)
+ : QToolButton(parent)
{
m_type = type;
menu = new QMenu(this);
- switch (type) {
+ switch(type) {
case BackButton:
setIcon(style()->standardIcon(QStyle::SP_ArrowBack));
setMenu(menu);
@@ -37,10 +37,8 @@ NavigationButton::NavigationButton(Type type, QWidget *parent) :
}
connect(this, &NavigationButton::clicked, this, &NavigationButton::doAction);
-
}
-
void NavigationButton::setView(WebView *view)
{
disconnect(loadStartedConnection);
@@ -57,7 +55,7 @@ void NavigationButton::setView(WebView *view)
void NavigationButton::updateOnLoadStarted()
{
- switch (m_type) {
+ switch(m_type) {
case BackButton:
break;
case ForwardButton:
@@ -73,7 +71,7 @@ void NavigationButton::updateOnLoadStarted()
void NavigationButton::updateOnLoadFinished()
{
- switch (m_type) {
+ switch(m_type) {
case BackButton:
if(m_view->history()->canGoBack()) {
setEnabled(true);
@@ -99,7 +97,7 @@ void NavigationButton::updateOnLoadFinished()
void NavigationButton::doAction()
{
- switch (m_type) {
+ switch(m_type) {
case BackButton:
m_view->history()->back();
break;
@@ -120,7 +118,7 @@ void NavigationButton::prepareMenu()
menu->clear();
QList<QWebEngineHistoryItem> items;
- switch (m_type) {
+ switch(m_type) {
case BackButton:
items = m_view->history()->backItems(10);
break;
diff --git a/lib/navigation/navigationbutton.h b/lib/navigation/navigationbutton.h
index 7c76b9c..e0d358a 100644
--- a/lib/navigation/navigationbutton.h
+++ b/lib/navigation/navigationbutton.h
@@ -9,8 +9,8 @@
#ifndef NAVIGATIONBUTTON_H
#define NAVIGATIONBUTTON_H
-#include <QToolButton>
#include "../../src/webengine/webview.h"
+#include <QToolButton>
class QMenu;
@@ -18,7 +18,6 @@ class NavigationButton : public QToolButton
{
Q_OBJECT
public:
-
enum Type {
BackButton,
ForwardButton,
diff --git a/lib/navigation/urllineedit.cpp b/lib/navigation/urllineedit.cpp
index 85f443d..4c207a1 100644
--- a/lib/navigation/urllineedit.cpp
+++ b/lib/navigation/urllineedit.cpp
@@ -7,9 +7,9 @@
*/
#include "urllineedit.h"
-#include <QTimer>
#include <QMenu>
#include <QStyle>
+#include <QTimer>
#include <QWidgetAction>
// ssl menu
@@ -18,9 +18,9 @@
#include <QListView>
#include <QStringListModel>
-UrlLineEdit::UrlLineEdit(QWidget *parent) :
- QLineEdit(parent),
- m_listView(new QListView(this))
+UrlLineEdit::UrlLineEdit(QWidget *parent)
+ : QLineEdit(parent)
+ , m_listView(new QListView(this))
{
setPlaceholderText(tr("Enter address"));
@@ -66,7 +66,6 @@ UrlLineEdit::UrlLineEdit(QWidget *parent) :
}
this->clearFocus();
});
-
}
QAction *UrlLineEdit::pageAction()
@@ -145,7 +144,7 @@ void UrlLineEdit::keyPressEvent(QKeyEvent *event)
int count = m_listView->model()->rowCount();
QModelIndex currentIndex = m_listView->currentIndex();
- switch (key) {
+ switch(key) {
case Qt::Key_Down:
if(currentIndex.row() + 1 >= count) {
m_listView->setCurrentIndex(m_listView->model()->index(0, 0));
@@ -185,7 +184,6 @@ void UrlLineEdit::setTextFormat(const QTextLayout::FormatRange &format)
attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, format.start, format.length, format.format));
QInputMethodEvent ev(QString(), attributes);
event(&ev);
-
}
void UrlLineEdit::clearTextFormat()
diff --git a/lib/navigation/urllineedit.h b/lib/navigation/urllineedit.h
index a06ba1b..9ac0366 100644
--- a/lib/navigation/urllineedit.h
+++ b/lib/navigation/urllineedit.h
@@ -9,9 +9,9 @@
#ifndef URLLINEEDIT_H
#define URLLINEEDIT_H
+#include <QAction>
#include <QLineEdit>
#include <QTextLayout>
-#include <QAction>
class QAbstractItemModel;
class QMenu;
diff --git a/lib/settings/configuration.cpp b/lib/settings/configuration.cpp
index 1fa1fbf..06ee0bd 100644
--- a/lib/settings/configuration.cpp
+++ b/lib/settings/configuration.cpp
@@ -38,19 +38,19 @@ bool Configuration::readUserConfiguration(const std::string &path)
m_userCfgPath = path;
try {
m_userCfg->readFile(path.c_str());
- } catch (FileIOException) {
+ } catch(FileIOException) {
return false;
- } catch (ParseException) {
+ } catch(ParseException) {
return false;
}
- return true;
+ return true;
}
bool Configuration::parse(const std::string &contents)
{
try {
m_userCfg->readString(contents);
- } catch (ParseException) {
+ } catch(ParseException) {
return false;
}
return true;
@@ -61,7 +61,7 @@ bool Configuration::writeUserConfiguration(const std::string &path)
m_userCfgPath = path;
try {
m_userCfg->writeFile(m_userCfgPath.c_str());
- } catch (FileIOException) {
+ } catch(FileIOException) {
return false;
}
return true;
@@ -71,7 +71,7 @@ bool Configuration::writeIfNeeded()
{
try {
m_userCfg->writeFile(m_userCfgPath.c_str());
- } catch (FileIOException) {
+ } catch(FileIOException) {
return false;
}
return true;
@@ -81,13 +81,13 @@ bool Configuration::parseDefaultConfiguration(const std::string &contents)
{
try {
m_defaultCfg->readString(contents);
- } catch (ParseException) {
+ } catch(ParseException) {
return false;
}
return true;
}
-std::vector<std::string> Configuration::childrenSettings(const char* name)
+std::vector<std::string> Configuration::childrenSettings(const char *name)
{
std::vector<std::string> groupNames;
const Setting &root = m_userCfg->lookup(name);
@@ -101,7 +101,7 @@ std::vector<std::string> Configuration::childrenSettings(const char* name)
return groupNames;
}
-std::vector<std::string> Configuration::childrenGroups(const char* name)
+std::vector<std::string> Configuration::childrenGroups(const char *name)
{
std::vector<std::string> groupNames;
const Setting &root = m_userCfg->lookup(name);
@@ -118,7 +118,7 @@ void Configuration::resetValue(const char *path)
{
if(m_userCfg->exists(path)) {
Setting &v = m_userCfg->lookup(path);
- switch (v.getType()) {
+ switch(v.getType()) {
case Setting::TypeNone:
break;
case Setting::TypeInt:
@@ -146,8 +146,8 @@ void Configuration::resetValue(const char *path)
}
}
-template<typename T>
-std::optional<T> Configuration::value(const char* path) const
+template <typename T>
+std::optional<T> Configuration::value(const char *path) const
{
// if setting doesn't exist, give back a nullopt
if(!m_userCfg->exists(path)) {
@@ -160,7 +160,7 @@ std::optional<T> Configuration::value(const char* path) const
// cast depending on type
// type checks are done during compile time
- switch (setting.getType()) {
+ switch(setting.getType()) {
case Setting::TypeNone:
r = std::nullopt;
break;
@@ -201,7 +201,7 @@ std::optional<T> Configuration::value(const char* path) const
case Setting::TypeString:
// const char*, std::string
if constexpr(std::is_same<T, std::string>::value) {
- r = std::optional<std::string>(static_cast<const char*>(setting));
+ r = std::optional<std::string>(static_cast<const char *>(setting));
} else {
r = std::nullopt;
}
@@ -235,22 +235,22 @@ std::optional<T> Configuration::value(const char* path) const
}
// tell the compiler to export these functions, otherwise you get linking errors
-template std::optional<int> Configuration::value<int>(const char* path) const;
-template std::optional<unsigned int> Configuration::value<unsigned int>(const char* path) const;
-template std::optional<long> Configuration::value<long>(const char* path) const;
-template std::optional<unsigned long> Configuration::value<unsigned long>(const char* path) const;
+template std::optional<int> Configuration::value<int>(const char *path) const;
+template std::optional<unsigned int> Configuration::value<unsigned int>(const char *path) const;
+template std::optional<long> Configuration::value<long>(const char *path) const;
+template std::optional<unsigned long> Configuration::value<unsigned long>(const char *path) const;
-template std::optional<long long> Configuration::value<long long>(const char* path) const;
-template std::optional<unsigned long long> Configuration::value<unsigned long long>(const char* path) const;
+template std::optional<long long> Configuration::value<long long>(const char *path) const;
+template std::optional<unsigned long long> Configuration::value<unsigned long long>(const char *path) const;
-template std::optional<float> Configuration::value<float>(const char* path) const;
-template std::optional<double> Configuration::value<double>(const char* path) const;
+template std::optional<float> Configuration::value<float>(const char *path) const;
+template std::optional<double> Configuration::value<double>(const char *path) const;
-template std::optional<bool> Configuration::value<bool>(const char* path) const;
+template std::optional<bool> Configuration::value<bool>(const char *path) const;
-template std::optional<std::string> Configuration::value<std::string>(const char* path) const;
+template std::optional<std::string> Configuration::value<std::string>(const char *path) const;
-template<typename T>
+template <typename T>
bool Configuration::setValue(std::string path, const T &val)
{
if(m_userCfg->exists(path)) {
@@ -259,7 +259,7 @@ bool Configuration::setValue(std::string path, const T &val)
if constexpr(std::is_unsigned_v<T> && !std::is_same_v<T, bool>) {
setting = static_cast<typename std::make_signed_t<T>>(val);
} else if constexpr(std::is_same_v<T, std::string>) {
- switch (setting.getType()) {
+ switch(setting.getType()) {
case Setting::TypeNone:
break;
@@ -279,7 +279,7 @@ bool Configuration::setValue(std::string path, const T &val)
case Setting::TypeBoolean:
if(static_cast<std::string>(val) == "true") {
setting = true;
- } else if (static_cast<std::string>(val) == "false") {
+ } else if(static_cast<std::string>(val) == "false") {
setting = false;
}
break;
diff --git a/lib/settings/configuration.h b/lib/settings/configuration.h
index b258cb3..4fc614e 100644
--- a/lib/settings/configuration.h
+++ b/lib/settings/configuration.h
@@ -10,10 +10,11 @@
#define CONFIGURATION_H
#include <optional>
-#include <vector>
#include <string>
+#include <vector>
-namespace libconfig {
+namespace libconfig
+{
class Config;
class Setting;
}
@@ -34,12 +35,12 @@ public:
std::vector<std::string> childrenSettings(const char *name = "");
std::vector<std::string> childrenGroups(const char *name = "");
- void resetValue(const char* path);
+ void resetValue(const char *path);
- template<typename T>
- std::optional<T> value(const char* path) const;
+ template <typename T>
+ std::optional<T> value(const char *path) const;
- template<typename T>
+ template <typename T>
bool setValue(std::string path, const T &val);
private:
@@ -49,26 +50,26 @@ private:
};
// replace ~ with home
-std::string& patchHome(std::string &path, const std::string &home);
+std::string &patchHome(std::string &path, const std::string &home);
// instantiate functions
// this needs to be done because the implementation is in the cpp file
// Settings::value<>
-extern template std::optional<int> Configuration::value<int>(const char* path) const;
-extern template std::optional<unsigned int> Configuration::value<unsigned int>(const char* path) const;
-extern template std::optional<long> Configuration::value<long>(const char* path) const;
-extern template std::optional<unsigned long> Configuration::value<unsigned long>(const char* path) const;
+extern template std::optional<int> Configuration::value<int>(const char *path) const;
+extern template std::optional<unsigned int> Configuration::value<unsigned int>(const char *path) const;
+extern template std::optional<long> Configuration::value<long>(const char *path) const;
+extern template std::optional<unsigned long> Configuration::value<unsigned long>(const char *path) const;
-extern template std::optional<long long> Configuration::value<long long>(const char* path) const;
-extern template std::optional<unsigned long long> Configuration::value<unsigned long long>(const char* path) const;
+extern template std::optional<long long> Configuration::value<long long>(const char *path) const;
+extern template std::optional<unsigned long long> Configuration::value<unsigned long long>(const char *path) const;
-extern template std::optional<float> Configuration::value<float>(const char* path) const;
-extern template std::optional<double> Configuration::value<double>(const char* path) const;
+extern template std::optional<float> Configuration::value<float>(const char *path) const;
+extern template std::optional<double> Configuration::value<double>(const char *path) const;
-extern template std::optional<bool> Configuration::value<bool>(const char* path) const;
+extern template std::optional<bool> Configuration::value<bool>(const char *path) const;
-extern template std::optional<std::string> Configuration::value<std::string>(const char* path) const;
+extern template std::optional<std::string> Configuration::value<std::string>(const char *path) const;
// Settings::setValue<>
extern template bool Configuration::setValue<int>(std::string path, const int &val);
diff --git a/lib/settings/settingsdialog.cpp b/lib/settings/settingsdialog.cpp
index 478e372..97b5f44 100644
--- a/lib/settings/settingsdialog.cpp
+++ b/lib/settings/settingsdialog.cpp
@@ -7,19 +7,19 @@
*/
#include "settingsdialog.h"
-#include "ui_settingsdialog.h"
#include "configuration.h"
-#include <QScrollArea>
+#include "ui_settingsdialog.h"
#include <QFormLayout>
+#include <QGroupBox>
#include <QLineEdit>
+#include <QScrollArea>
#include <QToolButton>
-#include <QGroupBox>
inline QHBoxLayout *createEntry(Configuration *config, const std::string &path, QWidget *widget);
-SettingsDialog::SettingsDialog(std::shared_ptr<Configuration> &settings, QWidget *parent) :
- QDialog(parent),
- ui(new Ui::SettingsDialog)
+SettingsDialog::SettingsDialog(std::shared_ptr<Configuration> &settings, QWidget *parent)
+ : QDialog(parent)
+ , ui(new Ui::SettingsDialog)
{
ui->setupUi(this);
@@ -67,7 +67,7 @@ QWidget *widgetForGroup(std::shared_ptr<Configuration> &settings, const std::str
return widget;
}
-inline QHBoxLayout *createEntry(Configuration* config, const std::string &path, QWidget *widget)
+inline QHBoxLayout *createEntry(Configuration *config, const std::string &path, QWidget *widget)
{
QLineEdit *lineEdit = new QLineEdit(widget);
lineEdit->setText(QString::fromStdString(config->value<std::string>(path.c_str()).value()));
diff --git a/lib/settings/settingsdialog.h b/lib/settings/settingsdialog.h
index 74dd964..f77b822 100644
--- a/lib/settings/settingsdialog.h
+++ b/lib/settings/settingsdialog.h
@@ -12,7 +12,8 @@
#include <QDialog>
#include <memory>
-namespace Ui {
+namespace Ui
+{
class SettingsDialog;
}