Example #1
0
    def __init__(self, parent=None, project=None, **kwargs):
        super(ChooseTargetsPage, self).__init__(parent)

        self.__project = project

        self.setTitle("Apply the dependency")

        layout = QtGui.QVBoxLayout(self)
        layout.setContentsMargins(2, 0, 2, 0)

        self.__errText = QtGui.QLabel("", self)

        self.group1 = group1 = QtGui.QGroupBox("Dependant Item", self)
        groupLayout1 = QtGui.QVBoxLayout(group1)
        groupLayout1.setContentsMargins(0, 0, 0, 0)
        self.__sourceSelector = src = common.job.JobColumnWidget(
            project=project, parent=self)
        # src.setSingleSelections(True)
        groupLayout1.addWidget(src)

        self.group2 = group2 = QtGui.QGroupBox("Item Depends On", self)
        groupLayout2 = QtGui.QVBoxLayout(group2)
        groupLayout2.setContentsMargins(0, 0, 0, 0)
        self.__destSelector = dst = common.job.JobColumnWidget(project=project,
                                                               parent=self)
        groupLayout2.addWidget(self.__destSelector)

        layout.addWidget(self.__errText)
        layout.addWidget(group1)
        layout.addWidget(group2)

        self.registerField("sourceSelection*", self, "sourceSelection")
        self.registerField("destSelection*", self, "destSelection")
Example #2
0
    def __init__(self, attrs, parent=None):
        QtGui.QWidget.__init__(self, parent)
        layout = QtGui.QVBoxLayout(self)
        layout.setContentsMargins(4, 0, 4, 4)

        self.__attrs = attrs

        self.__table = table = TableWidget(self)
        table.sortByColumn(0, QtCore.Qt.AscendingOrder)
        table.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)

        self.__jobId = None
        self.__layers = {}
        self.__model = None
        self.__proxy = proxy = TaskFilterProxyModel(self)
        proxy.setSortRole(SortRole)
        proxy.setDynamicSortFilter(True)
        proxy.sort(0, QtCore.Qt.AscendingOrder)
        table.setModel(proxy)

        self.layout().addWidget(table)

        # connections
        table.customContextMenuRequested.connect(self.__showContextMenu)
        table.doubleClicked.connect(self.__rowDoubleClicked)
Example #3
0
    def __init__(self, *args, **kwargs):
        super(ChooseTypeDepPage, self).__init__(*args, **kwargs)

        self.setTitle("Choose the type of dependency")

        layout = QtGui.QVBoxLayout(self)
        self.__title = QtGui.QLabel("", self)
        layout.addWidget(self.__title)

        self.__radioGroup = QtGui.QButtonGroup(self)
        self.__radioGroup.setExclusive(True)

        for val, meta in sorted(DEPEND_TYPES.items()):

            btn = QtGui.QRadioButton(meta['label'], self)
            self.__radioGroup.addButton(btn, val)

            label = QtGui.QLabel(
                "<font color='#c3c3c3'>%s</font>" % meta['descript'], self)
            label.setIndent(30)
            font = btn.font()
            font.setPointSize(font.pointSize() - 1)
            label.setFont(font)

            layout.addWidget(btn)
            layout.addWidget(label)

        self.registerField("dependType*", self, "dependType")
        self.__radioGroup.buttonClicked[int].connect(self.completeChanged)
Example #4
0
    def __init__(self, attrs, parent=None):
        QtGui.QWidget.__init__(self, parent)
        layout = QtGui.QVBoxLayout(self)
        layout.setContentsMargins(4, 0, 4, 4)

        self.__attrs = attrs

        self.__tree = tree = TreeWidget(self)
        tree.setItemDelegateForColumn(1, SimplePercentageBarDelegate(self))

        self.__model = ClusterModel(self)
        self.__proxy = proxy = models.AlnumSortProxyModel(self)
        proxy.setSortRole(QtCore.Qt.DisplayRole)
        proxy.setSourceModel(self.__model)

        tree.setModel(proxy)
        tree.sortByColumn(0, QtCore.Qt.AscendingOrder)

        for i, v in enumerate(self.WIDTH):
            tree.setColumnWidth(i, v)

        self.layout().addWidget(self.__tree)

        # connections
        tree.clicked.connect(self.__itemClicked)
        tree.doubleClicked.connect(self.__itemDoubleClicked)
