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); 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);
}

View File

@ -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;

View File

@ -23,13 +23,8 @@
<attribute name="title"> <attribute name="title">
<string>DHT</string> <string>DHT</string>
</attribute> </attribute>
<layout class="QVBoxLayout" name="verticalLayout_3"> <layout class="QGridLayout" name="gridLayout_6">
<item> <item row="0" column="0">
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<widget class="QWidget" name="">
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_16"> <layout class="QHBoxLayout" name="horizontalLayout_16">
@ -459,7 +454,85 @@
</layout> </layout>
</item> </item>
</layout> </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> </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"> <widget class="QTreeWidget" name="peerTreeWidget">
<property name="sortingEnabled"> <property name="sortingEnabled">
<bool>true</bool> <bool>true</bool>
@ -510,46 +583,15 @@
</property> </property>
</column> </column>
</widget> </widget>
<widget class="QTreeWidget" name="dhtTreeWidget"> </item>
<property name="sortingEnabled"> </layout>
<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> </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"> <widget class="QTreeWidget" name="relayTreeWidget">
<property name="sortingEnabled"> <property name="sortingEnabled">
<bool>true</bool> <bool>true</bool>
@ -595,6 +637,9 @@
</property> </property>
</column> </column>
</widget> </widget>
</item>
</layout>
</widget>
</widget> </widget>
</item> </item>
</layout> </layout>
@ -636,6 +681,11 @@
<header>gui/statistics/dhtgraph.h</header> <header>gui/statistics/dhtgraph.h</header>
<container>1</container> <container>1</container>
</customwidget> </customwidget>
<customwidget>
<class>LineEditClear</class>
<extends>QLineEdit</extends>
<header location="global">gui/common/LineEditClear.h</header>
</customwidget>
</customwidgets> </customwidgets>
<resources/> <resources/>
<connections/> <connections/>