Ejemplo n.º 1
0
 def focusInEvent(self, event):
     Tree.focusInEvent(self, event)
     node = self.GetSelectedNode()
     if node and isinstance(node, ProjectNode):
         appdata.active_document = node.doc
     else:
         appdata.active_document = None
Ejemplo n.º 2
0
 def focusInEvent(self, event):
     Tree.focusInEvent(self, event)
     node = self.GetSelectedNode()
     if node and isinstance(node, ProjectNode):
         appdata.active_document = node.doc
     else:
         appdata.active_document = None
Ejemplo n.º 3
0
 def dragMoveEvent(self, event):
     Tree.dragMoveEvent(self, event)
     if not event.isAccepted():
         mimeData = event.mimeData()
         data = self.decodeMime(mimeData)
         if data and 'paths' in data:
             event.acceptProposedAction()
Ejemplo n.º 4
0
 def dragMoveEvent(self, event):
     Tree.dragMoveEvent(self, event)
     if not event.isAccepted():
         mimeData = event.mimeData()
         data = self.decodeMime(mimeData)
         if data and "paths" in data:
             event.acceptProposedAction()
Ejemplo n.º 5
0
 def dropEvent(self, event):
     Tree.dropEvent(self, event)
     if not event.isAccepted():
         mimeData = event.mimeData()
         data = self.decodeMime(mimeData)
         if data and 'paths' in data:
             self.OpenPaths(data['paths'], self.root)
             event.accept()
Ejemplo n.º 6
0
 def dropEvent(self, event):
     Tree.dropEvent(self, event)
     if not event.isAccepted():
         mimeData = event.mimeData()
         data = self.decodeMime(mimeData)
         if data and "paths" in data:
             self.OpenPaths(data["paths"], self.root)
             event.accept()
Ejemplo n.º 7
0
 def decodeMime(self, mimeData):
     if mimeData.hasUrls():
         paths = [
             os.path.normpath(url.toLocalFile()) for url in mimeData.urls()
         ]
         return {'paths': paths}
     return Tree.decodeMime(self, mimeData)
Ejemplo n.º 8
0
 def __init__(self, parent):
     Tree.__init__(self, parent)
     self.setMouseTracking(True)
     appdata.project = self
     self.closing = False
     self.update_requested = False
     self.root = ProjectRootNode(self)
     self.ResetProject()
     self.root.Expand()
     self.setItemDelegate(ProjectTreeDelegate(self))
     self.projectfile = None
     self.header().setStretchLastSection(False)
     self.header().setResizeMode(QHeaderView.ResizeToContents)
     self.horizontalScrollBar().valueChanged.connect(lambda value: self.viewport().repaint())
     self.addActions(framework.menu.MakeActions("workbench.contextmenu.project_actions", self))
     self.changed = False
     self.projectdata = self.CurrentProjectData()
     self.autosavedata = None
     self.docs = []
     # keep model
     self.model = self.model()
Ejemplo n.º 9
0
 def __init__(self, parent):
     Tree.__init__(self, parent)
     self.setMouseTracking(True)
     appdata.project = self
     self.closing = False
     self.update_requested = False
     self.root = ProjectRootNode(self)
     self.ResetProject()
     self.root.Expand()
     self.setItemDelegate(ProjectTreeDelegate(self))
     self.projectfile = None
     self.header().setStretchLastSection(False)
     self.header().setResizeMode(QHeaderView.ResizeToContents)
     self.horizontalScrollBar().valueChanged.connect(
         lambda value: self.viewport().repaint())
     self.addActions(
         framework.menu.MakeActions('workbench.contextmenu.project_actions',
                                    self))
     self.changed = False
     self.projectdata = self.CurrentProjectData()
     self.autosavedata = None
     self.docs = []
     # keep model
     self.model = self.model()
Ejemplo n.º 10
0
    def __init__(self, parent):
        View.__init__(self, parent)
        self.UpdateLabel(self.GetLabel())

        widget = QWidget(self)

        layout = QVBoxLayout(widget)

        self.wnd_tree = Tree(widget)
        if not self.bound_uri:
            self.wnd_filter = SearchBox(widget, self.wnd_tree,
                                        self.msg_filterdesc, self.Filter,
                                        self.Search, self.msg_filteroptions,
                                        self.msg_filtermulti)
            layout.addWidget(self.wnd_filter)

        self.setFocusProxy(self.wnd_tree)
        self.wnd_tree.view = self
        layout.addWidget(self.wnd_tree)
        layout.setContentsMargins(0, 5, 0, 0)

        self.destroyed.connect(self.OnDestroy)
        self.setWidget(widget)
        self.Seed()
Ejemplo n.º 11
0
    def __init__(self, parent):
        View.__init__(self, parent)
        self.UpdateLabel(self.GetLabel())

        widget = QWidget(self)

        layout = QVBoxLayout(widget)

        self.wnd_tree = Tree(widget)
        if not self.bound_uri:
            self.wnd_filter = SearchBox(widget, self.wnd_tree, self.msg_filterdesc, self.Filter, self.Search, self.msg_filteroptions, self.msg_filtermulti)
            layout.addWidget(self.wnd_filter)

        self.setFocusProxy(self.wnd_tree)
        self.wnd_tree.view = self
        layout.addWidget(self.wnd_tree)
        layout.setContentsMargins(0,5,0,0)

        self.destroyed.connect(self.OnDestroy)
        self.setWidget(widget)
        self.Seed()
