Exemplo n.º 1
0
    def filterAcceptsRow(self, source_row, source_parent):
        """
        Tells by analysing the given row if it should be shown or not. This behaviour can be modified via setFilterRegExp
         method so that e.g. only the entries of a specific host can be shown.

        :param source_row: the source row
        :type source_row: int
        :param source_parent: the source of the parent
        :type source_parent: QModelIndex

        :returns: bool
        """
        return QSortFilterProxyModel.filterAcceptsRow(self, source_row, source_parent)
Exemplo n.º 2
0
    def filterAcceptsRow(self, source_row, source_parent):
        """
        Tells by analysing the given row if it should be shown or not. This behaviour can be modified via setFilterRegExp
         method so that e.g. only the entries of a specific host can be shown.

        :param source_row: the source row
        :type source_row: int
        :param source_parent: the source of the parent
        :type source_parent: QModelIndex

        :returns: bool
        """
        return QSortFilterProxyModel.filterAcceptsRow(self, source_row,
                                                      source_parent)
Exemplo n.º 3
0
    def filterAcceptsRow(self, source_row, source_parent):
        """
        Tells by analysing the given row if it should be shown or not. This behaviour can be modified via
        setFilterRegExp method so that e.g. only the entries of a specific host can be shown.

        :param source_row: the source of the parent
        :type source_row: int
        :param source_parent: the source of the parent
        :type source_parent: QModelIndex

        :returns: True if the row should be shown
        :rtype: bool
        """
        entries = []
        item = source_parent.internalPointer()
        child = None
        if item is not None:
            if isinstance(item, TreeTopicItem):
                child = item.get_child(
                    source_row,
                    self.sourceModel().parent(source_parent).internalPointer())
            else:
                child = source_parent.internalPointer().get_child(source_row)
            entries = [
                child.get_type(),
                child.get_seuid(),
                child.get_state(),
                child.get_short_data()
            ]
        else:
            child = self.sourceModel().get_root_item().get_child(source_row)
            entries = [
                child.get_type(),
                child.get_seuid(),
                child.get_state(),
                child.get_short_data()
            ]

        child_childs = child.get_childs(
            self.sourceModel().parent(source_parent).internalPointer())

        for i in range(0, len(child_childs)):
            if self.filterAcceptsRow(
                    i,
                    self.sourceModel().index(source_row, 0, source_parent)):
                return True

        correct_type = False
        data = entries[0]

        if data[0] == "h":
            correct_type = True
        elif self.__show_nodes and data[0] == "n":
            correct_type = True
        elif self.__show_connections and data[0] == "c":
            if self.__show_subscribers:
                correct_type = True
            else:
                if child.is_subscriber:
                    correct_type = False
                else:
                    correct_type = True
        elif self.__show_topics is True:
            if data[0] == "t":
                correct_type = True

        if correct_type is False:
            return False

        if self.__hide_debug is True:
            for entry in self.__quiet_names:
                if entries[1].find(entry) is not -1:
                    return False

        # todo: speed this implementation a lot up by not using the model!!!
        if self.__filter_string is not "":
            for i in range(0, len(entries)):
                if self.__filter_string in entries[i]:
                    return QSortFilterProxyModel.filterAcceptsRow(
                        self, source_row, source_parent)
            return False
        return QSortFilterProxyModel.filterAcceptsRow(self, source_row,
                                                      source_parent)
Exemplo n.º 4
0
    def filterAcceptsRow(self, source_row, source_parent):
        """
        Tells by analysing the given row if it should be shown or not. This behaviour can be modified via
        setFilterRegExp method so that e.g. only the entries of a specific host can be shown.

        :param source_row: the source of the parent
        :type source_row: int
        :param source_parent: the source of the parent
        :type source_parent: QModelIndex

        :returns: True if the row should be shown
        :rtype: bool
        """
        entries = []
        item = source_parent.internalPointer()
        child = None
        if item is not None:
            if isinstance(item, TreeTopicItem):
                child = item.get_child(source_row, self.sourceModel().parent(
                    source_parent).internalPointer())
            else:
                child = source_parent.internalPointer().get_child(source_row)
            entries = [child.get_type(), child.get_seuid(), child.get_state(), child.get_short_data()]
        else:
            child = self.sourceModel().get_root_item().get_child(source_row)
            entries = [child.get_type(), child.get_seuid(), child.get_state(), child.get_short_data()]

        child_childs = child.get_childs( self.sourceModel().parent(
                    source_parent).internalPointer())

        for i in range(0, len(child_childs)):
            if self.filterAcceptsRow(i, self.sourceModel().index(source_row, 0, source_parent)):
                return True

        correct_type = False
        data = entries[0]

        if data[0] == "h":
            correct_type = True
        elif self.__show_nodes and data[0] == "n":
            correct_type = True
        elif self.__show_connections and data[0] == "c":
            if self.__show_subscribers:
                correct_type = True
            else:
                if child.is_subscriber:
                    correct_type = False
                else:
                    correct_type = True
        elif self.__show_topics is True:
            if data[0] == "t":
                correct_type = True

        if correct_type is False:
            return False

        if self.__hide_debug is True:
            for entry in self.__quiet_names:
                if entries[1].find(entry) is not -1:
                    return False


        # todo: speed this implementation a lot up by not using the model!!!
        if self.__filter_string is not "":
            for i in range(0, len(entries)):
                if self.__filter_string in entries[i]:
                    return QSortFilterProxyModel.filterAcceptsRow(self, source_row, source_parent)
            return False
        return QSortFilterProxyModel.filterAcceptsRow(self, source_row, source_parent)