Merge lp:~ian-clatworthy/qbzr/qrun-categories into lp:qbzr

Proposed by Ian Clatworthy
Status: Merged
Merged at revision: not available
Proposed branch: lp:~ian-clatworthy/qbzr/qrun-categories
Merge into: lp:qbzr
Diff against target: 281 lines (+107/-19)
5 files modified
NEWS.txt (+5/-0)
lib/commands.py (+6/-2)
lib/run.py (+60/-10)
lib/ui_run.py (+14/-5)
ui/run.ui (+22/-2)
To merge this branch: bzr merge lp:~ian-clatworthy/qbzr/qrun-categories
Reviewer Review Type Date Requested Status
Alexander Belchenko Approve
Review via email: mp+15714@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Ian Clatworthy (ian-clatworthy) wrote :

This branch adds a Category combo to qrun, making it much easier to find commands.

Revision history for this message
Alexander Belchenko (bialix) wrote :

Recently I've fixed regression in signals handling introduced by you in command patch.
Now my change and your new code are conflicted. Please, resolve this conflict.

review: Needs Fixing
1158. By Ian Clatworthy

Merge trunk

Revision history for this message
Alexander Belchenko (bialix) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'NEWS.txt'
2--- NEWS.txt 2009-12-07 23:23:40 +0000
3+++ NEWS.txt 2009-12-07 23:41:10 +0000
4@@ -29,6 +29,11 @@
5 Gary van der Merwe)
6 * Show all revisions that touch the file in the log list. (Bug #488824,
7 Gary van der Merwe)
8+ * qrun:
9+ * A category field has been added to make finding commands easier.
10+ (#486968, Ian Clatworthy)
11+ * The command name, command parameters and command category can be
12+ passed on the command line. (Ian Clatworthy)
13 * qsubprocess:
14 * Catch possible errors from bencode decoder is we got malformed string
15 from child process. Show the error nicely.
16
17=== modified file 'lib/commands.py'
18--- lib/commands.py 2009-12-06 02:48:19 +0000
19+++ lib/commands.py 2009-12-07 23:41:10 +0000
20@@ -1059,17 +1059,21 @@
21 short_name='d',
22 type=unicode,
23 ),
24+ Option('category',
25+ help='Initial category selection.',
26+ type=unicode,
27+ ),
28 ]
29 aliases = ['qcmd']
30
31 def _qbzr_run(self, command=None, parameters_list=None, ui_mode=False,
32- directory=None):
33+ directory=None, category=None):
34 from bzrlib.plugins.qbzr.lib.run import QBzrRunDialog
35 if parameters_list:
36 parameters = " ".join(parameters_list)
37 else:
38 parameters = None
39 window = QBzrRunDialog(command=command, parameters=parameters,
40- workdir=directory, ui_mode=ui_mode)
41+ workdir=directory, category=category, ui_mode=ui_mode)
42 window.show()
43 self._application.exec_()
44
45=== modified file 'lib/run.py'
46--- lib/run.py 2009-12-06 11:27:14 +0000
47+++ lib/run.py 2009-12-07 23:41:10 +0000
48@@ -38,12 +38,13 @@
49 class QBzrRunDialog(SubProcessDialog):
50
51 def __init__(self, command=None, parameters=None, workdir=None,
52- ui_mode=False, parent=None):
53+ category=None, ui_mode=False, parent=None):
54 """Build dialog.
55
56 @param command: initial command selection.
57 @param parameters: initial options and arguments (string) for command.
58 @param workdir: working directory to run command.
59+ @param category: initial category selection.
60 @param ui_mode: wait after the operation is complete.
61 @param parent: parent window.
62 """
63@@ -61,6 +62,8 @@
64 self.ui.cmd_layout.setColumnStretch(2, 1)
65 # fill cmd_combobox with available commands
66 self.collect_command_names()
67+ categories = sorted(self.all_cmds.keys())
68+ self.ui.cat_combobox.insertItems(0, categories)
69 self.set_cmd_combobox(cmd_name=command)
70 # add the parameters, if any
71 if parameters:
72@@ -76,13 +79,16 @@
73 # setup signals
74 QtCore.QObject.connect(self.ui.hidden_checkbox,
75 QtCore.SIGNAL("stateChanged(int)"),
76- lambda x: self.set_cmd_combobox(all=x))
77+ self.set_show_hidden)
78 QtCore.QObject.connect(self.ui.cmd_combobox,
79 QtCore.SIGNAL("currentIndexChanged(const QString&)"),
80 self.set_cmd_help)
81 QtCore.QObject.connect(self.ui.cmd_combobox,
82 QtCore.SIGNAL("editTextChanged(const QString&)"),
83 self.set_cmd_help)
84+ QtCore.QObject.connect(self.ui.cat_combobox,
85+ QtCore.SIGNAL("currentIndexChanged(const QString&)"),
86+ self.set_category)
87 hookup_directory_picker(self, self.ui.browse_button,
88 self.ui.wd_edit, gettext("Select working directory"))
89 QtCore.QObject.connect(self.ui.directory_button,
90@@ -91,6 +97,13 @@
91 QtCore.QObject.connect(self.ui.filenames_button,
92 QtCore.SIGNAL("clicked()"),
93 self.insert_filenames)
94+ # Init the category if set.
95+ # (This needs to be done after the signals are hooked up)
96+ if category:
97+ cb = self.ui.cat_combobox
98+ index = cb.findText(category)
99+ if index >= 0:
100+ cb.setCurrentIndex(index)
101 # ready to go
102 if command:
103 self.ui.opt_arg_edit.setFocus()
104@@ -108,24 +121,61 @@
105 names = list(_mod_commands.all_command_names())
106 self.cmds_dict = dict((n, _mod_commands.get_cmd_object(n))
107 for n in names)
108- self.all_cmds = sorted(names)
109- self.public_cmds = sorted([n
110- for n,o in self.cmds_dict.iteritems()
111- if not o.hidden])
112-
113- def set_cmd_combobox(self, cmd_name=None, all=False):
114+ # Find the commands for each category, public or otherwise
115+ builtins = _mod_commands.builtin_command_names()
116+ self.all_cmds = {'All': []}
117+ self.public_cmds = {'All': []}
118+ for name, cmd in self.cmds_dict.iteritems():
119+ # If a command is builtin, we always put it into the Core
120+ # category, even if overridden in a plugin
121+ if name in builtins:
122+ category = 'Core'
123+ else:
124+ category = cmd.plugin_name()
125+ self.all_cmds['All'].append(name)
126+ self.all_cmds.setdefault(category, []).append(name)
127+ if not cmd.hidden:
128+ self.public_cmds['All'].append(name)
129+ self.public_cmds.setdefault(category, []).append(name)
130+ # Sort them
131+ for category in self.all_cmds:
132+ self.all_cmds[category].sort()
133+ try:
134+ self.public_cmds[category].sort()
135+ except KeyError:
136+ # no public commands - that's ok
137+ pass
138+
139+ def set_category(self, category):
140+ cmd_name = self._get_cmd_name()
141+ all = self.ui.hidden_checkbox.isChecked()
142+ category = unicode(category)
143+ self.set_cmd_combobox(cmd_name=cmd_name, all=all, category=category)
144+
145+ def set_show_hidden(self, show):
146+ cmd_name = self._get_cmd_name()
147+ all = bool(show)
148+ category = unicode(self.ui.cat_combobox.currentText())
149+ self.set_cmd_combobox(cmd_name=cmd_name, all=all, category=category)
150+
151+ def set_cmd_combobox(self, cmd_name=None, all=False, category=None):
152 """Fill command combobox with bzr commands names.
153
154 @param cmd_name: if not None, the command to initially select
155 if it exists in the list.
156 @param all: show all commands including hidden ones.
157+ @param category: show commands just for this category.
158+ If None, commands in all categories are shown.
159 """
160 cb = self.ui.cmd_combobox
161 cb.clear()
162 if all:
163- cb.addItems(self.all_cmds)
164+ lookup = self.all_cmds
165 else:
166- cb.addItems(self.public_cmds)
167+ lookup = self.public_cmds
168+ if category is None:
169+ category = 'All'
170+ cb.addItems(lookup.get(category, []))
171 if cmd_name is None:
172 index = -1
173 else:
174
175=== modified file 'lib/ui_run.py'
176--- lib/ui_run.py 2009-08-23 17:37:51 +0000
177+++ lib/ui_run.py 2009-12-07 23:41:10 +0000
178@@ -2,8 +2,8 @@
179
180 # Form implementation generated from reading ui file 'ui/run.ui'
181 #
182-# Created: Sun Aug 23 20:03:41 2009
183-# by: PyQt4 UI code generator 4.4.3
184+# Created: Mon Dec 7 01:25:47 2009
185+# by: PyQt4 UI code generator 4.6
186 #
187 # WARNING! All changes made in this file will be lost!
188
189@@ -49,17 +49,24 @@
190 self.frame_layout.addLayout(self.wd_layout)
191 self.cmd_layout = QtGui.QGridLayout()
192 self.cmd_layout.setObjectName("cmd_layout")
193+ self.cat_label = QtGui.QLabel(self.frame)
194+ self.cat_label.setObjectName("cat_label")
195+ self.cmd_layout.addWidget(self.cat_label, 0, 0, 1, 1)
196+ self.cat_combobox = QtGui.QComboBox(self.frame)
197+ self.cat_combobox.setMinimumSize(QtCore.QSize(170, 0))
198+ self.cat_combobox.setObjectName("cat_combobox")
199+ self.cmd_layout.addWidget(self.cat_combobox, 0, 1, 1, 1)
200 self.cmd_label = QtGui.QLabel(self.frame)
201 self.cmd_label.setObjectName("cmd_label")
202- self.cmd_layout.addWidget(self.cmd_label, 0, 0, 1, 1)
203+ self.cmd_layout.addWidget(self.cmd_label, 1, 0, 1, 1)
204 self.cmd_combobox = QtGui.QComboBox(self.frame)
205 self.cmd_combobox.setMinimumSize(QtCore.QSize(170, 0))
206 self.cmd_combobox.setEditable(True)
207 self.cmd_combobox.setObjectName("cmd_combobox")
208- self.cmd_layout.addWidget(self.cmd_combobox, 0, 1, 1, 1)
209+ self.cmd_layout.addWidget(self.cmd_combobox, 1, 1, 1, 1)
210 self.hidden_checkbox = QtGui.QCheckBox(self.frame)
211 self.hidden_checkbox.setObjectName("hidden_checkbox")
212- self.cmd_layout.addWidget(self.hidden_checkbox, 0, 2, 1, 1)
213+ self.cmd_layout.addWidget(self.hidden_checkbox, 1, 2, 1, 1)
214 self.frame_layout.addLayout(self.cmd_layout)
215 self.opt_arg_label = QtGui.QLabel(self.frame)
216 self.opt_arg_label.setLineWidth(0)
217@@ -83,6 +90,7 @@
218 self.help_browser.setObjectName("help_browser")
219 self.main_v_layout.addWidget(self.splitter)
220 self.wd_label.setBuddy(self.wd_edit)
221+ self.cat_label.setBuddy(self.cmd_combobox)
222 self.cmd_label.setBuddy(self.cmd_combobox)
223 self.opt_arg_label.setBuddy(self.opt_arg_edit)
224
225@@ -101,6 +109,7 @@
226 RunDialog.setWindowTitle(gettext("Run bzr command"))
227 self.wd_label.setText(gettext("&Working directory:"))
228 self.browse_button.setText(gettext("&Browse..."))
229+ self.cat_label.setText(gettext("C&ategory:"))
230 self.cmd_label.setText(gettext("&Command:"))
231 self.hidden_checkbox.setText(gettext("&Show hidden commands"))
232 self.opt_arg_label.setText(gettext("&Options and arguments for command:"))
233
234=== modified file 'ui/run.ui'
235--- ui/run.ui 2009-08-23 17:37:51 +0000
236+++ ui/run.ui 2009-12-07 23:41:10 +0000
237@@ -71,6 +71,26 @@
238 <item>
239 <layout class="QGridLayout" name="cmd_layout" >
240 <item row="0" column="0" >
241+ <widget class="QLabel" name="cat_label" >
242+ <property name="text" >
243+ <string>C&amp;ategory:</string>
244+ </property>
245+ <property name="buddy" >
246+ <cstring>cmd_combobox</cstring>
247+ </property>
248+ </widget>
249+ </item>
250+ <item row="0" column="1" >
251+ <widget class="QComboBox" name="cat_combobox" >
252+ <property name="minimumSize" >
253+ <size>
254+ <width>170</width>
255+ <height>0</height>
256+ </size>
257+ </property>
258+ </widget>
259+ </item>
260+ <item row="1" column="0" >
261 <widget class="QLabel" name="cmd_label" >
262 <property name="text" >
263 <string>&amp;Command:</string>
264@@ -80,7 +100,7 @@
265 </property>
266 </widget>
267 </item>
268- <item row="0" column="1" >
269+ <item row="1" column="1" >
270 <widget class="QComboBox" name="cmd_combobox" >
271 <property name="minimumSize" >
272 <size>
273@@ -93,7 +113,7 @@
274 </property>
275 </widget>
276 </item>
277- <item row="0" column="2" >
278+ <item row="1" column="2" >
279 <widget class="QCheckBox" name="hidden_checkbox" >
280 <property name="text" >
281 <string>&amp;Show hidden commands</string>

Subscribers

People subscribed via source and target branches