def mouseDoubleClickEvent(self, mouseEvent):
        """
        Reimplemented to disable expanding/collapsing of items when
        double-clicking. Instead the double-clicked entry is opened.
        """

        index = self.indexAt(mouseEvent.pos())
        if not index.isValid():
            return

        item = self.model().item(index)
        if item.itemType in [
            GlobalsItemType,
            ImportsItemType,
            FunctionsItemType,
            ClassesItemType,
            StaticAttributesItemType,
            InstanceAttributesItemType,
            DirectoryItemType,
            SysPathItemType,
        ]:
            QTreeView.mouseDoubleClickEvent(self, mouseEvent)
        else:
            self.openItem(item)
        return
Beispiel #2
0
    def __init__(self, parent=None):
        super().__init__(parent)

        self.train_data = None
        self.test_data = None

        #: An Ordered dictionary with current inputs and their testing
        #: results.
        self.learners = OrderedDict()

        sbox = gui.widgetBox(self.controlArea, "Sampling")
        rbox = gui.radioButtons(
            sbox, self, "resampling", callback=self._param_changed
        )
        gui.appendRadioButton(rbox, "Cross validation")
        ibox = gui.indentedBox(rbox)
        gui.spin(ibox, self, "k_folds", 2, 50, label="Number of folds:",
                 callback=self.kfold_changed)
        gui.appendRadioButton(rbox, "Leave one out")
        gui.appendRadioButton(rbox, "Random sampling")
        ibox = gui.indentedBox(rbox)
        gui.spin(ibox, self, "n_repeat", 2, 50, label="Repeat train/test",
                 callback=self.bootstrap_changed)
        gui.widgetLabel(ibox, "Relative training set size:")
        gui.hSlider(ibox, self, "sample_p", minValue=1, maxValue=100,
                    ticks=20, vertical=False, labelFormat="%d %%",
                    callback=self.bootstrap_changed)

        gui.appendRadioButton(rbox, "Test on train data")
        gui.appendRadioButton(rbox, "Test on test data")

        rbox.layout().addSpacing(5)
        gui.button(rbox, self, "Apply", callback=self.apply)

        self.cbox = gui.widgetBox(self.controlArea, "Target class")
        self.class_selection_combo = gui.comboBox(self.cbox, self, "class_selection",
             items=[],
             callback=self._select_class,
             sendSelectedValue=True, valueType=str)

        gui.rubber(self.controlArea)


        self.view = QTreeView(
            rootIsDecorated=False,
            uniformRowHeights=True,
            wordWrap=True,
            editTriggers=QTreeView.NoEditTriggers
        )
        header = self.view.header()
        header.setResizeMode(QHeaderView.ResizeToContents)
        header.setDefaultAlignment(Qt.AlignCenter)
        header.setStretchLastSection(False)

        self.result_model = QStandardItemModel()
        self.view.setModel(self.result_model)
        self.view.setItemDelegate(ItemDelegate())
        self._update_header()
        box = gui.widgetBox(self.mainArea, "Evaluation Results")
        box.layout().addWidget(self.view)
    def mousePressEvent(self, position):
        QTreeView.mousePressEvent(self, position)
        indexes = self.selectedIndexes()

        # trace the tree to find the selected item
        rows = []
        for index in indexes:
            row = index.row()
            rows.append(row)
            level = 0
            while index.parent().isValid():
                index = index.parent()
                row = index.row()
                rows.append(row)
                level += 1
        rows.reverse()

        # TODO: what is this for???
        if rows != self.old_rows:
            self.old_rows = rows
        valid, keys = self.get_row()
        if not valid:
            print('invalid=%s keys=%s' % (valid, keys))
        else:
            print('valid=%s keys=%s' % (valid, keys))
Beispiel #4
0
    def __init__( self, parent = None ):
        QTreeView.__init__( self, parent )

        self.__parentDialog = parent
        self.__model = FindFileModel()
        self.__sortModel = FindFileSortFilterProxyModel()
        self.__sortModel.setDynamicSortFilter( True )
        self.__sortModel.setSourceModel( self.__model )
        self.setModel( self.__sortModel )
        self.selectedIndex = None

        self.activated.connect( self.openCurrentItem )

        self.setRootIsDecorated( False )
        self.setAlternatingRowColors( True )
        self.setUniformRowHeights( True )
        self.setItemDelegate( NoOutlineHeightDelegate( 4 ) )

        header = self.header()
        header.setSortIndicator( 0, Qt.AscendingOrder )
        header.setSortIndicatorShown( True )
        header.setClickable( True )

        self.setSortingEnabled( True )

        self.setSelectionMode( QAbstractItemView.SingleSelection )
        self.setSelectionBehavior( QAbstractItemView.SelectRows )

        self.layoutDisplay()
        return
Beispiel #5
0
    def __init__(self, sourceModel, isProjectFilter, parent=None):
        QTreeView.__init__(self, parent)

        self.__model = sourceModel
        self.__sortModel = FilesBrowserSortFilterProxyModel(isProjectFilter)
        self.__sortModel.setSourceModel(self.__model)
        self.setModel(self.__sortModel)

        self.activated.connect(self.openSelectedItem)
        self.expanded.connect(self._resizeColumns)
        self.collapsed.connect(self._resizeColumns)

        self.setRootIsDecorated(True)
        self.setAlternatingRowColors(True)
        self.setUniformRowHeights(True)
        self.setItemDelegate(NoOutlineHeightDelegate(4))

        header = self.header()
        header.setSortIndicator(0, Qt.AscendingOrder)
        header.setSortIndicatorShown(True)
        header.setClickable(True)

        self.setSortingEnabled(True)

        self.setSelectionMode(QAbstractItemView.SingleSelection)
        self.setSelectionBehavior(QAbstractItemView.SelectRows)

        self.header().setStretchLastSection(True)
        self.layoutDisplay()

        self.__debugMode = False
        return
