개정판 b0ca3df0
issue #571: change project dialog
Change-Id: If3a6669680535f6a8ae64c44b0cab36e4fc2132b
App.spec | ||
---|---|---|
14 | 14 |
('C:\\Temp\\workspace\\ID2\\DTI_PID\\DTI_PID\\db\\*.db', 'db'), |
15 | 15 |
('C:\\Temp\\workspace\\ID2\\DTI_PID\\DTI_PID\\translate\\*.qm', 'translate'), |
16 | 16 |
('C:\\Temp\\workspace\\ID2\\DTI_PID\\DTI_PID\\Scripts\\*.sql', 'Scripts'), |
17 |
('.\\DTI_PID\\DTI_PID\\res\\*.svg', 'res'), |
|
17 | 18 |
('C:\\Temp\\workspace\ID2\\DTI_PID\DTI_PID\\Tesseract-OCR\\*.*', 'Tesseract-OCR'), |
18 | 19 |
('C:\\Temp\\workspace\ID2\\DTI_PID\DTI_PID\\Tesseract-OCR\\doc\\*', 'Tesseract-OCR\\doc'), |
19 | 20 |
('C:\\Temp\\workspace\ID2\\DTI_PID\DTI_PID\\Tesseract-OCR\\java\\*', 'Tesseract-OCR\\java'), |
DTI_PID/DTI_PID/AppDocData.py | ||
---|---|---|
988 | 988 |
@date 2018.04.06 |
989 | 989 |
@history humkyung 2018.04.19 use getPrjDatabasePath function instead of PROJECT_DB_PATH variable |
990 | 990 |
''' |
991 |
def insertProjectInfo(self, dir): |
|
991 |
def insertProjectInfo(self, desc, prj_unit, dir):
|
|
992 | 992 |
try: |
993 | 993 |
prjDatabaseFilePath = self.getPrjDatabasePath() |
994 | 994 |
conn = sqlite3.connect(prjDatabaseFilePath) |
995 | 995 |
folderName = dir.split('/')[-1] |
996 | 996 |
if folderName: |
997 | 997 |
nowDate = datetime.datetime.now().strftime('%Y.%m.%d %H:%M') |
998 |
sql = "INSERT INTO Projects(Name, Path, CreatedDate, UpdatedDate) VALUES('" + folderName + "', '" + dir + "', '" + nowDate + "', '" + nowDate + "')" |
|
999 |
cur = conn.cursor() |
|
1000 |
cur.execute(sql) |
|
998 |
sql = "insert into Projects(Name, [Desc], [Unit], Path, CreatedDate, UpdatedDate) values(?, ?, ?, ?, ?, ?)" |
|
999 |
param = (folderName, desc, prj_unit, dir, nowDate, nowDate) |
|
1000 |
|
|
1001 |
cursor = conn.cursor() |
|
1002 |
cursor.execute(sql, param) |
|
1001 | 1003 |
conn.commit() |
1002 | 1004 |
else: |
1003 | 1005 |
print("Empty folder name") |
... | ... | |
1034 | 1036 |
@date 2018.04.06 |
1035 | 1037 |
@history humkyung 2018.04.19 use getPrjDatabasePath function instead of PROJECT_DB_PATH variable |
1036 | 1038 |
''' |
1037 |
def updateProjectUpdatedDate(self, id): |
|
1039 |
def updateProjectUpdatedDate(self, id, desc, prj_unit):
|
|
1038 | 1040 |
try: |
1039 | 1041 |
prjDatabaseFilePath = self.getPrjDatabasePath() |
1040 | 1042 |
conn = sqlite3.connect(prjDatabaseFilePath) |
1041 | 1043 |
nowDate = datetime.datetime.now().strftime('%Y.%m.%d %H:%M') |
1042 | 1044 |
sql = ''' |
1043 | 1045 |
UPDATE Projects |
1044 |
SET UpdatedDate = ? |
|
1046 |
SET UpdatedDate = ?,[Desc]=?,[Unit]=?
|
|
1045 | 1047 |
WHERE Id = ? |
1046 | 1048 |
''' |
1047 | 1049 |
cur = conn.cursor() |
1048 |
cur.execute(sql, (nowDate, id)) |
|
1050 |
cur.execute(sql, (nowDate, desc, prj_unit, id))
|
|
1049 | 1051 |
conn.commit() |
1050 | 1052 |
except Exception as ex: |
1051 | 1053 |
# Roll back any change if something goes wrong |
... | ... | |
1066 | 1068 |
try: |
1067 | 1069 |
conn = sqlite3.connect(self.getPrjDatabasePath()) |
1068 | 1070 |
cursor = conn.cursor() |
1069 |
sql = 'SELECT id,name,path,createddate,updateddate FROM Projects ORDER BY UpdatedDate DESC' |
|
1071 |
sql = 'SELECT id,name,[desc],[unit],path,createddate,updateddate FROM Projects ORDER BY UpdatedDate DESC'
|
|
1070 | 1072 |
try: |
1071 | 1073 |
cursor.execute(sql) |
1072 | 1074 |
rows = cursor.fetchall() |
1073 | 1075 |
for row in rows: |
1074 |
if os.path.isdir(row[2]): # check if folder exists
|
|
1075 |
projectList.append(Project(row[0], row[1], row[2], row[3], row[4]))
|
|
1076 |
if os.path.isdir(row[4]): # check if folder exists
|
|
1077 |
projectList.append(Project(row[0], row[1], desc=row[2], prj_unit=row[3], path=row[4], createDate=row[5], updateDate=row[6]))
|
|
1076 | 1078 |
except Exception as ex: |
1077 | 1079 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
1078 | 1080 |
finally: |
DTI_PID/DTI_PID/Project.py | ||
---|---|---|
3 | 3 |
import os |
4 | 4 | |
5 | 5 |
class Project(): |
6 |
def __init__(self, id, name, path, createDate, updateDate): |
|
6 |
def __init__(self, id, name, desc, prj_unit, path, createDate, updateDate):
|
|
7 | 7 |
self.id = id |
8 | 8 |
self.name = name |
9 |
self._desc = desc |
|
10 |
self._prj_unit = prj_unit |
|
9 | 11 |
self.path = path |
10 | 12 |
self.createDate = createDate |
11 | 13 |
self.updateDate = updateDate |
... | ... | |
22 | 24 |
def getName(self): |
23 | 25 |
return self.name |
24 | 26 | |
27 |
@property |
|
28 |
def desc(self): |
|
29 |
return self._desc |
|
30 |
|
|
31 |
@desc.setter |
|
32 |
def desc(self, value): |
|
33 |
""" |
|
34 |
setter of desc |
|
35 |
""" |
|
36 |
self._desc = value |
|
37 | ||
38 |
@property |
|
39 |
def prj_unit(self): |
|
40 |
return self._prj_unit |
|
41 | ||
42 |
@prj_unit.setter |
|
43 |
def prj_unit(self, value): |
|
44 |
""" |
|
45 |
setter of prj_unit |
|
46 |
""" |
|
47 |
self._prj_unit = value |
|
48 | ||
25 | 49 |
def setPath(self, path): |
26 | 50 |
self.path = path |
27 | 51 |
DTI_PID/DTI_PID/ProjectDialog.py | ||
---|---|---|
22 | 22 |
self.ui = Project_UI.Ui_ProjectDialog() |
23 | 23 |
self.ui.setupUi(self) |
24 | 24 |
self.initComboBox() |
25 |
self.ui.comboBox.currentIndexChanged.connect(self.changeProject) |
|
26 |
self.changeProject() # force fill project's properties |
|
25 | 27 |
self.ui.toolButton.clicked.connect(self.addProjectClick) |
26 | 28 |
self.ui.toolButtonDelete.clicked.connect(self.deleteProjectClick) |
27 | 29 |
self.setWindowTitle(_translate('Project Dialog', 'Project')) |
... | ... | |
37 | 39 | |
38 | 40 |
if projectList: self.ui.comboBox.setCurrentIndex(0) |
39 | 41 | |
42 |
self.ui.comboBoxProjectUnit.clear() |
|
43 |
self.ui.comboBoxProjectUnit.addItem('Metric') |
|
44 |
self.ui.comboBoxProjectUnit.addItem('Imperial') |
|
45 |
self.ui.comboBoxProjectUnit.setCurrentIndex(0) |
|
46 | ||
40 | 47 |
def showDialog(self): |
41 | 48 |
self.setWindowFlags(self.windowFlags() & ~QtCore.Qt.WindowCloseButtonHint & ~QtCore.Qt.WindowContextHelpButtonHint) |
42 | 49 |
self.exec_() |
43 |
return self.selectedProject |
|
50 | ||
51 |
index = self.ui.comboBox.currentIndex() |
|
52 |
return self.ui.comboBox.itemData(index) |
|
44 | 53 | |
45 | 54 |
def accept(self): |
46 |
self.selectedProject = self.ui.comboBox.currentData() |
|
47 |
AppDocData.instance().updateProjectUpdatedDate(self.selectedProject.getId()) |
|
55 |
""" |
|
56 |
accept project |
|
57 |
""" |
|
58 |
index = self.ui.comboBox.currentIndex() |
|
59 |
project = self.ui.comboBox.itemData(index) |
|
60 |
prj_desc = self.ui.lineEditProjectDesc.text() |
|
61 |
prj_unit = self.ui.comboBoxProjectUnit.currentText() |
|
62 |
if project is not None: |
|
63 |
project.desc = prj_desc |
|
64 |
project.prj_unit = prj_unit |
|
65 |
AppDocData.instance().updateProjectUpdatedDate(project.getId(), desc=prj_desc, prj_unit=prj_unit) |
|
66 | ||
48 | 67 |
QDialog.accept(self) |
49 | 68 | |
50 | 69 |
def reject(self): |
... | ... | |
59 | 78 |
options |= QFileDialog.ShowDirsOnly |
60 | 79 |
selectedDir = QFileDialog.getExistingDirectory(None, _translate('Project Dialog', "Select Project Path"), os.getcwd() , options=options) |
61 | 80 |
if selectedDir: |
62 |
self.insertProjectInfo(selectedDir) |
|
81 |
prj_unit = self.ui.comboBoxProjectUnit.currentText() |
|
82 |
self.insertProjectInfo(dir=selectedDir, desc=self.ui.lineEditProjectDesc.text(), prj_unit=prj_unit) |
|
63 | 83 | |
64 | 84 |
def deleteProjectClick(self): |
65 | 85 |
""" |
... | ... | |
75 | 95 |
if QMessageBox.Ok == msg.exec_(): |
76 | 96 |
AppDocData.instance().removeProjectInfo(self.selectedProject) |
77 | 97 |
self.initComboBox() |
78 |
|
|
79 |
def insertProjectInfo(self, dir): |
|
80 |
AppDocData.instance().insertProjectInfo(dir) |
|
98 |
|
|
99 |
''' |
|
100 |
@brief display project desc and unit when change project |
|
101 |
@author humkyung |
|
102 |
@date 2019.04.09 |
|
103 |
''' |
|
104 |
def changeProject(self): |
|
105 |
index = self.ui.comboBox.currentIndex() |
|
106 |
project = self.ui.comboBox.itemData(index) |
|
107 |
if project is not None: |
|
108 |
self.ui.lineEditProjectDesc.setText(project.desc) |
|
109 |
self.ui.comboBoxProjectUnit.setCurrentText(project.prj_unit) |
|
110 | ||
111 |
def insertProjectInfo(self, desc, prj_unit, dir): |
|
112 |
AppDocData.instance().insertProjectInfo(dir=dir, desc=desc, prj_unit=prj_unit) |
|
81 | 113 |
self.initComboBox() |
82 | 114 |
|
83 | 115 |
#if __name__ == "__init__": |
DTI_PID/DTI_PID/Project_UI.py | ||
---|---|---|
1 | 1 |
# -*- coding: utf-8 -*- |
2 | 2 | |
3 |
# Form implementation generated from reading ui file '.\UI\Project.ui'
|
|
3 |
# Form implementation generated from reading ui file './UI/Project.ui'
|
|
4 | 4 |
# |
5 |
# Created by: PyQt5 UI code generator 5.11.3
|
|
5 |
# Created by: PyQt5 UI code generator 5.12
|
|
6 | 6 |
# |
7 | 7 |
# WARNING! All changes made in this file will be lost! |
8 | 8 | |
9 | 9 |
from PyQt5 import QtCore, QtGui, QtWidgets |
10 | 10 | |
11 | ||
11 | 12 |
class Ui_ProjectDialog(object): |
12 | 13 |
def setupUi(self, ProjectDialog): |
13 | 14 |
ProjectDialog.setObjectName("ProjectDialog") |
14 |
ProjectDialog.resize(650, 79)
|
|
15 |
ProjectDialog.resize(650, 144)
|
|
15 | 16 |
ProjectDialog.setMinimumSize(QtCore.QSize(650, 79)) |
16 |
ProjectDialog.setMaximumSize(QtCore.QSize(650, 79))
|
|
17 |
ProjectDialog.setMaximumSize(QtCore.QSize(650, 200))
|
|
17 | 18 |
font = QtGui.QFont() |
18 | 19 |
font.setFamily("맑은 고딕") |
19 | 20 |
font.setBold(True) |
... | ... | |
58 | 59 |
self.toolButtonDelete.setObjectName("toolButtonDelete") |
59 | 60 |
self.horizontalLayout.addWidget(self.toolButtonDelete) |
60 | 61 |
self.formLayout.setLayout(0, QtWidgets.QFormLayout.FieldRole, self.horizontalLayout) |
62 |
self.label_2 = QtWidgets.QLabel(ProjectDialog) |
|
63 |
font = QtGui.QFont() |
|
64 |
font.setPointSize(10) |
|
65 |
font.setBold(False) |
|
66 |
font.setWeight(50) |
|
67 |
self.label_2.setFont(font) |
|
68 |
self.label_2.setObjectName("label_2") |
|
69 |
self.formLayout.setWidget(1, QtWidgets.QFormLayout.LabelRole, self.label_2) |
|
70 |
self.lineEditProjectDesc = QtWidgets.QLineEdit(ProjectDialog) |
|
71 |
self.lineEditProjectDesc.setObjectName("lineEditProjectDesc") |
|
72 |
self.formLayout.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.lineEditProjectDesc) |
|
73 |
self.label_3 = QtWidgets.QLabel(ProjectDialog) |
|
74 |
font = QtGui.QFont() |
|
75 |
font.setPointSize(10) |
|
76 |
font.setBold(False) |
|
77 |
font.setWeight(50) |
|
78 |
self.label_3.setFont(font) |
|
79 |
self.label_3.setObjectName("label_3") |
|
80 |
self.formLayout.setWidget(2, QtWidgets.QFormLayout.LabelRole, self.label_3) |
|
81 |
self.comboBoxProjectUnit = QtWidgets.QComboBox(ProjectDialog) |
|
82 |
self.comboBoxProjectUnit.setObjectName("comboBoxProjectUnit") |
|
83 |
self.formLayout.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.comboBoxProjectUnit) |
|
61 | 84 |
self.verticalLayout.addLayout(self.formLayout) |
62 | 85 |
self.errorLabel = QtWidgets.QLabel(ProjectDialog) |
63 | 86 |
self.errorLabel.setMaximumSize(QtCore.QSize(16777215, 0)) |
... | ... | |
87 | 110 |
self.label.setText(_translate("ProjectDialog", "Project Name")) |
88 | 111 |
self.toolButton.setText(_translate("ProjectDialog", "+")) |
89 | 112 |
self.toolButtonDelete.setText(_translate("ProjectDialog", "-")) |
113 |
self.label_2.setText(_translate("ProjectDialog", "Project Desc")) |
|
114 |
self.label_3.setText(_translate("ProjectDialog", "Project Unit")) |
|
115 | ||
116 | ||
90 | 117 | |
91 | 118 | |
92 | 119 |
if __name__ == "__main__": |
... | ... | |
97 | 124 |
ui.setupUi(ProjectDialog) |
98 | 125 |
ProjectDialog.show() |
99 | 126 |
sys.exit(app.exec_()) |
100 |
DTI_PID/DTI_PID/Scripts/Project.Projects.sql | ||
---|---|---|
1 | 1 |
CREATE TABLE IF NOT EXISTS `Projects` ( |
2 | 2 |
`Id` INTEGER PRIMARY KEY AUTOINCREMENT, |
3 | 3 |
`Name` TEXT, |
4 |
`Path` TEXT, |
|
4 |
[Desc] TEXT, |
|
5 |
[Unit] TEXT NOT NULL DEFAULT Metric, |
|
6 |
`Path` TEXT NOT NULL, |
|
5 | 7 |
`CreatedDate` TEXT, |
6 | 8 |
`UpdatedDate` TEXT |
7 | 9 |
); |
DTI_PID/DTI_PID/UI/Project.ui | ||
---|---|---|
7 | 7 |
<x>0</x> |
8 | 8 |
<y>0</y> |
9 | 9 |
<width>650</width> |
10 |
<height>79</height>
|
|
10 |
<height>144</height>
|
|
11 | 11 |
</rect> |
12 | 12 |
</property> |
13 | 13 |
<property name="minimumSize"> |
... | ... | |
19 | 19 |
<property name="maximumSize"> |
20 | 20 |
<size> |
21 | 21 |
<width>650</width> |
22 |
<height>79</height>
|
|
22 |
<height>200</height>
|
|
23 | 23 |
</size> |
24 | 24 |
</property> |
25 | 25 |
<property name="font"> |
... | ... | |
92 | 92 |
</item> |
93 | 93 |
</layout> |
94 | 94 |
</item> |
95 |
<item row="1" column="0"> |
|
96 |
<widget class="QLabel" name="label_2"> |
|
97 |
<property name="font"> |
|
98 |
<font> |
|
99 |
<pointsize>10</pointsize> |
|
100 |
<weight>50</weight> |
|
101 |
<bold>false</bold> |
|
102 |
</font> |
|
103 |
</property> |
|
104 |
<property name="text"> |
|
105 |
<string>Project Desc</string> |
|
106 |
</property> |
|
107 |
</widget> |
|
108 |
</item> |
|
109 |
<item row="1" column="1"> |
|
110 |
<widget class="QLineEdit" name="lineEditProjectDesc"/> |
|
111 |
</item> |
|
112 |
<item row="2" column="0"> |
|
113 |
<widget class="QLabel" name="label_3"> |
|
114 |
<property name="font"> |
|
115 |
<font> |
|
116 |
<pointsize>10</pointsize> |
|
117 |
<weight>50</weight> |
|
118 |
<bold>false</bold> |
|
119 |
</font> |
|
120 |
</property> |
|
121 |
<property name="text"> |
|
122 |
<string>Project Unit</string> |
|
123 |
</property> |
|
124 |
</widget> |
|
125 |
</item> |
|
126 |
<item row="2" column="1"> |
|
127 |
<widget class="QComboBox" name="comboBoxProjectUnit"/> |
|
128 |
</item> |
|
95 | 129 |
</layout> |
96 | 130 |
</item> |
97 | 131 |
<item> |
ID2.wxs | ||
---|---|---|
386 | 386 |
<File Id="fil553E9C43172210937CB27F2B88445792" KeyPath="yes" Source=".\dist\App\db\Template.db" /> |
387 | 387 |
<CopyFile Id="MyCopyFile" FileId="fil553E9C43172210937CB27F2B88445792" DestinationDirectory="MyAppDataFolder"/> |
388 | 388 |
</Component> |
389 |
<Component Id="cmpC88C7058DD1B4F9D810AE363E929971D" DestinationDirectory="MyAppDataFolder" Guid="46E937DE-F9FD-4591-8F72-0BA60A024F23"> |
|
390 |
<File Id="fil0549994C50244D83A729C2696B167266" KeyPath="yes" Source=".\dist\App\res\Explode.svg" /> |
|
391 |
</Component> |
|
389 | 392 |
<Component Id="cmp918DC12DD06841688FB3B0066C92660E" Directory="dir2E9D0B9FF47444B6A356DBE9B14DEBFC" Guid="41AAFE8A-E22A-4D62-BD0B-F36A769AE0B8"> |
390 | 393 |
<File Id="fil2D55D34A13384E8B9E5DCEAF26B2F3DC" KeyPath="yes" Source=".\dist\App\translate\ko_kr.qm" /> |
391 | 394 |
</Component> |
내보내기 Unified diff