Added engine to master
authorKaj Wallin <kaj.wallin@ixonos.com>
Thu, 29 Apr 2010 13:03:02 +0000 (16:03 +0300)
committerKaj Wallin <kaj.wallin@ixonos.com>
Thu, 29 Apr 2010 13:03:02 +0000 (16:03 +0300)
Reviewed by: Marko Niemelä

Merge branch 'engine'

Conflicts:
src/engine/engine.cpp

18 files changed:
doc/test_cases/functionality-tests.doc
src/engine/engine.cpp
src/engine/engine.h
src/situareservice/imagefetcher.cpp
src/situareservice/imagefetcher.h
src/situareservice/situareservice.cpp
src/situareservice/situareservice.h
src/src.pro
src/ui/mainwindow.cpp
src/ui/mainwindow.h
src/ui/settingsdialog.cpp [new file with mode: 0644]
src/ui/settingsdialog.h [new file with mode: 0644]
src/ui/updatelocation/texteditautoresizer.cpp
src/ui/updatelocation/texteditautoresizer.h
src/ui/updatelocation/updatelocationdialog.cpp
src/ui/updatelocation/updatelocationdialog.h
src/user/user.cpp
src/user/user.h

index 55198eb..514a743 100644 (file)
Binary files a/doc/test_cases/functionality-tests.doc and b/doc/test_cases/functionality-tests.doc differ
index eb04d92..a1b29be 100644 (file)
 SituareEngine::SituareEngine(QMainWindow *parent)
     : QObject(parent)
 {
+    qDebug() << __PRETTY_FUNCTION__;
     m_ui = new MainWindow;
 
-    m_networkManager = new QNetworkAccessManager;
-    m_situareService = new SituareService(this, m_networkManager);
+    m_situareService = new SituareService(this);
 
     m_facebookAuthenticator = new FacebookAuthentication();
 
@@ -39,8 +39,10 @@ SituareEngine::SituareEngine(QMainWindow *parent)
             this, SLOT(loginOk()));
 
     connect(m_ui, SIGNAL(requestReverseGeo()), this, SLOT(requestAddress()));
-    connect(m_situareService, SIGNAL(reverseGeoReady(QString)), m_ui, SIGNAL(reverseGeoReady(QString)));
-    connect(m_ui, SIGNAL(statusUpdate(QString,bool)), this, SLOT(requestUpdateLocation(QString,bool)));
+    connect(m_situareService, SIGNAL(reverseGeoReady(QString)),
+            m_ui, SIGNAL(reverseGeoReady(QString)));
+    connect(m_ui, SIGNAL(statusUpdate(QString,bool)),
+            this, SLOT(requestUpdateLocation(QString,bool)));
 
     m_facebookAuthenticator->start();
 }
@@ -67,7 +69,7 @@ void SituareEngine::requestAddress()
     m_situareService->reverseGeo(coordinates);
 }
 
