528
541
//used only in register
529
void filter_preset_daterange_add_futuregap(Filter *filter, gint nbdays)
542
void filter_preset_daterange_add_futuregap(Filter *flt, gint nbdays)
544
g_return_if_fail( flt != NULL );
531
546
DB( g_print("\n[filter] range add future gap\n") );
533
filter->nbdaysfuture = 0;
548
flt->nbdaysfuture = 0;
534
549
//#1840998 if future active and visible: we should always maxdate to today + nbdays
535
if( filter_preset_daterange_future_enable(filter, filter->range) )
550
if( filter_preset_daterange_future_enable(flt, flt->range) )
537
552
guint32 jforcedmax = GLOBALS->today + nbdays;
539
if( filter->maxdate < jforcedmax )
540
filter->nbdaysfuture = jforcedmax - filter->maxdate;
554
if( flt->maxdate < jforcedmax )
555
flt->nbdaysfuture = jforcedmax - flt->maxdate;
542
557
// filter->nbdaysfuture = nbdays;
544
DB( g_print(" today=%d, tmpmax=%d, nbdays=%d\n final=%d", GLOBALS->today, jforcedmax, nbdays, filter->nbdaysfuture) );
559
DB( g_print(" today=%d, tmpmax=%d, nbdays=%d\n final=%d", GLOBALS->today, jforcedmax, nbdays, flt->nbdaysfuture) );
763
782
/* = = = = = = = = = = = = = = = = */
766
static void filter_group_import_keys(Filter *flt, gint group, gchar *text)
771
DB( g_print(" import keys '%s'\n", text) );
773
str_array = g_strsplit (text, ",", -1);
774
len = g_strv_length( str_array );
777
guint32 key = atoi(str_array[i]);
782
case FLT_GRP_ACCOUNT:
785
da_flt_status_acc_set(flt, key, TRUE);
786
DB( g_print(" set acc='%d' to true\n", key) );
792
da_flt_status_pay_set(flt, key, TRUE);
793
DB( g_print(" set pay='%d' to true\n", key) );
796
case FLT_GRP_CATEGORY:
799
da_flt_status_cat_set(flt, key, TRUE);
800
DB( g_print(" set cat='%d' to true\n", key) );
804
da_flt_status_tag_set(flt, key, TRUE);
808
g_strfreev(str_array);
812
void filter_group_import(Filter *flt, gint group, const gchar *text)
821
str_array = g_strsplit (text, "|", 4);
822
len = g_strv_length( str_array );
826
flt->option[group] = atoi(str_array[0]);
827
flt->range = atoi(str_array[1]);
829
if(len == 4 && flt->range == FLT_RANGE_MISC_CUSTOM)
831
flt->mindate = atoi(str_array[2]);
832
flt->maxdate = atoi(str_array[3]);
834
g_strfreev(str_array);
837
case FLT_GRP_ACCOUNT:
838
str_array = g_strsplit (text, "|", 2);
839
len = g_strv_length( str_array );
843
flt->option[group] = atoi(str_array[0]);
844
filter_group_import_keys(flt, FLT_GRP_ACCOUNT, str_array[1]);
846
g_strfreev(str_array);
850
str_array = g_strsplit (text, "|", 2);
851
len = g_strv_length( str_array );
855
flt->option[group] = atoi(str_array[0]);
856
filter_group_import_keys(flt, FLT_GRP_PAYEE, str_array[1]);
858
g_strfreev(str_array);
861
case FLT_GRP_CATEGORY:
862
str_array = g_strsplit (text, "|", 2);
863
len = g_strv_length( str_array );
867
flt->option[group] = atoi(str_array[0]);
868
filter_group_import_keys(flt, FLT_GRP_CATEGORY, str_array[1]);
870
g_strfreev(str_array);
880
gchar *filter_group_export(Filter *flt, gint group)
882
gchar *retval = NULL;
889
if(flt->option[group] > 0)
891
//TODO: maybe always keep 4 values here
892
if(flt->range == FLT_RANGE_MISC_CUSTOM)
893
retval = g_strdup_printf("%d|%d|%d|%d", flt->option[group], flt->range, flt->mindate, flt->maxdate);
895
retval = g_strdup_printf("%d|%d", flt->option[group], flt->range);
898
case FLT_GRP_ACCOUNT:
899
if(flt->option[group] > 0)
901
node = g_string_sized_new(flt->gbacc->len);
902
g_string_append_printf(node, "%d|", flt->option[group]);
903
DB( g_printf("acc len:%d\n", flt->gbacc->len) );
904
for(i=0;i<flt->gbacc->len;i++)
907
if( da_flt_status_acc_get(flt, i) == TRUE )
908
g_string_append_printf(node, "%d,", i);
910
g_string_erase(node, node->len-1, 1);
912
g_string_free(node, FALSE);
913
DB( g_printf(" '%s'\n", retval) );
918
if(flt->option[group] > 0)
920
node = g_string_sized_new(flt->gbpay->len);
921
g_string_append_printf(node, "%d|", flt->option[group]);
922
DB( g_printf("pay len:%d\n", flt->gbpay->len) );
923
for(i=0;i<flt->gbpay->len;i++)
926
if( da_flt_status_pay_get(flt, i) == TRUE )
927
g_string_append_printf(node, "%d,", i);
929
g_string_erase(node, node->len-1, 1);
931
g_string_free(node, FALSE);
932
DB( g_printf(" '%s'\n", retval) );
936
case FLT_GRP_CATEGORY:
937
if(flt->option[group] > 0)
939
node = g_string_sized_new(flt->gbcat->len);
940
g_string_append_printf(node, "%d|", flt->option[group]);
941
DB( g_printf("cat len:%d\n", flt->gbcat->len) );
942
for(i=0;i<flt->gbcat->len;i++)
945
if( da_flt_status_cat_get(flt, i) == TRUE )
946
g_string_append_printf(node, "%d,", i);
948
g_string_erase(node, node->len-1, 1);
950
g_string_free(node, FALSE);
951
DB( g_printf(" '%s'\n", retval) );
955
if(flt->option[group] > 0)
962
if(flt->option[group] > 0)
969
if(flt->option[group] > 0)
975
case FLT_GRP_PAYMODE:
976
if(flt->option[group] > 0)
983
if(flt->option[group] > 0)
990
if(flt->option[group] > 0)
1002
785
void filter_preset_status_set(Filter *flt, gint status)
788
g_return_if_fail( flt != NULL );
1005
790
DB( g_print("\n[filter] preset status set\n") );
1007
792
/* any status */