connect(this, SIGNAL(panelOpened()),
this, SLOT(clearFriendListFilter()));
+ /// @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();
+ m_panelVBox->addLayout(filteringLayout);
+
+ // line edit for filtering
m_filterField = new QLineEdit;
- m_panelVBox->addWidget(m_filterField);
+ filteringLayout->addWidget(m_filterField);
m_filterField->grabKeyboard();
- m_filterField->hide();
connect(m_filterField, SIGNAL(returnPressed()),
- this, SLOT(filterReturnPressed()));
+ this, SLOT(clearFiltering()));
connect(m_filterField, SIGNAL(textChanged(QString)),
this, SLOT(filterTextChanged(QString)));
+
+ // button for clearing the filtering
+ m_filterClearButton = new QToolButton();
+ filteringLayout->addWidget(m_filterClearButton);
+ m_filterClearButton->setIcon(QIcon::fromTheme(QLatin1String("general_close")));
+
+ connect(m_filterClearButton, SIGNAL(clicked()),
+ this, SLOT(clearFiltering()));
+
+ // filtering layout ites are hidden by defaults
+ setFilteringLayoutVisible(false);
}
-void FriendListPanel::filterReturnPressed()
+void FriendListPanel::clearFiltering()
{
+ qWarning() << __PRETTY_FUNCTION__;
+
+ // 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)
{
qWarning() << __PRETTY_FUNCTION__;
- if(text.isEmpty())
- m_filterField->hide();
- else
- m_filterField->show();
+ if (m_filterField->isHidden() && !text.isEmpty())
+ setFilteringLayoutVisible(true);
+ else if (m_filterField->isVisible() && text.isEmpty())
+ setFilteringLayoutVisible(false);
}
void FriendListPanel::friendImageReady(User *user)
m_friendListView->clearUnused(newUserIDs);
}
-void FriendListPanel::clearFriendListFilter()
+void FriendListPanel::setFilteringLayoutVisible(bool visible)
{
- qDebug() << __PRETTY_FUNCTION__;
+ qWarning() << __PRETTY_FUNCTION__;
- m_friendListHeaderWidget->hide();
- m_friendListView->clearFilter();
+ m_filterField->setVisible(visible);
+ m_filterClearButton->setVisible(visible);
}
void FriendListPanel::showFriendsInList(const QList<QString> &userIDs)