diff options
author | Cristiana Voicu <cristiana.voicu@intel.com> | 2013-03-20 14:35:06 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2013-03-22 16:54:39 +0000 |
commit | 860f826753cab81b1d1d9b2ecafa630a96676d9e (patch) | |
tree | 6f5da66864b05ded2f96c76ce9299a3386fa9c1f /bitbake/lib/bb/ui/crumbs/recipeselectionpage.py | |
parent | ab7d8bd172f61e14266a020bd6633d33d79e3d8f (diff) | |
download | ast2050-yocto-poky-860f826753cab81b1d1d9b2ecafa630a96676d9e.zip ast2050-yocto-poky-860f826753cab81b1d1d9b2ecafa630a96676d9e.tar.gz |
bitbake: hob: implementation of search functionality in Hob
Implemented the search functionality for recipes and packages using
filters on the listmodel. I have used the design which can be found in
bugzilla.
[YOCTO #3529]
(Bitbake rev: b77166ad7b8571895f73a84f7789d93fbd4f6d04)
Signed-off-by: Cristiana Voicu <cristiana.voicu@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/ui/crumbs/recipeselectionpage.py')
-rwxr-xr-x | bitbake/lib/bb/ui/crumbs/recipeselectionpage.py | 67 |
1 files changed, 47 insertions, 20 deletions
diff --git a/bitbake/lib/bb/ui/crumbs/recipeselectionpage.py b/bitbake/lib/bb/ui/crumbs/recipeselectionpage.py index 636762e..aa0cd60 100755 --- a/bitbake/lib/bb/ui/crumbs/recipeselectionpage.py +++ b/bitbake/lib/bb/ui/crumbs/recipeselectionpage.py @@ -33,11 +33,13 @@ from bb.ui.crumbs.hobpages import HobPage class RecipeSelectionPage (HobPage): pages = [ { - 'name' : 'Included recipes', - 'tooltip' : 'The recipes currently included for your image', - 'filter' : { RecipeListModel.COL_INC : [True], + 'name' : 'Included recipes', + 'tooltip' : 'The recipes currently included for your image', + 'filter' : { RecipeListModel.COL_INC : [True], RecipeListModel.COL_TYPE : ['recipe', 'packagegroup'] }, - 'columns' : [{ + 'search' : 'Search recipes by name', + 'searchtip' : 'Enter a recipe name to find it', + 'columns' : [{ 'col_name' : 'Recipe name', 'col_id' : RecipeListModel.COL_NAME, 'col_style': 'text', @@ -66,10 +68,12 @@ class RecipeSelectionPage (HobPage): 'col_max' : 100 }] }, { - 'name' : 'All recipes', - 'tooltip' : 'All recipes in your configured layers', - 'filter' : { RecipeListModel.COL_TYPE : ['recipe'] }, - 'columns' : [{ + 'name' : 'All recipes', + 'tooltip' : 'All recipes in your configured layers', + 'filter' : { RecipeListModel.COL_TYPE : ['recipe'] }, + 'search' : 'Search recipes by name', + 'searchtip' : 'Enter a recipe name to find it', + 'columns' : [{ 'col_name' : 'Recipe name', 'col_id' : RecipeListModel.COL_NAME, 'col_style': 'text', @@ -98,10 +102,12 @@ class RecipeSelectionPage (HobPage): 'col_max' : 100 }] }, { - 'name' : 'Package Groups', - 'tooltip' : 'All package groups in your configured layers', - 'filter' : { RecipeListModel.COL_TYPE : ['packagegroup'] }, - 'columns' : [{ + 'name' : 'Package Groups', + 'tooltip' : 'All package groups in your configured layers', + 'filter' : { RecipeListModel.COL_TYPE : ['packagegroup'] }, + 'search' : 'Search package groups by name', + 'searchtip' : 'Enter a package group name to find it', + 'columns' : [{ 'col_name' : 'Package group name', 'col_id' : RecipeListModel.COL_NAME, 'col_style': 'text', @@ -142,12 +148,18 @@ class RecipeSelectionPage (HobPage): # set visible members self.ins = HobNotebook() self.tables = [] # we need modify table when the dialog is shown + + search_names = [] + search_tips = [] # append the tabs in order for page in self.pages: columns = page['columns'] tab = HobViewTable(columns) + search_names.append(page['search']) + search_tips.append(page['searchtip']) filter = page['filter'] - tab.set_model(self.recipe_model.tree_model(filter)) + sort_model = self.recipe_model.tree_model(filter) + tab.set_model(sort_model) tab.connect("toggled", self.table_toggled_cb, page['name']) if page['name'] == "Included recipes": tab.connect("button-release-event", self.button_click_cb) @@ -161,13 +173,8 @@ class RecipeSelectionPage (HobPage): self.ins.append_page(tab, page['name'], page['tooltip']) self.tables.append(tab) - self.ins.set_entry("Search recipes:") - # set the search entry for each table - for tab in self.tables: - search_tip = "Enter a recipe's or task's name to find it" - self.ins.search.set_tooltip_text(search_tip) - self.ins.search.props.has_tooltip = True - tab.set_search_entry(0, self.ins.search) + self.ins.set_entry(search_names, search_tips) + self.ins.search.connect("changed", self.search_entry_changed) # add all into the window self.box_group_area.pack_start(self.ins, expand=True, fill=True) @@ -187,6 +194,26 @@ class RecipeSelectionPage (HobPage): self.back_button.connect("clicked", self.back_button_clicked_cb) button_box.pack_end(self.back_button, expand=False, fill=False) + def search_entry_changed(self, entry): + current_tab = self.ins.get_current_page() + filter = self.pages[current_tab]['filter'] + text = entry.get_text() + filter[RecipeListModel.COL_NAME] = text + self.tables[current_tab].set_model(self.recipe_model.tree_model(filter, search_data=text)) + if self.recipe_model.filtered_nb == 0: + if not self.ins.get_nth_page(current_tab).top_bar: + self.ins.get_nth_page(current_tab).add_no_result_bar(entry) + self.ins.get_nth_page(current_tab).top_bar.show() + self.ins.get_nth_page(current_tab).scroll.hide() + else: + if self.ins.get_nth_page(current_tab).top_bar: + self.ins.get_nth_page(current_tab).top_bar.hide() + self.ins.get_nth_page(current_tab).scroll.show() + if entry.get_text() == '': + entry.set_icon_sensitive(gtk.ENTRY_ICON_SECONDARY, False) + else: + entry.set_icon_sensitive(gtk.ENTRY_ICON_SECONDARY, True) + def button_click_cb(self, widget, event): path, col = widget.table_tree.get_cursor() tree_model = widget.table_tree.get_model() |