def __init__(self, view_type=None, parent=None):
    super(MItemViewSet, self).__init__(parent)
    self._main_lay = QVBoxLayout()
    self._main_lay.setSpacing(5)
    self._main_lay.setContentsMargins(0, 0, 0, 0)
    self.sort_filter_model = MSortFilterModel()
    self.source_model = MTableModel()
    self.sort_filter_model.setSourceModel(self.source_model)
    view_class = (view_type or MItemViewSet.TableViewType)
    self.item_view = view_class()
    self.item_view.doubleClicked.connect(self.sig_double_clicked)
    self.item_view.pressed.connect(self.slot_left_clicked)
    self.item_view.setModel(self.sort_filter_model)
    self._search_line_edit = MLineEdit().search().small()
    self._search_attr_button = MToolButton().icon_only().svg('down_fill.svg').small()
    self._search_line_edit.set_prefix_widget(self._search_attr_button)
    self._search_line_edit.textChanged.connect(self.sort_filter_model.set_search_pattern)
    self._search_line_edit.setVisible(False)
    _search_lay = QHBoxLayout()
    _search_lay.setContentsMargins(0, 0, 0, 0)
    _search_lay.addStretch()
    _search_lay.addWidget(self._search_line_edit)
    self._main_lay.addLayout(_search_lay)
    self._main_lay.addWidget(self.item_view)
    self.setLayout(self._main_lay)
def __init__(self, view_type=None, parent=None):
    super(MItemViewSet, self).__init__(parent)
    self._main_lay = QVBoxLayout()
    self._main_lay.setSpacing(5)
    self._main_lay.setContentsMargins(0, 0, 0, 0)
    self.sort_filter_model = MSortFilterModel()
    self.source_model = MTableModel()
    self.sort_filter_model.setSourceModel(self.source_model)
    view_class = (view_type or MItemViewSet.TableViewType)
    self.item_view = view_class()
    self.item_view.doubleClicked.connect(self.sig_double_clicked)
    self.item_view.pressed.connect(self.slot_left_clicked)
    self.item_view.setModel(self.sort_filter_model)
    self._search_line_edit = MLineEdit().search().small()
    self._search_attr_button = MToolButton().icon_only().svg('down_fill.svg').small()
    self._search_line_edit.set_prefix_widget(self._search_attr_button)
    self._search_line_edit.textChanged.connect(self.sort_filter_model.set_search_pattern)
    self._search_line_edit.setVisible(False)
    _search_lay = QHBoxLayout()
    _search_lay.setContentsMargins(0, 0, 0, 0)
    _search_lay.addStretch()
    _search_lay.addWidget(self._search_line_edit)
    self._main_lay.addLayout(_search_lay)
    self._main_lay.addWidget(self.item_view)
    self.setLayout(self._main_lay)