Example #5
0
    def __init__(self, items, default="name", parent=None):
        QtGui.QWidget.__init__(self, parent)
        QtGui.QVBoxLayout(self)
        self.__default = default

        self.setMaximumHeight(200)

        self.list_widget = QtGui.QListWidget(self)
        self.list_widget.itemDoubleClicked.connect(self.list_widget.editItem)
        for item in (items or []):
            list_item = self.__newItem(item)
            self.list_widget.addItem(list_item)
        self.list_widget.sortItems()

        self.btn_add = QtGui.QPushButton(QtGui.QIcon(":/images/plus.png"), "",
                                         self)
        self.btn_add.setFlat(True)
        self.btn_add.clicked.connect(self.addItem)
        self.btn_sub = QtGui.QPushButton(QtGui.QIcon(":/images/minus.png"), "",
                                         self)
        self.btn_sub.setFlat(True)
        self.btn_sub.clicked.connect(self.removeItems)

        layout_btn = QtGui.QHBoxLayout()
        layout_btn.setContentsMargins(0, 0, 0, 0)
        layout_btn.setSpacing(1)
        layout_btn.addStretch()
        layout_btn.addWidget(self.btn_add)
        layout_btn.addWidget(self.btn_sub)

        self.layout().addWidget(self.list_widget)
        self.layout().addLayout(layout_btn)
Example #6
0
    def __init__(self, title, options, checked, allSelected=True, parent=None):
        QtGui.QWidget.__init__(self, parent)
        layout = QtGui.QVBoxLayout(self)

        self.listItems = QtGui.QListWidget(self)
        self.listItems.setMaximumHeight(100)

        for opt in options:
            item = QtGui.QListWidgetItem(opt)
            item.setFlags(QtCore.Qt.ItemIsUserCheckable
                          | QtCore.Qt.ItemIsSelectable
                          | QtCore.Qt.ItemIsEnabled)
            if checked and opt in checked:
                item.setCheckState(QtCore.Qt.Checked)
            else:
                item.setCheckState(QtCore.Qt.Unchecked)
            self.listItems.addItem(item)

        self.checkBoxAll = QtGui.QCheckBox("All %s" % title, self)
        if allSelected:
            self.listItems.setDisabled(True)
            self.checkBoxAll.setCheckState(QtCore.Qt.Checked)
        self.checkBoxAll.stateChanged.connect(self.__allSelectedToggled)

        layout.addWidget(self.checkBoxAll)
        layout.addWidget(self.listItems)
Example #7
0
    def __init__(self, attrs, parent=None):
        QtGui.QWidget.__init__(self, parent)
        layout = QtGui.QVBoxLayout(self)
        layout.setContentsMargins(4, 0, 4, 4)

        self.attrs = attrs
        self.__jobs = {}

        self.__tree = tree = QtGui.QTreeWidget(self)
        tree.setHeaderLabels(self.HEADER)
        tree.setColumnCount(len(self.HEADER))
        tree.setUniformRowHeights(True)
        tree.viewport().setFocusPolicy(QtCore.Qt.NoFocus)
        tree.header().setStretchLastSection(True)
        tree.setSelectionMode(tree.ExtendedSelection)
        tree.setAlternatingRowColors(True)

        for i, v in enumerate(self.WIDTH):
            tree.setColumnWidth(i, v)

        layout.addWidget(tree)

        # connections
        tree.itemClicked.connect(lambda item: copyToClipboard(item.text(0)))
        tree.itemDoubleClicked.connect(self.__itemDoubleClicked)
        tree.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
        tree.customContextMenuRequested.connect(self.__showContextMenu)
