cl: Add new setting to select default sorting options #161

This commit is contained in:
Kaian 2016-12-14 15:21:49 +01:00
parent 4f7ef13e2e
commit fed8f0f410
5 changed files with 15 additions and 5 deletions

View File

@ -57,6 +57,8 @@ setting_t settings[SETTING_COUNT] = {
{ SETTING_CL_SCROLLSTEP, "cl.scrollstep", SETTING_FMT_NUMBER, "4", NULL },
{ SETTING_CL_COLORATTR, "cl.colorattr", SETTING_FMT_ENUM, SETTING_ON, SETTING_ENUM_ONOFF },
{ SETTING_CL_AUTOSCROLL, "cl.autoscroll", SETTING_FMT_ENUM, SETTING_OFF, SETTING_ENUM_ONOFF },
{ SETTING_CL_SORTFIELD, "cl.sortfield", SETTING_FMT_STRING, "index", NULL },
{ SETTING_CL_SORTORDER, "cl.sortorder", SETTING_FMT_STRING, "asc", NULL },
{ SETTING_CF_FORCERAW, "cf.forceraw", SETTING_FMT_ENUM, SETTING_ON, SETTING_ENUM_ONOFF },
{ SETTING_CF_RAWMINWIDTH, "cf.rawminwidth", SETTING_FMT_NUMBER, "40", NULL },
{ SETTING_CF_RAWFIXEDWIDTH, "cf.rawfixedwidth", SETTING_FMT_NUMBER, "", NULL },

View File

@ -87,6 +87,8 @@ enum setting_id {
SETTING_CL_SCROLLSTEP,
SETTING_CL_COLORATTR,
SETTING_CL_AUTOSCROLL,
SETTING_CL_SORTFIELD,
SETTING_CL_SORTORDER,
SETTING_CF_FORCERAW,
SETTING_CF_RAWMINWIDTH,
SETTING_CF_RAWFIXEDWIDTH,

View File

@ -156,9 +156,15 @@ sip_init(int limit, int only_calls, int no_incomplete)
// Create hash table for callid search
calls.callids = htable_create(calls.limit);
// By default sort by call index ascending
calls.sort.by = SIP_ATTR_CALLINDEX;
calls.sort.asc = true;
// Set default sorting field
if (sip_attr_from_name(setting_get_value(SETTING_CL_SORTFIELD)) >= 0) {
calls.sort.by = sip_attr_from_name(setting_get_value(SETTING_CL_SORTFIELD));
calls.sort.asc = (!strcmp(setting_get_value(SETTING_CL_SORTORDER), "asc"));
} else {
// Fallback to default sorting field
calls.sort.by = SIP_ATTR_CALLINDEX;
calls.sort.asc = true;
}
// Initialize payload parsing regexp
match_flags = REG_EXTENDED | REG_ICASE | REG_NEWLINE;

View File

@ -105,7 +105,7 @@ sip_attr_get_width(enum sip_attr_id id)
return 0;
}
enum sip_attr_id
int
sip_attr_from_name(const char *name)
{
int i;

View File

@ -187,7 +187,7 @@ sip_attr_get_width(enum sip_attr_id id);
* @param name Attribut name
* @return Attribute id or -1 if not found
*/
enum sip_attr_id
int
sip_attr_from_name(const char *name);
/**