Commit 1c622b19 authored by Nicolas Fella's avatar Nicolas Fella

clang-format code

parent 68925617
......@@ -26,9 +26,9 @@
#define JSTRING(s) QAndroidJniObject::fromString(s).object<jstring>()
AndroidUtils* AndroidUtils::s_instance = nullptr;
AndroidUtils *AndroidUtils::s_instance = nullptr;
AndroidUtils* AndroidUtils::instance()
AndroidUtils *AndroidUtils::instance()
{
if (!s_instance) {
s_instance = new AndroidUtils();
......@@ -63,17 +63,11 @@ 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*)
Q_DECL_EXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *)
{
static bool initialized = false;
if (initialized)
......@@ -81,7 +75,7 @@ Q_DECL_EXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void*)
initialized = true;
JNIEnv *env = nullptr;
if (vm->GetEnv((void**)&env, JNI_VERSION_1_4) != JNI_OK) {
if (vm->GetEnv((void **)&env, JNI_VERSION_1_4) != JNI_OK) {
qWarning() << "Failed to get JNI environment.";
return -1;
}
......
......@@ -34,13 +34,12 @@ public:
void _timeSelected(const QString &data);
void _timeCancelled();
static AndroidUtils* instance();
static AndroidUtils *instance();
Q_SIGNALS:
void datePickerFinished(bool accepted, const QString &date);
void timePickerFinished(bool accepted, const QString &time);
private:
static AndroidUtils* s_instance;
static AndroidUtils *s_instance;
};
......@@ -23,9 +23,7 @@
#include <KPublicTransport/LocationRequest>
#include <KPublicTransport/LocationReply>
LocationQueryModel::LocationQueryModel(QObject* parent)
: QAbstractListModel(parent)
, m_manager()
LocationQueryModel::LocationQueryModel(QObject *parent) : QAbstractListModel(parent), m_manager()
{
connect(this, &LocationQueryModel::queryChanged, this, &LocationQueryModel::triggerQuery);
}
......@@ -43,27 +41,22 @@ void LocationQueryModel::triggerQuery()
m_locations = reply->result();
endResetModel();
});
}
QVariant LocationQueryModel::data(const QModelIndex& index, int role) const
QVariant LocationQueryModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid()
|| index.row() < 0
|| index.row() >= rowCount())
{
if (!index.isValid() || index.row() < 0 || index.row() >= rowCount()) {
return QVariant();
}
switch (role) {
case NameRole:
return m_locations[index.row()].name();
case ObjectRole:
return QVariant::fromValue(m_locations[index.row()]);
default:
return QVariant(QStringLiteral("deadbeef"));
case NameRole:
return m_locations[index.row()].name();
case ObjectRole:
return QVariant::fromValue(m_locations[index.row()]);
default:
return QVariant(QStringLiteral("deadbeef"));
}
}
QString LocationQueryModel::query() const
......@@ -71,7 +64,7 @@ QString LocationQueryModel::query() const
return m_query;
}
int LocationQueryModel::rowCount(const QModelIndex& parent) const
int LocationQueryModel::rowCount(const QModelIndex &parent) const
{
return m_locations.size();
}
......
......@@ -33,12 +33,9 @@ class LocationQueryModel : public QAbstractListModel
Q_PROPERTY(QString query READ query WRITE setQuery NOTIFY queryChanged)
public:
enum Roles {
NameRole = Qt::DisplayRole,
ObjectRole = Qt::UserRole + 1
};
enum Roles { NameRole = Qt::DisplayRole, ObjectRole = Qt::UserRole + 1 };
explicit LocationQueryModel(QObject *parent=nullptr);
explicit LocationQueryModel(QObject *parent = nullptr);
QVariant data(const QModelIndex &index, int role) const override;
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
......
......@@ -26,12 +26,8 @@
#include <QJsonDocument>
#include <QJsonObject>
QueryController::QueryController(QObject* parent)
: QObject(parent)
, m_start()
, m_destination()
, m_locationCacheFile(QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + QStringLiteral("/locations.cache"))
, m_cachedLocationsJson()
QueryController::QueryController(QObject *parent)
: QObject(parent), m_start(), m_destination(), 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();
......@@ -73,7 +69,7 @@ KPublicTransport::JourneyRequest QueryController::createJourneyRequest()
QDateTime depTime = QDateTime::fromString(m_departureDate + QStringLiteral("T") + m_departureTime, Qt::ISODate);
req.setDepartureTime(depTime);
qDebug() << depTime << m_departureDate + QStringLiteral("T") + m_departureTime;
qDebug() << depTime << m_departureDate + QStringLiteral("T") + m_departureTime;
return req;
}
......@@ -83,7 +79,7 @@ QString QueryController::departureDate() const
return m_departureDate;
}
void QueryController::setDepartureDate(const QString& date)
void QueryController::setDepartureDate(const QString &date)
{
if (m_departureDate != date) {
m_departureDate = date;
......@@ -96,7 +92,7 @@ QString QueryController::departureTime() const
return m_departureTime;
}
void QueryController::setDepartureTime(const QString& time)
void QueryController::setDepartureTime(const QString &time)
{
if (m_departureTime != time) {
m_departureTime = time;
......@@ -109,7 +105,7 @@ QVariantList QueryController::cachedLocations() const
return m_cachedLocations;
}
void QueryController::setCachedLocations(const QVariantList& locations)
void QueryController::setCachedLocations(const QVariantList &locations)
{
if (locations != m_cachedLocations) {
m_cachedLocations = locations;
......@@ -137,7 +133,7 @@ void QueryController::loadLocationsFromCache()
{
m_cachedLocationsJson = QJsonDocument::fromJson(m_locationCacheFile.readAll()).array();
for (const QJsonValue& val : qAsConst(m_cachedLocationsJson)) {
for (const QJsonValue &val : qAsConst(m_cachedLocationsJson)) {
m_cachedLocations.append(QVariant::fromValue(KPublicTransport::Location::fromJson(val.toObject())));
}
}
......@@ -27,7 +27,8 @@
#include <KPublicTransport/Location>
#include <KPublicTransport/JourneyRequest>
class QueryController : public QObject {
class QueryController : public QObject
{
Q_OBJECT
Q_PROPERTY(KPublicTransport::Location start READ start WRITE setStart NOTIFY startChanged)
......@@ -37,7 +38,7 @@ class QueryController : public QObject {
Q_PROPERTY(QVariantList cachedLocations READ cachedLocations WRITE setCachedLocations NOTIFY cachedLocationsChanged)
public:
explicit QueryController(QObject *parent=nullptr);
explicit QueryController(QObject *parent = nullptr);
KPublicTransport::Location start() const;
void setStart(const KPublicTransport::Location start);
......@@ -46,13 +47,13 @@ public:
void setDestination(const KPublicTransport::Location destination);
QString departureDate() const;
void setDepartureDate(const QString& date);
void setDepartureDate(const QString &date);
QString departureTime() const;
void setDepartureTime(const QString& time);
void setDepartureTime(const QString &time);
QVariantList cachedLocations() const;
void setCachedLocations(const QVariantList& locations);
void setCachedLocations(const QVariantList &locations);
Q_INVOKABLE void addCachedLocation(const KPublicTransport::Location location);
Q_INVOKABLE KPublicTransport::JourneyRequest createJourneyRequest();
......
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