프로젝트

일반

사용자정보

개정판 b3ac9e2e

IDb3ac9e2ed78f18b153c993f8fd78d55cec6fa154
상위 7402cc95
하위 7ca21e50

백흠경이(가) 약 5년 전에 추가함

issue #571: 프로젝트 이름에 공백을 허용하지 않는다

Change-Id: I23ce805894fbd7d88564d9aed9642d605f1eea55

차이점 보기:

DTI_PID/DTI_PID/ProjectDialog.py
13 13
from AppDocData import AppDocData
14 14
import Project_UI
15 15

  
16

  
16 17
class Ui_Dialog(QDialog):
17 18
    def __init__(self, parent=None):
18 19
        QDialog.__init__(self, parent)
......
27 28
        self.ui.radioButtonMSSQL.clicked.connect(self.on_mssql_selected)
28 29
        self.ui.lineEditPassword.setEchoMode(QLineEdit.Password)
29 30
        self.ui.pushButtonTestConnection.clicked.connect(self.on_test_connection_clicked)
30
        self.changeProject()    # force fill project's properties
31
        self.changeProject()  # force fill project's properties
31 32
        self.ui.toolButton.clicked.connect(self.addProjectClick)
32 33
        self.ui.toolButtonDelete.clicked.connect(self.deleteProjectClick)
33 34
        self.setWindowTitle(_translate('Project Dialog', 'Project'))
......
37 38

  
38 39
        self.ui.comboBox.clear()
39 40
        projectList = AppDocData.instance().getProjectList()
40
        ## ComboBox setting
41
        # ComboBox setting
41 42
        for project in projectList:
42 43
            self.ui.comboBox.addItem(project.getName(), project)
43 44

  
......
49 50
        self.ui.comboBoxProjectUnit.setCurrentIndex(0)
50 51

  
51 52
    def showDialog(self):
52
        self.setWindowFlags(self.windowFlags() & ~QtCore.Qt.WindowCloseButtonHint & ~QtCore.Qt.WindowContextHelpButtonHint)
53
        self.setWindowFlags(
54
            self.windowFlags() & ~QtCore.Qt.WindowCloseButtonHint & ~QtCore.Qt.WindowContextHelpButtonHint)
53 55
        self.exec_()
54 56

  
55 57
        index = self.ui.comboBox.currentIndex()
......
94 96
        options = QFileDialog.Options()
95 97
        options |= QFileDialog.DontUseNativeDialog
96 98
        options |= QFileDialog.ShowDirsOnly
97
        selectedDir = QFileDialog.getExistingDirectory(None, _translate('Project Dialog', "Select Project Path"), os.getcwd(), options=options)
98
        if selectedDir:
99
        selectedDir = QFileDialog.getExistingDirectory(None, _translate('Project Dialog', "Select Project Path"),
100
                                                       os.getcwd(), options=options)
101
        if selectedDir and not any(c.isspace() for c in selectedDir):
99 102
            prj_unit = self.ui.comboBoxProjectUnit.currentText()
100 103
            self.insertProjectInfo(dir=selectedDir, desc=self.ui.lineEditProjectDesc.text(), prj_unit=prj_unit)
104
        else:
105
            QMessageBox.warning(self, self.tr('Message'), self.tr('Folder name should not contains space'))
101 106

  
102 107
    def deleteProjectClick(self):
103
        """
104
        remove selected project
105
        """
108
        """remove selected project"""
106 109
        self.selectedProject = self.ui.comboBox.currentData()
107 110
        if self.selectedProject:
108 111
            msg = QMessageBox()
109 112
            msg.setIcon(QMessageBox.Critical)
110
            msg.setText(self.tr('Are you sure you want to delete project "{}" ?\nData can not be restored! '.format(self.selectedProject.name)))
113
            msg.setText(self.tr('Are you sure you want to delete project "{}" ?\nData can not be restored! '.format(
114
                self.selectedProject.name)))
111 115
            msg.setWindowTitle(self.tr('Delete Project'))
112
            msg.setStandardButtons(QMessageBox.Ok|QMessageBox.Cancel)
116
            msg.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel)
113 117
            if QMessageBox.Ok == msg.exec_():
114 118
                AppDocData.instance().removeProjectInfo(self.selectedProject)
115 119
                self.initComboBox()
116
        
120

  
117 121
    '''
118 122
        @brief      display project desc,unit and database information when change project
119 123
        @author     humkyung
120 124
        @date       2019.04.09
121 125
    '''
126

  
122 127
    def changeProject(self):
123 128
        index = self.ui.comboBox.currentIndex()
124 129
        project = self.ui.comboBox.itemData(index)
125
        if project:        
130
        if project:
126 131
            self.ui.lineEditProjectDesc.setText(project.desc)
127 132
            self.ui.comboBoxProjectUnit.setCurrentText(project.prj_unit)
128 133

  
......
158 163

  
159 164
        index = self.ui.comboBox.currentIndex()
160 165
        project = self.ui.comboBox.itemData(index)
161
        database = AppDatabase('MSSQL', self.ui.lineEditServer.text(), self.ui.lineEditUser.text(), self.ui.lineEditPassword.text(), db_path=project.getName())
166
        database = AppDatabase('MSSQL', self.ui.lineEditServer.text(), self.ui.lineEditUser.text(),
167
                               self.ui.lineEditPassword.text(), db_path=project.getName())
162 168
        try:
163 169
            conn = database.connect()
164 170
            with conn:
......
173 179
    def insertProjectInfo(self, desc, prj_unit, dir):
174 180
        AppDocData.instance().insertProjectInfo(dir=dir, desc=desc, prj_unit=prj_unit)
175 181
        self.initComboBox()
176
        
177
#if __name__ == "__init__":
182

  
183
# if __name__ == "__init__":
178 184
#    dialog = QtWidgets.QDialog()
179 185
#    ui = Ui_Dialog()
180 186
#    ui.setupUi(Dialog)
181 187
#    Dialog.show()
182 188

  
183
#if __name__ == "__main__":
189
# if __name__ == "__main__":
184 190
#    import sys
185 191
#    app = QtWidgets.QApplication(sys.argv)
186 192
#    Dialog = QtWidgets.QDialog()
187 193
#    Dialog.show()
188
#    sys.exit(app.exec_())
194
#    sys.exit(app.exec_())

내보내기 Unified diff

클립보드 이미지 추가 (최대 크기: 500 MB)