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;
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)
{
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)
m_friendListHeaderWidget->show();
m_friendListView->filter(userIDs);
}
+
+void FriendListPanel::thisPanelClosed()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ releaseKeyboard();
+}
+
+void FriendListPanel::thisPanelOpened()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ grabKeyboard();
+ clearFriendListFilter();
+}
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:
*/
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
******************************************************************************/
* 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
};
*/
ListView(QWidget *parent = 0);
+ /**
+ * @brief Destructor.
+ *
+ * Calls ListView::clearList().
+ */
~ListView();
/******************************************************************************
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.
*
*/
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);
/**
******************************************************************************/
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
******************************************************************************/
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);
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);
/**