From 8020be30fd46798aa61017f0ec936806d6495d07 Mon Sep 17 00:00:00 2001 From: Roland Knall Date: Tue, 27 Jun 2017 16:36:19 +0200 Subject: Qt: Drag/Drop Filter buttons to order Allow the ordering of the filter buttons via drag/drop in the toolbar Change-Id: Id8793d6514bae36066a7a23d6890985665e753bd Reviewed-on: https://code.wireshark.org/review/22422 Petri-Dish: Roland Knall Tested-by: Petri Dish Buildbot Reviewed-by: Roland Knall --- epan/uat-int.h | 6 ++++++ epan/uat.c | 14 ++++++++++++++ 2 files changed, 20 insertions(+) (limited to 'epan') diff --git a/epan/uat-int.h b/epan/uat-int.h index c36a5c136e..a272c8f209 100644 --- a/epan/uat-int.h +++ b/epan/uat-int.h @@ -111,6 +111,12 @@ void uat_insert_record_idx(uat_t *uat, guint rec_idx, const void *src_record); WS_DLL_PUBLIC void uat_remove_record_idx(uat_t *uat, guint rec_idx); +/** + * Moves the entry from the old position to the new one + */ +WS_DLL_PUBLIC +void uat_move_index(uat_t *uat, guint old_idx, guint new_idx); + /** * Removes and destroys all records from the UAT. */ diff --git a/epan/uat.c b/epan/uat.c index 71403485b7..03f73d2a34 100644 --- a/epan/uat.c +++ b/epan/uat.c @@ -225,6 +225,20 @@ void uat_remove_record_idx(uat_t* uat, guint idx) { g_array_remove_index(uat->valid_data, idx); } +void uat_move_index(uat_t * uat, guint old_idx, guint new_idx) +{ + guint dir = 1; + guint start = old_idx; + if ( old_idx > new_idx ) + dir = -1; + + while ( start != new_idx ) + { + uat_swap(uat, start, start + dir); + start += dir; + } +} + /* The returned filename was g_malloc()'d so the caller must free it */ gchar* uat_get_actual_filename(uat_t* uat, gboolean for_writing) { gchar *pers_fname = NULL; -- cgit v1.2.1