piintrospector old pip support
This commit is contained in:
@@ -34,8 +34,13 @@ void ContainersModel::update(const PIVector<PIIntrospectionContainers::TypeInfo>
|
|||||||
}
|
}
|
||||||
piForeachC (PIIntrospectionContainers::TypeInfo & i, t) {
|
piForeachC (PIIntrospectionContainers::TypeInfo & i, t) {
|
||||||
all[ccCount] += i.count;
|
all[ccCount] += i.count;
|
||||||
|
#if PIP_VERSION >= PIP_MAKE_VERSION(2,35,0)
|
||||||
all[ccBytesAllocated] += i.allocated_bytes;
|
all[ccBytesAllocated] += i.allocated_bytes;
|
||||||
all[ccBytesUsed] += i.used_bytes;
|
all[ccBytesUsed] += i.used_bytes;
|
||||||
|
#else
|
||||||
|
all[ccBytesAllocated] += i.allocated;
|
||||||
|
all[ccBytesUsed] += i.used;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
int pts = cur_data.size_s();
|
int pts = cur_data.size_s();
|
||||||
cur_data = t;
|
cur_data = t;
|
||||||
@@ -112,20 +117,34 @@ QVariant ContainersModel::data(const QModelIndex & index, int role) const {
|
|||||||
case ccType: return PI2QString(t.name);
|
case ccType: return PI2QString(t.name);
|
||||||
case ccItemSize:
|
case ccItemSize:
|
||||||
if (role == Qt::UserRole) return t.item_size;
|
if (role == Qt::UserRole) return t.item_size;
|
||||||
|
#if PIP_VERSION >= PIP_MAKE_VERSION(2,35,0)
|
||||||
return PI2QString(t.item_size_str);
|
return PI2QString(t.item_size_str);
|
||||||
|
#else
|
||||||
|
return PI2QString(PIString::readableSize(t.item_size));
|
||||||
|
#endif
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
if (mode_changes) {
|
if (mode_changes) {
|
||||||
switch (index.column()) {
|
switch (index.column()) {
|
||||||
case ccCount: return int(t.count) - int(prev_data.value(id).count);
|
case ccCount: return int(t.count) - int(prev_data.value(id).count);
|
||||||
case ccBytesAllocated:
|
case ccBytesAllocated:
|
||||||
|
#if PIP_VERSION >= PIP_MAKE_VERSION(2,35,0)
|
||||||
v = t.allocated_bytes;
|
v = t.allocated_bytes;
|
||||||
v -= prev_data.value(id).allocated_bytes;
|
v -= prev_data.value(id).allocated_bytes;
|
||||||
|
#else
|
||||||
|
v = t.allocated;
|
||||||
|
v -= prev_data.value(id).allocated;
|
||||||
|
#endif
|
||||||
if (role == Qt::UserRole) return piAbs(v);
|
if (role == Qt::UserRole) return piAbs(v);
|
||||||
return PI2QString(PIString::readableSize(v));
|
return PI2QString(PIString::readableSize(v));
|
||||||
case ccBytesUsed:
|
case ccBytesUsed:
|
||||||
|
#if PIP_VERSION >= PIP_MAKE_VERSION(2,35,0)
|
||||||
v = t.used_bytes;
|
v = t.used_bytes;
|
||||||
v -= prev_data.value(id).used_bytes;
|
v -= prev_data.value(id).used_bytes;
|
||||||
|
#else
|
||||||
|
v = t.used;
|
||||||
|
v -= prev_data.value(id).used;
|
||||||
|
#endif
|
||||||
if (role == Qt::UserRole) return piAbs(v);
|
if (role == Qt::UserRole) return piAbs(v);
|
||||||
return PI2QString(PIString::readableSize(v));
|
return PI2QString(PIString::readableSize(v));
|
||||||
}
|
}
|
||||||
@@ -133,11 +152,19 @@ QVariant ContainersModel::data(const QModelIndex & index, int role) const {
|
|||||||
switch (index.column()) {
|
switch (index.column()) {
|
||||||
case ccCount: return t.count;
|
case ccCount: return t.count;
|
||||||
case ccBytesAllocated:
|
case ccBytesAllocated:
|
||||||
|
#if PIP_VERSION >= PIP_MAKE_VERSION(2,35,0)
|
||||||
if (role == Qt::UserRole) return t.allocated_bytes;
|
if (role == Qt::UserRole) return t.allocated_bytes;
|
||||||
return PI2QString(t.allocated_str);
|
return PI2QString(t.allocated_str);
|
||||||
case ccBytesUsed:
|
case ccBytesUsed:
|
||||||
if (role == Qt::UserRole) return t.used_bytes;
|
if (role == Qt::UserRole) return t.used_bytes;
|
||||||
return PI2QString(t.used_str);
|
return PI2QString(t.used_str);
|
||||||
|
#else
|
||||||
|
if (role == Qt::UserRole) return t.allocated;
|
||||||
|
return PI2QString(PIString::readableSize(t.allocated));
|
||||||
|
case ccBytesUsed:
|
||||||
|
if (role == Qt::UserRole) return t.used;
|
||||||
|
return PI2QString(PIString::readableSize(t.used));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -187,14 +214,15 @@ int cmp_func_name_d(const PIIntrospectionContainers::TypeInfo * t0, const PIIntr
|
|||||||
#endif
|
#endif
|
||||||
CMP_FUNC(item_size)
|
CMP_FUNC(item_size)
|
||||||
CMP_FUNC(count)
|
CMP_FUNC(count)
|
||||||
CMP_FUNC(allocated_bytes)
|
CMP_FUNC(allocated)
|
||||||
CMP_FUNC(used_bytes)
|
CMP_FUNC(used)
|
||||||
#undef CMP_FUNC
|
#undef CMP_FUNC
|
||||||
void ContainersModel::sort(int column, Qt::SortOrder order) {
|
void ContainersModel::sort(int column, Qt::SortOrder order) {
|
||||||
ls_column = column;
|
ls_column = column;
|
||||||
ls_order = order;
|
ls_order = order;
|
||||||
if (cur_data.isEmpty()) return;
|
if (cur_data.isEmpty()) return;
|
||||||
PIVector<PIIntrospectionContainers::TypeInfo>::CompareFunc cf = nullptr;
|
PIVector<PIIntrospectionContainers::TypeInfo>::CompareFunc cf = nullptr;
|
||||||
|
#if PIP_VERSION >= PIP_MAKE_VERSION(2,35,0)
|
||||||
std::function<void(PIIntrospectionContainers::TypeInfo & e)> pf;
|
std::function<void(PIIntrospectionContainers::TypeInfo & e)> pf;
|
||||||
switch (column) {
|
switch (column) {
|
||||||
case ccType : cf = order == Qt::AscendingOrder ? cmp_func_name_a : cmp_func_name_d ; pf = print_func_name; break;
|
case ccType : cf = order == Qt::AscendingOrder ? cmp_func_name_a : cmp_func_name_d ; pf = print_func_name; break;
|
||||||
@@ -211,6 +239,17 @@ void ContainersModel::sort(int column, Qt::SortOrder order) {
|
|||||||
qDebug() << "sort" << column << order;
|
qDebug() << "sort" << column << order;
|
||||||
cur_data.forEach(pf);
|
cur_data.forEach(pf);
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
switch (column) {
|
||||||
|
case ccType : cf = order == Qt::AscendingOrder ? cmp_func_name_a : cmp_func_name_d ; break;
|
||||||
|
case ccItemSize : cf = order == Qt::AscendingOrder ? cmp_func_item_size_a : cmp_func_item_size_d; break;
|
||||||
|
case ccCount : cf = order == Qt::AscendingOrder ? cmp_func_count_a : cmp_func_count_d ; break;
|
||||||
|
case ccBytesAllocated: cf = order == Qt::AscendingOrder ? cmp_func_allocated_a : cmp_func_allocated_d; break;
|
||||||
|
case ccBytesUsed : cf = order == Qt::AscendingOrder ? cmp_func_used_a : cmp_func_used_d ; break;
|
||||||
|
default : break;
|
||||||
|
}
|
||||||
|
if (cf) cur_data.sort(cf);
|
||||||
|
#endif
|
||||||
//qDebug() << "sort" << column << order;
|
//qDebug() << "sort" << column << order;
|
||||||
dataChanged(index(0, 0), index(cur_data.size_s() - 1, columnCount()));
|
dataChanged(index(0, 0), index(cur_data.size_s() - 1, columnCount()));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -160,7 +160,7 @@ QString QPIIntrospector::durationStr(PISystemTime t) {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if PIP_VERSION >= PIP_MAKE_VERSION(2,35,0)
|
||||||
void QPIIntrospector::prepareContainers(PIVector<PIIntrospectionContainers::TypeInfo> & data) {
|
void QPIIntrospector::prepareContainers(PIVector<PIIntrospectionContainers::TypeInfo> & data) {
|
||||||
for (PIIntrospectionContainers::TypeInfo & i: data) {
|
for (PIIntrospectionContainers::TypeInfo & i: data) {
|
||||||
i.allocated_bytes = i.allocated * i.item_size;
|
i.allocated_bytes = i.allocated * i.item_size;
|
||||||
@@ -170,7 +170,7 @@ void QPIIntrospector::prepareContainers(PIVector<PIIntrospectionContainers::Type
|
|||||||
i.used_str.setReadableSize(i.used_bytes);
|
i.used_str.setReadableSize(i.used_bytes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void QPIIntrospector::on_listApp_currentRowChanged(int r) {
|
void QPIIntrospector::on_listApp_currentRowChanged(int r) {
|
||||||
PIString cs;
|
PIString cs;
|
||||||
@@ -207,7 +207,9 @@ void QPIIntrospector::peerReceived(const PIString & from, const PIByteArray & da
|
|||||||
pba.clear(); cs.get(pba);
|
pba.clear(); cs.get(pba);
|
||||||
PIVector<PIIntrospectionContainers::TypeInfo> data;
|
PIVector<PIIntrospectionContainers::TypeInfo> data;
|
||||||
PIIntrospection::unpackContainers(pba, data);
|
PIIntrospection::unpackContainers(pba, data);
|
||||||
|
#if PIP_VERSION >= PIP_MAKE_VERSION(2,35,0)
|
||||||
prepareContainers(data);
|
prepareContainers(data);
|
||||||
|
#endif
|
||||||
widgetContainers->showContainers(data);
|
widgetContainers->showContainers(data);
|
||||||
} break;
|
} break;
|
||||||
case PIIntrospection::itObjects: {
|
case PIIntrospection::itObjects: {
|
||||||
|
|||||||
Reference in New Issue
Block a user