debug piintrospector/containers_view.cpp

This commit is contained in:
Andrey
2022-04-14 16:34:30 +03:00
parent 1038fa968f
commit e92556e744

View File

@@ -165,13 +165,15 @@ bool cmp_func_name_a(const PIIntrospectionContainers::TypeInfo & t0, const PIInt
bool cmp_func_name_d(const PIIntrospectionContainers::TypeInfo & t0, const PIIntrospectionContainers::TypeInfo & t1) {
return !cmp_func_name_a(t0, t1);
}
void print_func_name(const PIIntrospectionContainers::TypeInfo & t) {qDebug() << PI2QString(t.name);}
# define CMP_FUNC(field) \
bool cmp_func_##field##_a(const PIIntrospectionContainers::TypeInfo & t0, const PIIntrospectionContainers::TypeInfo & t1) { \
return t0.field < t1.field; \
} \
bool cmp_func_##field##_d(const PIIntrospectionContainers::TypeInfo & t0, const PIIntrospectionContainers::TypeInfo & t1) { \
return t0.field > t1.field; \
}
} \
void print_func_##field(const PIIntrospectionContainers::TypeInfo & t) {qDebug() << t.field;}
#else
int cmp_func_name_a(const PIIntrospectionContainers::TypeInfo * t0, const PIIntrospectionContainers::TypeInfo * t1) {
return QString::localeAwareCompare(PI2QString(t0->name), PI2QString(t1->name));
@@ -197,16 +199,21 @@ void ContainersModel::sort(int column, Qt::SortOrder order) {
ls_order = order;
if (cur_data.isEmpty()) return;
PIVector<PIIntrospectionContainers::TypeInfo>::CompareFunc cf = nullptr;
std::function<void(PIIntrospectionContainers::TypeInfo & e)> pf;
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;
case ccType : cf = order == Qt::AscendingOrder ? cmp_func_name_a : cmp_func_name_d ; pf = print_func_name; break;
case ccItemSize : cf = order == Qt::AscendingOrder ? cmp_func_item_size_a : cmp_func_item_size_d; pf = print_func_item_size; break;
case ccCount : cf = order == Qt::AscendingOrder ? cmp_func_count_a : cmp_func_count_d ; pf = print_func_count; break;
case ccBytesAllocated: cf = order == Qt::AscendingOrder ? cmp_func_allocated_a : cmp_func_allocated_d; pf = print_func_allocated; break;
case ccBytesUsed : cf = order == Qt::AscendingOrder ? cmp_func_used_a : cmp_func_used_d ; pf = print_func_used; break;
default : break;
}
if (cf)
if (cf) {
cur_data.forEach(pf);
cur_data.sort(cf);
qDebug() << "sort" << column << order;
cur_data.forEach(pf);
}
//qDebug() << "sort" << column << order;
dataChanged(index(0, 0), index(cur_data.size_s() - 1, columnCount()));
}