From: Sami Rämö Date: Mon, 16 Aug 2010 13:24:15 +0000 (+0300) Subject: Merge commit 'origin/locationlistview' into friendlist_filtering_text_field X-Git-Tag: v2.0b-1~61^2^2~13 X-Git-Url: http://vcs.maemo.org/git/?a=commitdiff_plain;h=b9e210ea869151849eb681ee170fca17ae5e305d;p=situare Merge commit 'origin/locationlistview' into friendlist_filtering_text_field Conflicts: src/application.cpp src/main.cpp src/ui/friendlistpanel.cpp src/ui/friendlistpanel.h --- b9e210ea869151849eb681ee170fca17ae5e305d diff --cc src/main.cpp index 9fac43e,d354beb..3dec172 --- a/src/main.cpp +++ b/src/main.cpp @@@ -19,12 -19,13 +19,8 @@@ USA. */ - #include - #include - #include - -#include - -#include "engine/engine.h" -#ifdef Q_WS_MAEMO_5 #include "application.h" -#endif - +#include "engine/engine.h" int main(int argc, char *argv[]) { diff --cc src/ui/friendlistpanel.cpp index 5c0b033,50b0f2c..99da131 --- a/src/ui/friendlistpanel.cpp +++ b/src/ui/friendlistpanel.cpp @@@ -20,8 -19,13 +20,12 @@@ along with Situare; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ + */ + + #include + #include + #include -#include "../user/user.h" #include "coordinates/geocoordinate.h" #include "friendlistitem.h" #include "friendlistitemdelegate.h" @@@ -77,69 -82,8 +84,69 @@@ FriendListPanel::FriendListPanel(QWidge connect(m_clearFilterButton, SIGNAL(clicked()), this, SLOT(clearFriendListFilter())); - // connect(this, SIGNAL(panelOpened()), - // this, SLOT(clearFriendListFilter())); + connect(m_routeButton, SIGNAL(clicked()), + this, SLOT(routeToSelectedFriend())); + + /// @todo remove old filterLayout when new panel are merged + + ////////////////////////////////////////////////////////////////////////// + // NOTE! Do not mix the new filtering layout below with the old one above + ////////////////////////////////////////////////////////////////////////// + + // filtering layout + QHBoxLayout *filteringLayout = new QHBoxLayout(); + friendListPanelLayout->addLayout(filteringLayout); + + // line edit for filtering + m_filterField = new QLineEdit; + filteringLayout->addWidget(m_filterField); + + connect(m_filterField, SIGNAL(returnPressed()), + this, SLOT(clearFiltering())); + + connect(m_filterField, SIGNAL(textChanged(QString)), + this, SLOT(filterTextChanged(QString))); + + // button for clearing the filtering + m_filterClearButton = new QPushButton(); + filteringLayout->addWidget(m_filterClearButton); + m_filterClearButton->setIcon(QIcon::fromTheme(QLatin1String("general_close"))); + + connect(m_filterClearButton, SIGNAL(clicked()), + this, SLOT(clearFiltering())); + + connect(qApp, SIGNAL(topmostWindowChanged(bool)), + this, SLOT(topmostWindowChanged(bool))); +} + +void FriendListPanel::clearFiltering() +{ + qDebug() << __PRETTY_FUNCTION__; + + ///< @todo Clear the filtering when fried list panel is closed (no hideEvent dispatched) + + // clearing the filtering text field does cause also hiding the filtering layout + m_filterField->clear(); +} + +void FriendListPanel::clearFriendListFilter() +{ + qDebug() << __PRETTY_FUNCTION__; + + m_friendListHeaderWidget->hide(); + m_friendListView->clearFilter(); +} + +void FriendListPanel::filterTextChanged(const QString &text) +{ + qDebug() << __PRETTY_FUNCTION__; + + if (m_filterField->isHidden() && !text.isEmpty()) + setFilteringLayoutVisibility(true); + else if (m_filterField->isVisible() && text.isEmpty()) + setFilteringLayoutVisibility(false); + + m_friendListView->filter(text); } void FriendListPanel::friendImageReady(User *user) @@@ -180,64 -124,32 +187,75 @@@ void FriendListPanel::friendInfoReceive m_friendListView->clearUnused(newUserIDs); } -void FriendListPanel::clearFriendListFilter() +void FriendListPanel::hideEvent(QHideEvent *event) { - qDebug() << __PRETTY_FUNCTION__; + qWarning() << __PRETTY_FUNCTION__; - m_friendListHeaderWidget->hide(); - m_friendListView->clearFilter(); + QWidget::hideEvent(event); + updateKeyboardGrabbing(); + clearFiltering(); } + void FriendListPanel::routeToSelectedFriend() + { + qDebug() << __PRETTY_FUNCTION__; + + FriendListItem *item = dynamic_cast(m_friendListView->selectedItem()); + + if (item) + emit routeToFriend(item->coordinates()); + } + +void FriendListPanel::setFilteringLayoutVisibility(bool visible) +{ + qDebug() << __PRETTY_FUNCTION__; + + m_filterField->setVisible(visible); + m_filterClearButton->setVisible(visible); +} + +void FriendListPanel::updateKeyboardGrabbing() +{ + qWarning() << __PRETTY_FUNCTION__; + + if (!m_mainWindowIsTopmost || !isVisible()) { + if (QWidget::keyboardGrabber() == m_filterField) { + m_filterField->releaseKeyboard(); + qWarning() << __PRETTY_FUNCTION__ << "released"; + } + } else if (m_mainWindowIsTopmost && isVisible()) { + if (QWidget::keyboardGrabber() != m_filterField) { + m_filterField->grabKeyboard(); + qWarning() << __PRETTY_FUNCTION__ << "grabbed"; + } + } +} + +void FriendListPanel::showEvent(QShowEvent *event) +{ + qWarning() << __PRETTY_FUNCTION__; + + QWidget::showEvent(event); + updateKeyboardGrabbing(); + setFilteringLayoutVisibility(false); +} + void FriendListPanel::showFriendsInList(const QList &userIDs) { qDebug() << __PRETTY_FUNCTION__; m_friendListLabel->setText(tr("Selected: %1").arg(userIDs.count())); - // openPanel(); m_friendListHeaderWidget->show(); m_friendListView->filter(userIDs); + + emit showPanelRequested(this); } + +void FriendListPanel::topmostWindowChanged(bool mainWindowIsTopmost) +{ + qWarning() << __PRETTY_FUNCTION__ << mainWindowIsTopmost; + + m_mainWindowIsTopmost = mainWindowIsTopmost; + updateKeyboardGrabbing(); +} diff --cc src/ui/friendlistpanel.h index 502dbdd,855bb9c..70ac68f --- a/src/ui/friendlistpanel.h +++ b/src/ui/friendlistpanel.h @@@ -97,61 -73,27 +97,68 @@@ public slots */ void friendInfoReceived(QList &friendList); +private: + /** + * @brief Set visibility for filtering related UI elements + * + * @param visible True if items should be visible, false if not + */ + void setFilteringLayoutVisibility(bool visible); + + /** + * @brief Takes care of grabbing and releasing the keyboard when required + * + * Keyboard is grabbed when MainWindow it the topmost window and FriendListPanel is visible. + * Releasing is done if the MainWindow is not the topmost window and/or FriendListPanel + * is invisible. + */ + void updateKeyboardGrabbing(); + private slots: /** - * @brief Slot to clear friend list filter. + * @brief Slot to clear friend list filter */ void clearFriendListFilter(); /** + * @brief Slot for clearing the friend list filtering. + */ + void clearFiltering(); + + /** + * @brief Set filtering UI elements visibility based on the filtering text value + * + * Filtering UI elements are invoked when the text becomes not empty and hidden when text + * becomes empty. + * + * @param text New text value + */ + void filterTextChanged(const QString &text); + + /** - * @brief Called when topmost window is changed - * - * Does set m_mainWindowIsTopmost and calls updateKeyboardGrabbing() + * @brief Routes to selected friend. * - * @param mainWindowIsTopmost True if MainWindow is the topmost one + * Emits routeToFriend if friend is selected from list. */ - void topmostWindowChanged(bool mainWindowIsTopmost); + void routeToSelectedFriend(); /** - * @brief Slot to show friends in list + * @brief Slot to show friends in list. * - * Shows only friends that are on userIDs list. + * Shows only friends that are on userIDs list * @param userIDs list of user ID's */ void showFriendsInList(const QList &userIDs); ++ /** ++ * @brief Called when topmost window is changed ++ * ++ * Does set m_mainWindowIsTopmost and calls updateKeyboardGrabbing() ++ * ++ * @param mainWindowIsTopmost True if MainWindow is the topmost one ++ */ ++ void topmostWindowChanged(bool mainWindowIsTopmost); ++ /******************************************************************************* * SIGNALS ******************************************************************************/ @@@ -167,12 -123,11 +188,16 @@@ signals * DATA MEMBERS ******************************************************************************/ private: - QLabel *m_friendListLabel; ///< Friend list label + bool m_mainWindowIsTopmost; ///< Is the MainWindow the topmost one + QLabel *m_friendListLabel; ///< Friend list label ++ + QLineEdit *m_filterField; ///< Text field for the filter text ++ QPushButton *m_clearFilterButton; ///< Button to clear list filtering + QPushButton *m_filterClearButton; ///< Button for clearing the filtering + QPushButton *m_routeButton; ///< Button to route to friend + QWidget *m_friendListHeaderWidget; ///< Friend list header widget FriendListView *m_friendListView; ///< Friend list view