Example #8
0
    def __init__(self, attrs, parent=None):
        super(NodeWidget, self).__init__(parent)
        self.__attrs = attrs

        layout = QtGui.QVBoxLayout(self)
        layout.setContentsMargins(4, 0, 4, 4)

        self.__model = model = NodeModel(self)
        self.__proxy = proxy = models.AlnumSortProxyModel(self)
        proxy.setSourceModel(model)

        self.__view = view = TableWidget(self)
        view.setModel(proxy)
        view.sortByColumn(0, QtCore.Qt.AscendingOrder)

        layout.addWidget(view)

        view.setColumnWidth(0, 150)
        view.setColumnWidth(model.HEADERS.index('Locked'), 60)
        view.setColumnWidth(model.HEADERS.index('Cores (Total)'), 90)
        view.setColumnWidth(model.HEADERS.index('Cores (Idle)'), 90)

        view.setColumnHidden(model.HEADERS.index('Ram (Total)'), True)
        view.setColumnHidden(model.HEADERS.index('Swap (Total)'), True)

        view.setItemDelegateForColumn(model.HEADERS.index('Ram (Free)'),
                                      ResourceDelegate(parent=self))
        view.setItemDelegateForColumn(
            model.HEADERS.index('Swap (Free)'),
            ResourceDelegate(warn=.75, critical=.25, parent=self))

        view.doubleClicked.connect(self.__itemDoubleClicked)
Example #9
0
    def __init__(self, attrs, parent=None):
        QtGui.QWidget.__init__(self, parent)
        layout = QtGui.QVBoxLayout(self)
        layout.setContentsMargins(4, 0, 4, 4)

        self.attrs = attrs
        self.__jobs = {}

        self.__tree = tree = QtGui.QTreeWidget(self)
        tree.setHeaderLabels(self.Header)
        tree.setColumnCount(len(self.Header))
        tree.setUniformRowHeights(True)
        tree.viewport().setFocusPolicy(QtCore.Qt.NoFocus)
        tree.header().setStretchLastSection(True)

        for i, v in enumerate(self.Width):
            tree.setColumnWidth(i, v)

        def treeMousePress(event):
            item = self.__tree.itemAt(event.pos())
            if not item:
                self.__tree.clearSelection()
            QtGui.QTreeWidget.mousePressEvent(self.__tree, event)

        tree.mousePressEvent = treeMousePress

        layout.addWidget(tree)

        # connections
        tree.itemDoubleClicked.connect(self.__itemDoubleClicked)
        tree.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
        tree.customContextMenuRequested.connect(self.__showContextMenu)
Example #10
0
    def __init__(self, attrs, parent=None):
        super(LayerWidget, self).__init__(parent)

        self.__attrs = attrs

        self.__view = table = TableWidget(self)
        table.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)

        delegate = JobProgressDelegate(dataRole=LayerModel.ObjectRole,
                                       parent=self)
        table.setItemDelegateForColumn(LayerModel.HEADERS.index('Progress'),
                                       delegate)

        self.__jobId = None
        self.__model = None

        self.__proxy = proxy = models.AlnumSortProxyModel(self)
        proxy.setSortRole(LayerModel.DataRole)
        table.setModel(proxy)

        layout = QtGui.QVBoxLayout(self)
        layout.setContentsMargins(4, 0, 4, 4)
        layout.addWidget(table)

        # connections
        table.customContextMenuRequested.connect(self.__showContextMenu)
        table.clicked.connect(self.__itemClicked)
        table.doubleClicked.connect(self.__itemDoubleClicked)
Example #11
0
    def __init__(self, attrs, parent=None):
        QtGui.QWidget.__init__(self, parent)
        layout = QtGui.QVBoxLayout(self)
        layout.setContentsMargins(4, 0, 4, 4)

        self.__attrs = attrs
        self.__scroll = QtGui.QScrollArea(self)
        self.__scroll.setWidgetResizable(True)
        self.__scroll.setFocusPolicy(QtCore.Qt.NoFocus)
        self.layout().addWidget(self.__scroll)
