|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2006 - 2009 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing the user specific project properties dialog. |
|
8 """ |
|
9 |
|
10 from PyQt4.QtCore import * |
|
11 from PyQt4.QtGui import * |
|
12 |
|
13 from E4Gui.E4Application import e4App |
|
14 |
|
15 import Preferences |
|
16 |
|
17 from Ui_UserPropertiesDialog import Ui_UserPropertiesDialog |
|
18 |
|
19 class UserPropertiesDialog(QDialog, Ui_UserPropertiesDialog): |
|
20 """ |
|
21 Class implementing the user specific project properties dialog. |
|
22 """ |
|
23 def __init__(self, project, parent = None, name = None): |
|
24 """ |
|
25 Constructor |
|
26 |
|
27 @param project reference to the project object |
|
28 @param parent parent widget of this dialog (QWidget) |
|
29 @param name name of this dialog (string) |
|
30 """ |
|
31 QDialog.__init__(self, parent) |
|
32 if name: |
|
33 self.setObjectName(name) |
|
34 self.setupUi(self) |
|
35 |
|
36 self.project = project |
|
37 |
|
38 if self.project.pudata["VCSSTATUSMONITORINTERVAL"]: |
|
39 self.vcsStatusMonitorIntervalSpinBox.setValue( |
|
40 self.project.pudata["VCSSTATUSMONITORINTERVAL"][0]) |
|
41 else: |
|
42 self.vcsStatusMonitorIntervalSpinBox.setValue( |
|
43 Preferences.getVCS("StatusMonitorInterval")) |
|
44 |
|
45 enableVcsGroup = False |
|
46 if self.project.pdata["VCS"]: |
|
47 found = False |
|
48 for indicator, vcsData in e4App().getObject("PluginManager")\ |
|
49 .getVcsSystemIndicators().items(): |
|
50 for vcsSystem, vcsSystemDisplay in vcsData: |
|
51 if vcsSystem == self.project.pdata["VCS"][0]: |
|
52 found = True |
|
53 break |
|
54 |
|
55 if found: |
|
56 for vcsSystem, vcsSystemDisplay in vcsData: |
|
57 self.vcsInterfaceCombo.addItem(vcsSystemDisplay, |
|
58 QVariant(vcsSystem)) |
|
59 enableVcsGroup = len(vcsData) > 1 |
|
60 break |
|
61 self.vcsGroup.setEnabled(enableVcsGroup) |
|
62 |
|
63 if self.vcsGroup.isEnabled(): |
|
64 if self.project.pudata["VCSOVERRIDE"]: |
|
65 vcsSystem = self.project.pudata["VCSOVERRIDE"][0] |
|
66 else: |
|
67 vcsSystem = self.project.pdata["VCS"][0] |
|
68 index = self.vcsInterfaceCombo.findData(QVariant(vcsSystem)) |
|
69 if index == -1: |
|
70 index = 0 |
|
71 self.vcsInterfaceCombo.setCurrentIndex(index) |
|
72 |
|
73 def storeData(self): |
|
74 """ |
|
75 Public method to store the entered/modified data. |
|
76 """ |
|
77 vcsStatusMonitorInterval = self.vcsStatusMonitorIntervalSpinBox.value() |
|
78 if vcsStatusMonitorInterval != Preferences.getVCS("StatusMonitorInterval"): |
|
79 self.project.pudata["VCSSTATUSMONITORINTERVAL"] = [vcsStatusMonitorInterval] |
|
80 else: |
|
81 self.project.pudata["VCSSTATUSMONITORINTERVAL"] = [] |
|
82 |
|
83 if self.vcsGroup.isEnabled(): |
|
84 vcsSystem = self.vcsInterfaceCombo\ |
|
85 .itemData(self.vcsInterfaceCombo.currentIndex()).toString() |
|
86 if self.vcsInterfaceDefaultCheckBox.isChecked(): |
|
87 if vcsSystem != self.project.pdata["VCS"][0]: |
|
88 self.project.pdata["VCS"] = [vcsSystem] |
|
89 self.project.pudata["VCSOVERRIDE"] = [] |
|
90 self.project.setDirty(True) |
|
91 else: |
|
92 if vcsSystem != self.project.pdata["VCS"][0]: |
|
93 self.project.pudata["VCSOVERRIDE"] = [vcsSystem] |
|
94 else: |
|
95 self.project.pudata["VCSOVERRIDE"] = [] |