Python PyQt5.QtGui.QStandardItem() Examples

The following are 30 code examples for showing how to use PyQt5.QtGui.QStandardItem(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.

You may check out the related API usage on the sidebar.

You may also want to check out all available functions/classes of the module PyQt5.QtGui , or try the search function .

Example 1
Project: qutebrowser   Author: qutebrowser   File: listcategory.py    License: GNU General Public License v3.0 6 votes vote down vote up
def __init__(self,
                 name: str,
                 items: typing.Iterable[_ItemType],
                 sort: bool = True,
                 delete_func: util.DeleteFuncType = None,
                 parent: QWidget = None):
        super().__init__(parent)
        self.name = name
        self.srcmodel = QStandardItemModel(parent=self)
        self._pattern = ''
        # ListCategory filters all columns
        self.columns_to_filter = [0, 1, 2]
        self.setFilterKeyColumn(-1)
        for item in items:
            self.srcmodel.appendRow([QStandardItem(x) for x in item])
        self.setSourceModel(self.srcmodel)
        self.delete_func = delete_func
        self._sort = sort 
Example 2
Project: Lector   Author: BasioMeusPuga   File: dockwidgets.py    License: GNU General Public License v3.0 6 votes vote down vote up
def generate_annotation_model(self):
        # TODO
        # Annotation previews will require creation of a
        # QStyledItemDelegate

        saved_annotations = self.parent.main_window.settings['annotations']
        if not saved_annotations:
            return

        # Create annotation model
        for i in saved_annotations:
            item = QtGui.QStandardItem()
            item.setText(i['name'])
            item.setData(i, QtCore.Qt.UserRole)
            self.parent.annotationModel.appendRow(item)
        self.annotationListView.setModel(self.parent.annotationModel) 
Example 3
Project: detection   Author: xsyann   File: detection.py    License: GNU General Public License v2.0 6 votes vote down vote up
def populateTree(self, node, parent):
        """Create a QTreeView node under 'parent'.
        """
        item = QtGui.QStandardItem(node)
        h, s, v = Detector.getDefaultHSVColor(node)
        color = QColor()
        color.setHsvF(h, s, v)
        item.setIcon(self.getIcon(color))
        # Unique hash for QStandardItem
        key = hash(item)
        while key in self.classifiersParameters:
            key += 1
        item.setData(key)
        cp = ClassifierParameters(item.data(), node, node, color,
                                  self.SHAPE_RECT, self.FILL_OUTLINE)
        self.classifiersParameters[key] = cp
        parent.appendRow(item)
        return item 
Example 4
Project: opcua-modeler   Author: FreeOpcUa   File: refnodesets_widget.py    License: GNU General Public License v3.0 6 votes vote down vote up
def import_nodeset(self, path):
        print("IMPORT", path)
        name = os.path.basename(path)
        if name in self.nodesets:
            return
        try:
            self.server_mgr.import_xml(path)
        except Exception as ex:
            self.error.emit(ex)
            raise

        item = QStandardItem(name)
        self.model.appendRow([item])
        self.nodesets.append(name)
        self.view.expandAll()
        self.nodeset_added.emit(path) 
Example 5
Project: DIE   Author: ynvb   File: FunctionViewEx.py    License: MIT License 6 votes vote down vote up
def _make_nonexec_function_time(self, function_name):
        """
        Build a tree item for a function name (for a non-executed function)
        @type: String
        @param function_name: Function name
        @return:
        """

        item_function = QtGui.QStandardItem(self.die_icons.icon_function, function_name)
        item_function_count = QtGui.QStandardItem("0")

        item_function_count.setEditable(False)
        item_function.setEditable(False)

        item_list = [item_function, item_function_count]

        return item_list 
Example 6
Project: Miyamoto   Author: aboood40091   File: puzzle.py    License: GNU General Public License v3.0 6 votes vote down vote up
def addObj(self):
        global Tileset

        Tileset.addObject(new=True)

        pix = QtGui.QPixmap(24, 24)
        pix.fill(Qt.transparent)

        painter = QtGui.QPainter(pix)
        painter.drawPixmap(0, 0, Tileset.tiles[0].image.scaledToWidth(24, Qt.SmoothTransformation))
        painter.end()
        del painter

        count = len(Tileset.objects)
        item = QtGui.QStandardItem(QtGui.QIcon(pix), 'Object {0}'.format(count-1))
        item.setFlags(item.flags() & ~Qt.ItemIsEditable)
        window.objmodel.appendRow(item)
        index = window.objectList.currentIndex()
        window.objectList.setCurrentIndex(index)
        self.setObject(index)

        window.objectList.update()
        self.update() 
Example 7
Project: eddy   Author: danielepantaleone   File: ontology_explorer.py    License: GNU General Public License v3.0 6 votes vote down vote up
def doAddNode(self, diagram, node):
        """
        Add a node in the tree view.
        :type diagram: QGraphicsScene
        :type node: AbstractItem
        """
        if node.type() in {Item.ConceptNode, Item.RoleNode, Item.AttributeNode, Item.IndividualNode}:
            parent = self.parentFor(node)
            if not parent:
                parent = QtGui.QStandardItem(self.parentKey(node))
                parent.setIcon(self.iconFor(node))
                self.model.appendRow(parent)
                self.proxy.sort(0, QtCore.Qt.AscendingOrder)
            child = QtGui.QStandardItem(self.childKey(diagram, node))
            child.setData(node)
            parent.appendRow(child)
            self.proxy.sort(0, QtCore.Qt.AscendingOrder) 
Example 8
Project: opcua-client-gui   Author: FreeOpcUa   File: mainwindow.py    License: GNU General Public License v3.0 6 votes vote down vote up
def _subscribe(self, node=None):
        if not isinstance(node, Node):
            node = self.window.get_current_node()
            if node is None:
                return
        if node in self._subscribed_nodes:
            logger.warning("allready subscribed to node: %s ", node)
            return
        self.model.setHorizontalHeaderLabels(["DisplayName", "Value", "Timestamp"])
        text = str(node.get_display_name().Text)
        row = [QStandardItem(text), QStandardItem("No Data yet"), QStandardItem("")]
        row[0].setData(node)
        self.model.appendRow(row)
        self._subscribed_nodes.append(node)
        self.window.ui.subDockWidget.raise_()
        try:
            self.uaclient.subscribe_datachange(node, self._subhandler)
        except Exception as ex:
            self.window.show_error(ex)
            idx = self.model.indexFromItem(row[0])
            self.model.takeRow(idx.row())
            raise 
Example 9
Project: Resetter   Author: gaining   File: EasyInstall.py    License: GNU General Public License v3.0 6 votes vote down vote up
def addItems(self):
        package = str(self.EditText.text())
        try:
            pkg = self.cache[package.strip()]
            n = pkg.shortname
            v = pkg.versions[0].version
            desc = pkg.versions[0].description
            name = "{}: {}".format(n, v)
            if len(package) > 0 and pkg.is_installed is False:
                item = QtGui.QStandardItem(name)
                item.setCheckable(True)
                item.setSelectable(True)
                item.setToolTip((textwrap.fill(desc, 70)))
                item.setCheckState(QtCore.Qt.Unchecked)
                self.model.appendRow(item)
                self.list_view.setModel(self.model)
            else:
                self.alreadyInstalled(name)
            self.EditText.clear()
        except KeyError:
            self.showMessage(package) 
Example 10
Project: Dwarf   Author: iGio90   File: panel_search.py    License: GNU General Public License v3.0 6 votes vote down vote up
def _on_show_results(self):
        if self._search_results:
            self.results.clear()
            if self._app_window.debug_panel.memory_panel:
                self._app_window.debug_panel.memory_panel.remove_highlights('search')
            selected_index = self.ranges.selectionModel().currentIndex().row()
            if selected_index is not None:
                item_txt = self._ranges_model.item(selected_index, 3).text()
                if item_txt == '':
                    return

                for result in self._search_results[selected_index]:
                    self._result_model.appendRow(
                        QStandardItem(result['address']))

                    # TODO: fix hexview highlights performance
                    """
                    if self._app_window.memory_panel:
                        try:
                            self._app_window.memory_panel.add_highlight(
                                HighLight('search', utils.parse_ptr(result['address']), self._pattern_length))
                        except HighlightExistsError:
                            pass""" 
Example 11
Project: PyQt   Author: PyQt5   File: CustomWidgetItem.py    License: GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, *args, **kwargs):
        super(ListView, self).__init__(*args, **kwargs)
        # 模型
        self._model = QStandardItemModel(self)
        self.setModel(self._model)

        # 循环生成10个自定义控件
        for i in range(10):
            item = QStandardItem()
            self._model.appendRow(item)  # 添加item

            # 得到索引
            index = self._model.indexFromItem(item)
            widget = CustomWidget(str(i))
            item.setSizeHint(widget.sizeHint())  # 主要是调整item的高度
            # 设置自定义的widget
            self.setIndexWidget(index, widget) 
