diff options
author | natural <natural> | 2006-12-29 07:37:39 +0000 |
---|---|---|
committer | natural <natural> | 2006-12-29 07:37:39 +0000 |
commit | e60bfbb3b724d5999d089ed952ae8a43c244e9ae (patch) | |
tree | 08271831068169fe7fd3268c794e167118f1df79 /kberylsettings/pluginframe.py | |
parent | 3f0d8beae4fe502938aa8b15efa875159ebf3280 (diff) | |
download | kberylsettings-e60bfbb3b724d5999d089ed952ae8a43c244e9ae.tar.gz kberylsettings-e60bfbb3b724d5999d089ed952ae8a43c244e9ae.tar.bz2 |
Added changed signal to bell binding checkbox.
Made category view sort like beryl-settings; now places plugins in the 'Unknown Category' at top of list and not as children of other items.
Removed unused signals and slots; sorted Signals and Slots class members.
Diffstat (limited to 'kberylsettings/pluginframe.py')
-rw-r--r-- | kberylsettings/pluginframe.py | 53 |
1 files changed, 44 insertions, 9 deletions
diff --git a/kberylsettings/pluginframe.py b/kberylsettings/pluginframe.py index 3d139be..8d81f9e 100644 --- a/kberylsettings/pluginframe.py +++ b/kberylsettings/pluginframe.py @@ -384,15 +384,25 @@ class CategoryView(BasicPluginView): @return None """ + active = self.context.active for category in self.context.categories[::-1]: plugins = [p for p in category.plugins[::-1] if p.Name in active] - catitem = self.categoryItem(category) - catitem.setVisible(bool(plugins)) - for plugin in plugins: - if plugin.Name in active: - self.pluginItem(plugin, catitem) - + if not category.Name: + ## general plugin(s) + for plugin in category.plugins: + if plugin.Name in active: + self.pluginItem(plugin, self) + else: + catitem = self.categoryItem(category) + catitem.setVisible(bool(plugins)) + for plugin in plugins: + if plugin.Name in active: + self.pluginItem(plugin, catitem) + self.setSorting(1) + self.sort() + self.setSorting(-1) + def categoryItem(self, category): """ create a list view item for a category @@ -402,7 +412,7 @@ class CategoryView(BasicPluginView): desc = category.ShortDesc item = self.findItem(desc, 0) if not item: - item = ValueListViewItem(self, desc, (None, None)) + item = CategoryListViewItem(self, desc, (None, None)) item.setPixmap(0, category.icon(self.iconSize, self.loader)) return item @@ -412,10 +422,35 @@ class CategoryView(BasicPluginView): @param category @return QListViewItem instance """ - for item in [i for i in self if i.parent() == parent]: + for item in [i for i in self if i.parent() in (parent, 0)]: if item.value[0].Name == plugin.Name: item.value = (plugin, None) return item - item = ValueListViewItem(parent, plugin.ShortDesc, (plugin, None)) + if parent is self: + item = self.findItem(plugin.ShortDesc, 0) + if item: + item.value = (plugin, None) + return item + item = CategoryListViewItem(parent, plugin.ShortDesc, (plugin, None)) item.setPixmap(0, plugin.icon(self.iconSize, self.loader)) return item + + +class CategoryListViewItem(ValueListViewItem): + """ Sortable items for the category list view + + """ + def compare(self, other, column, ascending): + """ compare this item to another + + @param other QListViewItem instance to compare against + @param column ignored + @param ascending ignored + @return -1 if this item is less than other, 1 if greater, 0 if equal + """ + for (obj, val) in ((self, -1), (other, 1)): + plugin = obj.value[0] + if plugin and plugin.isGeneral: + return val + return cmp(self.text(0), other.text(0)) + |