From b4530da86b6fd27508aef319bc6bc3c7b5730bb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9F=D0=B5=D0=BB=D0=B8=D0=BF=D0=B5=D0=BD=D0=BA=D0=BE=20?= =?UTF-8?q?=D0=98=D0=B2=D0=B0=D0=BD?= Date: Wed, 2 Mar 2016 08:08:33 +0000 Subject: [PATCH] git-svn-id: svn://db.shs.com.ru/libs@83 a8b55f48-bf90-11e4-a774-851b48703e85 --- piqt_tools/piintrospector.cpp | 52 ++++++- piqt_tools/piintrospector.h | 14 +- piqt_tools/piintrospector.ui | 231 ++++++++++++++--------------- piqt_tools/piintrospector_main.cpp | 4 +- 4 files changed, 178 insertions(+), 123 deletions(-) diff --git a/piqt_tools/piintrospector.cpp b/piqt_tools/piintrospector.cpp index 295e242..baf31f4 100644 --- a/piqt_tools/piintrospector.cpp +++ b/piqt_tools/piintrospector.cpp @@ -5,9 +5,11 @@ #include -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 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; +} diff --git a/piqt_tools/piintrospector.h b/piqt_tools/piintrospector.h index 50022e6..c920273 100644 --- a/piqt_tools/piintrospector.h +++ b/piqt_tools/piintrospector.h @@ -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: }; diff --git a/piqt_tools/piintrospector.ui b/piqt_tools/piintrospector.ui index 1c89e71..48a7a83 100644 --- a/piqt_tools/piintrospector.ui +++ b/piqt_tools/piintrospector.ui @@ -14,125 +14,124 @@ PIP introspector - - - - 9 - 9 - 273 - 225 - - - - Select application - - - - - 10 - 23 - 253 - 192 - - - - QAbstractItemView::NoEditTriggers - - - QAbstractItemView::ScrollPerPixel - - - QAbstractItemView::ScrollPerPixel - - - - - - - 330 - 100 - 254 - 225 - - - - QAbstractItemView::NoEditTriggers - - - QAbstractItemView::ScrollPerPixel - - - - - - - - - - - 320 - 10 - 79 - 84 - - - - Containers - - - - QFormLayout::AllNonFixedFieldsGrow - - - QFormLayout::DontWrapRows - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - count: + + + + + Qt::Horizontal + + + + Select application + + + + + QAbstractItemView::NoEditTriggers + + + QAbstractItemView::ScrollPerPixel + + + QAbstractItemView::ScrollPerPixel + + + + - - - - - 0 - + + + + + + + + + Qt::AlignCenter + + + + + + + Containers + + + + QFormLayout::AllNonFixedFieldsGrow + + + QFormLayout::DontWrapRows + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + count: + + + + + + + 0 + + + + + + + allocated: + + + + + + + 0 + + + + + + + used: + + + + + + + 0 + + + + + + + + + + QAbstractItemView::NoEditTriggers + + + QAbstractItemView::ScrollPerPixel + + + + + + + + + - - - - - allocated: - - - - - - - 0 - - - - - - - used: - - - - - - - 0 - - - - - + + + diff --git a/piqt_tools/piintrospector_main.cpp b/piqt_tools/piintrospector_main.cpp index ef66e97..b94783d 100644 --- a/piqt_tools/piintrospector_main.cpp +++ b/piqt_tools/piintrospector_main.cpp @@ -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(); }