Example 12
Project: PyQt   Author: PyQt5   File: modelviewserver.py    License: GNU General Public License v3.0 6 votes vote down vote up
def addChild(numChildren, nestingLevel):
    result = []

    if nestingLevel == 0:
        return result

    for i in range(numChildren):
        child = QStandardItem(
                "Child num {}, nesting level {}".format(i + 1, nestingLevel))

        if i == 0:
            child.appendRow(addChild(numChildren, nestingLevel - 1))

        result.append(child)

    return result 
Example 13
Project: Lector   Author: BasioMeusPuga   File: widgets.py    License: GNU General Public License v3.0 5 votes vote down vote up
def generate_toc_model(self):
        # The toc list is:
        # 0: Level
        # 1: Title
        # 2: Chapter content / page number
        # pprint it out to get a better idea of structure

        toc = self.metadata['toc']
        parent_list = []
        for i in toc:
            item = QtGui.QStandardItem()
            item.setText(i[1])
            item.setData(i[2], QtCore.Qt.UserRole)
            item.setData(i[1], QtCore.Qt.UserRole + 1)

            current_level = i[0]
            if current_level == 1:
                self.tocModel.appendRow(item)
                parent_list.clear()
                parent_list.append(item)
            else:
                parent_list[current_level - 2].appendRow(item)
                try:
                    next_level = toc[toc.index(i) + 1][0]
                    if next_level > current_level:
                        parent_list.append(item)

                    if next_level < current_level:
                        level_difference = current_level - next_level
                        parent_list = parent_list[:-level_difference]
                except IndexError:
                    pass

        # This is needed to be able to have the toc Combobox
        # jump to the correct position in the book when it is
        # first opened
        self.main_window.bookToolBar.tocBox.setModel(self.tocModel)
        self.main_window.bookToolBar.tocTreeView.expandAll() 