Example #12
0
    def __show_popup(self):

        frame = QtGui.QFrame(self, QtCore.Qt.Popup | QtCore.Qt.Window)
        frame.resize(350, 200)
        frame.setFrameStyle(QtGui.QFrame.Box | QtGui.QFrame.Raised)
        frame.setLineWidth(2)
        frame.move(QtGui.QCursor.pos())

        layout = QtGui.QVBoxLayout(frame)
        layout.addWidget(getHelpTextWidget(self.__help))
        frame.show()
Example #13
0
    def __init__(self, parent=None):
        super(DragDropList, self).__init__(parent)

        self.setFrameStyle(self.Panel|self.Sunken)
        self.setAcceptDrops(True)

        self._buttonGroup = QtGui.QButtonGroup(self)
        self._buttonGroup.setExclusive(True)

        header = QtGui.QWidget(self)
        header.setFixedHeight(20)
        headerLayout = QtGui.QHBoxLayout(header)
        headerLayout.setSpacing(0)
        headerLayout.setContentsMargins(8, 0, 8, 0)
        self._headerLayer = headerLayout

        self._contentWidget = content = QtGui.QWidget(self)
        scroll = QtGui.QScrollArea(self)
        scroll.setFrameStyle(self.Panel|self.Raised)
        scroll.setWidgetResizable(True)
        scroll.setWidget(content)
        scrollLayout = QtGui.QVBoxLayout(content)
        scrollLayout.setSpacing(0)
        scrollLayout.setContentsMargins(0, 0, 0, 0)

        self._itemLayout = QtGui.QVBoxLayout()
        self._itemLayout.setSpacing(self.ITEM_SPACING)
        self._itemLayout.setContentsMargins(0, 12, 0, 12)

        scrollLayout.addLayout(self._itemLayout)
        scrollLayout.addStretch()

        layout = QtGui.QVBoxLayout(self)
        layout.setContentsMargins(4, 4, 4, 4)

        layout.addWidget(header)
        layout.addWidget(scroll)

        # Connections
        self._buttonGroup.buttonClicked.connect(self.itemClicked)
Example #14
0
    def __init__(self, title, options, cols=3, parent=None):
        QtGui.QWidget.__init__(self, parent)
        layout = QtGui.QVBoxLayout(self)

        group_box = QtGui.QGroupBox(title)
        group_box_layout = QtGui.QGridLayout(group_box)

        row = 0
        for item, opt in enumerate(options):
            row = item / cols
            radio = QtGui.QRadioButton(opt, self)
            group_box_layout.addWidget(radio, row, item % cols)

        layout.addWidget(group_box)
Example #15
0
    def __init__(self, parent=None):
        QtGui.QDialog.__init__(self, parent)
        layout = QtGui.QVBoxLayout(self)
        self.__jobSelector = JobSelectionWidget(self)

        self.__btns = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok
                                             | QtGui.QDialogButtonBox.Cancel)

        layout.addWidget(self.__jobSelector)
        layout.addWidget(self.__btns)

        # connections
        self.__jobSelector.valueDoubleClicked.connect(self.accept)
        self.__btns.accepted.connect(self.accept)
        self.__btns.rejected.connect(self.reject)
Example #16
0
    def __init__(self, *args, **kwargs):
        super(ConfirmApplyPage, self).__init__(*args, **kwargs)

        self.setTitle("Confirming dependency")

        self.setSubTitle("Please review the actions that are about to be " \
                         "taken, and then hit 'Finish' to apply them.")

        self.__depOpts = []

        self.__text = text = QtGui.QTextEdit(self)
        text.setReadOnly(True)
        text.setWordWrapMode(QtGui.QTextOption.NoWrap)

        layout = QtGui.QVBoxLayout(self)
        layout.addWidget(self.__text)
Example #17
0
    def __init__(self, attrs, parent=None):
        QtGui.QWidget.__init__(self, parent)

        self.__tasks = {}
        self.__interval = 1000

        self.__tabs = QtGui.QTabWidget(self)
        self.__tabs.setTabsClosable(True)
        self.__tabs.tabCloseRequested.connect(self.closeTab)

        self.__fontSize = DEFAULT_FONT_SIZE

        layout = QtGui.QVBoxLayout()
        layout.setContentsMargins(4, 0, 4, 4)
        layout.addWidget(self.__tabs)
        self.setLayout(layout)
