git-svn-id: svn://db.shs.com.ru/libs@83 a8b55f48-bf90-11e4-a774-851b48703e85

This commit is contained in:
2016-03-02 08:08:33 +00:00
parent 64130922ad
commit b4530da86b
4 changed files with 178 additions and 123 deletions

View File

@@ -5,9 +5,11 @@
#include <QClipboard>
QPIIntrospector::QPIIntrospector(QWidget * parent): QMainWindow(parent) {
QPIIntrospector::QPIIntrospector(QWidget * parent): QMainWindow(parent), peer("__introspection_client__") {
setupUi(this);
tree->header()->setResizeMode(QHeaderView::ResizeToContents);
CONNECTU(&peer, dataReceivedEvent, this, peerReceived)
startTimer(100);
}
@@ -23,9 +25,55 @@ void QPIIntrospector::changeEvent(QEvent * e) {
}
void QPIIntrospector::buildDump() {
void QPIIntrospector::timerEvent(QTimerEvent * ) {
listApp->blockSignals(true);
QString cs = listApp->currentItem() ? listApp->currentItem()->text() : "";
listApp->clear();
peer.lock();
piForeachC (PIPeer::PeerInfo & p, peer.allPeers()) {
QString pn = PI2QString(p.name);
listApp->addItem(pn);
if (pn == cs)
listApp->setCurrentRow(listApp->count() - 1);
}
peer.unlock();
listApp->blockSignals(false);
}
void QPIIntrospector::buildTree(QByteArray d) {
PIVector<PIIntrospectionThreads::ThreadInfo> threads;
PIByteArray pd = Q2PIByteArray(d);
pd >> threads;
tree->clear();
piForeachC (PIIntrospectionThreads::ThreadInfo & t, threads) {
QTreeWidgetItem * ti = new QTreeWidgetItem();
ti->setText(0, QString(PI2QString(t.name) + " (%1)").arg(t.id));
tree->addTopLevelItem(ti);
}
}
void QPIIntrospector::buildDumpSection(QTreeWidgetItem * pi, PIString & str) {
}
void QPIIntrospector::on_listApp_currentRowChanged(int r) {
if (r < 0) cur_server.clear();
else cur_server = Q2PIString(listApp->item(r)->text());
}
void QPIIntrospector::peerReceived(const PIString & from, const PIByteArray & data) {
if (from != cur_server) return;
PIString appname;
PIIntrospectionContainers cont;
PIByteArray ba(data);
ba >> appname >> cont;// >> threads.threads;
QMetaObject::invokeMethod(labelAppname, "setText", Qt::QueuedConnection, Q_ARG(QString, PI2QString(appname)));
QMetaObject::invokeMethod(labelCount, "setText", Qt::QueuedConnection, Q_ARG(QString, QString::number(cont.count)));
QMetaObject::invokeMethod(labelAlloc, "setText", Qt::QueuedConnection, Q_ARG(QString, PI2QString(PIString::readableSize(cont.bytes_allocated))));
QMetaObject::invokeMethod(labelUsed, "setText", Qt::QueuedConnection, Q_ARG(QString, PI2QString(PIString::readableSize(cont.bytes_used))));
QMetaObject::invokeMethod(this, "buildTree", Qt::QueuedConnection, Q_ARG(QByteArray, PI2QByteArray(ba)));
//piCout << appname;
}

View File

@@ -9,20 +9,28 @@
#include "piqt.h"
#include "piintrospection.h"
class QPIIntrospector: public QMainWindow, private Ui::QPIIntrospector
class QPIIntrospector: public QMainWindow, private Ui::QPIIntrospector, public PIObject
{
Q_OBJECT
PIOBJECT(QPIIntrospector)
public:
QPIIntrospector(QWidget * parent = 0);
protected:
void changeEvent(QEvent * e);
void timerEvent(QTimerEvent * );
void buildDump();
void buildDumpSection(QTreeWidgetItem * pi, PIString & str);
EVENT_HANDLER2(void, peerReceived, const PIString &, from, const PIByteArray &, data);
PIString cur_server;
PIPeer peer;
private slots:
void buildTree(QByteArray d);
void on_listApp_currentRowChanged(int r);
public slots:
};

View File

@@ -14,125 +14,124 @@
<string>PIP introspector</string>
</property>
<widget class="QWidget" name="centralwidget">
<widget class="QGroupBox" name="groupBox">
<property name="geometry">
<rect>
<x>9</x>
<y>9</y>
<width>273</width>
<height>225</height>
</rect>
</property>
<property name="title">
<string>Select application</string>
</property>
<widget class="QListWidget" name="listApp">
<property name="geometry">
<rect>
<x>10</x>
<y>23</y>
<width>253</width>
<height>192</height>
</rect>
</property>
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="verticalScrollMode">
<enum>QAbstractItemView::ScrollPerPixel</enum>
</property>
<property name="horizontalScrollMode">
<enum>QAbstractItemView::ScrollPerPixel</enum>
</property>
</widget>
</widget>
<widget class="QTreeWidget" name="tree">
<property name="geometry">
<rect>
<x>330</x>
<y>100</y>
<width>254</width>
<height>225</height>
</rect>
</property>
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="verticalScrollMode">
<enum>QAbstractItemView::ScrollPerPixel</enum>
</property>
<column>
<property name="text">
<string/>
</property>
</column>
</widget>
<widget class="QGroupBox" name="groupBox_2">
<property name="geometry">
<rect>
<x>320</x>
<y>10</y>
<width>79</width>
<height>84</height>
</rect>
</property>
<property name="title">
<string>Containers</string>
</property>
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<property name="rowWrapPolicy">
<enum>QFormLayout::DontWrapRows</enum>
</property>
<property name="labelAlignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>count:</string>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Select application</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QListWidget" name="listApp">
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="verticalScrollMode">
<enum>QAbstractItemView::ScrollPerPixel</enum>
</property>
<property name="horizontalScrollMode">
<enum>QAbstractItemView::ScrollPerPixel</enum>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="labelCount">
<property name="text">
<string>0</string>
</property>
<widget class="QWidget" name="">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="labelAppname">
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Containers</string>
</property>
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<property name="rowWrapPolicy">
<enum>QFormLayout::DontWrapRows</enum>
</property>
<property name="labelAlignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>count:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="labelCount">
<property name="text">
<string>0</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>allocated:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="labelAlloc">
<property name="text">
<string>0</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>used:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="labelUsed">
<property name="text">
<string>0</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QTreeWidget" name="tree">
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="verticalScrollMode">
<enum>QAbstractItemView::ScrollPerPixel</enum>
</property>
<column>
<property name="text">
<string/>
</property>
</column>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>allocated:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="labelAlloc">
<property name="text">
<string>0</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>used:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="labelUsed">
<property name="text">
<string>0</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
</widget>
<resources/>

View File

@@ -4,7 +4,7 @@
int main(int argc, char * argv[]) {
QApplication a(argc, argv);
//QPIIntrospector w;
//w.show();
QPIIntrospector w;
w.show();
return a.exec();
}