aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Faure <faure@kde.org>2019-09-10 09:42:22 +0200
committerDavid Faure <faure@kde.org>2019-09-17 18:27:06 +0200
commitc34e457bf9506ca068491eda41467013b180e544 (patch)
treef4708f5dc3d766914e0ee033c70add5ffb43f8e9
parentc358fd68e27738340582386d7f1c1c2fccac7df2 (diff)
downloadkconfig-c34e457bf9506ca068491eda41467013b180e544.tar.gz
kconfig-c34e457bf9506ca068491eda41467013b180e544.tar.bz2
[KConfig] port away from deprecated methods in Qt 5.14
Summary: In kconf_update, the ctime usage used to be about metadata change time (buff.st_ctime, before it got ported to the misnamed created()). I ported it to birthTime, because I think date of birth is a more useful way to identify a file than date of permission change which doesn't really matter to us. But in practice, I can't help but wonder if mtime alone wouldn't be enough. For the QStringLiteral("%%1").arg(i) bit, I tested it in tst_qstring, the first % is left untouched. Test Plan: make && ctest Reviewers: mdawson, arichardson, vkrause Reviewed By: vkrause Subscribers: pino, arojas, mlaurent, kde-frameworks-devel Tags: #frameworks Differential Revision: https://phabricator.kde.org/D23815
-rw-r--r--autotests/kconfigloadertest.cpp2
-rw-r--r--autotests/kconfigtest.cpp2
-rw-r--r--src/core/kcoreconfigskeleton.cpp6
-rw-r--r--src/kconf_update/kconf_update.cpp13
-rw-r--r--src/kconfig_compiler/kconfig_compiler.cpp3
5 files changed, 14 insertions, 12 deletions
diff --git a/autotests/kconfigloadertest.cpp b/autotests/kconfigloadertest.cpp
index 1c818b7f..eae1e2b2 100644
--- a/autotests/kconfigloadertest.cpp
+++ b/autotests/kconfigloadertest.cpp
@@ -161,7 +161,7 @@ void ConfigLoaderTest::intListDefaultValue()
expected.append(5);
expected.append(8);
- QVERIFY(typeItem->isEqual(qVariantFromValue(expected)));
+ QVERIFY(typeItem->isEqual(QVariant::fromValue(expected)));
}
void ConfigLoaderTest::longLongDefaultValue()
diff --git a/autotests/kconfigtest.cpp b/autotests/kconfigtest.cpp
index 9af3b464..b915a07a 100644
--- a/autotests/kconfigtest.cpp
+++ b/autotests/kconfigtest.cpp
@@ -1341,7 +1341,7 @@ static void ageTimeStamp(const QString &path, int nsec)
#ifdef Q_OS_UNIX
QDateTime mtime = QFileInfo(path).lastModified().addSecs(-nsec);
struct utimbuf utbuf;
- utbuf.actime = mtime.toTime_t();
+ utbuf.actime = mtime.toSecsSinceEpoch();
utbuf.modtime = utbuf.actime;
utime(QFile::encodeName(path), &utbuf);
#else
diff --git a/src/core/kcoreconfigskeleton.cpp b/src/core/kcoreconfigskeleton.cpp
index 384efdb4..2d8048a2 100644
--- a/src/core/kcoreconfigskeleton.cpp
+++ b/src/core/kcoreconfigskeleton.cpp
@@ -255,7 +255,7 @@ bool KCoreConfigSkeleton::ItemUrl::isEqual(const QVariant &v) const
QVariant KCoreConfigSkeleton::ItemUrl::property() const
{
- return qVariantFromValue<QUrl>(mReference);
+ return QVariant::fromValue<QUrl>(mReference);
}
KCoreConfigSkeleton::ItemProperty::ItemProperty(const QString &_group,
@@ -955,7 +955,7 @@ bool KCoreConfigSkeleton::ItemUrlList::isEqual(const QVariant &v) const
QVariant KCoreConfigSkeleton::ItemUrlList::property() const
{
- return qVariantFromValue<QList<QUrl> >(mReference);
+ return QVariant::fromValue<QList<QUrl> >(mReference);
}
KCoreConfigSkeleton::ItemIntList::ItemIntList(const QString &_group, const QString &_key,
@@ -990,7 +990,7 @@ bool KCoreConfigSkeleton::ItemIntList::isEqual(const QVariant &v) const
QVariant KCoreConfigSkeleton::ItemIntList::property() const
{
- return qVariantFromValue< QList<int> >(mReference);
+ return QVariant::fromValue< QList<int> >(mReference);
}
//static int kCoreConfigSkeletionDebugArea() { static int s_area = KDebug::registerArea("kdecore (KConfigSkeleton)"); return s_area; }
diff --git a/src/kconf_update/kconf_update.cpp b/src/kconf_update/kconf_update.cpp
index 09537e2f..2c48fa35 100644
--- a/src/kconf_update/kconf_update.cpp
+++ b/src/kconf_update/kconf_update.cpp
@@ -200,10 +200,11 @@ QStringList KonfUpdate::findUpdateFiles(bool dirtyOnly)
QFileInfo info(file);
KConfigGroup cg(m_config, fileName);
- const QDateTime ctime = QDateTime::fromTime_t(cg.readEntry("ctime", 0u));
- const QDateTime mtime = QDateTime::fromTime_t(cg.readEntry("mtime", 0u));
+ const QDateTime ctime = QDateTime::fromSecsSinceEpoch(cg.readEntry("ctime", 0u));
+ const QDateTime mtime = QDateTime::fromSecsSinceEpoch(cg.readEntry("mtime", 0u));
if (!dirtyOnly ||
- (ctime != info.created()) || (mtime != info.lastModified())) {
+ (ctime.isValid() && ctime != info.birthTime()) ||
+ mtime != info.lastModified()) {
result.append(file);
}
}
@@ -372,8 +373,10 @@ bool KonfUpdate::updateFile(const QString &filename)
QFileInfo info(filename);
KConfigGroup cg(m_config, m_currentFilename);
- cg.writeEntry("ctime", info.created().toTime_t());
- cg.writeEntry("mtime", info.lastModified().toTime_t());
+ if (info.birthTime().isValid()) {
+ cg.writeEntry("ctime", info.birthTime().toSecsSinceEpoch());
+ }
+ cg.writeEntry("mtime", info.lastModified().toSecsSinceEpoch());
cg.sync();
return true;
}
diff --git a/src/kconfig_compiler/kconfig_compiler.cpp b/src/kconfig_compiler/kconfig_compiler.cpp
index dd43e57d..349afee7 100644
--- a/src/kconfig_compiler/kconfig_compiler.cpp
+++ b/src/kconfig_compiler/kconfig_compiler.cpp
@@ -1282,8 +1282,7 @@ QString paramString(const QString &group, const QList<Param> &parameters)
for (QList<Param>::ConstIterator it = parameters.constBegin();
it != parameters.constEnd(); ++it) {
if (paramString.contains("$(" + (*it).name + ')')) {
- QString tmp;
- tmp.sprintf("%%%d", i++);
+ const QString tmp = QStringLiteral("%%1").arg(i++);
paramString.replace("$(" + (*it).name + ')', tmp);
arguments += ".arg( mParam" + (*it).name + " )";
}