mirror of https://github.com/djcb/mu.git
* threader/container: support reverse sorting for threaded output, some cleanups
This commit is contained in:
parent
f3264affba
commit
c8f869e041
|
@ -300,7 +300,7 @@ mu_container_from_list (GSList *lst)
|
|||
|
||||
struct _SortFuncData {
|
||||
MuMsgFieldId mfid;
|
||||
gboolean invert;
|
||||
gboolean revert;
|
||||
gpointer user_data;
|
||||
};
|
||||
typedef struct _SortFuncData SortFuncData;
|
||||
|
@ -323,7 +323,7 @@ sort_func_wrapper (MuContainer *a, MuContainer *b, SortFuncData *data)
|
|||
else if (!b1->msg)
|
||||
return -1;
|
||||
|
||||
if (data->invert)
|
||||
if (data->revert)
|
||||
return mu_msg_cmp (b1->msg, a1->msg, data->mfid);
|
||||
else
|
||||
return mu_msg_cmp (a1->msg, b1->msg, data->mfid);
|
||||
|
@ -355,14 +355,14 @@ mu_container_sort_real (MuContainer *c, SortFuncData *sfdata)
|
|||
|
||||
|
||||
MuContainer*
|
||||
mu_container_sort (MuContainer *c, MuMsgFieldId mfid, gpointer user_data,
|
||||
gboolean invert)
|
||||
mu_container_sort (MuContainer *c, MuMsgFieldId mfid, gboolean revert,
|
||||
gpointer user_data)
|
||||
{
|
||||
|
||||
SortFuncData sfdata;
|
||||
|
||||
sfdata.mfid = mfid;
|
||||
sfdata.invert = invert;
|
||||
sfdata.revert = revert;
|
||||
sfdata.user_data = user_data;
|
||||
|
||||
g_return_val_if_fail (c, NULL);
|
||||
|
|
|
@ -172,13 +172,13 @@ typedef int (*MuContainerCmpFunc) (MuContainer *c1, MuContainer *c2,
|
|||
*
|
||||
* @param c a container
|
||||
* @param mfid the field to sort by
|
||||
* @param revert if TRUE, revert the sorting order *
|
||||
* @param user_data a user pointer to pass to the sorting function
|
||||
* @param invert if TRUE, invert the sorting order
|
||||
*
|
||||
* @return a sorted container
|
||||
*/
|
||||
MuContainer* mu_container_sort (MuContainer *c, MuMsgFieldId mfid,
|
||||
gpointer user_data, gboolean invert);
|
||||
MuContainer* mu_container_sort (MuContainer *c, MuMsgFieldId mfid, gboolean revert,
|
||||
gpointer user_data);
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -58,7 +58,8 @@ GHashTable* create_doc_id_thread_path_hash (MuContainer *root, size_t match_num)
|
|||
/* msg threading algorithm, based on JWZ's algorithm,
|
||||
* http://www.jwz.org/doc/threading.html */
|
||||
GHashTable*
|
||||
mu_threader_calculate (MuMsgIter *iter, size_t matchnum, MuMsgFieldId sortfield)
|
||||
mu_threader_calculate (MuMsgIter *iter, size_t matchnum,
|
||||
MuMsgFieldId sortfield, gboolean revert)
|
||||
{
|
||||
GHashTable *id_table, *thread_ids;
|
||||
MuContainer *root_set;
|
||||
|
@ -81,8 +82,8 @@ mu_threader_calculate (MuMsgIter *iter, size_t matchnum, MuMsgFieldId sortfield)
|
|||
|
||||
/* sort root set */
|
||||
if (sortfield != MU_MSG_FIELD_ID_NONE)
|
||||
root_set = mu_container_sort (root_set, sortfield,
|
||||
NULL, FALSE);
|
||||
root_set = mu_container_sort (root_set, sortfield, revert,
|
||||
NULL);
|
||||
|
||||
/* step 5: group root set by subject */
|
||||
/* group_root_set_by_subject (root_set); */
|
||||
|
|
|
@ -43,11 +43,12 @@ G_BEGIN_DECLS
|
|||
* @param matches the number of matches in the set *
|
||||
* @param sortfield the field to sort results by, or
|
||||
* MU_MSG_FIELD_ID_NONE if no sorting should be performed
|
||||
* @param revert if TRUE, if revert the sorting order
|
||||
*
|
||||
* @return a hashtable; free with g_hash_table_destroy when done with it
|
||||
*/
|
||||
GHashTable *mu_threader_calculate (MuMsgIter *iter, size_t matches,
|
||||
MuMsgFieldId sortfield);
|
||||
MuMsgFieldId sortfield, gboolean revert);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
|
Loading…
Reference in New Issue