code format
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
#include "piintrospector.h"
|
||||
#include <QClipboard>
|
||||
#include <QScrollBar>
|
||||
|
||||
#include "ccm_piintrospector.h"
|
||||
#include "pichunkstream.h"
|
||||
#include "pidir.h"
|
||||
#include "pifile.h"
|
||||
#include "pitime.h"
|
||||
#include "pidir.h"
|
||||
#include "pichunkstream.h"
|
||||
#include "ccm_piintrospector.h"
|
||||
|
||||
#include <QClipboard>
|
||||
#include <QScrollBar>
|
||||
|
||||
|
||||
QPIIntrospector::QPIIntrospector(QWidget * parent): EMainWindow(parent), peer("__introspection_client__") {
|
||||
@@ -13,22 +15,22 @@ QPIIntrospector::QPIIntrospector(QWidget * parent): EMainWindow(parent), peer("_
|
||||
request_timer = 0;
|
||||
session.setFile("qpiintrospector_session.conf");
|
||||
#if QT_VERSION >= 0x050000
|
||||
//treeContainers->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
|
||||
// treeContainers->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
|
||||
#else
|
||||
//treeContainers->header()->setResizeMode(QHeaderView::ResizeToContents);
|
||||
// treeContainers->header()->setResizeMode(QHeaderView::ResizeToContents);
|
||||
#endif
|
||||
CONNECTU_QUEUED(&peer, peerConnectedEvent, this, peersChanged, this);
|
||||
CONNECTU_QUEUED(&peer, peerDisconnectedEvent, this, peersChanged, this);
|
||||
CONNECTU_QUEUED(&peer, dataReceivedEvent, this, peerReceived, this);
|
||||
//CONNECTU(&peer, peerConnectedEvent, this, reqProcPIEvents);
|
||||
//CONNECTU(&peer, peerDisconnectedEvent, this, reqProcPIEvents);
|
||||
//CONNECTU(&peer, dataReceivedEvent, this, reqProcPIEvents);
|
||||
// CONNECTU(&peer, peerConnectedEvent, this, reqProcPIEvents);
|
||||
// CONNECTU(&peer, peerDisconnectedEvent, this, reqProcPIEvents);
|
||||
// CONNECTU(&peer, dataReceivedEvent, this, reqProcPIEvents);
|
||||
session.addEntry(this);
|
||||
session.addEntry(tabWidgetMain);
|
||||
PICodeInfo::EnumInfo * ei = PICodeInfo::enumsInfo->value("PIIntrospection::InfoTypes");
|
||||
if (ei) {
|
||||
piForeachC (PICodeInfo::EnumeratorInfo & e, ei->members) {
|
||||
#if PIP_VERSION >= PIP_MAKE_VERSION(2,39,0)
|
||||
piForeachC(PICodeInfo::EnumeratorInfo & e, ei->members) {
|
||||
#if PIP_VERSION >= PIP_MAKE_VERSION(2, 39, 0)
|
||||
QCheckBox * cb = new QCheckBox(PI2QString(e.name.mid(2).toString()));
|
||||
#else
|
||||
QCheckBox * cb = new QCheckBox(PI2QString(e.name.mid(2)));
|
||||
@@ -54,19 +56,15 @@ QPIIntrospector::~QPIIntrospector() {
|
||||
void QPIIntrospector::changeEvent(QEvent * e) {
|
||||
EMainWindow::changeEvent(e);
|
||||
switch (e->type()) {
|
||||
case QEvent::LanguageChange:
|
||||
retranslateUi(this);
|
||||
break;
|
||||
case QEvent::LanguageChange: retranslateUi(this); break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void QPIIntrospector::timerEvent(QTimerEvent * e) {
|
||||
if (e->timerId() == pip_timer)
|
||||
callQueuedEvents();
|
||||
if (e->timerId() == request_timer)
|
||||
buttonRequest->click();
|
||||
if (e->timerId() == pip_timer) callQueuedEvents();
|
||||
if (e->timerId() == request_timer) buttonRequest->click();
|
||||
}
|
||||
|
||||
|
||||
@@ -86,9 +84,9 @@ void QPIIntrospector::buildTree(QByteArray d) {
|
||||
pd >> threads;
|
||||
treeContainers->clear();
|
||||
piForeachC (PIIntrospectionThreads::ThreadInfo & t, threads) {
|
||||
QTreeWidgetItem * ti = new QTreeWidgetItem();
|
||||
ti->setText(0, QString(PI2QString(t.name) + " (%1)").arg(t.id));
|
||||
treeContainers->addTopLevelItem(ti);
|
||||
QTreeWidgetItem * ti = new QTreeWidgetItem();
|
||||
ti->setText(0, QString(PI2QString(t.name) + " (%1)").arg(t.id));
|
||||
treeContainers->addTopLevelItem(ti);
|
||||
}*/
|
||||
}
|
||||
|
||||
@@ -101,8 +99,7 @@ void QPIIntrospector::procRequestTimer() {
|
||||
}
|
||||
|
||||
|
||||
void QPIIntrospector::buildDumpSection(QTreeWidgetItem * pi, PIString & str) {
|
||||
}
|
||||
void QPIIntrospector::buildDumpSection(QTreeWidgetItem * pi, PIString & str) {}
|
||||
|
||||
|
||||
void QPIIntrospector::showInfo() {
|
||||
@@ -141,15 +138,15 @@ QString QPIIntrospector::durationStr(PISystemTime t) {
|
||||
QString ret;
|
||||
double s = t.toSeconds();
|
||||
int d, h, m;
|
||||
d = piFloor(s / (24*60*60));
|
||||
d = piFloor(s / (24 * 60 * 60));
|
||||
if (d > 0) {
|
||||
ret += QString::number(d) + " d ";
|
||||
s -= d * (24*60*60);
|
||||
s -= d * (24 * 60 * 60);
|
||||
}
|
||||
h = piFloor(s / (60*60));
|
||||
h = piFloor(s / (60 * 60));
|
||||
if (h > 0) {
|
||||
ret += QString::number(h) + " h ";
|
||||
s -= h * (60*60);
|
||||
s -= h * (60 * 60);
|
||||
}
|
||||
m = piFloor(s / 60);
|
||||
if (m > 0) {
|
||||
@@ -160,11 +157,11 @@ QString QPIIntrospector::durationStr(PISystemTime t) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
#if PIP_VERSION >= PIP_MAKE_VERSION(2,35,0)
|
||||
#if PIP_VERSION >= PIP_MAKE_VERSION(2, 35, 0)
|
||||
void QPIIntrospector::prepareContainers(PIVector<PIIntrospectionContainers::TypeInfo> & data) {
|
||||
for (PIIntrospectionContainers::TypeInfo & i: data) {
|
||||
i.allocated_bytes = i.allocated * i.item_size;
|
||||
i.used_bytes = i.used * i.item_size;
|
||||
i.used_bytes = i.used * i.item_size;
|
||||
i.item_size_str.setReadableSize(i.item_size);
|
||||
i.allocated_str.setReadableSize(i.allocated_bytes);
|
||||
i.used_str.setReadableSize(i.used_bytes);
|
||||
@@ -174,56 +171,63 @@ void QPIIntrospector::prepareContainers(PIVector<PIIntrospectionContainers::Type
|
||||
|
||||
void QPIIntrospector::on_listApp_currentRowChanged(int r) {
|
||||
PIString cs;
|
||||
if (r < 0) cs.clear();
|
||||
else cs = Q2PIString(listApp->item(r)->data(Qt::UserRole).toString());
|
||||
if (cur_server != cs)
|
||||
widgetContainers->clear();
|
||||
if (r < 0)
|
||||
cs.clear();
|
||||
else
|
||||
cs = Q2PIString(listApp->item(r)->data(Qt::UserRole).toString());
|
||||
if (cur_server != cs) widgetContainers->clear();
|
||||
cur_server = cs;
|
||||
}
|
||||
|
||||
|
||||
void QPIIntrospector::peerReceived(const PIString & from, const PIByteArray & data) {
|
||||
if (from != cur_server) return;
|
||||
//piCout << "rec" << data.size();
|
||||
// piCout << "rec" << data.size();
|
||||
PIByteArray ba(data);
|
||||
if (ba.size_s() < 4) return;
|
||||
uint sign(0); ba >> sign;
|
||||
uint sign(0);
|
||||
ba >> sign;
|
||||
if (sign != PIIntrospection::sign) return;
|
||||
PIChunkStream cs(ba);
|
||||
PIByteArray pba;
|
||||
while (!cs.atEnd()) {
|
||||
switch (cs.read()) {
|
||||
case PIIntrospection::itInfo: {
|
||||
pba.clear(); cs.get(pba);
|
||||
pba.clear();
|
||||
cs.get(pba);
|
||||
PIIntrospection::unpackInfo(pba, info);
|
||||
} break;
|
||||
} break;
|
||||
case PIIntrospection::itProcStat: {
|
||||
pba.clear(); cs.get(pba);
|
||||
pba.clear();
|
||||
cs.get(pba);
|
||||
PIIntrospection::unpackProcStat(pba, stat);
|
||||
widgetThreads->setStat(stat.threads);
|
||||
//showInfo(info);
|
||||
} break;
|
||||
// showInfo(info);
|
||||
} break;
|
||||
case PIIntrospection::itContainers: {
|
||||
pba.clear(); cs.get(pba);
|
||||
pba.clear();
|
||||
cs.get(pba);
|
||||
PIVector<PIIntrospectionContainers::TypeInfo> data;
|
||||
PIIntrospection::unpackContainers(pba, data);
|
||||
#if PIP_VERSION >= PIP_MAKE_VERSION(2,35,0)
|
||||
#if PIP_VERSION >= PIP_MAKE_VERSION(2, 35, 0)
|
||||
prepareContainers(data);
|
||||
#endif
|
||||
widgetContainers->showContainers(data);
|
||||
} break;
|
||||
} break;
|
||||
case PIIntrospection::itObjects: {
|
||||
pba.clear(); cs.get(pba);
|
||||
pba.clear();
|
||||
cs.get(pba);
|
||||
PIVector<PIIntrospection::ObjectInfo> objects;
|
||||
PIIntrospection::unpackObjects(pba, objects);
|
||||
widgetObjects->showObjects(objects);
|
||||
} break;
|
||||
} break;
|
||||
case PIIntrospection::itThreads: {
|
||||
pba.clear(); cs.get(pba);
|
||||
pba.clear();
|
||||
cs.get(pba);
|
||||
PIVector<PIIntrospectionThreads::ThreadInfo> threads;
|
||||
PIIntrospection::unpackThreads(pba, threads);
|
||||
widgetThreads->showThreads(threads);
|
||||
} break;
|
||||
} break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
@@ -237,14 +241,13 @@ void QPIIntrospector::peersChanged(const PIString & name) {
|
||||
QString cs = listApp->currentItem() ? listApp->currentItem()->text() : "";
|
||||
listApp->clear();
|
||||
peer.lock();
|
||||
piForeachC (PIPeer::PeerInfo & p, peer.allPeers()) {
|
||||
piForeachC(PIPeer::PeerInfo & p, peer.allPeers()) {
|
||||
QString pn = PI2QString(p.name);
|
||||
if (!pn.contains(tag)) continue;
|
||||
QListWidgetItem * li = new QListWidgetItem(pn.left(pn.indexOf(tag)));
|
||||
li->setData(Qt::UserRole, pn);
|
||||
listApp->addItem(li);
|
||||
if (pn == cs)
|
||||
listApp->setCurrentRow(listApp->count() - 1);
|
||||
if (pn == cs) listApp->setCurrentRow(listApp->count() - 1);
|
||||
}
|
||||
peer.unlock();
|
||||
listApp->blockSignals(false);
|
||||
@@ -255,7 +258,7 @@ void QPIIntrospector::on_buttonRequest_clicked() {
|
||||
if (cur_server.isEmpty()) return;
|
||||
PIIntrospection::RequiredInfo info;
|
||||
for (int i = 0; i < layoutRequestFlags->count(); ++i) {
|
||||
QCheckBox * cb = qobject_cast<QCheckBox*>(layoutRequestFlags->itemAt(i)->widget());
|
||||
QCheckBox * cb = qobject_cast<QCheckBox *>(layoutRequestFlags->itemAt(i)->widget());
|
||||
if (!cb) continue;
|
||||
if (!cb->isChecked()) continue;
|
||||
info.types |= cb->property("__value__").toInt();
|
||||
|
||||
Reference in New Issue
Block a user