Beispiel #6
0
    def __init__(self, parent=None):
        QTreeView.__init__(self, parent)

        self.__parentDialog = parent
        self.__model = FindFileModel()
        self.__sortModel = FindFileSortFilterProxyModel()
        self.__sortModel.setDynamicSortFilter(True)
        self.__sortModel.setSourceModel(self.__model)
        self.setModel(self.__sortModel)
        self.selectedIndex = None

        self.activated.connect(self.openCurrentItem)

        self.setRootIsDecorated(False)
        self.setAlternatingRowColors(True)
        self.setUniformRowHeights(True)
        self.setItemDelegate(NoOutlineHeightDelegate(4))

        header = self.header()
        header.setSortIndicator(0, Qt.AscendingOrder)
        header.setSortIndicatorShown(True)
        header.setClickable(True)

        self.setSortingEnabled(True)

        self.setSelectionMode(QAbstractItemView.SingleSelection)
        self.setSelectionBehavior(QAbstractItemView.SelectRows)

        self.layoutDisplay()
        return
Beispiel #7
0
    def __init__ ( self, editor ):

        QTreeView.__init__( self )

        self._editor = editor
        self.connect( self, SIGNAL( 'doubleClicked(QModelIndex)' ),
                      editor._on_dclick )
    def eventFilter(self, widget, event):
        if widget is self.viewport():
            if QEvent is None:
                return QTreeView.eventFilter(self, widget, event)
            elif event.type() == QEvent.MouseMove:
                index = self.indexAt(event.pos())
                if not index.isValid():
                    index = None
            elif event.type() == QEvent.Leave:
                index = None
                self.hoverExitAll.emit()
            else:
                index = self._last_hovered_item

            if index != self._last_hovered_item:
                if self._last_hovered_item is not None:
                    try:
                        # self.hoverExitIndex.emit(self._last_hovered_item)
                        self.hover_exit(self._last_hovered_item)
                    except IndexError:
                        log.warning("Hover row index %s out of range",
                                    self._last_hovered_item)

                if index is not None:
                    try:
                        self.hover_enter(index)
                        # self.hoverEnterIndex.emit(index)
                    except IndexError:
                        log.warning("Hover row index %s out of range",
                                    index.row()),
                self._last_hovered_item = index

        return QTreeView.eventFilter(self, widget, event)
Beispiel #9
0
    def __init__(self, projects, parent=None):
        super(AddToProject, self).__init__(parent)
        #pathProjects must be a list
        self._projects = projects
        self.setWindowTitle(translations.TR_ADD_FILE_TO_PROJECT)
        self.pathSelected = ''
        vbox = QVBoxLayout(self)

        hbox = QHBoxLayout()
        self._list = QListWidget()
        for project in self._projects:
            self._list.addItem(project.name)
        self._list.setCurrentRow(0)
        self._tree = QTreeView()
        #self._tree.header().setHidden(True)
        self._tree.setSelectionMode(QTreeView.SingleSelection)
        self._tree.setAnimated(True)
        self.load_tree(self._projects[0])
        hbox.addWidget(self._list)
        hbox.addWidget(self._tree)
        vbox.addLayout(hbox)

        hbox2 = QHBoxLayout()
        btnAdd = QPushButton(translations.TR_ADD_HERE)
        btnCancel = QPushButton(translations.TR_CANCEL)
        hbox2.addWidget(btnCancel)
        hbox2.addWidget(btnAdd)
        vbox.addLayout(hbox2)

        self.connect(btnCancel, SIGNAL("clicked()"), self.close)
        self.connect(btnAdd, SIGNAL("clicked()"), self._select_path)
        self.connect(
            self._list,
            SIGNAL("currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)"),
            self._project_changed)
Beispiel #10
0
	def initUi(self):

		vbox = QtGui.QVBoxLayout()

		vline = QtGui.QHBoxLayout()
		vline.setSpacing(2)
		btnTickAll = QtGui.QPushButton(u"全部记录Tick", self)
		btnBarAll = QtGui.QPushButton(u'全部记录Bar', self)
		btnSaveAll = QtGui.QPushButton(u'保存设置(重启后生效)', self)
		btnTickAll.clicked.connect(self.selectAllTick)
		btnBarAll.clicked.connect(self.selectAllBar)
		btnSaveAll.clicked.connect(self.saveSetting)

		vline.addWidget(btnTickAll)
		vline.addWidget(btnBarAll)
		vline.addWidget(btnSaveAll)

		vbox.addLayout(vline)

		self.qTreeView = QTreeView()
		self.model = TreeModel()
		self.qTreeView.setModel(self.model)
		self.qTreeView.setSelectionMode(QtGui.QAbstractItemView.NoSelection)
		self.qTreeView.setItemDelegateForColumn(1, CheckBoxDelegate(self))
		self.qTreeView.setItemDelegateForColumn(2, CheckBoxDelegate(self))
		self.qTreeView.setItemDelegateForColumn(3, CheckBoxDelegate(self))
		self.qTreeView.setItemDelegateForColumn(5, ComboDelegate(self, ["CTP", "LTS", "XTP", "FEMAS", "XSPEED", "QDP",
		                                                                "KSOTP", "KSGOLD", "SGIT"]))

		vbox.addWidget(self.qTreeView)
		self.setLayout(vbox)
Beispiel #11
0
    def _createUi(self):
        self.setWindowTitle(core.project().path() or 'Locator')

        self.setLayout(QVBoxLayout())
        self.layout().setContentsMargins(0, 0, 0, 0)
        self.layout().setSpacing(1)

        biggerFont = self.font()
        biggerFont.setPointSizeF(biggerFont.pointSizeF() * 2)
        self.setFont(biggerFont)

        self._edit = _CompletableLineEdit(self)
        self._edit.updateCurrentCommand.connect(self._updateCurrentCommand)
        self._edit.enterPressed.connect(self._onEnterPressed)
        self._edit.installEventFilter(self)  # catch Up, Down
        self.layout().addWidget(self._edit)
        self.setFocusProxy(self._edit)

        self._table = QTreeView(self)
        self._table.setFont(biggerFont)
        self._model = _CompleterModel()
        self._table.setModel(self._model)
        self._table.setItemDelegate(HTMLDelegate(self._table))
        self._table.setRootIsDecorated(False)
        self._table.setHeaderHidden(True)
        self._table.clicked.connect(self._onItemClicked)
        self._table.setAlternatingRowColors(True)
        self._table.installEventFilter(
            self)  # catch focus and give to the edit
        self.layout().addWidget(self._table)

        width = QFontMetrics(self.font()).width('x' *
                                                64)  # width of 64 'x' letters
        self.resize(width, width * 0.62)
