<file>res/images/calendar.png</file>
<file>res/images/message.png</file>
<file>res/images/message_unread.png</file>
+ <file>res/images/message_remove_btn.png</file>
+ <file>res/images/message_remove_btn_d.png</file>
+ <file>res/images/message_remove_btn_s.png</file>
+ <file>res/images/friend_list_btn.png</file>
+ <file>res/images/friend_list_btn_d.png</file>
+ <file>res/images/friend_list_btn_s.png</file>
</qresource>
</RCC>
connect(m_ui, SIGNAL(draggingModeTriggered()),
this, SLOT(draggingModeTriggered()));
- // signal from search location dialog
+ // signal from search search dialogs
connect(m_ui, SIGNAL(searchForLocation(QString)),
this, SLOT(locationSearch(QString)));
+ connect(m_ui, SIGNAL(requestSearchPeopleByTag(QString)),
+ m_situareService, SLOT(searchPeopleByTag(QString)));
+
// signals from meet people panel
connect(m_ui, SIGNAL(requestInterestingPeople()),
this, SLOT(requestInterestingPeople()));
// signals from message panel
connect(m_ui, SIGNAL(requestMessages()),
m_situareService, SLOT(fetchMessages()));
+
+ connect(m_ui, SIGNAL(requestRemoveMessage(QString)),
+ m_situareService, SLOT(removeMessage(QString)));
}
void SituareEngine::signalsFromMapEngine()
connect(m_situareService, SIGNAL(userDataChanged(User*, QList<User*>&)),
this, SLOT(userDataChanged(User*, QList<User*>&)));
- connect(m_situareService, SIGNAL(updateWasSuccessful()),
- this, SLOT(updateWasSuccessful()));
+ connect(m_situareService, SIGNAL(updateWasSuccessful(SituareService::SuccessfulMethod)),
+ this, SLOT(updateWasSuccessful(SituareService::SuccessfulMethod)));
- connect(m_situareService, SIGNAL(updateWasSuccessful()),
+ connect(m_situareService, SIGNAL(updateWasSuccessful(SituareService::SuccessfulMethod)),
m_ui, SIGNAL(clearUpdateLocationDialogData()));
connect(m_situareService, SIGNAL(interestingPeopleReceived(QList<User>&)),
setPowerSaving(!isMainWindow);
}
-void SituareEngine::updateWasSuccessful()
+void SituareEngine::updateWasSuccessful(SituareService::SuccessfulMethod successfulMethod)
{
- qDebug() << __PRETTY_FUNCTION__;
+ qWarning() << __PRETTY_FUNCTION__;
- if (m_networkAccessManager->isConnected())
- m_situareService->fetchLocations();
- else
+ if (m_networkAccessManager->isConnected()) {
+ if (successfulMethod == SituareService::SuccessfulUpdateLocation)
+ m_situareService->fetchLocations();
+ else if (successfulMethod == SituareService::SuccessfulRemoveMessage)
+ m_situareService->fetchMessages();
+ } else {
error(ErrorContext::NETWORK, QNetworkReply::UnknownNetworkError);
+ }
}
void SituareEngine::userDataChanged(User *user, QList<User *> &friendsList)
#include <QPair>
#include "coordinates/geocoordinate.h"
+#include "situareservice/situareservice.h"
class QTimer;
/**
* @brief Slot to intercept signal from successful location update
*
+ * @param successfulMethod which method was successful
*/
- void updateWasSuccessful();
+ void updateWasSuccessful(SituareService::SuccessfulMethod successfulMethod);
/**
* @brief Slot to intercept signal when new user data is available.
"id INTEGER PRIMARY KEY,"
"senderid INTEGER,"
"receiverid INTEGER,"
- "type VARCHAR(10),"
+ "read INTEGER,"
"timestamp VARCHAR(20),"
"text TEXT,"
"FOREIGN KEY(senderid) REFERENCES user(id),"
return created;
}
+QByteArray Database::getInterestingPeopleByTag(qulonglong userId, const QString &tag)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ QHash<QString, QString> tags;
+
+ QSqlQuery tagQuery(QString("SELECT DISTINCT usertag.userid, tag.name FROM usertag, tag WHERE "
+ "usertag.tagid = tag.id AND usertag.userid != '%1' AND "
+ "tag.name LIKE '%2'").arg(userId).arg(tag));
+
+ while (tagQuery.next()) {
+ QString userId = tagQuery.value(0).toString();
+ QString tagName = tagQuery.value(1).toString();
+
+ if (tags.contains(userId)) {
+ QString value = tags.take(userId);
+ value.append(", \"" + tagName + "\"");
+ tags.insert(userId, value);
+ }
+ else {
+ tags.insert(userId, QString("\"" + tagName + "\""));
+ }
+ }
+
+ QStringList userIds;
+ QHashIterator<QString, QString> i(tags);
+ while (i.hasNext())
+ userIds.append(i.next().key());
+
+ QSqlQuery userQuery(QString("SELECT user.id, user.name, user.image_url FROM user WHERE "
+ "user.id IN (") + userIds.join(", ") + QString(")"));
+ QString result;
+ result.append("{\"people\": [");
+
+ while (userQuery.next()) {
+ result.append("{");
+ result.append("\"uid\": \"" + userQuery.value(0).toString() + "\",");
+ result.append("\"name\": \"" + userQuery.value(1).toString() + "\",");
+ result.append("\"image_url\": \"" + userQuery.value(2).toString() + "\",");
+ result.append("\"tags\": [" + tags.value(userQuery.value(0).toString()) + "]");
+ result.append("},");
+ }
+
+ int lastComma = result.lastIndexOf(",");
+ if (lastComma != -1)
+ result.remove(result.lastIndexOf(","), 1);
+
+ result.append("]}");
+
+ return result.toUtf8();
+}
+
+
QByteArray Database::getInterestingPeople(qulonglong userId,
const GeoCoordinate &southWestCoordinates,
const GeoCoordinate &northEastCoordinates)
"user.longitude >= '%3' AND user.longitude < '%4'")
.arg(southWestCoordinates.latitude()).arg(northEastCoordinates.latitude())
.arg(southWestCoordinates.longitude()).arg(northEastCoordinates.longitude()));
- qWarning() << userQuery.lastQuery();
+
QString result;
result.append("{\"people\": [");
result.remove(result.lastIndexOf(","), 1);
result.append("]}");
- qWarning() << result;
+
return result.toUtf8();
}
return m_database.open();
}
+bool Database::removeMessage(qulonglong userId, const QString &id)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ QSqlQuery removeMessageQuery;
+
+ return removeMessageQuery.exec(QString("DELETE FROM notification WHERE "
+ "notification.receiverid = '%1' AND "
+ "notification.id = '%2'").arg(userId).arg(id));
+}
+
bool Database::removeTags(qulonglong userId, const QStringList &tags)
{
qDebug() << __PRETTY_FUNCTION__;
QSqlQuery removeTagsQuery;
- bool val = removeTagsQuery.exec(QString("DELETE FROM usertag WHERE usertag.userid = "
+ return removeTagsQuery.exec(QString("DELETE FROM usertag WHERE usertag.userid = "
"'%1' AND usertag.tagid IN (").arg(userId) +
tags.join(", ") + ")");
-
- qWarning() << __PRETTY_FUNCTION__ << val;
- qWarning() << removeTagsQuery.lastQuery();
-
- return true;
}
bool Database::sendMessage(qulonglong senderId, qulonglong receiverId, const QString &message)
QSqlQuery sendMessageQuery;
return sendMessageQuery.exec(QString("INSERT INTO notification VALUES("
- "NULL, '%1', '%2', \"message\", strftime('%s','now'), '%3')")
+ "NULL, '%1', '%2', 0, strftime('%s','now'), '%3')")
.arg(senderId).arg(receiverId).arg(message));
}
QByteArray getInterestingPeople(qulonglong userId,
const GeoCoordinate &southWestCoordinates,
const GeoCoordinate &northEastCoordinates);
+ QByteArray getInterestingPeopleByTag(qulonglong userId, const QString &tag);
bool createNotificationTable();
bool createTagTable();
bool createUserTagTable();
bool createUserTable();
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);
parseUserData(replyArray);
} else if(replyArray.isEmpty()) {
if(reply->url().toString().contains(UPDATE_LOCATION.toAscii())) {
- emit updateWasSuccessful();
+ emit updateWasSuccessful(SituareService::SuccessfulUpdateLocation);
} else {
// session credentials are invalid
emit error(ErrorContext::SITUARE, SituareError::SESSION_EXPIRED);
m_database->removeTags(613374451, tags);
}
+void SituareService::removeMessage(const QString &id)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ if (m_database->removeMessage(613374451, id))
+ emit updateWasSuccessful(SituareService::SuccessfulRemoveMessage);
+}
+
void SituareService::addTags(const QStringList &tags)
{
qDebug() << __PRETTY_FUNCTION__;
foreach (QString tag, tags)
m_database->addTag(613374451, tag);
}
+
+void SituareService::searchPeopleByTag(const QString &tag)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ QByteArray arr = m_database->getInterestingPeopleByTag(613374451, tag);
+
+ parseInterestingPeopleData(arr);
+}
*/
friend class TestSituareService;
+ enum SuccessfulMethod {SuccessfulUpdateLocation, SuccessfulAddTags, SuccessfulRemoveTags,
+ SuccessfulSendMessage, SuccessfulRemoveMessage};
+
/**
* @brief Default constructor
*
void credentialsReady(const FacebookCredentials &credentials);
/**
+ * @brief Removes message.
+ *
+ * @param id message ID
+ */
+ void removeMessage(const QString &id);
+
+ /**
* @brief Removes tags.
*
* @param tags list of tags to remove
void requestFinished(QNetworkReply *reply);
/**
+ * @brief Searches people by tag name.
+ *
+ * @param tag tag name
+ */
+ void searchPeopleByTag(const QString &tag);
+
+ /**
* @brief Sends a message to a person.
*
* @param receiverId Facebook user ID
* @brief Signals when updateLocation request finished successfully
*
*/
- void updateWasSuccessful();
+ void updateWasSuccessful(SituareService::SuccessfulMethod successfulMethod);
/**
* @brief Signals when user data is retrieved
connect(m_meetPeoplePanel, SIGNAL(requestMessageDialog(QPair<QString, QString>)),
this, SIGNAL(requestMessageDialog(QPair<QString, QString>)));
+
+ connect(m_meetPeoplePanel, SIGNAL(requestShowFriend(QList<QString>)),
+ m_friendsListPanel, SLOT(showFriendsInList(QList<QString>)));
}
void MainWindow::buildMessagePanel()
{
qDebug() << __PRETTY_FUNCTION__;
- m_messsagePanel = new MessagePanel(this);
+ m_messagePanel = new MessagePanel(this);
connect(this, SIGNAL(messagesReceived(QList<Message>&)),
- m_messsagePanel, SLOT(populateMessageListView(QList<Message>&)));
+ m_messagePanel, SLOT(populateMessageListView(QList<Message>&)));
- connect(m_messsagePanel, SIGNAL(requestMessages()),
+ connect(m_messagePanel, SIGNAL(requestMessages()),
this, SIGNAL(requestMessages()));
connect(this, SIGNAL(friendImageReady(QString,QPixmap)),
- m_messsagePanel, SLOT(setImage(QString,QPixmap)));
+ m_messagePanel, SLOT(setImage(QString,QPixmap)));
+
+ connect(m_messagePanel, SIGNAL(requestRemoveMessage(QString)),
+ this, SIGNAL(requestRemoveMessage(QString)));
}
void MainWindow::buildOsmLicense()
m_situareTabsIndexes.append(
m_tabbedPanel->addTab(m_meetPeoplePanel, QIcon(":/res/images/meet_people.png")));
m_situareTabsIndexes.append(
- m_tabbedPanel->addTab(m_messsagePanel, QIcon(":/res/images/message.png")));
+ m_tabbedPanel->addTab(m_messagePanel, QIcon(":/res/images/message.png")));
connect(m_mapView, SIGNAL(viewResized(QSize)),
m_tabbedPanel, SLOT(resizePanel(QSize)));
m_meetPeoplePanel, SLOT(anyPanelClosed()));
connect(m_tabbedPanel, SIGNAL(panelClosed()),
- m_messsagePanel, SLOT(anyPanelClosed()));
+ m_messagePanel, SLOT(anyPanelClosed()));
// signals for showing and hiding list item context buttons
connect(m_userInfoPanel, SIGNAL(listItemSelectionChanged(bool)),
connect(m_meetPeoplePanel, SIGNAL(listItemSelectionChanged(bool)),
m_tabbedPanel, SIGNAL(listItemSelectionChanged(bool)));
- connect(m_messsagePanel, SIGNAL(listItemSelectionChanged(bool)),
+ connect(m_messagePanel, SIGNAL(listItemSelectionChanged(bool)),
m_tabbedPanel, SIGNAL(listItemSelectionChanged(bool)));
}
}
} else if(searchDialog) {
if(status != 0) {
- emit searchForLocation(searchDialog->input());
+ if (searchDialog->type() == SearchDialog::Location)
+ emit searchForLocation(searchDialog->input());
+ else if (searchDialog->type() == SearchDialog::PeopleTag)
+ emit requestSearchPeopleByTag(searchDialog->input());
}
}
else if (messageDialog) {
{
qDebug() << __PRETTY_FUNCTION__;
- SearchDialog *searchDialog = new SearchDialog(SearchDialog::People);
+ SearchDialog *searchDialog = new SearchDialog(SearchDialog::PeopleTag);
queueDialog(searchDialog);
}
void requestContactDialog(const QString &facebookId);
/**
+ * @brief Requests message remove.
+ *
+ * @param id message ID
+ */
+ void requestRemoveMessage(const QString &id);
+
+ /**
* @brief Requests message dialog.
* @param receiver receiver facebook ID and name
*/
void requestReverseGeo();
/**
+ * @brief Requests search people by tag name.
+ *
+ * @param tag tag name
+ */
+ void requestSearchPeopleByTag(const QString &tag);
+
+ /**
* @brief Signals, when address data is ready
*
* @param address Street address
MapView *m_mapView; ///< Instance of the map view
MeetPeoplePanel *m_meetPeoplePanel; ///< Instance of MeetPeoplePanel
NetworkCookieJar *m_cookieJar; ///< Placeholder for QNetworkCookies
- MessagePanel *m_messsagePanel; ///< Instance of MessagePanel
+ MessagePanel *m_messagePanel; ///< Instance of MessagePanel
RoutingPanel *m_routingPanel; ///< Instance of routing panel
TabbedPanel *m_tabbedPanel; ///< Widget for tabbed panels
UserInfoPanel *m_userInfoPanel; ///< Instance of the user information panel
connect(searchPeopleButton, SIGNAL(clicked()),
this, SIGNAL(requestInterestingPeopleSearch()));
+ ImageButton *friendListButton = new ImageButton(":/res/images/friend_list_btn.png",
+ ":/res/images/friend_list_btn_s.png",
+ ":/res/images/friend_list_btn_d.png", this);
+ connect(friendListButton, SIGNAL(clicked()),
+ this, SLOT(showFriend()));
+
ImageButton *messageButton = new ImageButton(":/res/images/chat_btn.png",
":/res/images/chat_btn_s.png",
":/res/images/chat_btn_d.png", this);
m_genericButtonsLayout->addWidget(refreshInterestingPeopleButton);
m_genericButtonsLayout->addWidget(searchPeopleButton);
+ m_itemButtonsLayout->addWidget(friendListButton);
m_itemButtonsLayout->addWidget(messageButton);
}
personItem->setAvatarImage(image);
}
+void MeetPeoplePanel::showFriend()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ PersonListItem *personItem = dynamic_cast<PersonListItem*>(m_personListView->selectedItem());
+ if (personItem) {
+ QList<QString> userIds;
+ userIds.append(personItem->facebookId());
+ emit requestShowFriend(userIds);
+ }
+}
+
void MeetPeoplePanel::populateInterestingPeopleListView(QList<User> &interestingPeople)
{
qDebug() << __PRETTY_FUNCTION__ ;
void setImage(const QString &id, const QPixmap &image);
/**
+ * Shows selected friend in friend list
+ *
+ * Emits requestShowFriend with selected friend from list
+ */
+ void showFriend();
+
+ /**
* @brief Populates interesting people list view.
*
* @param interestingPeople list of interesting people
*/
void requestMessageDialog(const QPair<QString, QString> &receiver);
+ /**
+ * @brief Requests to show friend in friend list.
+ *
+ * @param userIDs list of friends' user IDs
+ */
+ void requestShowFriend(const QList<QString> &userIDs);
+
private:
PersonListView *m_personListView; ///< Interesting people list view
ImageButton *m_chatButton; ///< Chat button
connect(refreshMessagesButton, SIGNAL(clicked()),
this, SIGNAL(requestMessages()));
+ ImageButton *deleteMessageButton = new ImageButton(":res/images/message_remove_btn.png",
+ ":res/images/message_remove_btn_s.png",
+ ":res/images/message_remove_btn_d.png", this);
+ connect(deleteMessageButton, SIGNAL(clicked()),
+ this, SLOT(removeMessage()));
+
m_messageListView = new MessageListView(this);
m_messageListView->setItemDelegate(new ExtendedListItemDelegate(this));
listViewLayout->addWidget(m_messageListView);
+ connect(m_messageListView, SIGNAL(listItemSelectionChanged()),
+ this, SLOT(onListItemSelectionChanged()));
+
+ m_itemButtonsLayout->addWidget(deleteMessageButton);
m_genericButtonsLayout->addWidget(refreshMessagesButton);
}
m_messageListView->clearItemSelection();
}
+void MessagePanel::removeMessage()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ MessageListItem *item = dynamic_cast<MessageListItem *>(m_messageListView->selectedItem());
+
+ if (item) {
+ emit requestRemoveMessage(item->id());
+ }
+}
+
void MessagePanel::hideEvent(QHideEvent *event)
{
qDebug() << __PRETTY_FUNCTION__;
void anyPanelClosed();
/**
+ * @brief Removes message.
+ *
+ * Removes selected message from list view and emits removeMessage signal.
+ */
+ void removeMessage();
+
+ /**
* @brief Populates message list view.
*
* @param locations list of Message objects
*/
void requestMessages();
+ /**
+ * @brief Requests message remove.
+ *
+ * @param id message ID
+ */
+ void requestRemoveMessage(const QString &id);
+
/*******************************************************************************
* DATA MEMBERS
******************************************************************************/
#include "searchdialog.h"
SearchDialog::SearchDialog(SearchDialogType type, QWidget *parent)
- : QDialog(parent)
+ : QDialog(parent),
+ m_type(type)
{
qDebug() << __PRETTY_FUNCTION__;
setLayout(layout);
}
+SearchDialog::SearchDialogType SearchDialog::type()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ return m_type;
+}
+
QString SearchDialog::input()
{
qDebug() << __PRETTY_FUNCTION__;
public:
- enum SearchDialogType {Location, People};
+ enum SearchDialogType {Location, PeopleTag};
/**
* @brief Constructor
*/
QString input();
+ /**
+ * @brief Returns search dialog type
+ *
+ * @return SearchDialogType
+ */
+ SearchDialog::SearchDialogType type();
+
/*******************************************************************************
* DATA MEMBERS
******************************************************************************/
&& (abs(m_mousePosition.x() - event->pos().x()) <= MOUSE_PRESS_AREA_HEIGHT)) {
if (m_expanded) {
setExpanded(false);
- m_expanded = false;
+ //m_expanded = false;
}
else {
setExpanded(true);
- m_expanded = true;
+ //m_expanded = true;
}
- update();
}
}
{
qDebug() << __PRETTY_FUNCTION__;
+ m_expanded = expanded;
+
if (expanded) {
m_statusTextLabel->setText(m_messageText);
} else {
m_statusTextLabel->setText(TextModifier::shortenText(m_statusTextLabel->fontMetrics(),
m_messageText, LABEL_MAX_WIDTH));
}
+ update();
emit itemSelectionChanged(expanded);
}
foreach (QString removedTag, m_tagsDialog->removedTags())
removedTagsIds.append(m_userTags.key(removedTag));
- emit removeTags(removedTagsIds);
- emit addTags(m_tagsDialog->newTags());
+ if (!removedTagsIds.isEmpty())
+ emit removeTags(removedTagsIds);
+ if (!m_tagsDialog->newTags().isEmpty())
+ emit addTags(m_tagsDialog->newTags());
}
m_tagsDialog->deleteLater();