-void SituareEngine::requestUpdateLocation(const QString &status, const bool &publish)
+void SituareEngine::requestUpdateLocation(const QString &status, bool publish)
 {
     qDebug() << __PRETTY_FUNCTION__;
     QPointF coordinates(65, 25.5); // this will be get from somewhere, map etc...
index 0adfa05..3e4a717 100644 (file)
@@ -28,8 +28,7 @@
 #include <QtDebug>
 #include "facebookservice/facebookauthentication.h"
 #include "situareservice/situareservice.h"
-#include <QNetworkAccessManager>
-#include "../ui/mainwindow.h"
+#include "ui/mainwindow.h"
 
 /**
 * @brief Engine class for Situare Application
@@ -77,7 +76,7 @@ public slots:
     * @param status Status message
     * @param publish Publish on Facebook
     */
-    void requestUpdateLocation(const QString &status, const bool &publish);
+    void requestUpdateLocation(const QString &status, bool publish);
 
     /**
     * @brief Slot to initiate update friends list function
@@ -90,7 +89,6 @@ public slots:
 private:
     MainWindow *m_ui; ///< Instance of the MainWindow UI
     FacebookAuthentication *m_facebookAuthenticator; ///< Instance for facebook authenticator
-    QNetworkAccessManager *m_networkManager; ///< NetworkManager that is passed on to SituareService
     SituareService *m_situareService; ///< Instance of the situare server communication service
 };
 
index 25d26c2..d6f2f79 100644 (file)
@@ -29,6 +29,8 @@ ImageFetcher::ImageFetcher(QNetworkAccessManager *manager, QObject *parent)
     : QObject(parent)
     , m_manager(manager)
 {
+    qDebug() << __PRETTY_FUNCTION__;
+
     connect(m_manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(
             downloadFinished(QNetworkReply*)));
 }
@@ -37,25 +39,15 @@ void ImageFetcher::fetchImage(const QUrl &url)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    if (url.isEmpty() || !url.isValid())
-        return;
-
-    if (m_downloadQueue.size() >= DOWNLOAD_QUEUE_SIZE)
-        m_downloadQueue.dequeue();
-
     m_downloadQueue.enqueue(url);
 
-    if (m_currentDownloads.size() < MAX_PARALLEL_DOWNLOADS)
-        startNextDownload();
+    startNextDownload();
 }
 
 void ImageFetcher::startNextDownload()
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    if (m_downloadQueue.isEmpty())
-        return;
-
     QUrl url = m_downloadQueue.dequeue();
 
     QNetworkRequest request(url);
@@ -70,13 +62,13 @@ void ImageFetcher::downloadFinished(QNetworkReply *reply)
     qDebug() << __PRETTY_FUNCTION__;
 
     if (reply->error() == QNetworkReply::NoError) {
-        QImage image;
+        QPixmap image;
         QUrl url = reply->url();
 
-        if (!image.load(reply, 0))
-            image = QImage();
+        if (!image.loadFromData(reply->readAll(), 0))
+            image = QPixmap();
 
-        emit imageReceived(url, QPixmap::fromImage(image));
+        emit imageReceived(url, image);
     }
     else {
         emit error(reply->errorString());
@@ -84,5 +76,7 @@ void ImageFetcher::downloadFinished(QNetworkReply *reply)
 
     m_currentDownloads.removeAll(reply);
     reply->deleteLater();
-    startNextDownload();
+
+    if (!m_downloadQueue.isEmpty())
+        startNextDownload();
 }
index 274d366..08087ab 100644 (file)
@@ -23,8 +23,8 @@
 #define IMAGEFETCHER_H
 
 #include <QtCore>
-#include <QNetworkAccessManager>
 
+class QNetworkAccessManager;
 class QNetworkReply;
 class QUrl;
 
@@ -101,13 +101,10 @@ signals:
  * DATA MEMBERS
  ******************************************************************************/
 private:
-    static const int MAX_PARALLEL_DOWNLOADS = 2; ///< Max simultaneous parallel downloads
-    static const int DOWNLOAD_QUEUE_SIZE = 50; ///< Max downloads waiting in queue
 
     QList<QNetworkReply*> m_currentDownloads; ///< List of current downloads
     QQueue<QUrl> m_downloadQueue;             ///< Queue of pending requests
     QNetworkAccessManager *m_manager;       ///< Network access manager
-
 };
 
 #endif // IMAGEFETCHER_H
index f937e0b..9ad50dc 100644 (file)
@@ -19,6 +19,7 @@
    USA.
 */
 
+#include <QtAlgorithms>
 #include <QDebug>
 #include <QtGlobal>
 #include <QStringList>
 #include "../cookiehandler/cookiehandler.h"
 #include "parser.h"
 
-SituareService::SituareService(QObject *parent, QNetworkAccessManager *manager)
-        : QObject(parent), m_networkManager(manager)
+SituareService::SituareService(QObject *parent)
+        : QObject(parent)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
+    m_networkManager = new QNetworkAccessManager;
     connect(m_networkManager, SIGNAL(finished(QNetworkReply*)), SLOT(requestFinished(QNetworkReply*)));
 
     m_imageFetcher = new ImageFetcher(new QNetworkAccessManager(this), this);