Beispiel #12
0
    def __init__(self, mainWindow):
        QTreeView.__init__(self, mainWindow)
        self.mainWindow = mainWindow

        self.setModel(DBModel(self))
        self.setHeaderHidden(True)
        self.setEditTriggers(QTreeView.EditKeyPressed
                             | QTreeView.SelectedClicked)

        self.setDragEnabled(True)
        self.setAcceptDrops(True)
        self.setDropIndicatorShown(True)

        self.connect(
            self.selectionModel(),
            SIGNAL("currentChanged(const QModelIndex&, const QModelIndex&)"),
            self.currentItemChanged)
        self.connect(self, SIGNAL("expanded(const QModelIndex&)"),
                     self.itemChanged)
        self.connect(self, SIGNAL("collapsed(const QModelIndex&)"),
                     self.itemChanged)
        self.connect(
            self.model(),
            SIGNAL("dataChanged(const QModelIndex&, const QModelIndex&)"),
            self.modelDataChanged)
        self.connect(self.model(), SIGNAL("notPopulated"), self.collapse)
Beispiel #13
0
    def mousePressEvent(self, position):
        QTreeView.mousePressEvent(self, position)
        indexes = self.selectedIndexes()

        # trace the tree to find the selected item
        rows = []
        for index in indexes:
            row = index.row()
            rows.append(row)
            level = 0
            while index.parent().isValid():
                index = index.parent()
                row = index.row()
                rows.append(row)
                level += 1
        rows.reverse()

        # TODO: what is this for???
        if rows != self.old_rows:
            self.old_rows = rows
        valid, keys = self.get_row()
        if not valid:
            print('invalid=%s keys=%s' % (valid, keys))
        else:
            print('valid=%s keys=%s' % (valid, keys))
    def __init__(self, sourceModel, isProjectFilter, parent=None):
        QTreeView.__init__(self, parent)

        self.__model = sourceModel
        self.__sortModel = FilesBrowserSortFilterProxyModel(isProjectFilter)
        self.__sortModel.setSourceModel(self.__model)
        self.setModel(self.__sortModel)

        self.activated.connect(self.openSelectedItem)
        self.expanded.connect(self._resizeColumns)
        self.collapsed.connect(self._resizeColumns)

        self.setRootIsDecorated(True)
        self.setAlternatingRowColors(True)
        self.setUniformRowHeights(True)
        self.setItemDelegate(NoOutlineHeightDelegate(4))

        header = self.header()
        header.setSortIndicator(0, Qt.AscendingOrder)
        header.setSortIndicatorShown(True)
        header.setClickable(True)

        self.setSortingEnabled(True)

        self.setSelectionMode(QAbstractItemView.SingleSelection)
        self.setSelectionBehavior(QAbstractItemView.SelectRows)

        self.header().setStretchLastSection(True)
        self.layoutDisplay()

        self.__debugMode = False
        return
Beispiel #15
0
 def selectionChanged(self, selected, deselected):
     items = [
         self.model().itemFromIndex(index)
         for index in self.selectionModel().selectedIndexes()
     ]
     self.selectedItemsChanged.emit(items)
     QTreeView.selectionChanged(self, selected, deselected)
Beispiel #16
0
    def __init__(self, parent):
        QTreeView.__init__(self, parent)
        while not isinstance(parent, QDialog) and not isinstance(parent, QMainWindow):
            parent = parent.parent()
        self.setObjectName("TreeView" + str(len(parent.findChildren(TreeView))))

        # self.setObjectName("TreeViewWidget")
        # self.hLayout = QHBoxLayout(self)
        # self.hLayout.setObjectName("hLayout")
        # 
        # sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
        # sizePolicy.setHorizontalStretch(0)
        # sizePolicy.setVerticalStretch(0)
        # sizePolicy.setHeightForWidth(self.sizePolicy().hasHeightForWidth())
        # self.setSizePolicy(sizePolicy)
        # 
        # # self.frame = Frame()
        # self = QTreeView(self)
        # self.hLayout.addWidget(self)

        self.stdModel = QStandardItemModel()
        self.setModel(self.stdModel)

        self.hasObject = False
        self.treeNodeList = []

        self.checkBoxList = []
        self.setHeaderHidden(True)
    def on_copy(self):
        self.ds_model.sort(DSManagerModel.COLUMN_GROUP_DS)

        select_data_sources_dialog = QDialog(self)
        select_data_sources_dialog.setWindowTitle(self.tr("Choose source service"))
        layout = QVBoxLayout(select_data_sources_dialog)
        select_data_sources_dialog.setLayout(layout)

        list_view = QTreeView(self)
        layout.addWidget(list_view)
        list_view.setModel(self.ds_model)
        list_view.setColumnHidden(DSManagerModel.COLUMN_VISIBILITY, True)
        list_view.setAlternatingRowColors(True)
        list_view.header().setResizeMode(DSManagerModel.COLUMN_GROUP_DS, QHeaderView.ResizeToContents)
        list_view.clicked.connect(
            lambda index: select_data_sources_dialog.accept()
            if not self.ds_model.isGroup(index) and index.column() == DSManagerModel.COLUMN_GROUP_DS
            else None
        )

        if select_data_sources_dialog.exec_() == QDialog.Accepted:
            data_source = self.ds_model.data(list_view.currentIndex(), Qt.UserRole)
            data_source.id += "_copy"
            edit_dialog = DsEditDialog()
            edit_dialog.setWindowTitle(self.tr("Create service from existing"))
            edit_dialog.fill_ds_info(data_source)
            if edit_dialog.exec_() == QDialog.Accepted:
                self.feel_list()
                self.ds_model.resetModel()
	def __init__(self, parent = None):
		QDockWidget.__init__(self, "File System Tree View", parent)
		self.setObjectName("FileNavigatorDock")

		self.fsm = QFileSystemModel(self)
		tv = QTreeView(self)
		tv.showColumn(1)
		self.fsm.setRootPath(self.parent().workdir)
		tv.setModel(self.fsm)

		self.setAllowedAreas( self.left | self.right )
		self.setGeometry(0,0,400,1000)

		pb = QPushButton("...",self)
		pb.clicked.connect(self.changeWorkdir)
		self.le = QLineEdit(self)
		self.le.setText(self.parent().workdir)

		dockbox = QWidget(self)
		hl = QHBoxLayout(dockbox)
		hl.addWidget(self.le)
		hl.addWidget(pb)
		hll=QWidget(self)
		hll.setLayout(hl)
		vl = QVBoxLayout(dockbox)
		dockbox.setLayout(vl)
		vl.addWidget(hll)
		vl.addWidget(tv)
		self.setWidget(dockbox)

		self.adjustSize()

		self.parent().say("Vista del sistema de ficheros creada")
