summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCristiana Voicu <cristiana.voicu@intel.com>2013-05-07 11:07:53 +0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-05-10 13:33:33 +0100
commit39d3409d31b7d81a4fe5435935e28f994edfa402 (patch)
tree42f4430431caa80916d6c76209bdd80f7f5bfae5
parent6dab4d0148289de730ea323cf6b98b5fb4e49b11 (diff)
downloadpoky-39d3409d31b7d81a4fe5435935e28f994edfa402.tar.gz
bitbake: hob: sort alphabetically results in groups of recipes/packages
When you search a string, there are 2 groups: recipes/packages starting with that string, and the rest. These 2 groups are now sorted. [YOCTO #4111] (Bitbake rev: 8d2b2a1c97570d3c6b40727f1afa1db8c00882f9) Signed-off-by: Cristiana Voicu <cristiana.voicu@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--bitbake/lib/bb/ui/crumbs/hoblistmodel.py38
1 files changed, 12 insertions, 26 deletions
diff --git a/bitbake/lib/bb/ui/crumbs/hoblistmodel.py b/bitbake/lib/bb/ui/crumbs/hoblistmodel.py
index 547c1cade9..42fd6ce27d 100644
--- a/bitbake/lib/bb/ui/crumbs/hoblistmodel.py
+++ b/bitbake/lib/bb/ui/crumbs/hoblistmodel.py
@@ -152,12 +152,7 @@ class PackageListModel(gtk.ListStore):
152 if user_data: 152 if user_data:
153 val1 = model.get_value(iter1, PackageListModel.COL_NAME) 153 val1 = model.get_value(iter1, PackageListModel.COL_NAME)
154 val2 = model.get_value(iter2, PackageListModel.COL_NAME) 154 val2 = model.get_value(iter2, PackageListModel.COL_NAME)
155 if val1.startswith(user_data) and not val2.startswith(user_data): 155 return self.cmp_vals(val1, val2, user_data)
156 return -1
157 elif not val1.startswith(user_data) and val2.startswith(user_data):
158 return 1
159 else:
160 return 0
161 else: 156 else:
162 val1 = model.get_value(iter1, PackageListModel.COL_FADE_INC) 157 val1 = model.get_value(iter1, PackageListModel.COL_FADE_INC)
163 val2 = model.get_value(iter2, PackageListModel.COL_INC) 158 val2 = model.get_value(iter2, PackageListModel.COL_INC)
@@ -167,12 +162,7 @@ class PackageListModel(gtk.ListStore):
167 if user_data: 162 if user_data:
168 val1 = model.get_value(iter1, PackageListModel.COL_NAME) 163 val1 = model.get_value(iter1, PackageListModel.COL_NAME)
169 val2 = model.get_value(iter2, PackageListModel.COL_NAME) 164 val2 = model.get_value(iter2, PackageListModel.COL_NAME)
170 if val1.startswith(user_data) and not val2.startswith(user_data): 165 return self.cmp_vals(val1, val2, user_data)
171 return -1
172 elif not val1.startswith(user_data) and val2.startswith(user_data):
173 return 1
174 else:
175 return 0
176 else: 166 else:
177 val1 = model.get_value(iter1, PackageListModel.COL_INC) 167 val1 = model.get_value(iter1, PackageListModel.COL_INC)
178 val2 = model.get_value(iter2, PackageListModel.COL_INC) 168 val2 = model.get_value(iter2, PackageListModel.COL_INC)
@@ -181,12 +171,15 @@ class PackageListModel(gtk.ListStore):
181 def sort_func(self, model, iter1, iter2, user_data): 171 def sort_func(self, model, iter1, iter2, user_data):
182 val1 = model.get_value(iter1, PackageListModel.COL_NAME) 172 val1 = model.get_value(iter1, PackageListModel.COL_NAME)
183 val2 = model.get_value(iter2, PackageListModel.COL_NAME) 173 val2 = model.get_value(iter2, PackageListModel.COL_NAME)
174 return self.cmp_vals(val1, val2, user_data)
175
176 def cmp_vals(self, val1, val2, user_data):
184 if val1.startswith(user_data) and not val2.startswith(user_data): 177 if val1.startswith(user_data) and not val2.startswith(user_data):
185 return -1 178 return -1
186 elif not val1.startswith(user_data) and val2.startswith(user_data): 179 elif not val1.startswith(user_data) and val2.startswith(user_data):
187 return 1 180 return 1
188 else: 181 else:
189 return 0 182 return cmp(val1, val2)
190 183
191 def convert_vpath_to_path(self, view_model, view_path): 184 def convert_vpath_to_path(self, view_model, view_path):
192 # view_model is the model sorted 185 # view_model is the model sorted
@@ -533,12 +526,7 @@ class RecipeListModel(gtk.ListStore):
533 if user_data: 526 if user_data:
534 val1 = model.get_value(iter1, RecipeListModel.COL_NAME) 527 val1 = model.get_value(iter1, RecipeListModel.COL_NAME)
535 val2 = model.get_value(iter2, RecipeListModel.COL_NAME) 528 val2 = model.get_value(iter2, RecipeListModel.COL_NAME)
536 if val1.startswith(user_data) and not val2.startswith(user_data): 529 return self.cmp_vals(val1, val2, user_data)
537 return -1
538 elif not val1.startswith(user_data) and val2.startswith(user_data):
539 return 1
540 else:
541 return 0
542 else: 530 else:
543 val1 = model.get_value(iter1, RecipeListModel.COL_FADE_INC) 531 val1 = model.get_value(iter1, RecipeListModel.COL_FADE_INC)
544 val2 = model.get_value(iter2, RecipeListModel.COL_INC) 532 val2 = model.get_value(iter2, RecipeListModel.COL_INC)
@@ -548,12 +536,7 @@ class RecipeListModel(gtk.ListStore):
548 if user_data: 536 if user_data:
549 val1 = model.get_value(iter1, RecipeListModel.COL_NAME) 537 val1 = model.get_value(iter1, RecipeListModel.COL_NAME)
550 val2 = model.get_value(iter2, RecipeListModel.COL_NAME) 538 val2 = model.get_value(iter2, RecipeListModel.COL_NAME)
551 if val1.startswith(user_data) and not val2.startswith(user_data): 539 return self.cmp_vals(val1, val2, user_data)
552 return -1
553 elif not val1.startswith(user_data) and val2.startswith(user_data):
554 return 1
555 else:
556 return 0
557 else: 540 else:
558 val1 = model.get_value(iter1, RecipeListModel.COL_INC) 541 val1 = model.get_value(iter1, RecipeListModel.COL_INC)
559 val2 = model.get_value(iter2, RecipeListModel.COL_INC) 542 val2 = model.get_value(iter2, RecipeListModel.COL_INC)
@@ -562,12 +545,15 @@ class RecipeListModel(gtk.ListStore):
562 def sort_func(self, model, iter1, iter2, user_data): 545 def sort_func(self, model, iter1, iter2, user_data):
563 val1 = model.get_value(iter1, RecipeListModel.COL_NAME) 546 val1 = model.get_value(iter1, RecipeListModel.COL_NAME)
564 val2 = model.get_value(iter2, RecipeListModel.COL_NAME) 547 val2 = model.get_value(iter2, RecipeListModel.COL_NAME)
548 return self.cmp_vals(val1, val2, user_data)
549
550 def cmp_vals(self, val1, val2, user_data):
565 if val1.startswith(user_data) and not val2.startswith(user_data): 551 if val1.startswith(user_data) and not val2.startswith(user_data):
566 return -1 552 return -1
567 elif not val1.startswith(user_data) and val2.startswith(user_data): 553 elif not val1.startswith(user_data) and val2.startswith(user_data):
568 return 1 554 return 1
569 else: 555 else:
570 return 0 556 return cmp(val1, val2)
571 557
572 """ 558 """
573 Create, if required, and return a filtered gtk.TreeModelSort 559 Create, if required, and return a filtered gtk.TreeModelSort