eric6/MultiProject/MultiProjectBrowser.py

Sat, 27 Feb 2021 12:08:23 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 27 Feb 2021 12:08:23 +0100
changeset 8138
169e65a6787c
parent 8047
b5594178c7fa
child 8143
2c730d5fd177
permissions
-rw-r--r--

Shell: added functionality to show a prompt when the main client process has exited (e.g. a script ended).

0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
7923
91e843545d9a Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
3 # Copyright (c) 2008 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing the multi project browser.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
6652
dfc89403b426 MultiProject, MultiProjectBrowser: added capability to delete a project from disk.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
10 import os
dfc89403b426 MultiProject, MultiProjectBrowser: added capability to delete a project from disk.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
11 import glob
dfc89403b426 MultiProject, MultiProjectBrowser: added capability to delete a project from disk.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
12
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3545
diff changeset
13 from PyQt5.QtCore import Qt
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3545
diff changeset
14 from PyQt5.QtWidgets import QTreeWidget, QTreeWidgetItem, QDialog, QMenu
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15
55
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 53
diff changeset
16 from E5Gui.E5Application import e5App
6652
dfc89403b426 MultiProject, MultiProjectBrowser: added capability to delete a project from disk.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
17 from E5Gui import E5MessageBox
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 import UI.PixmapCache
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
21
3197
4103c8013c36 Added support for the categorisation of projects to multi projects and changed the multi project file format.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
22 class MultiProjectBrowser(QTreeWidget):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 Class implementing the multi project browser.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 """
5889
092d06e0193f Fixed some weaknesses in the multi project code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5616
diff changeset
26 ProjectFileNameRole = Qt.UserRole
092d06e0193f Fixed some weaknesses in the multi project code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5616
diff changeset
27 ProjectUidRole = Qt.UserRole + 1
092d06e0193f Fixed some weaknesses in the multi project code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5616
diff changeset
28
5314
76013775e623 Changed the way the currently opened project is highlighted in the multi project browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
29 def __init__(self, multiProject, project, parent=None):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 Constructor
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32
2960
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2404
diff changeset
33 @param multiProject reference to the multi project object
5314
76013775e623 Changed the way the currently opened project is highlighted in the multi project browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
34 @type MultiProject
76013775e623 Changed the way the currently opened project is highlighted in the multi project browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
35 @param project reference to the project object
76013775e623 Changed the way the currently opened project is highlighted in the multi project browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
36 @type Project
76013775e623 Changed the way the currently opened project is highlighted in the multi project browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
37 @param parent parent widget
76013775e623 Changed the way the currently opened project is highlighted in the multi project browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
38 @type QWidget
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 """
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2404
diff changeset
40 super(MultiProjectBrowser, self).__init__(parent)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 self.multiProject = multiProject
5314
76013775e623 Changed the way the currently opened project is highlighted in the multi project browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
42 self.project = project
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
44 self.setWindowIcon(UI.PixmapCache.getIcon("eric"))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 self.setAlternatingRowColors(True)
3197
4103c8013c36 Added support for the categorisation of projects to multi projects and changed the multi project file format.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
46 self.setHeaderHidden(True)
4103c8013c36 Added support for the categorisation of projects to multi projects and changed the multi project file format.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
47 self.setItemsExpandable(False)
4103c8013c36 Added support for the categorisation of projects to multi projects and changed the multi project file format.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
48 self.setRootIsDecorated(False)
4103c8013c36 Added support for the categorisation of projects to multi projects and changed the multi project file format.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
49 self.setSortingEnabled(True)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50
2099
afde0e9110f7 Implemented guards against double activation of list entries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
51 self.__openingProject = False
afde0e9110f7 Implemented guards against double activation of list entries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
52
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
53 self.multiProject.newMultiProject.connect(
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
54 self.__newMultiProject)
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
55 self.multiProject.multiProjectOpened.connect(
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
56 self.__multiProjectOpened)
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
57 self.multiProject.multiProjectClosed.connect(
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
58 self.__multiProjectClosed)
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
59 self.multiProject.projectDataChanged.connect(
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
60 self.__projectDataChanged)
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
61 self.multiProject.projectAdded.connect(
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
62 self.__projectAdded)
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
63 self.multiProject.projectRemoved.connect(
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
64 self.__projectRemoved)
5314
76013775e623 Changed the way the currently opened project is highlighted in the multi project browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
65
76013775e623 Changed the way the currently opened project is highlighted in the multi project browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
66 self.project.projectOpened.connect(self.__projectOpened)
76013775e623 Changed the way the currently opened project is highlighted in the multi project browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
67 self.project.projectClosed.connect(self.__projectClosed)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 self.__createPopupMenu()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 self.setContextMenuPolicy(Qt.CustomContextMenu)
458
1695e7a2db54 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
71 self.customContextMenuRequested.connect(self.__contextMenuRequested)
495
b31b0bffa5b0 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
72 self.itemActivated.connect(self.__openItem)
3830
70831a7beb3f Fixed an issue with the enabled state of the multi project browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
73
70831a7beb3f Fixed an issue with the enabled state of the multi project browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
74 self.setEnabled(False)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
76 ###########################################################################
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 ## Slot handling methods below
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
78 ###########################################################################
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 def __newMultiProject(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 Private slot to handle the creation of a new multi project.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 self.clear()
3830
70831a7beb3f Fixed an issue with the enabled state of the multi project browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
85 self.setEnabled(True)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87 def __multiProjectOpened(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89 Private slot to handle the opening of a multi project.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91 for project in self.multiProject.getProjects():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92 self.__addProject(project)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93
3197
4103c8013c36 Added support for the categorisation of projects to multi projects and changed the multi project file format.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
94 self.sortItems(0, Qt.AscendingOrder)
3830
70831a7beb3f Fixed an issue with the enabled state of the multi project browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
95
70831a7beb3f Fixed an issue with the enabled state of the multi project browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
96 self.setEnabled(True)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98 def __multiProjectClosed(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 Private slot to handle the closing of a multi project.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102 self.clear()
3830
70831a7beb3f Fixed an issue with the enabled state of the multi project browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
103 self.setEnabled(False)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105 def __projectAdded(self, project):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107 Private slot to handle the addition of a project to the multi project.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 @param project reference to the project data dictionary
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111 self.__addProject(project)
3197
4103c8013c36 Added support for the categorisation of projects to multi projects and changed the multi project file format.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
112 self.sortItems(0, Qt.AscendingOrder)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114 def __projectRemoved(self, project):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116 Private slot to handle the removal of a project from the multi project.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118 @param project reference to the project data dictionary
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 """
3197
4103c8013c36 Added support for the categorisation of projects to multi projects and changed the multi project file format.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
120 itm = self.__findProjectItem(project)
4103c8013c36 Added support for the categorisation of projects to multi projects and changed the multi project file format.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
121 if itm:
4103c8013c36 Added support for the categorisation of projects to multi projects and changed the multi project file format.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
122 parent = itm.parent()
4103c8013c36 Added support for the categorisation of projects to multi projects and changed the multi project file format.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
123 parent.removeChild(itm)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124 del itm
3197
4103c8013c36 Added support for the categorisation of projects to multi projects and changed the multi project file format.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
125 if parent.childCount() == 0:
5616
adcffadf4962 Reworked some __IGNORE_WARNING__ comments to be more specific.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
126 top = self.takeTopLevelItem(self.indexOfTopLevelItem(parent))
adcffadf4962 Reworked some __IGNORE_WARNING__ comments to be more specific.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
127 # __IGNORE_WARNING__
3197
4103c8013c36 Added support for the categorisation of projects to multi projects and changed the multi project file format.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
128 del top
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130 def __projectDataChanged(self, project):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132 Private slot to handle the change of a project of the multi project.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
133
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
134 @param project reference to the project data dictionary
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135 """
3197
4103c8013c36 Added support for the categorisation of projects to multi projects and changed the multi project file format.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
136 itm = self.__findProjectItem(project)
4103c8013c36 Added support for the categorisation of projects to multi projects and changed the multi project file format.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
137 if itm:
4103c8013c36 Added support for the categorisation of projects to multi projects and changed the multi project file format.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
138 parent = itm.parent()
4103c8013c36 Added support for the categorisation of projects to multi projects and changed the multi project file format.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
139 if parent.text(0) != project["category"]:
4103c8013c36 Added support for the categorisation of projects to multi projects and changed the multi project file format.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
140 self.__projectRemoved(project)
4103c8013c36 Added support for the categorisation of projects to multi projects and changed the multi project file format.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
141 self.__addProject(project)
4103c8013c36 Added support for the categorisation of projects to multi projects and changed the multi project file format.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
142 else:
4103c8013c36 Added support for the categorisation of projects to multi projects and changed the multi project file format.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
143 self.__setItemData(itm, project)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
144
3197
4103c8013c36 Added support for the categorisation of projects to multi projects and changed the multi project file format.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
145 self.sortItems(0, Qt.AscendingOrder)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146
5314
76013775e623 Changed the way the currently opened project is highlighted in the multi project browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
147 def __projectOpened(self):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
148 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
149 Private slot to handle the opening of a project.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
150 """
5314
76013775e623 Changed the way the currently opened project is highlighted in the multi project browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
151 projectfile = self.project.getProjectFile()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
152 project = {
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
153 'name': "",
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
154 'file': projectfile,
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
155 'master': False,
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
156 'description': "",
3197
4103c8013c36 Added support for the categorisation of projects to multi projects and changed the multi project file format.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
157 'category': "",
5889
092d06e0193f Fixed some weaknesses in the multi project code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5616
diff changeset
158 'uid': "",
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
159 }
3197
4103c8013c36 Added support for the categorisation of projects to multi projects and changed the multi project file format.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
160 itm = self.__findProjectItem(project)
4103c8013c36 Added support for the categorisation of projects to multi projects and changed the multi project file format.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
161 if itm:
5314
76013775e623 Changed the way the currently opened project is highlighted in the multi project browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
162 font = itm.font(0)
76013775e623 Changed the way the currently opened project is highlighted in the multi project browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
163 font.setBold(True)
76013775e623 Changed the way the currently opened project is highlighted in the multi project browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
164 itm.setFont(0, font)
76013775e623 Changed the way the currently opened project is highlighted in the multi project browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
165
76013775e623 Changed the way the currently opened project is highlighted in the multi project browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
166 def __projectClosed(self):
76013775e623 Changed the way the currently opened project is highlighted in the multi project browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
167 """
76013775e623 Changed the way the currently opened project is highlighted in the multi project browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
168 Private slot to handle the closing of a project.
76013775e623 Changed the way the currently opened project is highlighted in the multi project browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
169 """
76013775e623 Changed the way the currently opened project is highlighted in the multi project browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
170 for topIndex in range(self.topLevelItemCount()):
76013775e623 Changed the way the currently opened project is highlighted in the multi project browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
171 topItem = self.topLevelItem(topIndex)
76013775e623 Changed the way the currently opened project is highlighted in the multi project browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
172 for childIndex in range(topItem.childCount()):
76013775e623 Changed the way the currently opened project is highlighted in the multi project browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
173 childItem = topItem.child(childIndex)
76013775e623 Changed the way the currently opened project is highlighted in the multi project browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
174 font = childItem.font(0)
76013775e623 Changed the way the currently opened project is highlighted in the multi project browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
175 font.setBold(False)
76013775e623 Changed the way the currently opened project is highlighted in the multi project browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
176 childItem.setFont(0, font)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
177
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
178 def __contextMenuRequested(self, coord):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
179 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
180 Private slot to show the context menu.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
181
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
182 @param coord the position of the mouse pointer (QPoint)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
183 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
184 itm = self.itemAt(coord)
3197
4103c8013c36 Added support for the categorisation of projects to multi projects and changed the multi project file format.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
185 if itm is None or itm.parent() is None:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
186 self.__backMenu.popup(self.mapToGlobal(coord))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
187 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
188 self.__menu.popup(self.mapToGlobal(coord))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
189
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
190 def __openItem(self, itm=None):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
191 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
192 Private slot to open a project.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
193
3197
4103c8013c36 Added support for the categorisation of projects to multi projects and changed the multi project file format.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
194 @param itm reference to the project item to be opened (QTreeWidgetItem)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
195 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
196 if itm is None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
197 itm = self.currentItem()
3197
4103c8013c36 Added support for the categorisation of projects to multi projects and changed the multi project file format.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
198 if itm is None or itm.parent() is None:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
199 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
200
2099
afde0e9110f7 Implemented guards against double activation of list entries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
201 if not self.__openingProject:
5889
092d06e0193f Fixed some weaknesses in the multi project code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5616
diff changeset
202 filename = itm.data(0, MultiProjectBrowser.ProjectFileNameRole)
2099
afde0e9110f7 Implemented guards against double activation of list entries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
203 if filename:
afde0e9110f7 Implemented guards against double activation of list entries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
204 self.__openingProject = True
afde0e9110f7 Implemented guards against double activation of list entries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
205 self.multiProject.openProject(filename)
afde0e9110f7 Implemented guards against double activation of list entries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
206 self.__openingProject = False
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
207
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
208 ###########################################################################
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
209 ## Private methods below
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
210 ###########################################################################
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
211
3197
4103c8013c36 Added support for the categorisation of projects to multi projects and changed the multi project file format.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
212 def __findCategoryItem(self, category):
4103c8013c36 Added support for the categorisation of projects to multi projects and changed the multi project file format.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
213 """
4103c8013c36 Added support for the categorisation of projects to multi projects and changed the multi project file format.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
214 Private method to find the item for a category.
4103c8013c36 Added support for the categorisation of projects to multi projects and changed the multi project file format.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
215
4103c8013c36 Added support for the categorisation of projects to multi projects and changed the multi project file format.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
216 @param category category to search for (string)
4103c8013c36 Added support for the categorisation of projects to multi projects and changed the multi project file format.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
217 @return reference to the category item or None, if there is
4103c8013c36 Added support for the categorisation of projects to multi projects and changed the multi project file format.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
218 no such item (QTreeWidgetItem or None)
4103c8013c36 Added support for the categorisation of projects to multi projects and changed the multi project file format.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
219 """
4103c8013c36 Added support for the categorisation of projects to multi projects and changed the multi project file format.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
220 if category == "":
4103c8013c36 Added support for the categorisation of projects to multi projects and changed the multi project file format.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
221 category = self.tr("Not categorized")
4103c8013c36 Added support for the categorisation of projects to multi projects and changed the multi project file format.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
222 for index in range(self.topLevelItemCount()):
4103c8013c36 Added support for the categorisation of projects to multi projects and changed the multi project file format.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
223 itm = self.topLevelItem(index)
4103c8013c36 Added support for the categorisation of projects to multi projects and changed the multi project file format.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
224 if itm.text(0) == category:
4103c8013c36 Added support for the categorisation of projects to multi projects and changed the multi project file format.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
225 return itm
4103c8013c36 Added support for the categorisation of projects to multi projects and changed the multi project file format.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
226
4103c8013c36 Added support for the categorisation of projects to multi projects and changed the multi project file format.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
227 return None
4103c8013c36 Added support for the categorisation of projects to multi projects and changed the multi project file format.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
228
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
229 def __addProject(self, project):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
230 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
231 Private method to add a project to the list.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
232
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
233 @param project reference to the project data dictionary
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
234 """
3197
4103c8013c36 Added support for the categorisation of projects to multi projects and changed the multi project file format.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
235 parent = self.__findCategoryItem(project['category'])
4103c8013c36 Added support for the categorisation of projects to multi projects and changed the multi project file format.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
236 if parent is None:
4103c8013c36 Added support for the categorisation of projects to multi projects and changed the multi project file format.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
237 if project['category']:
4103c8013c36 Added support for the categorisation of projects to multi projects and changed the multi project file format.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
238 parent = QTreeWidgetItem(self, [project['category']])
4103c8013c36 Added support for the categorisation of projects to multi projects and changed the multi project file format.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
239 else:
4103c8013c36 Added support for the categorisation of projects to multi projects and changed the multi project file format.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
240 parent = QTreeWidgetItem(self, [self.tr("Not categorized")])
4103c8013c36 Added support for the categorisation of projects to multi projects and changed the multi project file format.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
241 parent.setExpanded(True)
4103c8013c36 Added support for the categorisation of projects to multi projects and changed the multi project file format.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
242 itm = QTreeWidgetItem(parent)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
243 self.__setItemData(itm, project)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
244
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
245 def __setItemData(self, itm, project):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
246 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
247 Private method to set the data of a project item.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
248
3197
4103c8013c36 Added support for the categorisation of projects to multi projects and changed the multi project file format.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
249 @param itm reference to the item to be set (QTreeWidgetItem)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
250 @param project reference to the project data dictionary
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
251 """
3197
4103c8013c36 Added support for the categorisation of projects to multi projects and changed the multi project file format.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
252 itm.setText(0, project['name'])
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
253 if project['master']:
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
254 itm.setIcon(0, UI.PixmapCache.getIcon("masterProject"))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
255 else:
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
256 itm.setIcon(0, UI.PixmapCache.getIcon("empty"))
3197
4103c8013c36 Added support for the categorisation of projects to multi projects and changed the multi project file format.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
257 itm.setToolTip(0, project['file'])
5889
092d06e0193f Fixed some weaknesses in the multi project code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5616
diff changeset
258 itm.setData(0, MultiProjectBrowser.ProjectFileNameRole,
092d06e0193f Fixed some weaknesses in the multi project code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5616
diff changeset
259 project['file'])
092d06e0193f Fixed some weaknesses in the multi project code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5616
diff changeset
260 itm.setData(0, MultiProjectBrowser.ProjectUidRole, project['uid'])
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
261
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
262 def __findProjectItem(self, project):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
263 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
264 Private method to search a specific project item.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
265
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
266 @param project reference to the project data dictionary
3197
4103c8013c36 Added support for the categorisation of projects to multi projects and changed the multi project file format.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
267 @return reference to the item (QTreeWidgetItem) or None
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
268 """
5889
092d06e0193f Fixed some weaknesses in the multi project code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5616
diff changeset
269 if project["uid"]:
092d06e0193f Fixed some weaknesses in the multi project code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5616
diff changeset
270 compareData = project["uid"]
092d06e0193f Fixed some weaknesses in the multi project code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5616
diff changeset
271 compareRole = MultiProjectBrowser.ProjectUidRole
092d06e0193f Fixed some weaknesses in the multi project code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5616
diff changeset
272 else:
092d06e0193f Fixed some weaknesses in the multi project code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5616
diff changeset
273 compareData = project["file"]
092d06e0193f Fixed some weaknesses in the multi project code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5616
diff changeset
274 compareRole = MultiProjectBrowser.ProjectFileNameRole
092d06e0193f Fixed some weaknesses in the multi project code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5616
diff changeset
275
3197
4103c8013c36 Added support for the categorisation of projects to multi projects and changed the multi project file format.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
276 for topIndex in range(self.topLevelItemCount()):
4103c8013c36 Added support for the categorisation of projects to multi projects and changed the multi project file format.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
277 topItm = self.topLevelItem(topIndex)
4103c8013c36 Added support for the categorisation of projects to multi projects and changed the multi project file format.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
278 for childIndex in range(topItm.childCount()):
4103c8013c36 Added support for the categorisation of projects to multi projects and changed the multi project file format.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
279 itm = topItm.child(childIndex)
5889
092d06e0193f Fixed some weaknesses in the multi project code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5616
diff changeset
280 data = itm.data(0, compareRole)
092d06e0193f Fixed some weaknesses in the multi project code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5616
diff changeset
281 if data == compareData:
3197
4103c8013c36 Added support for the categorisation of projects to multi projects and changed the multi project file format.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
282 return itm
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
283
3197
4103c8013c36 Added support for the categorisation of projects to multi projects and changed the multi project file format.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
284 return None
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
285
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
286 def __removeProject(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
287 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
288 Private method to handle the Remove context menu entry.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
289 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
290 itm = self.currentItem()
3197
4103c8013c36 Added support for the categorisation of projects to multi projects and changed the multi project file format.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
291 if itm is not None and itm.parent() is not None:
5889
092d06e0193f Fixed some weaknesses in the multi project code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5616
diff changeset
292 uid = itm.data(0, MultiProjectBrowser.ProjectUidRole)
092d06e0193f Fixed some weaknesses in the multi project code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5616
diff changeset
293 if uid:
092d06e0193f Fixed some weaknesses in the multi project code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5616
diff changeset
294 self.multiProject.removeProject(uid)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
295
6652
dfc89403b426 MultiProject, MultiProjectBrowser: added capability to delete a project from disk.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
296 def __deleteProject(self):
dfc89403b426 MultiProject, MultiProjectBrowser: added capability to delete a project from disk.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
297 """
dfc89403b426 MultiProject, MultiProjectBrowser: added capability to delete a project from disk.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
298 Private method to handle the Delete context menu entry.
dfc89403b426 MultiProject, MultiProjectBrowser: added capability to delete a project from disk.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
299 """
dfc89403b426 MultiProject, MultiProjectBrowser: added capability to delete a project from disk.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
300 itm = self.currentItem()
dfc89403b426 MultiProject, MultiProjectBrowser: added capability to delete a project from disk.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
301 if itm is not None and itm.parent() is not None:
dfc89403b426 MultiProject, MultiProjectBrowser: added capability to delete a project from disk.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
302 projectFile = itm.data(0, MultiProjectBrowser.ProjectFileNameRole)
dfc89403b426 MultiProject, MultiProjectBrowser: added capability to delete a project from disk.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
303 projectPath = os.path.dirname(projectFile)
dfc89403b426 MultiProject, MultiProjectBrowser: added capability to delete a project from disk.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
304
dfc89403b426 MultiProject, MultiProjectBrowser: added capability to delete a project from disk.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
305 if self.project.getProjectPath() == projectPath:
dfc89403b426 MultiProject, MultiProjectBrowser: added capability to delete a project from disk.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
306 E5MessageBox.warning(
dfc89403b426 MultiProject, MultiProjectBrowser: added capability to delete a project from disk.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
307 self,
dfc89403b426 MultiProject, MultiProjectBrowser: added capability to delete a project from disk.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
308 self.tr("Delete Project"),
dfc89403b426 MultiProject, MultiProjectBrowser: added capability to delete a project from disk.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
309 self.tr("""The current project cannot be deleted."""
dfc89403b426 MultiProject, MultiProjectBrowser: added capability to delete a project from disk.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
310 """ Please close it first."""))
dfc89403b426 MultiProject, MultiProjectBrowser: added capability to delete a project from disk.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
311 else:
8047
b5594178c7fa Made some more JSON file related changes and exported some dark styles in the new file format.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
312 projectFiles = glob.glob(os.path.join(projectPath, "*.epj"))
b5594178c7fa Made some more JSON file related changes and exported some dark styles in the new file format.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
313 projectFiles += glob.glob(os.path.join(projectPath, "*.e4p"))
6652
dfc89403b426 MultiProject, MultiProjectBrowser: added capability to delete a project from disk.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
314 if not projectFiles:
dfc89403b426 MultiProject, MultiProjectBrowser: added capability to delete a project from disk.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
315 # Oops, that should not happen; play it save
dfc89403b426 MultiProject, MultiProjectBrowser: added capability to delete a project from disk.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
316 res = False
dfc89403b426 MultiProject, MultiProjectBrowser: added capability to delete a project from disk.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
317 elif len(projectFiles) == 1:
dfc89403b426 MultiProject, MultiProjectBrowser: added capability to delete a project from disk.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
318 res = E5MessageBox.yesNo(
dfc89403b426 MultiProject, MultiProjectBrowser: added capability to delete a project from disk.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
319 self,
dfc89403b426 MultiProject, MultiProjectBrowser: added capability to delete a project from disk.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
320 self.tr("Delete Project"),
dfc89403b426 MultiProject, MultiProjectBrowser: added capability to delete a project from disk.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
321 self.tr("""<p>Shall the project <b>{0}</b> (Path:"""
dfc89403b426 MultiProject, MultiProjectBrowser: added capability to delete a project from disk.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
322 """ {1}) really be deleted?</p>""").format(
dfc89403b426 MultiProject, MultiProjectBrowser: added capability to delete a project from disk.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
323 itm.text(0), projectPath))
dfc89403b426 MultiProject, MultiProjectBrowser: added capability to delete a project from disk.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
324 else:
dfc89403b426 MultiProject, MultiProjectBrowser: added capability to delete a project from disk.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
325 res = E5MessageBox.yesNo(
dfc89403b426 MultiProject, MultiProjectBrowser: added capability to delete a project from disk.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
326 self,
dfc89403b426 MultiProject, MultiProjectBrowser: added capability to delete a project from disk.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
327 self.tr("Delete Project"),
dfc89403b426 MultiProject, MultiProjectBrowser: added capability to delete a project from disk.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
328 self.tr("""<p>Shall the project <b>{0}</b> (Path:"""
dfc89403b426 MultiProject, MultiProjectBrowser: added capability to delete a project from disk.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
329 """ {1}) really be deleted?</p>"""
dfc89403b426 MultiProject, MultiProjectBrowser: added capability to delete a project from disk.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
330 """<p><b>Warning:</b> It contains <b>{2}</b>"""
dfc89403b426 MultiProject, MultiProjectBrowser: added capability to delete a project from disk.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
331 """ sub-projects.</p>""").format(
dfc89403b426 MultiProject, MultiProjectBrowser: added capability to delete a project from disk.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
332 itm.text(0), projectPath, len(projectFiles)))
dfc89403b426 MultiProject, MultiProjectBrowser: added capability to delete a project from disk.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
333 if res:
dfc89403b426 MultiProject, MultiProjectBrowser: added capability to delete a project from disk.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
334 for subprojectFile in projectFiles:
dfc89403b426 MultiProject, MultiProjectBrowser: added capability to delete a project from disk.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
335 # remove all sub-projects before deleting the directory
dfc89403b426 MultiProject, MultiProjectBrowser: added capability to delete a project from disk.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
336 if subprojectFile != projectFile:
dfc89403b426 MultiProject, MultiProjectBrowser: added capability to delete a project from disk.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
337 projectData = {
dfc89403b426 MultiProject, MultiProjectBrowser: added capability to delete a project from disk.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
338 'name': "",
dfc89403b426 MultiProject, MultiProjectBrowser: added capability to delete a project from disk.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
339 'file': subprojectFile,
dfc89403b426 MultiProject, MultiProjectBrowser: added capability to delete a project from disk.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
340 'master': False,
dfc89403b426 MultiProject, MultiProjectBrowser: added capability to delete a project from disk.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
341 'description': "",
dfc89403b426 MultiProject, MultiProjectBrowser: added capability to delete a project from disk.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
342 'category': "",
dfc89403b426 MultiProject, MultiProjectBrowser: added capability to delete a project from disk.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
343 'uid': "",
dfc89403b426 MultiProject, MultiProjectBrowser: added capability to delete a project from disk.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
344 }
dfc89403b426 MultiProject, MultiProjectBrowser: added capability to delete a project from disk.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
345 pitm = self.__findProjectItem(projectData)
dfc89403b426 MultiProject, MultiProjectBrowser: added capability to delete a project from disk.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
346 if pitm:
dfc89403b426 MultiProject, MultiProjectBrowser: added capability to delete a project from disk.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
347 uid = pitm.data(
dfc89403b426 MultiProject, MultiProjectBrowser: added capability to delete a project from disk.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
348 0, MultiProjectBrowser.ProjectUidRole)
dfc89403b426 MultiProject, MultiProjectBrowser: added capability to delete a project from disk.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
349 if uid:
dfc89403b426 MultiProject, MultiProjectBrowser: added capability to delete a project from disk.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
350 self.multiProject.removeProject(uid)
dfc89403b426 MultiProject, MultiProjectBrowser: added capability to delete a project from disk.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
351
dfc89403b426 MultiProject, MultiProjectBrowser: added capability to delete a project from disk.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
352 uid = itm.data(0, MultiProjectBrowser.ProjectUidRole)
dfc89403b426 MultiProject, MultiProjectBrowser: added capability to delete a project from disk.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
353 if uid:
dfc89403b426 MultiProject, MultiProjectBrowser: added capability to delete a project from disk.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
354 self.multiProject.deleteProject(uid)
dfc89403b426 MultiProject, MultiProjectBrowser: added capability to delete a project from disk.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
355
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
356 def __showProjectProperties(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
357 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
358 Private method to show the data of a project entry.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
359 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
360 itm = self.currentItem()
3197
4103c8013c36 Added support for the categorisation of projects to multi projects and changed the multi project file format.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
361 if itm is not None and itm.parent() is not None:
5889
092d06e0193f Fixed some weaknesses in the multi project code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5616
diff changeset
362 uid = itm.data(0, MultiProjectBrowser.ProjectUidRole)
092d06e0193f Fixed some weaknesses in the multi project code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5616
diff changeset
363 if uid:
092d06e0193f Fixed some weaknesses in the multi project code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5616
diff changeset
364 project = self.multiProject.getProject(uid)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
365 if project is not None:
2404
cba0ff902c2b Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2317
diff changeset
366 from .AddProjectDialog import AddProjectDialog
3197
4103c8013c36 Added support for the categorisation of projects to multi projects and changed the multi project file format.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
367 dlg = AddProjectDialog(
4103c8013c36 Added support for the categorisation of projects to multi projects and changed the multi project file format.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
368 self, project=project,
4103c8013c36 Added support for the categorisation of projects to multi projects and changed the multi project file format.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
369 categories=self.multiProject.getCategories())
7759
51aa6c6b66f7 Changed calls to exec_() into exec() (remainder of Python2 elimination).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
370 if dlg.exec() == QDialog.Accepted:
3545
4a0bbb2d5457 Improved the multi project manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
371 (name, filename, isMaster, description, category,
4a0bbb2d5457 Improved the multi project manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
372 uid) = dlg.getData()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
373 project = {
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
374 'name': name,
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
375 'file': filename,
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
376 'master': isMaster,
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
377 'description': description,
3197
4103c8013c36 Added support for the categorisation of projects to multi projects and changed the multi project file format.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
378 'category': category,
3545
4a0bbb2d5457 Improved the multi project manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
379 'uid': uid,
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
380 }
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
381 self.multiProject.changeProjectProperties(project)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
382
2317
ac7ffbf5b36b Extended the context menus of the multi project browser to be able to add projects this way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
383 def __addNewProject(self):
ac7ffbf5b36b Extended the context menus of the multi project browser to be able to add projects this way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
384 """
ac7ffbf5b36b Extended the context menus of the multi project browser to be able to add projects this way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
385 Private method to add a new project entry.
ac7ffbf5b36b Extended the context menus of the multi project browser to be able to add projects this way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
386 """
6653
ac800d2700d2 MultiProjectBrowser: use category of current entry to preset the category of a project to be added.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6652
diff changeset
387 itm = self.currentItem()
ac800d2700d2 MultiProjectBrowser: use category of current entry to preset the category of a project to be added.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6652
diff changeset
388 if itm is not None:
ac800d2700d2 MultiProjectBrowser: use category of current entry to preset the category of a project to be added.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6652
diff changeset
389 if itm.parent() is None:
ac800d2700d2 MultiProjectBrowser: use category of current entry to preset the category of a project to be added.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6652
diff changeset
390 # current item is a category item
ac800d2700d2 MultiProjectBrowser: use category of current entry to preset the category of a project to be added.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6652
diff changeset
391 category = itm.text(0)
ac800d2700d2 MultiProjectBrowser: use category of current entry to preset the category of a project to be added.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6652
diff changeset
392 else:
ac800d2700d2 MultiProjectBrowser: use category of current entry to preset the category of a project to be added.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6652
diff changeset
393 category = itm.parent().text(0)
ac800d2700d2 MultiProjectBrowser: use category of current entry to preset the category of a project to be added.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6652
diff changeset
394 else:
ac800d2700d2 MultiProjectBrowser: use category of current entry to preset the category of a project to be added.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6652
diff changeset
395 category = ""
ac800d2700d2 MultiProjectBrowser: use category of current entry to preset the category of a project to be added.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6652
diff changeset
396 self.multiProject.addNewProject(category=category)
2317
ac7ffbf5b36b Extended the context menus of the multi project browser to be able to add projects this way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
397
6836
93b8c77502e0 Multi Project: added capability to the multi project browser to copy a project.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6674
diff changeset
398 def __copyProject(self):
93b8c77502e0 Multi Project: added capability to the multi project browser to copy a project.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6674
diff changeset
399 """
93b8c77502e0 Multi Project: added capability to the multi project browser to copy a project.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6674
diff changeset
400 Private method to copy the selected project on disk.
93b8c77502e0 Multi Project: added capability to the multi project browser to copy a project.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6674
diff changeset
401 """
93b8c77502e0 Multi Project: added capability to the multi project browser to copy a project.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6674
diff changeset
402 itm = self.currentItem()
93b8c77502e0 Multi Project: added capability to the multi project browser to copy a project.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6674
diff changeset
403 if itm and itm.parent():
93b8c77502e0 Multi Project: added capability to the multi project browser to copy a project.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6674
diff changeset
404 # it is a project item and not a category
93b8c77502e0 Multi Project: added capability to the multi project browser to copy a project.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6674
diff changeset
405 uid = itm.data(0, MultiProjectBrowser.ProjectUidRole)
93b8c77502e0 Multi Project: added capability to the multi project browser to copy a project.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6674
diff changeset
406 if uid:
93b8c77502e0 Multi Project: added capability to the multi project browser to copy a project.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6674
diff changeset
407 self.multiProject.copyProject(uid)
93b8c77502e0 Multi Project: added capability to the multi project browser to copy a project.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6674
diff changeset
408
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
409 def __createPopupMenu(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
410 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
411 Private method to create the popup menu.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
412 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
413 self.__menu = QMenu(self)
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
414 self.__menu.addAction(self.tr("Open"), self.__openItem)
6652
dfc89403b426 MultiProject, MultiProjectBrowser: added capability to delete a project from disk.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
415 self.__menu.addAction(self.tr("Remove from Multi Project"),
dfc89403b426 MultiProject, MultiProjectBrowser: added capability to delete a project from disk.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
416 self.__removeProject)
dfc89403b426 MultiProject, MultiProjectBrowser: added capability to delete a project from disk.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
417 self.__menu.addAction(self.tr("Delete from Disk"),
dfc89403b426 MultiProject, MultiProjectBrowser: added capability to delete a project from disk.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
418 self.__deleteProject)
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
419 self.__menu.addAction(self.tr("Properties"),
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
420 self.__showProjectProperties)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
421 self.__menu.addSeparator()
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
422 self.__menu.addAction(self.tr("Add Project..."),
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
423 self.__addNewProject)
6836
93b8c77502e0 Multi Project: added capability to the multi project browser to copy a project.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6674
diff changeset
424 self.__menu.addAction(self.tr("Copy Project..."),
93b8c77502e0 Multi Project: added capability to the multi project browser to copy a project.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6674
diff changeset
425 self.__copyProject)
2317
ac7ffbf5b36b Extended the context menus of the multi project browser to be able to add projects this way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
426 self.__menu.addSeparator()
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
427 self.__menu.addAction(self.tr("Configure..."), self.__configure)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
428
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
429 self.__backMenu = QMenu(self)
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
430 self.__backMenu.addAction(self.tr("Add Project..."),
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
431 self.__addNewProject)
2317
ac7ffbf5b36b Extended the context menus of the multi project browser to be able to add projects this way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
432 self.__backMenu.addSeparator()
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
433 self.__backMenu.addAction(self.tr("Configure..."),
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
434 self.__configure)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
435
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
436 def __configure(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
437 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
438 Private method to open the configuration dialog.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
439 """
458
1695e7a2db54 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
440 e5App().getObject("UserInterface").showPreferences("multiProjectPage")

eric ide

mercurial