프로젝트

일반

사용자정보

개정판 e68498f6

IDe68498f6f0f1e5e91f2ca835a32d6ee571620f59
상위 efc41806
하위 cdcde280

함의성이(가) 9달 전에 추가함

add drawing list time sorting

Change-Id: Icff7febdde7074ffbec946ee527e32be2d6f509c

차이점 보기:

DTI_PID/DTI_PID/DrawingTreeWidget.py
37 37
    def __init__(self):
38 38
        QTreeWidget.__init__(self)
39 39

  
40
    def load_drawing_list(self, reverse=False):
40
    def load_drawing_list(self, reverse=False, date=False):
41 41
        """load p&id drawing list"""
42 42
        from Drawing import Drawing
43 43

  
......
51 51
        self.root.setCheckState(0, Qt.Unchecked)
52 52
        files = app_doc_data.getDrawingFileList()
53 53

  
54
        count = 0
54
        drawing_list = []
55

  
55 56
        for file in files if not reverse else reversed(files):
56 57
            x = [drawing for drawing in drawings if drawing.name == file]
57 58
            if not x or not x[0].UID:
......
60 61
            else:
61 62
                drawing = x[0]
62 63

  
63
            item = QTreeWidgetItem(self.root, [file, drawing.datetime])
64
            drawing_list.append(drawing)
65

  
66
        if date:
67
            drawing_list.sort(key=lambda x:int(x.datetime.replace('-', '').replace(':', '').replace(' ', '')) if x.datetime else 0)
68
            if reverse:
69
                drawing_list.reverse()
70

  
71
        for drawing in drawing_list:
72
            item = QTreeWidgetItem(self.root, [drawing.name, drawing.datetime])
64 73
            item.setIcon(0, QIcon(':newPrefix/image.png'))
65 74
            item.setFlags(item.flags() | Qt.ItemIsUserCheckable)
66 75
            item.setCheckState(0, Qt.Unchecked)
67 76
            item.setData(Qt.UserRole, 0, drawing)
68 77

  
69
            count += 1
70

  
71 78
        self.root.setText(0, self.tr('P&ID Drawings') + f"({self.root.childCount()})")
72 79
        self.expandItem(self.root)
73 80
        self.resizeColumnToContents(0)
DTI_PID/DTI_PID/MainWindow.py
664 664
            else:
665 665
                self.load_drawing_list(reverse=True)
666 666
            self.drawing_reverse = not self.drawing_reverse
667
        elif index == 1:
668
            if self.drawing_reverse:
669
                self.load_drawing_list(reverse=False, date=True)
670
            else:
671
                self.load_drawing_list(reverse=True, date=True)
672
            self.drawing_reverse = not self.drawing_reverse
667 673

  
668 674
    def on_line_no_sort_setting(self):
669 675
        from PSNLineNoAttrTargetDialog import PSNLineNoAttrTargetDialog
......
671 677
        dialog = PSNLineNoAttrTargetDialog(self, 'Sort')
672 678
        (isAccept) = dialog.showDialog()        
673 679

  
674
    def load_drawing_list(self, reverse=False):
680
    def load_drawing_list(self, reverse=False, date=False):
675 681
        """load p&id drawing list"""
676 682
        try:
677
            self.treeWidgetDrawingList.load_drawing_list(reverse)
683
            self.treeWidgetDrawingList.load_drawing_list(reverse, date)
678 684
        except Exception as ex:
679 685
            message = f'error occurred({repr(ex)}) in {sys.exc_info()[-1].tb_frame.f_code.co_filename}:' \
680 686
                      f'{sys.exc_info()[-1].tb_lineno}'

내보내기 Unified diff