Example 14
Project: Lector   Author: BasioMeusPuga   File: annotations.py    License: GNU General Public License v3.0 5 votes vote down vote up
def ok_pressed(self):
        annotation_name = self.nameEdit.text()
        if annotation_name == '':
            self.nameEdit.setText('Why do you like bugs? WHY?')
            return

        annotation_components = {}
        if self.foregroundCheck.isChecked():
            annotation_components['foregroundColor'] = self.foregroundColor
        if self.highlightCheck.isChecked():
            annotation_components['highlightColor'] = self.highlightColor
        if self.boldCheck.isChecked():
            annotation_components['bold'] = True
        if self.italicCheck.isChecked():
            annotation_components['italic'] = True
        if self.underlineCheck.isChecked():
            annotation_components['underline'] = (
                self.underlineType.currentText(), self.underlineColor)

        self.current_annotation = {
            'name': annotation_name,
            'applicable_to': 'text',
            'type': 'text_markup',
            'components': annotation_components}

        if self.modelIndex:
            self.parent.annotationModel.setData(
                self.modelIndex, annotation_name, QtCore.Qt.DisplayRole)
            self.parent.annotationModel.setData(
                self.modelIndex, self.current_annotation, QtCore.Qt.UserRole)
        else:  # New annotation
            new_annotation_item = QtGui.QStandardItem()
            new_annotation_item.setText(annotation_name)
            new_annotation_item.setData(self.current_annotation, QtCore.Qt.UserRole)
            self.parent.annotationModel.appendRow(new_annotation_item)

        self.hide() 
Example 15
Project: Lector   Author: BasioMeusPuga   File: settingsdialog.py    License: GNU General Public License v3.0 5 votes vote down vote up
def generate_annotations(self):
        saved_annotations = self.main_window.settings['annotations']

        for i in saved_annotations:
            item = QtGui.QStandardItem()
            item.setText(i['name'])
            item.setData(i, QtCore.Qt.UserRole)
            self.annotationModel.appendRow(item)

        self.annotationsList.setModel(self.annotationModel) 
