当前位置: 首页>>代码示例>>Python>>正文


Python Backend.categoryischildof方法代码示例

本文整理汇总了Python中backend.Backend.categoryischildof方法的典型用法代码示例。如果您正苦于以下问题:Python Backend.categoryischildof方法的具体用法?Python Backend.categoryischildof怎么用?Python Backend.categoryischildof使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在backend.Backend的用法示例。


在下文中一共展示了Backend.categoryischildof方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: MainWindow

# 需要导入模块: from backend import Backend [as 别名]
# 或者: from backend.Backend import categoryischildof [as 别名]

#.........这里部分代码省略.........
        self.tableArchivedThreads.clicked.connect(self._archivedthreadselected)

    def _buildfilters(self):
        """Builds a list of lambda functions which serve as thread retrieval
        filters based on what filters are set in the filter widgets.
        """
        filters = []
        filters.append((self._buildcategoryfilters()))
        filters.append((self._buildforumfilters()))
        filters.append((self._builddatefilter()))
        filters.append((self._buildtagfilters()))
        return filters

    def _buildforumfilters(self):
        """Builds a list of lambda functions which will be used to filter
        archived threads by forums.
        """
        if self.checkForumFilter.checkState() == Qt.Checked:
            rowid = -1
            for row in self.tableForumFilter.selectedItems():
                if not rowid == row.row():
                    yield (lambda x:
                            x.forum() == row.data(Qt.UserRole)[1])
                    rowid = row.row()

    def _buildcategoryfilters(self):
        """Builds a list of lambda functions which will be used to filter
        archived threads by categories.
        """
        if self.checkCategoryFilter.checkState() == Qt.Checked:
            for row in self.treeCategory.selectionModel().selectedRows():
                cid, name, parent = row.data(Qt.UserRole)
                yield (lambda x:
                        self._backend.categoryischildof(x.categoryid(), cid)
                        or x.categoryid() == cid)

    def _buildtagfilters(self):
        """Builds a list of lambda functions which will be used to filter
        archived threads by tags.
        """
        if self.checkTagFilter.checkState() == Qt.Checked:
            for row in self.listTags.selectedItems():
                tid = row.data(Qt.UserRole)
                yield (lambda x: tid in (y[0] for y in x.tags()))

    def _builddatefilter(self):
        """Builds a lambda function which will be used to filter archived
        threads by date.
        """
        if self.checkDateFilter.checkState() == Qt.Checked:
            fromdate = self.dateFrom.date().toPython()
            if self.radioDateOlder.isChecked():
                yield (lambda x: datefromstring(x.timestamp()) < fromdate)
            elif self.radioDateNewer.isChecked():
                yield (lambda x: datefromstring(x.timestamp()) > fromdate)
            else:
                todate = self.dateTo.date().toPython()
                yield (lambda x: datefromstring(x.timestamp()) >= fromdate
                        and datefromstring(x.timestamp()) <= todate)

    def _showarchivedthreads(self):
        """Shows all threads that match the current filters."""
        self.tableArchivedThreads.setModel(
                ThreadsArchiveTableModel(
                    self._backend, self._buildfilters(), self))
开发者ID:Hydrael,项目名称:4ca,代码行数:69,代码来源:mainwindow.py


注:本文中的backend.Backend.categoryischildof方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。