signature stringlengths 8 3.44k | body stringlengths 0 1.41M | docstring stringlengths 1 122k | id stringlengths 5 17 |
|---|---|---|---|
def __init__(self, parent, model=None, read_only=False, message=None): | LOGGER.debug("<STR_LIT>".format(self.__class__.__name__))<EOL>umbra.ui.views.Abstract_QTreeView.__init__(self, parent, read_only, message)<EOL>self.__tree_view_indentation = <NUM_LIT:15><EOL>self.setModel(model)<EOL>Projects_QTreeView.__initialize_ui(self)<EOL> | Initializes the class.
:param parent: Object parent.
:type parent: QObject
:param model: Model.
:type model: QObject
:param read_only: View is read only.
:type read_only: bool
:param message: View default message when Model is empty.
:type message: unicode | f13137:c0:m0 |
@property<EOL><INDENT>def tree_view_indentation(self):<DEDENT> | return self.__tree_view_indentation<EOL> | Property for **self.__tree_view_indentation** attribute.
:return: self.__tree_view_indentation.
:rtype: int | f13137:c0:m1 |
@tree_view_indentation.setter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def tree_view_indentation(self, value):<DEDENT> | raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL> | Setter for **self.__tree_view_indentation** attribute.
:param value: Attribute value.
:type value: int | f13137:c0:m2 |
@tree_view_indentation.deleter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def tree_view_indentation(self):<DEDENT> | raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL> | Deleter for **self.__tree_view_indentation** attribute. | f13137:c0:m3 |
def __initialize_ui(self): | self.setAutoScroll(True)<EOL>self.setIndentation(self.__tree_view_indentation)<EOL>self.setRootIsDecorated(False)<EOL>self.setDragDropMode(QAbstractItemView.DragOnly)<EOL>self.header().hide()<EOL>self.setSortingEnabled(True)<EOL>self.sortByColumn(<NUM_LIT:0>, Qt.AscendingOrder)<EOL>self.__set_default_ui_state()<EOL>self.model().modelReset.connect(self.__set_default_ui_state)<EOL> | Initializes the Widget ui. | f13137:c0:m4 |
def __set_default_ui_state(self): | LOGGER.debug("<STR_LIT>")<EOL>if not self.model():<EOL><INDENT>return<EOL><DEDENT>self.expandAll()<EOL> | Sets the Widget default ui state. | f13137:c0:m5 |
def setModel(self, model): | LOGGER.debug("<STR_LIT>".format(model))<EOL>if not model:<EOL><INDENT>return<EOL><DEDENT>umbra.ui.views.Abstract_QTreeView.setModel(self, model)<EOL> | Reimplements the **umbra.ui.views.Abstract_QTreeView.setModel** method.
:param model: Model to set.
:type model: QObject | f13137:c0:m6 |
def __init__(self, parent, *args, **kwargs): | LOGGER.debug("<STR_LIT>".format(self.__class__.__name__))<EOL>QSortFilterProxyModel.__init__(self, parent, *args, **kwargs)<EOL>color = "<STR_LIT>"<EOL>self.__editor_node_format = "<STR_LIT>"<EOL>self.__file_node_format = "<STR_LIT>".format(color.format(<NUM_LIT>, <NUM_LIT>, <NUM_LIT>))<EOL>self.__directory_node_format = "<STR_LIT>"<EOL>self.__project_node_format = "<STR_LIT>"<EOL>self.__default_project_node_format = "<STR_LIT>"<EOL> | Initializes the class.
:param parent: Object parent.
:type parent: QObject
:param \*args: Arguments.
:type \*args: \*
:param \*\*kwargs: Keywords arguments.
:type \*\*kwargs: \*\* | f13138:c0:m0 |
def filterAcceptsRow(self, row, parent): | child = self.sourceModel().get_node(parent).child(row)<EOL>if isinstance(child, EditorNode):<EOL><INDENT>return False<EOL><DEDENT>return True<EOL> | Reimplements the :meth:`QSortFilterProxyModel.filterAcceptsRow` method.
:param row: Source row.
:type row: int
:param parent: Source parent.
:type parent: QModelIndex
:return: Filter result
:rtype: bool | f13138:c0:m1 |
def data(self, index, role=Qt.DisplayRole): | if role == Qt.DisplayRole:<EOL><INDENT>node = self.get_node(index)<EOL>if node.family == "<STR_LIT>":<EOL><INDENT>data = self.__editor_node_format.format(node.name)<EOL><DEDENT>elif node.family == "<STR_LIT>":<EOL><INDENT>data = self.__file_node_format.format(node.name)<EOL><DEDENT>elif node.family == "<STR_LIT>":<EOL><INDENT>data = self.__directory_node_format.format(node.name)<EOL><DEDENT>elif node.family == "<STR_LIT>":<EOL><INDENT>if node is self.sourceModel().default_project_node:<EOL><INDENT>data = self.__default_project_node_format.format(node.name)<EOL><DEDENT>else:<EOL><INDENT>data = self.__project_node_format.format(node.name)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>data = QVariant()<EOL><DEDENT>return data<EOL><DEDENT>else:<EOL><INDENT>return QSortFilterProxyModel.data(self, index, role)<EOL><DEDENT> | Reimplements the :meth:`QSortFilterProxyModel.data` method.
:param index: Index.
:type index: QModelIndex
:param role: Role.
:type role: int
:return: Data.
:rtype: QVariant | f13138:c0:m2 |
def get_node(self, index): | index = self.mapToSource(index)<EOL>if not index.isValid():<EOL><INDENT>return self.sourceModel().root_node<EOL><DEDENT>return index.internalPointer() or self.sourceModel().root_node<EOL> | Returns the Node at given index.
:param index: Index.
:type index: QModelIndex
:return: Node.
:rtype: AbstractCompositeNode | f13138:c0:m3 |
def get_attribute(self, *args): | pass<EOL> | Reimplements requisite method. | f13138:c0:m4 |
def __init__(self): | LOGGER.debug("<STR_LIT>".format(self.__class__.__name__))<EOL>self.__roles = None<EOL>self.__flags = None<EOL>self.__trigger_model = False<EOL> | Initializes the class. | f13139:c0:m0 |
@property<EOL><INDENT>def roles(self):<DEDENT> | return self.__roles<EOL> | Property for **self.__roles** attribute.
:return: self.__roles.
:rtype: dict | f13139:c0:m1 |
@roles.setter<EOL><INDENT>@foundations.exceptions.handle_exceptions(AssertionError)<EOL>def roles(self, value):<DEDENT> | if value is not None:<EOL><INDENT>assert type(value) is dict, "<STR_LIT>".format("<STR_LIT>", value)<EOL>for key in value:<EOL><INDENT>assert type(key) is Qt.ItemDataRole, "<STR_LIT>".format(<EOL>"<STR_LIT>", key)<EOL><DEDENT><DEDENT>self.__roles = value<EOL> | Setter for **self.__roles** attribute.
:param value: Attribute value.
:type value: dict | f13139:c0:m2 |
@roles.deleter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def roles(self):<DEDENT> | raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL> | Deleter for **self.__roles** attribute. | f13139:c0:m3 |
@property<EOL><INDENT>def flags(self):<DEDENT> | return self.__flags<EOL> | Property for **self.__flags** attribute.
:return: self.__flags.
:rtype: int | f13139:c0:m4 |
@flags.setter<EOL><INDENT>@foundations.exceptions.handle_exceptions(AssertionError)<EOL>def flags(self, value):<DEDENT> | if value is not None:<EOL><INDENT>assert type(value) is int, "<STR_LIT>".format("<STR_LIT>", value)<EOL><DEDENT>self.__flags = value<EOL> | Setter for **self.__flags** attribute.
:param value: Attribute value.
:type value: int | f13139:c0:m5 |
@flags.deleter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def flags(self):<DEDENT> | raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL> | Deleter for **self.__flags** attribute. | f13139:c0:m6 |
@property<EOL><INDENT>def trigger_model(self):<DEDENT> | return self.__trigger_model<EOL> | Property for **self.__trigger_model** attribute.
:return: self.__trigger_model.
:rtype: bool | f13139:c0:m7 |
@trigger_model.setter<EOL><INDENT>@foundations.exceptions.handle_exceptions(AssertionError)<EOL>def trigger_model(self, value):<DEDENT> | if value is not None:<EOL><INDENT>assert type(value) is bool, "<STR_LIT>".format("<STR_LIT>", value)<EOL><DEDENT>self.__trigger_model = value<EOL> | Setter for **self.__trigger_model** attribute.
:param value: Attribute value.
:type value: bool | f13139:c0:m8 |
@trigger_model.deleter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def trigger_model(self):<DEDENT> | raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL> | Deleter for **self.__trigger_model** attribute. | f13139:c0:m9 |
def __init__(self, name=None, value=None, roles=None, flags=None, **kwargs): | LOGGER.debug("<STR_LIT>".format(self.__class__.__name__))<EOL>Attribute.__init__(self, name, value, **kwargs)<EOL>Mixin_GraphModelObject.__init__(self)<EOL>self.roles = roles or {Qt.DisplayRole: value, Qt.EditRole: value}<EOL>self.flags = flags or int(Qt.ItemIsSelectable | Qt.ItemIsEditable | Qt.ItemIsEnabled)<EOL> | Initializes the class.
:param name: Attribute name.
:type name: unicode
:param value: Attribute value.
:type value: object
:param roles: Roles.
:type roles: dict
:param flags: Flags.
:type flags: int
:param \*\*kwargs: Keywords arguments.
:type \*\*kwargs: \*\* | f13139:c1:m0 |
def __setattr__(self, attribute, value): | current_value = getattr(self, attribute, None)<EOL>Attribute.__setattr__(self, attribute, value)<EOL>if not attribute in ("<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>"):<EOL><INDENT>return<EOL><DEDENT>trigger_model = getattr(self, "<STR_LIT>", False)<EOL>if trigger_model and value is not current_value:<EOL><INDENT>self.attribute_changed()<EOL><DEDENT> | Reimplements the :meth:`foundations.nodes.Attribute.__setattr__` method.
:param attribute: Attribute.
:type attribute: object
:param value: Value.
:type value: object | f13139:c1:m1 |
def attribute_changed(self): | for model in umbra.ui.models.GraphModel.find_model(self):<EOL><INDENT>headers = model.horizontal_headers.values()<EOL>if not self.name in headers:<EOL><INDENT>continue<EOL><DEDENT>model.attribute_changed(model.find_node(self), headers.index(self.name))<EOL><DEDENT>return True<EOL> | Triggers the host model(s) :meth:`umbra.ui.models.GraphModel.attribute_changed` method.
:return: Method success.
:rtype: bool | f13139:c1:m2 |
def __init__(self, name=None, parent=None, children=None, roles=None, flags=None, **kwargs): | LOGGER.debug("<STR_LIT>".format(self.__class__.__name__))<EOL>AbstractCompositeNode.__init__(self, name, parent, children, **kwargs)<EOL>Mixin_GraphModelObject.__init__(self)<EOL>self.roles = roles or {Qt.DisplayRole: self.name, Qt.EditRole: self.name}<EOL>self.flags = flags or int(Qt.ItemIsSelectable | Qt.ItemIsEditable | Qt.ItemIsEnabled | Qt.ItemIsDragEnabled)<EOL> | Initializes the class.
:param name: Node name.
:type name: unicode
:param parent: Node parent.
:type parent: AbstractNode or AbstractCompositeNode
:param children: Children.
:type children: list
:param roles: Roles.
:type roles: dict
:param flags: Flags. ( Qt.ItemFlag )
:param \*\*kwargs: Keywords arguments.
:type \*\*kwargs: \*\* | f13139:c2:m0 |
def __setattr__(self, attribute, value): | current_value = getattr(self, attribute, None)<EOL>AbstractCompositeNode.__setattr__(self, attribute, value)<EOL>if not attribute in ("<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>"):<EOL><INDENT>return<EOL><DEDENT>trigger_model = getattr(self, "<STR_LIT>", False)<EOL>if trigger_model and value is not current_value:<EOL><INDENT>self.node_changed()<EOL><DEDENT> | Reimplements the :meth:`foundations.nodes.AbstractCompositeNode.__setattr__` method.
:param attribute.: Attribute.
:type attribute.: object
:param value.: Value.
:type value.: object | f13139:c2:m1 |
def node_changed(self): | for model in umbra.ui.models.GraphModel.find_model(self):<EOL><INDENT>model.node_changed(self)<EOL><DEDENT>return True<EOL> | Triggers the host model(s) :meth:`umbra.ui.models.GraphModel.node_changed` method.
:return: Method success.
:rtype: bool | f13139:c2:m2 |
def __init__(self, name=None, parent=None, children=None, **kwargs): | LOGGER.debug("<STR_LIT>".format(self.__class__.__name__))<EOL>AbstractCompositeNode.__init__(self, name, parent, children, **kwargs)<EOL> | Initializes the class.
:param name: Node name.
:type name: unicode
:param parent: Node parent.
:type parent: AbstractCompositeNode
:param children: Children.
:type children: list
:param \*\*kwargs: Keywords arguments.
:type \*\*kwargs: \*\* | f13139:c3:m0 |
def __init__(self, name=None, parent=None, children=None, format=None, **kwargs): | LOGGER.debug("<STR_LIT>".format(self.__class__.__name__))<EOL>AbstractCompositeNode.__init__(self, name, parent, children, **kwargs)<EOL>self.__format = None<EOL>self.format = format<EOL> | Initializes the class.
:param name: Node name.
:type name: unicode
:param parent: Node parent.
:type parent: AbstractNode or AbstractCompositeNode
:param children: Children.
:type children: list
:param format: Format.
:type format: object
:param \*\*kwargs: Keywords arguments.
:type \*\*kwargs: \*\* | f13139:c4:m0 |
@property<EOL><INDENT>def format(self):<DEDENT> | return self.__format<EOL> | Property for **self.__format** attribute.
:return: self.__format.
:rtype: object | f13139:c4:m1 |
@format.setter<EOL><INDENT>def format(self, value):<DEDENT> | self.__format = value<EOL> | Setter for **self.__format** attribute.
:param value: Attribute value.
:type value: object | f13139:c4:m2 |
@format.deleter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def format(self):<DEDENT> | raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL> | Deleter for **self.__format** attribute. | f13139:c4:m3 |
def eventFilter(self, object, event): | if event.type() == QEvent.MouseButtonDblClick:<EOL><INDENT>view = object.parent()<EOL>if view.read_only:<EOL><INDENT>self.__raise_user_error(view)<EOL>return True<EOL><DEDENT><DEDENT>return False<EOL> | Reimplements the **QObject.eventFilter** method.
:param object: Object.
:type object: QObject
:param event: Event.
:type event: QEvent
:return: Event filtered.
:rtype: bool | f13140:c0:m0 |
@foundations.exceptions.handle_exceptions(umbra.exceptions.notify_exception_handler,<EOL>foundations.exceptions.UserError)<EOL><INDENT>def __raise_user_error(self, view):<DEDENT> | raise foundations.exceptions.UserError("<STR_LIT>".format(<EOL>self.__class__.__name__, view.objectName() or view))<EOL> | Raises an error if the given View has been set read only and the user attempted to edit its content.
:param view: View.
:type view: QWidget | f13140:c0:m1 |
def __init__(self, message=None): | LOGGER.debug("<STR_LIT>".format(self.__class__.__name__))<EOL>self.__message = None<EOL>self.message = message or "<STR_LIT>"<EOL>self.__notifier = Notification_QLabel(self,<EOL>color=QColor(<NUM_LIT>, <NUM_LIT>, <NUM_LIT>),<EOL>background_color=QColor(<NUM_LIT>, <NUM_LIT>, <NUM_LIT>),<EOL>border_color=QColor(<NUM_LIT:32>, <NUM_LIT:32>, <NUM_LIT:32>),<EOL>anchor=<NUM_LIT:8>)<EOL> | Initializes the class.
:param parent: Object parent.
:type parent: QObject
:param message: View default message when Model is empty.
:type message: unicode | f13140:c1:m0 |
@property<EOL><INDENT>def message(self):<DEDENT> | return self.__message<EOL> | Property for **self.__message** attribute.
:return: self.__message.
:rtype: unicode | f13140:c1:m1 |
@message.setter<EOL><INDENT>@foundations.exceptions.handle_exceptions(AssertionError)<EOL>def message(self, value):<DEDENT> | if value is not None:<EOL><INDENT>assert type(value) in (unicode, QString),"<STR_LIT>".format("<STR_LIT:message>", value)<EOL><DEDENT>self.__message = value<EOL> | Setter for **self.__message** attribute.
:param value: Attribute value.
:type value: unicode | f13140:c1:m2 |
@message.deleter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def message(self):<DEDENT> | raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT:message>"))<EOL> | Deleter for **self.__message** attribute. | f13140:c1:m3 |
def resizeEvent(self, event): | super(type(self), self).resizeEvent(event)<EOL>self.__notifier.refresh_position()<EOL> | Reimplements the :meth:`*.resizeEvent` method.
:param event: QEvent.
:type event: QEvent | f13140:c1:m4 |
def paintEvent(self, event): | super(type(self), self).paintEvent(event)<EOL>show_message = True<EOL>model = self.model()<EOL>if issubclass(type(model), GraphModel):<EOL><INDENT>if model.has_nodes():<EOL><INDENT>show_message = False<EOL><DEDENT><DEDENT>elif issubclass(type(model), QAbstractItemModel) orissubclass(type(model), QAbstractListModel) orissubclass(type(model), QAbstractTableModel):<EOL><INDENT>if model.rowCount():<EOL><INDENT>show_message = False<EOL><DEDENT><DEDENT>if show_message:<EOL><INDENT>self.__notifier.show_message(self.__message, <NUM_LIT:0>)<EOL><DEDENT>else:<EOL><INDENT>self.__notifier.hide_message()<EOL><DEDENT> | Reimplements the :meth:`*.paintEvent` method.
:param event: QEvent.
:type event: QEvent | f13140:c1:m5 |
def __init__(self, read_only=None, message=None): | LOGGER.debug("<STR_LIT>".format(self.__class__.__name__))<EOL>Mixin_AbstractBase.__init__(self, message or "<STR_LIT>")<EOL>self.__read_only = read_only<EOL>Mixin_AbstractView.__initialize_ui(self)<EOL> | Initializes the class.
:param parent: Object parent.
:type parent: QObject
:param read_only: View is read only.
:type read_only: bool
:param message: View default message when Model is empty.
:type message: unicode | f13140:c2:m0 |
@property<EOL><INDENT>def read_only(self):<DEDENT> | return self.__read_only<EOL> | Property for **self.__read_only** attribute.
:return: self.__read_only.
:rtype: bool | f13140:c2:m1 |
@read_only.setter<EOL><INDENT>@foundations.exceptions.handle_exceptions(AssertionError)<EOL>def read_only(self, value):<DEDENT> | if value is not None:<EOL><INDENT>assert type(value) is bool, "<STR_LIT>".format("<STR_LIT>", value)<EOL><DEDENT>self.__read_only = value<EOL> | Setter for **self.__read_only** attribute.
:param value: Attribute value.
:type value: bool | f13140:c2:m2 |
@read_only.deleter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def read_only(self):<DEDENT> | raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL> | Deleter for **self.__read_only** attribute. | f13140:c2:m3 |
def __initialize_ui(self): | self.viewport().installEventFilter(ReadOnlyFilter(self))<EOL>if issubclass(type(self), QListView):<EOL><INDENT>super(type(self), self).setUniformItemSizes(True)<EOL><DEDENT>elif issubclass(type(self), QTreeView):<EOL><INDENT>super(type(self), self).setUniformRowHeights(True)<EOL><DEDENT> | Initializes the View ui. | f13140:c2:m4 |
def get_nodes(self): | return [node for node in foundations.walkers.nodes_walker(self.model().root_node)]<EOL> | Returns the View nodes.
:return: View nodes.
:rtype: list | f13140:c2:m5 |
def filter_nodes(self, pattern, attribute, flags=re.IGNORECASE): | return [node for node in self.get_nodes() if re.search(pattern, getattr(node, attribute), flags)]<EOL> | Filters the View Nodes on given attribute using given pattern.
:param pattern: Filtering pattern.
:type pattern: unicode
:param attribute: Filtering attribute.
:type attribute: unicode
:param flags: Regex filtering flags.
:type flags: int
:return: View filtered nodes.
:rtype: list | f13140:c2:m6 |
@foundations.exceptions.handle_exceptions(NotImplementedError)<EOL><INDENT>def get_view_nodes_from_indexes(self, *indexes):<DEDENT> | nodes = {}<EOL>model = self.model()<EOL>if not model:<EOL><INDENT>return nodes<EOL><DEDENT>if not hasattr(model, "<STR_LIT>"):<EOL><INDENT>raise NotImplementedError(<EOL>"<STR_LIT>".format(__name__, model))<EOL><DEDENT>if not hasattr(model, "<STR_LIT>"):<EOL><INDENT>raise NotImplementedError(<EOL>"<STR_LIT>".format(__name__, model))<EOL><DEDENT>for index in indexes:<EOL><INDENT>node = model.get_node(index)<EOL>if not node in nodes:<EOL><INDENT>nodes[node] = []<EOL><DEDENT>attribute = model.get_attribute(node, index.column())<EOL>attribute and nodes[node].append(attribute)<EOL><DEDENT>return nodes<EOL> | Returns the View Nodes from given indexes.
:param view: View.
:type view: QWidget
:param \*indexes: Indexes.
:type \*indexes: list
:return: View nodes.
:rtype: dict | f13140:c2:m7 |
def get_view_selected_nodes(self): | return self.get_view_nodes_from_indexes(*self.selectedIndexes())<EOL> | Returns the View selected nodes.
:param view: View.
:type view: QWidget
:return: View selected nodes.
:rtype: dict | f13140:c2:m8 |
def get_selected_nodes(self): | return self.get_view_selected_nodes()<EOL> | Returns the View selected nodes.
:return: View selected nodes.
:rtype: dict | f13140:c2:m9 |
def select_view_indexes(self, indexes, flags=QItemSelectionModel.Select | QItemSelectionModel.Rows): | if self.selectionModel():<EOL><INDENT>selection = QItemSelection()<EOL>for index in indexes:<EOL><INDENT>selection.merge(QItemSelection(index, index), flags)<EOL><DEDENT>self.selectionModel().select(selection, flags)<EOL><DEDENT>return True<EOL> | Selects the View given indexes.
:param view: View.
:type view: QWidget
:param indexes: Indexes to select.
:type indexes: list
:param flags: Selection flags. ( QItemSelectionModel.SelectionFlags )
:return: Definition success.
:rtype: bool | f13140:c2:m10 |
def select_indexes(self, indexes, flags=QItemSelectionModel.Select | QItemSelectionModel.Rows): | return self.select_view_indexes(indexes, flags)<EOL> | Selects given indexes.
:param indexes: Indexes to select.
:type indexes: list
:param flags: Selection flags. ( QItemSelectionModel.SelectionFlags )
:return: Method success.
:rtype: bool | f13140:c2:m11 |
def __init__(self, parent=None, read_only=False, message=None): | LOGGER.debug("<STR_LIT>".format(self.__class__.__name__))<EOL>QListView.__init__(self, parent)<EOL>Mixin_AbstractView.__init__(self, read_only, message)<EOL> | Initializes the class.
:param parent: Object parent.
:type parent: QObject
:param read_only: View is read only.
:type read_only: bool
:param message: View default message when Model is empty.
:type message: unicode | f13140:c4:m0 |
def __init__(self, parent=None, read_only=False, message=None): | LOGGER.debug("<STR_LIT>".format(self.__class__.__name__))<EOL>QTableView.__init__(self, parent)<EOL>Mixin_AbstractView.__init__(self, read_only, message)<EOL> | Initializes the class.
:param parent: Object parent.
:type parent: QObject
:param read_only: View is read only.
:type read_only: bool
:param message: View default message when Model is empty.
:type message: unicode | f13140:c5:m0 |
def __init__(self, parent=None, read_only=False, message=None): | LOGGER.debug("<STR_LIT>".format(self.__class__.__name__))<EOL>QTreeView.__init__(self, parent)<EOL>Mixin_AbstractView.__init__(self, read_only, message)<EOL> | Initializes the class.
:param parent: Object parent.
:type parent: QObject
:param read_only: View is read only.
:type read_only: bool
:param message: View default message when Model is empty.
:type message: unicode | f13140:c6:m0 |
def __init__(self, parent=None, message=None): | LOGGER.debug("<STR_LIT>".format(self.__class__.__name__))<EOL>QListWidget.__init__(self, parent)<EOL>Mixin_AbstractWidget.__init__(self, message)<EOL> | Initializes the class.
:param parent: Object parent.
:type parent: QObject
:param message: View default message when Model is empty.
:type message: unicode | f13140:c7:m0 |
def __init__(self, parent=None, read_only=False, message=None): | LOGGER.debug("<STR_LIT>".format(self.__class__.__name__))<EOL>QTableWidget.__init__(self, parent)<EOL>Mixin_AbstractWidget.__init__(self, message)<EOL> | Initializes the class.
:param parent: Object parent.
:type parent: QObject
:param message: View default message when Model is empty.
:type message: unicode | f13140:c8:m0 |
def __init__(self, parent=None, message=None): | LOGGER.debug("<STR_LIT>".format(self.__class__.__name__))<EOL>QTreeWidget.__init__(self, parent)<EOL>Mixin_AbstractWidget.__init__(self, message)<EOL> | Initializes the class.
:param parent: Object parent.
:type parent: QObject
:param message: View default message when Model is empty.
:type message: unicode | f13140:c9:m0 |
def __init__(self, parent=None, language=None, tokens=None): | LOGGER.debug("<STR_LIT>".format(self.__class__.__name__))<EOL>self.__language = None<EOL>self.language = language<EOL>self.__set_cache(tokens)<EOL>QCompleter.__init__(self,<EOL>DefaultCompleter._DefaultCompleter__tokens[self.__language], parent)<EOL>self.setCaseSensitivity(Qt.CaseSensitive)<EOL>self.setCompletionMode(QCompleter.PopupCompletion)<EOL> | Initializes the class.
:param parent: Object parent.
:type parent: QObject
:param language: Language name.
:type language: unicode
:param tokens: Completer tokens list.
:type tokens: tuple or list | f13141:c0:m0 |
@property<EOL><INDENT>def language(self):<DEDENT> | return self.__language<EOL> | Property for **self.__language** attribute.
:return: self.__language.
:rtype: unicode | f13141:c0:m1 |
@language.setter<EOL><INDENT>@foundations.exceptions.handle_exceptions(AssertionError)<EOL>def language(self, value):<DEDENT> | if value is not None:<EOL><INDENT>assert type(value) is unicode, "<STR_LIT>".format(<EOL>"<STR_LIT>", value)<EOL><DEDENT>self.__language = value<EOL> | Setter for **self.__language** attribute.
:param value: Attribute value.
:type value: unicode | f13141:c0:m2 |
@language.deleter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def language(self):<DEDENT> | raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL> | Deleter for **self.__language** attribute. | f13141:c0:m3 |
def __set_cache(self, tokens): | if DefaultCompleter._DefaultCompleter__tokens.get(self.__language):<EOL><INDENT>return<EOL><DEDENT>DefaultCompleter._DefaultCompleter__tokens[self.__language] = tokens<EOL> | Sets the tokens cache.
:param tokens: Completer tokens list.
:type tokens: tuple or list | f13141:c0:m4 |
def update_model(self, words): | extended_words = DefaultCompleter._DefaultCompleter__tokens[self.__language][:]<EOL>extended_words.extend((word for word in set(words)<EOL>if word not in DefaultCompleter._DefaultCompleter__tokens[self.__language]))<EOL>self.setModel(QStringListModel(extended_words))<EOL>return True<EOL> | Updates the completer model.
:param words: Words to update the completer with.
:type words: tuple or list
:return: Method success.
:rtype: bool | f13141:c0:m5 |
def __init__(self, **kwargs): | LOGGER.debug("<STR_LIT>".format(self.__class__.__name__))<EOL>foundations.data_structures.Structure.__init__(self, **kwargs)<EOL> | Initializes the class.
:param \*\*kwargs: .
:type \*\*kwargs: dict | f13142:c0:m0 |
def __init__(self,<EOL>parent=None,<EOL>style=None,<EOL>highlightColor=None,<EOL>hoverColor=None,<EOL>background_color=None,<EOL>highlightBackgroundColor=None,<EOL>hoverBackgroundColor=None): | LOGGER.debug("<STR_LIT>".format(self.__class__.__name__))<EOL>QStyledItemDelegate.__init__(self, parent)<EOL>self.__indent = <NUM_LIT:5><EOL>self.__label = QLabel()<EOL>self.__label.setIndent(self.__indent)<EOL>self.__label.setTextFormat(Qt.RichText)<EOL>self.__default_style = Style(default="""<STR_LIT>""",<EOL>hover="""<STR_LIT>""",<EOL>highlight="""<STR_LIT>""")<EOL>self.__style = self.__default_style<EOL>self.style = style or self.__style<EOL> | Initializes the class.
:param parent: Widget parent.
:type parent: QObject
:param style: Style.
:type style: Style | f13142:c1:m0 |
@property<EOL><INDENT>def style(self):<DEDENT> | return self.__style<EOL> | Property for **self.__style** attribute.
:return: self.__style.
:rtype: Style | f13142:c1:m1 |
@style.setter<EOL><INDENT>@foundations.exceptions.handle_exceptions(AssertionError)<EOL>def style(self, value):<DEDENT> | if value is not None:<EOL><INDENT>assert type(value) is Style, "<STR_LIT>".format("<STR_LIT>", value)<EOL>style = Style()<EOL>for item in (self.__default_style, value):<EOL><INDENT>style.update(item)<EOL><DEDENT>value = style<EOL><DEDENT>self.__style = value<EOL> | Setter for **self.__style** attribute.
:param value: Attribute value.
:type value: Style | f13142:c1:m2 |
@style.deleter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def style(self):<DEDENT> | raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL> | Deleter for **self.__style** attribute. | f13142:c1:m3 |
def paint(self, painter, option, index): | if option.state & QStyle.State_MouseOver:<EOL><INDENT>styleSheet = self.__style.hover<EOL><DEDENT>elif option.state & QStyle.State_Selected:<EOL><INDENT>styleSheet = self.__style.highlight<EOL><DEDENT>else:<EOL><INDENT>styleSheet = self.__style.default<EOL><DEDENT>self.__label.setStyleSheet(styleSheet)<EOL>data = index.model().data(index, Qt.DisplayRole)<EOL>self.__label.setText(umbra.ui.common.QVariant_to_string(data))<EOL>self.__label.setFixedSize(option.rect.size())<EOL>painter.save()<EOL>painter.translate(option.rect.topLeft())<EOL>self.__label.render(painter)<EOL>painter.restore()<EOL> | Reimplements the :meth:`QStyledItemDelegate.paint` method. | f13142:c1:m4 |
def sizeHint(self, option, index): | document = QTextDocument()<EOL>document.setDefaultFont(option.font)<EOL>data = index.model().data(index)<EOL>text = umbra.ui.common.QVariant_to_string(data)<EOL>self.__label.setText(text)<EOL>document.setHtml(text)<EOL>return QSize(document.idealWidth() + self.__indent, option.fontMetrics.height())<EOL> | Reimplements the :meth:`QStyledItemDelegate.sizeHint` method. | f13142:c1:m5 |
def __init__(self, **kwargs): | LOGGER.debug("<STR_LIT>".format(self.__class__.__name__))<EOL>foundations.data_structures.Structure.__init__(self, **kwargs)<EOL> | Initializes the class.
:param \*\*kwargs: pattern, format.
:type \*\*kwargs: dict | f13143:c0:m0 |
def __init__(self, theme=None): | LOGGER.debug("<STR_LIT>".format(self.__class__.__name__))<EOL>self.__root_node = DefaultNode("<STR_LIT>")<EOL>self._FormatsTree__initialize_tree(theme or DEFAULT_THEME)<EOL> | Initializes the class.
:param theme: Theme.
:type theme: dict | f13143:c1:m0 |
@property<EOL><INDENT>def root_node(self):<DEDENT> | return self.__root_node<EOL> | Property for **self.__root_node** attribute.
:return: self.__root_node.
:rtype: AbstractCompositeNode | f13143:c1:m1 |
@root_node.setter<EOL><INDENT>@foundations.exceptions.handle_exceptions(AssertionError)<EOL>def root_node(self, value):<DEDENT> | if value is not None:<EOL><INDENT>assert issubclass(value.__class__, AbstractCompositeNode),"<STR_LIT>".format(<EOL>"<STR_LIT>", value, AbstractCompositeNode.__name__)<EOL><DEDENT>self.__root_node = value<EOL> | Setter for **self.__root_node** attribute.
:param value: Attribute value.
:type value: AbstractCompositeNode | f13143:c1:m2 |
@root_node.deleter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def root_node(self):<DEDENT> | raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".root_node(self.__class__.__name__, "<STR_LIT>"))<EOL> | Deleter for **self.__root_node** attribute. | f13143:c1:m3 |
def __initialize_tree(self, theme): | for item in sorted(theme):<EOL><INDENT>current_node = self.__root_node<EOL>for format in item.split("<STR_LIT:.>"):<EOL><INDENT>nodes = [node for node in current_node.children if node.name == format]<EOL>format_node = foundations.common.get_first_item(nodes)<EOL>if not format_node:<EOL><INDENT>format_node = FormatNode(format, format=theme[item])<EOL>current_node.add_child(format_node)<EOL><DEDENT>current_node = format_node<EOL><DEDENT><DEDENT> | Initializes the object formats tree.
:param theme: Theme.
:type theme: dict | f13143:c1:m4 |
def list_formats(self, node, path=(), formats=None): | if formats == None:<EOL><INDENT>formats = []<EOL><DEDENT>for child in node.children:<EOL><INDENT>self.list_formats(child, path + (child.name,), formats)<EOL><DEDENT>path and formats.append("<STR_LIT:.>".join(path))<EOL>return sorted(formats)<EOL> | Lists the object formats in sorted order.
:param node: Root node to start listing the formats from.
:type node: AbstractCompositeNode
:param path: Walked paths.
:type path: tuple
:param formats: Formats.
:type formats: list
:return: Formats.
:rtype: list | f13143:c1:m5 |
@foundations.decorators.memoize(None)<EOL><INDENT>def get_format(self, name):<DEDENT> | formats = [format for format in self.list_formats(self.__root_node) if format in name]<EOL>if not formats:<EOL><INDENT>return QTextCharFormat()<EOL><DEDENT>name = max(formats)<EOL>format = None<EOL>current_node = self.__root_node<EOL>for selector in name.split("<STR_LIT:.>"):<EOL><INDENT>nodes = [node for node in current_node.children if node.name == selector]<EOL>format_node = nodes and nodes[<NUM_LIT:0>] or None<EOL>if not format_node:<EOL><INDENT>break<EOL><DEDENT>current_node = format_node<EOL>if not format_node.format:<EOL><INDENT>continue<EOL><DEDENT>format = format_node.format<EOL><DEDENT>return format<EOL> | Returns the closest format or closest parent format associated to given name.
:param name: Format name.
:type name: unicode
:return: Format.
:rtype: QTextCharFormat | f13143:c1:m6 |
def __init__(self, parent=None): | LOGGER.debug("<STR_LIT>".format(self.__class__.__name__))<EOL>QSyntaxHighlighter.__init__(self, parent)<EOL>self.__formats = None<EOL>self.__rules = None<EOL> | Initializes the class.
:param parent: Widget parent.
:type parent: QObject | f13143:c2:m0 |
@property<EOL><INDENT>def formats(self):<DEDENT> | return self.__formats<EOL> | Property for **self.__formats** attribute.
:return: self.__formats.
:rtype: FormatsTree | f13143:c2:m1 |
@formats.setter<EOL><INDENT>@foundations.exceptions.handle_exceptions(AssertionError)<EOL>def formats(self, value):<DEDENT> | if value is not None:<EOL><INDENT>assert type(value) is FormatsTree, "<STR_LIT>".format(<EOL>"<STR_LIT>", value)<EOL><DEDENT>self.__formats = value<EOL> | Setter for **self.__formats** attribute.
:param value: Attribute value.
:type value: FormatsTree | f13143:c2:m2 |
@formats.deleter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def formats(self):<DEDENT> | raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL> | Deleter for **self.__formats** attribute. | f13143:c2:m3 |
@property<EOL><INDENT>def rules(self):<DEDENT> | return self.__rules<EOL> | Property for **self.__rules** attribute.
:return: self.__rules.
:rtype: tuple or list | f13143:c2:m4 |
@rules.setter<EOL><INDENT>@foundations.exceptions.handle_exceptions(AssertionError)<EOL>def rules(self, value):<DEDENT> | if value is not None:<EOL><INDENT>assert type(value) in (tuple, list), "<STR_LIT>".format(<EOL>"<STR_LIT>", value)<EOL><DEDENT>self.__rules = value<EOL> | Setter for **self.__rules** attribute.
:param value: Attribute value.
:type value: tuple or list | f13143:c2:m5 |
@rules.deleter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def rules(self):<DEDENT> | raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL> | Deleter for **self.__rules** attribute. | f13143:c2:m6 |
@foundations.exceptions.handle_exceptions(NotImplementedError)<EOL><INDENT>def highlightBlock(self, block):<DEDENT> | raise NotImplementedError("<STR_LIT>".format(self.__class__.__name__,<EOL>self.highlightBlock.__name__,<EOL>self.__class__.__name__))<EOL> | Reimplements the :meth:`QSyntaxHighlighter.highlightBlock` method.
:param block: Text block.
:type block: QString | f13143:c2:m7 |
def highlight_text(self, text, start, end): | for rule in self.__rules:<EOL><INDENT>index = rule.pattern.indexIn(text, start)<EOL>while index >= start and index < end:<EOL><INDENT>length = rule.pattern.matchedLength()<EOL>format = self.formats.get_format(rule.name) or self.formats.get_format("<STR_LIT:default>")<EOL>self.setFormat(index, min(length, end - index), format)<EOL>index = rule.pattern.indexIn(text, index + length)<EOL><DEDENT><DEDENT>return True<EOL> | Highlights given text.
:param text: Text.
:type text: QString
:param start: Text start index.
:type start: int
:param end: Text end index.
:type end: int
:return: Method success.
:rtype: bool | f13143:c2:m8 |
def __init__(self, parent=None, rules=None, theme=None): | LOGGER.debug("<STR_LIT>".format(self.__class__.__name__))<EOL>AbstractHighlighter.__init__(self, parent)<EOL>self.rules = rules<EOL>self.__theme = None<EOL>self.theme = theme<EOL>self.__set_formats()<EOL> | Initializes the class.
:param parent: Widget parent.
:type parent: QObject
:param rules: Rules.
:type rules: tuple or list
:param theme: Theme.
:type theme: dict | f13143:c3:m0 |
@property<EOL><INDENT>def theme(self):<DEDENT> | return self.__theme<EOL> | Property for **self.__theme** attribute.
:return: self.__theme.
:rtype: dict | f13143:c3:m1 |
@theme.setter<EOL><INDENT>@foundations.exceptions.handle_exceptions(AssertionError)<EOL>def theme(self, value):<DEDENT> | if value is not None:<EOL><INDENT>assert type(value) is dict, "<STR_LIT>".format("<STR_LIT>", value)<EOL><DEDENT>self.__theme = value<EOL> | Setter for **self.__theme** attribute.
:param value: Attribute value.
:type value: dict | f13143:c3:m2 |
@theme.deleter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def theme(self):<DEDENT> | raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL> | Deleter for **self.__theme** attribute. | f13143:c3:m3 |
def __set_formats(self): | self.formats = FormatsTree(self.__theme)<EOL> | Sets the highlighting formats. | f13143:c3:m4 |
def highlightBlock(self, block): | self.highlight_text(block, <NUM_LIT:0>, len(block))<EOL>self.setCurrentBlockState(<NUM_LIT:0>)<EOL>state = <NUM_LIT:1><EOL>for rule in self.rules:<EOL><INDENT>if re.match("<STR_LIT>", rule.name):<EOL><INDENT>format = self.formats.get_format(rule.name) or self.formats.get_format("<STR_LIT:default>")<EOL>if self.highlight_multiline_block(block, rule.pattern,<EOL>foundations.common.get_first_item([item for item in self.rules<EOL>if item.name == rule.name.replace(<EOL>"<STR_LIT:start>", "<STR_LIT:end>")]).pattern, state, format):<EOL><INDENT>break<EOL><DEDENT>state += <NUM_LIT:1><EOL><DEDENT><DEDENT> | Reimplements the :meth:`AbstractHighlighter.highlightBlock` method.
:param block: Text block.
:type block: QString | f13143:c3:m5 |
def highlight_multiline_block(self, block, start_pattern, end_pattern, state, format): | if self.previousBlockState() == state:<EOL><INDENT>start = <NUM_LIT:0><EOL>extend = <NUM_LIT:0><EOL><DEDENT>else:<EOL><INDENT>start = start_pattern.indexIn(block)<EOL>extend = start_pattern.matchedLength()<EOL><DEDENT>while start >= <NUM_LIT:0>:<EOL><INDENT>end = end_pattern.indexIn(block, start + extend)<EOL>if end >= extend:<EOL><INDENT>length = end - start + extend + end_pattern.matchedLength()<EOL>self.setCurrentBlockState(<NUM_LIT:0>)<EOL><DEDENT>else:<EOL><INDENT>self.setCurrentBlockState(state)<EOL>length = block.length() - start + extend<EOL><DEDENT>self.setFormat(start, length, format)<EOL>start = start_pattern.indexIn(block, start + length)<EOL><DEDENT>if self.currentBlockState() == state:<EOL><INDENT>return True<EOL><DEDENT>else:<EOL><INDENT>return False<EOL><DEDENT> | Highlights given multiline text block.
:param block: Text block.
:type block: QString
:param pattern: Start regex pattern.
:type pattern: QRegExp
:param pattern: End regex pattern.
:type pattern: QRegExp
:param format: Format.
:type format: QTextCharFormat
:param state: Block state.
:type state: int
:return: Current block matching state.
:rtype: bool | f13143:c3:m6 |
def __init__(self,<EOL>parent=None,<EOL>default_pixmap=None,<EOL>hover_pixmap=None,<EOL>active_pixmap=None,<EOL>checkable=False,<EOL>checked=False): | LOGGER.debug("<STR_LIT>".format(self.__class__.__name__))<EOL>QLabel.__init__(self, parent)<EOL>self.__default_pixmap = None<EOL>self.default_pixmap = default_pixmap or QPixmap()<EOL>self.__hover_pixmap = None<EOL>self.hover_pixmap = hover_pixmap or QPixmap()<EOL>self.__active_pixmap = None<EOL>self.active_pixmap = active_pixmap or QPixmap()<EOL>self.__checkable = None<EOL>self.checkable = checkable<EOL>self.__checked = None<EOL>self.checked = checked<EOL>self.__menu = None<EOL>if self.__checked:<EOL><INDENT>self.setPixmap(self.__active_pixmap)<EOL><DEDENT>else:<EOL><INDENT>self.setPixmap(self.__default_pixmap)<EOL><DEDENT> | Initializes the class.
:param parent: Widget parent.
:type parent: QObject
:param default_pixmap: Label default pixmap.
:type default_pixmap: QPixmap
:param hover_pixmap: Label hover pixmap.
:type hover_pixmap: QPixmap
:param active_pixmap: Label active pixmap.
:type active_pixmap: QPixmap
:param checkable: Checkable state.
:type checkable: bool
:param checked: Checked state.
:type checked: bool | f13144:c0:m0 |
@property<EOL><INDENT>def default_pixmap(self):<DEDENT> | return self.__default_pixmap<EOL> | Property for **self.__default_pixmap** attribute.
:return: self.__default_pixmap.
:rtype: QPixmap | f13144:c0:m1 |
@default_pixmap.setter<EOL><INDENT>@foundations.exceptions.handle_exceptions(AssertionError)<EOL>def default_pixmap(self, value):<DEDENT> | if value is not None:<EOL><INDENT>assert type(value) is QPixmap, "<STR_LIT>".format(<EOL>"<STR_LIT>", value)<EOL><DEDENT>self.__default_pixmap = value<EOL> | Setter for **self.__default_pixmap** attribute.
:param value: Attribute value.
:type value: QPixmap | f13144:c0:m2 |
@default_pixmap.deleter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def default_pixmap(self):<DEDENT> | raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL> | Deleter for **self.__default_pixmap** attribute. | f13144:c0:m3 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.