MultiProject/AddProjectDialog.py

branch
Py2 comp.
changeset 3484
645c12de6b0c
parent 3178
f25fc1364c88
parent 3197
4103c8013c36
child 3545
4a0bbb2d5457
--- a/MultiProject/AddProjectDialog.py	Sun Mar 30 22:00:14 2014 +0200
+++ b/MultiProject/AddProjectDialog.py	Thu Apr 03 23:05:31 2014 +0200
@@ -18,32 +18,41 @@
 from .Ui_AddProjectDialog import Ui_AddProjectDialog
 
 import Utilities
+import UI.PixmapCache
 
 
 class AddProjectDialog(QDialog, Ui_AddProjectDialog):
     """
     Class implementing the add project dialog.
     """
-    def __init__(self, parent=None, startdir=None, project=None):
+    def __init__(self, parent=None, startdir=None, project=None,
+                 categories=None):
         """
         Constructor
         
         @param parent parent widget of this dialog (QWidget)
         @param startdir start directory for the selection dialog (string)
         @param project dictionary containing project data
+        @param categories list of already used categories (list of string)
         """
         super(AddProjectDialog, self).__init__(parent)
         self.setupUi(self)
         
+        self.fileButton.setIcon(UI.PixmapCache.getIcon("open.png"))
+        
         self.fileCompleter = E5FileCompleter(self.filenameEdit)
         
+        if categories:
+            self.categoryComboBox.addItem("")
+            self.categoryComboBox.addItems(sorted(categories))
+        
         self.startdir = startdir
         
         self.__okButton = self.buttonBox.button(QDialogButtonBox.Ok)
         self.__okButton.setEnabled(False)
         
         if project is not None:
-            self.setWindowTitle(self.trUtf8("Project Properties"))
+            self.setWindowTitle(self.tr("Project Properties"))
             
             self.filenameEdit.setReadOnly(True)
             self.fileButton.setEnabled(False)
@@ -52,6 +61,10 @@
             self.filenameEdit.setText(project['file'])
             self.descriptionEdit.setPlainText(project['description'])
             self.masterCheckBox.setChecked(project['master'])
+            index = self.categoryComboBox.findText(project['category'])
+            if index == -1:
+                index = 0
+            self.categoryComboBox.setCurrentIndex(index)
     
     @pyqtSlot()
     def on_fileButton_clicked(self):
@@ -63,9 +76,9 @@
             startdir = self.startdir
             projectFile = E5FileDialog.getOpenFileName(
                 self,
-                self.trUtf8("Add Project"),
+                self.tr("Add Project"),
                 startdir,
-                self.trUtf8("Project Files (*.e4p)"))
+                self.tr("Project Files (*.e4p)"))
             
             if projectFile:
                 self.filenameEdit.setText(
@@ -75,14 +88,16 @@
         """
         Public slot to retrieve the dialogs data.
         
-        @return tuple of four values (string, string, boolean, string) giving
-            the project name, the name of the project file, a flag telling,
-            whether the project shall be the main project and a short
-            description for the project
+        @return tuple of five values (string, string, boolean, string, string)
+            giving the project name, the name of the project file, a flag
+            telling whether the project shall be the main project, a short
+            description for the project and the project category
         """
-        return (self.nameEdit.text(), self.filenameEdit.text(),
+        return (self.nameEdit.text(),
+                self.filenameEdit.text(),
                 self.masterCheckBox.isChecked(),
-                self.descriptionEdit.toPlainText())
+                self.descriptionEdit.toPlainText(),
+                self.categoryComboBox.currentText())
     
     @pyqtSlot(str)
     def on_nameEdit_textChanged(self, txt):

eric ide

mercurial