mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-27 10:21:40 -05:00
Added Search Filter for Contacts View
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3030 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
3d09acf96b
commit
d7b8e9cb7c
@ -64,6 +64,8 @@ MessageComposer::MessageComposer(QWidget *parent, Qt::WFlags flags)
|
|||||||
connect(ui.actionContactsView, SIGNAL(triggered()), this, SLOT(toggleContacts()));
|
connect(ui.actionContactsView, SIGNAL(triggered()), this, SLOT(toggleContacts()));
|
||||||
connect(ui.actionSaveas, SIGNAL(triggered()), this, SLOT(saveasDraft()));
|
connect(ui.actionSaveas, SIGNAL(triggered()), this, SLOT(saveasDraft()));
|
||||||
connect(ui.actionAttach, SIGNAL(triggered()), this, SLOT(attachFile()));
|
connect(ui.actionAttach, SIGNAL(triggered()), this, SLOT(attachFile()));
|
||||||
|
connect(ui.filterPatternLineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(filterRegExpChanged()));
|
||||||
|
connect(ui.clearButton, SIGNAL(clicked()), this, SLOT(clearFilter()));
|
||||||
|
|
||||||
connect(ui.sizeincreaseButton, SIGNAL (clicked()), this, SLOT (fontSizeIncrease()));
|
connect(ui.sizeincreaseButton, SIGNAL (clicked()), this, SLOT (fontSizeIncrease()));
|
||||||
connect(ui.sizedecreaseButton, SIGNAL (clicked()), this, SLOT (fontSizeDecrease()));
|
connect(ui.sizedecreaseButton, SIGNAL (clicked()), this, SLOT (fontSizeDecrease()));
|
||||||
@ -183,7 +185,8 @@ MessageComposer::MessageComposer(QWidget *parent, Qt::WFlags flags)
|
|||||||
|
|
||||||
QPalette palette = QApplication::palette();
|
QPalette palette = QApplication::palette();
|
||||||
codeBackground = palette.color( QPalette::Active, QPalette::Midlight );
|
codeBackground = palette.color( QPalette::Active, QPalette::Midlight );
|
||||||
|
|
||||||
|
ui.clearButton->hide();
|
||||||
|
|
||||||
/* Hide platform specific features */
|
/* Hide platform specific features */
|
||||||
#ifdef Q_WS_WIN
|
#ifdef Q_WS_WIN
|
||||||
@ -290,6 +293,10 @@ void MessageComposer::insertSendList()
|
|||||||
/* add to the list */
|
/* add to the list */
|
||||||
items.append(item);
|
items.append(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ui.filterPatternLineEdit->text().isEmpty() == false) {
|
||||||
|
FilterItems();
|
||||||
|
}
|
||||||
|
|
||||||
/* remove old items ??? */
|
/* remove old items ??? */
|
||||||
sendWidget->clear();
|
sendWidget->clear();
|
||||||
@ -1275,3 +1282,61 @@ void MessageComposer::checkAttachmentReady()
|
|||||||
int msec_rate = 1000;
|
int msec_rate = 1000;
|
||||||
QTimer::singleShot( msec_rate, this, SLOT(checkAttachmentReady(void)));
|
QTimer::singleShot( msec_rate, this, SLOT(checkAttachmentReady(void)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* clear Filter */
|
||||||
|
void MessageComposer::clearFilter()
|
||||||
|
{
|
||||||
|
ui.filterPatternLineEdit->clear();
|
||||||
|
ui.filterPatternLineEdit->setFocus();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MessageComposer::filterRegExpChanged()
|
||||||
|
{
|
||||||
|
|
||||||
|
QString text = ui.filterPatternLineEdit->text();
|
||||||
|
|
||||||
|
if (text.isEmpty()) {
|
||||||
|
ui.clearButton->hide();
|
||||||
|
} else {
|
||||||
|
ui.clearButton->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
FilterItems();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MessageComposer::FilterItems()
|
||||||
|
{
|
||||||
|
QString sPattern = ui.filterPatternLineEdit->text();
|
||||||
|
|
||||||
|
int nCount = ui.msgSendList->topLevelItemCount ();
|
||||||
|
for (int nIndex = 0; nIndex < nCount; nIndex++) {
|
||||||
|
FilterItem(ui.msgSendList->topLevelItem(nIndex), sPattern);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool MessageComposer::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);
|
||||||
|
}
|
@ -119,6 +119,8 @@ private slots:
|
|||||||
void toggleCode();
|
void toggleCode();
|
||||||
void addPostSplitter();
|
void addPostSplitter();
|
||||||
|
|
||||||
|
void filterRegExpChanged();
|
||||||
|
void clearFilter();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setTextColor(const QColor& col) ;
|
void setTextColor(const QColor& col) ;
|
||||||
@ -139,6 +141,9 @@ private:
|
|||||||
void alignmentChanged(Qt::Alignment a);
|
void alignmentChanged(Qt::Alignment a);
|
||||||
|
|
||||||
void sendMessage_internal(bool bDraftbox);
|
void sendMessage_internal(bool bDraftbox);
|
||||||
|
|
||||||
|
void FilterItems();
|
||||||
|
bool FilterItem(QTreeWidgetItem *pItem, QString &sPattern);
|
||||||
|
|
||||||
/** Define the popup menus for the Context menu */
|
/** Define the popup menus for the Context menu */
|
||||||
QMenu* contextMnu;
|
QMenu* contextMnu;
|
||||||
|
@ -66,14 +66,78 @@
|
|||||||
<string>Contacts</string>
|
<string>Contacts</string>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="dockWidgetContents">
|
<widget class="QWidget" name="dockWidgetContents">
|
||||||
<layout class="QGridLayout">
|
<layout class="QGridLayout" name="gridLayout_4">
|
||||||
<property name="margin">
|
<property name="margin">
|
||||||
<number>0</number>
|
<number>1</number>
|
||||||
</property>
|
|
||||||
<property name="spacing">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
</property>
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<property name="verticalSpacing">
|
||||||
|
<number>2</number>
|
||||||
|
</property>
|
||||||
|
<item row="0" column="0" colspan="2">
|
||||||
|
<widget class="QLabel" name="label_2">
|
||||||
|
<property name="text">
|
||||||
|
<string>Search for Name:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<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 row="1" column="1">
|
||||||
|
<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="msgSendList">
|
<widget class="QTreeWidget" name="msgSendList">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user