Example #18
0
    def __init__(self, attrs, parent=None):
        super(NodeWidget, self).__init__(parent)
        self.__attrs = attrs

        layout = QtGui.QVBoxLayout(self)
        layout.setContentsMargins(4,0,4,4)

        self.__refreshEnabled = True
        self.__clusters = {}

        self.__model = model = NodeModel(self)
        self.__proxy = proxy = NodeFilterProxyModel(self)
        proxy.setSortRole(model.DataRole)
        proxy.setSourceModel(model)

        self.__view = view = TableWidget(self)
        view.setModel(proxy)

        layout.addWidget(view)

        headers = model.HEADERS
        view.setColumnWidth(0, 150)
        view.setColumnWidth(headers.index('Locked'), 55)
        view.setColumnWidth(headers.index('State'), 75)
        view.setColumnWidth(headers.index('Total Cores'), 90)
        view.setColumnWidth(headers.index('Idle Cores'), 90)
        view.setColumnWidth(headers.index('Tags'), 100)
        view.setColumnWidth(headers.index('Ping'), 80)
        view.setColumnWidth(headers.index('Uptime'), 80)

        view.setColumnHidden(headers.index('Total Ram'), True)
        view.setColumnHidden(headers.index('Total Swap'), True)

        delegate = ResourceDelegate(dataRole=model.DataRole, parent=self)
        view.setItemDelegateForColumn(headers.index('Free Ram'), delegate)

        delegate = ResourceDelegate(warn=.75, critical=.25, dataRole=model.DataRole, parent=self)
        view.setItemDelegateForColumn(headers.index('Free Swap'), delegate)

        view.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)

        view.customContextMenuRequested.connect(self.__showContextMenu)
        view.clicked.connect(self.__itemClicked)
        view.doubleClicked.connect(self.__itemDoubleClicked)
Example #19
0
    def __init__(self, filt=None, items=None, data=None, parent=None):
        QtGui.QWidget.__init__(self, parent)

        self.__data = {}

        self.__txt_label = QtGui.QLabel(self)
        self.__txt_filter = QtGui.QLineEdit(self)
        self.__txt_filter.textChanged.connect(self.__filterChanged)

        self.__model = QtGui.QStringListModel(self)

        self.__proxyModel = proxy = QtGui.QSortFilterProxyModel(self)
        proxy.setSourceModel(self.__model)

        self.__list = view = QtGui.QListView(self)
        view.setSelectionMode(self.__list.ExtendedSelection)
        view.setModel(proxy)

        proxy.sort(0)
        proxy.setDynamicSortFilter(True)

        layout = QtGui.QVBoxLayout(self)
        layout.setSpacing(4)
        layout.setContentsMargins(0, 0, 0, 0)

        hlayout = QtGui.QHBoxLayout()
        hlayout.setContentsMargins(0, 0, 0, 0)
        hlayout.addWidget(self.__txt_label)
        hlayout.addWidget(self.__txt_filter)

        layout.addLayout(hlayout)
        layout.addWidget(self.__list)

        # connections
        self.__list.doubleClicked.connect(self._itemDoubleClicked)
        self.__list.clicked.connect(self._itemClicked)
        self.__list.selectionModel().selectionChanged.connect(
            self._selectionChanged)

        if items:
            self.setStringList(items)

        if filt:
            self.setFilter(filt)
Example #20
0
    def __init__(self, title, options, selected=None, icons=None, parent=None):
        QtGui.QWidget.__init__(self, parent)
        layout = QtGui.QVBoxLayout(self)

        self.__btn = btn = QtGui.QPushButton(title)
        btn.setFocusPolicy(QtCore.Qt.NoFocus)
        btn.setMaximumHeight(22)
        btn.setFlat(True)
        btn.setContentsMargins(0, 0, 0, 0)

        self.__menu = menu = QtGui.QMenu(self)
        btn.setMenu(menu)

        self.setOptions(options, selected, icons)

        layout.addWidget(btn)

        btn.toggled.connect(btn.showMenu)
        menu.triggered.connect(
            lambda action: self.optionSelected.emit(action.text()))
