projects
/
situare
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
6f00085
)
Added coordinates to sendMessage.
author
Jussi Laitinen
<jupe@l3l7588.ixonos.local>
Wed, 3 Nov 2010 14:01:33 +0000
(16:01 +0200)
committer
Jussi Laitinen
<jupe@l3l7588.ixonos.local>
Wed, 3 Nov 2010 14:01:33 +0000
(16:01 +0200)
src/engine/engine.cpp
patch
|
blob
|
history
src/engine/engine.h
patch
|
blob
|
history
src/situareservice/database.cpp
patch
|
blob
|
history
src/situareservice/database.h
patch
|
blob
|
history
src/situareservice/situareservice.cpp
patch
|
blob
|
history
src/situareservice/situareservice.h
patch
|
blob
|
history
src/ui/mainwindow.cpp
patch
|
blob
|
history
src/ui/mainwindow.h
patch
|
blob
|
history
src/ui/messagedialog.cpp
patch
|
blob
|
history
src/ui/messagedialog.h
patch
|
blob
|
history
diff --git
a/src/engine/engine.cpp
b/src/engine/engine.cpp
index
a265296
..
9701f45
100644
(file)
--- a/
src/engine/engine.cpp
+++ b/
src/engine/engine.cpp
@@
-495,6
+495,18
@@
void SituareEngine::requestInterestingPeople()
GeoCoordinate(topRightSceneCoordinate));
}
GeoCoordinate(topRightSceneCoordinate));
}
+void SituareEngine::requestSendMessage(const QString &receiverId, const QString &message,
+ bool addCoordinates)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ if (addCoordinates)
+ m_situareService->sendMessage(receiverId, message, m_mapEngine->centerGeoCoordinate());
+ else
+ m_situareService->sendMessage(receiverId, message);
+}
+
+
void SituareEngine::routeParsed(Route &route)
{
qDebug() << __PRETTY_FUNCTION__;
void SituareEngine::routeParsed(Route &route)
{
qDebug() << __PRETTY_FUNCTION__;
@@
-765,8
+777,8
@@
void SituareEngine::signalsFromMainWindow()
connect(m_ui, SIGNAL(requestMessageDialog(QPair<QString, QString>)),
this, SLOT(showMessageDialog(QPair<QString, QString>)));
connect(m_ui, SIGNAL(requestMessageDialog(QPair<QString, QString>)),
this, SLOT(showMessageDialog(QPair<QString, QString>)));
- connect(m_ui, SIGNAL(sendMessage(QString,QString)),
- m_situareService, SLOT(sendMessage(QString,QString)));
+ connect(m_ui, SIGNAL(sendMessage(QString,QString,bool)),
+ this, SLOT(requestSendMessage(QString,QString,bool)));
// signals from message panel
connect(m_ui, SIGNAL(requestMessages()),
// signals from message panel
connect(m_ui, SIGNAL(requestMessages()),
diff --git
a/src/engine/engine.h
b/src/engine/engine.h
index
420a4d9
..
2cd2341
100644
(file)
--- a/
src/engine/engine.h
+++ b/
src/engine/engine.h
@@
-274,6
+274,16
@@
private slots:
void routeToCursor();
/**
void routeToCursor();
/**
+ * @brief Requests to send a message to a person.
+ *
+ * Adds coordinates to to message if selected.
+ * @param receiverId Facebook user ID
+ * @param message message text
+ * @param addCoordinates true if coordinates should be added, false otherwise
+ */
+ void requestSendMessage(const QString &receiverId, const QString &message, bool addCoordinates);
+
+ /**
* @brief Slot for setting auto centering state.
*
* Calls gps to send last known position
* @brief Slot for setting auto centering state.
*
* Calls gps to send last known position
diff --git
a/src/situareservice/database.cpp
b/src/situareservice/database.cpp
index
e2163af
..
1d4d630
100644
(file)
--- a/
src/situareservice/database.cpp
+++ b/
src/situareservice/database.cpp
@@
-196,8
+196,13
@@
QByteArray Database::getInterestingPeople(qulonglong userId,
{
qDebug() << __PRETTY_FUNCTION__;
{
qDebug() << __PRETTY_FUNCTION__;
+ //People start
+ QString result;
+ result.append("{\"people\": [");
+
QHash<QString, QString> tags;
QHash<QString, QString> tags;
+ //Get friends
QSqlQuery tagQuery(QString("SELECT usertag.userid, tag.name FROM usertag, tag WHERE "
"usertag.tagid IN (SELECT usertag.tagid FROM usertag WHERE "
"usertag.userid = '%1') AND usertag.userid != '%2' "
QSqlQuery tagQuery(QString("SELECT usertag.userid, tag.name FROM usertag, tag WHERE "
"usertag.tagid IN (SELECT usertag.tagid FROM usertag WHERE "
"usertag.userid = '%1') AND usertag.userid != '%2' "
@@
-229,9
+234,6
@@
QByteArray Database::getInterestingPeople(qulonglong userId,
.arg(southWestCoordinates.latitude()).arg(northEastCoordinates.latitude())
.arg(southWestCoordinates.longitude()).arg(northEastCoordinates.longitude()));
.arg(southWestCoordinates.latitude()).arg(northEastCoordinates.latitude())
.arg(southWestCoordinates.longitude()).arg(northEastCoordinates.longitude()));
- QString result;
- result.append("{\"people\": [");
-
while (userQuery.next()) {
result.append("{");
result.append("\"uid\": \"" + userQuery.value(0).toString() + "\",");
while (userQuery.next()) {
result.append("{");
result.append("\"uid\": \"" + userQuery.value(0).toString() + "\",");
@@
-245,6
+247,7
@@
QByteArray Database::getInterestingPeople(qulonglong userId,
if (lastComma != -1)
result.remove(result.lastIndexOf(","), 1);
if (lastComma != -1)
result.remove(result.lastIndexOf(","), 1);
+ //People end
result.append("]}");
return result.toUtf8();
result.append("]}");
return result.toUtf8();
@@
-333,13
+336,15
@@
bool Database::removeTags(qulonglong userId, const QStringList &tags)
tags.join(", ") + ")");
}
tags.join(", ") + ")");
}
-bool Database::sendMessage(qulonglong senderId, qulonglong receiverId, const QString &message)
+bool Database::sendMessage(qulonglong senderId, qulonglong receiverId, const QString &message,
+ const GeoCoordinate &coordinates)
{
qDebug() << __PRETTY_FUNCTION__;
QSqlQuery sendMessageQuery;
return sendMessageQuery.exec(QString("INSERT INTO notification VALUES("
{
qDebug() << __PRETTY_FUNCTION__;
QSqlQuery sendMessageQuery;
return sendMessageQuery.exec(QString("INSERT INTO notification VALUES("
- "NULL, '%1', '%2', 0, strftime('%s','now'), '%3')")
- .arg(senderId).arg(receiverId).arg(message));
+ "NULL, '%1', '%2', strftime('%s','now'), '%3', '%4', '%5')")
+ .arg(senderId).arg(receiverId).arg(message).arg(coordinates.latitude()).
+ arg(coordinates.longitude()));
}
}
diff --git
a/src/situareservice/database.h
b/src/situareservice/database.h
index
f5c79e1
..
59e09d9
100644
(file)
--- a/
src/situareservice/database.h
+++ b/
src/situareservice/database.h
@@
-33,7
+33,8
@@
public:
bool openDatabase();
bool removeMessage(qulonglong userId, const QString &id);
bool removeTags(qulonglong userId, const QStringList &tags);
bool openDatabase();
bool removeMessage(qulonglong userId, const QString &id);
bool removeTags(qulonglong userId, const QStringList &tags);
- bool sendMessage(qulonglong senderId, qulonglong receiverId, const QString &message);
+ bool sendMessage(qulonglong senderId, qulonglong receiverId, const QString &message,
+ const GeoCoordinate &coordinates);
private:
QSqlDatabase m_database;
private:
QSqlDatabase m_database;
diff --git
a/src/situareservice/situareservice.cpp
b/src/situareservice/situareservice.cpp
index
03b5842
..
bedce39
100644
(file)
--- a/
src/situareservice/situareservice.cpp
+++ b/
src/situareservice/situareservice.cpp
@@
-254,11
+254,14
@@
QString SituareService::formUrlParameters(const GeoCoordinate &coordinates, QStr
return parameters;
}
return parameters;
}
-void SituareService::sendMessage(const QString &receiverId, const QString &message)
+void SituareService::sendMessage(const QString &receiverId, const QString &message,
+ const GeoCoordinate &coordinates)
{
qDebug() << __PRETTY_FUNCTION__;
{
qDebug() << __PRETTY_FUNCTION__;
- qWarning() << __PRETTY_FUNCTION__ << m_database->sendMessage(613374451, receiverId.toULongLong(), message);
+ qWarning() << __PRETTY_FUNCTION__ << m_database->sendMessage(613374451,
+ receiverId.toULongLong(), message,
+ coordinates);
}
void SituareService::sendRequest(const QUrl &url, const QString &cookieType, const QString &cookie)
}
void SituareService::sendRequest(const QUrl &url, const QString &cookieType, const QString &cookie)
diff --git
a/src/situareservice/situareservice.h
b/src/situareservice/situareservice.h
index
88cbc93
..
3227bc5
100644
(file)
--- a/
src/situareservice/situareservice.h
+++ b/
src/situareservice/situareservice.h
@@
-166,8
+166,10
@@
public slots:
*
* @param receiverId Facebook user ID
* @param message message text
*
* @param receiverId Facebook user ID
* @param message message text
+ * @param message coordinates
*/
*/
- void sendMessage(const QString &receiverId, const QString &message);
+ void sendMessage(const QString &receiverId, const QString &message,
+ const GeoCoordinate &coordinates = GeoCoordinate());
private:
/**
private:
/**
diff --git
a/src/ui/mainwindow.cpp
b/src/ui/mainwindow.cpp
index
e0c0a34
..
f57a7a4
100644
(file)
--- a/
src/ui/mainwindow.cpp
+++ b/
src/ui/mainwindow.cpp
@@
-681,7
+681,8
@@
void MainWindow::dialogFinished(int status)
}
else if (messageDialog) {
if (status != 0)
}
else if (messageDialog) {
if (status != 0)
- emit sendMessage(messageDialog->input().first, messageDialog->input().second);
+ emit sendMessage(messageDialog->input().first, messageDialog->input().second,
+ messageDialog->isAddCoordinatesSelected());
}
dialog->deleteLater();
}
dialog->deleteLater();
diff --git
a/src/ui/mainwindow.h
b/src/ui/mainwindow.h
index
3640b7c
..
287f7f0
100644
(file)
--- a/
src/ui/mainwindow.h
+++ b/
src/ui/mainwindow.h
@@
-725,8
+725,9
@@
signals:
*
* @param receiverId Facebook user ID
* @param message message text
*
* @param receiverId Facebook user ID
* @param message message text
+ * @param addCoordinates true if coordinates should be added, false otherwise
*/
*/
- void sendMessage(const QString &receiverId, const QString &message);
+ void sendMessage(const QString &receiverId, const QString &message, bool addCoordinates);
/**
* @brief Signal for requestLocationUpdate from SituareEngine
/**
* @brief Signal for requestLocationUpdate from SituareEngine
diff --git
a/src/ui/messagedialog.cpp
b/src/ui/messagedialog.cpp
index
89c2334
..
f4253da
100644
(file)
--- a/
src/ui/messagedialog.cpp
+++ b/
src/ui/messagedialog.cpp
@@
-21,8
+21,10
@@
#include <QDebug>
#include <QDialogButtonBox>
#include <QHBoxLayout>
#include <QDebug>
#include <QDialogButtonBox>
#include <QHBoxLayout>
+#include <QVBoxLayout>
#include <QLineEdit>
#include <QPushButton>
#include <QLineEdit>
#include <QPushButton>
+#include <QCheckBox>
#include "messagedialog.h"
#include "messagedialog.h"
@@
-35,16
+37,21
@@
MessageDialog::MessageDialog(const QString &id, const QString &receiver, QWidget
setWindowTitle(tr("Message to ") + receiver);
m_messageField = new QLineEdit(this);
setWindowTitle(tr("Message to ") + receiver);
m_messageField = new QLineEdit(this);
+ m_addCoordinatesCheckBox = new QCheckBox(tr("Add coordinates"));
QHBoxLayout *layout = new QHBoxLayout(this);
QHBoxLayout *layout = new QHBoxLayout(this);
+ QVBoxLayout *leftLayout = new QVBoxLayout();
QDialogButtonBox *buttonBox = new QDialogButtonBox(Qt::Vertical);
QPushButton *sendButton = buttonBox->addButton(QDialogButtonBox::Ok);
QPushButton *cancelButton = buttonBox->addButton(QDialogButtonBox::Cancel);
sendButton->setText(tr("Send"));
QDialogButtonBox *buttonBox = new QDialogButtonBox(Qt::Vertical);
QPushButton *sendButton = buttonBox->addButton(QDialogButtonBox::Ok);
QPushButton *cancelButton = buttonBox->addButton(QDialogButtonBox::Cancel);
sendButton->setText(tr("Send"));
- layout->addWidget(m_messageField);
+ leftLayout->addWidget(m_messageField);
+ leftLayout->addWidget(m_addCoordinatesCheckBox);
+ layout->addLayout(leftLayout);
layout->addWidget(buttonBox);
layout->addWidget(buttonBox);
+
connect(sendButton, SIGNAL(clicked()),
this, SLOT(accept()));
connect(cancelButton, SIGNAL(clicked()),
connect(sendButton, SIGNAL(clicked()),
this, SLOT(accept()));
connect(cancelButton, SIGNAL(clicked()),
@@
-61,3
+68,8
@@
QPair<QString, QString> MessageDialog::input()
return pair;
}
return pair;
}
+
+bool MessageDialog::isAddCoordinatesSelected()
+{
+ return m_addCoordinatesCheckBox->isChecked();
+}
diff --git
a/src/ui/messagedialog.h
b/src/ui/messagedialog.h
index
e7e173c
..
6b627c1
100644
(file)
--- a/
src/ui/messagedialog.h
+++ b/
src/ui/messagedialog.h
@@
-24,6
+24,7
@@
#include <QDialog>
#include <QDialog>
+class QCheckBox;
class QDialogButtonBox;
class QLineEdit;
class QDialogButtonBox;
class QLineEdit;
@@
-51,6
+52,13
@@
public:
*/
MessageDialog(const QString &id, const QString &receiver, QWidget *parent = 0);
*/
MessageDialog(const QString &id, const QString &receiver, QWidget *parent = 0);
+ /**
+ * @brief Returns add coordinates check box selection state.
+ *
+ * @return true if check box is selected, false otherwise
+ */
+ bool isAddCoordinatesSelected();
+
/*******************************************************************************
* MEMBER FUNCTIONS AND SLOTS
******************************************************************************/
/*******************************************************************************
* MEMBER FUNCTIONS AND SLOTS
******************************************************************************/
@@
-66,8
+74,9
@@
public:
******************************************************************************/
private:
******************************************************************************/
private:
- QLineEdit *m_messageField; ///< Pointer to message field
- QString m_id; ///< Receiver ID
+ QCheckBox *m_addCoordinatesCheckBox; ///< Add coordinates check box
+ QLineEdit *m_messageField; ///< Pointer to message field
+ QString m_id; ///< Receiver ID
};
#endif // MESSAGEDIALOG_H
};
#endif // MESSAGEDIALOG_H