USA.
*/
+#include "common.h"
#include "imagebutton.h"
#include "../user/user.h"
#include "userinfo.h"
const int BACKGROUND_WIDTH = 240; ///< Width for item
const int BACKGROUND_TOP_HEIGHT = 16; ///< Height for item top
const int BACKGROUND_BOTTOM_HEIGHT = 15; ///< Height for item bottom
-const QColor COLOR_GRAY = QColor(152, 152, 152); ///< Gray color
-const QFont NOKIA_FONT_NORMAL = QFont("Nokia Sans", 18, QFont::Normal); ///< Normal font
-const QFont NOKIA_FONT_SMALL = QFont("Nokia Sans", 13, QFont::Normal); ///< Small font
+//const QColor COLOR_GRAY = QColor(152, 152, 152); ///< Gray color
+//const QFont NOKIA_FONT_NORMAL = QFont("Nokia Sans", 18, QFont::Normal); ///< Normal font
+//const QFont NOKIA_FONT_SMALL = QFont("Nokia Sans", 13, QFont::Normal); ///< Small font
const int ICON_HEIGHT = 24; ///< Icon height
const int ICON_WIDTH = 24; ///< Icon width
const int IMAGE_HEIGHT = 60; ///< Profile image height
const int MARGIN = 5; ///< Icon margin
const int MOUSE_PRESS_AREA_WIDTH = 20; ///< Area width for item height toggling
const int MOUSE_PRESS_AREA_HEIGHT = 20; ///< Area height for item height toggling
+const QString USER_UNSEND_MESSAGE = "User_unsend_message_content";
+const QString USER_UNSEND_MESSAGE_PUBLISH_POLICITY = "User_unsend_message_publish";
/**
* @var LABEL_MAX_WIDTH
m_updatedLabel = new QLabel();
m_updatedLabel->setWordWrap(true);
+ m_messageDialog = new UpdateLocationDialog(this);
+ m_messageDialog->hide();
+
ImageButton *updateFriendsButton = new ImageButton(this, ":/res/images/refresh.png",
":/res/images/refresh_s.png");
ImageButton *updateStatusMessageButton = new ImageButton(this, ":/res/images/send_position.png",
m_backgroundTopImage.load(":/res/images/user_info_item_top.png");
m_backgroundMiddleImage.load(":/res/images/user_info_item_middle.png");
m_backgroundBottomImage.load(":/res/images/user_info_item_bottom.png");
+
+ restoreUnsendMessage();
+}
+
+UserInfo::~UserInfo()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ if (!m_backupMessage.isEmpty()) {
+ QSettings settings(DIRECTORY_NAME, FILE_NAME);
+ settings.setValue(USER_UNSEND_MESSAGE, m_backupMessage.toAscii());
+ settings.setValue(USER_UNSEND_MESSAGE_PUBLISH_POLICITY, m_backupFacebookPublishPolicity);
+ }
+
+}
+
+void UserInfo::restoreUnsendMessage()
+{
+ QSettings settings(DIRECTORY_NAME, FILE_NAME);
+ m_backupMessage = settings.value(USER_UNSEND_MESSAGE, "").toString();
+ m_backupFacebookPublishPolicity =
+ settings.value(USER_UNSEND_MESSAGE_PUBLISH_POLICITY, false).toBool();
+
}
void UserInfo::setAddress(const QString &address)
{
qDebug() << __PRETTY_FUNCTION__;
- UpdateLocationDialog updateLocationDialog(this);
+ m_messageDialog->show();
+ m_messageDialog->m_textEdit->setPlainText(m_backupMessage);
+ m_messageDialog->m_checkBox->setCheckState(Qt::Unchecked);
- //updateLocationDialog.m_textEdit->setPlainText("");
- updateLocationDialog.m_textEdit->setPlainText(messageText());
- //updateLocationDialog.m_textEdit->setPlainText("Messaging around the world");
+ if (m_backupFacebookPublishPolicity == true)
+ m_messageDialog->m_checkBox->setCheckState(Qt::Checked);
emit requestReverseGeo();
connect(this, SIGNAL(reverseGeoReady(QString)),
- &updateLocationDialog, SLOT(setAddress(QString)));
-
- connect(&updateLocationDialog, SIGNAL(statusUpdate(QString, bool)),
- this, SIGNAL(statusUpdate(QString, bool)));
-
-// connect(this, SIGNAL(messageUpdatedToSituare()),
-// &updateLocationDialog, SLOT(close())); //poistuu
-
-// /*connect(this, SIGNAL(messageSendingFailed(QString)),
-// &updateLocationDialog, SLOT(saveMessageAndClose(QString)))*/;
+ m_messageDialog, SLOT(setAddress(QString)));
-// connect(&updateLocationDialog, SIGNAL(saveMessage(QString)),
-// this, SLOT(setMessageText(QString)));
+ connect(m_messageDialog, SIGNAL(statusUpdate(QString,bool)),
+ this, SIGNAL(statusUpdate(QString,bool)));
- connect(&updateLocationDialog, SIGNAL(statusUpdate(QString,bool)),
- this, SLOT(updateUserData(QString,bool)));
+ connect(m_messageDialog, SIGNAL(statusUpdate(QString,bool)),
+ this, SLOT(backupUpdateLocationDialogData(QString,bool)));
connect(this, SIGNAL(messageUpdatedToSituare()),
- this, SLOT(deleteUserData()));
+ this, SLOT(clearUpdateLocationDialogData()));
- updateLocationDialog.exec();
+ m_messageDialog->exec();
}
-void UserInfo::updateUserData(const QString &status, const bool &publish)
+void UserInfo::backupUpdateLocationDialogData(const QString &status, const bool &publish)
{
qDebug() << __PRETTY_FUNCTION__;
- setMessageText(status);
- //laita loputkin talteen (publish ja koordinaatit)
+ m_backupMessage = status;
+ m_backupFacebookPublishPolicity = publish;
}
-void UserInfo::deleteUserData()
+void UserInfo::clearUpdateLocationDialogData()
{
qDebug() << __PRETTY_FUNCTION__;
- qDebug() << "TEKSTIN SISALTO ENNEN: " << m_messageText;
- m_messageText.clear();
- qDebug() << "TEKSTIN SISALTO JALKEEN: " << m_messageText;
+ qDebug() << "TEKSTIN SISALTO ENNEN: " << m_backupMessage;
+ m_backupMessage.clear();
+ qDebug() << "TEKSTIN SISALTO JALKEEN: " << m_backupMessage;
+ m_backupFacebookPublishPolicity = false;
}
* @param parent Parent
*/
UserInfo(QWidget *parent=0);
+ ~UserInfo();
/*******************************************************************************
* BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
void setUserName(const QString &name);
public slots:
- void deleteUserData();
+ void clearUpdateLocationDialogData();
/**
* @brief Sets the message text
*
* @param text Reference to user message
*/
void setMessageText(const QString &text);
- void updateUserData(const QString &status, const bool &publish);
+ void backupUpdateLocationDialogData(const QString &status, const bool &publish);
private:
+ void restoreUnsendMessage();
/**
* @brief Set shortened or full-length text to labels.
*
******************************************************************************/
private:
bool m_expanded; ///< Item expanded state
+ bool m_backupFacebookPublishPolicity; ///< Backup of publish on Facebook checkbox value
QLabel *m_locationLabel; ///< Location label
QLabel *m_nameLabel; ///< Name label
QLabel *m_statusTextLabel; ///< Status text label
QPixmap m_backgroundTopImage; ///< Top background image
QPoint m_mousePosition; ///< Current mouse press position
QPointF m_coordinates; ///< User current coordinates
- QString m_address; ///< Address from where the new message was sent.
+ QString m_address; ///< Address from where the new message was sent
+ QString m_backupMessage; ///< Backup of users message
QString m_messageText; ///< User's message
QString m_time; ///< Time when the new message was sent
QString m_userName; ///< User's name
ImageButton *m_findButton; ///< User find button
+ UpdateLocationDialog *m_messageDialog; ///< Dialog for sending message and location
};
#endif // USERINFO_H