Example 16
Project: dunya-desktop   Author: MTG   File: filteringmodel.py    License: GNU General Public License v3.0 5 votes vote down vote up
def add_items(self, attribute):
        self.setRowCount(len(attribute))

        for row, item in enumerate(attribute):
            name = QStandardItem(item['name'])
            self.setItem(row, 0, name) 
Example 17
Project: dunya-desktop   Author: MTG   File: recordingmodel.py    License: GNU General Public License v3.0 5 votes vote down vote up
def set_checked(self, rows):
        for row in rows:
            check_item = QStandardItem()
            check_item.setCheckState(Qt.Checked)
            check_item.setEnabled(False)
            check_item.setToolTip('Already added to main collection...')
            self.setItem(row, 0, check_item) 
Example 18
Project: dunya-desktop   Author: MTG   File: recordingmodel.py    License: GNU General Public License v3.0 5 votes vote down vote up
def _make_item(text):
        return QStandardItem(text) 
Example 19
Project: FIRST-plugin-ida   Author: vrtadmin   File: first.py    License: GNU General Public License v2.0 5 votes vote down vote up
def make_model_headers(model, full=True, check_all=True):
            '''
            Set the model horizontal header data
            @param model: the QStandardItemModel which headers should be set

            When full is set to False this mean the headers are for the user
            to review metadata they've created.
            '''
            center_align = ['Rank', 'Similarity', 'i', 'Matches']
            headers = [ ('Function', 'function name'),
                        ('Rank', 'number of times metadata has been applied'),
                        ('Prototype', 'function prototype')]

            if full:
                full_headers = [headers[0]]
                if check_all:
                    full_headers.append(('Matches', 'number of unique matches'))

                full_headers += [
                            headers[1],
                            ('Similarity', 'percent of how similary the match is to the function'),
                            headers[2],
                            ('i', 'full prototype information'),
                            ('Engines', 'engines that matched on this function'),
                            ('i', 'detailed engine information'),
                            ('User', 'creator of the metadata')
                                ]

                headers = full_headers

            i = 0
            for display_name, tooltip in headers:
                item_header = QtGui.QStandardItem(display_name)
                item_header.setToolTip(tooltip)

                if display_name in center_align:
                    item_header.setTextAlignment(Qt.AlignCenter)

                model.setHorizontalHeaderItem(i, item_header)

                i += 1 
Example 20
Project: FIRST-plugin-ida   Author: vrtadmin   File: first.py    License: GNU General Public License v2.0 5 votes vote down vote up
def _make_function_item(self, function, matches):
            '''
            Top level function information (level-0)
            '''
            #if not isinstance(function, FIRST.MetadataShim):
            if not {'name', 'address'}.issubset(dir(function)):
                return QtGui.QStandardItem('-')

            label = '0x{0.address:08x} - {0.name}'
            if not FIRST.Info.is_32bit():
                label = label.replace(':08x}', ':016x}')

            function_label = QtGui.QStandardItem(label.format(function))
            function_label.setToolTip(function.name)
            function_label.setData(function.address, role=FIRSTUI.ROLE_ADDRESS)
            function_label.setData(function.name, role=FIRSTUI.ROLE_NAME)

            if 999999 < matches:
                matches = '{}M'.format(round(matches / 1000000.0, 1))
            elif 999 < matches:
                matches = '{}K'.format(round(matches / 1000.0, 1))
            else:
                matches = str(matches)

            matches = QtGui.QStandardItem(matches)
            matches.setTextAlignment(Qt.AlignCenter)

            row = [function_label, matches] + \
                    [QtGui.QStandardItem() for i in range(7)]

            [x.setEditable(False) for x in row]
            return row 