Ejemplo n.º 12
0
class FilteredView(View):

    msg_filterdesc  = tm.main.filter
    document        = None
    bound_uri       = None
    msg_filteroptions = None
    msg_filtermulti = False

    @property
    def selected(self):
        return self.wnd_tree.selected

    def FindViewMethod(self, methodname):
        if not self.wnd_tree.hasFocus() and not appdata.topwindow.menuBar().hasFocus():
            return

        if getattr(self, methodname, None):
            return getattr(self, methodname)

        v = self.selected
        if not v:
            return

        return util.findcommonmethod(v, methodname)

    def __init__(self, parent):
        View.__init__(self, parent)
        self.UpdateLabel(self.GetLabel())

        widget = QWidget(self)

        layout = QVBoxLayout(widget)

        self.wnd_tree = Tree(widget)
        if not self.bound_uri:
            self.wnd_filter = SearchBox(widget, self.wnd_tree, self.msg_filterdesc, self.Filter, self.Search, self.msg_filteroptions, self.msg_filtermulti)
            layout.addWidget(self.wnd_filter)

        self.setFocusProxy(self.wnd_tree)
        self.wnd_tree.view = self
        layout.addWidget(self.wnd_tree)
        layout.setContentsMargins(0,5,0,0)

        self.destroyed.connect(self.OnDestroy)
        self.setWidget(widget)
        self.Seed()

    def GetIcon(self):
        if not self.bound_uri and self.document != None:
            return self.document.GetIcon()
        if getattr(self, 'vis_icon', None) != None:
            return self.vis_icon
        else:
            return 'blank_ico'

    def GetLabel(self):
        if getattr(self, 'vis_label', None) != None:
            return self.vis_label
        elif self.document:
            return self.document.GetLabel()
        else:
            return tm.main.view

    def UpdateLabel(self, label):
        self.SetTitle(label)

    def OnDestroy(self):
        self.wnd_tree.clear()
        appdata.views.discard(self)

    # override

    def Seed(self):
        pass

    def Filter(self, value):
        pass

    def Search(self, value):
        pass

    def CanCopyText(self):
        if self.wnd_tree.selected:
            return True
        return False

    def CopyText(self):
        selected = self.wnd_tree.selected_sorted
        lines    = []
        for v in selected:
            line = ''
            p = v.parent
            indent  = 0
            while p:
                indent += 1
                p = p.parent
            line += v.text(0)
            lines.append((indent, line))

        if lines:
            min_indent = sorted(lines)[0][0]
            text = '\n'.join(['\t'*(i-min_indent)+l for i, l in lines])
        else:
            text = ''
        util.SetClipboard(text, None)
Ejemplo n.º 13
0
 def dragLeaveEvent(self, event):
     Tree.dragLeaveEvent(self, event)
     if not event.isAccepted():
         evt.accept()
Ejemplo n.º 14
0
class FilteredView(View):

    msg_filterdesc = tm.main.filter
    document = None
    bound_uri = None
    msg_filteroptions = None
    msg_filtermulti = False

    @property
    def selected(self):
        return self.wnd_tree.selected

    def FindViewMethod(self, methodname):
        if not self.wnd_tree.hasFocus() and not appdata.topwindow.menuBar(
        ).hasFocus():
            return

        if getattr(self, methodname, None):
            return getattr(self, methodname)

        v = self.selected
        if not v:
            return

        return util.findcommonmethod(v, methodname)

    def __init__(self, parent):
        View.__init__(self, parent)
        self.UpdateLabel(self.GetLabel())

        widget = QWidget(self)

        layout = QVBoxLayout(widget)

        self.wnd_tree = Tree(widget)
        if not self.bound_uri:
            self.wnd_filter = SearchBox(widget, self.wnd_tree,
                                        self.msg_filterdesc, self.Filter,
                                        self.Search, self.msg_filteroptions,
                                        self.msg_filtermulti)
            layout.addWidget(self.wnd_filter)

        self.setFocusProxy(self.wnd_tree)
        self.wnd_tree.view = self
        layout.addWidget(self.wnd_tree)
        layout.setContentsMargins(0, 5, 0, 0)

        self.destroyed.connect(self.OnDestroy)
        self.setWidget(widget)
        self.Seed()

    def GetIcon(self):
        if not self.bound_uri and self.document != None:
            return self.document.GetIcon()
        if getattr(self, 'vis_icon', None) != None:
            return self.vis_icon
        else:
            return 'blank_ico'

    def GetLabel(self):
        if getattr(self, 'vis_label', None) != None:
            return self.vis_label
        elif self.document:
            return self.document.GetLabel()
        else:
            return tm.main.view

    def UpdateLabel(self, label):
        self.SetTitle(label)

    def OnDestroy(self):
        self.wnd_tree.clear()
        appdata.views.discard(self)

    # override

    def Seed(self):
        pass

    def Filter(self, value):
        pass

    def Search(self, value):
        pass

    def CanCopyText(self):
        if self.wnd_tree.selected:
            return True
        return False

    def CopyText(self):
        selected = self.wnd_tree.selected_sorted
        lines = []
        for v in selected:
            line = ''
            p = v.parent
            indent = 0
            while p:
                indent += 1
                p = p.parent
            line += v.text(0)
            lines.append((indent, line))

        if lines:
            min_indent = sorted(lines)[0][0]
            text = '\n'.join(['\t' * (i - min_indent) + l for i, l in lines])
        else:
            text = ''
        util.SetClipboard(text, None)
Ejemplo n.º 15
0
 def dragLeaveEvent(self, event):
     Tree.dragLeaveEvent(self, event)
     if not event.isAccepted():
         evt.accept()
Ejemplo n.º 16
0
 def decodeMime(self, mimeData):
     if mimeData.hasUrls():
         paths = [os.path.normpath(url.toLocalFile()) for url in mimeData.urls()]
         return {"paths": paths}
     return Tree.decodeMime(self, mimeData)