Beispiel #19
0
 def __init__(self, _=None, parent=None):
     QTreeView.__init__(self, parent)
     self.setAlternatingRowColors(True)
     self.setVerticalScrollMode(QAbstractItemView.ScrollPerPixel)
     self.controller = None
     self.header().setResizeMode(QHeaderView.ResizeToContents)
     self.setDragEnabled(True)
    def __init__(self, template, character, parent=None):
        super(SubPowerWidget, self).__init__(parent)

        self.__storage = template
        self.__character = character

        self.__model = QStandardItemModel()
        # Das ungenutzte Model dient dazu, alle Unterkräfte aufzunehmen, die ich nicht darstellen möchte. Ist einfacher, als diese im View zu verstecken.
        self.__modelUnused = QStandardItemModel()

        self._layout = QVBoxLayout()
        self.setLayout(self._layout)

        self.__view = QTreeView()
        self.__view.setHeaderHidden(True)
        self.__view.setModel(self.__model)

        self._layout.addWidget(self.__view)

        self._typ = "Subpower"
        categories = self.__storage.categories(self._typ)

        self.__items = {}

        self.__rootItem = QStandardItem()
        self.__rootItem = self.__model.invisibleRootItem()

        self.__rootItemUnused = QStandardItem()
        self.__rootItemUnused = self.__modelUnused.invisibleRootItem()

        for item in categories:
            categoryItem = QStandardItem(item)
            self.__rootItem.appendRow(categoryItem)

            ## Ich benötige diese Items auch im ungenutzten Model.
            categoryItemUnused = QStandardItem(item)
            self.__rootItemUnused.appendRow(categoryItemUnused)

            traitList = list(self.__character.traits[self._typ][item].items())
            traitList.sort()
            for trait in traitList:
                traitItem = QStandardItem(trait[1].name)
                traitItem.setCheckable(True)
                ## Unhashable Type
                self.__items[trait[1]] = traitItem
                categoryItem.appendRow(traitItem)

                ## Funktioniert mit PySide nicht:
                #trait[1].availableChanged.connect(traitItem.setEnabled)
                ## Funktioniert auch mit PySide:
                trait[1].availableChanged.connect(
                    lambda enable, item=traitItem: item.setEnabled(enable))
                trait[1].valueChanged.connect(lambda val, trait=trait[
                    1], item=traitItem: self.__setItemValue(trait, item))

        self.__model.itemChanged.connect(self.__getItemValue)
        self.__character.speciesChanged.connect(self.hideOrShowToolPage)
        self.__character.breedChanged.connect(self.hideOrShowToolPage)
        self.__character.factionChanged.connect(self.hideOrShowToolPage)
Beispiel #21
0
 def selectionChanged(self, selected, deselected):
     " The slot is called when the selection has changed "
     if selected.indexes():
         self.emit(SIGNAL('selectionChanged'), selected.indexes()[0])
     else:
         self.emit(SIGNAL('selectionChanged'), None)
     QTreeView.selectionChanged(self, selected, deselected)
     return
Beispiel #22
0
 def selectionChanged(self, selected, deselected):
     " Slot is called when the selection has been changed "
     if selected.indexes():
         self.selectedIndex = selected.indexes()[0]
     else:
         self.selectedIndex = None
     QTreeView.selectionChanged(self, selected, deselected)
     return
Beispiel #23
0
 def mousePressEvent(self, e):
     try:
         index = self.indexAt(e.pos())
         if index.isValid():
             self.model().selectKey(index)
     except:
         pass
     QTreeView.mousePressEvent(self, e)
Beispiel #24
0
def experiment_qt():
    """Template for functions that test Qt GUI components."""
    print "Start"
    app = QApplication(sys.argv)
    view = QTreeView()
    view.show()
    app.exec_()
    print "End"
Beispiel #25
0
 def mousePressEvent(self, e):
   try:
     index = self.indexAt(e.pos())
     if index.isValid():
       self.model().selectKey(index)
   except:
     pass
   QTreeView.mousePressEvent(self, e)
Beispiel #26
0
 def contextMenuEvent(self, event):
     QTreeView.contextMenuEvent(self, event)
     var = self.selectionModel().currentIndex().internalPointer()
     if not event.isAccepted() and var is not None:
         menu = self.prepareContextMenu()
         self.contextMenuOpen.emit(True)
         menu.exec_(event.globalPos())
         self.contextMenuOpen.emit(False)
Beispiel #27
0
 def selectionChanged( self, selected, deselected ):
     " Slot is called when the selection has been changed "
     if selected.indexes():
         self.selectedIndex = selected.indexes()[ 0 ]
     else:
         self.selectedIndex = None
     QTreeView.selectionChanged( self, selected, deselected )
     return
