def columnCount(self, parent=QModelIndex()):
     """Returns the number of columns."""
     return len(self._parameter_values) + 1
Beispiel #2
0
 def rowCount(self, index=QModelIndex()):
     return len(self.nutrients)
Beispiel #3
0
 def data(self, index: QtCore.QModelIndex, role: int = ...) -> typing.Any:
     """ For given index and DisplayRole return name of the selected city"""
     if not index.isValid():
         return None
     if role == QtCore.Qt.DisplayRole:
         return self.number_list[index.row()]
Beispiel #4
0
 def selectFirstItem(self):
     self.setCurrentIndex(self.model.index(0, 0, QModelIndex()))
Beispiel #5
0
 def parent(self, index):
     return QModelIndex()
Beispiel #6
0
 def append_objects(self, objects):
     self.beginInsertRows(QModelIndex(), len(self.m_objects),
                          len(self.m_objects) + len(self.objects) - 1)
     self.m_objects = self.m_objects + objects
     self.endInsertRows()
     QObject.emit(self, SIGNAL("countChanged()"))
 def rowCount(self, parent=QModelIndex()):
     """Number of rows in the model."""
     return len(self._main_data)
Beispiel #8
0
	def parent(self, child):
		return QModelIndex()
 def deleteRow(self):
     """Delete all rows corresponding to selected cells."""
     rowidxlst = list(set(elt.row()
                          for elt in self.table.selectedIndexes()))
     for idx in sorted(rowidxlst, reverse=True):
         self.model.removeRows(idx, 1, QModelIndex())
Beispiel #10
0
	def __init__(self, parent, name, data):
		if not type(data) == binaryninja.binaryview.BinaryView:
			raise Exception('expected widget data to be a BinaryView')

		self.bv = data

		QWidget.__init__(self, parent)
		DockContextHandler.__init__(self, self, name)
		self.actionHandler = UIActionHandler()
		self.actionHandler.setupActionHandler(self)

		self.table = QTableView(self)
		self.model = DebugThreadsListModel(self.table)
		self.table.setModel(self.model)
		self.table.clicked.connect(self.threadRowClicked)

		self.item_delegate = DebugThreadsItemDelegate(self)
		self.table.setItemDelegate(self.item_delegate)

		# self.table.setSortingEnabled(True)
		self.table.setSelectionBehavior(QAbstractItemView.SelectionBehavior.SelectRows)
		self.table.setSelectionMode(QAbstractItemView.ExtendedSelection)

		self.table.verticalHeader().setSectionResizeMode(QHeaderView.ResizeToContents)
		self.table.verticalHeader().setVisible(False)

		self.table.setHorizontalScrollMode(QAbstractItemView.ScrollPerPixel)
		self.table.setVerticalScrollMode(QAbstractItemView.ScrollPerPixel)

		self.table.resizeColumnsToContents()
		self.table.resizeRowsToContents()

		for i in range(len(self.model.columns)):
			self.table.setColumnWidth(i, self.item_delegate.sizeHint(self.table.viewOptions(), self.model.index(-1, i, QModelIndex())).width())
		self.table.horizontalHeader().setSectionResizeMode(1, QHeaderView.Stretch)

		layout = QVBoxLayout()
		layout.setContentsMargins(0, 0, 0, 0)
		layout.setSpacing(0)
		layout.addWidget(self.table)
		self.setLayout(layout)
Beispiel #11
0
	def index(self, row, column, parent):
		if parent.isValid() or column > len(self.columns) or row >= len(self.rows):
			return QModelIndex()
		return self.createIndex(row, column)
Beispiel #12
0
 def columnCount(self, parent=QModelIndex()):
     return len(self._df.columns)
Beispiel #13
0
 def rowCount(self, parent=QModelIndex()):
     return len(self._df.index)
 def rowCount(self, parent=QModelIndex()):
     """Return the number of rows."""
     return self._rows_shown
Beispiel #15
0
 def _on_selected_row_changed(self, index: QModelIndex):
     self.action_remove.setEnabled(index.isValid())
     self.action_move_up.setEnabled(index.isValid())
     self.action_move_down.setEnabled(index.isValid())
Beispiel #16
0
 def rowCount(self, parent=QModelIndex()):
     return len(self._primesList) + 2
Beispiel #17
0
 def insert(self, i, mobject):
     self.beginInsertRows(QModelIndex(), i, i)
     self.m_objects.append(mobject)
     self.endInsertRows()
     QObject.emit(self, SIGNAL("countChanged()"))
Beispiel #18
0
 def columnCount(self, parent=QModelIndex()):
     return self._tableWidth
Beispiel #19
0
 def edit_single_parameter(self, index: QModelIndex) -> None:
     """Take the index and update the underlying brightway Parameter."""
     param = self.get_parameter(index)
     field = self._dataframe.columns[index.column()]
     signals.parameter_modified.emit(param, field, index.data())
