Example #1
0
/* Function to compare elements for child array sort. a and b are children, user_data
points to a st_flags value */
extern gint
stat_node_array_sortcmp (gconstpointer a, gconstpointer b, gpointer user_data)
{
	/* user_data is *guint value to st_flags */
	return stats_tree_sort_compare (*(const stat_node**)a,*(const stat_node**)b,
					((sortinfo*)user_data)->sort_column,((sortinfo*)user_data)->sort_descending);
}
    bool operator< (const QTreeWidgetItem &other) const
    {
        stat_node *thisnode = VariantPointer<stat_node>::asPtr(data(item_col_, Qt::UserRole));
        stat_node *othernode = VariantPointer<stat_node>::asPtr(other.data(item_col_, Qt::UserRole));
        Qt::SortOrder order = treeWidget()->header()->sortIndicatorOrder();
        int result;

        result = stats_tree_sort_compare(thisnode, othernode, treeWidget()->sortColumn(),
                                         order==Qt::DescendingOrder);
        if (order==Qt::DescendingOrder) {
            result = -result;
        }
        return result < 0;
    }