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)
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)
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)
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)