mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-04 20:59:05 -04:00
Added new basic class for a QLineEdit with a clear button - LineEditClear.
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5080 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
1df5582e1c
commit
7756b093bf
34 changed files with 413 additions and 962 deletions
|
@ -158,8 +158,7 @@ ForumsDialog::ForumsDialog(QWidget *parent)
|
|||
|
||||
connect(ui.downloadButton, SIGNAL(clicked()), this, SLOT(downloadAllFiles()));
|
||||
|
||||
connect(ui.clearButton, SIGNAL(clicked()), this, SLOT(clearFilter()));
|
||||
connect(ui.filterPatternLineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(filterRegExpChanged()));
|
||||
connect(ui.filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterItems(QString)));
|
||||
connect(ui.filterColumnComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(filterColumnChanged()));
|
||||
|
||||
connect(NotifyQt::getInstance(), SIGNAL(forumMsgReadSatusChanged(QString,QString,int)), this, SLOT(forumMsgReadSatusChanged(QString,QString,int)));
|
||||
|
@ -201,8 +200,6 @@ ForumsDialog::ForumsDialog(QWidget *parent)
|
|||
|
||||
lastViewType = -1;
|
||||
|
||||
ui.clearButton->hide();
|
||||
|
||||
// load settings
|
||||
processSettings(true);
|
||||
|
||||
|
@ -818,8 +815,8 @@ void ForumsDialog::fillThreadFinished()
|
|||
}
|
||||
thread->itemToExpand.clear();
|
||||
|
||||
if (ui.filterPatternLineEdit->text().isEmpty() == false) {
|
||||
FilterItems();
|
||||
if (ui.filterLineEdit->text().isEmpty() == false) {
|
||||
filterItems(ui.filterLineEdit->text());
|
||||
}
|
||||
|
||||
insertPost ();
|
||||
|
@ -1557,29 +1554,6 @@ void ForumsDialog::replytomessage()
|
|||
}
|
||||
}
|
||||
|
||||
void ForumsDialog::filterRegExpChanged()
|
||||
{
|
||||
// QRegExp regExp(ui.filterPatternLineEdit->text(), Qt::CaseInsensitive , QRegExp::FixedString);
|
||||
// proxyModel->setFilterRegExp(regExp);
|
||||
|
||||
QString text = ui.filterPatternLineEdit->text();
|
||||
|
||||
if (text.isEmpty()) {
|
||||
ui.clearButton->hide();
|
||||
} else {
|
||||
ui.clearButton->show();
|
||||
}
|
||||
|
||||
FilterItems();
|
||||
}
|
||||
|
||||
/* clear Filter */
|
||||
void ForumsDialog::clearFilter()
|
||||
{
|
||||
ui.filterPatternLineEdit->clear();
|
||||
ui.filterPatternLineEdit->setFocus();
|
||||
}
|
||||
|
||||
void ForumsDialog::changedViewBox()
|
||||
{
|
||||
if (m_bProcessSettings) {
|
||||
|
@ -1603,21 +1577,20 @@ void ForumsDialog::filterColumnChanged()
|
|||
// need content ... refill
|
||||
insertThreads();
|
||||
} else {
|
||||
FilterItems();
|
||||
filterItems(ui.filterLineEdit->text());
|
||||
}
|
||||
|
||||
// save index
|
||||
Settings->setValueToGroup("ForumsDialog", "filterColumn", filterColumn);
|
||||
}
|
||||
|
||||
void ForumsDialog::FilterItems()
|
||||
void ForumsDialog::filterItems(const QString& text)
|
||||
{
|
||||
QString sPattern = ui.filterPatternLineEdit->text();
|
||||
int filterColumn = FilterColumnFromComboBox(ui.filterColumnComboBox->currentIndex());
|
||||
|
||||
int nCount = ui.threadTreeWidget->topLevelItemCount ();
|
||||
for (int nIndex = 0; nIndex < nCount; nIndex++) {
|
||||
FilterItem(ui.threadTreeWidget->topLevelItem(nIndex), sPattern, filterColumn);
|
||||
filterItem(ui.threadTreeWidget->topLevelItem(nIndex), text, filterColumn);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1627,12 +1600,12 @@ void ForumsDialog::shareKey()
|
|||
shareUi.exec();
|
||||
}
|
||||
|
||||
bool ForumsDialog::FilterItem(QTreeWidgetItem *pItem, QString &sPattern, int filterColumn)
|
||||
bool ForumsDialog::filterItem(QTreeWidgetItem *pItem, const QString &text, int filterColumn)
|
||||
{
|
||||
bool bVisible = true;
|
||||
|
||||
if (sPattern.isEmpty() == false) {
|
||||
if (pItem->text(filterColumn).contains(sPattern, Qt::CaseInsensitive) == false) {
|
||||
if (text.isEmpty() == false) {
|
||||
if (pItem->text(filterColumn).contains(text, Qt::CaseInsensitive) == false) {
|
||||
bVisible = false;
|
||||
}
|
||||
}
|
||||
|
@ -1640,7 +1613,7 @@ bool ForumsDialog::FilterItem(QTreeWidgetItem *pItem, QString &sPattern, int fil
|
|||
int nVisibleChildCount = 0;
|
||||
int nCount = pItem->childCount();
|
||||
for (int nIndex = 0; nIndex < nCount; nIndex++) {
|
||||
if (FilterItem(pItem->child(nIndex), sPattern, filterColumn)) {
|
||||
if (filterItem(pItem->child(nIndex), text, filterColumn)) {
|
||||
nVisibleChildCount++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -97,8 +97,7 @@ private slots:
|
|||
void changedViewBox();
|
||||
|
||||
void filterColumnChanged();
|
||||
void filterRegExpChanged();
|
||||
void clearFilter();
|
||||
void filterItems(const QString &text);
|
||||
|
||||
void generateMassData();
|
||||
|
||||
|
@ -127,8 +126,7 @@ private:
|
|||
void processSettings(bool bLoad);
|
||||
void togglethreadview_internal();
|
||||
|
||||
void FilterItems();
|
||||
bool FilterItem(QTreeWidgetItem *pItem, QString &sPattern, int filterColumn);
|
||||
bool filterItem(QTreeWidgetItem *pItem, const QString &text, int filterColumn);
|
||||
|
||||
bool m_bProcessSettings;
|
||||
bool inMsgAsReadUnread;
|
||||
|
|
|
@ -1051,58 +1051,9 @@ border: 1px solid #CCCCCC;}</string>
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="filterPatternLineEdit">
|
||||
<widget class="LineEditClear" name="filterLineEdit">
|
||||
<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 forums</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="focusPolicy">
|
||||
<enum>Qt::NoFocus</enum>
|
||||
</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/>
|
||||
<string>Search forums</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -1279,6 +1230,11 @@ border-image: url(:/images/closepressed.png)
|
|||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>LineEditClear</class>
|
||||
<extends>QLineEdit</extends>
|
||||
<header>gui/common/LineEditClear.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>LinkTextBrowser</class>
|
||||
<extends>QTextBrowser</extends>
|
||||
|
|
|
@ -172,8 +172,7 @@ MessagesDialog::MessagesDialog(QWidget *parent)
|
|||
ui.actionIconOnly->setData(Qt::ToolButtonIconOnly);
|
||||
ui.actionTextUnderIcon->setData(Qt::ToolButtonTextUnderIcon);
|
||||
|
||||
connect(ui.clearButton, SIGNAL(clicked()), this, SLOT(clearFilter()));
|
||||
connect(ui.filterPatternLineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(filterRegExpChanged()));
|
||||
connect(ui.filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterChanged(QString)));
|
||||
|
||||
connect(ui.filterColumnComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(filterColumnChanged()));
|
||||
|
||||
|
@ -258,13 +257,9 @@ MessagesDialog::MessagesDialog(QWidget *parent)
|
|||
//viewmenu->addAction(ui.actionTextUnderIcon);
|
||||
ui.viewtoolButton->setMenu(viewmenu);
|
||||
|
||||
ui.filterPatternLineEdit->setMinimumWidth(20);
|
||||
|
||||
//setting default filter by column as subject
|
||||
proxyModel->setFilterKeyColumn(FilterColumnFromComboBox(ui.filterColumnComboBox->currentIndex()));
|
||||
|
||||
ui.clearButton->hide();
|
||||
|
||||
// load settings
|
||||
processSettings(true);
|
||||
|
||||
|
@ -1568,21 +1563,10 @@ void MessagesDialog::buttonStyle()
|
|||
setToolbarButtonStyle((Qt::ToolButtonStyle) dynamic_cast<QAction*>(sender())->data().toInt());
|
||||
}
|
||||
|
||||
void MessagesDialog::filterRegExpChanged()
|
||||
void MessagesDialog::filterChanged(const QString& text)
|
||||
{
|
||||
QRegExp regExp(ui.filterPatternLineEdit->text(), Qt::CaseInsensitive , QRegExp::FixedString);
|
||||
QRegExp regExp(text, Qt::CaseInsensitive, QRegExp::FixedString);
|
||||
proxyModel->setFilterRegExp(regExp);
|
||||
|
||||
QString text = ui.filterPatternLineEdit->text();
|
||||
|
||||
if (text.isEmpty())
|
||||
{
|
||||
ui.clearButton->hide();
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.clearButton->show();
|
||||
}
|
||||
}
|
||||
|
||||
void MessagesDialog::filterColumnChanged()
|
||||
|
@ -1802,13 +1786,6 @@ void MessagesDialog::updateMessageSummaryList()
|
|||
}
|
||||
}
|
||||
|
||||
/** clear Filter **/
|
||||
void MessagesDialog::clearFilter()
|
||||
{
|
||||
ui.filterPatternLineEdit->clear();
|
||||
ui.filterPatternLineEdit->setFocus();
|
||||
}
|
||||
|
||||
void MessagesDialog::tagAboutToShow()
|
||||
{
|
||||
TagsMenu *menu = dynamic_cast<TagsMenu*>(ui.tagButton->menu());
|
||||
|
|
|
@ -77,10 +77,9 @@ private slots:
|
|||
|
||||
void buttonStyle();
|
||||
|
||||
void filterRegExpChanged();
|
||||
void filterChanged(const QString &text);
|
||||
void filterColumnChanged();
|
||||
|
||||
void clearFilter();
|
||||
void tagAboutToShow();
|
||||
void tagSet(int tagId, bool set);
|
||||
void tagRemoveAll();
|
||||
|
|
|
@ -900,47 +900,7 @@ border: 1px solid #CCCCCC;}</string>
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="filterPatternLineEdit"/>
|
||||
</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="focusPolicy">
|
||||
<enum>Qt::NoFocus</enum>
|
||||
</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>
|
||||
<widget class="LineEditClear" name="filterLineEdit"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
|
@ -1398,6 +1358,11 @@ padding: 4px;
|
|||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>LineEditClear</class>
|
||||
<extends>QLineEdit</extends>
|
||||
<header>gui/common/LineEditClear.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>RSTabWidget</class>
|
||||
<extends>QTabWidget</extends>
|
||||
|
|
|
@ -112,10 +112,9 @@ MessengerWindow::MessengerWindow(QWidget* parent, Qt::WFlags flags)
|
|||
connect( ui.shareButton, SIGNAL(clicked()), SLOT(openShareManager()));
|
||||
connect( ui.addIMAccountButton, SIGNAL(clicked( bool ) ), this , SLOT( addFriend() ) );
|
||||
#endif // MINIMAL_RSGUI
|
||||
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()));
|
||||
connect(ui.filterLineEdit, SIGNAL(textChanged(QString)), ui.friendList, SLOT(filterItems(QString)));
|
||||
|
||||
#ifndef MINIMAL_RSGUI
|
||||
connect(NotifyQt::getInstance(), SIGNAL(ownAvatarChanged()), this, SLOT(updateAvatar()));
|
||||
|
@ -185,8 +184,6 @@ MessengerWindow::MessengerWindow(QWidget* parent, Qt::WFlags flags)
|
|||
loadmystatusmessage();
|
||||
#endif // MINIMAL_RSGUI
|
||||
|
||||
ui.clearButton->hide();
|
||||
|
||||
/* Hide platform specific features */
|
||||
#ifdef Q_WS_WIN
|
||||
#endif
|
||||
|
@ -284,24 +281,3 @@ void MessengerWindow::updateOwnStatus(const QString &peer_id, int status)
|
|||
}
|
||||
|
||||
#endif // MINIMAL_RSGUI
|
||||
|
||||
/* 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();
|
||||
}
|
||||
|
||||
ui.friendList->filterItems(text);
|
||||
}
|
||||
|
|
|
@ -65,11 +65,6 @@ private slots:
|
|||
void savestatusmessage();
|
||||
#endif // MINIMAL_RSGUI
|
||||
|
||||
void filterRegExpChanged();
|
||||
void clearFilter();
|
||||
|
||||
signals:
|
||||
|
||||
private:
|
||||
static MessengerWindow *_instance;
|
||||
|
||||
|
|
|
@ -275,54 +275,12 @@ subcontrol-position: bottom right;
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="filterPatternLineEdit">
|
||||
<widget class="LineEditClear" name="filterLineEdit">
|
||||
<property name="toolTip">
|
||||
<string>Search Friends</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>
|
||||
</layout>
|
||||
|
@ -381,6 +339,11 @@ stop:0 #FEFEFE, stop:1 #E8E8E8);
|
|||
</widget>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>LineEditClear</class>
|
||||
<extends>QLineEdit</extends>
|
||||
<header>gui/common/LineEditClear.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>AvatarWidget</class>
|
||||
<extends>QWidget</extends>
|
||||
|
|
|
@ -90,9 +90,8 @@ NetworkDialog::NetworkDialog(QWidget *parent)
|
|||
connect( ui.unvalidGPGkeyWidget, SIGNAL( itemSelectionChanged()), ui.connecttreeWidget, SLOT( clearSelection() ) );
|
||||
connect( ui.unvalidGPGkeyWidget, SIGNAL( itemDoubleClicked(QTreeWidgetItem*,int)), this, SLOT( peerdetails () ) );
|
||||
|
||||
connect( ui.filterPatternLineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(filterRegExpChanged()));
|
||||
connect( ui.filterLineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(filterItems(QString)));
|
||||
connect( ui.filterColumnComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(filterColumnChanged()));
|
||||
connect( ui.clearButton, SIGNAL(clicked()), this, SLOT(clearFilter()));
|
||||
|
||||
connect( ui.showUnvalidKeys, SIGNAL(clicked()), this, SLOT(insertConnect()));
|
||||
|
||||
|
@ -182,8 +181,6 @@ NetworkDialog::NetworkDialog(QWidget *parent)
|
|||
updateNetworkStatus();
|
||||
loadtabsettings();
|
||||
|
||||
ui.clearButton->hide();
|
||||
|
||||
/* Hide platform specific features */
|
||||
#ifdef Q_WS_WIN
|
||||
|
||||
|
@ -564,8 +561,8 @@ void NetworkDialog::insertConnect()
|
|||
connectWidget->update(); /* update display */
|
||||
ui.unvalidGPGkeyWidget->update(); /* update display */
|
||||
|
||||
if (ui.filterPatternLineEdit->text().isEmpty() == false) {
|
||||
FilterItems();
|
||||
if (ui.filterLineEdit->text().isEmpty() == false) {
|
||||
filterItems(ui.filterLineEdit->text());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -841,72 +838,48 @@ void NetworkDialog::loadtabsettings()
|
|||
Settings->endGroup();
|
||||
}
|
||||
|
||||
/* clear Filter */
|
||||
void NetworkDialog::clearFilter()
|
||||
{
|
||||
ui.filterPatternLineEdit->clear();
|
||||
ui.filterPatternLineEdit->setFocus();
|
||||
}
|
||||
|
||||
void NetworkDialog::filterRegExpChanged()
|
||||
{
|
||||
|
||||
QString text = ui.filterPatternLineEdit->text();
|
||||
|
||||
if (text.isEmpty()) {
|
||||
ui.clearButton->hide();
|
||||
} else {
|
||||
ui.clearButton->show();
|
||||
}
|
||||
|
||||
FilterItems();
|
||||
}
|
||||
|
||||
void NetworkDialog::filterColumnChanged()
|
||||
{
|
||||
|
||||
FilterItems();
|
||||
|
||||
filterItems(ui.filterLineEdit->text());
|
||||
}
|
||||
|
||||
void NetworkDialog::FilterItems()
|
||||
void NetworkDialog::filterItems(const QString &text)
|
||||
{
|
||||
QString sPattern = ui.filterPatternLineEdit->text();
|
||||
int nFilterColumn = FilterColumnFromComboBox(ui.filterColumnComboBox->currentIndex());
|
||||
int filterColumn = FilterColumnFromComboBox(ui.filterColumnComboBox->currentIndex());
|
||||
|
||||
int nCount = ui.connecttreeWidget->topLevelItemCount ();
|
||||
for (int nIndex = 0; nIndex < nCount; nIndex++) {
|
||||
FilterItem(ui.connecttreeWidget->topLevelItem(nIndex), sPattern, nFilterColumn);
|
||||
int count = ui.connecttreeWidget->topLevelItemCount ();
|
||||
for (int index = 0; index < count; index++) {
|
||||
filterItem(ui.connecttreeWidget->topLevelItem(index), text, filterColumn);
|
||||
}
|
||||
nCount = ui.unvalidGPGkeyWidget->topLevelItemCount ();
|
||||
for (int nIndex = 0; nIndex < nCount; nIndex++) {
|
||||
FilterItem(ui.unvalidGPGkeyWidget->topLevelItem(nIndex), sPattern, nFilterColumn);
|
||||
count = ui.unvalidGPGkeyWidget->topLevelItemCount ();
|
||||
for (int nIndex = 0; nIndex < count; nIndex++) {
|
||||
filterItem(ui.unvalidGPGkeyWidget->topLevelItem(nIndex), text, filterColumn);
|
||||
}
|
||||
}
|
||||
|
||||
bool NetworkDialog::FilterItem(QTreeWidgetItem *pItem, QString &sPattern, int nFilterColumn)
|
||||
bool NetworkDialog::filterItem(QTreeWidgetItem *item, const QString &text, int filterColumn)
|
||||
{
|
||||
bool bVisible = true;
|
||||
bool visible = true;
|
||||
|
||||
if (sPattern.isEmpty() == false) {
|
||||
if (pItem->text(nFilterColumn).contains(sPattern, Qt::CaseInsensitive) == false) {
|
||||
bVisible = false;
|
||||
if (text.isEmpty() == false) {
|
||||
if (item->text(filterColumn).contains(text, Qt::CaseInsensitive) == false) {
|
||||
visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
int nVisibleChildCount = 0;
|
||||
int nCount = pItem->childCount();
|
||||
for (int nIndex = 0; nIndex < nCount; nIndex++) {
|
||||
if (FilterItem(pItem->child(nIndex), sPattern, nFilterColumn)) {
|
||||
nVisibleChildCount++;
|
||||
int visibleChildCount = 0;
|
||||
int count = item->childCount();
|
||||
for (int index = 0; index < count; index++) {
|
||||
if (filterItem(item->child(index), text, filterColumn)) {
|
||||
visibleChildCount++;
|
||||
}
|
||||
}
|
||||
|
||||
if (bVisible || nVisibleChildCount) {
|
||||
pItem->setHidden(false);
|
||||
if (visible || visibleChildCount) {
|
||||
item->setHidden(false);
|
||||
} else {
|
||||
pItem->setHidden(true);
|
||||
item->setHidden(true);
|
||||
}
|
||||
|
||||
return (bVisible || nVisibleChildCount);
|
||||
return (visible || visibleChildCount);
|
||||
}
|
||||
|
|
|
@ -80,8 +80,7 @@ private slots:
|
|||
void on_actionTabsTriangular_activated();
|
||||
|
||||
void filterColumnChanged();
|
||||
void filterRegExpChanged();
|
||||
void clearFilter();
|
||||
void filterItems(const QString &text);
|
||||
|
||||
private:
|
||||
QTreeWidgetItem *getCurrentNeighbour();
|
||||
|
@ -90,8 +89,7 @@ private:
|
|||
|
||||
class NetworkView *networkview;
|
||||
|
||||
void FilterItems();
|
||||
bool FilterItem(QTreeWidgetItem *pItem, QString &sPattern, int nFilterColumn);
|
||||
bool filterItem(QTreeWidgetItem *item, const QString &text, int filterColumn);
|
||||
|
||||
/** Qt Designer generated object */
|
||||
Ui::NetworkDialog ui;
|
||||
|
|
|
@ -171,7 +171,7 @@ border: 1px solid #CCCCCC;}</string>
|
|||
<string/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap>:/images/rs1.png</pixmap>
|
||||
<pixmap resource="images.qrc">:/images/rs1.png</pixmap>
|
||||
</property>
|
||||
<property name="scaledContents">
|
||||
<bool>true</bool>
|
||||
|
@ -206,62 +206,17 @@ p, li { white-space: pre-wrap; }
|
|||
<string/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap>:/images/find-16.png</pixmap>
|
||||
<pixmap resource="images.qrc">:/images/find-16.png</pixmap>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="filterPatternLineEdit">
|
||||
<widget class="LineEditClear" name="filterLineEdit">
|
||||
<property name="toolTip">
|
||||
<string>Search Network</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="focusPolicy">
|
||||
<enum>Qt::NoFocus</enum>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Clear Filter</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>
|
||||
|
@ -323,7 +278,7 @@ subcontrol-position: bottom right;
|
|||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<iconset resource="images.qrc">
|
||||
<normaloff>:/images/looknfeel.png</normaloff>:/images/looknfeel.png</iconset>
|
||||
</property>
|
||||
<property name="default">
|
||||
|
@ -376,7 +331,7 @@ subcontrol-position: bottom right;
|
|||
<string/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap>:/images/ledoff1.png</pixmap>
|
||||
<pixmap resource="images.qrc">:/images/ledoff1.png</pixmap>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -409,7 +364,7 @@ subcontrol-position: bottom right;
|
|||
<string/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap>:/images/ledoff1.png</pixmap>
|
||||
<pixmap resource="images.qrc">:/images/ledoff1.png</pixmap>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -442,7 +397,7 @@ subcontrol-position: bottom right;
|
|||
<string/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap>:/images/ledoff1.png</pixmap>
|
||||
<pixmap resource="images.qrc">:/images/ledoff1.png</pixmap>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -570,7 +525,7 @@ subcontrol-position: bottom right;
|
|||
</action>
|
||||
<action name="actionAddFriend">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<iconset resource="images.qrc">
|
||||
<normaloff>:/images/user/add_user16.png</normaloff>:/images/user/add_user16.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
|
@ -584,7 +539,7 @@ subcontrol-position: bottom right;
|
|||
</action>
|
||||
<action name="actionExportKey">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<iconset resource="images.qrc">
|
||||
<normaloff>:/images/exportpeers_16x16.png</normaloff>:/images/exportpeers_16x16.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
|
@ -600,6 +555,15 @@ subcontrol-position: bottom right;
|
|||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources/>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>LineEditClear</class>
|
||||
<extends>QLineEdit</extends>
|
||||
<header>gui/common/LineEditClear.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="images.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
|
|
@ -96,7 +96,6 @@ SearchDialog::SearchDialog(QWidget *parent)
|
|||
|
||||
_queueIsAlreadyTakenCareOf = false ;
|
||||
ui.lineEdit->setFocus();
|
||||
ui.lineEdit->setToolTip(tr("Enter a keyword here (at least 3 char long)"));
|
||||
|
||||
/* initialise the filetypes mapping */
|
||||
if (!SearchDialog::initialised)
|
||||
|
@ -115,8 +114,6 @@ SearchDialog::SearchDialog(QWidget *parent)
|
|||
connect( ui.pushButtonsearch, SIGNAL( released ( void ) ), this, SLOT( searchKeywords( void ) ) );
|
||||
connect( ui.pushButtonDownload, SIGNAL( released ( void ) ), this, SLOT( download( void ) ) );
|
||||
connect( ui.cloaseallsearchresultsButton, SIGNAL(clicked()), this, SLOT(searchRemoveAll()));
|
||||
connect( ui.resetButton, SIGNAL(clicked()), this, SLOT(clearKeyword()));
|
||||
connect( ui.lineEdit, SIGNAL( textChanged(const QString &)), this, SLOT(togglereset()));
|
||||
|
||||
connect( ui.searchResultWidget, SIGNAL( itemDoubleClicked ( QTreeWidgetItem *, int)), this, SLOT(download()));
|
||||
|
||||
|
@ -125,9 +122,8 @@ SearchDialog::SearchDialog(QWidget *parent)
|
|||
|
||||
connect(ui.FileTypeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(selectSearchResults(int)));
|
||||
|
||||
connect( ui.filterPatternLineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(filterRegExpChanged()));
|
||||
connect(ui.filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterItems(QString)));
|
||||
connect( ui.filterColumnComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(filterColumnChanged()));
|
||||
connect( ui.clearButton, SIGNAL(clicked()), this, SLOT(clearFilter()));
|
||||
|
||||
/* hide the Tree +/- */
|
||||
ui.searchResultWidget -> setRootIsDecorated( true );
|
||||
|
@ -175,9 +171,6 @@ SearchDialog::SearchDialog(QWidget *parent)
|
|||
|
||||
ui.searchResultWidget->sortItems(SR_NAME_COL, Qt::AscendingOrder);
|
||||
|
||||
ui.resetButton->hide();
|
||||
ui.clearButton->hide();
|
||||
|
||||
/* Set initial size the splitter */
|
||||
QList<int> sizes;
|
||||
sizes << 250 << width(); // Qt calculates the right sizes
|
||||
|
@ -487,13 +480,6 @@ void SearchDialog::searchRemoveAll()
|
|||
nextSearchId = 1;
|
||||
}
|
||||
|
||||
/** clear keywords and ComboBox **/
|
||||
void SearchDialog::clearKeyword()
|
||||
{
|
||||
ui.lineEdit->clear();
|
||||
ui.lineEdit->setFocus();
|
||||
}
|
||||
|
||||
void SearchDialog::copySearchLink()
|
||||
{
|
||||
/* get the current search id from the summary window */
|
||||
|
@ -870,8 +856,8 @@ void SearchDialog::insertDirectory(const std::string &txt, qulonglong searchId,
|
|||
}
|
||||
}
|
||||
|
||||
if (ui.filterPatternLineEdit->text().isEmpty() == false) {
|
||||
FilterItems();
|
||||
if (ui.filterLineEdit->text().isEmpty() == false) {
|
||||
filterItems(ui.filterLineEdit->text());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -924,8 +910,8 @@ void SearchDialog::insertDirectory(const std::string &txt, qulonglong searchId,
|
|||
|
||||
selectSearchResults();
|
||||
|
||||
if (ui.filterPatternLineEdit->text().isEmpty() == false) {
|
||||
FilterItems();
|
||||
if (ui.filterLineEdit->text().isEmpty() == false) {
|
||||
filterItems(ui.filterLineEdit->text());
|
||||
}
|
||||
// TODO: check for duplicate directories
|
||||
}
|
||||
|
@ -1147,8 +1133,8 @@ void SearchDialog::insertFile(const std::string& txt,qulonglong searchId, const
|
|||
/* select this search result */
|
||||
selectSearchResults();
|
||||
|
||||
if (ui.filterPatternLineEdit->text().isEmpty() == false) {
|
||||
FilterItems();
|
||||
if (ui.filterLineEdit->text().isEmpty() == false) {
|
||||
filterItems(ui.filterLineEdit->text());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1222,7 +1208,7 @@ void SearchDialog::selectSearchResults(int index)
|
|||
}
|
||||
}
|
||||
ui.searchResultWidget->update();
|
||||
ui.filterPatternLineEdit->clear();
|
||||
ui.filterLineEdit->clear();
|
||||
}
|
||||
|
||||
void SearchDialog::setIconAndType(QTreeWidgetItem *item, const QString& filename)
|
||||
|
@ -1282,21 +1268,6 @@ void SearchDialog::sendLinkTo( )
|
|||
/* window will destroy itself! */
|
||||
}
|
||||
|
||||
void SearchDialog::togglereset()
|
||||
{
|
||||
QString text = ui.lineEdit->text();
|
||||
|
||||
if (text.isEmpty())
|
||||
{
|
||||
ui.resetButton->hide();
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.resetButton->show();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// not in use for the moment
|
||||
void SearchDialog::onComboIndexChanged(int index)
|
||||
{
|
||||
|
@ -1359,69 +1330,44 @@ void SearchDialog::onComboIndexChanged(int index)
|
|||
}
|
||||
}
|
||||
|
||||
/* clear Filter */
|
||||
void SearchDialog::clearFilter()
|
||||
{
|
||||
ui.filterPatternLineEdit->clear();
|
||||
ui.filterPatternLineEdit->setFocus();
|
||||
}
|
||||
|
||||
void SearchDialog::filterRegExpChanged()
|
||||
{
|
||||
|
||||
QString text = ui.filterPatternLineEdit->text();
|
||||
|
||||
if (text.isEmpty()) {
|
||||
ui.clearButton->hide();
|
||||
} else {
|
||||
ui.clearButton->show();
|
||||
}
|
||||
|
||||
FilterItems();
|
||||
}
|
||||
|
||||
void SearchDialog::filterColumnChanged()
|
||||
{
|
||||
|
||||
FilterItems();
|
||||
|
||||
filterItems(ui.filterLineEdit->text());
|
||||
}
|
||||
|
||||
void SearchDialog::FilterItems()
|
||||
void SearchDialog::filterItems(const QString &text)
|
||||
{
|
||||
QString sPattern = ui.filterPatternLineEdit->text();
|
||||
int nFilterColumn = FilterColumnFromComboBox(ui.filterColumnComboBox->currentIndex());
|
||||
int filterColumn = FilterColumnFromComboBox(ui.filterColumnComboBox->currentIndex());
|
||||
|
||||
int nCount = ui.searchResultWidget->topLevelItemCount ();
|
||||
for (int nIndex = 0; nIndex < nCount; nIndex++) {
|
||||
FilterItem(ui.searchResultWidget->topLevelItem(nIndex), sPattern, nFilterColumn);
|
||||
int count = ui.searchResultWidget->topLevelItemCount ();
|
||||
for (int index = 0; index < count; index++) {
|
||||
filterItem(ui.searchResultWidget->topLevelItem(index), text, filterColumn);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool SearchDialog::FilterItem(QTreeWidgetItem *pItem, QString &sPattern, int nFilterColumn)
|
||||
bool SearchDialog::filterItem(QTreeWidgetItem *item, const QString &text, int filterColumn)
|
||||
{
|
||||
bool bVisible = true;
|
||||
bool visible = true;
|
||||
|
||||
if (sPattern.isEmpty() == false) {
|
||||
if (pItem->text(nFilterColumn).contains(sPattern, Qt::CaseInsensitive) == false) {
|
||||
bVisible = false;
|
||||
if (text.isEmpty() == false) {
|
||||
if (item->text(filterColumn).contains(text, Qt::CaseInsensitive) == false) {
|
||||
visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
int nVisibleChildCount = 0;
|
||||
int nCount = pItem->childCount();
|
||||
for (int nIndex = 0; nIndex < nCount; nIndex++) {
|
||||
if (FilterItem(pItem->child(nIndex), sPattern, nFilterColumn)) {
|
||||
nVisibleChildCount++;
|
||||
int visibleChildCount = 0;
|
||||
int count = item->childCount();
|
||||
for (int index = 0; index < count; index++) {
|
||||
if (filterItem(item->child(index), text, filterColumn)) {
|
||||
visibleChildCount++;
|
||||
}
|
||||
}
|
||||
|
||||
if (bVisible || nVisibleChildCount) {
|
||||
pItem->setHidden(false);
|
||||
if (visible || visibleChildCount) {
|
||||
item->setHidden(false);
|
||||
} else {
|
||||
pItem->setHidden(true);
|
||||
item->setHidden(true);
|
||||
}
|
||||
|
||||
return (bVisible || nVisibleChildCount);
|
||||
return (visible || visibleChildCount);
|
||||
}
|
||||
|
|
|
@ -81,19 +81,12 @@ private slots:
|
|||
|
||||
void selectSearchResults(int index = -1);
|
||||
|
||||
void clearKeyword();
|
||||
|
||||
void sendLinkTo();
|
||||
|
||||
void togglereset();
|
||||
|
||||
void onComboIndexChanged(int index);
|
||||
|
||||
void filterColumnChanged();
|
||||
void filterRegExpChanged();
|
||||
void clearFilter();
|
||||
|
||||
|
||||
void filterItems(const QString &text);
|
||||
|
||||
private:
|
||||
/** render the results to the tree widget display */
|
||||
|
@ -106,8 +99,6 @@ private:
|
|||
void downloadDirectory(const QTreeWidgetItem *item, const QString &base);
|
||||
void getSourceFriendsForHash(const std::string& hash,std::list<std::string>& srcIds);
|
||||
|
||||
|
||||
|
||||
/** the advanced search dialog instance */
|
||||
AdvancedSearchDialog * advSearchDialog;
|
||||
|
||||
|
@ -129,8 +120,7 @@ private:
|
|||
|
||||
void processSettings(bool bLoad);
|
||||
|
||||
void FilterItems();
|
||||
bool FilterItem(QTreeWidgetItem *pItem, QString &sPattern, int nFilterColumn);
|
||||
bool filterItem(QTreeWidgetItem *item, const QString &text, int filterColumn);
|
||||
|
||||
bool m_bProcessSettings;
|
||||
|
||||
|
|
|
@ -726,7 +726,7 @@ background: white;}</string>
|
|||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="lineEdit">
|
||||
<widget class="LineEditClear" name="lineEdit">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>3</horstretch>
|
||||
|
@ -739,14 +739,8 @@ background: white;}</string>
|
|||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>1677777</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Enter a Keyword here</string>
|
||||
<string>Enter a keyword here (at least 3 char long)</string>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QLineEdit#lineEdit{background: transparent;
|
||||
|
@ -755,46 +749,6 @@ border: none;}
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QPushButton" name="resetButton">
|
||||
<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="focusPolicy">
|
||||
<enum>Qt::NoFocus</enum>
|
||||
</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>
|
||||
<item row="0" column="0">
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="sizePolicy">
|
||||
|
@ -1023,7 +977,7 @@ border-image: url(:/images/btn_26_pressed.png) 4;
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="filterPatternLineEdit">
|
||||
<widget class="LineEditClear" name="filterLineEdit">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
|
@ -1035,51 +989,6 @@ border-image: url(:/images/btn_26_pressed.png) 4;
|
|||
</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="focusPolicy">
|
||||
<enum>Qt::NoFocus</enum>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Clear Filter</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>
|
||||
|
@ -1433,6 +1342,11 @@ border: 2px solid #CCCCCC;}</string>
|
|||
<extends>QTreeWidget</extends>
|
||||
<header>gui/SearchTreeWidget.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>LineEditClear</class>
|
||||
<extends>QLineEdit</extends>
|
||||
<header>gui/common/LineEditClear.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="images.qrc"/>
|
||||
|
|
|
@ -1806,12 +1806,12 @@ void FriendList::setBigName(bool bigName)
|
|||
/**
|
||||
* Hides all items that don't contain sPattern in the name column.
|
||||
*/
|
||||
void FriendList::filterItems(const QString &sPattern)
|
||||
void FriendList::filterItems(const QString &text)
|
||||
{
|
||||
filterText = sPattern;
|
||||
int nCount = ui->peerTreeWidget->topLevelItemCount();
|
||||
for (int nIndex = 0; nIndex < nCount; nIndex++) {
|
||||
FriendList::filterItem(ui->peerTreeWidget->topLevelItem(nIndex), sPattern);
|
||||
filterText = text;
|
||||
int count = ui->peerTreeWidget->topLevelItemCount();
|
||||
for (int index = 0; index < count; index++) {
|
||||
FriendList::filterItem(ui->peerTreeWidget->topLevelItem(index), filterText);
|
||||
}
|
||||
|
||||
QTreeWidgetItem *c = getCurrentPeer();
|
||||
|
@ -1821,31 +1821,31 @@ void FriendList::filterItems(const QString &sPattern)
|
|||
}
|
||||
}
|
||||
|
||||
bool FriendList::filterItem(QTreeWidgetItem *pItem, const QString &sPattern)
|
||||
bool FriendList::filterItem(QTreeWidgetItem *item, const QString &text)
|
||||
{
|
||||
bool bVisible = true;
|
||||
bool visible = true;
|
||||
|
||||
if (sPattern.isEmpty() == false) {
|
||||
if (pItem->text(0).contains(sPattern, Qt::CaseInsensitive) == false) {
|
||||
bVisible = false;
|
||||
if (text.isEmpty() == false) {
|
||||
if (item->text(0).contains(text, Qt::CaseInsensitive) == false) {
|
||||
visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
int nVisibleChildCount = 0;
|
||||
int nCount = pItem->childCount();
|
||||
for (int nIndex = 0; nIndex < nCount; nIndex++) {
|
||||
if (FriendList::filterItem(pItem->child(nIndex), sPattern)) {
|
||||
nVisibleChildCount++;
|
||||
int visibleChildCount = 0;
|
||||
int count = item->childCount();
|
||||
for (int index = 0; index < count; index++) {
|
||||
if (FriendList::filterItem(item->child(index), text)) {
|
||||
visibleChildCount++;
|
||||
}
|
||||
}
|
||||
|
||||
if (bVisible || nVisibleChildCount) {
|
||||
pItem->setHidden(false);
|
||||
if (visible || visibleChildCount) {
|
||||
item->setHidden(false);
|
||||
} else {
|
||||
pItem->setHidden(true);
|
||||
item->setHidden(true);
|
||||
}
|
||||
|
||||
return (bVisible || nVisibleChildCount);
|
||||
return (visible || visibleChildCount);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -56,7 +56,7 @@ public:
|
|||
virtual void updateDisplay();
|
||||
|
||||
public slots:
|
||||
void filterItems(const QString &sPattern);
|
||||
void filterItems(const QString &text);
|
||||
|
||||
void setBigName(bool bigName); // show customStateString in second line of the name cell
|
||||
void setShowGroups(bool show);
|
||||
|
@ -89,7 +89,7 @@ private:
|
|||
std::set<std::string> *openPeers;
|
||||
|
||||
QTreeWidgetItem *getCurrentPeer() const;
|
||||
static bool filterItem(QTreeWidgetItem *pItem, const QString &sPattern);
|
||||
static bool filterItem(QTreeWidgetItem *item, const QString &text);
|
||||
void updateHeader();
|
||||
void initializeHeader(bool afterLoadSettings);
|
||||
void getSslIdsFromItem(QTreeWidgetItem *item, std::list<std::string> &sslIds);
|
||||
|
|
|
@ -85,8 +85,7 @@ FriendSelectionWidget::FriendSelectionWidget(QWidget *parent) :
|
|||
connect(ui->friendList, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuRequested(QPoint)));
|
||||
connect(ui->friendList, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), this, SLOT(itemDoubleClicked(QTreeWidgetItem*,int)));
|
||||
connect(ui->friendList, SIGNAL(itemChanged(QTreeWidgetItem*,int)), this, SLOT(itemChanged(QTreeWidgetItem*,int)));
|
||||
connect(ui->filterEdit, SIGNAL(textChanged(const QString &)), this, SLOT(filterChanged()));
|
||||
connect(ui->clearButton, SIGNAL(clicked()), this, SLOT(clearFilter()));
|
||||
connect(ui->filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterItems(QString)));
|
||||
|
||||
connect(NotifyQt::getInstance(), SIGNAL(groupsChanged(int)), this, SLOT(fillList()));
|
||||
connect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(const QString&,int)), this, SLOT(peerStatusChanged(const QString&,int)));
|
||||
|
@ -94,8 +93,6 @@ FriendSelectionWidget::FriendSelectionWidget(QWidget *parent) :
|
|||
compareRole = new RSTreeWidgetItemCompareRole;
|
||||
compareRole->setRole(COLUMN_NAME, ROLE_SORT);
|
||||
|
||||
ui->clearButton->hide();
|
||||
|
||||
// sort list by name ascending
|
||||
ui->friendList->sortItems(COLUMN_NAME, Qt::AscendingOrder);
|
||||
}
|
||||
|
@ -285,8 +282,8 @@ void FriendSelectionWidget::fillList()
|
|||
}
|
||||
}
|
||||
|
||||
if (ui->filterEdit->text().isEmpty() == false) {
|
||||
filterItems();
|
||||
if (ui->filterLineEdit->text().isEmpty() == false) {
|
||||
filterItems(ui->filterLineEdit->text());
|
||||
}
|
||||
|
||||
ui->friendList->update(); /* update display */
|
||||
|
@ -384,26 +381,11 @@ void FriendSelectionWidget::itemChanged(QTreeWidgetItem *item, int column)
|
|||
inItemChanged = false;
|
||||
}
|
||||
|
||||
void FriendSelectionWidget::clearFilter()
|
||||
{
|
||||
ui->filterEdit->clear();
|
||||
ui->filterEdit->setFocus();
|
||||
}
|
||||
|
||||
void FriendSelectionWidget::filterChanged()
|
||||
{
|
||||
QString text = ui->filterEdit->text();
|
||||
|
||||
ui->clearButton->setVisible(!text.isEmpty());
|
||||
|
||||
filterItems();
|
||||
}
|
||||
|
||||
void FriendSelectionWidget::filterItems()
|
||||
void FriendSelectionWidget::filterItems(const QString& text)
|
||||
{
|
||||
int count = ui->friendList->topLevelItemCount();
|
||||
for (int index = 0; index < count; index++) {
|
||||
filterItem(ui->friendList->topLevelItem(index),ui->filterEdit->text());
|
||||
filterItem(ui->friendList->topLevelItem(index), text);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -76,14 +76,12 @@ signals:
|
|||
private slots:
|
||||
void fillList();
|
||||
void peerStatusChanged(const QString& peerId, int status);
|
||||
void filterChanged();
|
||||
void clearFilter();
|
||||
void filterItems(const QString &text);
|
||||
void contextMenuRequested(const QPoint &pos);
|
||||
void itemDoubleClicked(QTreeWidgetItem *item, int column);
|
||||
void itemChanged(QTreeWidgetItem *item, int column);
|
||||
|
||||
private:
|
||||
void filterItems();
|
||||
bool filterItem(QTreeWidgetItem *item, const QString &text);
|
||||
|
||||
void selectedIds(IdType idType, std::list<std::string> &ids, bool onlyDirectSelected);
|
||||
|
|
|
@ -33,57 +33,12 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLineEdit" name="filterEdit">
|
||||
<widget class="LineEditClear" name="filterLineEdit">
|
||||
<property name="toolTip">
|
||||
<string>Search Friends</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="focusPolicy">
|
||||
<enum>Qt::NoFocus</enum>
|
||||
</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>
|
||||
|
@ -118,6 +73,13 @@ border-image: url(:/images/closepressed.png)
|
|||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>LineEditClear</class>
|
||||
<extends>QLineEdit</extends>
|
||||
<header>gui/common/LineEditClear.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
****************************************************************/
|
||||
|
||||
#include <QMenu>
|
||||
#include <QPushButton>
|
||||
|
||||
#include "GroupTreeWidget.h"
|
||||
#include "ui_GroupTreeWidget.h"
|
||||
|
@ -62,8 +63,7 @@ GroupTreeWidget::GroupTreeWidget(QWidget *parent) :
|
|||
compareRole->setRole(COLUMN_DATA, ROLE_NAME);
|
||||
|
||||
/* Connect signals */
|
||||
connect(ui->clearFilter, SIGNAL(clicked()), this, SLOT(clearFilter()));
|
||||
connect(ui->filterText, SIGNAL(textChanged(const QString &)), this, SLOT(filterChanged()));
|
||||
connect(ui->filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterChanged()));
|
||||
connect(ui->filterCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(filterChanged()));
|
||||
|
||||
connect(ui->treeWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(customContextMenuRequested(QPoint)));
|
||||
|
@ -83,9 +83,6 @@ GroupTreeWidget::GroupTreeWidget(QWidget *parent) :
|
|||
header->resizeSection(COLUMN_NAME, 170);
|
||||
header->setResizeMode(COLUMN_POPULARITY, QHeaderView::Fixed);
|
||||
header->resizeSection(COLUMN_POPULARITY, 25);
|
||||
|
||||
/* Initialize filter */
|
||||
ui->clearFilter->hide();
|
||||
}
|
||||
|
||||
GroupTreeWidget::~GroupTreeWidget()
|
||||
|
@ -239,6 +236,8 @@ void GroupTreeWidget::fillGroupItems(QTreeWidgetItem *categoryItem, const QList<
|
|||
return;
|
||||
}
|
||||
|
||||
QString filterText = ui->filterLineEdit->text();
|
||||
|
||||
/* Iterate all items */
|
||||
QList<GroupItemInfo>::const_iterator it;
|
||||
for (it = itemList.begin(); it != itemList.end(); it++) {
|
||||
|
@ -294,7 +293,7 @@ void GroupTreeWidget::fillGroupItems(QTreeWidgetItem *categoryItem, const QList<
|
|||
item->setForeground(COLUMN_NAME, brush);
|
||||
|
||||
/* Calculate score */
|
||||
calculateScore(item);
|
||||
calculateScore(item, filterText);
|
||||
}
|
||||
|
||||
/* Remove all items not in list */
|
||||
|
@ -377,11 +376,10 @@ QTreeWidgetItem *GroupTreeWidget::activateId(const QString &id, bool focus)
|
|||
return item;
|
||||
}
|
||||
|
||||
void GroupTreeWidget::calculateScore(QTreeWidgetItem *item)
|
||||
void GroupTreeWidget::calculateScore(QTreeWidgetItem *item, const QString &filterText)
|
||||
{
|
||||
if (item) {
|
||||
/* Calculate one item */
|
||||
QString filterText = ui->filterText->text();
|
||||
int score;
|
||||
if (filterText.isEmpty()) {
|
||||
score = 0;
|
||||
|
@ -422,34 +420,14 @@ void GroupTreeWidget::calculateScore(QTreeWidgetItem *item)
|
|||
continue;
|
||||
}
|
||||
|
||||
calculateScore(item);
|
||||
calculateScore(item, filterText);
|
||||
}
|
||||
}
|
||||
|
||||
void GroupTreeWidget::filterChanged()
|
||||
{
|
||||
if (ui->filterText->text().isEmpty()) {
|
||||
clearFilter();
|
||||
return;
|
||||
}
|
||||
|
||||
ui->clearFilter->setEnabled(true);
|
||||
ui->clearFilter->show();
|
||||
|
||||
/* Recalculate score */
|
||||
calculateScore(NULL);
|
||||
|
||||
resort(NULL);
|
||||
}
|
||||
|
||||
void GroupTreeWidget::clearFilter()
|
||||
{
|
||||
ui->filterText->clear();
|
||||
ui->clearFilter->hide();
|
||||
ui->filterText->setFocus();
|
||||
|
||||
/* Recalculate score */
|
||||
calculateScore(NULL);
|
||||
calculateScore(NULL, ui->filterLineEdit->text());
|
||||
|
||||
resort(NULL);
|
||||
}
|
||||
|
@ -458,7 +436,7 @@ void GroupTreeWidget::resort(QTreeWidgetItem *categoryItem)
|
|||
{
|
||||
Qt::SortOrder order = (actionSortAscending == NULL || actionSortAscending->isChecked()) ? Qt::AscendingOrder : Qt::DescendingOrder;
|
||||
|
||||
if (ui->filterText->text().isEmpty() == false) {
|
||||
if (ui->filterLineEdit->text().isEmpty() == false) {
|
||||
compareRole->setRole(COLUMN_DATA, ROLE_SEARCH_SCORE);
|
||||
compareRole->addRole(COLUMN_DATA, ROLE_LASTPOST);
|
||||
} else if (actionSortByName && actionSortByName->isChecked()) {
|
||||
|
|
|
@ -90,12 +90,11 @@ private slots:
|
|||
void customContextMenuRequested(const QPoint &pos);
|
||||
void currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous);
|
||||
void filterChanged();
|
||||
void clearFilter();
|
||||
|
||||
void sort();
|
||||
|
||||
private:
|
||||
void calculateScore(QTreeWidgetItem *item);
|
||||
void calculateScore(QTreeWidgetItem *item, const QString &filterText);
|
||||
void resort(QTreeWidgetItem *categoryItem);
|
||||
|
||||
private:
|
||||
|
|
|
@ -94,36 +94,19 @@ border: 1px solid #CCCCCC;}
|
|||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLineEdit" name="filterText">
|
||||
<widget class="LineEditClear" name="filterLineEdit">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>3</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>1677777</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Enter a Keyword here</string>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QLineEdit#searchLine{
|
||||
border: none;}
|
||||
</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<item row="0" column="2">
|
||||
<widget class="QComboBox" name="filterCombo">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
|
@ -143,46 +126,6 @@ border: none;}
|
|||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QPushButton" name="clearFilter">
|
||||
<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="focusPolicy">
|
||||
<enum>Qt::NoFocus</enum>
|
||||
</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>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -225,12 +168,6 @@ border-image: url(:/images/closepressed.png)
|
|||
<attribute name="headerStretchLastSection">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<attribute name="headerVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<attribute name="headerStretchLastSection">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string notr="true">1</string>
|
||||
|
@ -240,6 +177,13 @@ border-image: url(:/images/closepressed.png)
|
|||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>LineEditClear</class>
|
||||
<extends>QLineEdit</extends>
|
||||
<header>gui/common/LineEditClear.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
|
60
retroshare-gui/src/gui/common/LineEditClear.cpp
Normal file
60
retroshare-gui/src/gui/common/LineEditClear.cpp
Normal file
|
@ -0,0 +1,60 @@
|
|||
/****************************************************************
|
||||
*
|
||||
* RetroShare is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2012, RetroShare Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
#include "LineEditClear.h"
|
||||
|
||||
#include <QToolButton>
|
||||
#include <QStyle>
|
||||
|
||||
LineEditClear::LineEditClear(QWidget *parent)
|
||||
: QLineEdit(parent)
|
||||
{
|
||||
clearButton = new QToolButton(this);
|
||||
clearButton->setFixedSize(16, 16);
|
||||
clearButton->setIconSize(QSize(16, 16));
|
||||
clearButton->setCursor(Qt::ArrowCursor);
|
||||
clearButton->setStyleSheet("QToolButton { border: none; padding: 0px; }"
|
||||
"QToolButton { border-image: url(:/images/closenormal.png) }"
|
||||
"QToolButton:hover { border-image: url(:/images/closehover.png) }"
|
||||
"QToolButton:pressed { border-image: url(:/images/closepressed.png) }");
|
||||
clearButton->hide();
|
||||
|
||||
connect(clearButton, SIGNAL(clicked()), this, SLOT(clear()));
|
||||
connect(this, SIGNAL(textChanged(const QString&)), this, SLOT(updateCloseButton(const QString&)));
|
||||
|
||||
int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
|
||||
setStyleSheet(QString("QLineEdit { padding-right: %1px; } ").arg(clearButton->sizeHint().width() + frameWidth + 1));
|
||||
QSize msz = minimumSizeHint();
|
||||
setMinimumSize(qMax(msz.width(), clearButton->sizeHint().height() + frameWidth * 2), qMax(msz.height(), clearButton->sizeHint().height() + frameWidth * 2));
|
||||
}
|
||||
|
||||
void LineEditClear::resizeEvent(QResizeEvent *)
|
||||
{
|
||||
QSize sz = clearButton->sizeHint();
|
||||
int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
|
||||
clearButton->move(rect().right() - frameWidth - sz.width() + 2, (rect().bottom() - sz.height()) / 2 + 2);
|
||||
}
|
||||
|
||||
void LineEditClear::updateCloseButton(const QString& text)
|
||||
{
|
||||
clearButton->setVisible(!text.isEmpty());
|
||||
}
|
47
retroshare-gui/src/gui/common/LineEditClear.h
Normal file
47
retroshare-gui/src/gui/common/LineEditClear.h
Normal file
|
@ -0,0 +1,47 @@
|
|||
/****************************************************************
|
||||
*
|
||||
* RetroShare is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2012, RetroShare Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
#ifndef LINEEDITCLEAR_H
|
||||
#define LINEEDITCLEAR_H
|
||||
|
||||
#include <QLineEdit>
|
||||
|
||||
class QToolButton;
|
||||
|
||||
class LineEditClear : public QLineEdit
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
LineEditClear(QWidget *parent = 0);
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *);
|
||||
|
||||
private slots:
|
||||
void updateCloseButton(const QString &text);
|
||||
|
||||
private:
|
||||
QToolButton *clearButton;
|
||||
};
|
||||
|
||||
#endif // LINEEDITCLEAR_H
|
|
@ -102,8 +102,7 @@ ImHistoryBrowser::ImHistoryBrowser(const std::string &peerId, QTextEdit *edit, Q
|
|||
|
||||
connect(NotifyQt::getInstance(), SIGNAL(historyChanged(uint, int)), this, SLOT(historyChanged(uint, int)));
|
||||
|
||||
connect(ui.clearFilterButton, SIGNAL(clicked()), this, SLOT(clearFilter()));
|
||||
connect(ui.filterPatternLineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(filterRegExpChanged()));
|
||||
connect(ui.filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterChanged(QString)));
|
||||
|
||||
connect(ui.copyButton, SIGNAL(clicked()), SLOT(copyMessage()));
|
||||
connect(ui.removeButton, SIGNAL(clicked()), SLOT(removeMessages()));
|
||||
|
@ -111,8 +110,6 @@ ImHistoryBrowser::ImHistoryBrowser(const std::string &peerId, QTextEdit *edit, Q
|
|||
connect(ui.listWidget, SIGNAL(itemSelectionChanged()), this, SLOT(itemSelectionChanged()));
|
||||
connect(ui.listWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(customContextMenuRequested(QPoint)));
|
||||
|
||||
ui.clearFilterButton->hide();
|
||||
|
||||
// embed smileys ?
|
||||
if (m_isPrivateChat) {
|
||||
embedSmileys = Settings->valueFromGroup("Chat", "Emoteicons_PrivatChat", true).toBool();
|
||||
|
@ -166,7 +163,7 @@ void ImHistoryBrowser::createThreadFinished()
|
|||
// clear list
|
||||
m_createThread->m_items.clear();
|
||||
|
||||
filterRegExpChanged();
|
||||
filterChanged(ui.filterLineEdit->text());
|
||||
|
||||
// dummy call for set buttons
|
||||
itemSelectionChanged();
|
||||
|
@ -217,7 +214,7 @@ void ImHistoryBrowser::historyAdd(HistoryMsg& msg)
|
|||
QListWidgetItem *itemWidget = createItem(msg);
|
||||
if (itemWidget) {
|
||||
ui.listWidget->addItem(itemWidget);
|
||||
filterItems(itemWidget);
|
||||
filterItems(ui.filterLineEdit->text(), itemWidget);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -290,29 +287,13 @@ QListWidgetItem *ImHistoryBrowser::createItem(HistoryMsg& msg)
|
|||
return itemWidget;
|
||||
}
|
||||
|
||||
void ImHistoryBrowser::filterRegExpChanged()
|
||||
void ImHistoryBrowser::filterChanged(const QString &text)
|
||||
{
|
||||
QString text = ui.filterPatternLineEdit->text();
|
||||
|
||||
if (text.isEmpty()) {
|
||||
ui.clearFilterButton->hide();
|
||||
} else {
|
||||
ui.clearFilterButton->show();
|
||||
}
|
||||
|
||||
filterItems();
|
||||
filterItems(text);
|
||||
}
|
||||
|
||||
void ImHistoryBrowser::clearFilter()
|
||||
void ImHistoryBrowser::filterItems(const QString &text, QListWidgetItem *item)
|
||||
{
|
||||
ui.filterPatternLineEdit->clear();
|
||||
ui.filterPatternLineEdit->setFocus();
|
||||
}
|
||||
|
||||
void ImHistoryBrowser::filterItems(QListWidgetItem *item)
|
||||
{
|
||||
QString text = ui.filterPatternLineEdit->text();
|
||||
|
||||
if (item == NULL) {
|
||||
int count = ui.listWidget->count();
|
||||
for (int i = 0; i < count; i++) {
|
||||
|
|
|
@ -56,8 +56,7 @@ private slots:
|
|||
|
||||
void historyChanged(uint msgId, int type);
|
||||
|
||||
void filterRegExpChanged();
|
||||
void clearFilter();
|
||||
void filterChanged(const QString& text);
|
||||
|
||||
void itemSelectionChanged();
|
||||
void customContextMenuRequested(QPoint pos);
|
||||
|
@ -73,7 +72,7 @@ private:
|
|||
|
||||
QListWidgetItem *createItem(HistoryMsg& msg);
|
||||
void fillItem(QListWidgetItem *itemWidget, HistoryMsg& msg);
|
||||
void filterItems(QListWidgetItem *item = NULL);
|
||||
void filterItems(const QString &text, QListWidgetItem *item = NULL);
|
||||
|
||||
void getSelectedItems(std::list<uint32_t> &items);
|
||||
|
||||
|
|
|
@ -134,44 +134,7 @@ border: 1px solid #CCCCCC;}</string>
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="filterPatternLineEdit"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="clearFilterButton">
|
||||
<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="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>
|
||||
<widget class="LineEditClear" name="filterLineEdit"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
|
@ -300,6 +263,13 @@ border-image: url(:/images/closepressed.png)
|
|||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>LineEditClear</class>
|
||||
<extends>QLineEdit</extends>
|
||||
<header>gui/common/LineEditClear.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../images.qrc"/>
|
||||
</resources>
|
||||
|
|
|
@ -42,11 +42,9 @@ SoundPage::SoundPage(QWidget * parent, Qt::WFlags flags)
|
|||
|
||||
connect(ui.eventTreeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)), this, SLOT(eventChanged(QTreeWidgetItem*, QTreeWidgetItem*)));
|
||||
connect(ui.filenameEdit, SIGNAL(textChanged(QString)), this, SLOT(filenameChanged(QString)));
|
||||
connect(ui.clearButton, SIGNAL(clicked()), this, SLOT(clearButtonClicked()));
|
||||
connect(ui.browseButton, SIGNAL(clicked()), this, SLOT(browseButtonClicked()));
|
||||
connect(ui.playButton, SIGNAL(clicked()), this, SLOT(playButtonClicked()));
|
||||
|
||||
ui.clearButton->hide();
|
||||
ui.eventTreeWidget->setColumnCount(COLUMN_COUNT);
|
||||
|
||||
QTreeWidgetItem *headerItem = ui.eventTreeWidget->headerItem();
|
||||
|
@ -147,7 +145,6 @@ void SoundPage::eventChanged(QTreeWidgetItem *current, QTreeWidgetItem */*previo
|
|||
void SoundPage::filenameChanged(QString filename)
|
||||
{
|
||||
ui.playButton->setEnabled(!filename.isEmpty());
|
||||
ui.clearButton->setVisible(!filename.isEmpty());
|
||||
|
||||
QTreeWidgetItem *item = ui.eventTreeWidget->currentItem();
|
||||
if (item) {
|
||||
|
@ -155,11 +152,6 @@ void SoundPage::filenameChanged(QString filename)
|
|||
}
|
||||
}
|
||||
|
||||
void SoundPage::clearButtonClicked()
|
||||
{
|
||||
ui.filenameEdit->clear();
|
||||
}
|
||||
|
||||
void SoundPage::browseButtonClicked()
|
||||
{
|
||||
QString filename;
|
||||
|
|
|
@ -49,7 +49,6 @@ public:
|
|||
private slots:
|
||||
void eventChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous);
|
||||
void filenameChanged(QString filename);
|
||||
void clearButtonClicked();
|
||||
void browseButtonClicked();
|
||||
void playButtonClicked();
|
||||
|
||||
|
|
|
@ -517,56 +517,7 @@
|
|||
<number>2</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="filenameEdit">
|
||||
<property name="toolTip">
|
||||
<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="focusPolicy">
|
||||
<enum>Qt::NoFocus</enum>
|
||||
</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>
|
||||
<widget class="LineEditClear" name="filenameEdit"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
|
@ -630,6 +581,13 @@ border-image: url(:/images/closepressed.png)
|
|||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>LineEditClear</class>
|
||||
<extends>QLineEdit</extends>
|
||||
<header>gui/common/LineEditClear.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../images.qrc"/>
|
||||
</resources>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue