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

clang-format

parent 6b38b293
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* along with this library; see the file COPYING.LIB. If not, write to * along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
*/ */
#include "knumbermodel.h" #include "knumbermodel.h"
...@@ -33,13 +33,9 @@ public: ...@@ -33,13 +33,9 @@ public:
QLocale::NumberOptions formattingOptions = QLocale::DefaultNumberOptions; QLocale::NumberOptions formattingOptions = QLocale::DefaultNumberOptions;
}; };
KNumberModel::KNumberModel(QObject *parent): KNumberModel::KNumberModel(QObject *parent) : QAbstractListModel(parent), d(new KNumberModelPrivate) {}
QAbstractListModel(parent),
d(new KNumberModelPrivate)
{}
KNumberModel::~KNumberModel() KNumberModel::~KNumberModel() {}
{}
void KNumberModel::setMinimumValue(qreal minimumValue) void KNumberModel::setMinimumValue(qreal minimumValue)
{ {
...@@ -100,7 +96,7 @@ void KNumberModel::setFormattingOptions(QLocale::NumberOptions formattingOptions ...@@ -100,7 +96,7 @@ void KNumberModel::setFormattingOptions(QLocale::NumberOptions formattingOptions
if (rowCount() == 0) { if (rowCount() == 0) {
return; 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(); emit formattingOptionsChanged();
} }
...@@ -122,13 +118,13 @@ int KNumberModel::rowCount(const QModelIndex &index) const ...@@ -122,13 +118,13 @@ int KNumberModel::rowCount(const QModelIndex &index) const
if (index.parent().isValid()) { if (index.parent().isValid()) {
return 0; 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)); return 1 + std::max(0, qFloor((d->maximumValue - d->minimumValue) / d->stepSize));
} }
QVariant KNumberModel::data(const QModelIndex &index, int role) const QVariant KNumberModel::data(const QModelIndex &index, int role) const
{ {
switch(role) { switch (role) {
case KNumberModel::DisplayRole: { case KNumberModel::DisplayRole: {
auto locale = QLocale::system(); auto locale = QLocale::system();
locale.setNumberOptions(d->formattingOptions); locale.setNumberOptions(d->formattingOptions);
...@@ -142,6 +138,5 @@ QVariant KNumberModel::data(const QModelIndex &index, int role) const ...@@ -142,6 +138,5 @@ QVariant KNumberModel::data(const QModelIndex &index, int role) const
QHash<int, QByteArray> KNumberModel::roleNames() const QHash<int, QByteArray> KNumberModel::roleNames() const
{ {
return {{KNumberModel::DisplayRole, QByteArrayLiteral("display")}, return { { KNumberModel::DisplayRole, QByteArrayLiteral("display") }, { KNumberModel::ValueRole, QByteArrayLiteral("value") } };
{KNumberModel::ValueRole, QByteArrayLiteral("value")}};
} }
...@@ -25,8 +25,7 @@ ...@@ -25,8 +25,7 @@
#include <QStringMatcher> #include <QStringMatcher>
#include <KLocalizedString> #include <KLocalizedString>
TimeZoneFilterProxy::TimeZoneFilterProxy(QObject *parent) TimeZoneFilterProxy::TimeZoneFilterProxy(QObject *parent) : QSortFilterProxyModel(parent)
: QSortFilterProxyModel(parent)
{ {
m_stringMatcher.setCaseSensitivity(Qt::CaseInsensitive); m_stringMatcher.setCaseSensitivity(Qt::CaseInsensitive);
} }
...@@ -41,8 +40,7 @@ bool TimeZoneFilterProxy::filterAcceptsRow(int source_row, const QModelIndex &so ...@@ -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 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(); 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 || if (m_stringMatcher.indexIn(city) != -1 || m_stringMatcher.indexIn(region) != -1 || m_stringMatcher.indexIn(comment) != -1) {
m_stringMatcher.indexIn(comment) != -1) {
return true; return true;
} }
...@@ -59,16 +57,12 @@ void TimeZoneFilterProxy::setFilterString(const QString &filterString) ...@@ -59,16 +57,12 @@ void TimeZoneFilterProxy::setFilterString(const QString &filterString)
//============================================================================= //=============================================================================
TimeZoneModel::TimeZoneModel(QObject *parent) TimeZoneModel::TimeZoneModel(QObject *parent) : QAbstractListModel(parent), m_timezonesI18n(new TimezonesI18n(this))
: QAbstractListModel(parent),
m_timezonesI18n(new TimezonesI18n(this))
{ {
update(); update();
} }
TimeZoneModel::~TimeZoneModel() TimeZoneModel::~TimeZoneModel() {}
{
}
int TimeZoneModel::rowCount(const QModelIndex &parent) const int TimeZoneModel::rowCount(const QModelIndex &parent) const
{ {
...@@ -81,7 +75,7 @@ QVariant TimeZoneModel::data(const QModelIndex &index, int role) const ...@@ -81,7 +75,7 @@ QVariant TimeZoneModel::data(const QModelIndex &index, int role) const
if (index.isValid()) { if (index.isValid()) {
TimeZoneData currentData = m_data.at(index.row()); TimeZoneData currentData = m_data.at(index.row());
switch(role) { switch (role) {
case TimeZoneIdRole: case TimeZoneIdRole:
return currentData.id; return currentData.id;
case RegionRole: case RegionRole:
...@@ -152,9 +146,7 @@ void TimeZoneModel::update() ...@@ -152,9 +146,7 @@ void TimeZoneModel::update()
const QStringList splitted = QString::fromUtf8(zone.id()).split(QStringLiteral("/")); const QStringList splitted = QString::fromUtf8(zone.id()).split(QStringLiteral("/"));
// CITY | COUNTRY | CONTINENT // CITY | COUNTRY | CONTINENT
const QString key = QStringLiteral("%1|%2|%3").arg(splitted.last(), const QString key = QStringLiteral("%1|%2|%3").arg(splitted.last(), QLocale::countryToString(zone.country()), splitted.first());
QLocale::countryToString(zone.country()),
splitted.first());
cities.append(key); cities.append(key);
zonesByCity.insert(key, zone); zonesByCity.insert(key, zone);
...@@ -165,10 +157,10 @@ void TimeZoneModel::update() ...@@ -165,10 +157,10 @@ void TimeZoneModel::update()
const QTimeZone timeZone = zonesByCity.value(key); const QTimeZone timeZone = zonesByCity.value(key);
QString comment = timeZone.comment(); QString comment = timeZone.comment();
//FIXME - this was in the old code but makes no sense // FIXME - this was in the old code but makes no sense
// if (!comment.isEmpty()) { // if (!comment.isEmpty()) {
// comment = i18n(comment.toUtf8()); // comment = i18n(comment.toUtf8());
// } // }
const QStringList cityCountryContinent = key.split(QLatin1Char('|')); const QStringList cityCountryContinent = key.split(QLatin1Char('|'));
...@@ -215,19 +207,10 @@ void TimeZoneModel::selectLocalTimeZone() ...@@ -215,19 +207,10 @@ void TimeZoneModel::selectLocalTimeZone()
QHash<int, QByteArray> TimeZoneModel::roleNames() const QHash<int, QByteArray> TimeZoneModel::roleNames() const
{ {
return QHash<int, QByteArray>({ return QHash<int, QByteArray>({ { TimeZoneIdRole, "timeZoneId" }, { RegionRole, "region" }, { CityRole, "city" }, { CommentRole, "comment" }, { CheckedRole, "checked" } });
{TimeZoneIdRole, "timeZoneId"},
{RegionRole, "region"},
{CityRole, "city"},
{CommentRole, "comment"},
{CheckedRole, "checked"}
});
} }
void TimeZoneModel::sortTimeZones() void TimeZoneModel::sortTimeZones()
{ {
std::sort(m_selectedTimeZones.begin(), m_selectedTimeZones.end(), 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](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