git-svn-id: svn://db.shs.com.ru/libs@563 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -1,9 +1,10 @@
|
|||||||
project(piintrospector)
|
project(piintrospector)
|
||||||
file(GLOB SRC "*.h" "*.cpp" "*.ui" "*.qrc" "lang/*.ts")
|
file(GLOB SRC "*.h" "*.cpp" "*.ui" "*.qrc" "lang/*.ts")
|
||||||
pip_code_model(CCMPII "../../pip/src_main/introspection/piintrospection_server_p.h" OPTIONS "-DPIP_EXPORT" "-Es")
|
set(PII_ROOT "../../pip/src_main/introspection")
|
||||||
|
pip_code_model(CCM "${PII_ROOT}/piintrospection_server_p.h" "${PII_ROOT}/piintrospection_threads_p.h" OPTIONS "-DPIP_EXPORT" "-Es")
|
||||||
find_qt(${QtVersions} Core Gui)
|
find_qt(${QtVersions} Core Gui)
|
||||||
qt_wrap(${SRC} HDRS out_HDR CPPS out_CPP QMS out_QM)
|
qt_wrap(${SRC} HDRS out_HDR CPPS out_CPP QMS out_QM)
|
||||||
qt_add_executable(${PROJECT_NAME} WIN32 out_CPP CCMPII)
|
qt_add_executable(${PROJECT_NAME} WIN32 out_CPP CCM)
|
||||||
qt_target_link_libraries(${PROJECT_NAME} pip qad_utils qad_widgets qad_application piqt_utils)
|
qt_target_link_libraries(${PROJECT_NAME} pip qad_utils qad_widgets qad_application piqt_utils)
|
||||||
message(STATUS "Building ${PROJECT_NAME}")
|
message(STATUS "Building ${PROJECT_NAME}")
|
||||||
if(LIB)
|
if(LIB)
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
#include "containers_view.h"
|
#include "containers_view.h"
|
||||||
#include <QTreeView>
|
#include <QTreeView>
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QStyle>
|
||||||
#include <QSortFilterProxyModel>
|
#include <QSortFilterProxyModel>
|
||||||
|
|
||||||
#include <cxxabi.h>
|
#include <cxxabi.h>
|
||||||
@@ -29,7 +31,7 @@ ContainersModel::ContainersModel() {
|
|||||||
prev_all.resize(all.size(), 0L);
|
prev_all.resize(all.size(), 0L);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef PIP_INTROSPECTION
|
|
||||||
void ContainersModel::update(const PIMap<uint, PIIntrospectionContainers::Type> & td, const PIMap<uint, PIString> & tn) {
|
void ContainersModel::update(const PIMap<uint, PIIntrospectionContainers::Type> & td, const PIMap<uint, PIString> & tn) {
|
||||||
prev_typedata = typedata;
|
prev_typedata = typedata;
|
||||||
typedata = td;
|
typedata = td;
|
||||||
@@ -49,14 +51,12 @@ void ContainersModel::update(const PIMap<uint, PIIntrospectionContainers::Type>
|
|||||||
all[ccBytesAllocated] += i.value().bytes_allocated;
|
all[ccBytesAllocated] += i.value().bytes_allocated;
|
||||||
all[ccBytesUsed] += i.value().bytes_used;
|
all[ccBytesUsed] += i.value().bytes_used;
|
||||||
}
|
}
|
||||||
dataChanged(index(1, 0), index(columnCount(), typeids.size_s() - 1));
|
dataChanged(index(0, ccCount), index(typeids.size_s() - 1, columnCount()));
|
||||||
emit headerDataChanged(Qt::Horizontal, 1, columnCount());
|
emit headerDataChanged(Qt::Horizontal, ccCount, columnCount());
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
void ContainersModel::clear() {
|
void ContainersModel::clear() {
|
||||||
#ifdef PIP_INTROSPECTION
|
|
||||||
beginRemoveRows(QModelIndex(), 0, typeids.size_s() - 1);
|
beginRemoveRows(QModelIndex(), 0, typeids.size_s() - 1);
|
||||||
typedata.clear();
|
typedata.clear();
|
||||||
prev_typedata.clear();
|
prev_typedata.clear();
|
||||||
@@ -64,9 +64,9 @@ void ContainersModel::clear() {
|
|||||||
typeids.clear();
|
typeids.clear();
|
||||||
all.fill(0L);
|
all.fill(0L);
|
||||||
endRemoveRows();
|
endRemoveRows();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int ContainersModel::rowCount(const QModelIndex & parent) const {
|
int ContainersModel::rowCount(const QModelIndex & parent) const {
|
||||||
return typeids.size_s();
|
return typeids.size_s();
|
||||||
}
|
}
|
||||||
@@ -78,9 +78,7 @@ int ContainersModel::columnCount(const QModelIndex & parent) const {
|
|||||||
|
|
||||||
|
|
||||||
QModelIndex ContainersModel::index(int row, int column, const QModelIndex & parent) const {
|
QModelIndex ContainersModel::index(int row, int column, const QModelIndex & parent) const {
|
||||||
#ifdef PIP_INTROSPECTION
|
|
||||||
if (row >= typenames.size_s() || row >= typedata.size_s()) return QModelIndex();
|
if (row >= typenames.size_s() || row >= typedata.size_s()) return QModelIndex();
|
||||||
#endif
|
|
||||||
return createIndex(row, column, typeids[row]);
|
return createIndex(row, column, typeids[row]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,40 +108,43 @@ QVariant ContainersModel::headerData(int section, Qt::Orientation orientation, i
|
|||||||
|
|
||||||
|
|
||||||
QVariant ContainersModel::data(const QModelIndex & index, int role) const {
|
QVariant ContainersModel::data(const QModelIndex & index, int role) const {
|
||||||
if (role != Qt::DisplayRole && role != Qt::UserRole) return QVariant();
|
if (role != Qt::DisplayRole && role != Qt::UserRole && role != (Qt::UserRole+1)) return QVariant();
|
||||||
#ifdef PIP_INTROSPECTION
|
|
||||||
uint id = uint(index.internalId());
|
uint id = uint(index.internalId());
|
||||||
llong v = 0L;
|
llong v = 0L;
|
||||||
if (mode_changes) {
|
if (role == Qt::DisplayRole || role == Qt::UserRole) {
|
||||||
switch (index.column()) {
|
if (mode_changes) {
|
||||||
case ccType: return demangle(typenames.value(id).dataAscii());
|
switch (index.column()) {
|
||||||
case ccCount: return int(typedata.value(id).count) - int(prev_typedata.value(id).count);
|
case ccType: return demangle(typenames.value(id).dataAscii());
|
||||||
case ccBytesAllocated:
|
case ccCount: return int(typedata.value(id).count) - int(prev_typedata.value(id).count);
|
||||||
v = typedata.value(id).bytes_allocated;
|
case ccBytesAllocated:
|
||||||
v -= prev_typedata.value(id).bytes_allocated;
|
v = typedata.value(id).bytes_allocated;
|
||||||
if (role == Qt::UserRole) return piAbs(v);
|
v -= prev_typedata.value(id).bytes_allocated;
|
||||||
return PI2QString(PIString::readableSize(v));
|
if (role == Qt::UserRole) return piAbs(v);
|
||||||
case ccBytesUsed:
|
return PI2QString(PIString::readableSize(v));
|
||||||
v = typedata.value(id).bytes_used;
|
case ccBytesUsed:
|
||||||
v -= prev_typedata.value(id).bytes_used;
|
v = typedata.value(id).bytes_used;
|
||||||
if (role == Qt::UserRole) return piAbs(v);
|
v -= prev_typedata.value(id).bytes_used;
|
||||||
return PI2QString(PIString::readableSize(v));
|
if (role == Qt::UserRole) return piAbs(v);
|
||||||
}
|
return PI2QString(PIString::readableSize(v));
|
||||||
} else {
|
}
|
||||||
switch (index.column()) {
|
} else {
|
||||||
case ccType: return demangle(typenames.value(id).dataAscii());
|
switch (index.column()) {
|
||||||
case ccCount: return typedata.value(id).count;
|
case ccType: return demangle(typenames.value(id).dataAscii());
|
||||||
case ccBytesAllocated:
|
case ccCount: return typedata.value(id).count;
|
||||||
v = typedata.value(id).bytes_allocated;
|
case ccBytesAllocated:
|
||||||
if (role == Qt::UserRole) return v;
|
v = typedata.value(id).bytes_allocated;
|
||||||
return PI2QString(PIString::readableSize(v));
|
if (role == Qt::UserRole) return v;
|
||||||
case ccBytesUsed:
|
return PI2QString(PIString::readableSize(v));
|
||||||
v = typedata.value(id).bytes_used;
|
case ccBytesUsed:
|
||||||
if (role == Qt::UserRole) return v;
|
v = typedata.value(id).bytes_used;
|
||||||
return PI2QString(PIString::readableSize(v));
|
if (role == Qt::UserRole) return v;
|
||||||
|
return PI2QString(PIString::readableSize(v));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
if (role == (Qt::UserRole+1) && (index.column() == ccCount)) {
|
||||||
|
return typedata.value(id).count;
|
||||||
|
}
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -155,8 +156,27 @@ Qt::ItemFlags ContainersModel::flags(const QModelIndex & index) const {
|
|||||||
|
|
||||||
void ContainersModel::setChangesMode(bool yes) {
|
void ContainersModel::setChangesMode(bool yes) {
|
||||||
mode_changes = yes;
|
mode_changes = yes;
|
||||||
dataChanged(index(1, 0), index(columnCount(), typeids.size_s() - 1));
|
dataChanged(index(0, ccCount), index(typeids.size_s() - 1, columnCount()));
|
||||||
emit headerDataChanged(Qt::Horizontal, 1, columnCount());
|
emit headerDataChanged(Qt::Horizontal, ccCount, columnCount());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void ContainersDelegate::paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const {
|
||||||
|
QStyledItemDelegate::paint(painter, option, index);
|
||||||
|
if (model->index(index.row(), ccCount).data(Qt::UserRole+1).toInt() == 0) {
|
||||||
|
QColor col;
|
||||||
|
if (option.state == QStyle::State_Enabled ||
|
||||||
|
option.state == QStyle::State_HasFocus)
|
||||||
|
col = option.palette.color(QPalette::Active, QPalette::WindowText);
|
||||||
|
else
|
||||||
|
col = option.palette.color(QPalette::Disabled, QPalette::WindowText);
|
||||||
|
col.setAlphaF(0.5);
|
||||||
|
int y = option.rect.center().y() + (option.fontMetrics.height() / 2.5) - option.fontMetrics.strikeOutPos();
|
||||||
|
painter->setPen(QPen(col, lineThickness()));
|
||||||
|
painter->drawLine(QPoint(option.rect.left(), y), QPoint(option.rect.right(), y));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -170,7 +190,8 @@ ContainersView::ContainersView(QWidget * parent): QWidget(parent) {
|
|||||||
proxy->setSourceModel(model);
|
proxy->setSourceModel(model);
|
||||||
proxy->setSortRole(Qt::UserRole);
|
proxy->setSortRole(Qt::UserRole);
|
||||||
proxy->setDynamicSortFilter(false);
|
proxy->setDynamicSortFilter(false);
|
||||||
treeContainers->setModel(proxy);
|
treeContainers->setModel(model);
|
||||||
|
treeContainers->setItemDelegate(new ContainersDelegate(model));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -189,11 +210,10 @@ void ContainersView::changeEvent(QEvent * e) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef PIP_INTROSPECTION
|
|
||||||
void ContainersView::showContainers(const PIMap<uint, PIIntrospectionContainers::Type> & data, const PIMap<uint, PIString> & typenames) {
|
void ContainersView::showContainers(const PIMap<uint, PIIntrospectionContainers::Type> & data, const PIMap<uint, PIString> & typenames) {
|
||||||
model->update(data, typenames);
|
model->update(data, typenames);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
void ContainersView::clear() {
|
void ContainersView::clear() {
|
||||||
|
|||||||
@@ -4,6 +4,8 @@
|
|||||||
#include "ui_containers_view.h"
|
#include "ui_containers_view.h"
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
#include <QAbstractItemModel>
|
||||||
|
#include <QStyledItemDelegate>
|
||||||
#include "piqt.h"
|
#include "piqt.h"
|
||||||
#ifdef PIP_INTROSPECTION
|
#ifdef PIP_INTROSPECTION
|
||||||
# include "piintrospection_containers_p.h"
|
# include "piintrospection_containers_p.h"
|
||||||
@@ -43,6 +45,14 @@ public slots:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class ContainersDelegate: public QStyledItemDelegate {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
ContainersDelegate(QAbstractItemModel * m) {model = m;}
|
||||||
|
void paint(QPainter *painter, const QStyleOptionViewItem & option, const QModelIndex &index) const override;
|
||||||
|
QAbstractItemModel * model;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class ContainersView: public QWidget, private Ui::ContainersView
|
class ContainersView: public QWidget, private Ui::ContainersView
|
||||||
@@ -58,7 +68,6 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
void changeEvent(QEvent * e);
|
void changeEvent(QEvent * e);
|
||||||
|
|
||||||
QStringList src_header;
|
|
||||||
ContainersModel * model;
|
ContainersModel * model;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|||||||
@@ -125,25 +125,37 @@ void QPIIntrospector::peerReceived(const PIString & from, const PIByteArray & da
|
|||||||
PIByteArray pba;
|
PIByteArray pba;
|
||||||
while (!cs.atEnd()) {
|
while (!cs.atEnd()) {
|
||||||
switch (cs.read()) {
|
switch (cs.read()) {
|
||||||
case 1: {
|
case PIIntrospection::itInfo: {
|
||||||
cs.get(pba);
|
cs.get(pba);
|
||||||
PIIntrospection::ProcessInfo info;
|
PIIntrospection::ProcessInfo info;
|
||||||
PIIntrospection::unpackInfo(pba, info);
|
PIIntrospection::unpackInfo(pba, info);
|
||||||
showInfo(info);
|
showInfo(info);
|
||||||
} break;
|
} break;
|
||||||
case 2: {
|
case PIIntrospection::itProcStat: {
|
||||||
|
cs.get(pba);
|
||||||
|
PIIntrospection::ProcessStat stat;
|
||||||
|
PIIntrospection::unpackProcStat(pba, stat);
|
||||||
|
//showInfo(info);
|
||||||
|
} break;
|
||||||
|
case PIIntrospection::itContainers: {
|
||||||
cs.get(pba);
|
cs.get(pba);
|
||||||
PIMap<uint, PIIntrospectionContainers::Type> data;
|
PIMap<uint, PIIntrospectionContainers::Type> data;
|
||||||
PIMap<uint, PIString> typenames;
|
PIMap<uint, PIString> typenames;
|
||||||
PIIntrospection::unpackContainers(pba, data, typenames);
|
PIIntrospection::unpackContainers(pba, data, typenames);
|
||||||
widgetContainers->showContainers(data, typenames);
|
widgetContainers->showContainers(data, typenames);
|
||||||
} break;
|
} break;
|
||||||
case 4: {
|
case PIIntrospection::itObjects: {
|
||||||
cs.get(pba);
|
cs.get(pba);
|
||||||
PIVector<PIIntrospection::ObjectInfo> objects;
|
PIVector<PIIntrospection::ObjectInfo> objects;
|
||||||
PIIntrospection::unpackObjects(pba, objects);
|
PIIntrospection::unpackObjects(pba, objects);
|
||||||
widgetObjects->showObjects(objects);
|
widgetObjects->showObjects(objects);
|
||||||
} break;
|
} break;
|
||||||
|
case PIIntrospection::itThreads: {
|
||||||
|
cs.get(pba);
|
||||||
|
PIVector<PIIntrospectionThreads::ThreadInfo> threads;
|
||||||
|
PIIntrospection::unpackThreads(pba, threads);
|
||||||
|
widgetThreads->showThreads(threads);
|
||||||
|
} break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -124,7 +124,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QTabWidget" name="tabWidgetMain">
|
<widget class="QTabWidget" name="tabWidgetMain">
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>1</number>
|
<number>3</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="tab">
|
<widget class="QWidget" name="tab">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
@@ -167,6 +167,11 @@
|
|||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
<string>Threads</string>
|
<string>Threads</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_7">
|
||||||
|
<item>
|
||||||
|
<widget class="ThreadsView" name="widgetThreads" native="true"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@@ -190,6 +195,12 @@
|
|||||||
<header>containers_view.h</header>
|
<header>containers_view.h</header>
|
||||||
<container>1</container>
|
<container>1</container>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>ThreadsView</class>
|
||||||
|
<extends>QWidget</extends>
|
||||||
|
<header>threads_view.h</header>
|
||||||
|
<container>1</container>
|
||||||
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections>
|
<connections>
|
||||||
|
|||||||
Reference in New Issue
Block a user