Merge branch 'master' into situare_interact
[situare] / src / ui / mainwindow.cpp
index 8a0ea5a..843a430 100644 (file)
@@ -42,6 +42,9 @@
 #include "map/mapcommon.h"
 #include "map/mapview.h"
 #include "mapscale.h"
+#include "meetpeoplepanel.h"
+#include "messagedialog.h"
+#include "messagepanel.h"
 #include "panelcommon.h"
 #include "routingpanel.h"
 #include "searchdialog.h"
@@ -182,8 +185,8 @@ void MainWindow::buildFriendListPanel()
     connect(m_friendsListPanel, SIGNAL(findFriend(GeoCoordinate)),
             this, SIGNAL(centerToCoordinates(GeoCoordinate)));
 
-    connect(this, SIGNAL(friendImageReady(User*)),
-            m_friendsListPanel, SLOT(friendImageReady(User*)));
+    connect(this, SIGNAL(friendImageReady(QString,QPixmap)),
+            m_friendsListPanel, SLOT(friendImageReady(QString,QPixmap)));
 
     connect(m_friendsListPanel, SIGNAL(routeToFriend(const GeoCoordinate&)),
             this, SIGNAL(routeTo(const GeoCoordinate&)));
@@ -352,6 +355,59 @@ void MainWindow::buildMapScale()
             m_mapScale, SLOT(updateMapResolution(qreal)));
 }
 
+void MainWindow::buildMeetPeoplePanel()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    m_meetPeoplePanel = new MeetPeoplePanel(this);
+
+    connect(this, SIGNAL(friendImageReady(QString,QPixmap)),
+            m_meetPeoplePanel, SLOT(setImage(QString,QPixmap)));
+
+    connect(this, SIGNAL(interestingPeopleReceived(QList<User>&,QList<User>&)),
+            m_meetPeoplePanel, SLOT(populateInterestingPeopleListView(QList<User>&,QList<User>&)));
+
+    connect(m_meetPeoplePanel, SIGNAL(requestInterestingPeople()),
+            this, SIGNAL(requestInterestingPeople()));
+
+    connect(m_meetPeoplePanel, SIGNAL(requestInterestingPeopleSearch()),
+            this, SLOT(startPeopleSearch()));
+
+    connect(m_meetPeoplePanel, SIGNAL(findPerson(GeoCoordinate)),
+            this, SIGNAL(centerToCoordinates(GeoCoordinate)));
+
+    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_messagePanel = new MessagePanel(this);
+
+    connect(this, SIGNAL(messagesReceived(QList<Message>&, QList<Message>&)),
+            m_messagePanel, SLOT(populateMessageListView(QList<Message>&, QList<Message>&)));
+
+    connect(m_messagePanel, SIGNAL(requestMessages()),
+            this, SIGNAL(requestMessages()));
+
+    connect(this, SIGNAL(friendImageReady(QString,QPixmap)),
+            m_messagePanel, SLOT(setImage(QString,QPixmap)));
+
+    connect(m_messagePanel, SIGNAL(requestRemoveMessage(QString)),
+            this, SIGNAL(requestRemoveMessage(QString)));
+
+    connect(m_messagePanel, SIGNAL(findFriend(GeoCoordinate)),
+            this, SIGNAL(centerToCoordinates(GeoCoordinate)));
+
+    connect(m_messagePanel, SIGNAL(requestMessageDialog(QPair<QString, QString>)),
+            this, SIGNAL(requestMessageDialog(QPair<QString, QString>)));
+}
+
 void MainWindow::buildOsmLicense()
 {
     qDebug() << __PRETTY_FUNCTION__;
@@ -376,6 +432,8 @@ void MainWindow::buildPanels()
     buildFriendListPanel();
     buildLocationSearchPanel();
     buildRoutingPanel();
+    buildMeetPeoplePanel();
+    buildMessagePanel();
 
     m_tabbedPanel = new TabbedPanel(this);
 
@@ -385,8 +443,12 @@ void MainWindow::buildPanels()
     m_situareTabsIndexes.append(
             m_tabbedPanel->addTab(m_friendsListPanel, QIcon(":/res/images/friend_list.png")));
 
-    m_tabbedPanel->addTab(m_locationSearchPanel, QIcon(":/res/images/location_search.png"));
-    m_tabbedPanel->addTab(m_routingPanel, QIcon(":/res/images/routing.png"));
+//    m_tabbedPanel->addTab(m_locationSearchPanel, QIcon(":/res/images/location_search.png"));
+//    m_tabbedPanel->addTab(m_routingPanel, QIcon(":/res/images/routing.png"));
+    m_situareTabsIndexes.append(
+            m_tabbedPanel->addTab(m_meetPeoplePanel, QIcon(":/res/images/meet_people.png")));
+    m_situareTabsIndexes.append(
+            m_tabbedPanel->addTab(m_messagePanel, QIcon(":/res/images/message.png")));
 
     connect(m_mapView, SIGNAL(viewResized(QSize)),
             m_tabbedPanel, SLOT(resizePanel(QSize)));
@@ -418,7 +480,16 @@ void MainWindow::buildPanels()
     connect(m_tabbedPanel, SIGNAL(currentChanged(int)),
             m_userInfoPanel, SIGNAL(collapse()));
 
+    connect(m_tabbedPanel, SIGNAL(panelClosed()),
+            m_meetPeoplePanel, SLOT(anyPanelClosed()));
+
+    connect(m_tabbedPanel, SIGNAL(panelClosed()),
+            m_messagePanel, SLOT(anyPanelClosed()));
+
     // signals for showing and hiding list item context buttons
+    connect(m_userInfoPanel, SIGNAL(listItemSelectionChanged(bool)),
+            m_tabbedPanel, SIGNAL(listItemSelectionChanged(bool)));
+
     connect(m_friendsListPanel, SIGNAL(listItemSelectionChanged(bool)),
             m_tabbedPanel, SIGNAL(listItemSelectionChanged(bool)));
 
@@ -427,6 +498,12 @@ void MainWindow::buildPanels()
 
     connect(m_routingPanel, SIGNAL(listItemSelectionChanged(bool)),
             m_tabbedPanel, SIGNAL(listItemSelectionChanged(bool)));
+
+    connect(m_meetPeoplePanel, SIGNAL(listItemSelectionChanged(bool)),
+            m_tabbedPanel, SIGNAL(listItemSelectionChanged(bool)));
+
+    connect(m_messagePanel, SIGNAL(listItemSelectionChanged(bool)),
+            m_tabbedPanel, SIGNAL(listItemSelectionChanged(bool)));
 }
 
 void MainWindow::buildRoutingPanel()
