40 parent, name) |
40 parent, name) |
41 |
41 |
42 # instantiate the extensions |
42 # instantiate the extensions |
43 from .ShelveExtension.ProjectBrowserHelper import \ |
43 from .ShelveExtension.ProjectBrowserHelper import \ |
44 ShelveProjectBrowserHelper |
44 ShelveProjectBrowserHelper |
|
45 from .LargefilesExtension.ProjectBrowserHelper import \ |
|
46 LargefilesProjectBrowserHelper |
45 self.__extensions = { |
47 self.__extensions = { |
46 "shelve": ShelveProjectBrowserHelper(vcsObject, browserObject, |
48 "shelve": ShelveProjectBrowserHelper( |
47 projectObject), |
49 vcsObject, browserObject, projectObject), |
|
50 "largefiles": LargefilesProjectBrowserHelper( |
|
51 vcsObject, browserObject, projectObject), |
48 } |
52 } |
49 |
53 |
50 self.__extensionMenuTitles = {} |
54 self.__extensionMenuTitles = {} |
51 for extension in self.__extensions: |
55 for extension in self.__extensions: |
52 self.__extensionMenuTitles[ |
56 self.__extensionMenuTitles[ |
54 self.__extensionMenus = {} |
58 self.__extensionMenus = {} |
55 for extension in self.__extensions: |
59 for extension in self.__extensions: |
56 self.__extensionMenus[extension] = \ |
60 self.__extensionMenus[extension] = \ |
57 self.__extensions[extension].initMenus() |
61 self.__extensions[extension].initMenus() |
58 |
62 |
59 def __showExtensionMenu(self, key): |
63 def __showExtensionMenu(self, key, controlled): |
60 """ |
64 """ |
61 Private slot showing the extensions menu. |
65 Private slot showing the extensions menu. |
62 |
66 |
63 @param key menu key (string, one of 'mainMenu', 'multiMenu', |
67 @param key menu key (string, one of 'mainMenu', 'multiMenu', |
64 'backMenu', 'dirMenu' or 'dirMultiMenu') |
68 'backMenu', 'dirMenu' or 'dirMultiMenu') |
|
69 @param controlled flag indicating to show the menu for a |
|
70 version controlled entry or a non-version controlled entry |
|
71 (boolean) |
65 """ |
72 """ |
66 for extensionName in self.__extensionMenus: |
73 for extensionName in self.__extensionMenus: |
67 if key in self.__extensionMenus[extensionName]: |
74 if key in self.__extensionMenus[extensionName]: |
68 self.__extensionMenus[extensionName][key].setEnabled( |
75 self.__extensionMenus[extensionName][key].setEnabled( |
69 self.vcs.isExtensionActive(extensionName)) |
76 self.vcs.isExtensionActive(extensionName)) |
|
77 if self.__extensionMenus[extensionName][key].isEnabled(): |
|
78 # adjust individual extension menu entries |
|
79 self.__extensions[extensionName].showExtensionMenu( |
|
80 key, controlled) |
70 if (not self.__extensionMenus[extensionName][key].isEnabled() |
81 if (not self.__extensionMenus[extensionName][key].isEnabled() |
71 and self.__extensionMenus[extensionName][key] |
82 and self.__extensionMenus[extensionName][key] |
72 .isTearOffMenuVisible()): |
83 .isTearOffMenuVisible()): |
73 self.__extensionMenus[extensionName][key].hideTearOffMenu() |
84 self.__extensionMenus[extensionName][key].hideTearOffMenu() |
74 |
85 |
82 @param menu reference to the menu to be shown |
93 @param menu reference to the menu to be shown |
83 @param standardItems array of standard items that need |
94 @param standardItems array of standard items that need |
84 activation/deactivation depending on the overall VCS status |
95 activation/deactivation depending on the overall VCS status |
85 """ |
96 """ |
86 if self.browser.currentItem().data(1) == self.vcs.vcsName(): |
97 if self.browser.currentItem().data(1) == self.vcs.vcsName(): |
|
98 controlled = True |
87 for act in self.vcsMenuActions: |
99 for act in self.vcsMenuActions: |
88 act.setEnabled(True) |
100 act.setEnabled(True) |
89 for act in self.vcsAddMenuActions: |
101 for act in self.vcsAddMenuActions: |
90 act.setEnabled(False) |
102 act.setEnabled(False) |
91 for act in standardItems: |
103 for act in standardItems: |
92 act.setEnabled(False) |
104 act.setEnabled(False) |
93 if not hasattr(self.browser.currentItem(), 'fileName'): |
105 if not hasattr(self.browser.currentItem(), 'fileName'): |
94 self.annotateAct.setEnabled(False) |
106 self.annotateAct.setEnabled(False) |
95 self.__showExtensionMenu("mainMenu") |
|
96 else: |
107 else: |
|
108 controlled = False |
97 for act in self.vcsMenuActions: |
109 for act in self.vcsMenuActions: |
98 act.setEnabled(False) |
110 act.setEnabled(False) |
99 for act in self.vcsAddMenuActions: |
111 for act in self.vcsAddMenuActions: |
100 act.setEnabled(True) |
112 act.setEnabled(True) |
101 for act in standardItems: |
113 for act in standardItems: |
102 act.setEnabled(True) |
114 act.setEnabled(True) |
|
115 self.__showExtensionMenu("mainMenu", controlled) |
103 |
116 |
104 def showContextMenuMulti(self, menu, standardItems): |
117 def showContextMenuMulti(self, menu, standardItems): |
105 """ |
118 """ |
106 Slot called before the context menu (multiple selections) is shown. |
119 Slot called before the context menu (multiple selections) is shown. |
107 |
120 |
119 for itm in items: |
132 for itm in items: |
120 if itm.data(1) == vcsName: |
133 if itm.data(1) == vcsName: |
121 vcsItems += 1 |
134 vcsItems += 1 |
122 |
135 |
123 if vcsItems > 0: |
136 if vcsItems > 0: |
|
137 controlled = True |
124 if vcsItems != len(items): |
138 if vcsItems != len(items): |
125 for act in self.vcsMultiMenuActions: |
139 for act in self.vcsMultiMenuActions: |
126 act.setEnabled(False) |
140 act.setEnabled(False) |
127 else: |
141 else: |
128 for act in self.vcsMultiMenuActions: |
142 for act in self.vcsMultiMenuActions: |
129 act.setEnabled(True) |
143 act.setEnabled(True) |
130 for act in self.vcsAddMultiMenuActions: |
144 for act in self.vcsAddMultiMenuActions: |
131 act.setEnabled(False) |
145 act.setEnabled(False) |
132 for act in standardItems: |
146 for act in standardItems: |
133 act.setEnabled(False) |
147 act.setEnabled(False) |
134 self.__showExtensionMenu("multiMenu") |
|
135 else: |
148 else: |
|
149 controlled = False |
136 for act in self.vcsMultiMenuActions: |
150 for act in self.vcsMultiMenuActions: |
137 act.setEnabled(False) |
151 act.setEnabled(False) |
138 for act in self.vcsAddMultiMenuActions: |
152 for act in self.vcsAddMultiMenuActions: |
139 act.setEnabled(True) |
153 act.setEnabled(True) |
140 for act in standardItems: |
154 for act in standardItems: |
141 act.setEnabled(True) |
155 act.setEnabled(True) |
|
156 self.__showExtensionMenu("multiMenu", controlled) |
142 |
157 |
143 def showContextMenuDir(self, menu, standardItems): |
158 def showContextMenuDir(self, menu, standardItems): |
144 """ |
159 """ |
145 Slot called before the context menu is shown. |
160 Slot called before the context menu is shown. |
146 |
161 |
150 @param menu reference to the menu to be shown |
165 @param menu reference to the menu to be shown |
151 @param standardItems array of standard items that need |
166 @param standardItems array of standard items that need |
152 activation/deactivation depending on the overall VCS status |
167 activation/deactivation depending on the overall VCS status |
153 """ |
168 """ |
154 if self.browser.currentItem().data(1) == self.vcs.vcsName(): |
169 if self.browser.currentItem().data(1) == self.vcs.vcsName(): |
|
170 controlled = True |
155 for act in self.vcsDirMenuActions: |
171 for act in self.vcsDirMenuActions: |
156 act.setEnabled(True) |
172 act.setEnabled(True) |
157 for act in self.vcsAddDirMenuActions: |
173 for act in self.vcsAddDirMenuActions: |
158 act.setEnabled(False) |
174 act.setEnabled(False) |
159 for act in standardItems: |
175 for act in standardItems: |
160 act.setEnabled(False) |
176 act.setEnabled(False) |
161 self.__showExtensionMenu("dirMenu") |
|
162 else: |
177 else: |
|
178 controlled = False |
163 for act in self.vcsDirMenuActions: |
179 for act in self.vcsDirMenuActions: |
164 act.setEnabled(False) |
180 act.setEnabled(False) |
165 for act in self.vcsAddDirMenuActions: |
181 for act in self.vcsAddDirMenuActions: |
166 act.setEnabled(True) |
182 act.setEnabled(True) |
167 for act in standardItems: |
183 for act in standardItems: |
168 act.setEnabled(True) |
184 act.setEnabled(True) |
|
185 self.__showExtensionMenu("dirMenu", controlled) |
169 |
186 |
170 def showContextMenuDirMulti(self, menu, standardItems): |
187 def showContextMenuDirMulti(self, menu, standardItems): |
171 """ |
188 """ |
172 Slot called before the context menu is shown. |
189 Slot called before the context menu is shown. |
173 |
190 |
185 for itm in items: |
202 for itm in items: |
186 if itm.data(1) == vcsName: |
203 if itm.data(1) == vcsName: |
187 vcsItems += 1 |
204 vcsItems += 1 |
188 |
205 |
189 if vcsItems > 0: |
206 if vcsItems > 0: |
|
207 controlled = True |
190 if vcsItems != len(items): |
208 if vcsItems != len(items): |
191 for act in self.vcsDirMultiMenuActions: |
209 for act in self.vcsDirMultiMenuActions: |
192 act.setEnabled(False) |
210 act.setEnabled(False) |
193 else: |
211 else: |
194 for act in self.vcsDirMultiMenuActions: |
212 for act in self.vcsDirMultiMenuActions: |
195 act.setEnabled(True) |
213 act.setEnabled(True) |
196 for act in self.vcsAddDirMultiMenuActions: |
214 for act in self.vcsAddDirMultiMenuActions: |
197 act.setEnabled(False) |
215 act.setEnabled(False) |
198 for act in standardItems: |
216 for act in standardItems: |
199 act.setEnabled(False) |
217 act.setEnabled(False) |
200 self.__showExtensionMenu("dirMultiMenu") |
|
201 else: |
218 else: |
|
219 controlled = False |
202 for act in self.vcsDirMultiMenuActions: |
220 for act in self.vcsDirMultiMenuActions: |
203 act.setEnabled(False) |
221 act.setEnabled(False) |
204 for act in self.vcsAddDirMultiMenuActions: |
222 for act in self.vcsAddDirMultiMenuActions: |
205 act.setEnabled(True) |
223 act.setEnabled(True) |
206 for act in standardItems: |
224 for act in standardItems: |
207 act.setEnabled(True) |
225 act.setEnabled(True) |
|
226 self.__showExtensionMenu("dirMultiMenu", controlled) |
208 |
227 |
209 ########################################################################### |
228 ########################################################################### |
210 ## Private menu generation methods below |
229 ## Private menu generation methods below |
211 ########################################################################### |
230 ########################################################################### |
212 |
231 |
263 act = menu.addAction( |
282 act = menu.addAction( |
264 UI.PixmapCache.getIcon("vcsCommit.png"), |
283 UI.PixmapCache.getIcon("vcsCommit.png"), |
265 self.tr('Commit changes to repository...'), |
284 self.tr('Commit changes to repository...'), |
266 self._VCSCommit) |
285 self._VCSCommit) |
267 self.vcsMenuActions.append(act) |
286 self.vcsMenuActions.append(act) |
268 act = self.__addExtensionsMenu(menu, 'mainMenu') |
287 self.__addExtensionsMenu(menu, 'mainMenu') |
269 if act: |
|
270 self.vcsMenuActions.append(act) |
|
271 menu.addSeparator() |
288 menu.addSeparator() |
272 act = menu.addAction( |
289 act = menu.addAction( |
273 UI.PixmapCache.getIcon("vcsAdd.png"), |
290 UI.PixmapCache.getIcon("vcsAdd.png"), |
274 self.tr('Add to repository'), |
291 self.tr('Add to repository'), |
275 self._VCSAdd) |
292 self._VCSAdd) |
374 act = menu.addAction( |
391 act = menu.addAction( |
375 UI.PixmapCache.getIcon("vcsCommit.png"), |
392 UI.PixmapCache.getIcon("vcsCommit.png"), |
376 self.tr('Commit changes to repository...'), |
393 self.tr('Commit changes to repository...'), |
377 self._VCSCommit) |
394 self._VCSCommit) |
378 self.vcsMultiMenuActions.append(act) |
395 self.vcsMultiMenuActions.append(act) |
379 act = self.__addExtensionsMenu(menu, 'multiMenu') |
396 self.__addExtensionsMenu(menu, 'multiMenu') |
380 if act: |
|
381 self.vcsMultiMenuActions.append(act) |
|
382 menu.addSeparator() |
397 menu.addSeparator() |
383 act = menu.addAction( |
398 act = menu.addAction( |
384 UI.PixmapCache.getIcon("vcsAdd.png"), |
399 UI.PixmapCache.getIcon("vcsAdd.png"), |
385 self.tr('Add to repository'), self._VCSAdd) |
400 self.tr('Add to repository'), self._VCSAdd) |
386 self.vcsAddMultiMenuActions.append(act) |
401 self.vcsAddMultiMenuActions.append(act) |
491 act = menu.addAction( |
506 act = menu.addAction( |
492 UI.PixmapCache.getIcon("vcsCommit.png"), |
507 UI.PixmapCache.getIcon("vcsCommit.png"), |
493 self.tr('Commit changes to repository...'), |
508 self.tr('Commit changes to repository...'), |
494 self._VCSCommit) |
509 self._VCSCommit) |
495 self.vcsDirMenuActions.append(act) |
510 self.vcsDirMenuActions.append(act) |
496 act = self.__addExtensionsMenu(menu, 'dirMenu') |
511 self.__addExtensionsMenu(menu, 'dirMenu') |
497 if act: |
|
498 self.vcsDirMenuActions.append(act) |
|
499 menu.addSeparator() |
512 menu.addSeparator() |
500 act = menu.addAction( |
513 act = menu.addAction( |
501 UI.PixmapCache.getIcon("vcsAdd.png"), |
514 UI.PixmapCache.getIcon("vcsAdd.png"), |
502 self.tr('Add to repository'), self._VCSAdd) |
515 self.tr('Add to repository'), self._VCSAdd) |
503 self.vcsAddDirMenuActions.append(act) |
516 self.vcsAddDirMenuActions.append(act) |
585 act = menu.addAction( |
598 act = menu.addAction( |
586 UI.PixmapCache.getIcon("vcsCommit.png"), |
599 UI.PixmapCache.getIcon("vcsCommit.png"), |
587 self.tr('Commit changes to repository...'), |
600 self.tr('Commit changes to repository...'), |
588 self._VCSCommit) |
601 self._VCSCommit) |
589 self.vcsDirMultiMenuActions.append(act) |
602 self.vcsDirMultiMenuActions.append(act) |
590 act = self.__addExtensionsMenu(menu, 'dirMultiMenu') |
603 self.__addExtensionsMenu(menu, 'dirMultiMenu') |
591 if act: |
|
592 self.vcsDirMultiMenuActions.append(act) |
|
593 menu.addSeparator() |
604 menu.addSeparator() |
594 act = menu.addAction( |
605 act = menu.addAction( |
595 UI.PixmapCache.getIcon("vcsAdd.png"), |
606 UI.PixmapCache.getIcon("vcsAdd.png"), |
596 self.tr('Add to repository'), self._VCSAdd) |
607 self.tr('Add to repository'), self._VCSAdd) |
597 self.vcsAddDirMultiMenuActions.append(act) |
608 self.vcsAddDirMultiMenuActions.append(act) |