Commit 10717a5a authored by Nicolas Fella's avatar Nicolas Fella

clang-format

parent 6b38b293
......@@ -15,7 +15,7 @@
* 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.
*/
*/
#include "knumbermodel.h"
......@@ -33,13 +33,9 @@ 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)
{
......@@ -100,7 +96,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();
}
......@@ -109,7 +105,7 @@ QLocale::NumberOptions KNumberModel::formattingOptions() const
return d->formattingOptions;
}
qreal KNumberModel::value(const QModelIndex &index) const
qreal KNumberModel::value(const QModelIndex &index) const
{
if (!index.isValid()) {
return 0.0;
......@@ -122,26 +118,25 @@ int KNumberModel::rowCount(const QModelIndex &index) const
if (index.parent().isValid()) {
return 0;
}
//1 initial entry (the minimumValue) + the number of valid steps afterwards
// 1 initial entry (the minimumValue) + the number of valid steps afterwards
return 1 + std::max(0, qFloor((d->maximumValue - d->minimumValue) / d->stepSize));
}
QVariant KNumberModel::data(const QModelIndex &index, int role) const
{
switch(role) {
case KNumberModel::DisplayRole: {
auto locale = QLocale::system();
locale.setNumberOptions(d->formattingOptions);
return QVariant(locale.toString(value(index)));
}
case KNumberModel::ValueRole:
return QVariant(value(index));
switch (role) {
case KNumberModel::DisplayRole: {
auto locale = QLocale::system();
locale.setNumberOptions(d->formattingOptions);
return QVariant(locale.toString(value(index)));
}
case KNumberModel::ValueRole:
return QVariant(value(index));
}
return QVariant();
}
QHash<int, QByteArray> KNumberModel::roleNames() const
{
return {{KNumberModel::DisplayRole, QByteArrayLiteral("display")},
{KNumberModel::ValueRole, QByteArrayLiteral("value")}};
return { { KNumberModel::DisplayRole, QByteArrayLiteral("display") }, { KNumberModel::ValueRole, QByteArrayLiteral("value") } };
}
......@@ -25,8 +25,7 @@
#include <QStringMatcher>
#include <KLocalizedString>
TimeZoneFilterProxy::TimeZoneFilterProxy(QObject *parent)
: QSortFilterProxyModel(parent)
TimeZoneFilterProxy::TimeZoneFilterProxy(QObject *parent) : QSortFilterProxyModel(parent)
{
m_stringMatcher.setCaseSensitivity(Qt::CaseInsensitive);
}
......@@ -41,8 +40,7 @@ bool TimeZoneFilterProxy::filterAcceptsRow(int source_row, const QModelIndex &so
const QString region = sourceModel()->index(source_row, 0, source_parent).data(TimeZoneModel::RegionRole).toString();
const QString comment = sourceModel()->index(source_row, 0, source_parent).data(TimeZoneModel::CommentRole).toString();
if (m_stringMatcher.indexIn(city) != -1 || m_stringMatcher.indexIn(region) != -1 ||
m_stringMatcher.indexIn(comment) != -1) {
if (m_stringMatcher.indexIn(city) != -1 || m_stringMatcher.indexIn(region) != -1 || m_stringMatcher.indexIn(comment) != -1) {
return true;
}
......@@ -59,16 +57,12 @@ 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
{
......@@ -81,7 +75,7 @@ QVariant TimeZoneModel::data(const QModelIndex &index, int role) const
if (index.isValid()) {
TimeZoneData currentData = m_data.at(index.row());
switch(role) {
switch (role) {
case TimeZoneIdRole:
return currentData.id;
case RegionRole:
......@@ -152,9 +146,7 @@ void TimeZoneModel::update()
const QStringList splitted = QString::fromUtf8(zone.id()).split(QStringLiteral("/"));
// CITY | COUNTRY | CONTINENT
const QString key = QStringLiteral("%1|%2|%3").arg(splitted.last(),
QLocale::countryToString(zone.country()),
splitted.first());
const QString key = QStringLiteral("%1|%2|%3").arg(splitted.last(), QLocale::countryToString(zone.country()), splitted.first());
cities.append(key);
zonesByCity.insert(key, zone);
......@@ -165,10 +157,10 @@ void TimeZoneModel::update()
const QTimeZone timeZone = zonesByCity.value(key);
QString comment = timeZone.comment();
//FIXME - this was in the old code but makes no sense
// if (!comment.isEmpty()) {
// comment = i18n(comment.toUtf8());
// }
// FIXME - this was in the old code but makes no sense
// if (!comment.isEmpty()) {
// comment = i18n(comment.toUtf8());
// }
const QStringList cityCountryContinent = key.split(QLatin1Char('|'));
......@@ -215,19 +207,10 @@ 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()
{
std::sort(m_selectedTimeZones.begin(), m_selectedTimeZones.end(),
[this](const QString &a, const QString &b) {
return m_offsetData.value(a) < m_offsetData.value(b);
});
std::sort(m_selectedTimeZones.begin(), m_selectedTimeZones.end(), [this](const QString &a, const QString &b) { return m_offsetData.value(a) < m_offsetData.value(b); });
}
This source diff could not be displayed because it is too large. You can view the blob instead.
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