개정판 8f614711
issue #000 Project Unit 제거
Change-Id: I667c0d82a97cf3f407685436cf7b5d55a168f21c
HYTOS/HYTOS/AppDocData.py | ||
---|---|---|
1014 | 1014 |
@date 2018.04.06 |
1015 | 1015 |
@history humkyung 2018.04.19 use getPrjDatabasePath function instead of PROJECT_DB_PATH variable |
1016 | 1016 |
''' |
1017 |
def insertProjectInfo(self, desc, prj_unit, dir):
|
|
1017 |
def insertProjectInfo(self, desc, dir): |
|
1018 | 1018 |
try: |
1019 | 1019 |
prjDatabaseFilePath = self.getPrjDatabasePath() |
1020 | 1020 |
conn = sqlite3.connect(prjDatabaseFilePath) |
1021 | 1021 |
folderName = dir.split('/')[-1] |
1022 | 1022 |
if folderName: |
1023 | 1023 |
nowDate = datetime.datetime.now().strftime('%Y.%m.%d %H:%M') |
1024 |
sql = "insert or replace into Projects(Name, [Desc], [Unit], Path, CreatedDate, UpdatedDate) values(?, ?, ?, ?, ?, ?)"
|
|
1025 |
param = (folderName, desc, prj_unit, dir, nowDate, nowDate)
|
|
1024 |
sql = "insert or replace into Projects(Name, [Desc], Path, CreatedDate, UpdatedDate) values(?, ?, ?, ?, ?)"
|
|
1025 |
param = (folderName, desc, dir, nowDate, nowDate) |
|
1026 | 1026 |
|
1027 | 1027 |
cursor = conn.cursor() |
1028 | 1028 |
cursor.execute(sql, param) |
... | ... | |
1062 | 1062 |
@date 2018.04.06 |
1063 | 1063 |
@history humkyung 2018.04.19 use getPrjDatabasePath function instead of PROJECT_DB_PATH variable |
1064 | 1064 |
''' |
1065 |
def updateProjectUpdatedDate(self, id, desc, prj_unit):
|
|
1065 |
def updateProjectUpdatedDate(self, id, desc): |
|
1066 | 1066 |
try: |
1067 | 1067 |
prjDatabaseFilePath = self.getPrjDatabasePath() |
1068 | 1068 |
conn = sqlite3.connect(prjDatabaseFilePath) |
1069 | 1069 |
nowDate = datetime.datetime.now().strftime('%Y.%m.%d %H:%M') |
1070 | 1070 |
sql = ''' |
1071 | 1071 |
UPDATE Projects |
1072 |
SET UpdatedDate = ?,[Desc]=?,[Unit]=?
|
|
1072 |
SET UpdatedDate = ?,[Desc]=? |
|
1073 | 1073 |
WHERE Id = ? |
1074 | 1074 |
''' |
1075 | 1075 |
cur = conn.cursor() |
1076 |
cur.execute(sql, (nowDate, desc, prj_unit, id))
|
|
1076 |
cur.execute(sql, (nowDate, desc, id)) |
|
1077 | 1077 |
conn.commit() |
1078 | 1078 |
except Exception as ex: |
1079 | 1079 |
# Roll back any change if something goes wrong |
... | ... | |
1094 | 1094 |
try: |
1095 | 1095 |
conn = sqlite3.connect(self.getPrjDatabasePath()) |
1096 | 1096 |
cursor = conn.cursor() |
1097 |
sql = 'SELECT id,name,[desc],[unit],path,createddate,updateddate FROM Projects ORDER BY UpdatedDate DESC'
|
|
1097 |
sql = 'SELECT id,name,[desc],path,createddate,updateddate FROM Projects ORDER BY UpdatedDate DESC' |
|
1098 | 1098 |
try: |
1099 | 1099 |
cursor.execute(sql) |
1100 | 1100 |
rows = cursor.fetchall() |
1101 | 1101 |
for row in rows: |
1102 |
if os.path.isdir(row[4]): # check if folder exists
|
|
1103 |
projectList.append(Project(row[0], row[1], desc=row[2], prj_unit=row[3], path=row[4], createDate=row[5], updateDate=row[6]))
|
|
1102 |
if os.path.isdir(row[3]): # check if folder exists
|
|
1103 |
projectList.append(Project(row[0], row[1], desc=row[2], path=row[3], createDate=row[4], updateDate=row[5]))
|
|
1104 | 1104 |
except Exception as ex: |
1105 | 1105 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
1106 | 1106 |
finally: |
HYTOS/HYTOS/Project.py | ||
---|---|---|
3 | 3 |
import os |
4 | 4 |
|
5 | 5 |
class Project(): |
6 |
def __init__(self, id, name, desc, prj_unit, path, createDate, updateDate):
|
|
6 |
def __init__(self, id, name, desc, path, createDate, updateDate): |
|
7 | 7 |
self.id = id |
8 | 8 |
self.name = name |
9 | 9 |
self._desc = desc |
10 |
self._prj_unit = prj_unit |
|
11 | 10 |
self.path = path |
12 | 11 |
self.createDate = createDate |
13 | 12 |
self.updateDate = updateDate |
... | ... | |
35 | 34 |
""" |
36 | 35 |
self._desc = value |
37 | 36 |
|
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 |
|
|
49 | 37 |
def setPath(self, path): |
50 | 38 |
self.path = path |
51 | 39 |
|
HYTOS/HYTOS/ProjectDialog.py | ||
---|---|---|
39 | 39 |
|
40 | 40 |
if projectList: self.ui.comboBox.setCurrentIndex(0) |
41 | 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 |
|
|
47 | 42 |
def showDialog(self): |
48 | 43 |
self.setWindowFlags(self.windowFlags() & ~QtCore.Qt.WindowCloseButtonHint & ~QtCore.Qt.WindowContextHelpButtonHint) |
49 | 44 |
self.exec_() |
... | ... | |
61 | 56 |
index = self.ui.comboBox.currentIndex() |
62 | 57 |
project = self.ui.comboBox.itemData(index) |
63 | 58 |
prj_desc = self.ui.lineEditProjectDesc.text() |
64 |
prj_unit = self.ui.comboBoxProjectUnit.currentText() |
|
65 | 59 |
if project is not None: |
66 |
project.desc = prj_desc |
|
67 |
project.prj_unit = prj_unit |
|
68 |
AppDocData.instance().updateProjectUpdatedDate(project.getId(), desc=prj_desc, prj_unit=prj_unit) |
|
60 |
project.desc = prj_desc |
|
61 |
AppDocData.instance().updateProjectUpdatedDate(project.getId(), desc=prj_desc) |
|
69 | 62 |
self.selectedProject = True |
70 | 63 |
|
71 | 64 |
QDialog.accept(self) |
... | ... | |
82 | 75 |
options |= QFileDialog.ShowDirsOnly |
83 | 76 |
selectedDir = QFileDialog.getExistingDirectory(None, _translate('Project Dialog', "Select Project Path"), os.getcwd() , options=options) |
84 | 77 |
if selectedDir: |
85 |
prj_unit = self.ui.comboBoxProjectUnit.currentText() |
|
86 |
self.insertProjectInfo(dir=selectedDir, desc=self.ui.lineEditProjectDesc.text(), prj_unit=prj_unit) |
|
78 |
self.insertProjectInfo(dir=selectedDir, desc=self.ui.lineEditProjectDesc.text()) |
|
87 | 79 |
|
88 | 80 |
def deleteProjectClick(self): |
89 | 81 |
""" |
... | ... | |
110 | 102 |
project = self.ui.comboBox.itemData(index) |
111 | 103 |
if project is not None: |
112 | 104 |
self.ui.lineEditProjectDesc.setText(project.desc) |
113 |
self.ui.comboBoxProjectUnit.setCurrentText(project.prj_unit) |
|
114 | 105 |
|
115 |
def insertProjectInfo(self, desc, prj_unit, dir):
|
|
116 |
AppDocData.instance().insertProjectInfo(dir=dir, desc=desc, prj_unit=prj_unit)
|
|
106 |
def insertProjectInfo(self, desc, dir): |
|
107 |
AppDocData.instance().insertProjectInfo(dir=dir, desc=desc) |
|
117 | 108 |
self.initComboBox() |
118 | 109 |
|
119 | 110 |
#if __name__ == "__init__": |
HYTOS/HYTOS/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.12
|
|
5 |
# Created by: PyQt5 UI code generator 5.11.3
|
|
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 |
|
|
12 | 11 |
class Ui_ProjectDialog(object): |
13 | 12 |
def setupUi(self, ProjectDialog): |
14 | 13 |
ProjectDialog.setObjectName("ProjectDialog") |
15 |
ProjectDialog.resize(650, 144)
|
|
16 |
ProjectDialog.setMinimumSize(QtCore.QSize(650, 79))
|
|
14 |
ProjectDialog.resize(450, 107)
|
|
15 |
ProjectDialog.setMinimumSize(QtCore.QSize(450, 79))
|
|
17 | 16 |
ProjectDialog.setMaximumSize(QtCore.QSize(650, 200)) |
18 | 17 |
font = QtGui.QFont() |
19 | 18 |
font.setFamily("맑은 고딕") |
... | ... | |
70 | 69 |
self.lineEditProjectDesc = QtWidgets.QLineEdit(ProjectDialog) |
71 | 70 |
self.lineEditProjectDesc.setObjectName("lineEditProjectDesc") |
72 | 71 |
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) |
|
84 | 72 |
self.verticalLayout.addLayout(self.formLayout) |
85 | 73 |
self.errorLabel = QtWidgets.QLabel(ProjectDialog) |
86 | 74 |
self.errorLabel.setMaximumSize(QtCore.QSize(16777215, 0)) |
... | ... | |
111 | 99 |
self.toolButton.setText(_translate("ProjectDialog", "+")) |
112 | 100 |
self.toolButtonDelete.setText(_translate("ProjectDialog", "-")) |
113 | 101 |
self.label_2.setText(_translate("ProjectDialog", "Project Desc")) |
114 |
self.label_3.setText(_translate("ProjectDialog", "Project Unit")) |
|
115 |
|
|
116 |
|
|
117 |
|
|
118 | 102 |
|
119 |
if __name__ == "__main__": |
|
120 |
import sys |
|
121 |
app = QtWidgets.QApplication(sys.argv) |
|
122 |
ProjectDialog = QtWidgets.QDialog() |
|
123 |
ui = Ui_ProjectDialog() |
|
124 |
ui.setupUi(ProjectDialog) |
|
125 |
ProjectDialog.show() |
|
126 |
sys.exit(app.exec_()) |
HYTOS/HYTOS/Scripts/Project.Projects.sql | ||
---|---|---|
1 | 1 |
CREATE TABLE IF NOT EXISTS `Projects` ( |
2 | 2 |
`Id` INTEGER PRIMARY KEY AUTOINCREMENT, |
3 | 3 |
`Name` TEXT UNIQUE, |
4 |
[Desc] TEXT, |
|
5 |
[Unit] TEXT NOT NULL DEFAULT Metric, |
|
4 |
[Desc] TEXT, |
|
6 | 5 |
`Path` TEXT NOT NULL, |
7 | 6 |
`CreatedDate` TEXT, |
8 | 7 |
`UpdatedDate` TEXT |
HYTOS/HYTOS/UI/Project.ui | ||
---|---|---|
6 | 6 |
<rect> |
7 | 7 |
<x>0</x> |
8 | 8 |
<y>0</y> |
9 |
<width>650</width>
|
|
10 |
<height>144</height>
|
|
9 |
<width>450</width>
|
|
10 |
<height>107</height>
|
|
11 | 11 |
</rect> |
12 | 12 |
</property> |
13 | 13 |
<property name="minimumSize"> |
14 | 14 |
<size> |
15 |
<width>650</width>
|
|
15 |
<width>450</width>
|
|
16 | 16 |
<height>79</height> |
17 | 17 |
</size> |
18 | 18 |
</property> |
... | ... | |
109 | 109 |
<item row="1" column="1"> |
110 | 110 |
<widget class="QLineEdit" name="lineEditProjectDesc"/> |
111 | 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> |
|
129 | 112 |
</layout> |
130 | 113 |
</item> |
131 | 114 |
<item> |
내보내기 Unified diff