@@ -41,6 +43,7 @@ SituareService::SituareService(QObject *parent, QNetworkAccessManager *manager)
     connect(m_imageFetcher, SIGNAL(imageReceived(QUrl,QPixmap)), this,
             SLOT(imageReceived(QUrl, QPixmap)));
 
+    m_user = 0;
 }
 
 SituareService::~SituareService()
@@ -48,9 +51,16 @@ SituareService::~SituareService()
     qDebug() << __PRETTY_FUNCTION__;
 
     delete m_networkManager;
+    m_networkManager = 0;
     if(m_user) {
         delete m_user;
+        m_user = 0;
     }
+    delete m_imageFetcher;
+    m_imageFetcher = 0;
+
+    qDeleteAll(m_friendsList.begin(), m_friendsList.end());
+    m_friendsList.clear();
 }
 
 void SituareService::fetchLocations()
@@ -64,7 +74,6 @@ void SituareService::fetchLocations()
                                               m_credentials.sig(), EN_LOCALE);
 
     QUrl url = formUrl(SITUARE_URL, GET_LOCATIONS);
-
     sendRequest(url, COOKIE, cookie);
 }
 
@@ -77,7 +86,6 @@ void SituareService::reverseGeo(const QPointF &coordinates)
     QString cookie = cookieHandler.formCookie(API_KEY, m_credentials.expires(), m_credentials.userID(),
                                               m_credentials.sessionKey(), m_credentials.sessionSecret(),
                                               m_credentials.sig(), EN_LOCALE);
-
     QString urlParameters = formUrlParameters(coordinates);
     QUrl url = formUrl(SITUARE_URL, REVERSE_GEO, urlParameters);
 
