This commit is contained in:
2022-04-13 12:31:29 +03:00
parent 2319b77f84
commit 3f92f67d48

View File

@@ -158,19 +158,35 @@ 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)
bool cmp_func_name_a(const PIIntrospectionContainers::TypeInfo & t0, const PIIntrospectionContainers::TypeInfo & t1) {
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);
}
# 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); \
}
#else
int cmp_func_name_a(const PIIntrospectionContainers::TypeInfo * t0, const PIIntrospectionContainers::TypeInfo * t1) {
return QString::localeAwareCompare(PI2QString(t0->name), PI2QString(t1->name));
}
int cmp_func_name_d(const PIIntrospectionContainers::TypeInfo * t0, const PIIntrospectionContainers::TypeInfo * t1) {
return -cmp_func_name_a(t0, t1);
}
#define CMP_FUNC(field) \
# define CMP_FUNC(field) \
int cmp_func_##field##_a(const PIIntrospectionContainers::TypeInfo * t0, const PIIntrospectionContainers::TypeInfo * t1) { \
return (t0->field) <= (t1->field) ? -1 : ((t0->field) == (t1->field) ? 0 : 1); \
} \
int cmp_func_##field##_d(const PIIntrospectionContainers::TypeInfo * t0, const PIIntrospectionContainers::TypeInfo * t1) { \
return -cmp_func_##field##_a(t0, t1); \
}
#endif
CMP_FUNC(item_size)
CMP_FUNC(count)
CMP_FUNC(allocated)
@@ -180,7 +196,7 @@ void ContainersModel::sort(int column, Qt::SortOrder order) {
ls_column = column;
ls_order = order;
if (cur_data.isEmpty()) return;
PIVector<PIIntrospectionContainers::TypeInfo>::CompareFunc cf = 0;
PIVector<PIIntrospectionContainers::TypeInfo>::CompareFunc cf = nullptr;
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;