Ticket #1225: gui_internal_poi_zip_filter.diff

File gui_internal_poi_zip_filter.diff, 5.2 KB (added by tryagain, 7 years ago)

Add address search with ZIP in internal gui POI filter.

  • navit/gui/internal/gui_internal_command.c

     
    642642        if (in[1] && ATTR_IS_STRING(in[1]->type)) {
    643643                gui_internal_poi_param_set_filter(param, in[1]->u.str);
    644644                if (in[2] && ATTR_IS_INT(in[2]->type))
    645                         param->isAddressFilter=in[2]->u.num;
     645                        param->AddressFilterType=in[2]->u.num;
    646646        }
    647647       
    648648        transform_from_geo(pro.u.projection,in[0]->u.coord_geo,&c);
  • navit/gui/internal/gui_internal_poi.c

     
    301301        type=item_to_name(item->type);
    302302
    303303        icon=gui_internal_poi_icon(this,item);
     304        if(!icon && item->type==type_house_number)
     305                icon=image_new_xs(this,"post");
    304306        if(!icon) {
    305307                icon=image_new_xs(this,"gui_inactive");
    306308                text=g_strdup_printf("%s%s%s%s %s", distbuf, dirbuf, routedistbuf, type, name);
     
    332334 */
    333335
    334336char *
    335 gui_internal_compose_item_address_string(struct item *item)
     337gui_internal_compose_item_address_string(struct item *item, int prependPostal)
    336338{
    337339        char *s=g_strdup("");
    338340        struct attr attr;
     341        if(prependPostal && item_attr_get(item, attr_postal, &attr))
     342                s=g_strjoin(" ",s,map_convert_string_tmp(item->map,attr.u.str),NULL);
    339343        if(item_attr_get(item, attr_house_number, &attr))
    340344                s=g_strjoin(" ",s,map_convert_string_tmp(item->map,attr.u.str),NULL);
    341345        if(item_attr_get(item, attr_street_name, &attr))
     
    383387                char *long_name, *s;
    384388                GList *f;
    385389                int i;
    386                 if (param->isAddressFilter) {
    387                         s=gui_internal_compose_item_address_string(item);
     390                if (param->AddressFilterType>0) {
     391                        s=gui_internal_compose_item_address_string(item,param->AddressFilterType==2?1:0);
    388392                } else if (item_attr_get(item, attr_label, &attr)) {
    389393                        s=g_strdup_printf("%s %s", item_to_name(item->type), map_convert_string_tmp(item->map,attr.u.str));
    390394                } else {
     
    455459        } else {
    456460                param=g_new0(struct poi_param,1);
    457461        }
    458         param->isAddressFilter=strcmp(wm->name,"AddressFilter")==0;
     462        if(!strcmp(wm->name,"AddressFilter"))
     463                param->AddressFilterType=1;
     464        else if(!strcmp(wm->name,"AddressFilterZip"))
     465                param->AddressFilterType=2;
     466        else
     467                param->AddressFilterType=0;
    459468
    460469        gui_internal_poi_param_set_filter(param, w->text);
    461470
     
    516525        wb->name=g_strdup("AddressFilter");
    517526        wb->func = gui_internal_cmd_pois_filter_do;
    518527        wb->data=wk;
     528        gui_internal_widget_append(we, wb=gui_internal_image_new(this, image_new_xs(this, "library")));
     529        wb->state |= STATE_SENSITIVE;
     530        wb->name=g_strdup("AddressFilterZip");
     531        wb->func = gui_internal_cmd_pois_filter_do;
     532        wb->data=wk;
    519533       
    520534        if (this->keyboard)
    521535                gui_internal_widget_append(w, gui_internal_keyboard(this,keyboard_mode));
     
    582596        items= g_new0( struct item_data, maxitem);
    583597       
    584598       
    585         dbg(2, "Params: sel = %i, selnb = %i, pagenb = %i, dist = %i, filterstr = %s, isAddressFilter= %d\n",
    586                 param->sel, param->selnb, param->pagenb, param->dist, param->filterstr, param->isAddressFilter);
     599        dbg(2, "Params: sel = %i, selnb = %i, pagenb = %i, dist = %i, filterstr = %s, AddressFilterType= %d\n",
     600                param->sel, param->selnb, param->pagenb, param->dist, param->filterstr, param->AddressFilterType);
    587601
    588602        wb=gui_internal_menu(this, isel ? isel->name : _("POIs"));
    589603        w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
     
    612626                                        char *label;
    613627                                        item_attr_rewind(item);
    614628                                        if (item->type==type_house_number) {
    615                                                 label=gui_internal_compose_item_address_string(item);
     629                                                label=gui_internal_compose_item_address_string(item,1);
    616630                                        } else if (item_attr_get(item, attr_label, &attr)) {
    617631                                                label=map_convert_string(item->map,attr.u.str);
    618632                                                // Buildings which label is equal to addr:housenumber value
  • navit/gui/internal/gui_internal_poi.h

     
    2525                unsigned char dist;
    2626                /**
    2727                 * Should filter phrase be compared to postal address of the POI.
    28                  * =1 - address filter, =0 - name filter
     28                 * =0 - name filter, =1 - address filter, =2 - address filter, including postal code
    2929                 */             
    30                 unsigned char isAddressFilter;
     30                unsigned char AddressFilterType;
    3131                /**
    3232                 * Filter string, casefold()ed and divided into substrings at the spaces, which are replaced by ASCII 0*.
    3333                 */             
     
    5151void gui_internal_poi_param_free(void *p);
    5252void gui_internal_poi_param_set_filter(struct poi_param *param, char *text);
    5353struct widget *gui_internal_cmd_pois_item(struct gui_priv *this, struct coord *center, struct item *item, struct coord *c, struct route *route, int dist, char *name);
    54 char *gui_internal_compose_item_address_string(struct item *item);
     54char *gui_internal_compose_item_address_string(struct item *item, int prependPostal);
    5555void gui_internal_cmd_pois_filter(struct gui_priv *this, struct widget *wm, void *data);
    5656void gui_internal_cmd_pois(struct gui_priv *this, struct widget *wm, void *data);
    5757/* end of prototypes */