本文整理汇总了C++中QVariantList::constFirst方法的典型用法代码示例。如果您正苦于以下问题:C++ QVariantList::constFirst方法的具体用法?C++ QVariantList::constFirst怎么用?C++ QVariantList::constFirst使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QVariantList
的用法示例。
在下文中一共展示了QVariantList::constFirst方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: checkChanges
bool ChangeLog::checkChanges(const QString &previousVersion, const QString ¤tVersion)
{
QVersionNumber previous = QVersionNumber::fromString(previousVersion);
QVersionNumber current = QVersionNumber::fromString(currentVersion);
if (current <= previous) {
qCInfo(CHANGELOG_CATEGORY) << "Current version isn't newer, than previous"
<< previousVersion << currentVersion;
return false;
}
QFileSelector fileSelector;
fileSelector.setExtraSelectors(QStringList() << QLocale::system().uiLanguages().constFirst().split('-').constFirst());
const QString path = fileSelector.select(":/changelogs/changelog.json");
QFile file(path);
if (!file.open(QIODevice::ReadOnly)) {
qCCritical(CHANGELOG_CATEGORY) << "Fail to open changelog file" << path << file.errorString();
return false;
}
QByteArray data = file.readAll();
QJsonParseError parseError;
QJsonDocument document = QJsonDocument::fromJson(data, &parseError);
if (parseError.error != QJsonParseError::NoError) {
qCritical(CHANGELOG_CATEGORY) << "Fail to parse changelog data JSON:"
<< data << "error at offset"
<< parseError.offset
<< parseError.errorString() << parseError.error;
return false;
}
QVariantList content = document.array().toVariantList();
while (!content.isEmpty()) {
if (QVersionNumber::fromString(content.constFirst().toMap().value("version").toString()) > current) {
content.takeFirst();
} else {
break;
}
}
QVariantList result;
while (!content.isEmpty()) {
if (QVersionNumber::fromString(content.constFirst().toMap().value("version").toString()) > previous) {
result.append(content.takeFirst());
} else {
break;
}
}
if (result.isEmpty()) {
qCWarning(CHANGELOG_CATEGORY) << "Empty changelog" << previousVersion << currentVersion;
return false;
}
emit changesAvailable(result);
return true;
}