Beispiel #28
0
    def __init__(self, parent):
        super(ScorePartsWidget, self).__init__(parent)

        self.typesLabel = QLabel()
        self.typesView = QTreeView(selectionMode=QTreeView.ExtendedSelection,
                                   selectionBehavior=QTreeView.SelectRows,
                                   animated=True,
                                   headerHidden=True)
        self.scoreLabel = QLabel()
        self.scoreView = widgets.treewidget.TreeWidget(
            selectionMode=QTreeView.ExtendedSelection,
            selectionBehavior=QTreeView.SelectRows,
            headerHidden=True,
            animated=True,
            dragDropMode=QTreeView.InternalMove)
        self.addButton = QPushButton(icon=icons.get("list-add"))
        self.removeButton = QPushButton(icon=icons.get("list-remove"))
        self.upButton = QToolButton(icon=icons.get("go-up"))
        self.downButton = QToolButton(icon=icons.get("go-down"))
        self.partSettings = QStackedWidget()

        w = QWidget()
        self.addWidget(w)
        layout = QVBoxLayout(spacing=0)
        w.setLayout(layout)

        layout.addWidget(self.typesLabel)
        layout.addWidget(self.typesView)
        layout.addWidget(self.addButton)

        w = QWidget()
        self.addWidget(w)
        layout = QVBoxLayout(spacing=0)
        w.setLayout(layout)

        layout.addWidget(self.scoreLabel)
        layout.addWidget(self.scoreView)

        box = QHBoxLayout(spacing=0)
        layout.addLayout(box)

        box.addWidget(self.removeButton)
        box.addWidget(self.upButton)
        box.addWidget(self.downButton)

        self.addWidget(self.partSettings)

        self.typesView.setModel(parts.model())
        app.translateUI(self)

        # signal connections
        self.addButton.clicked.connect(self.slotAddButtonClicked)
        self.removeButton.clicked.connect(self.slotRemoveButtonClicked)
        self.typesView.doubleClicked.connect(self.slotDoubleClicked)
        self.scoreView.currentItemChanged.connect(self.slotCurrentItemChanged)
        self.upButton.clicked.connect(self.scoreView.moveSelectedChildrenUp)
        self.downButton.clicked.connect(
            self.scoreView.moveSelectedChildrenDown)
Beispiel #29
0
	def keyPressEvent(self, event):
		if event.key() == Qt.Key_Return and int(event.modifiers()) == (QtCore.Qt.ShiftModifier):
			children = self.getChildren()
			self.addSongs.emit(children, False)
		elif event.key() == Qt.Key_Return:
			children = self.getChildren()
			self.addSongs.emit(children, True)
		else:
			QTreeView.keyPressEvent(self, event)
    def __init__(self, parent_widget):
        '''
        Tree view for displaying data in a XmlModel
        @param parent_widget (QWidget): Parent widget
        '''
        QTreeView.__init__(self, parent_widget)

        self.setAnimated(True)
        self.setMinimumHeight(200)
Beispiel #31
0
    def __init__(self, parent_widget):
        '''
        Tree view for displaying data in a XmlModel
        @param parent_widget (QWidget): Parent widget
        '''
        QTreeView.__init__(self, parent_widget)

        self.setAnimated(True)
        self.setMinimumHeight(200)
Beispiel #32
0
 def contextMenuEvent(self, event):
     QTreeView.contextMenuEvent(self, event)
     if not event.isAccepted():
         selectionModel = self.selectionModel()
         wrapper = selectionModel.currentIndex().internalPointer()
         if isinstance(wrapper, TreeStdVarWrapper):
             menu = QMenu()
             filters.add_actions_for_all_filters(menu.addMenu("Set Filter for %s..." % wrapper.getExp()), wrapper)
             menu.exec_(event.globalPos())
Beispiel #33
0
    def currentChanged ( self, curr, prev ):
        """ Reimplemented to tell the editor when the current index has
            changed.
        """
        QTreeView.currentChanged( self, curr, prev )

        self._editor.update_object( curr )

#-- EOF ------------------------------------------------------------------------
Beispiel #34
0
class DataListToTreeWidget(DataPusherWidget):
    '''
    DataPusherWidget widget for track layout
    '''
    def __init__(self, parent=None):
        super(DataListToTreeWidget, self).__init__(parent)
        self.rightTreeView = None
        self.leftDataTypeListView = None
        self.setupRightPane()

    def setupLeftPane(self):
        self.leftDataTypeListView = QListView()
        self.leftScrollArea.setWidgetResizable(True)
        self.leftVerticalLayout.addWidget(self.leftDataTypeListView)
        self.leftDataTypeListView.setSelectionMode(
            QAbstractItemView.ExtendedSelection)

    def setupRightPane(self):
        self.rightTreeView = QTreeView()
        self.rightScrollArea.setWidgetResizable(True)
        self.rightVerticalLayout.addWidget(self.rightTreeView)
        self.rightTreeView.setSelectionMode(QAbstractItemView.SingleSelection)

    def connectSlots(self):
        self.rightArrowPushButton.clicked.connect(self.rightArrowClicked)
        self.upPushButton.clicked.connect(self.upClicked)
        self.downPushButton.clicked.connect(self.downClicked)
        self.deletePushButton.clicked.connect(self.deleteClicked)

    def rightArrowClicked(self):
        logger.debug("rightArrowClicked")
        model = self.logTypeListView.model()
        trackList = []
        if model is not None:
            for row in range(model.rowCount()):
                item = model.item(row)
                if item.checkState() == Qt.Checked:
                    trackList.append(item.text())
            self.populateRightListView(trackList)

        #see https://wiki.python.org/moin/PyQt/Reading%20selections%20from%20a%20selection%20model
    def upClicked(self):
        logger.debug("upClicked")

        promoteList = []
        indexes = self.trackListView.selectionModel().selectedIndexes()
        model = self.trackListView.model()
        parent = QModelIndex()
        #selectedItems = self.trackListView.selectionModel().selectedItems()
        for index in indexes:
            #item = model.index(index.row(), index.column(), parent)
            item = self.getComboBoxItemFromIndex(model, index)
            #promoteList.append(item)
            promoteList.append(str(item.data()))
            logger.debug("data: {0}".format(item.data()))
        promotedList = self.resortRightList(promoteList)
        self.populateTrackListView(promotedList)
Beispiel #35
0
 def selectionChanged( self, selected, deselected ):
     " The slot is called when the selection has changed "
     if selected.indexes():
         self.emit( SIGNAL( 'selectionChanged' ),
                    selected.indexes()[ 0 ] )
     else:
         self.emit( SIGNAL( 'selectionChanged' ), None )
     QTreeView.selectionChanged( self, selected, deselected )
     return
