mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-14 18:34:29 -05:00
Added Search Friend Filter for Messenger Window
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2987 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
98c99172c0
commit
d0ef2c335d
@ -101,9 +101,10 @@ MessengerWindow::MessengerWindow(QWidget* parent, Qt::WFlags flags)
|
||||
connect( ui.shareButton, SIGNAL(clicked()), SLOT(openShareManager()));
|
||||
connect( ui.addIMAccountButton, SIGNAL(clicked( bool ) ), this , SLOT( addFriend() ) );
|
||||
connect( ui.actionHide_Offline_Friends, SIGNAL(triggered()), this, SLOT(insertPeers()));
|
||||
connect(ui.clearButton, SIGNAL(clicked()), this, SLOT(clearFilter()));
|
||||
|
||||
connect(ui.messagelineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(savestatusmessage()));
|
||||
|
||||
connect(ui.filterPatternLineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(filterRegExpChanged()));
|
||||
|
||||
QTimer *timer = new QTimer(this);
|
||||
timer->connect(timer, SIGNAL(timeout()), this, SLOT(updateMessengerDisplay()));
|
||||
@ -145,7 +146,7 @@ MessengerWindow::MessengerWindow(QWidget* parent, Qt::WFlags flags)
|
||||
updateAvatar();
|
||||
loadmystatusmessage();
|
||||
|
||||
|
||||
ui.clearButton->hide();
|
||||
|
||||
displayMenu();
|
||||
updateMessengerDisplay();
|
||||
@ -551,6 +552,10 @@ void MessengerWindow::insertPeers()
|
||||
/* add gpg item to the list. If item is already in the list, it won't be duplicated thanks to Qt */
|
||||
peertreeWidget->addTopLevelItem(gpg_item);
|
||||
}
|
||||
|
||||
if (ui.filterPatternLineEdit->text().isEmpty() == false) {
|
||||
FilterItems();
|
||||
}
|
||||
}
|
||||
|
||||
/* Utility Fns */
|
||||
@ -1055,3 +1060,61 @@ void MessengerWindow::checkAndSetIdle(int idleTime){
|
||||
void MessengerWindow::setIdle(bool idle){
|
||||
isIdle = idle;
|
||||
}
|
||||
|
||||
/* clear Filter */
|
||||
void MessengerWindow::clearFilter()
|
||||
{
|
||||
ui.filterPatternLineEdit->clear();
|
||||
ui.filterPatternLineEdit->setFocus();
|
||||
}
|
||||
|
||||
void MessengerWindow::filterRegExpChanged()
|
||||
{
|
||||
|
||||
QString text = ui.filterPatternLineEdit->text();
|
||||
|
||||
if (text.isEmpty()) {
|
||||
ui.clearButton->hide();
|
||||
} else {
|
||||
ui.clearButton->show();
|
||||
}
|
||||
|
||||
FilterItems();
|
||||
}
|
||||
|
||||
void MessengerWindow::FilterItems()
|
||||
{
|
||||
QString sPattern = ui.filterPatternLineEdit->text();
|
||||
|
||||
int nCount = ui.messengertreeWidget->topLevelItemCount ();
|
||||
for (int nIndex = 0; nIndex < nCount; nIndex++) {
|
||||
FilterItem(ui.messengertreeWidget->topLevelItem(nIndex), sPattern);
|
||||
}
|
||||
}
|
||||
|
||||
bool MessengerWindow::FilterItem(QTreeWidgetItem *pItem, QString &sPattern)
|
||||
{
|
||||
bool bVisible = true;
|
||||
|
||||
if (sPattern.isEmpty() == false) {
|
||||
if (pItem->text(0).contains(sPattern, Qt::CaseInsensitive) == false) {
|
||||
bVisible = false;
|
||||
}
|
||||
}
|
||||
|
||||
int nVisibleChildCount = 0;
|
||||
int nCount = pItem->childCount();
|
||||
for (int nIndex = 0; nIndex < nCount; nIndex++) {
|
||||
if (FilterItem(pItem->child(nIndex), sPattern)) {
|
||||
nVisibleChildCount++;
|
||||
}
|
||||
}
|
||||
|
||||
if (bVisible || nVisibleChildCount) {
|
||||
pItem->setHidden(false);
|
||||
} else {
|
||||
pItem->setHidden(true);
|
||||
}
|
||||
|
||||
return (bVisible || nVisibleChildCount);
|
||||
}
|
||||
|
@ -105,6 +105,9 @@ private slots:
|
||||
void on_actionRoot_isnot_decorated_activated();
|
||||
|
||||
void displayMenu();
|
||||
|
||||
void filterRegExpChanged();
|
||||
void clearFilter();
|
||||
|
||||
signals:
|
||||
void friendsUpdated() ;
|
||||
@ -124,7 +127,9 @@ private:
|
||||
void setIdle(bool Idle);
|
||||
bool isIdle;
|
||||
const unsigned long maxTimeBeforeIdle;
|
||||
|
||||
|
||||
void FilterItems();
|
||||
bool FilterItem(QTreeWidgetItem *pItem, QString &sPattern);
|
||||
|
||||
std::map<std::string, PopupChatDialog *> chatDialogs;
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>295</width>
|
||||
<height>507</height>
|
||||
<height>482</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -351,14 +351,78 @@ background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1,
|
||||
stop:0 #FEFEFE, stop:1 #E8E8E8);
|
||||
}</string>
|
||||
</property>
|
||||
<layout class="QGridLayout">
|
||||
<property name="margin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="spacing">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap resource="images.qrc">:/images/find-16.png</pixmap>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="filterPatternLineEdit">
|
||||
<property name="toolTip">
|
||||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;">
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Search Friends</span></p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="clearButton">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>MS Shell Dlg 2</family>
|
||||
</font>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Reset</string>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QPushButton
|
||||
{
|
||||
border-image: url(:/images/closenormal.png)
|
||||
}
|
||||
|
||||
QPushButton:hover
|
||||
{
|
||||
border-image: url(:/images/closehover.png)
|
||||
}
|
||||
|
||||
QPushButton:pressed {
|
||||
border-image: url(:/images/closepressed.png)
|
||||
}</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QTreeWidget" name="messengertreeWidget">
|
||||
<property name="contextMenuPolicy">
|
||||
<enum>Qt::CustomContextMenu</enum>
|
||||
|
Loading…
Reference in New Issue
Block a user