def __init__(self, parent): QtWidgets.QTreeWidget.__init__(self, parent) self._pan = scrollareapan.ScrollAreaPan(self, scrollFactor=0.05) self._pan.installEventFilterOn(self.viewport()) self._uiStream = uistream.UiStream() self._codeVisitor = gotocode.CodeLineVisitor(self) self._codeVisitor.errorIssued.connect(self._onGoToCodeError) self.setItemDelegate(self._TreeItemDelegate(self)) self.setTextElideMode(QtCore.Qt.ElideLeft) self.setColumnCount(2) self._setHeaderStretch() self.setHeaderHidden(True) self.setAlternatingRowColors(True) self.setExpandsOnDoubleClick(False) self.setSelectionMode(self.ExtendedSelection) self.itemDoubleClicked.connect(self.onItemDoubleClicked) self.setIndentation(10) self._rootTestItem = None self._testCases = [] self._allItemsIdMap = {} self._initAllIcons() self._testManager = None self._viewStates = ViewStates(self) self._contextMenu = QtWidgets.QMenu(self) self._makeContextMenu() self.setToolTip( "This view lists out the tests, <b>Double Click</b> on them to run them, <b>Ctrl+C</b> to copy the python module path;" + "<br><br><b>MMB Dragging</b> to pan the view around." )
def makeMenuToolButton(icon=None, toolTip="", parent=None): btn = QtWidgets.QToolButton(parent) if icon: btn.setIcon(icon) btn.setToolTip(toolTip) btn.setContentsMargins(0, 0, 0, 0) btn.setIconSize(QtCore.QSize(20, 20)) btn.setPopupMode(btn.InstantPopup) menu = QtWidgets.QMenu(btn) btn.setMenu(menu) return (btn, menu)
def __init__(self, parent=None): btnLineEdit.InlineButtonLineEdit.__init__(self, withClearButton=False, parent=parent) self._initIcons() self.editingFinished.connect(self.onEditFinished) self._initPath = None self._browseBtn = uiutils.makeIconButton(self._moreIcon, self) self._browseBtn.clicked.connect(self._onBrowseBtnClicked) self._browseMenu = QtWidgets.QMenu(self._browseBtn) self.addButton("Browse", self._browseBtn) self.regenerateBrowseMenu()
def _makeContextMenu(self): self._initAllIcons() self._runSetupOnlyAct = QtWidgets.QAction("Run setUp( ) Only", self) self._runSetupOnlyAct.triggered.connect(self._atRunSetupOnly) self._runSetupOnlyAct.setIcon(self._runPartialIcon) self._runWithoutTearDownAct = QtWidgets.QAction("Run Without tearDown( )", self) self._runWithoutTearDownAct.triggered.connect(self._atRunWithoutTearDown) self._runWithoutTearDownAct.setIcon(self._runPartialIcon) self._runSelectedAct = QtWidgets.QAction("Run Selected", self) self._runSelectedAct.triggered.connect(self._atRunSelected) self._runSelectedAct.setIcon(self._runSelectedIcon) self._runAllAct = QtWidgets.QAction("Run All", self) self._runAllAct.triggered.connect(self._atRunAll) self._runAllAct.setIcon(self._runAllIcon) self._copyPathAct = QtWidgets.QAction("Copy Selected Path", self) self._copyPathAct.triggered.connect(self.copyFirstSelectedTestId) self._goToCodeAct = QtWidgets.QAction("Go To Code...", self) self._goToCodeAct.triggered.connect(self._atGoToCode) self._reloadModulesAct = QtWidgets.QAction("Reload Selected Modules", self) self._reloadModulesAct.setVisible( importutils.isReimportFeatureAvailable(silentCheck=True) ) self._reloadModulesAct.triggered.connect(self._atReloadSelectedModules) self._reloadModulesAct.setIcon(self._reimportAndRunIcon) self._contextMenu.addAction(self._runAllAct) self._contextMenu.addAction(self._runSelectedAct) self._contextMenu.addSeparator() self._contextMenu.addAction(self._runSetupOnlyAct) self._contextMenu.addAction(self._runWithoutTearDownAct) self._contextMenu.addSeparator() self._contextMenu.addAction(self._copyPathAct) self._contextMenu.addAction(self._goToCodeAct) self._contextMenu.addSeparator() self._contextMenu.addAction(self._reloadModulesAct) self._logLevelMenu = QtWidgets.QMenu("Set Logging Level") self._contextMenu.addMenu(self._logLevelMenu) self._logLevelActionGrp = QtWidgets.QActionGroup(self._logLevelMenu) self._logLevelActionGrp.setExclusive(True)
def _makeRunMoreButton(self): _runMoreBtn = QtWidgets.QToolButton(self) _runMoreBtn.setIcon(self._view._runPartialIcon) _runMoreBtn.setAutoRaise(True) _runMoreBtn.setToolButtonStyle(QtCore.Qt.ToolButtonIconOnly) _runMoreBtn.setPopupMode(_runMoreBtn.InstantPopup) self._runSetupAct = QtWidgets.QAction("Run setUp( ) Only", self) self._runSetupAct.setIcon(self._view._runPartialIcon) self._runSetupAct.triggered.connect(self._runTestSetupOnly) self._runNoTearDown = QtWidgets.QAction("Run without tearDown( )", self) self._runNoTearDown.setIcon(self._view._runPartialIcon) self._runNoTearDown.triggered.connect(self._runTestWithoutTearDown) menu = QtWidgets.QMenu(_runMoreBtn) menu.addAction(self._runSetupAct) menu.addAction(self._runNoTearDown) _runMoreBtn.setMenu(menu) return _runMoreBtn