@@ -463,8 +540,20 @@ void MainWindow::buildUserInfoPanel()
     connect(m_userInfoPanel, SIGNAL(refreshUserData()),
             this, SIGNAL(refreshUserData()));
 
-    connect(m_userInfoPanel, SIGNAL(updateLocationMessageButtonClicked()),
-            this, SLOT(showUpdateLocationDialog()));
+    connect(this, SIGNAL(userImageReady(QString,QPixmap)),
+            m_userInfoPanel, SLOT(setImage(QString,QPixmap)));
+
+    connect(m_userInfoPanel, SIGNAL(addTags(QStringList)),
+            this, SIGNAL(addTags(QStringList)));
+
+    connect(m_userInfoPanel, SIGNAL(removeTags(QStringList)),
+            this, SIGNAL(removeTags(QStringList)));
+
+    connect(this, SIGNAL(popularTagsReceived(QHash<QString,QString>&)),
+            m_userInfoPanel, SLOT(populatePopularTags(QHash<QString,QString>&)));
+
+    connect(m_userInfoPanel, SIGNAL(requestPopularTags()),
+            this, SIGNAL(requestPopularTags()));
 }
 
 void MainWindow::buildZoomButtonPanel()
@@ -541,8 +630,17 @@ void MainWindow::dialogFinished(int status)
 
     QDialog *dialog = m_queue.takeFirst();
     SearchDialog *searchDialog = qobject_cast<SearchDialog *>(dialog);
-    if ((searchDialog) && (status != 0))
-        emit searchForLocation(searchDialog->input());
+    MessageDialog *messageDialog = qobject_cast<MessageDialog *>(dialog);    
+
+    if ((searchDialog) && (status != 0)) {
+        if (searchDialog->type() == SearchDialog::Location)
+            emit searchForLocation(searchDialog->input());
+        else if (searchDialog->type() == SearchDialog::PeopleTag)
+            emit requestSearchPeopleByTag(searchDialog->input());
+    } else if ((messageDialog) && (status != 0)) {
+        emit sendMessage(messageDialog->input().first, messageDialog->input().second,
+                         messageDialog->isAddCoordinatesSelected());
+    }
 
     dialog->deleteLater();
 
@@ -786,6 +884,14 @@ void MainWindow::showContactDialog(const QString &guid)
 #endif
 }
 
+void MainWindow::showMessageDialog(const QPair<QString, QString> &receiver)
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    MessageDialog *messageDialog = new MessageDialog(receiver.first, receiver.second);
+    queueDialog(messageDialog);
+}
+
 void MainWindow::showEnableAutomaticUpdateLocationDialog(const QString &text)
 {
     qDebug() << __PRETTY_FUNCTION__;
@@ -840,22 +946,30 @@ void MainWindow::showUpdateLocationDialog()
     emit requestReverseGeo();
 }
 
-void MainWindow::sslErrors(QNetworkReply *reply, const QList<QSslError> &errors)
+void MainWindow::startLocationSearch()
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    Q_UNUSED(errors)
-    reply->ignoreSslErrors();
+    SearchDialog *searchDialog = new SearchDialog(SearchDialog::Location);
+    queueDialog(searchDialog);
 }
 
-void MainWindow::startLocationSearch()
+void MainWindow::startPeopleSearch()
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    SearchDialog *searchDialog = new SearchDialog();
+    SearchDialog *searchDialog = new SearchDialog(SearchDialog::PeopleTag);
     queueDialog(searchDialog);
 }
 
+void MainWindow::sslErrors(QNetworkReply *reply, const QList<QSslError> &errors)
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    Q_UNUSED(errors)
+    reply->ignoreSslErrors();
+}
+
 void MainWindow::toggleFullScreen()
 {
     qDebug() << __PRETTY_FUNCTION__;