Beispiel #36
0
    def _setup_gui_labels(self):
        vlayout = QVBoxLayout()
        vlayout.setContentsMargins(0, 0, 0, 0)
        vlayout.setSpacing(1)

        self.labels_edit = QTreeView()
        self.labels_edit.setEditTriggers(QTreeView.CurrentChanged)
        self.labels_edit.setRootIsDecorated(False)

        self.labels_model = DictItemsModel()
        self.labels_edit.setModel(self.labels_model)

        self.labels_edit.selectionModel().selectionChanged.connect(
            self.on_label_selection_changed)

        # Necessary signals to know when the labels change
        self.labels_model.dataChanged.connect(self.on_labels_changed)
        self.labels_model.rowsInserted.connect(self.on_labels_changed)
        self.labels_model.rowsRemoved.connect(self.on_labels_changed)

        vlayout.addWidget(self.labels_edit)
        hlayout = QHBoxLayout()
        hlayout.setContentsMargins(0, 0, 0, 0)
        hlayout.setSpacing(1)
        self.add_label_action = QAction("+",
                                        self,
                                        toolTip="Add a new label.",
                                        triggered=self.on_add_label,
                                        enabled=False,
                                        shortcut=QKeySequence(
                                            QKeySequence.New))

        self.remove_label_action = QAction(unicodedata.lookup("MINUS SIGN"),
                                           self,
                                           toolTip="Remove selected label.",
                                           triggered=self.on_remove_label,
                                           enabled=False,
                                           shortcut=QKeySequence(
                                               QKeySequence.Delete))

        button_size = gui.toolButtonSizeHint()
        button_size = QSize(button_size, button_size)

        button = QToolButton(self)
        button.setFixedSize(button_size)
        button.setDefaultAction(self.add_label_action)
        hlayout.addWidget(button)

        button = QToolButton(self)
        button.setFixedSize(button_size)
        button.setDefaultAction(self.remove_label_action)
        hlayout.addWidget(button)
        hlayout.addStretch(10)
        vlayout.addLayout(hlayout)

        self.main_form.addRow("Labels", vlayout)
Beispiel #37
0
 def keyPressEvent(self, event):
     """Reimplement Qt method"""
     if event.key() in (Qt.Key_Enter, Qt.Key_Return):
         self.clicked()
     elif event.key() == Qt.Key_F2:
         self.rename()
     elif event.key() == Qt.Key_Delete:
         self.delete()
     else:
         QTreeView.keyPressEvent(self, event)
Beispiel #38
0
    def selectionChanged(self, selected, deselected):
        " Triggered when the selection changed "

        QTreeView.selectionChanged(self, selected, deselected)
        indexesList = selected.indexes()
        if indexesList:
            self.emit(SIGNAL('firstSelectedItem'), indexesList[0])
        else:
            self.emit(SIGNAL('firstSelectedItem'), None)
        return
Beispiel #39
0
    def __init__(self, parent=None, **kwargs):
        QTreeView.__init__(self, parent, **kwargs)
        self.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Expanding)

        self.__model = QStandardItemModel()
        self.__flattened = False
        self.__actionRole = Qt.UserRole
        self.__view = None

        self.__setupUi()
Beispiel #40
0
 def keyPressEvent(self, event):
     """Reimplement Qt method"""
     if event.key() in (Qt.Key_Enter, Qt.Key_Return):
         self.clicked()
     elif event.key() == Qt.Key_F2:
         self.rename()
     elif event.key() == Qt.Key_Delete:
         self.delete()
     else:
         QTreeView.keyPressEvent(self, event)
Beispiel #41
0
 def selectionChanged( self, selected, deselected ):
     " Slot is called when the selection has been changed "
     if selected.indexes():
         # The objects browsers may have no more than one selected item
         self.emit( SIGNAL( "selectionChanged" ),
                    selected.indexes()[ 0 ] )
     else:
         self.emit( SIGNAL( "selectionChanged" ), None )
     QTreeView.selectionChanged( self, selected, deselected )
     return
Beispiel #42
0
    def currentChanged(self, current, previous):
        QTreeView.currentChanged(self.directoryTree, current, previous)
        currentIndex = self.directoryTree.selectionModel().currentIndex()
        path = str(self.directoryTree.model().filePath(currentIndex))

        if self.directoryTree.model().isDir(currentIndex):
            self.directorySelectedSignal.emit(path)
        else:
            self.directorySelectedSignal.emit(os.path.dirname(path))
            self.fileSelectedSignal.emit(path)
    def selectionChanged(self, selected, deselected):
        " Triggered when the selection changed "

        QTreeView.selectionChanged(self, selected, deselected)
        indexesList = selected.indexes()
        if indexesList:
            self.emit(SIGNAL("firstSelectedItem"), indexesList[0])
        else:
            self.emit(SIGNAL("firstSelectedItem"), None)
        return
Beispiel #44
0
 def keyPressEvent(self, event):
     if event.key() == Qt.Key_Return and int(
             event.modifiers()) == (QtCore.Qt.ShiftModifier):
         children = self.getChildren()
         self.addSongs.emit(children, False)
     elif event.key() == Qt.Key_Return:
         children = self.getChildren()
         self.addSongs.emit(children, True)
     else:
         QTreeView.keyPressEvent(self, event)
Beispiel #45
0
 def currentChanged(self, current, previous):
     QTreeView.currentChanged(self.directoryTree, current, previous)
     currentIndex = self.directoryTree.selectionModel().currentIndex()
     path = str ( self.directoryTree.model().filePath(currentIndex) )
     
     if self.directoryTree.model().isDir(currentIndex):
         self.directorySelectedSignal.emit(path)
     else:
         self.directorySelectedSignal.emit(os.path.dirname(path))
         self.fileSelectedSignal.emit(path)
