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();
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();
}
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...
#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
* @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
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
};
: QObject(parent)
, m_manager(manager)
{
+ qDebug() << __PRETTY_FUNCTION__;
+
connect(m_manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(
downloadFinished(QNetworkReply*)));
}
{
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);
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());
m_currentDownloads.removeAll(reply);
reply->deleteLater();
- startNextDownload();
+
+ if (!m_downloadQueue.isEmpty())
+ startNextDownload();
}
#define IMAGEFETCHER_H
#include <QtCore>
-#include <QNetworkAccessManager>
+class QNetworkAccessManager;
class QNetworkReply;
class QUrl;
* 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
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);
connect(m_imageFetcher, SIGNAL(imageReceived(QUrl,QPixmap)), this,
SLOT(imageReceived(QUrl, QPixmap)));
+ m_user = 0;
}
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()
m_credentials.sig(), EN_LOCALE);
QUrl url = formUrl(SITUARE_URL, GET_LOCATIONS);
-
sendRequest(url, COOKIE, cookie);
}
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);
urlString.append(baseUrl);
urlString.append(phpScript);
- if(urlParameters != NULL)
+ if(!urlParameters.isEmpty())
urlString.append(urlParameters);
QUrl url = QUrl(urlString);
parameters.append(PUBLISH_FALSE);
}
- if(status != NULL) {
+ if(!status.isEmpty()) {
parameters.append(AMBERSAND_MARK);
parameters.append(DATA);
parameters.append(EQUAL_MARK);
m_visited = 0;
m_nbrOfImages = 0;
+ qDeleteAll(m_friendsList.begin(), m_friendsList.end());
m_friendsList.clear();
QJson::Parser parser;
{
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());
}
* @param parent instance of parent
* @param manager instance of QNetworkAccessManager
*/
- SituareService(QObject *parent = 0, QNetworkAccessManager *manager = 0);
+ SituareService(QObject *parent = 0);
/**
* @brief Destructor
/*******************************************************************************
* MEMBER FUNCTIONS AND SLOTS
******************************************************************************/
-
/**
* @brief Retrieves location user and friends information from Situare server
*
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 \
facebookservice/facebookauthentication.h \
facebookservice/facebookcommon.h \
engine/engine.h \
- user/user.h
+ user/user.h \
+ ui/settingsdialog.h
QT += network \
webkit
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)
#include "mainwindow.h"
#include "listviewscreen.h"
#include "mapviewscreen.h"
+#include "settingsdialog.h"
#include "facebookservice/facebookauthentication.h"
#include "situareservice/situareservice.h"
qDebug() << __PRETTY_FUNCTION__;
delete m_toListViewAct;
delete m_toMapViewAct;
+ delete m_toSettingsAct;
delete m_situareViews;
}
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"));
}
break;
}
}
+
void MainWindow::openLocationUpdateDialog()
{
qDebug() << __PRETTY_FUNCTION__;
emit requestReverseGeo();
m_locationDialog->exec();
}
+
+void MainWindow::openSettingsDialog()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+ SettingsDialog *dialog = new SettingsDialog(this);
+ dialog->show();
+}
+
+
******************************************************************************/
public slots:
/**
+ * @brief Public slot, which open settings dialog
+ */
+ void openSettingsDialog();
+
+ /**
* @brief Public slot, which initiates toListViewAct action to switch view
*/
void toListView();
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
};
--- /dev/null
+/*
+ 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();
+
+}
--- /dev/null
+/*
+ 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
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();
*/
TextEditAutoResizer(QWidget *parent = 0);
+/*******************************************************************************
+ * MEMBER FUNCTIONS AND SLOTS
+ ******************************************************************************/
private slots:
/**
* @brief Private slot which indicate when textEdit has been changed
* @fn textEditChanged
*/
void textEditChanged();
-
+/*******************************************************************************
+ * DATA MEMBERS
+ ******************************************************************************/
private:
QFrame *m_edit; ///< Pointer to Frame
QPlainTextEdit *m_plainTextEdit; ///< Pointer to PlainTextEdit
UpdateLocationDialog::UpdateLocationDialog(QWidget *parent)
: QDialog(parent)
{
+ qDebug() << __PRETTY_FUNCTION__;
setWindowTitle(tr("Update Location"));
QScrollArea *scrollArea = new QScrollArea(this);
class QGroupBox;
class QLabel;
class QLineEdit;
-class QTextEdit;
class QPushButton;
class QScrollArea;
+class QTextEdit;
/**
* @brief Update Location UI
#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 ¬e, const QUrl &imageUrl, const QString ×tamp, const bool &type,
+ const QString &userId, const QString &units, const double &value)
: m_address(address)
, m_coordinates(coordinates)
, m_name(name)
}
+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;
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;
}
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;
}
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 ¬e, const QUrl &imageUrl, const QString ×tamp, 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
*
* @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
*
* @return QString profile name
*/
- QString name() const;
+ const QString &name() const;
/**
* @brief Get note/status message
*
* @return QString note
*/
- QString note() const;
+ const QString ¬e() 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 ×tamp() 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
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
};