piintrospector/containers_view.cpp

This commit is contained in:
2022-04-14 16:12:32 +03:00
parent 3c4a230c63
commit 969f45afd6

View File

@@ -158,19 +158,19 @@ Qt::ItemFlags ContainersModel::flags(const QModelIndex & index) const {
//bool cmp(const PIIntrospectionContainers::TypeInfo & a, const PIIntrospectionContainers::TypeInfo & b);
#if PIP_VERSION > PIP_MAKE_VERSION(2,34,1)
#if PIP_VERSION >= PIP_MAKE_VERSION(2,35,0)
bool cmp_func_name_a(const PIIntrospectionContainers::TypeInfo & t0, const PIIntrospectionContainers::TypeInfo & t1) {
return QString::localeAwareCompare(PI2QString(t0.name), PI2QString(t1.name)) > 0;
return QString::localeAwareCompare(PI2QString(t0.name), PI2QString(t1.name)) < 0;
}
bool cmp_func_name_d(const PIIntrospectionContainers::TypeInfo & t0, const PIIntrospectionContainers::TypeInfo & t1) {
return -cmp_func_name_a(t0, t1);
return !cmp_func_name_a(t0, t1);
}
# 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 -cmp_func_##field##_a(t0, t1); \
return t0.field > t1.field; \
}
#else
int cmp_func_name_a(const PIIntrospectionContainers::TypeInfo * t0, const PIIntrospectionContainers::TypeInfo * t1) {
@@ -198,11 +198,11 @@ void ContainersModel::sort(int column, Qt::SortOrder order) {
if (cur_data.isEmpty()) return;
PIVector<PIIntrospectionContainers::TypeInfo>::CompareFunc cf = nullptr;
switch (column) {
case ccType : cf = order == Qt::AscendingOrder ? cmp_func_name_a : cmp_func_name_d; break;
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 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 ccBytesUsed : cf = order == Qt::AscendingOrder ? cmp_func_used_a : cmp_func_used_d ; break;
default : break;
}
if (cf)