Example 21
Project: pyleecan   Author: Eomys   File: TreeView.py    License: Apache License 2.0 5 votes vote down vote up
def generate_branch(self, data, parent):
        for attr in data.as_dict():
            if attr[0] != "_":
                _attr = getattr(data, attr)
                # pyleecan object attributes
                if hasattr(_attr, "as_dict"):
                    branch = QtGui.QStandardItem(attr)
                    branch.setEditable(False)
                    value = QtGui.QStandardItem("")
                    value.setEditable(False)
                    unit = QtGui.QStandardItem("")
                    cls_name = QtGui.QStandardItem(type(_attr).__name__)
                    # class description rathern than attribure description
                    cls_doc = (
                        getattr(type(data), attr).__doc__
                        if _attr.__doc__ is None
                        else _attr.__doc__
                    )
                    cls_doc = QtGui.QStandardItem(cls_doc)
                    parent.appendRow([branch, value, unit, cls_name, cls_doc])
                    self.generate(_attr, parent=branch)

                # float, int, str attributes
                elif isinstance(_attr, (float, int, str)):
                    attribute = QtGui.QStandardItem(attr)
                    attribute.setEditable(False)
                    value = QtGui.QStandardItem(str(getattr(data, attr)))
                    value.setEditable(False)
                    unit = QtGui.QStandardItem("na")
                    cls_name = QtGui.QStandardItem(type(_attr).__name__)
                    cls_doc = getattr(
                        type(data), attr
                    ).__doc__  # tc.__class__.prop.__doc__
                    cls_doc = QtGui.QStandardItem(cls_doc)
                    parent.appendRow([attribute, value, unit, cls_name, cls_doc])

                # todo: list, dict, ndarray attributes
                else:
                    pass 
Example 22
Project: opcua-modeler   Author: FreeOpcUa   File: refnodesets_widget.py    License: GNU General Public License v3.0 5 votes vote down vote up
def set_server_mgr(self, server_mgr):
        self.server_mgr = server_mgr
        self.nodesets = []
        self.model.clear()
        self.model.setHorizontalHeaderLabels(['Node Sets'])
        item = QStandardItem("Opc.Ua.NodeSet2.xml")
        item.setFlags(Qt.NoItemFlags)
        self.model.appendRow([item])
        self.view.expandAll() 
Example 23
Project: opcua-modeler   Author: FreeOpcUa   File: namespace_widget.py    License: GNU General Public License v3.0 5 votes vote down vote up
def add_namespace(self):
        uries = self.node.get_value()
        newidx = len(uries)
        it = self.model.item(0, 0)
        uri_it = QStandardItem("")
        it.appendRow([QStandardItem(), QStandardItem(str(newidx)), uri_it])
        idx = self.model.indexFromItem(uri_it)
        self.view.edit(idx) 
Example 24
Project: opcua-modeler   Author: FreeOpcUa   File: namespace_widget.py    License: GNU General Public License v3.0 5 votes vote down vote up
def show_array(self):
        self.model.setHorizontalHeaderLabels(['Browse Name', 'Index', 'Value'])

        name_item = QStandardItem(self.node.get_browse_name().Name)
        self.model.appendRow([name_item, QStandardItem(""), QStandardItem()])
        it = self.model.item(0, 0)
        val = self.node.get_value()
        for idx, url in enumerate(val):
            it.appendRow([QStandardItem(), QStandardItem(str(idx)), QStandardItem(url)])
        self.view.expandAll() 
Example 25
Project: DIE   Author: ynvb   File: ValueViewEx.py    License: MIT License 5 votes vote down vote up
def _make_value_type_item(self, type):
        """
        Make a value item type
        @param type: item type
        """

        item_value_type = QtGui.QStandardItem(type)
        item_value_type.setEditable(False)

        return [item_value_type] 
Example 26
Project: DIE   Author: ynvb   File: ValueViewEx.py    License: MIT License 5 votes vote down vote up
def _make_value_item(self, value):
        """
        Make a value model item
        @param value: dbParsed_Value object
        @return: a list of items for this row.
        """
        null_item = QtGui.QStandardItem()
        null_item.setEditable(False)
        null_item.setData(value.type, role=DIE.UI.ValueType_Role)
        null_item.setData(value.__hash__(), role=DIE.UI.Value_Role)

        item_value_score = QtGui.QStandardItem(str(value.score))
        item_value_score.setEditable(False)

        item_value_data = QtGui.QStandardItem(value.data)
        ea_list = self.die_db.get_parsed_value_contexts(value)
        item_value_data.setData(ea_list, role=DIE.UI.ContextList_Role)
        item_value_data.setEditable(False)

        item_value_desc = QtGui.QStandardItem(value.description)
        item_value_desc.setEditable(False)

        item_value_raw = QtGui.QStandardItem(value.raw)
        item_value_raw.setEditable(False)

        return [null_item, item_value_score, item_value_data, item_value_desc, item_value_raw]


