// QSettings common values
const QString SETTINGS_AUTOMATIC_UPDATE_ENABLED = "SETTINGS_AUTOMATIC_UPDATE_ENABLED";
const QString SETTINGS_AUTOMATIC_UPDATE_INTERVAL = "SETTINGS_AUTOMATIC_UPDATE_INTERVAL";
-const QString USER_UNSEND_MESSAGE = "UNSEND_MESSAGE_CONTENT";
-const QString USER_UNSEND_MESSAGE_PUBLISH = "UNSEND_MESSAGE_PUBLISH_POLICITY";
// Misc values
const int DEFAULT_SCREEN_WIDTH = 800; ///< Default N900 screen width
qDebug() << __PRETTY_FUNCTION__;
m_ui->loggedIn(false);
- m_ui->clearUpdateLocationDialogData();
m_situareService->updateSession(""); // empty session string means logged out
m_automaticUpdateFirstStart = true;
}
connect(m_ui, SIGNAL(requestReverseGeo()),
this, SLOT(requestAddress()));
- connect(m_ui, SIGNAL(statusUpdate(QString,bool)),
+ connect(m_ui, SIGNAL(locationUpdate(QString,bool)),
this, SLOT(requestUpdateLocation(QString,bool)));
connect(m_ui, SIGNAL(enableAutomaticLocationUpdate(bool, int)),
this, SLOT(updateWasSuccessful()));
connect(m_situareService, SIGNAL(updateWasSuccessful()),
- m_ui, SLOT(clearUpdateLocationDialogData()));
+ m_ui, SIGNAL(updateWasSuccessful()));
}
void SituareEngine::startAutomaticUpdate()
--- /dev/null
+/*
+ Situare - A location system for Facebook
+ Copyright (C) 2010 Ixonos Plc. Authors:
+
+ Sami Rämö - sami.ramo@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 <QDebug>
+#include <QSettings>
+
+#include "common.h"
+
+#include "updatelocation.h"
+
+const QString UNSENT_MESSAGE_SETTING = "UNSENT_MESSAGE";
+const QString UNSENT_MESSAGE_PUBLISH_SETTING = "UNSENT_MESSAGE_PUBLISH";
+
+UpdateLocation::UpdateLocation(QObject *parent) :
+ QObject(parent),
+ m_publish(false)
+{
+ qWarning() << __PRETTY_FUNCTION__;
+
+ QSettings settings(SETTINGS_ORGANIZATION_NAME, SETTINGS_APPLICATION_NAME);
+ m_message = settings.value(UNSENT_MESSAGE_SETTING).toString();
+ m_publish = settings.value(UNSENT_MESSAGE_PUBLISH_SETTING, false).toBool();
+}
+
+UpdateLocation::~UpdateLocation()
+{
+ qWarning() << __PRETTY_FUNCTION__;
+
+ QSettings settings(SETTINGS_ORGANIZATION_NAME, SETTINGS_APPLICATION_NAME);
+
+ if (!m_message.isEmpty()) {
+ settings.setValue(UNSENT_MESSAGE_SETTING, m_message);
+ settings.setValue(UNSENT_MESSAGE_PUBLISH_SETTING, m_publish);
+ } else {
+ settings.remove(UNSENT_MESSAGE_SETTING);
+ settings.remove(UNSENT_MESSAGE_PUBLISH_SETTING);
+ }
+}
+
+void UpdateLocation::clear()
+{
+ qWarning() << __PRETTY_FUNCTION__;
+
+ m_message.clear();
+ m_publish = false;
+}
+
+QString UpdateLocation::message() const
+{
+ qWarning() << __PRETTY_FUNCTION__;
+
+ return m_message;
+}
+
+void UpdateLocation::send()
+{
+ qWarning() << __PRETTY_FUNCTION__;
+
+ emit locationUpdate(m_message, m_publish);
+}
+
+void UpdateLocation::setMessage(const QString &message)
+{
+ qWarning() << __PRETTY_FUNCTION__;
+
+ if (message != m_message) {
+ m_message = message;
+ emit messageChanged();
+ }
+}
+
+bool UpdateLocation::publish() const
+{
+ qWarning() << __PRETTY_FUNCTION__;
+
+ return m_publish;
+}
+
+void UpdateLocation::setPublish(bool publish)
+{
+ qWarning() << __PRETTY_FUNCTION__;
+
+ if (publish != m_publish) {
+ m_publish = publish;
+ emit publishChanged();
+ }
+}
--- /dev/null
+/*
+ Situare - A location system for Facebook
+ Copyright (C) 2010 Ixonos Plc. Authors:
+
+ Sami Rämö - sami.ramo@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 UPDATELOCATION_H
+#define UPDATELOCATION_H
+
+#include <QObject>
+
+/**
+ * @brief Controller for location update
+ *
+ * @author Sami Rämö (at) ixonos.com
+ */
+class UpdateLocation : public QObject
+{
+ Q_OBJECT
+
+ /**
+ * @brief Message text
+ *
+ * @property message
+ */
+ Q_PROPERTY(QString message READ message WRITE setMessage NOTIFY messageChanged)
+
+ /**
+ * @brief Publish on FB wall setting
+ *
+ * @property publish
+ */
+ Q_PROPERTY(bool publish READ publish WRITE setPublish NOTIFY publishChanged)
+
+public:
+ /**
+ * @brief Constructor
+ *
+ * Read unsent message from settigs.
+ */
+ explicit UpdateLocation(QObject *parent = 0);
+
+ /**
+ * @brief Destructor
+ *
+ * Save unsent message to settings.
+ */
+ ~UpdateLocation();
+
+ /**
+ * @brief Getter for message.
+ *
+ * @returns Message
+ */
+ QString message() const;
+
+ /**
+ * @brief Getter for publish setting
+ *
+ * @returns True is update should be published on FB wall.
+ */
+ bool publish() const;
+
+public slots:
+ /**
+ * @brief Clear data.
+ */
+ void clear();
+
+ /**
+ * @brief Send location update
+ *
+ * Emits locationUpdate() signal.
+ */
+ void send();
+
+ /**
+ * @brief Setter for message
+ *
+ * @param message New message.
+ */
+ void setMessage(const QString &message);
+
+ /**
+ * @brief Setter for publish setting
+ *
+ * @param publish True is update should be published on FB wall.
+ */
+ void setPublish(bool publish);
+
+signals:
+ /**
+ * @brief Send location update
+ *
+ * @param status Status message
+ * @param publish Publish on Facebook?
+ */
+ void locationUpdate(const QString &status, bool publish);
+
+ /**
+ * @brief Notifies that message has changed
+ */
+ void messageChanged();
+
+ /**
+ * @brief Notifies that publish setting has changed
+ */
+ void publishChanged();
+
+private:
+ bool m_publish; ///< Should the update be published on FB wall
+ QString m_message; ///< Location update message
+};
+
+#endif // UPDATELOCATION_H
void FacebookAuthentication::clearAccountInformation(bool clearUserInformation)
{
+ /// @todo Parameter not needed
qWarning() << __PRETTY_FUNCTION__ << "clearUserInformation:" << clearUserInformation;
- QSettings settings(SETTINGS_ORGANIZATION_NAME, SETTINGS_APPLICATION_NAME);
-
- settings.remove(USER_UNSEND_MESSAGE);
- settings.remove(USER_UNSEND_MESSAGE_PUBLISH);
-
if (clearUserInformation) {
NetworkCookieJar::clearCookiesSetting();
+ QSettings settings(SETTINGS_ORGANIZATION_NAME, SETTINGS_APPLICATION_NAME);
settings.remove(SETTINGS_AUTOMATIC_UPDATE_ENABLED);
settings.remove(SETTINGS_AUTOMATIC_UPDATE_INTERVAL);
}
}
}
+ /// @todo BUG: Url parameter strings are not url escaped
+
// qWarning() << __PRETTY_FUNCTION__ << "request url with parameters:" << url;
if (!m_session.isEmpty()) {
/**
* @brief Signals when updateLocation request finished successfully
- *
*/
void updateWasSuccessful();
ui/zoombutton.cpp \
ui/zoombuttonpanel.cpp \
user/user.cpp \
- ui/listitemcontextbuttonbar.cpp
+ ui/listitemcontextbuttonbar.cpp \
+ engine/updatelocation.cpp
HEADERS += application.h \
common.h \
coordinates/geocoordinate.h \
ui/zoombutton.h \
ui/zoombuttonpanel.h \
user/user.h \
- ui/listitemcontextbuttonbar.h
+ ui/listitemcontextbuttonbar.h \
+ engine/updatelocation.h
QT += network \
webkit
DEFINES += QT_NO_DEBUG_OUTPUT
#include <QMessageBox>
#include "common.h"
+#include "engine/updatelocation.h"
#include "error.h"
#include "friendlistpanel.h"
#include "fullscreenbutton.h"
m_fullScreenButton(0),
m_indicatorButtonPanel(0),
m_mapScale(0),
- m_updateLocation(0)
+ m_updateLocationController(0)
{
qDebug() << __PRETTY_FUNCTION__;
qDeleteAll(m_error_queue.begin(), m_error_queue.end());
m_error_queue.clear();
-
- QSettings settings(SETTINGS_ORGANIZATION_NAME, SETTINGS_APPLICATION_NAME);
-
- if (!m_backupMessage.isEmpty()) {
- settings.setValue(USER_UNSEND_MESSAGE, m_backupMessage.toAscii());
- settings.setValue(USER_UNSEND_MESSAGE_PUBLISH, m_backupFacebookPublishPolicity);
- } else {
- settings.remove(USER_UNSEND_MESSAGE);
- settings.remove(USER_UNSEND_MESSAGE_PUBLISH);
- }
}
void MainWindow::automaticUpdateDialogFinished(int result)
m_automaticUpdateLocationDialog->deleteLater();
}
-void MainWindow::backupUpdateLocationDialogData(const QString &status, bool publish)
-{
- qDebug() << __PRETTY_FUNCTION__;
-
- m_backupMessage = status;
- m_backupFacebookPublishPolicity = publish;
-}
-
void MainWindow::buildCrosshair()
{
qDebug() << __PRETTY_FUNCTION__;
this, SIGNAL(draggingModeTriggered()));
}
-void MainWindow::clearUpdateLocationDialogData()
-{
- qDebug() << __PRETTY_FUNCTION__;
-
- m_backupMessage.clear();
- m_backupFacebookPublishPolicity = false;
-}
-
void MainWindow::createMenus()
{
qDebug() << __PRETTY_FUNCTION__;
} else {
m_loginAct->setText(tr("Login"));
m_userInfoPanel->showUserInfo(false);
+ m_updateLocationController->clear();
}
updateItemVisibility(logged);
}
}
}
-void MainWindow::restoreUnsendMessage()
-{
- qDebug() << __PRETTY_FUNCTION__;
-
- QSettings settings(SETTINGS_ORGANIZATION_NAME, SETTINGS_APPLICATION_NAME);
- m_backupMessage = settings.value(USER_UNSEND_MESSAGE).toString();
- m_backupFacebookPublishPolicity = settings.value(USER_UNSEND_MESSAGE_PUBLISH, false).toBool();
-}
-
void MainWindow::setCrosshairVisibility(bool visibility)
{
qDebug() << __PRETTY_FUNCTION__;
{
qDebug() << __PRETTY_FUNCTION__;
- delete m_updateLocation;
- m_updateLocation = new UpdateLocationDialog(m_backupMessage, m_backupFacebookPublishPolicity,
- this);
-
- connect(this, SIGNAL(reverseGeoReady(QString)),
- m_updateLocation, SLOT(setAddress(QString)));
-
- connect(m_updateLocation, SIGNAL(statusUpdate(QString, bool)),
- this, SIGNAL(statusUpdate(QString, bool)));
+ if (!m_updateLocationController) {
+ m_updateLocationController = new UpdateLocation(this);
+ if (!m_updateLocationController)
+ return;
+ else
+ connect(this, SIGNAL(updateWasSuccessful()), m_updateLocationController, SLOT(clear()));
+ connect(m_updateLocationController, SIGNAL(locationUpdate(QString,bool)),
+ this, SIGNAL(locationUpdate(QString,bool)));
+ }
- connect(m_updateLocation, SIGNAL(statusUpdate(QString, bool)),
- this, SLOT(backupUpdateLocationDialogData(QString, bool)));
+ UpdateLocationDialog *updateLocationDialog
+ = new UpdateLocationDialog(m_updateLocationController, this);
- connect(m_updateLocation, SIGNAL(finished(int)),
- this, SLOT(updateLocationDialogFinished(int)));
+ connect(this, SIGNAL(reverseGeoReady(QString)),
+ updateLocationDialog, SLOT(setAddress(QString)));
- m_updateLocation->show();
+ updateLocationDialog->show();
emit requestReverseGeo();
}
m_tabbedPanel->setTabsEnabled(m_situareTabsIndexes, loggedIn);
}
-
-void MainWindow::updateLocationDialogFinished(int reason)
-{
- qDebug() << __PRETTY_FUNCTION__;
-
- Q_UNUSED(reason);
-
- if (m_updateLocation) {
- disconnect(this, SIGNAL(reverseGeoReady(QString)),
- m_updateLocation, SLOT(setAddress(QString)));
-
- disconnect(m_updateLocation, SIGNAL(statusUpdate(QString,bool)),
- this, SIGNAL(statusUpdate(QString,bool)));
-
- disconnect(m_updateLocation, SIGNAL(statusUpdate(QString,bool)),
- this, SLOT(backupUpdateLocationDialogData(QString,bool)));
-
- disconnect(m_updateLocation, SIGNAL(finished(int)),
- this, SLOT(updateLocationDialogFinished(int)));
-
- m_updateLocation->deleteLater();
- m_updateLocation = 0;
- }
-}
class SettingsDialog;
class SituareService;
class TabbedPanel;
-class UpdateLocationDialog;
+class UpdateLocation;
class User;
class UserInfoPanel;
class ZoomButtonPanel;
public slots:
/**
- * @brief Saves status message and Facebook publish setting
- *
- * @param status message that user sends. Message is stored to m_backupMessage data member
- * @param publish setting that determines whether the user status message is published on
- * Facebook. This value is stored to m_backupFacebookPublishPolicity data member.
- */
- void backupUpdateLocationDialogData(const QString &status, bool publish);
-
- /**
* @brief Builds information box with message.
*
* @param message Information message
void buildInformationBox(const QString &message, bool modal=false);
/**
- * @brief Clears backups of message and publish on Facebook setting
- */
- void clearUpdateLocationDialogData();
-
- /**
* @brief Hides and deletes login dialog
*/
void destroyLoginDialog();
void queueDialog(QDialog *dialog);
/**
- * @brief reads Unsend message from settings at startup
- */
- void restoreUnsendMessage();
-
- /**
* @brief Shows queued error information box
*
*/
*/
void toggleFullScreen();
- /**
- * @brief Slot function to get indication when dialog is finished
- */
- void updateLocationDialogFinished(int reason);
-
/*******************************************************************************
* SIGNALS
******************************************************************************/
void locationItemClicked(const GeoCoordinate &swBound, const GeoCoordinate &neBound);
/**
+ * @brief Send location update
+ *
+ * @param status Status message
+ * @param publish Publish on Facebook?
+ */
+ void locationUpdate(const QString &status, bool publish);
+
+ /**
* @brief Signals when Login/Logout action is pressed
*
*/
void searchHistoryItemClicked(const QString &searchString);
/**
- * @brief Signal for requestLocationUpdate from SituareEngine
- *
- * @param status Status message
- * @param publish Publish on Facebook
- */
- void statusUpdate(const QString &status, const bool &publish);
-
- /**
* @brief Dragging mode triggered.
*/
void draggingModeTriggered();
void viewZoomFinished();
/**
+ * @brief Signals when updateLocation request finished successfully
+ */
+ void updateWasSuccessful();
+
+ /**
* @brief Signal for use location ready.
*
* @param user User object
* DATA MEMBERS
******************************************************************************/
private:
- bool m_backupFacebookPublishPolicity; ///< Backup of publish on Facebook checkbox value
bool m_errorShown; ///< Indicates if error dialog/note is shown
bool m_loggedIn; ///< Indicates login state
bool m_refresh; ///< Indicates when webpage is refreshed
QMessageBox *m_automaticUpdateLocationDialog; ///< Automatic update location dialog
- QString m_backupMessage; ///< Backup of users message
-
FriendListPanel *m_friendsListPanel; ///< Instance of friends list panel
FullScreenButton *m_fullScreenButton; ///< Instance of the fullscreen toggle button
IndicatorButtonPanel *m_indicatorButtonPanel; ///< Instance of direction indicator button
MapView *m_mapView; ///< Instance of the map view
RoutingPanel *m_routingPanel; ///< Instance of routing panel
TabbedPanel *m_tabbedPanel; ///< Widget for tabbed panels
- UpdateLocationDialog *m_updateLocation; ///< Update location dialog
+ UpdateLocation *m_updateLocationController; ///< Controller for update location dialog
UserInfoPanel *m_userInfoPanel; ///< Instance of the user information panel
ZoomButtonPanel *m_zoomButtonPanel; ///< Instance of zoom button panel
};
#include <QScrollArea>\r
#include <QTextEdit>\r
\r
+#include "engine/updatelocation.h"\r
+\r
#include "updatelocationdialog.h"\r
\r
const int MESSAGE_MAX_LENGTH = 255;\r
\r
-UpdateLocationDialog::UpdateLocationDialog(const QString &userMessage, bool publishOnFacebook,\r
- QWidget *parent)\r
+UpdateLocationDialog::UpdateLocationDialog(UpdateLocation *controller, QWidget *parent)\r
: QDialog(parent)\r
{\r
qDebug() << __PRETTY_FUNCTION__;\r
\r
+ m_controller = controller;\r
+\r
setWindowTitle(tr("Update Location"));\r
\r
QGridLayout *gridLayout = new QGridLayout();\r
m_textEdit->setAcceptRichText(false);\r
m_charCountLabel = new QLabel();\r
\r
- if (userMessage.isEmpty())\r
+ if (controller->message().isEmpty())\r
{\r
m_textEdit->setText(tr("Message:"));\r
m_textEdit->selectAll();\r
}\r
else\r
{\r
- m_textEdit->setText(userMessage);\r
+ m_textEdit->setText(controller->message());\r
m_textEdit->document()->setModified(true);\r
textChanged();\r
}\r
m_locationLabel = new QLabel();\r
m_locationLabel->setWordWrap(true);\r
m_checkBox = new QCheckBox(tr("Publish on Facebook"));\r
- m_checkBox->setChecked(publishOnFacebook);\r
+ m_checkBox->setChecked(controller->publish());\r
\r
QDialogButtonBox *buttonBox = new QDialogButtonBox(Qt::Vertical);\r
QPushButton *sendButton = buttonBox->addButton(QDialogButtonBox::Ok);\r
connect(cancelButton, SIGNAL(clicked()),\r
this, SLOT(reject()));\r
\r
+ connect(this, SIGNAL(rejected()), controller, SLOT(clear()));\r
+\r
connect(m_textEdit, SIGNAL(textChanged()),\r
this, SLOT(textChanged()));\r
\r
#endif\r
\r
m_textEdit->setFocus(Qt::OtherFocusReason);\r
+\r
+ setAttribute(Qt::WA_DeleteOnClose);\r
}\r
\r
UpdateLocationDialog::~UpdateLocationDialog()\r
{\r
qDebug() << __PRETTY_FUNCTION__;\r
\r
- // coordinates for this call will be get from somewhere, map etc...\r
- emit statusUpdate(m_textEdit->document()->isModified() ? m_textEdit->toPlainText() : QString(),\r
- m_checkBox->isChecked());\r
+ m_controller->setMessage(m_textEdit->toPlainText());\r
+ m_controller->setPublish(m_checkBox->isChecked());\r
+ m_controller->send();\r
\r
- close();\r
+ accept();\r
}\r
\r
void UpdateLocationDialog::textChanged()\r
#include <QAbstractKineticScroller>\r
#endif // Q_WS_MAEMO_5\r
\r
+class UpdateLocation;\r
+\r
#include "texteditautoresizer.h"\r
\r
class QCheckBox;\r
/**\r
* @brief Default constructor\r
*\r
- * @param userMessage update location dialog message\r
- * @param publishOnFacebook update location dialog Facebook publish policity\r
+ * Is deleted automatically when closed.\r
+ *\r
+ * @param controller Controller for location update\r
* @param parent\r
*/\r
- UpdateLocationDialog(const QString &userMessage = "", bool publishOnFacebook = false,\r
- QWidget *parent = 0);\r
+ UpdateLocationDialog(UpdateLocation *controller, QWidget *parent = 0);\r
\r
+ /**\r
+ * @brief Destructor\r
+ *\r
+ * Does nothing.\r
+ */\r
~UpdateLocationDialog();\r
\r
/*******************************************************************************\r
private slots:\r
/**\r
* @brief Used to connect send button\r
- *\r
*/\r
void sendUpdate();\r
\r
/**\r
* @brief Used to get changes in messagetext\r
- *\r
*/\r
void textChanged();\r
\r
/**\r
* @brief Used to clear default messagetext\r
- *\r
*/\r
void textSelectionChanged();\r
\r
/*******************************************************************************\r
- * SIGNALS\r
- ******************************************************************************/\r
-signals:\r
- /**\r
- * @brief Routing signal for requestLocationUpdate to SituareEngine via MainWindow class\r
- *\r
- * @param status Status message\r
- * @param publish Publish on Facebook\r
- */\r
- void statusUpdate(const QString &status, const bool &publish);\r
-\r
-/*******************************************************************************\r
* DATA MEMBERS\r
******************************************************************************/\r
private:\r
QLabel *m_charCountLabel; ///< Pointer to character counter label\r
QLabel *m_locationLabel; ///< Pointer to locationLabel\r
QTextEdit *m_textEdit; ///< Pointer to TextEdit\r
+\r
+ UpdateLocation *m_controller; ///< Controller for location update dialog\r
};\r
\r
#endif // UPDATELOCATIONDIALOG_H\r
m_backgroundTopImage.load(":/res/images/list_item_top.png");
m_backgroundMiddleImage.load(":/res/images/list_item_middle.png");
m_backgroundBottomImage.load(":/res/images/list_item_bottom.png");
-
-// restoreUnsendMessage();
}
UserInfo::~UserInfo()