Beispiel #20
0
    def data(self,
             index: QModelIndex,
             role: Qt.ItemDataRole = Qt.DisplayRole) -> Any:
        if not index.isValid():
            return None
        col = self.getColumnKey(index.column())
        if not col:
            return None

        if role == Qt.FontRole:
            if col in (
                    'datatype',
                    'size',
            ):
                return QFontDatabase.systemFont(QFontDatabase.FixedFont)
            return None

        if role == Qt.CheckStateRole:
            if col in ('enabled', ):
                mod = self.modmodel[index.row()]
                val = mod[col]
                return Qt.Checked if val else Qt.Unchecked
            return None

        if role == Qt.BackgroundRole:
            mod = self.modmodel[index.row()]
            if not mod.enabled:
                return QColor(240, 240, 240)
            if col in ('priority', ) and mod.datatype not in (
                    'mod',
                    'udf',
            ):
                return QColor(240, 240, 240)
            if mod.installdate > self._lastUpdate:
                return QColor(242, 255, 242)
            if mod.installdate > self._lastInitialization:
                return QColor(242, 246, 255)
            if not mod.installed:
                return QColor(250, 240, 240)
            return None

        if role == Qt.ForegroundRole:
            mod = self.modmodel[index.row()]
            if not mod.enabled:
                return QColor(60, 60, 60)
            return None

        if role == Qt.DecorationRole:
            if col in ('datatype', ):
                mod = self.modmodel[index.row()]
                val = mod[col]
                return self._icons[val] if val in self._icons else self._icons[
                    'udf']
            return None

        if role == Qt.ToolTipRole:
            mod = self.modmodel[index.row()]
            if col in ('datatype', ):
                val = mod[col]
                return self._datatypes[
                    val] if val in self._datatypes else self._datatypes['udf']
            if col in ('enabled', ):
                val = mod[col]
                return 'Enabled' if val else 'Disabled'
            return str(mod[col])

        if role == Qt.TextAlignmentRole:
            if col in ('size', ):
                # Right|VCenter
                return 0x0082
            if col in (
                    'priority',
                    'installdate',
                    'binFiles',
                    'menuFiles',
                    'settings',
                    'inputs',
                    'contentFiles',
                    'scriptFiles',
            ):
                # HCenter|VCenter
                return 0x0084
            # Left|VCenter
            return 0x0081

        if role == Qt.EditRole:
            if col in (
                    'package',
                    'filename',
                    'category',
                    'priority',
            ):
                mod = self.modmodel[index.row()]
                return str(mod[col])
            return None

        # role used for sorting
        if role == Qt.UserRole:
            mod = self.modmodel[index.row()]
            if col in ('priority', ):
                return f'{int(mod[col]): >20} {mod["filename"]}'
            if col in ('size', ):
                return int(mod[col])
            if col in ('binFiles', 'menuFiles', 'contentFiles', \
                       'scriptFiles', 'settings', 'inputs',):
                return len(mod[col])
            return str(mod[col])

        if role == Qt.DisplayRole:
            if col in ('enabled', ):
                return None
            mod = self.modmodel[index.row()]
            if col in ('datatype', ):
                return str(mod[col]).upper()
            if col in ('priority', ):
                val = mod[col]
                if val <= 0:
                    return 'none'
                return val
            if col in ('installdate', ):
                return mod[col].astimezone(
                    tz=None).strftime('%Y-%m-%d %H:%M:%S')
            if col in ('size', ):
                val = mod[col]
                frm = 'b'
                val /= 1024
                frm = 'K'
                if val // 1024:
                    val /= 1024
                    frm = 'M'
                return '%.1f %s' % (val, frm)
            if col in (
                    'inputs',
                    'settings',
            ):
                val = 0
                for s in mod[col]:
                    for n in s.config.sections():
                        val += len(s.config.items(n))
                return val if val else None

            if col in (
                    'binFiles',
                    'menuFiles',
                    'contentFiles',
                    'scriptFiles',
            ):
                val = len(mod[col])
                if val < 1:
                    return ''
                return val
            return str(mod[col])

        return None
 def columnCount(self, parent=QModelIndex()):
     """Number of columns in the model."""
     return len(self.header) or len(next(iter(self._main_data), []))
Beispiel #22
0
 def columnCount(self, parent=QModelIndex()):
     return 2
Beispiel #23
0
 def activateFirstItem(self):
     self.exportDoubleClicked(self.model.index(0, 0, QModelIndex()))
Beispiel #24
0
 def rowCount(self, parent=QModelIndex()):
     return 1
Beispiel #25
0
    def removeRows(self, position, rows=1, index=QModelIndex()):
        self.beginRemoveRows(QModelIndex(), position, position + rows - 1)
        del self.nutrients[position:position + rows]
        self.endRemoveRows()

        return True
Beispiel #26
0
 def rowCount(self, parent=QModelIndex()):
     return len(self._benchmarks) + 1
Beispiel #27
0
 def columnCount(self, index=QModelIndex()):
     return len(nut_col_to_attr)
Beispiel #28
0
 def _on_project_activated(self, index: QModelIndex):
     true_index = self.model.index(index.row(), 0)
     item = self.model.itemFromIndex(true_index)
     self.current_project = item.data()
     self.hide()
     locator.get_static("StateMachine").transition("Loading")
Beispiel #29
0
 def index(self, row, column, parentIndex=QModelIndex()):
     """ Returns the index of the item in the model specified by the given row, column and parent index. """
     if not self.hasIndex(row, column, parentIndex):
         return QModelIndex()
     parent = self.nodeFromIndex(parentIndex)
     return self.createIndex(row, column, parent.child(row))
Beispiel #30
0
 def flight(index: QModelIndex) -> Flight:
     return index.data(PackageModel.FlightRole)