Example #21
0
    def __init__(self, attrs, parent=None):
        QtGui.QWidget.__init__(self, parent)
        layout = QtGui.QVBoxLayout(self)
        layout.setContentsMargins(4, 0, 4, 4)

        self.__attrs = attrs

        self.__tree = tree = TreeWidget(self)
        tree.setItemDelegateForColumn(1, SimplePercentageBarDelegate(self))

        self.__model = ClusterModel(self)
        tree.setModel(self.__model)
        self.__model.refresh()

        for i, v in enumerate(self.Width):
            tree.setColumnWidth(i, v)

        self.layout().addWidget(self.__tree)

        # connections
        tree.doubleClicked.connect(self.__itemDoubleClicked)
Example #22
0
    def __init__(self, attrs, parent=None):
        super(JobWranglerWidget, self).__init__(parent)
        self.__attrs = attrs

        layout = QtGui.QVBoxLayout(self)
        layout.setContentsMargins(4,0,4,4)

        # DEBUG
        if not "projects" in attrs:
            attrs['projects'] = plow.client.get_projects()

        self.__model = model = JobModel(attrs, self)
        self.__proxy = proxy = models.AlnumSortProxyModel(self)
        proxy.setSourceModel(model)

        self.__view = view = TreeWidget(self)
        view.setModel(proxy)
        view.sortByColumn(4, QtCore.Qt.DescendingOrder)

        for i, width in enumerate(JobNode.HEADER_WIDTHS):
            view.setColumnWidth(i, width)

        view.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
        view.customContextMenuRequested.connect(self.__showContextMenu)

        layout.addWidget(view)

        #
        # Connections
        #
        view.doubleClicked.connect(self.__itemDoubleClicked)
        view.activated.connect(self.__itemClicked)

        model.modelReset.connect(view.expandAll)

        self.__refreshTimer = timer = QtCore.QTimer(self)
        timer.setSingleShot(True)
        timer.setInterval(1500)
        timer.timeout.connect(self.refresh)
Example #23
0
    def __init__(self, attrs, parent=None):
        QtGui.QDialog.__init__(self, parent)
        layout = QtGui.QVBoxLayout(self)

        self.sliderRefresh = SpinSliderWidget(1, 60, attrs["refreshSeconds"],
                                              self)
        self.sliderRefresh.slider.setTickInterval(5)
        self.sliderRefresh.slider.setTickPosition(QtGui.QSlider.TicksBelow)
        self.checkboxLoadMine = BooleanCheckBox(bool(attrs["loadMine"]))
        self.listUsers = ManagedListWidget(attrs["users"], "name", self)
        self.checkboxLoadErrors = QtGui.QCheckBox(self)

        projects = [project.code for project in plow.client.get_projects()]
        self.listProjects = CheckableListBox("Projects", projects,
                                             attrs["projects"],
                                             bool(attrs["allProjects"]), self)

        group_box1 = QtGui.QGroupBox("Auto Load Jobs", self)

        form_layout1 = QtGui.QFormLayout(group_box1)
        form_layout1.addRow("Refresh", self.sliderRefresh)
        form_layout1.addRow("Load Mine:", self.checkboxLoadMine)
        form_layout1.addRow("Load User:"******"Load With Errors:", self.checkboxLoadErrors)

        # move to project multi-select widget
        group_box2 = QtGui.QGroupBox("Filters", self)
        form_layout2 = QtGui.QFormLayout(group_box2)
        form_layout2.addRow("For Projects:", self.listProjects)

        buttons = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok
                                         | QtGui.QDialogButtonBox.Cancel)
        buttons.accepted.connect(self.accept)
        buttons.rejected.connect(self.reject)

        layout.addWidget(group_box1)
        layout.addWidget(group_box2)
        layout.addWidget(buttons)
