本文整理汇总了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))