Beispiel #1
0
    def __init__(self, parent=None, flags=QtCore.Qt.WindowFlags(0), **kwargs):
        super(ItemModelMainWindow, self).__init__(parent, flags, **kwargs)

        #: main application datamodel (QStandardItemModel)
        self.datamodel = QtGui.QStandardItemModel(self)

        # @TODO: custom treeview with "currentChanged" slot re-implemented
        #: tree view for the main application data model
        self.treeview = QtWidgets.QTreeView()
        # @TODO
        #self.treeview.setSelectionMode(QtWidgets.QTreeView.SingleSelection)
        self.treeview.setModel(self.datamodel)
        self.treeview.setEditTriggers(
            QtWidgets.QAbstractItemView.NoEditTriggers)
        self.treeview.header().hide()

        self.treeview.clicked.connect(self.setActiveWinFromIndex)
        self.mdiarea.subWindowActivated.connect(self.setActiveIndexFromWin)
        self.datamodel.rowsAboutToBeRemoved.connect(self.onItemsClosed)

        # setup the treeview dock
        treeviewdock = QtWidgets.QDockWidget(self.tr('Data Browser'), self)
        treeviewdock.setWidget(self.treeview)
        treeviewdock.setObjectName('TreeViewPanel')
        self.addDockWidget(QtCore.Qt.LeftDockWidgetArea, treeviewdock)
Beispiel #2
0
    def __init__(self, parent=None, flags=QtCore.Qt.WindowFlags(0)):
        QtWidgets.QMainWindow.__init__(self, parent, flags)
        self.statusBar().show()

        self.model = QtGui.QStandardItemModel(self)
        self.model.setColumnCount(2)

        self.treeview = QtWidgets.QTreeView()
        self.treeview.setModel(self.model)
        self.treeview.setHeaderHidden(True)
        self.treeview.setIndentation(0)
        self.treeview.setSelectionMode(
            QtWidgets.QAbstractItemView.ExtendedSelection)
        self.treeview.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
        self.treeview.header().setStretchLastSection(True)

        self.treedock = QtWidgets.QDockWidget(self.tr('Layers View'), self)
        self.treedock.setWidget(self.treeview)
        self.addDockWidget(QtCore.Qt.LeftDockWidgetArea, self.treedock)

        self.scene = QtWidgets.QGraphicsScene(self)
        self.graphicsview = QtWidgets.QGraphicsView(self.scene, self)
        self.setCentralWidget(self.graphicsview)

        self.mousemanager = MouseManager(self)
        self.mousemanager.register(self.graphicsview)
        self.mousemanager.mode = 'hand'

        self.layermanager = LayerManager(self.treeview, self)

        # File Actions
        self.fileactions = self._setupFileActions()

        menu = QtWidgets.QMenu('File', self)
        menu.addActions(self.fileactions.actions())
        self.menuBar().addMenu(menu)
        self._filemenu = menu

        toolbar = QtWidgets.QToolBar('File toolbar', self)
        toolbar.addActions(self.fileactions.actions())
        self.addToolBar(toolbar)

        # Mouse Actions
        menu = QtWidgets.QMenu('Mouse', self)
        menu.addActions(self.mousemanager.actions.actions())
        self.menuBar().addMenu(menu)

        toolbar = QtWidgets.QToolBar('Mouse toolbar')
        toolbar.addActions(self.mousemanager.actions.actions())
        self.addToolBar(toolbar)

        # View Actions
        self.viewactions = self._setupViewActions()

        menu = QtWidgets.QMenu('View', self)
        menu.addActions(self.viewactions.actions())
        self.menuBar().addMenu(menu)

        toolbar = QtWidgets.QToolBar('View toolbar')
        toolbar.addActions(self.viewactions.actions())
        self.addToolBar(toolbar)

        # Layer Actions
        layeractions = self.layermanager.actions

        menu = QtWidgets.QMenu('Layer', self)
        menu.addActions(layeractions.actions())
        self.menuBar().addMenu(menu)

        toolbar = QtWidgets.QToolBar('Layer toolbar')
        toolbar.addActions(layeractions.actions())
        self.addToolBar(toolbar)

        # Help action
        self.helpactions = self._setupHelpActions()

        menu = QtWidgets.QMenu('Help', self)
        menu.addActions(self.helpactions.actions())
        self.menuBar().addMenu(menu)

        toolbar = QtWidgets.QToolBar('Help toolbar', self)
        toolbar.addActions(self.helpactions.actions())
        self.addToolBar(toolbar)

        self.resize(900, 500)
        self.reset()
        self.statusBar().showMessage('Ready')