Beispiel #46
0
    def __init__(self, finders, iface, parent=None):
        self.iface = iface
        self.mapCanvas = iface.mapCanvas()
        self.rubber = QgsRubberBand(self.mapCanvas)
        self.rubber.setColor(QColor(255, 255, 50, 200))
        self.rubber.setIcon(self.rubber.ICON_CIRCLE)
        self.rubber.setIconSize(15)
        self.rubber.setWidth(4)
        self.rubber.setBrushStyle(Qt.NoBrush)

        QComboBox.__init__(self, parent)
        self.setEditable(True)
        self.setInsertPolicy(QComboBox.InsertAtTop)
        self.setMinimumHeight(27)
        self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)

        self.insertSeparator(0)
        self.lineEdit().returnPressed.connect(self.search)

        self.resultView = QTreeView()
        self.resultView.setHeaderHidden(True)
        self.resultView.setMinimumHeight(300)
        self.resultView.activated.connect(self.itemActivated)
        self.resultView.pressed.connect(self.itemPressed)
        self.setView(self.resultView)

        self.resultModel = ResultModel(self)
        self.setModel(self.resultModel)

        self.finders = finders
        for finder in self.finders.values():
            finder.resultFound.connect(self.resultFound)
            finder.limitReached.connect(self.limitReached)
            finder.finished.connect(self.finished)

        self.clearButton = QPushButton(self)
        self.clearButton.setIcon(
            QIcon(":/plugins/quickfinder/icons/draft.svg"))
        self.clearButton.setText('')
        self.clearButton.setFlat(True)
        self.clearButton.setCursor(QCursor(Qt.ArrowCursor))
        self.clearButton.setStyleSheet('border: 0px; padding: 0px;')
        self.clearButton.clicked.connect(self.clear)

        layout = QHBoxLayout(self)
        self.setLayout(layout)
        layout.addStretch()
        layout.addWidget(self.clearButton)
        layout.addSpacing(20)

        buttonSize = self.clearButton.sizeHint()
        # frameWidth = self.lineEdit().style().pixelMetric(QtGui.QStyle.PM_DefaultFrameWidth)
        padding = buttonSize.width()  # + frameWidth + 1
        self.lineEdit().setStyleSheet('QLineEdit {padding-right: %dpx; }' %
                                      padding)
Beispiel #47
0
    def createWidget(self):
        """
        Create qt widget
        """
        
        self.screenResolutionLabel = QLabel(self)
        self.screenTapLabel = QLabel(self)
        
        
        mobileLayout = QVBoxLayout()
        
        self.mobileDockToolbar = QToolBar(self)
        self.mobileDockToolbar.setStyleSheet("QToolBar { border: 0px }");
        self.mobileDockToolbar.setToolButtonStyle(Qt.ToolButtonTextUnderIcon)

        self.mobileImageLabel = QLabel(self)
        self.mobileImageLabel.setMouseTracking(True)
        self.mobileImageLabel.installEventFilter(self)
        self.mobileImageLabel.setScaledContents(True)
        self.mobileImageLabel.mousePressEvent = self.pixelSelect

        self.refreshCheckbox = QCheckBox("Automatic Refresh", self)
        self.refreshCheckbox.setEnabled(False)
        self.refreshCheckbox.stateChanged.connect(self.onRefreshChanged)
        
        self.clickCheckbox = QCheckBox("Enable Tap", self)
        self.clickCheckbox.setEnabled(False)

        self.model = DomModel(QDomDocument(), self)
        self.mobileTreeView = QTreeView(self)
        self.mobileTreeView.setMinimumWidth(300)
        self.mobileTreeView.setModel(self.model)
        self.mobileTreeView.clicked.connect(self.onTreeViewClicked)
        
        
        header=["Attribute", "Value"]
        self.tableModel = MyTableModel(self, [], header)
        self.mobileTableView = QTableView(self)
        self.mobileTableView.setSelectionMode(QAbstractItemView.SingleSelection)
        self.mobileTableView.setModel(self.tableModel)
        self.mobileTableView.setContextMenuPolicy(Qt.CustomContextMenu)
        self.mobileTableView.customContextMenuRequested.connect( self.onContextMenuEvent )
        self.mobileTableView.setMinimumWidth(300)

        mobileViewLayout = QHBoxLayout()
        mobileViewLayout.addWidget(self.mobileImageLabel)
        mobileViewLayout.addWidget(self.mobileTreeView)
        mobileViewLayout.addWidget(self.mobileTableView)

        mobileLayout.addWidget(self.mobileDockToolbar)
        mobileLayout.addLayout(mobileViewLayout)

        
        self.setLayout(mobileLayout)
Beispiel #48
0
    def __init__(self, parent_widget):
        '''
        Tree view for displaying data in a XmlModel
        @param parent_widget (QWidget): Parent widget
        '''
        QTreeView.__init__(self, parent_widget)

        self.setAnimated(True)
        self.setMinimumHeight(200)
        # handled by the controller:
        self.setExpandsOnDoubleClick(False)
 def __init__(self):
     QTreeView.__init__(self)
     self.model = QDirModel()
     self.setModel(self.model)
     self.setSortingEnabled(True)
     i = self.model.index(os.getcwd())
     self.scrollTo(i)
     self.expand(i)
     self.setCurrentIndex(i)
     for i in range(self.model.columnCount()):
         self.resizeColumnToContents(i)
Beispiel #50
0
    def __init__(self, parent=None, **kwargs):
        QTreeView.__init__(self, parent, **kwargs)
        self.setSizePolicy(QSizePolicy.MinimumExpanding,
                           QSizePolicy.Expanding)

        self.__model = QStandardItemModel()
        self.__flattened = False
        self.__actionRole = Qt.UserRole
        self.__view = None

        self.__setupUi()
