Added show friend button to MeetPeoplePanel.
authorJussi Laitinen <jupe@l3l7588.ixonos.local>
Tue, 2 Nov 2010 13:08:56 +0000 (15:08 +0200)
committerJussi Laitinen <jupe@l3l7588.ixonos.local>
Tue, 2 Nov 2010 13:08:56 +0000 (15:08 +0200)
22 files changed:
images.qrc
res/images/friend_list_btn.png [new file with mode: 0644]
res/images/friend_list_btn_d.png [new file with mode: 0644]
res/images/friend_list_btn_s.png [new file with mode: 0644]
res/images/message_remove_btn.png [new file with mode: 0644]
res/images/message_remove_btn_d.png [new file with mode: 0644]
res/images/message_remove_btn_s.png [new file with mode: 0644]
src/engine/engine.cpp
src/engine/engine.h
src/situareservice/database.cpp
src/situareservice/database.h
src/situareservice/situareservice.cpp
src/situareservice/situareservice.h
src/ui/mainwindow.cpp
src/ui/mainwindow.h
src/ui/meetpeoplepanel.cpp
src/ui/meetpeoplepanel.h
src/ui/messagepanel.cpp
src/ui/messagepanel.h
src/ui/searchdialog.cpp
src/ui/searchdialog.h
src/ui/userinfo.cpp

index 0235a7d..82edeb8 100644 (file)
         <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>
diff --git a/res/images/friend_list_btn.png b/res/images/friend_list_btn.png
new file mode 100644 (file)
index 0000000..544b133
Binary files /dev/null and b/res/images/friend_list_btn.png differ
diff --git a/res/images/friend_list_btn_d.png b/res/images/friend_list_btn_d.png
new file mode 100644 (file)
index 0000000..897631b
Binary files /dev/null and b/res/images/friend_list_btn_d.png differ
diff --git a/res/images/friend_list_btn_s.png b/res/images/friend_list_btn_s.png
new file mode 100644 (file)
index 0000000..d07c1d4
Binary files /dev/null and b/res/images/friend_list_btn_s.png differ
diff --git a/res/images/message_remove_btn.png b/res/images/message_remove_btn.png
new file mode 100644 (file)
index 0000000..9df0143
Binary files /dev/null and b/res/images/message_remove_btn.png differ
diff --git a/res/images/message_remove_btn_d.png b/res/images/message_remove_btn_d.png
new file mode 100644 (file)
index 0000000..8af91b7
Binary files /dev/null and b/res/images/message_remove_btn_d.png differ
diff --git a/res/images/message_remove_btn_s.png b/res/images/message_remove_btn_s.png
new file mode 100644 (file)
index 0000000..ce16ad4
Binary files /dev/null and b/res/images/message_remove_btn_s.png differ
index 236485e..81dfe47 100644 (file)
@@ -756,10 +756,13 @@ void SituareEngine::signalsFromMainWindow()
     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()));
@@ -773,6 +776,9 @@ void SituareEngine::signalsFromMainWindow()
     // 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()
@@ -840,10 +846,10 @@ void SituareEngine::signalsFromSituareService()
     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>&)),
@@ -868,14 +874,18 @@ void SituareEngine::topmostWindowChanged(bool isMainWindow)
     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)
index 90e0300..420a4d9 100644 (file)
@@ -31,6 +31,7 @@
 #include <QPair>
 
 #include "coordinates/geocoordinate.h"
+#include "situareservice/situareservice.h"
 
 class QTimer;
 
@@ -142,8 +143,9 @@ public slots:
     /**
     * @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.
index d97749f..e2163af 100644 (file)
@@ -66,7 +66,7 @@ bool Database::createNotificationTable()
                              "id INTEGER PRIMARY KEY,"
                              "senderid INTEGER,"
                              "receiverid INTEGER,"
-                             "type VARCHAR(10),"
+                             "read INTEGER,"
                              "timestamp VARCHAR(20),"
                              "text TEXT,"
                              "FOREIGN KEY(senderid) REFERENCES user(id),"
@@ -137,6 +137,59 @@ bool Database::createUserTagTable()
     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)
@@ -175,7 +228,7 @@ QByteArray Database::getInterestingPeople(qulonglong userId,
                                 "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\": [");
 
@@ -225,7 +278,7 @@ QByteArray Database::getNotifications(qulonglong userId)
         result.remove(result.lastIndexOf(","), 1);
 
     result.append("]}");
-    qWarning() << result;
+
     return result.toUtf8();
 }
 
@@ -258,20 +311,26 @@ bool Database::openDatabase()
     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)
@@ -281,6 +340,6 @@ bool Database::sendMessage(qulonglong senderId, qulonglong receiverId, const QSt
     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));
 }
index fba806e..f5c79e1 100644 (file)
@@ -24,12 +24,14 @@ public:
     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);
 
index d5fe2f3..03b5842 100644 (file)
@@ -305,7 +305,7 @@ void SituareService::requestFinished(QNetworkReply *reply)
                 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);
@@ -614,6 +614,14 @@ void SituareService::removeTags(const QStringList &tags)
     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__;
@@ -621,3 +629,12 @@ void SituareService::addTags(const QStringList &tags)
     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);
+}
index 78c40bb..88cbc93 100644 (file)
@@ -54,6 +54,9 @@ public:
     */
     friend class TestSituareService;
 
