프로젝트

일반

사용자정보

개정판 366e4ab3

ID366e4ab35f7d4eca2feac77333f7d5f2789265a9
상위 90ed4055
하위 5f913eaa

humkyung 이(가) 6년 이상 전에 추가함

issue #488:
- support multiple note numbers in one text

차이점 보기:

DTI_PID/DTI_PID/AppDocData.py
2543 2543

  
2544 2544
            for item in items:
2545 2545
                sql = item.toSql()
2546
                if sql is not None and 2 == len(sql):
2547
                    cursor.execute(sql[0], sql[1])
2546
                if type(sql) is list:
2547
                    for item in sql:
2548
                        if item is not None and 2 == len(item):
2549
                            cursor.execute(item[0], item[1])
2550
                else:
2551
                    if sql is not None and 2 == len(sql):
2552
                        cursor.execute(sql[0], sql[1])
2548 2553

  
2549 2554
            conn.commit()
2550 2555
        # Catch the exception
DTI_PID/DTI_PID/ItemPropertyTableWidget.py
409 409
        @date       18.04.27
410 410
    '''
411 411
    def initNoteCell(self, noteNoStr, noteContentsList):
412
        import re
413
        result = ''.join(re.findall('\d*', noteNoStr))
414
        
415
        self.setItem(0, 1, QTableWidgetItem(result))
416
        
417 412
        row = self.rowCount()
418
        count = 1
419 413
        self.setRowCount(row + len(noteContentsList))
420
        for index in range(len(noteContentsList)):
421
            item = QTableWidgetItem("노트내용{}".format(count))
422
            item.setFlags(Qt.ItemIsEnabled)
423
            self.setItem(row, 0, item)
424
            self.setItem(row, 1, QTableWidgetItem(noteContentsList[index]))
425
            row = row + 1
426
            count = count + 1
414
        for key in noteContentsList:
415
            for index in range(len(noteContentsList[key])):
416
                item = QTableWidgetItem(key)
417
                item.setFlags(Qt.ItemIsEnabled)
418
                self.setItem(row, 0, item)
419
                self.setItem(row, 1, QTableWidgetItem(noteContentsList[key][index]))
427 420

  
428 421
    '''
429 422
        @brief      Initialize Line No Contents Cell
DTI_PID/DTI_PID/Shapes/EngineeringNoteItem.py
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))

내보내기 Unified diff