@@ -116,7 +124,7 @@ QUrl SituareService::formUrl(const QString &baseUrl, const QString &phpScript, Q
 
     urlString.append(baseUrl);
     urlString.append(phpScript);
-    if(urlParameters != NULL)
+    if(!urlParameters.isEmpty())
         urlString.append(urlParameters);
 
     QUrl url = QUrl(urlString);
@@ -152,7 +160,7 @@ QString SituareService::formUrlParameters(const QPointF &coordinates, QString st
         parameters.append(PUBLISH_FALSE);
     }
 
-    if(status != NULL) {
+    if(!status.isEmpty()) {
         parameters.append(AMBERSAND_MARK);
         parameters.append(DATA);
         parameters.append(EQUAL_MARK);
@@ -239,6 +247,7 @@ void SituareService::parseUserData(const QByteArray &jsonReply)
 
     m_visited = 0;
     m_nbrOfImages = 0;
+    qDeleteAll(m_friendsList.begin(), m_friendsList.end());
     m_friendsList.clear();
 
     QJson::Parser parser;
@@ -308,12 +317,12 @@ void SituareService::addProfileImages()
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    if(m_user->profileImageUrl() != QUrl("")) {
+    if(!m_user->profileImageUrl().isEmpty() && m_user->profileImageUrl().isValid()) {
         emit fetchImage(m_user->profileImageUrl());
     }
 
     for(int i=0;i<m_friendsList.count();i++) {
-        if(m_friendsList.at(i)->profileImageUrl() != QUrl("")) {
+        if(!m_friendsList.at(i)->profileImageUrl().isEmpty() && m_user->profileImageUrl().isValid()) {
             m_visited++; // indicates how many friends that have profile image
             emit fetchImage(m_friendsList.at(i)->profileImageUrl());
         }
index 626ac97..0906b78 100644 (file)
@@ -52,7 +52,7 @@ public:
     * @param parent instance of parent
     * @param manager instance of QNetworkAccessManager
     */
-    SituareService(QObject *parent = 0, QNetworkAccessManager *manager = 0);
+    SituareService(QObject *parent = 0);
 
     /**
     * @brief Destructor
@@ -63,7 +63,6 @@ public:
 /*******************************************************************************
  * MEMBER FUNCTIONS AND SLOTS
  ******************************************************************************/
-
     /**
     * @brief Retrieves location user and friends information from Situare server
     *
index 8f6aad6..78b2559 100644 (file)
@@ -25,7 +25,8 @@ SOURCES += main.cpp \
     ui/updatelocation/updatelocationdialog.cpp \
     ui/updatelocation/texteditautoresizer.cpp \
     engine/engine.cpp \
-    user/user.cpp
+    user/user.cpp \
+    ui/settingsdialog.cpp
 HEADERS += ui/mainwindow.h \
     ui/mapviewscreen.h \
     ui/listviewscreen.h \
@@ -47,7 +48,8 @@ HEADERS += ui/mainwindow.h \
     facebookservice/facebookauthentication.h \
     facebookservice/facebookcommon.h \
     engine/engine.h \
-    user/user.h
+    user/user.h \
+    ui/settingsdialog.h
 QT += network \
     webkit
 
@@ -57,17 +59,14 @@ QT += network \
     message(OpenGL built in)
     message(Make sure you have OpenGL development headers installed)
     message(install headers with: sudo apt-get install libgl-dev libglu-dev)
-
     message(QJson built in)
     message(Make sure you have QJson development headers installed)
     message(install headers with: sudo apt-get install libqjson-dev)
 }
-
-maemo5 {
+maemo5 { 
     message(QJson built in)
     message(Make sure you have QJson development headers installed)
     message(add: deb http://repository.maemo.org/extras-devel fremantle free non-free)
-    message(and deb-src http://repository.maemo.org/extras-devel fremantle free non-free)
     message(to scratchbox's sources.list in /etc/apt)
     message(run: apt-get update)
     message(install headers with: apt-get install libqjson-dev)
index 035ba02..c67b106 100644 (file)
@@ -24,6 +24,7 @@
 #include "mainwindow.h"
 #include "listviewscreen.h"
 #include "mapviewscreen.h"
+#include "settingsdialog.h"
 #include "facebookservice/facebookauthentication.h"
 #include "situareservice/situareservice.h"
 
@@ -52,6 +53,7 @@ MainWindow::~MainWindow()
     qDebug() << __PRETTY_FUNCTION__;
     delete m_toListViewAct;
     delete m_toMapViewAct;
+    delete m_toSettingsAct;
     delete m_situareViews;
 }
 
@@ -64,9 +66,13 @@ void MainWindow::createMenus()
     m_toMapViewAct = new QAction(tr("Map"), this);
     m_toMapViewAct->setObjectName(tr("Map"));
     connect(m_toMapViewAct, SIGNAL(triggered()), this, SLOT(toMapView()));
+    m_toSettingsAct = new QAction(tr("Settings"), this);
+    m_toSettingsAct->setObjectName(tr("Settings"));
+    connect(m_toSettingsAct, SIGNAL(triggered()), this, SLOT(openSettingsDialog()));
     m_viewMenu = menuBar()->addMenu(tr("View"));
     m_viewMenu->addAction(m_toListViewAct);
     m_viewMenu->addAction(m_toMapViewAct);
+    m_viewMenu->addAction(m_toSettingsAct);
     m_viewMenu->setObjectName(tr("View Menu"));
 }
 
@@ -113,6 +119,7 @@ void MainWindow::switchView(int nextIndex)
             break;
     }
 }
+
 void MainWindow::openLocationUpdateDialog()
 {
     qDebug() << __PRETTY_FUNCTION__;
@@ -120,3 +127,12 @@ void MainWindow::openLocationUpdateDialog()
     emit requestReverseGeo();
     m_locationDialog->exec();
 }
+
+void MainWindow::openSettingsDialog()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+    SettingsDialog *dialog = new SettingsDialog(this);
+    dialog->show();
+}
+
+
index ff0a93f..b321c9d 100644 (file)
@@ -66,6 +66,11 @@ public:
  ******************************************************************************/
 public slots:
     /**
+    * @brief Public slot, which open settings dialog
+    */
+     void openSettingsDialog();
+
+    /**
     * @brief Public slot, which initiates toListViewAct action to switch view
     */
     void toListView();
@@ -138,6 +143,7 @@ private:
     QStackedWidget *m_situareViews; ///< Stacked widget that hold both view widgets
     QAction *m_toListViewAct; ///< Action to trigger switch to list view
     QAction *m_toMapViewAct; ///< Action to trigger switch to map view
+    QAction *m_toSettingsAct; ///< Action to trigger switch to settings dialog
     QMenu *m_viewMenu; ///< Object that hold the view menu items
 };
 
diff --git a/src/ui/settingsdialog.cpp b/src/ui/settingsdialog.cpp
new file mode 100644 (file)
index 0000000..48e3333
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+   Situare - A location system for Facebook
+   Copyright (C) 2010  Ixonos Plc. Authors:
+
+      Katri Kaikkonen - katri.kaikkonen@ixonos.com
+
+   Situare is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License
+   version 2 as published by the Free Software Foundation.
+
+   Situare is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with Situare; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
+   USA.
+*/
+
+#include <QtGui>
+#include <QDebug>
+#include "facebookservice/facebookcommon.h"
+#include "settingsdialog.h"
+
+const QString AUTOMATIC_LOCATION_UPDATE("Automatic_location_update");
+
+SettingsDialog::SettingsDialog(QWidget *parent)
+    : QDialog(parent)
+{
+    qDebug() << __PRETTY_FUNCTION__;
+    setWindowTitle(tr("Settings"));
+
+    QScrollArea *scrollArea = new QScrollArea(this);
+    QGridLayout *gridLayout = new QGridLayout(this);
+    QGroupBox *groupBox = new QGroupBox(scrollArea);
+    QSettings settings(DIRECTORY_NAME, FILE_NAME);
+
+    m_automaticLocationUpdate = new QCheckBox(tr("Use automatic location update"));
+    m_automaticLocationUpdate->setChecked(settings.value(AUTOMATIC_LOCATION_UPDATE).toBool());
+
+    QDialogButtonBox *buttonBox = new QDialogButtonBox(Qt::Vertical);
+    QPushButton *saveButton = buttonBox->addButton(QDialogButtonBox::Save);
+    QPushButton *cancelButton = buttonBox->addButton(QDialogButtonBox::Cancel);
+    connect(saveButton, SIGNAL(clicked()), this, SLOT(saveValues()));
+    connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
+
+    connect(this, SIGNAL(finished(int)), this, SLOT(dialogFinished(int)));
+
+    QFormLayout *form = new QFormLayout();
+    form->addWidget(m_automaticLocationUpdate);
+
+    groupBox->setLayout(form);
+    scrollArea->setWidget(groupBox);
+    scrollArea->setWidgetResizable(true);
+    gridLayout->addWidget(scrollArea, 0, 0, 2, 1);
+    gridLayout->addWidget(buttonBox, 0, 1, 1, 1);
+    setLayout(gridLayout);
+
+    scrollArea->show();
+}
+
+SettingsDialog::~SettingsDialog()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+    delete m_automaticLocationUpdate;
+}
+
+void SettingsDialog::dialogFinished(int /* reason */)
+{
+    qDebug() << __PRETTY_FUNCTION__;
+    deleteLater();
+}
+
+void SettingsDialog::saveValues()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+    QSettings settings(DIRECTORY_NAME, FILE_NAME);
+    settings.setValue(AUTOMATIC_LOCATION_UPDATE, m_automaticLocationUpdate->isChecked());
+    accept();
+
+}
diff --git a/src/ui/settingsdialog.h b/src/ui/settingsdialog.h
new file mode 100644 (file)
index 0000000..a4681e9
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+   Situare - A location system for Facebook
+   Copyright (C) 2010  Ixonos Plc. Authors:
+
+      Katri Kaikkonen - katri.kaikkonen@ixonos.com
+
+   Situare is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License
+   version 2 as published by the Free Software Foundation.
+
+   Situare is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with Situare; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
+   USA.
+*/
+
+#ifndef SETTINGSDIALOG_H
+#define SETTINGSDIALOG_H
+
+#include <QDialog>
+
+class QCheckBox;
+
+/**
+* @brief Settings Dialog NOTE: dialog deletes itself after saving or closing settings
+*
+* @class SettingsDialog settingsdialog.h "ui/settingsdialog.h"
+*/
+class SettingsDialog : public QDialog
+ {
+    Q_OBJECT
+
+public:
+    /**
+    * @brief Default constructor
+    *
+    * @param parent Parent
+    */
+    SettingsDialog(QWidget *parent = 0);
+
+    /**
+    * @brief Destructor
+    */
+    ~SettingsDialog();
+
+/*******************************************************************************
+* MEMBER FUNCTIONS AND SLOTS
+******************************************************************************/
+private slots:
+    /**
+    * @brief is called when dialog is closed
+    *
+    * @param reason why dialog was closed
+    */
+    void dialogFinished(int reason);
+
+    /**
+    * @brief Saves settings to file
+    */
+    void saveValues();
+
+/*******************************************************************************
+ * DATA MEMBERS
+ ******************************************************************************/
+private:
+    QCheckBox *m_automaticLocationUpdate; ///< Pointer to CheckBox
+};
+
+#endif // SETTINGSDIALOG_H
index dabf73a..8852d71 100755 (executable)
@@ -37,6 +37,7 @@ TextEditAutoResizer::TextEditAutoResizer(QWidget *parent)
 
 void TextEditAutoResizer::textEditChanged()
 {
+    qDebug() << __PRETTY_FUNCTION__;
     QTextDocument *document = m_textEdit ? m_textEdit->document() : m_plainTextEdit->document();
     QRect cursor = m_textEdit ? m_textEdit->cursorRect() : m_plainTextEdit->cursorRect();
 
index 64c4af6..47d9dd2 100755 (executable)
@@ -45,6 +45,9 @@ public:
     */
     TextEditAutoResizer(QWidget *parent = 0);
 
+/*******************************************************************************
+ * MEMBER FUNCTIONS AND SLOTS
+ ******************************************************************************/
 private slots:
     /**
     * @brief Private slot which indicate when textEdit has been changed
@@ -52,7 +55,9 @@ private slots:
     * @fn textEditChanged
     */
     void textEditChanged();
-
+/*******************************************************************************
+ * DATA MEMBERS
+ ******************************************************************************/
 private:
     QFrame *m_edit; ///< Pointer to Frame
     QPlainTextEdit *m_plainTextEdit; ///< Pointer to PlainTextEdit
index 42363a2..a7faf15 100755 (executable)
@@ -26,6 +26,7 @@
 UpdateLocationDialog::UpdateLocationDialog(QWidget *parent)
     : QDialog(parent)
 {
+    qDebug() << __PRETTY_FUNCTION__;
     setWindowTitle(tr("Update Location"));
 
     QScrollArea *scrollArea = new QScrollArea(this);
index 9ebbd29..820bd1c 100755 (executable)
@@ -34,9 +34,9 @@ class QDialogButtonBox;
 class QGroupBox;
 class QLabel;
 class QLineEdit;
-class QTextEdit;
 class QPushButton;
 class QScrollArea;
+class QTextEdit;
 
 /**
 * @brief Update Location UI
index 3a7b1b8..9c8ca08 100644 (file)
@@ -21,8 +21,9 @@
 
 #include "user.h"
 
-User::User(QString address, QPointF coordinates, QString name, QString note, QUrl imageUrl,
-           QString timestamp, bool type, QString userId, QString units, double value)
+User::User(const QString &address, const QPointF &coordinates, const QString &name,
+           const QString &note, const QUrl &imageUrl, const QString &timestamp, const bool &type,
+           const QString &userId, const QString &units, const double &value)
                : m_address(address)
                , m_coordinates(coordinates)
                , m_name(name)
@@ -37,6 +38,21 @@ User::User(QString address, QPointF coordinates, QString name, QString note, QUr
 
 }
 
+User::User()
+    : m_address()
+    , m_coordinates()
+    , m_name()
+    , m_note()
+    , m_profileImageUrl()
+    , m_timestamp()
+    , m_type()
+    , m_units()
+    , m_userId()
+    , m_value()
+{
+
+}
+
 void User::setAddress(const QString &address)
 {
     m_address = address;
@@ -73,12 +89,12 @@ void User::setTimestamp(const QString &timestamp)
     m_timestamp = timestamp;
 }
 
-QString User::address() const
+const QString& User::address() const
 {
     return m_address;
 }
 
-QPointF User::coordinates() const
+const QPointF& User::coordinates() const
 {
     return m_coordinates;
 }
@@ -89,37 +105,37 @@ void User::distance(double &value, QString &units) const
     units = m_units;
 }
 
-QString User::name() const
+const QString& User::name() const
 {
     return m_name;
 }
 
-QString User::note() const
+const QString& User::note() const
 {
     return m_note;
 }
 
-QPixmap User::profileImage() const
+const QPixmap& User::profileImage() const
 {
     return m_profileImage;
 }
 
-QUrl User::profileImageUrl() const
+const QUrl& User::profileImageUrl() const
 {
     return m_profileImageUrl;
 }
 
-QString User::timestamp() const
+const QString& User::timestamp() const
 {
     return m_timestamp;
 }
 
-bool User::type() const
+const bool& User::type() const
 {
     return m_type;
 }
 
-QString User::userId() const
+const QString& User::userId() const
 {
     return m_userId;
 }
index 9992329..4c853c0 100644 (file)
@@ -38,12 +38,18 @@ class User
 public:
 
     /**
-    * @brief Default constructor, initializes member data
+    * @brief Constructor, initializes member data
     *
     */
-    User(const QString address, const QPointF coordinates, const QString name, const QString note,
-         const QUrl imageUrl, const QString timestamp, const bool type, const QString userId,
-         const QString units = 0, const double value = 0);
+    User(const QString &address, const QPointF &coordinates, const QString &name,
+         const QString &note, const QUrl &imageUrl, const QString &timestamp, const bool &type,
+         const QString &userId, const QString &units = 0, const double &value = 0);
+
+    /**
+    * @brief Default constructor, initializes member data as NULL/0
+    *
+    */
+    User();
 
     /*******************************************************************************
      * MEMBER FUNCTIONS AND SLOTS
@@ -104,14 +110,14 @@ public:
     *
     * @return QString address
     */
-    QString address() const;
+    const QString &address() const;
 
     /**
     * @brief Get coordinates
     *
     * @return QPointF coordinates
     */
-    QPointF coordinates() const;
+    const QPointF &coordinates() const;
 
     /**
     * @brief Get distance and units
@@ -126,49 +132,49 @@ public:
     *
     * @return QString profile name
     */
-    QString name() const;
+    const QString &name() const;
 
     /**
     * @brief Get note/status message
     *
     * @return QString note
     */
-    QString note() const;
+    const QString &note() const;
 
     /**
     * @brief Get profile image
     *
     * @return QPixmap image
     */
-    QPixmap profileImage() const;
+    const QPixmap &profileImage() const;
 
     /**
     * @brief Get download address for profile image
     *
     * @return QString url
     */
-    QUrl profileImageUrl() const;
+    const QUrl &profileImageUrl() const;
 
     /**
     * @brief Get timestamp of last status update
     *
     * @return QString timestamp
     */
-    QString timestamp() const;
+    const QString &timestamp() const;
 
     /**
     * @brief Get user type
     *
     * @return bool user type (true = user, false = friend)
     */
-    bool type() const;
+    const bool &type() const;
 
     /**
     * @brief Get userId
     *
     * @return QString userId
     */
-    QString userId() const;
+    const QString &userId() const;
 
     /*******************************************************************************
      * DATA MEMBERS
@@ -186,7 +192,7 @@ private:
     QString m_userId; ///< placeholder for userId
     double m_value; ///< placeholder for distance value
 
-    QPixmap m_profileImage; ///< placehokder for image
+    QPixmap m_profileImage; ///< placeholder for image
 };