mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Added tab for the DHT TreeWidgets for better view
Added a search Filter for DHT IP addresses
This commit is contained in:
parent
fabc3a3985
commit
c168765bb2
@ -40,7 +40,9 @@ DhtWindow::DhtWindow(QWidget *parent)
|
|||||||
: RsAutoUpdatePage(1000,parent)
|
: RsAutoUpdatePage(1000,parent)
|
||||||
{
|
{
|
||||||
ui.setupUi(this);
|
ui.setupUi(this);
|
||||||
|
|
||||||
|
connect( ui.filterLineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(filterItems(QString)));
|
||||||
|
connect( ui.filterLineEdit, SIGNAL(filterChanged(int)), this, SLOT(filterColumnChanged(int)));
|
||||||
}
|
}
|
||||||
|
|
||||||
DhtWindow::~DhtWindow()
|
DhtWindow::~DhtWindow()
|
||||||
@ -700,3 +702,46 @@ void DhtWindow::getDHTStatus()
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DhtWindow::filterColumnChanged(int)
|
||||||
|
{
|
||||||
|
filterItems(ui.filterLineEdit->text());
|
||||||
|
}
|
||||||
|
|
||||||
|
void DhtWindow::filterItems(const QString &text)
|
||||||
|
{
|
||||||
|
int filterColumn = ui.filterLineEdit->currentFilter();
|
||||||
|
|
||||||
|
int count = ui.dhtTreeWidget->topLevelItemCount ();
|
||||||
|
for (int index = 0; index < count; ++index) {
|
||||||
|
filterItem(ui.dhtTreeWidget->topLevelItem(index), text, filterColumn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DhtWindow::filterItem(QTreeWidgetItem *item, const QString &text, int filterColumn)
|
||||||
|
{
|
||||||
|
bool visible = true;
|
||||||
|
|
||||||
|
if (text.isEmpty() == false) {
|
||||||
|
if (item->text(filterColumn).contains(text, Qt::CaseInsensitive) == false) {
|
||||||
|
visible = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int visibleChildCount = 0;
|
||||||
|
int count = item->childCount();
|
||||||
|
for (int index = 0; index < count; ++index) {
|
||||||
|
if (filterItem(item->child(index), text, filterColumn)) {
|
||||||
|
++visibleChildCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (visible || visibleChildCount) {
|
||||||
|
item->setHidden(false);
|
||||||
|
} else {
|
||||||
|
item->setHidden(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (visible || visibleChildCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -42,11 +42,17 @@ public:
|
|||||||
public slots:
|
public slots:
|
||||||
virtual void updateDisplay() ;
|
virtual void updateDisplay() ;
|
||||||
|
|
||||||
|
void filterColumnChanged(int);
|
||||||
|
void filterItems(const QString &text);
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//void changeEvent(QEvent *e);
|
//void changeEvent(QEvent *e);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
bool filterItem(QTreeWidgetItem *item, const QString &text, int filterColumn);
|
||||||
|
|
||||||
/** Qt Designer generated object */
|
/** Qt Designer generated object */
|
||||||
Ui::DhtWindow ui;
|
Ui::DhtWindow ui;
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user