프로젝트

일반

사용자정보

개정판 e85bb909

IDe85bb909a29c1e53dfe073f720eac3cba2c53b3d
상위 a5da7d72
하위 8df40630

김정우 이(가) 약 7년 전에 추가함

TreeWidget Context Menu 세팅 - Display, Delete symbol 구현 필요

차이점 보기:

DTI_PID/DTI_PID/QDirTreeWidget.py
24 24
        self.isDoubleClicked = False
25 25
        self.itemDoubleClicked.connect(self.itemDoubleClickEvent)
26 26
        self.itemClicked.connect(self.itemClickEvent)
27
        self.setContextMenuPolicy(Qt.CustomContextMenu)
28
        self.customContextMenuRequested.connect(self.openContextMenu)
29

  
30
    def openContextMenu(self, position):
31
        indexes = self.selectedIndexes()
32
        itemPosition = self.mapTo(self, position)
33
        item = self.itemAt(itemPosition)
34
        text = item.text(0)
35
        if len(indexes) > 0:
36
            level = 0
37
            index = indexes[0]
38
            while index.parent().isValid():
39
                index = index.parent()
40
                level += 1
41
        if text.lower().endswith(".png"):
42
            menu = QMenu()
43
            editSymbolAction = QAction(self.tr("Edit Symbol"))
44
            editSymbolAction.triggered.connect(lambda: self.editSymbolActionClickEvent(item, 0))
45
            menu.addAction(editSymbolAction)
46
            displaySymbolAction = QAction(self.tr("Display Symbol"))
47
            displaySymbolAction.triggered.connect(lambda: self.displaySymbolActionClickEvent())
48
            menu.addAction(displaySymbolAction)
49
            deleteSymbolAction = QAction(self.tr("Delete Symbol"))
50
            deleteSymbolAction.triggered.connect(lambda: self.deleteSymbolActionClickEvent())
51
            menu.addAction(deleteSymbolAction)
52
            menu.exec_(self.viewport().mapToGlobal(position))
53

  
54
    def editSymbolActionClickEvent(self, item, columNo):
55
        self.showSymbolEditorDialog(item, columNo)
56

  
57
    def displaySymbolActionClickEvent(self):
58
        print("display symbol")
59

  
60
    def deleteSymbolActionClickEvent(self):
61
        print("delete symbol")
27 62

  
28 63
    def initDirTreeWidget(self):
29 64
        project = AppDocData.instance().getCurrentProject()
......
52 87
            if os.path.isdir(pathInfo):
53 88
                self.loadDirectoryInfo(pathInfo, parentItem)
54 89

  
55
    def itemDoubleClickEvent(self, item, columnNo):
56
        self.isDoubleClicked = True
57
        itemName = item.text(columnNo)
58
        print(itemName + " : Double Clicked")
90
    def showSymbolEditorDialog(self, item, columnNo):
59 91
        sym = self.getSymbolByItemName(item, columnNo)
60 92
        if sym is not None:
61 93
            image = QImage(sym.getPath(), "PNG")
......
63 95
            symbolEditorDialog = QSymbolEditorDialog.QSymbolEditorDialog(self, image, AppDocData.instance().getCurrentProject(), sym)
64 96
            _ret = symbolEditorDialog.showDialog()
65 97
            self.initDirTreeWidget()
98

  
99
    def itemDoubleClickEvent(self, item, columnNo):
100
        self.isDoubleClicked = True
101
        itemName = item.text(columnNo)
102
        print(itemName + " : Double Clicked")
103
        self.showSymbolEditorDialog(item, columnNo)
66 104
        self.isDoubleClicked = False
67 105

  
68 106
    def itemClickEvent(self, item, columnNo):

내보내기 Unified diff

클립보드 이미지 추가 (최대 크기: 500 MB)