Example #24
0
    def __init__(self, filt=None, items=None, data=None, parent=None):
        super(FilterableListBox, self).__init__(parent)

        self.__data = {}

        height = 20

        self.__txt_label = QtGui.QLabel(self)
        self.__txt_filter = QtGui.QLineEdit(self)
        self.__txt_filter.setFixedHeight(height)
        self.__txt_filter.textChanged.connect(self.__filterChanged)

        self.__txt_clear = btn = QtGui.QPushButton(self)
        btn.setIcon(QtGui.QIcon(":/images/delete.png"))
        btn.setFlat(True)
        btn.setFixedSize(height, height)
        btn.setIconSize(QtCore.QSize(14, 14))
        btn.setVisible(False)

        self.__model = QtGui.QStringListModel(self)

        self.__proxyModel = proxy = QtGui.QSortFilterProxyModel(self)
        proxy.setSourceModel(self.__model)

        self.__list = view = QtGui.QListView(self)
        view.setSelectionMode(self.__list.ExtendedSelection)
        view.setModel(proxy)

        proxy.sort(0)
        proxy.setDynamicSortFilter(True)

        layout = QtGui.QVBoxLayout(self)
        layout.setSpacing(4)
        layout.setContentsMargins(0, 0, 0, 0)

        hlayout = QtGui.QHBoxLayout()
        hlayout.setSpacing(0)
        hlayout.setContentsMargins(0, 0, 0, 0)
        hlayout.addWidget(self.__txt_label)
        hlayout.addSpacing(2)
        hlayout.addWidget(self.__txt_filter)
        hlayout.addWidget(self.__txt_clear)

        layout.addLayout(hlayout)
        layout.addWidget(self.__list)

        # connections
        self.__list.doubleClicked.connect(self._itemDoubleClicked)
        self.__list.clicked.connect(self._itemClicked)

        self.__selModel = self.__list.selectionModel()
        self.__selModel.selectionChanged.connect(self._selectionChanged)

        self.__txt_filter.textChanged.connect(
            lambda v: self.__txt_clear.setVisible(bool(v)))
        self.__txt_clear.clicked.connect(lambda: self.setFilter(''))

        if items:
            self.setStringList(items)

        if filt:
            self.setFilter(filt)
Example #25
0
    def __init__(self, job=None, task=None, attrs=None, parent=None):
        QtGui.QWidget.__init__(self, parent)

        self.__task = None
        self.__log_file = QtCore.QFile()
        self.__log_stream = QtCore.QTextStream()

        openAction = QtGui.QAction("Open Log File", self)
        openAction.setShortcut(QtGui.QKeySequence.Open)
        self.addAction(openAction)

        self.__searchLine = QtGui.QLineEdit(self)
        self.__chk_tail = QtGui.QAction("Tail log", self)
        self.__chk_tail.setCheckable(True)

        self.__findPrevBtn = prev = QtGui.QAction(self)
        prev.setToolTip("Find Previous Match")
        prev.setIcon(QtGui.QIcon(":/images/left_arrow.png"))

        self.__findNextBtn = nxt = QtGui.QAction(self)
        nxt.setToolTip("Find Next Match")
        nxt.setIcon(QtGui.QIcon(":/images/right_arrow.png"))

        self.__jobNameLabel = label = QtGui.QLabel(self)
        label.setIndent(10)
        # label.setTextInteractionFlags(QtCore.Qt.TextSelectableByMouse)
        label.hide()
        self.__jobNameSpacer = QtGui.QWidget(self)
        self.__jobNameSpacer.setFixedHeight(6)
        self.__jobNameSpacer.hide()

        def spacer(width):
            w = QtGui.QWidget()
            w.setFixedWidth(width)
            return w

        stretch = QtGui.QWidget()
        stretch.setSizePolicy(QtGui.QSizePolicy.Expanding,
                              QtGui.QSizePolicy.Preferred)

        self.__toolbar = tb = QtGui.QToolBar(self)
        tb.addWidget(spacer(4))
        tb.addWidget(QtGui.QLabel("Find: ", self))
        tb.addWidget(self.__searchLine)
        tb.addAction(self.__findPrevBtn)
        tb.addAction(self.__findNextBtn)
        tb.addWidget(stretch)
        tb.addAction(self.__chk_tail)
        tb.addWidget(spacer(4))

        self.__view = view = QtGui.QPlainTextEdit(self)
        font = view.font()
        font.setPixelSize(DEFAULT_FONT_SIZE)
        view.setFont(font)
        view.setLineWrapMode(view.WidgetWidth)
        view.setReadOnly(True)
        view.setMaximumBlockCount(1000000)
        # self.__view.setFocusPolicy(QtCore.Qt.NoFocus)

        layout = QtGui.QVBoxLayout(self)
        layout.setSpacing(0)
        layout.setContentsMargins(0, 0, 0, 0)
        layout.addWidget(self.__toolbar)
        layout.addWidget(self.__jobNameLabel)
        layout.addWidget(self.__jobNameSpacer)
        layout.addWidget(self.__view)

        self.__highlighter = TextHighlighter(view.document())
        self.__logWatcher = FileWatcher(self)

        # Connections
        self.__logWatcher.fileChanged.connect(self.__logUpdated)
        self.__chk_tail.toggled.connect(self.__logTailToggled)
        self.__searchLine.textChanged.connect(self.findText)
        self.__searchLine.returnPressed.connect(self.findNext)
        self.__findPrevBtn.triggered.connect(self.findPrev)
        self.__findNextBtn.triggered.connect(self.findNext)
        openAction.triggered.connect(self.openLogFile)

        # Optional args
        if job:
            self.setJobName(job.name)

        if task:
            self.setCurrentTask(task)
