34 |
34 |
self.title = None
|
35 |
35 |
self.conetents = None
|
36 |
36 |
|
|
37 |
@property
|
|
38 |
def numbers(self):
|
|
39 |
'''
|
|
40 |
return note numbers which combines of digits
|
|
41 |
'''
|
|
42 |
import re
|
|
43 |
|
|
44 |
return re.findall('\d+', self.text())
|
|
45 |
|
37 |
46 |
'''
|
38 |
47 |
@brief Find Note Contents by NOTE No.
|
39 |
48 |
@author Jeongwoo
|
... | ... | |
44 |
53 |
2018.05.02 Jeongwoo Add if-statement. Append text to list when Regex start position is not 0
|
45 |
54 |
'''
|
46 |
55 |
def findNoteContents(self, noteNoText):
|
|
56 |
res = {}
|
|
57 |
|
47 |
58 |
# Get NoteArea
|
48 |
59 |
notesArea = AppDocData.instance().getArea('Note')
|
49 |
60 |
# Get all note contents
|
50 |
61 |
items = self.scene().items(QRectF(notesArea.x, notesArea.y, notesArea.x + notesArea.width, notesArea.y + notesArea.height))
|
51 |
62 |
items = [item for item in items if type(item) is QEngineeringTextItem] # Filtering QEngineeringTextItem
|
52 |
63 |
items.sort(key=lambda item:item.loc[1]) # Compare with loc[1] (Y-Coord)
|
53 |
|
foundNumberStr = None
|
54 |
|
foundNote = []
|
55 |
|
numberStr = ''
|
56 |
64 |
results = re.findall("\d+", noteNoText)
|
57 |
|
if results is not None and len(results) > 0:
|
58 |
|
numberStr = results[0]
|
59 |
|
for item in items:
|
60 |
|
if type(item) is QEngineeringTextItem:
|
61 |
|
text = item.text()
|
62 |
|
if foundNumberStr is None: # Not found yet
|
63 |
|
try:
|
64 |
|
# Find NOTE Contents start with header [ex - 1. 1) 2. 2) ...]
|
65 |
|
position = re.search(numberStr+"(.|\))", text).start()
|
66 |
|
if position == 0: # Start with NOTE No.
|
67 |
|
foundNote.append(text)
|
68 |
|
foundNumberStr = numberStr
|
69 |
|
except Exception as ex:
|
70 |
|
'''NOT FOUND, DO NOTHING'''
|
71 |
|
else:
|
72 |
|
try:
|
73 |
|
position = re.search("\d+(.|\))", text).start()
|
74 |
|
# If NOTE No starts with any number header, break
|
75 |
|
if position == 0:
|
76 |
|
break
|
77 |
|
else:
|
|
65 |
|
|
66 |
for numberStr in results:
|
|
67 |
foundNumberStr = None
|
|
68 |
foundNote = []
|
|
69 |
for item in items:
|
|
70 |
if type(item) is QEngineeringTextItem:
|
|
71 |
text = item.text()
|
|
72 |
if foundNumberStr is None: # Not found yet
|
|
73 |
try:
|
|
74 |
# Find NOTE Contents start with header [ex - 1. 1) 2. 2) ...]
|
|
75 |
position = re.search(numberStr+"(.|\))", text).start()
|
|
76 |
if position == 0: # Start with NOTE No.
|
|
77 |
foundNote.append(text)
|
|
78 |
foundNumberStr = numberStr
|
|
79 |
except Exception as ex:
|
|
80 |
'''NOT FOUND, DO NOTHING'''
|
|
81 |
else:
|
|
82 |
try:
|
|
83 |
position = re.search("\d+(.|\))", text).start()
|
|
84 |
# If NOTE No starts with any number header, break
|
|
85 |
if position == 0:
|
|
86 |
break
|
|
87 |
else:
|
|
88 |
foundNote.append(text)
|
|
89 |
except Exception as ex:
|
78 |
90 |
foundNote.append(text)
|
79 |
|
except Exception as ex:
|
80 |
|
foundNote.append(text)
|
81 |
|
return foundNote
|
|
91 |
|
|
92 |
res[numberStr] = foundNote
|
|
93 |
|
|
94 |
return res
|
82 |
95 |
|
83 |
96 |
def toSql(self):
|
84 |
97 |
"""
|
85 |
98 |
convert note no data to sql query
|
86 |
99 |
"""
|
87 |
100 |
from AppDocData import AppDocData
|
|
101 |
res = []
|
88 |
102 |
|
89 |
103 |
appDocData = AppDocData.instance()
|
90 |
104 |
|
... | ... | |
92 |
106 |
values = ['?','?', '?', '?']
|
93 |
107 |
|
94 |
108 |
noteContentsList = self.findNoteContents(self.text())
|
95 |
|
param = [str(self.uid), ''.join(re.findall('\d*', self.text())), ' '.join(noteContentsList), appDocData.activeDrawing.name]
|
|
109 |
for key in noteContentsList.keys():
|
|
110 |
param = [str(self.uid), key, ' '.join(noteContentsList[key]), appDocData.activeDrawing.name]
|
|
111 |
sql = 'insert or replace into NOTE_DATA_LIST({}) values({})'.format(','.join(cols), ','.join(values))
|
|
112 |
res.append((sql, tuple(param)))
|
96 |
113 |
|
97 |
|
sql = 'insert or replace into NOTE_DATA_LIST({}) values({})'.format(','.join(cols), ','.join(values))
|
98 |
|
return (sql, tuple(param))
|
|
114 |
return res
|
99 |
115 |
|
100 |
116 |
'''
|
101 |
117 |
@brief return note Data List
|
... | ... | |
106 |
122 |
|
107 |
123 |
dataList = []
|
108 |
124 |
try:
|
|
125 |
import re
|
109 |
126 |
from AppDocData import AppDocData
|
110 |
127 |
|
111 |
128 |
global noteColumnList
|
... | ... | |
115 |
132 |
noteContentsList = self.findNoteContents(self.text())
|
116 |
133 |
|
117 |
134 |
loopIndex = 1
|
118 |
|
for noteDescription in noteContentsList:
|
119 |
|
data = []
|
120 |
|
for index in range(len(noteColumnList)):
|
121 |
|
data.append('')
|
122 |
|
|
123 |
|
data[0] = str(self.uid) + "-" + str(loopIndex)
|
124 |
|
import re
|
125 |
|
data[1] = ''.join(re.findall('\d*', self.text()))
|
126 |
|
data[2] = noteDescription
|
127 |
|
data[3] = docData.imgName
|
128 |
|
|
129 |
|
dataList.append(data)
|
|
135 |
for key in noteContentsList.keys():
|
|
136 |
for noteDescription in noteContentsList[key]:
|
|
137 |
data = []
|
|
138 |
for index in range(len(noteColumnList)):
|
|
139 |
data.append('')
|
|
140 |
|
|
141 |
data[0] = str(self.uid) + "-" + str(loopIndex)
|
|
142 |
data[1] = key
|
|
143 |
data[2] = noteDescription
|
|
144 |
data[3] = docData.imgName
|
|
145 |
|
|
146 |
dataList.append(data)
|
130 |
147 |
|
131 |
148 |
except Exception as ex:
|
132 |
149 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
|