From: Sami Rämö Date: Tue, 10 Aug 2010 06:31:05 +0000 (+0300) Subject: Implemented text field for filtering the friend list X-Git-Tag: v2.0b-1~61^2^2~26 X-Git-Url: https://vcs.maemo.org/git/?a=commitdiff_plain;h=ba0ae5323f3e1fad87473d14ee4da2c6b085d9eb;p=situare Implemented text field for filtering the friend list - the field grabs the keyboard, so all keypresses modify the field even if it is not focused - the field is hidden by default, and is invoked when a key is pressed. - the field is hidden when it is empty (for example when cleared by using the backspace) - the field is cleared (and thus hidden) when return/enter is pressed --- diff --git a/src/ui/friendlistpanel.cpp b/src/ui/friendlistpanel.cpp index 70aca8d..d243b82 100644 --- a/src/ui/friendlistpanel.cpp +++ b/src/ui/friendlistpanel.cpp @@ -71,6 +71,32 @@ FriendListPanel::FriendListPanel(QWidget *parent) this, SLOT(clearFriendListFilter())); connect(this, SIGNAL(panelOpened()), this, SLOT(clearFriendListFilter())); + + m_filterField = new QLineEdit; + m_panelVBox->addWidget(m_filterField); + m_filterField->grabKeyboard(); + m_filterField->hide(); + + connect(m_filterField, SIGNAL(returnPressed()), + this, SLOT(filterReturnPressed())); + + connect(m_filterField, SIGNAL(textChanged(QString)), + this, SLOT(filterTextChanged(QString))); +} + +void FriendListPanel::filterReturnPressed() +{ + m_filterField->clear(); +} + +void FriendListPanel::filterTextChanged(const QString &text) +{ + qWarning() << __PRETTY_FUNCTION__; + + if(text.isEmpty()) + m_filterField->hide(); + else + m_filterField->show(); } void FriendListPanel::friendImageReady(User *user) diff --git a/src/ui/friendlistpanel.h b/src/ui/friendlistpanel.h index 6e83cb9..fb2d9d7 100644 --- a/src/ui/friendlistpanel.h +++ b/src/ui/friendlistpanel.h @@ -77,6 +77,10 @@ private slots: */ void clearFriendListFilter(); + void filterReturnPressed(); + + void filterTextChanged(const QString &text); + /** * @brief Slot to show friends in list. * @@ -105,6 +109,8 @@ private: QPushButton *m_clearFilterButton; ///< Button to clear list filtering ListView *m_friendListView; ///< Friend list view FriendListItemDelegate *m_friendListItemDelegate; ///< Friend list item delegate + + QLineEdit *m_filterField; }; #endif // FRIENDLISTPANEL_H