Added missing comments.
authorJussi Laitinen <jupe@l3l7588.ixonos.local>
Tue, 3 Aug 2010 08:54:47 +0000 (11:54 +0300)
committerJussi Laitinen <jupe@l3l7588.ixonos.local>
Tue, 3 Aug 2010 08:54:47 +0000 (11:54 +0300)
src/situareservice/situareservice.cpp
src/ui/friendlistpanel.cpp
src/ui/friendlistpanel.h
src/ui/listview.h
src/ui/locationlistitem.h
src/ui/mainwindow.h

index 03be242..edf6495 100644 (file)
@@ -294,7 +294,18 @@ void SituareService::parseUserData(const QByteArray &jsonReply)
     QJson::Parser parser;
     bool ok;
 
-    QVariantMap result = parser.parse (jsonReply, &ok).toMap();
+    QVariantMap result;
+    QByteArray jsonDummy;
+    QFile temp("generated_json.txt");
+    if(temp.open(QIODevice::ReadOnly)) {
+        jsonDummy = temp.readAll();
+        temp.close();
+        result = parser.parse (jsonDummy, &ok).toMap();
+    } else
+        result = parser.parse (jsonReply, &ok).toMap();
+
+
+    //QVariantMap result = parser.parse (jsonReply, &ok).toMap();
     if (!ok) {
         emit error(ErrorContext::SITUARE, SituareError::INVALID_JSON);
         return;
index fbaa696..87a0765 100644 (file)
@@ -79,11 +79,16 @@ FriendListPanel::FriendListPanel(QWidget *parent)
 
     connect(m_clearFilterButton, SIGNAL(clicked()),
             this, SLOT(clearFriendListFilter()));
-    connect(this, SIGNAL(panelOpened()),
-            this, SLOT(clearFriendListFilter()));
 
     connect(m_locationListView, SIGNAL(locationItemClicked(GeoCoordinate&,GeoCoordinate&)),
             this, SIGNAL(locationItemClicked(GeoCoordinate&,GeoCoordinate&)));
+
+    connect(this, SIGNAL(panelClosed()),
+            this, SLOT(thisPanelClosed()));
+
+    connect(this, SIGNAL(panelOpened()),
+            this, SLOT(thisPanelOpened()));
+
 }
 
 void FriendListPanel::friendImageReady(User *user)
@@ -129,10 +134,21 @@ void FriendListPanel::clearFriendListFilter()
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-//    m_friendListHeaderWidget->hide();
-//    m_friendListView->clearFilter();
+    m_friendListHeaderWidget->hide();
+    m_friendListView->clearFilter();
+}
+
+void FriendListPanel::keyPressEvent(QKeyEvent *event)
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    if (event->key() == Qt::Key_Backspace)
+        m_friendListNameRegExp.chop(1);
+    else
+        m_friendListNameRegExp.append(event->text());
 
-    m_friendListView->filter("pek");
+    if (!m_friendListNameRegExp.isEmpty())
+        m_friendListView->filter(m_friendListNameRegExp);
 }
 
 void FriendListPanel::locationDataReady(QList<Location> &result)
@@ -167,3 +183,18 @@ void FriendListPanel::showFriendsInList(const QList<QString> &userIDs)
     m_friendListHeaderWidget->show();
     m_friendListView->filter(userIDs);
 }
+
+void FriendListPanel::thisPanelClosed()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    releaseKeyboard();
+}
+
+void FriendListPanel::thisPanelOpened()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    grabKeyboard();
+    clearFriendListFilter();
+}
index c934525..3c93d55 100644 (file)
@@ -56,6 +56,15 @@ public:
     FriendListPanel(QWidget *parent = 0);
 
 /*******************************************************************************
+ * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
+ ******************************************************************************/
+protected:
+    /**
+    * @brief Forms friend list search filter pattern.
+    */
+    void keyPressEvent(QKeyEvent *event);
+
+/*******************************************************************************
  * MEMBER FUNCTIONS AND SLOTS
  ******************************************************************************/
 public slots:
@@ -94,6 +103,16 @@ private slots:
     */
     void showFriendsInList(const QList<QString> &userIDs);
 
+    /**
+    * @brief Releases keyboard events from this panel.
+    */
+    void thisPanelClosed();
+
+    /**
+    * @brief Grabs keyboard events from this panel and clears friend list filtering.
+    */
+    void thisPanelOpened();
+
 /*******************************************************************************
  * SIGNALS
  ******************************************************************************/
@@ -117,9 +136,11 @@ signals:
  * DATA MEMBERS
  ******************************************************************************/
 private:
-    QWidget *m_friendListHeaderWidget;  ///< Friend list header widget
     QLabel *m_friendListLabel;          ///< Friend list label
     QPushButton *m_clearFilterButton;   ///< Button to clear list filtering
+    QString m_friendListNameRegExp;     ///< Friend list name search regular expression
+    QWidget *m_friendListHeaderWidget;  ///< Friend list header widget
+
     FriendListView *m_friendListView;         ///< Friend list view
     LocationListView *m_locationListView;   ///< Location list view
 };
index a6ceb64..0d798b3 100644 (file)
@@ -45,6 +45,11 @@ public:
     */
     ListView(QWidget *parent = 0);
 
+    /**
+    * @brief Destructor.
+    *
+    * Calls ListView::clearList().
+    */
     ~ListView();
 
 /******************************************************************************
@@ -98,7 +103,7 @@ public:
     bool contains(const QString &userID);
 
     /**
-    * @brief Sets filter to list.
+    * @brief Filters list by user IDs.
     *
     * Hide all items that are not in the userIDs list.
     *
@@ -106,6 +111,13 @@ public:
     */
     void filter(const QList<QString> &userIDs);
 
+    /**
+    * @brief Filters list by text pattern.
+    *
+    * Filtering uses item names.
+    *
+    * @param pattern text pattern to filter
+    */
     void filter(const QString &pattern);
 
     /**
@@ -141,9 +153,8 @@ protected slots:
  ******************************************************************************/
 private:
     QHash<QString, ListItem *> m_listItems; ///< List of items in this view. Key = user ID
+
     ListItem *m_previousItem;               ///< Previously selected item
-    QVector<int> m_filteredIndices;
-    QVector<int> m_shownIndices;
 };
 
 #endif // LISTVIEW_H
index b1c7341..90aedb9 100644 (file)
@@ -53,9 +53,9 @@ public:
 ******************************************************************************/
 public:
     /**
-    * @brief Set user data for this item.
+    * @brief Set location data for this item.
     *
-    * @param user User pointer
+    * @param location Location data
     */
     void setLocationData(const Location &location);
 
index 5cd050d..7f3586a 100644 (file)
@@ -490,12 +490,18 @@ signals:
     void locationDataParsed(QList<Location> &result);
 
     /**
-     * @brief Signal is emitted when location item is clicked.
+     * @brief Signal is emitted when location item is clicked on map.
      *
      * @param userIDs list of friends user IDs in the group
      */
     void locationItemClicked(const QList<QString> &userIDs);
 
+    /**
+     * @brief Signal is emitted when location item is clicked in list.
+     *
+     * @param swBound south-west bound in GeoCoorinate
+     * @param neBound north-east bound in GeoCoordinate
+     */
     void locationItemClicked(GeoCoordinate &swBound, GeoCoordinate &neBound);
 
     /**