本文整理汇总了Python中PyQt5.QtCore.QDate.isValid方法的典型用法代码示例。如果您正苦于以下问题:Python QDate.isValid方法的具体用法?Python QDate.isValid怎么用?Python QDate.isValid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtCore.QDate
的用法示例。
在下文中一共展示了QDate.isValid方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MySortFilterProxyModel
# 需要导入模块: from PyQt5.QtCore import QDate [as 别名]
# 或者: from PyQt5.QtCore.QDate import isValid [as 别名]
class MySortFilterProxyModel(QSortFilterProxyModel):
def __init__(self, parent=None):
super(MySortFilterProxyModel, self).__init__(parent)
self.minDate = QDate()
self.maxDate = QDate()
def setFilterMinimumDate(self, date):
self.minDate = date
self.invalidateFilter()
def filterMinimumDate(self):
return self.minDate
def setFilterMaximumDate(self, date):
self.maxDate = date
self.invalidateFilter()
def filterMaximumDate(self):
return self.maxDate
def filterAcceptsRow(self, sourceRow, sourceParent):
index0 = self.sourceModel().index(sourceRow, 0, sourceParent)
index1 = self.sourceModel().index(sourceRow, 1, sourceParent)
index2 = self.sourceModel().index(sourceRow, 2, sourceParent)
return (
self.filterRegExp().indexIn(self.sourceModel().data(index0)) >= 0
or self.filterRegExp().indexIn(self.sourceModel().data(index1)) >= 0
) and self.dateInRange(self.sourceModel().data(index2))
def lessThan(self, left, right):
leftData = self.sourceModel().data(left)
rightData = self.sourceModel().data(right)
if not isinstance(leftData, QDate):
emailPattern = QRegExp("([\\w\\.]*@[\\w\\.]*)")
if left.column() == 1 and emailPattern.indexIn(leftData) != -1:
leftData = emailPattern.cap(1)
if right.column() == 1 and emailPattern.indexIn(rightData) != -1:
rightData = emailPattern.cap(1)
return leftData < rightData
def dateInRange(self, date):
if isinstance(date, QDateTime):
date = date.date()
return (not self.minDate.isValid() or date >= self.minDate) and (
not self.maxDate.isValid() or date <= self.maxDate
)
示例2: SvnLogBrowserDialog
# 需要导入模块: from PyQt5.QtCore import QDate [as 别名]
# 或者: from PyQt5.QtCore.QDate import isValid [as 别名]
#.........这里部分代码省略.........
log["date"] = self.rx_rev.cap(3)
# number of lines is ignored
elif self.rx_rev2.exactMatch(s):
log["revision"] = self.rx_rev2.cap(1)
log["author"] = self.rx_rev2.cap(2)
log["date"] = self.rx_rev2.cap(3)
# number of lines is ignored
elif self.rx_flags1.exactMatch(s):
changedPaths.append({
"action":
self.rx_flags1.cap(1).strip(),
"path":
self.rx_flags1.cap(2).strip(),
"copyfrom_path":
self.rx_flags1.cap(3).strip(),
"copyfrom_revision":
self.rx_flags1.cap(4).strip(),
})
elif self.rx_flags2.exactMatch(s):
changedPaths.append({
"action":
self.rx_flags2.cap(1).strip(),
"path":
self.rx_flags2.cap(2).strip(),
"copyfrom_path": "",
"copyfrom_revision": "",
})
elif self.rx_sep1.exactMatch(s) or self.rx_sep2.exactMatch(s):
if len(log) > 1:
self.__generateLogItem(
log["author"], log["date"], log["message"],
log["revision"], changedPaths)
dt = QDate.fromString(log["date"], Qt.ISODate)
if not self.__maxDate.isValid() and \
not self.__minDate.isValid():
self.__maxDate = dt
self.__minDate = dt
else:
if self.__maxDate < dt:
self.__maxDate = dt
if self.__minDate > dt:
self.__minDate = dt
noEntries += 1
log = {"message": []}
changedPaths = []
else:
if s.strip().endswith(":") or not s.strip():
continue
else:
log["message"].append(s)
self.__resizeColumnsLog()
self.__resortLog()
if self.__started:
self.logTree.setCurrentItem(self.logTree.topLevelItem(0))
self.__started = False
if noEntries < self.limitSpinBox.value() and not self.cancelled:
self.nextButton.setEnabled(False)
self.limitSpinBox.setEnabled(False)
self.__filterLogsEnabled = False
self.fromDate.setMinimumDate(self.__minDate)
self.fromDate.setMaximumDate(self.__maxDate)
self.fromDate.setDate(self.__minDate)
示例3: SvnLogBrowserDialog
# 需要导入模块: from PyQt5.QtCore import QDate [as 别名]
# 或者: from PyQt5.QtCore.QDate import isValid [as 别名]
#.........这里部分代码省略.........
nextRev = 0
fetched = 0
logs = []
while fetched < limit:
flimit = min(fetchLimit, limit - fetched)
if fetched == 0:
revstart = start
else:
revstart = pysvn.Revision(
pysvn.opt_revision_kind.number, nextRev)
allLogs = self.client.log(
self.fname, revision_start=revstart,
discover_changed_paths=True, limit=flimit + 1,
strict_node_history=self.stopCheckBox.isChecked())
if len(allLogs) <= flimit or self._clientCancelCallback():
logs.extend(allLogs)
break
else:
logs.extend(allLogs[:-1])
nextRev = allLogs[-1]["revision"].number
fetched += fetchLimit
locker.unlock()
for log in logs:
author = log["author"]
message = log["message"]
if sys.version_info[0] == 2:
author = author.decode('utf-8')
message = message.decode('utf-8')
self.__generateLogItem(
author, log["date"], message,
log["revision"], log['changed_paths'])
dt = dateFromTime_t(log["date"])
if not self.__maxDate.isValid() and \
not self.__minDate.isValid():
self.__maxDate = dt
self.__minDate = dt
else:
if self.__maxDate < dt:
self.__maxDate = dt
if self.__minDate > dt:
self.__minDate = dt
if len(logs) < limit and not self.cancelled:
self.nextButton.setEnabled(False)
self.limitSpinBox.setEnabled(False)
self.__filterLogsEnabled = False
self.fromDate.setMinimumDate(self.__minDate)
self.fromDate.setMaximumDate(self.__maxDate)
self.fromDate.setDate(self.__minDate)
self.toDate.setMinimumDate(self.__minDate)
self.toDate.setMaximumDate(self.__maxDate)
self.toDate.setDate(self.__maxDate)
self.__filterLogsEnabled = True
self.__resizeColumnsLog()
self.__resortLog()
self.__filterLogs()
except pysvn.ClientError as e:
locker.unlock()
self.__showError(e.args[0])
os.chdir(cwd)
self.__finish()
def start(self, fn, isFile=False):
"""
Public slot to start the svn log command.