+    enum SuccessfulMethod {SuccessfulUpdateLocation, SuccessfulAddTags, SuccessfulRemoveTags,
+                           SuccessfulSendMessage, SuccessfulRemoveMessage};
+
     /**
     * @brief Default constructor
     *
@@ -131,6 +134,13 @@ public slots:
     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
@@ -145,6 +155,13 @@ public slots:
     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
@@ -308,7 +325,7 @@ signals:
     * @brief Signals when updateLocation request finished successfully
     *
     */
-    void updateWasSuccessful();
+    void updateWasSuccessful(SituareService::SuccessfulMethod successfulMethod);
 
     /**
     * @brief Signals when user data is retrieved
index f5bea55..e0c0a34 100644 (file)
@@ -359,22 +359,28 @@ void MainWindow::buildMeetPeoplePanel()
 
     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()
@@ -417,7 +423,7 @@ void MainWindow::buildPanels()
     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)));
@@ -453,7 +459,7 @@ void MainWindow::buildPanels()
             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)),
@@ -471,7 +477,7 @@ void MainWindow::buildPanels()
     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)));
 }
 
@@ -667,7 +673,10 @@ void MainWindow::dialogFinished(int status)
         }
     } 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) {
@@ -1110,7 +1119,7 @@ void MainWindow::startPeopleSearch()
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    SearchDialog *searchDialog = new SearchDialog(SearchDialog::People);
+    SearchDialog *searchDialog = new SearchDialog(SearchDialog::PeopleTag);
     queueDialog(searchDialog);
 }
 
index bf43cb0..3640b7c 100644 (file)
@@ -648,6 +648,13 @@ signals:
     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
     */
@@ -660,6 +667,13 @@ signals:
     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
@@ -826,7 +840,7 @@ private:
     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
index 259f59b..b30e767 100644 (file)
@@ -45,6 +45,12 @@ MeetPeoplePanel::MeetPeoplePanel(QWidget *parent)
     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);
@@ -53,6 +59,7 @@ MeetPeoplePanel::MeetPeoplePanel(QWidget *parent)
 
     m_genericButtonsLayout->addWidget(refreshInterestingPeopleButton);
     m_genericButtonsLayout->addWidget(searchPeopleButton);
+    m_itemButtonsLayout->addWidget(friendListButton);
     m_itemButtonsLayout->addWidget(messageButton);
 }
 
@@ -91,6 +98,18 @@ void MeetPeoplePanel::setImage(const QString &id, const QPixmap &image)
         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__ ;
index ec616ae..a1415a4 100644 (file)
@@ -82,6 +82,13 @@ private slots:
     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
@@ -114,6 +121,13 @@ signals:
     */
     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
index 9700b7c..d05cba8 100644 (file)
@@ -53,9 +53,19 @@ MessagePanel::MessagePanel(QWidget *parent)
     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);
 }
@@ -67,6 +77,17 @@ void MessagePanel::anyPanelClosed()
     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__;
index fbf6482..cded9c7 100644 (file)
@@ -71,6 +71,13 @@ private slots:
     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
@@ -94,6 +101,13 @@ signals:
     */
     void requestMessages();
 
+    /**
+    * @brief Requests message remove.
+    *
+    * @param id message ID
+    */
+    void requestRemoveMessage(const QString &id);
+
 /*******************************************************************************
  * DATA MEMBERS
  ******************************************************************************/
index 52dfe23..86e9cfc 100644 (file)
@@ -28,7 +28,8 @@
 #include "searchdialog.h"
 
 SearchDialog::SearchDialog(SearchDialogType type, QWidget *parent)
-        : QDialog(parent)
+        : QDialog(parent),
+          m_type(type)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
@@ -56,6 +57,13 @@ SearchDialog::SearchDialog(SearchDialogType type, QWidget *parent)
     setLayout(layout);
 }
 
+SearchDialog::SearchDialogType SearchDialog::type()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    return m_type;
+}
+
 QString SearchDialog::input()
 {
     qDebug() << __PRETTY_FUNCTION__;
index f9d0a99..8d8042b 100644 (file)
@@ -38,7 +38,7 @@ class SearchDialog : public QDialog
 
 public:
 
-    enum SearchDialogType {Location, People};
+    enum SearchDialogType {Location, PeopleTag};
 
     /**
     * @brief Constructor
@@ -58,6 +58,13 @@ public:
     */
     QString input();
 
+    /**
+    * @brief Returns search dialog type
+    *
+    * @return SearchDialogType
+    */
+    SearchDialog::SearchDialogType type();
+
 /*******************************************************************************
  * DATA MEMBERS
  ******************************************************************************/
index ad6f221..6546e5d 100644 (file)
@@ -218,13 +218,12 @@ void UserInfo::mouseReleaseEvent(QMouseEvent *event)
         && (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();
     }
 }
 
@@ -298,12 +297,15 @@ void UserInfo::setExpanded(bool expanded)
 {
     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);
 }
@@ -363,8 +365,10 @@ void UserInfo::tagsDialogFinished(int reason)
             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();