git-svn-id: svn://db.shs.com.ru/libs@221 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
21
piqt_utils/piintrospector/CMakeLists.txt
Normal file
21
piqt_utils/piintrospector/CMakeLists.txt
Normal file
@@ -0,0 +1,21 @@
|
||||
qt_project(piintrospector PIINTROSPECTOR_H PIINTROSPECTOR_CPP)
|
||||
add_executable(${PROJECT_NAME} WIN32 ${PIINTROSPECTOR_H} ${PIINTROSPECTOR_CPP})
|
||||
set(LIBS ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QAD_UTILS_LIBRARY} ${QAD_WIDGETS_LIBRARY} piqt_utils)
|
||||
target_link_libraries(${PROJECT_NAME} ${LIBS})
|
||||
message(STATUS "Building ${PROJECT_NAME}")
|
||||
if(LIB)
|
||||
if(WIN32)
|
||||
install(TARGETS ${PROJECT_NAME} DESTINATION ${MINGW_BIN})
|
||||
else()
|
||||
if(APPLE)
|
||||
install(TARGETS ${PROJECT_NAME} DESTINATION /usr/local/bin)
|
||||
else()
|
||||
install(TARGETS ${PROJECT_NAME} DESTINATION /usr/bin)
|
||||
endif()
|
||||
endif()
|
||||
message(STATUS "Install to system \"${CMAKE_INSTALL_PREFIX}\"")
|
||||
else()
|
||||
install(TARGETS ${PROJECT_NAME} DESTINATION bin)
|
||||
message(STATUS "Install to local \"bin\"")
|
||||
endif()
|
||||
|
||||
79
piqt_utils/piintrospector/piintrospector.cpp
Normal file
79
piqt_utils/piintrospector/piintrospector.cpp
Normal file
@@ -0,0 +1,79 @@
|
||||
#include "piintrospector.h"
|
||||
#include "pifile.h"
|
||||
#include "pitime.h"
|
||||
#include "pidir.h"
|
||||
#include <QClipboard>
|
||||
|
||||
|
||||
QPIIntrospector::QPIIntrospector(QWidget * parent): QMainWindow(parent), peer("__introspection_client__") {
|
||||
setupUi(this);
|
||||
tree->header()->setResizeMode(QHeaderView::ResizeToContents);
|
||||
CONNECTU(&peer, dataReceivedEvent, this, peerReceived)
|
||||
startTimer(100);
|
||||
}
|
||||
|
||||
|
||||
void QPIIntrospector::changeEvent(QEvent * e) {
|
||||
QMainWindow::changeEvent(e);
|
||||
switch (e->type()) {
|
||||
case QEvent::LanguageChange:
|
||||
retranslateUi(this);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
38
piqt_utils/piintrospector/piintrospector.h
Normal file
38
piqt_utils/piintrospector/piintrospector.h
Normal file
@@ -0,0 +1,38 @@
|
||||
#ifndef PIINTROSPECTOR_H
|
||||
#define PIINTROSPECTOR_H
|
||||
|
||||
#include "ui_piintrospector.h"
|
||||
#include <QImage>
|
||||
#include <QTime>
|
||||
#include <QDesktopWidget>
|
||||
#include <QDebug>
|
||||
#include "piqt.h"
|
||||
#include "piintrospection.h"
|
||||
|
||||
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 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:
|
||||
|
||||
};
|
||||
|
||||
#endif // PIINTROSPECTOR_H
|
||||
143
piqt_utils/piintrospector/piintrospector.ui
Normal file
143
piqt_utils/piintrospector/piintrospector.ui
Normal file
@@ -0,0 +1,143 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>QPIIntrospector</class>
|
||||
<widget class="QMainWindow" name="QPIIntrospector">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>923</width>
|
||||
<height>661</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>PIP introspector</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<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>
|
||||
<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>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
<slots>
|
||||
<slot>configChanged()</slot>
|
||||
<slot>updateMap()</slot>
|
||||
</slots>
|
||||
</ui>
|
||||
10
piqt_utils/piintrospector/piintrospector_main.cpp
Normal file
10
piqt_utils/piintrospector/piintrospector_main.cpp
Normal file
@@ -0,0 +1,10 @@
|
||||
#include <QApplication>
|
||||
#include "piintrospector.h"
|
||||
|
||||
|
||||
int main(int argc, char * argv[]) {
|
||||
QApplication a(argc, argv);
|
||||
QPIIntrospector w;
|
||||
w.show();
|
||||
return a.exec();
|
||||
}
|
||||
Reference in New Issue
Block a user