###############################################################################################
# Highlight Items
#
############################################################################################### 
Example 27
Project: DIE   Author: ynvb   File: FunctionViewEx.py    License: MIT License 5 votes vote down vote up
def _make_function_item(self, function):
        """
        Build a tree item for a function name (level-0)
        @param function: dbFunction object
        @return: QStandradItemModel item for the function
        """
        function_txt = "%s" % function.function_name

        item_function = QtGui.QStandardItem(self.die_icons.icon_function, function_txt)
        item_function.setData(function, role=DIE.UI.Function_Role)

        function_count = self.die_db.count_function_occurs(function)
        item_function_count = QtGui.QStandardItem(str(function_count))

        item_function_count.setEditable(False)
        item_function.setEditable(False)

        item_list = [item_function,
                     item_function_count,
                     QtGui.QStandardItem(),
                     QtGui.QStandardItem(),
                     QtGui.QStandardItem(),
                     QtGui.QStandardItem(),
                     QtGui.QStandardItem(),
                     QtGui.QStandardItem(),
                     QtGui.QStandardItem(),
                     QtGui.QStandardItem()]

        return item_list 
Example 28
Project: DIE   Author: ynvb   File: FunctionViewEx.py    License: MIT License 5 votes vote down vote up
def _make_func_occur_item(self, function_context, occur_num):
        """
        Build a tree item for function occurrence (level-2)
        @param function_context: a dbFunction_Context object
        @param occur_num: occurrence number
        @return: QStandradItemModel item for the function occurrence
        """
        func_occur_txt = "Occur %s" % str(occur_num)
        item_func_context = QtGui.QStandardItem(func_occur_txt)
        item_func_context.setColumnCount(5)
        item_func_context.setEditable(False)
        item_func_context.setData(function_context, role=DIE.UI.FunctionContext_Role)
        item_func_context.setData(id(function_context), role=DIE.UI.ContextId_Role)  # Used for module look-ups
        item_func_context.setData(self._make_thread_id_data(function_context.thread_id), role=DIE.UI.ThreadId_Role)

        item_list = [item_func_context,
                     QtGui.QStandardItem(),
                     QtGui.QStandardItem(),
                     QtGui.QStandardItem(),
                     QtGui.QStandardItem(),
                     QtGui.QStandardItem(),
                     QtGui.QStandardItem(),
                     QtGui.QStandardItem(),
                     QtGui.QStandardItem(),
                     QtGui.QStandardItem()]

        return item_list 
Example 29
Project: Miyamoto   Author: aboood40091   File: puzzle.py    License: GNU General Public License v3.0 5 votes vote down vote up
def SetupObjectModel(self, objects, tiles):
    global Tileset
    self.clear()

    count = 0
    for object in objects:
        tex = QtGui.QPixmap(object.width * 24, object.height * 24)
        tex.fill(Qt.transparent)
        painter = QtGui.QPainter(tex)

        Xoffset = 0
        Yoffset = 0

        for i in range(len(object.tiles)):
            for tile in object.tiles[i]:
                if (Tileset.slot == 0) or ((tile[2] & 3) != 0):
                    painter.drawPixmap(Xoffset, Yoffset, tiles[tile[1]].image.scaledToWidth(24, Qt.SmoothTransformation))
                Xoffset += 24
            Xoffset = 0
            Yoffset += 24

        painter.end()

        item = QtGui.QStandardItem(QtGui.QIcon(tex), 'Object {0}'.format(count))
        item.setFlags(item.flags() & ~Qt.ItemIsEditable)
        self.appendRow(item)

        count += 1


#############################################################################################
######################## List Widget with custom painter/MouseEvent ######################### 
Example 30
Project: VUT-FIT-IFJ-2017-toolkit   Author: thejoeejoee   File: tree_view_model.py    License: GNU General Public License v3.0 5 votes vote down vote up
def _create_item(self, parent_model: Union[QStandardItem, QStandardItemModel], name: str, data: Dict) -> QStandardItem:
        item = QStandardItem(name)
        for user_role, row_data in data.items():
            item.setData(row_data, user_role)
        parent_model.appendRow(item)
        return item