Example #26
0
    def __init__(self, project, *args, **kwargs):
        super(FilterManager, self).__init__(*args, **kwargs)

        self._projectLabel = QtGui.QLabel(self)

        self._filtersList = filt = FiltersList(parent=self)
        self._matchersList = match = MatchersList(parent=self)
        self._actionsList = act = ActionsList(parent=self)

        self._toolbar = tb = QtGui.QToolBar(self)
        tb.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
        tb.setMaximumHeight(32)
        tb.addAction(QtGui.QIcon(":/images/refresh.png"), "Refresh", self.refresh)

        self._status = QtGui.QStatusBar(self)

        h_splitter = QtGui.QSplitter(QtCore.Qt.Horizontal, self)
        h_splitter.setSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Expanding)

        v_splitter = QtGui.QSplitter(QtCore.Qt.Vertical, self)

        v_splitter.addWidget(self._matchersList)
        v_splitter.addWidget(self._actionsList)

        h_splitter.addWidget(self._filtersList)
        h_splitter.addWidget(v_splitter)

        tbLayout = QtGui.QHBoxLayout()
        tbLayout.setContentsMargins(0, 0, 4, 0)
        tbLayout.addWidget(self._toolbar)
        tbLayout.addWidget(self._projectLabel)

        layout = QtGui.QVBoxLayout(self)
        layout.setContentsMargins(6, 0, 6, 4)
        layout.setSpacing(2)

        layout.addLayout(tbLayout)
        layout.addWidget(h_splitter)
        layout.addWidget(self._status)

        v_splitter.setSizes([100,100])
        h_splitter.setSizes([100,100])

        self.setStyleSheet("""
            DragDropItem {
                border: 1px solid black;
                border-radius: 4px;
                background-color: QLinearGradient(x1: 0, y1: 0, x2: 0, y2: 1, 
                                                  stop: 0 rgb(40, 40, 40), 
                                                  stop: 1 rgb(27, 28, 30) );
            }
            DragDropItem:checked {
                border: 1px solid rgb(100,100,100);
                background-color: QLinearGradient(x1: 0, y1: 0, x2: 0, y2: 1, 
                                                  stop: 1 rgb(40, 40, 40), 
                                                  stop: 0 rgb(27, 28, 30) );                
            }
            """)

        self.setProject(project)

        # Connnections
        filt.filterSelected.connect(match.setFilterObject)
        filt.filterSelected.connect(act.setFilterObject)