From da1cb4c354e0c5f4f1b75079f82c0461413c176d Mon Sep 17 00:00:00 2001 From: Albert Vaca Date: Tue, 20 Jan 2015 22:22:14 -0800 Subject: [PATCH] Coding style --- core/filetransferjob.cpp | 37 +++++++++---------- core/filetransferjob.h | 7 ++-- interfaces/devicesmodel.h | 6 +-- interfaces/notificationsmodel.cpp | 8 ++-- interfaces/notificationsmodel.h | 14 +++---- .../kdeconnectdeclarativeplugin.h | 9 ++--- plugins/notifications/notification.cpp | 1 + 7 files changed, 39 insertions(+), 43 deletions(-) diff --git a/core/filetransferjob.cpp b/core/filetransferjob.cpp index 2dad5deba..070048c0e 100644 --- a/core/filetransferjob.cpp +++ b/core/filetransferjob.cpp @@ -28,18 +28,17 @@ #include "kdebugnamespace.h" -FileTransferJob::FileTransferJob(const QSharedPointer& origin, qint64 size, const KUrl& destination): KJob() +FileTransferJob::FileTransferJob(const QSharedPointer& origin, qint64 size, const KUrl& destination) + : KJob() + , mOrigin(origin) + , mDestinationJob(0) + , mDeviceName("KDE Connect") + , mDestination(destination) + , mSpeedBytes(0) + , mSize(size) + , mWritten(0) { Q_ASSERT(destination.isLocalFile()); - //TODO: Make a precondition before calling this function that destination file exists - mOrigin = origin; - mSize = size; - mWritten = 0; - m_speedBytes = 0; - mDestination = destination; - mDestinationJob = 0; - mDeviceName = i18nc("Device name that will appear on the jobs", "KDE-Connect"); - setCapabilities(Killable); kDebug(debugArea()) << "FileTransferJob Downloading payload to" << destination; } @@ -117,14 +116,14 @@ void FileTransferJob::startTransfer() { setTotalAmount(Bytes, mSize); setProcessedAmount(Bytes, 0); - m_time = QTime::currentTime(); + mTime = QTime::currentTime(); description(this, i18n("Receiving file over KDE-Connect"), QPair(i18nc("File transfer origin", "From"), QString(mDeviceName)), QPair(i18nc("File transfer destination", "To"), mDestination.path())); - QFile(mDestination.path()).open(QIODevice::WriteOnly | QIODevice::Truncate); //HACK: KIO is so dumb it can't create the file if it doesn't exist mDestinationJob = KIO::open(mDestination, QIODevice::WriteOnly); + QFile(mDestination.path()).open(QIODevice::WriteOnly | QIODevice::Truncate); //KIO won't create the file if it doesn't exist connect(mDestinationJob, SIGNAL(open(KIO::Job*)), this, SLOT(open(KIO::Job*))); connect(mDestinationJob, SIGNAL(result(KJob*)), this, SLOT(openFinished(KJob*))); @@ -165,15 +164,15 @@ void FileTransferJob::readyRead() if (mSize > -1) { //If a least 1 second has passed since last update - int secondsSinceLastTime = m_time.secsTo(QTime::currentTime()); - if (secondsSinceLastTime > 0 && m_speedBytes > 0) { - float speed = (mWritten - m_speedBytes) / secondsSinceLastTime; + int secondsSinceLastTime = mTime.secsTo(QTime::currentTime()); + if (secondsSinceLastTime > 0 && mSpeedBytes > 0) { + float speed = (mWritten - mSpeedBytes) / secondsSinceLastTime; emitSpeed(speed); - m_time = QTime::currentTime(); - m_speedBytes = mWritten; - } else if(m_speedBytes == 0) { - m_speedBytes = mWritten; + mTime = QTime::currentTime(); + mSpeedBytes = mWritten; + } else if(mSpeedBytes == 0) { + mSpeedBytes = mWritten; } } diff --git a/core/filetransferjob.h b/core/filetransferjob.h index b022210b6..30ab4c27d 100644 --- a/core/filetransferjob.h +++ b/core/filetransferjob.h @@ -40,7 +40,7 @@ public: FileTransferJob(const QSharedPointer& origin, qint64 size, const KUrl& destination); virtual void start(); KUrl destination() const { return mDestination; } - void setDeviceName(const QString &deviceName) {mDeviceName = deviceName;}; + void setDeviceName(const QString &deviceName) { mDeviceName = deviceName; } public Q_SLOTS: void doStart(); @@ -59,11 +59,10 @@ private: KIO::FileJob* mDestinationJob; QString mDeviceName; KUrl mDestination; - QTime m_time; - qulonglong m_speedBytes; + QTime mTime; + qulonglong mSpeedBytes; qint64 mSize; qint64 mWritten; - }; #endif diff --git a/interfaces/devicesmodel.h b/interfaces/devicesmodel.h index 75ee0c12b..283711e96 100644 --- a/interfaces/devicesmodel.h +++ b/interfaces/devicesmodel.h @@ -40,10 +40,10 @@ class KDECONNECTINTERFACES_EXPORT DevicesModel public: enum ModelRoles { - NameModelRole = Qt::DisplayRole, - IconModelRole = Qt::DecorationRole, + NameModelRole = Qt::DisplayRole, + IconModelRole = Qt::DecorationRole, StatusModelRole = Qt::InitialSortOrderRole, - IdModelRole = Qt::UserRole, + IdModelRole = Qt::UserRole, IconNameRole }; enum StatusFlag { diff --git a/interfaces/notificationsmodel.cpp b/interfaces/notificationsmodel.cpp index a3d7ca2d1..4f6feb4c2 100644 --- a/interfaces/notificationsmodel.cpp +++ b/interfaces/notificationsmodel.cpp @@ -48,9 +48,9 @@ NotificationsModel::NotificationsModel(QObject* parent) //Role names for QML QHash names = roleNames(); - names.insert(DbusInterfaceRole, "dbusInterface"); - names.insert(AppNameModelRole, "appName"); - names.insert(IdModelRole, "notificationId"); + names.insert(DbusInterfaceRole, "dbusInterface"); + names.insert(AppNameModelRole, "appName"); + names.insert(IdModelRole, "notificationId"); names.insert(DismissableModelRole, "dismissable"); setRoleNames(names); @@ -155,7 +155,7 @@ QVariant NotificationsModel::data(const QModelIndex& index, int role) const NotificationDbusInterface* notification = m_notificationList[index.row()]; - //FIXME: This function gets called lots of times, producing lots of dbus calls. Add a cache. + //FIXME: This function gets called lots of times, producing lots of dbus calls. Add a cache? switch (role) { case IconModelRole: return KIcon("device-notifier").pixmap(32, 32); diff --git a/interfaces/notificationsmodel.h b/interfaces/notificationsmodel.h index f9a747973..6825fa6de 100644 --- a/interfaces/notificationsmodel.h +++ b/interfaces/notificationsmodel.h @@ -38,13 +38,13 @@ class KDECONNECTINTERFACES_EXPORT NotificationsModel public: enum ModelRoles { - IconModelRole = Qt::DecorationRole, - NameModelRole = Qt::DisplayRole, - ContentModelRole = Qt::UserRole, - AppNameModelRole = Qt::UserRole + 1, - IdModelRole = Qt::UserRole + 2, - DismissableModelRole = Qt::UserRole + 3, - DbusInterfaceRole = Qt::UserRole + 4 + IconModelRole = Qt::DecorationRole, + NameModelRole = Qt::DisplayRole, + ContentModelRole = Qt::UserRole, + AppNameModelRole = Qt::UserRole + 1, + IdModelRole, + DismissableModelRole, + DbusInterfaceRole, }; NotificationsModel(QObject* parent = 0); diff --git a/plasmoid/declarativeplugin/kdeconnectdeclarativeplugin.h b/plasmoid/declarativeplugin/kdeconnectdeclarativeplugin.h index 6324b7aba..a976d19d7 100644 --- a/plasmoid/declarativeplugin/kdeconnectdeclarativeplugin.h +++ b/plasmoid/declarativeplugin/kdeconnectdeclarativeplugin.h @@ -18,8 +18,8 @@ * along with this program. If not, see . */ -#ifndef ANALITZADECLARATIVEPLUGIN_H -#define ANALITZADECLARATIVEPLUGIN_H +#ifndef KDECONNECTDECLARATIVEPLUGIN_H +#define KDECONNECTDECLARATIVEPLUGIN_H #include @@ -30,7 +30,4 @@ class KdeConnectDeclarativePlugin : public QDeclarativeExtensionPlugin }; - - - -#endif // ANALITZADECLARATIVEPLUGIN_H +#endif diff --git a/plugins/notifications/notification.cpp b/plugins/notifications/notification.cpp index 3c15d47dc..319d26739 100644 --- a/plugins/notifications/notification.cpp +++ b/plugins/notifications/notification.cpp @@ -45,3 +45,4 @@ void Notification::dismiss() Q_EMIT dismissRequested(this); } } +