Commit cd079211 authored by Nicolas Fella's avatar Nicolas Fella

clang-format all the things

parent bc41217e
# Copyright (C) 2016 Olivier Goffart <ogoffart@woboq.com>
#
# You may use this file under the terms of the 3-clause BSD license.
# See the file LICENSE from this package for details.
# This is the clang-format configuration style to be used by Qt,
# based on the rules from https://wiki.qt.io/Qt_Coding_Style and
# https://wiki.qt.io/Coding_Conventions
---
# Webkit style was loosely based on the Qt style
# SPDX-License-Identifier: MIT
#
# Copyright (C) 2019 Christoph Cullmann <cullmann@kde.org>
# Copyright (C) 2019 Gernot Gebhard <gebhard@absint.com>
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# Style for C++
Language: Cpp
# base is WebKit coding style: http://www.webkit.org/coding/coding-style.html
# below are only things set that diverge from this style!
BasedOnStyle: WebKit
# enforce C++11 (e.g. for std::vector<std::vector<lala>>
Standard: Cpp11
ColumnLimit: 200
# How much weight do extra characters after the line length limit have.
# PenaltyExcessCharacter: 4
# 4 spaces indent
TabWidth: 4
# Disable reflow of qdoc comments: indentation rules are different.
# Translation comments are also excluded.
CommentPragmas: "^!|^:"
# 3 * 80 wide lines
ColumnLimit: 240
# We want a space between the type and the star for pointer types.
PointerBindsToType: false
# sort includes inside line separated groups
SortIncludes: true
# We use template< without space.
SpaceAfterTemplateKeyword: false
# break before braces on function, namespace and class definitions.
BreakBeforeBraces: Linux
# We want to break before the operators, but not before a '='.
BreakBeforeBinaryOperators: NonAssignment
# Braces are usually attached, but not after functions or class declarations.
BreakBeforeBraces: Custom
BraceWrapping:
AfterClass: true
AfterControlStatement: false
AfterEnum: false
AfterFunction: true
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: true
AfterUnion: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
# When constructor initializers do not fit on one line, put them each on a new line.
ConstructorInitializerAllOnOneLineOrOnePerLine: true
# Indent initializers by 4 spaces
ConstructorInitializerIndentWidth: 4
# Indent width for line continuations.
ContinuationIndentWidth: 8
# No indentation for namespaces.
NamespaceIndentation: None
# CrlInstruction *a;
PointerAlignment: Right
# Horizontally align arguments after an open bracket.
# The coding style does not specify the following, but this is what gives
# results closest to the existing code.
AlignAfterOpenBracket: true
AlwaysBreakTemplateDeclarations: true
# horizontally aligns arguments after an open bracket.
AlignAfterOpenBracket: Align
# Ideally we should also allow less short function in a single line, but
# clang-format does not handle that.
AllowShortFunctionsOnASingleLine: Inline
# align trailing comments
AlignTrailingComments: true
# The coding style specifies some include order categories, but also tells to
# separate categories with an empty line. It does not specify the order within
# the categories. Since the SortInclude feature of clang-format does not
# re-order includes separated by empty lines, the feature is not used.
SortIncludes: false
# don't move all parameters to new line
AllowAllParametersOfDeclarationOnNextLine: false
# Put Q_PROPERTY's on one line
#TypeameMacros: [Q_PROPERTY]
# no single line functions
AllowShortFunctionsOnASingleLine: None
# macros for which the opening brace stays attached.
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH, forever, Q_FOREVER, QBENCHMARK, QBENCHMARK_ONCE ]
# always break before you encounter multi line strings
AlwaysBreakBeforeMultilineStrings: true
# Break constructor initializers before the colon and after the commas.
BreakConstructorInitializers: BeforeColon
# don't move arguments to own lines if they are not all on the same
BinPackArguments: false
# don't move parameters to own lines if they are not all on the same
BinPackParameters: false
# don't break binary ops
BreakBeforeBinaryOperators: None
# format C++11 braced lists like function calls
Cpp11BracedListStyle: true
# remove empty lines
KeepEmptyLinesAtTheStartOfBlocks: false
# no namespace indentation to keep indent level low
NamespaceIndentation: None
# we use template< without space.
SpaceAfterTemplateKeyword: false
# macros for which the opening brace stays attached.
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH, forever, Q_FOREVER, QBENCHMARK, QBENCHMARK_ONCE ]
......@@ -12,6 +12,7 @@ include(ECMSetupVersion)
include(FeatureSummary)
include(KDEInstallDirs)
include(KDECMakeSettings)
include(KDEClangFormat)
find_package(Qt5 REQUIRED COMPONENTS Gui Qml Quick)
find_package(KF5 REQUIRED COMPONENTS I18n)
......@@ -42,3 +43,7 @@ install(FILES org.kde.ktrip.svg DESTINATION ${KDE_INSTALL_FULL_ICONDIR}/hicolor/
install(FILES org.kde.ktrip.appdata.xml DESTINATION ${KDE_INSTALL_METAINFODIR})
feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)
# add clang-format target for all our real source files
file(GLOB_RECURSE ALL_CLANG_FORMAT_SOURCE_FILES *.cpp *.h)
kde_clang_format(${ALL_CLANG_FORMAT_SOURCE_FILES})
......@@ -63,9 +63,9 @@ static void timeCancelled(JNIEnv *env, jobject that)
AndroidUtils::instance()->_timeCancelled();
}
static const JNINativeMethod methods[] = { { "dateSelected", "(Ljava/lang/String;)V", (void *)dateSelected }, { "cancelled", "()V", (void *)dateCancelled } };
static const JNINativeMethod methods[] = {{"dateSelected", "(Ljava/lang/String;)V", (void *)dateSelected}, {"cancelled", "()V", (void *)dateCancelled}};
static const JNINativeMethod timeMethods[] = { { "timeSelected", "(Ljava/lang/String;)V", (void *)timeSelected }, { "cancelled", "()V", (void *)timeCancelled } };
static const JNINativeMethod timeMethods[] = {{"timeSelected", "(Ljava/lang/String;)V", (void *)timeSelected}, {"cancelled", "()V", (void *)timeCancelled}};
Q_DECL_EXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *)
{
......
......@@ -33,9 +33,15 @@ public:
QLocale::NumberOptions formattingOptions = QLocale::DefaultNumberOptions;
};
KNumberModel::KNumberModel(QObject *parent) : QAbstractListModel(parent), d(new KNumberModelPrivate) {}
KNumberModel::KNumberModel(QObject *parent)
: QAbstractListModel(parent)
, d(new KNumberModelPrivate)
{
}
KNumberModel::~KNumberModel() {}
KNumberModel::~KNumberModel()
{
}
void KNumberModel::setMinimumValue(qreal minimumValue)
{
......@@ -96,7 +102,7 @@ void KNumberModel::setFormattingOptions(QLocale::NumberOptions formattingOptions
if (rowCount() == 0) {
return;
}
dataChanged(index(0, 0, QModelIndex()), index(rowCount(), 0, QModelIndex()), QVector<int> { DisplayRole });
dataChanged(index(0, 0, QModelIndex()), index(rowCount(), 0, QModelIndex()), QVector<int> {DisplayRole});
emit formattingOptionsChanged();
}
......@@ -138,5 +144,5 @@ QVariant KNumberModel::data(const QModelIndex &index, int role) const
QHash<int, QByteArray> KNumberModel::roleNames() const
{
return { { KNumberModel::DisplayRole, QByteArrayLiteral("display") }, { KNumberModel::ValueRole, QByteArrayLiteral("value") } };
return {{KNumberModel::DisplayRole, QByteArrayLiteral("display")}, {KNumberModel::ValueRole, QByteArrayLiteral("value")}};
}
......@@ -15,14 +15,14 @@
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
*/
#ifndef KNUMBERMODEL_H
#define KNUMBERMODEL_H
#include <QAbstractListModel>
#include <QScopedPointer>
#include <QLocale>
#include <QScopedPointer>
// #include "kitemmodels_export.h"
......@@ -40,19 +40,16 @@ class KNumberModelPrivate;
class KNumberModel : public QAbstractListModel
{
Q_OBJECT
Q_PROPERTY (qreal minimumValue READ minimumValue WRITE setMinimumValue NOTIFY minimumValueChanged)
Q_PROPERTY (qreal maximumValue READ maximumValue WRITE setMaximumValue NOTIFY maximumValueChanged)
Q_PROPERTY (qreal stepSize READ stepSize WRITE setStepSize NOTIFY stepSizeChanged)
Q_PROPERTY (QLocale::NumberOptions formattingOptions READ formattingOptions WRITE setFormattingOptions NOTIFY formattingOptionsChanged)
Q_PROPERTY(qreal minimumValue READ minimumValue WRITE setMinimumValue NOTIFY minimumValueChanged)
Q_PROPERTY(qreal maximumValue READ maximumValue WRITE setMaximumValue NOTIFY maximumValueChanged)
Q_PROPERTY(qreal stepSize READ stepSize WRITE setStepSize NOTIFY stepSizeChanged)
Q_PROPERTY(QLocale::NumberOptions formattingOptions READ formattingOptions WRITE setFormattingOptions NOTIFY formattingOptionsChanged)
public:
KNumberModel(QObject *parent = nullptr);
~KNumberModel() override;
enum Roles {
DisplayRole = Qt::DisplayRole,
ValueRole = Qt::UserRole
};
enum Roles { DisplayRole = Qt::DisplayRole, ValueRole = Qt::UserRole };
/**
* The minimum value for the model.
......@@ -90,10 +87,10 @@ public:
/**
* Returns the value represented at the given index.
*/
qreal value(const QModelIndex &index) const;
qreal value(const QModelIndex &index) const;
int rowCount(const QModelIndex &index = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
QHash<int, QByteArray> roleNames() const override;
Q_SIGNALS:
......
#include <QQmlExtensionPlugin>
#include <QQmlEngine>
#include <QQmlExtensionPlugin>
#include "timezonemodel.h"
#include "knumbermodel.h"
#include "timezonemodel.h"
class KirigamiAddonsDataAndTimePlugin : public QQmlExtensionPlugin
{
......
......@@ -24,7 +24,6 @@
class TimeZoneData
{
public:
QString id;
QString region;
......@@ -32,7 +31,6 @@ public:
QString comment;
bool checked;
int offsetFromUtc;
};
#endif // TIMEZONEDATA_H
......@@ -21,11 +21,12 @@
#include "timezonemodel.h"
#include "timezonesi18n.h"
#include <QTimeZone>
#include <QStringMatcher>
#include <KLocalizedString>
#include <QStringMatcher>
#include <QTimeZone>
TimeZoneFilterProxy::TimeZoneFilterProxy(QObject *parent) : QSortFilterProxyModel(parent)
TimeZoneFilterProxy::TimeZoneFilterProxy(QObject *parent)
: QSortFilterProxyModel(parent)
{
m_stringMatcher.setCaseSensitivity(Qt::CaseInsensitive);
}
......@@ -57,12 +58,16 @@ void TimeZoneFilterProxy::setFilterString(const QString &filterString)
//=============================================================================
TimeZoneModel::TimeZoneModel(QObject *parent) : QAbstractListModel(parent), m_timezonesI18n(new TimezonesI18n(this))
TimeZoneModel::TimeZoneModel(QObject *parent)
: QAbstractListModel(parent)
, m_timezonesI18n(new TimezonesI18n(this))
{
update();
}
TimeZoneModel::~TimeZoneModel() {}
TimeZoneModel::~TimeZoneModel()
{
}
int TimeZoneModel::rowCount(const QModelIndex &parent) const
{
......@@ -166,8 +171,7 @@ void TimeZoneModel::update()
TimeZoneData newData;
newData.id = QString::fromUtf8(timeZone.id());
newData.region = timeZone.country() == QLocale::AnyCountry ? QString()
: m_timezonesI18n->i18nContinents(cityCountryContinent.at(2)) + QLatin1Char('/') + m_timezonesI18n->i18nCountry(timeZone.country());
newData.region = timeZone.country() == QLocale::AnyCountry ? QString() : m_timezonesI18n->i18nContinents(cityCountryContinent.at(2)) + QLatin1Char('/') + m_timezonesI18n->i18nCountry(timeZone.country());
newData.city = m_timezonesI18n->i18nCity(cityCountryContinent.at(0));
newData.comment = comment;
newData.checked = false;
......@@ -207,7 +211,7 @@ void TimeZoneModel::selectLocalTimeZone()
QHash<int, QByteArray> TimeZoneModel::roleNames() const
{
return QHash<int, QByteArray>({ { TimeZoneIdRole, "timeZoneId" }, { RegionRole, "region" }, { CityRole, "city" }, { CommentRole, "comment" }, { CheckedRole, "checked" } });
return QHash<int, QByteArray>({{TimeZoneIdRole, "timeZoneId"}, {RegionRole, "region"}, {CityRole, "city"}, {CommentRole, "comment"}, {CheckedRole, "checked"}});
}
void TimeZoneModel::sortTimeZones()
......
......@@ -58,13 +58,7 @@ public:
explicit TimeZoneModel(QObject *parent = nullptr);
~TimeZoneModel() override;
enum Roles {
TimeZoneIdRole = Qt::UserRole + 1,
RegionRole,
CityRole,
CommentRole,
CheckedRole
};
enum Roles { TimeZoneIdRole = Qt::UserRole + 1, RegionRole, CityRole, CommentRole, CheckedRole };
int rowCount(const QModelIndex &parent) const override;
QVariant data(const QModelIndex &index, int role) const override;
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -22,9 +22,9 @@
#ifndef TIMEZONESI18N_H
#define TIMEZONESI18N_H
#include <QObject>
#include <QHash>
#include <QLocale>
#include <QObject>
class TimezonesI18n : public QObject
{
......
......@@ -33,8 +33,7 @@ QString Formatter::formatDuration(int seconds)
return QString::number(hours) + QStringLiteral(":") + minutesString;
}
QString Formatter::formatTime(const QDateTime& time)
QString Formatter::formatTime(const QDateTime &time)
{
return time.toString(QStringLiteral("hh:mm"));
}
......@@ -24,11 +24,9 @@
class Formatter : public QObject
{
Q_OBJECT
public:
Q_INVOKABLE QString formatDuration(int seconds);
Q_INVOKABLE QString formatTime(const QDateTime &time);
};
......@@ -20,14 +20,16 @@
#include "locationcache.h"
#include <QDebug>
#include <QDateTime>
#include <QStandardPaths>
#include <QDebug>
#include <QJsonDocument>
#include <QJsonObject>
#include <QStandardPaths>
LocationCache::LocationCache(QObject *parent)
: QObject(parent), m_locationCacheFile(QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + QStringLiteral("/locations.cache")), m_cachedLocationsJson()
: QObject(parent)
, m_locationCacheFile(QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + QStringLiteral("/locations.cache"))
, m_cachedLocationsJson()
{
if (!m_locationCacheFile.open(QIODevice::ReadWrite)) {
qWarning() << "Could not open location cache file" << m_locationCacheFile.fileName();
......
......@@ -20,9 +20,9 @@
#pragma once
#include <QObject>
#include <QFile>
#include <QJsonArray>
#include <QObject>
#include <KPublicTransport/Location>
......@@ -49,4 +49,3 @@ private:
QFile m_locationCacheFile;
QJsonArray m_cachedLocationsJson;
};
......@@ -19,9 +19,9 @@
*/
#include "androidutils.h"
#include "querycontroller.h"
#include "locationcache.h"
#include "formatter.h"
#include "locationcache.h"
#include "querycontroller.h"
#include <QQmlApplicationEngine>
#include <QQmlContext>
......@@ -32,17 +32,16 @@
#include <QApplication>
#endif
#include <KPublicTransport/Manager>
#include <KPublicTransport/LocationRequest>
#include <KLocalizedContext>
#include <KLocalizedString>
#include <KPublicTransport/LocationRequest>
#include <KPublicTransport/Manager>
#ifdef Q_OS_ANDROID
Q_DECL_EXPORT
#endif
int main(int argc, char *argv[])
{
#ifdef Q_OS_ANDROID
QGuiApplication app(argc, argv);
#else
......
......@@ -20,14 +20,16 @@
#include "querycontroller.h"
#include <QDebug>
#include <QDateTime>
#include <QStandardPaths>
#include <QDebug>
#include <QJsonDocument>
#include <QJsonObject>
#include <QStandardPaths>
QueryController::QueryController(QObject *parent)
: QObject(parent), m_start(), m_destination()
: QObject(parent)
, m_start()
, m_destination()
{
m_departureDate = QDate::currentDate().toString(Qt::ISODate);
m_departureTime = QTime::currentTime().toString(Qt::SystemLocaleShortDate);
......
......@@ -23,14 +23,13 @@
#include <QObject>
#include <QVariant>
#include <KPublicTransport/DepartureRequest>
#include <KPublicTransport/JourneyRequest>
#include <KPublicTransport/Location>
#include <KPublicTransport/LocationRequest>
#include <KPublicTransport/JourneyRequest>
#include <KPublicTransport/DepartureRequest>
class QueryController : public QObject
{
Q_OBJECT
Q_PROPERTY(KPublicTransport::Location start READ start WRITE setStart NOTIFY startChanged)
Q_PROPERTY(KPublicTransport::Location destination READ destination WRITE setDestination NOTIFY destinationChanged)
......@@ -63,7 +62,6 @@ Q_SIGNALS:
void departureTimeChanged();
private:
KPublicTransport::Location m_start;
KPublicTransport::Location m_destination;
QString m_departureDate;
......
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