Added tab for the DHT TreeWidgets for better view

Added a search Filter for DHT IP addresses
This commit is contained in:
defnax 2015-08-07 15:14:47 +02:00
parent fabc3a3985
commit c168765bb2
3 changed files with 655 additions and 554 deletions

View File

@ -41,6 +41,8 @@ DhtWindow::DhtWindow(QWidget *parent)
{
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()
@ -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);
}

View File

@ -42,11 +42,17 @@ public:
public slots:
virtual void updateDisplay() ;
void filterColumnChanged(int);
void filterItems(const QString &text);
protected:
//void changeEvent(QEvent *e);
private:
bool filterItem(QTreeWidgetItem *item, const QString &text, int filterColumn);
/** Qt Designer generated object */
Ui::DhtWindow ui;

View File

@ -23,13 +23,8 @@
<attribute name="title">
<string>DHT</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<widget class="QWidget" name="">
<layout class="QGridLayout" name="gridLayout_6">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_16">
@ -459,7 +454,85 @@
</layout>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QTabWidget" name="tabWidget_2">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tab_3">
<attribute name="title">
<string>DHT</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_2">
<item row="1" column="0">
<widget class="QTreeWidget" name="dhtTreeWidget">
<property name="sortingEnabled">
<bool>true</bool>
</property>
<column>
<property name="text">
<string>Bucket</string>
</property>
</column>
<column>
<property name="text">
<string>IP:Port</string>
</property>
</column>
<column>
<property name="text">
<string>Key</string>
</property>
</column>
<column>
<property name="text">
<string>Status Flags</string>
</property>
</column>
<column>
<property name="text">
<string>Found</string>
</property>
</column>
<column>
<property name="text">
<string>Last Sent</string>
</property>
</column>
<column>
<property name="text">
<string>Last Recv</string>
</property>
</column>
</widget>
</item>
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_19">
<item>
<widget class="QLabel" name="filterLabel">
<property name="text">
<string>Filter:</string>
</property>
</widget>
</item>
<item>
<widget class="LineEditClear" name="filterLineEdit">
<property name="toolTip">
<string>Search Network</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_4">
<attribute name="title">
<string>Peers</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<widget class="QTreeWidget" name="peerTreeWidget">
<property name="sortingEnabled">
<bool>true</bool>
@ -510,46 +583,15 @@
</property>
</column>
</widget>
<widget class="QTreeWidget" name="dhtTreeWidget">
<property name="sortingEnabled">
<bool>true</bool>
</property>
<column>
<property name="text">
<string>Bucket</string>
</property>
</column>
<column>
<property name="text">
<string>IP:Port</string>
</property>
</column>
<column>
<property name="text">
<string>Key</string>
</property>
</column>
<column>
<property name="text">
<string>Status Flags</string>
</property>
</column>
<column>
<property name="text">
<string>Found</string>
</property>
</column>
<column>
<property name="text">
<string>Last Sent</string>
</property>
</column>
<column>
<property name="text">
<string>Last Recv</string>
</property>
</column>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_5">
<attribute name="title">
<string>Relay</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="0">
<widget class="QTreeWidget" name="relayTreeWidget">
<property name="sortingEnabled">
<bool>true</bool>
@ -595,6 +637,9 @@
</property>
</column>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
@ -636,6 +681,11 @@
<header>gui/statistics/dhtgraph.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>LineEditClear</class>
<extends>QLineEdit</extends>
<header location="global">gui/common/LineEditClear.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>