Beispiel #51
0
    def __init__(self, fileBrowser):
        QTreeView.__init__(self, fileBrowser)

        self._fileBrowser = fileBrowser

        self.setAttribute(Qt.WA_MacShowFocusRect, False)
        self.setAttribute(Qt.WA_MacSmallSize)
        self.setContextMenuPolicy(Qt.ActionsContextMenu)
        self.setHeaderHidden(True)
        self.setUniformRowHeights(True)
        self.setTextElideMode(Qt.ElideMiddle)

        # dir model
        self._dirsModel = _FileSystemModel(self)
        self._dirsModel.setNameFilterDisables(False)
        self._dirsModel.setFilter(QDir.AllDirs | QDir.AllEntries
                                  | QDir.CaseSensitive | QDir.NoDotAndDotDot)
        # self._dirsModel.directoryLoaded.connect(self.setFocus)  TODO don't have this signal in my Qt version

        # create proxy model
        self._filteredModel = FileBrowserFilteredModel(self)
        self._filteredModel.setSourceModel(self._dirsModel)

        self.setModel(self._filteredModel)

        if not sys.platform.startswith('win'):
            self._dirsModel.setRootPath("/")
        else:
            self._dirsModel.setRootPath('')

        # shortcut accessible only when self._tree has focus
        self._upShortcut = QShortcut(QKeySequence("BackSpace"), self)
        self._upShortcut.setContext(Qt.WidgetShortcut)
        self._upShortcut.activated.connect(self.moveUp)

        # shortcut accessible only when self._tree has focus
        self._homeShortcut = QShortcut(QKeySequence("`"), self)
        self._homeShortcut.setContext(Qt.WidgetShortcut)
        self._homeShortcut.activated.connect(self._goUserHomeDir)

        # shortcut accessible only when self._tree has focus
        self._homeShortcut = QShortcut(QKeySequence("."), self)
        self._homeShortcut.setContext(Qt.WidgetShortcut)
        self._homeShortcut.activated.connect(self._goCurrentDir)

        self.activated.connect(self._onActivated)
        self._fileActivated.connect(fileBrowser.fileActivated)

        # QDirModel loads item asynchronously, therefore we need timer for setting focus to the first item
        self._setFocusTimer = QTimer()
        self._setFocusTimer.timeout.connect(self._setFirstItemAsCurrent)
        self._setFocusTimer.setInterval(50)
        self.destroyed.connect(self._setFocusTimer.stop)
        self._timerAttempts = 0
Beispiel #52
0
    def __init__(self, fileBrowser):
        QTreeView.__init__(self, fileBrowser)

        self._fileBrowser = fileBrowser

        self.setAttribute( Qt.WA_MacShowFocusRect, False )
        self.setAttribute( Qt.WA_MacSmallSize )
        self.setContextMenuPolicy( Qt.ActionsContextMenu )
        self.setHeaderHidden( True )
        self.setUniformRowHeights( True )
        self.setTextElideMode(Qt.ElideMiddle)

        # dir model
        self._dirsModel = _FileSystemModel( self )
        self._dirsModel.setNameFilterDisables( False )
        self._dirsModel.setFilter( QDir.AllDirs | QDir.AllEntries | QDir.CaseSensitive | QDir.NoDotAndDotDot )
        # self._dirsModel.directoryLoaded.connect(self.setFocus)  TODO don't have this signal in my Qt version

        # create proxy model
        self._filteredModel = FileBrowserFilteredModel( self )
        self._filteredModel.setSourceModel( self._dirsModel )

        self.setModel( self._filteredModel)

        if not sys.platform.startswith('win'):
            self._dirsModel.setRootPath( "/" )
        else:
            self._dirsModel.setRootPath('')

        # shortcut accessible only when self._tree has focus
        self._upShortcut = QShortcut( QKeySequence( "BackSpace" ), self )
        self._upShortcut.setContext( Qt.WidgetShortcut )
        self._upShortcut.activated.connect(self.moveUp)

        # shortcut accessible only when self._tree has focus
        self._homeShortcut = QShortcut( QKeySequence( "`" ), self )
        self._homeShortcut.setContext( Qt.WidgetShortcut )
        self._homeShortcut.activated.connect(self._goUserHomeDir)

        # shortcut accessible only when self._tree has focus
        self._homeShortcut = QShortcut( QKeySequence( "." ), self )
        self._homeShortcut.setContext( Qt.WidgetShortcut )
        self._homeShortcut.activated.connect(self._goCurrentDir)

        self.activated.connect(self._onActivated)
        self._fileActivated.connect(fileBrowser.fileActivated)

        # QDirModel loads item asynchronously, therefore we need timer for setting focus to the first item
        self._setFocusTimer = QTimer()
        self._setFocusTimer.timeout.connect(self._setFirstItemAsCurrent)
        self._setFocusTimer.setInterval(50)
        self.destroyed.connect(self._setFocusTimer.stop)
        self._timerAttempts = 0
 def keyPressEvent(self, evt):
     """
     Protected method implementing special key handling.
     
     @param evt reference to the event (QKeyEvent)
     """
     if evt.key() in [Qt.Key_Delete, Qt.Key_Backspace] and \
        self.model() is not None:
         self.removeSelected()
         evt.setAccepted(True)
     else:
         QTreeView.keyPressEvent(self, evt)
Beispiel #54
0
 def __init__(self, parent=None):
     QTreeView.__init__(self, parent)
     # Connect
     self.connect(self, SIGNAL("customContextMenuRequested(QPoint)"),
             self.show_context_menu)
     self.connect(self, SIGNAL("doubleClicked(const QModelIndex&)"), 
             self.item_double_clicked)
     self.ctx_menu_actions = {}
     for name, text in self.ctx_menu.items():
         action = QAction(text, self)
         self.ctx_menu_actions[name] = action
         self.connect(action, SIGNAL("triggered()"), getattr(self, name))
Beispiel #55
0
    def __init__(self, parent=None):
        QTreeView.__init__(self, parent)

        self.__root = TreeItem("ERT")

        self.__tree_model = TreeModel(self.__root)

        self.setModel(self.__tree_model)

        #: :type: dict of (str, TreeItem)
        self.__groups = {}

        self.header().hide()
Beispiel #56
0
 def __init__(self, parent):
     QTreeView.__init__(self, parent)
     self.setObjectName("filetree")
     self.setSortingEnabled(True)
     self.setColumnWidth(0, 50)
     font = self.font()
     font.setPointSize(10)
     self.setFont(font)
     self.setHeaderHidden(True)
     self.setModel(QApplication.instance().filetree)
     for col in xrange(1, self.model().columnCount()):
         self.setColumnHidden(col, True)
     self.setRootIndex(self.model().index(os.path.expanduser('~')))
     self.clicked.connect(self._select_file)
Beispiel #57
0
    def __init__(self, parent=None, path=None):
        QTreeView.__init__(self, parent)
        self.ide = parent
        self.path = path

        self.model = explorerModel()

        self.setModel(self.model)
        self.setColumnHidden(3, True)
        self.setColumnHidden(2, True)

        self.setAnimated(False)
        self.setSortingEnabled(True)
        self.sortByColumn(0, Qt.AscendingOrder)