telepathy-qt icon indicating copy to clipboard operation
telepathy-qt copied to clipboard

Modernize the codebase (C++11)

Open Kaffeine opened this issue 9 years ago • 6 comments

Kaffeine avatar Sep 09 '16 23:09 Kaffeine

Are you aware of clang-tidy? Fixing at least the override and nullptr warnings should be fairly straightforward using it (https://www.kdab.com/clang-tidy-part-1-modernize-source-code-using-c11c14/).

jbruechert avatar Jan 17 '20 19:01 jbruechert

Yeah, I had it in mind and I ran it on some projects, but I had excuses to not run it on TelepathyQt yet. Thank you for the remind, I think it is a good time to use it right now.

Kaffeine avatar Jan 18 '20 16:01 Kaffeine

I also would like to apply your https://github.com/JBBgameich/telepathy-qt/commit/3bbe12683d8247948175a42e3ebbd1410a591a5e, :-) but we can't rely on Qt > 5.6 yet. (e.g. QDateTime::setSecsSinceEpoch() introduced in Qt 5.8) Would you mind to rework the commit to support Qt 5.6 or split the changes, so we can apply at least qVariantFromValue -> QVariant::fromValue and std::sort replacements? (I'm running override and nullptr conversions so those are going to be irrelevant).

Kaffeine avatar Jan 18 '20 16:01 Kaffeine

Opened https://github.com/TelepathyIM/telepathy-qt/pull/36 with the changes.

jbruechert avatar Jan 18 '20 18:01 jbruechert

Most of the work is done. Still TODO:

  • Use Qt5 connections wherever applicable
  • Use default member initializers instead of code in constructors
  • Use initializer lists wherever applicable
  • Use range-based for where it makes sense

Get rid of stuff like this:

QVariantMap map;
map.insert(QLatin1String(".AvailableMechanisms"),
           QVariant::fromValue(mPriv->adaptee->availableMechanisms()));
map.insert(QLatin1String(".HasInitialData"),
           QVariant::fromValue(mPriv->adaptee->hasInitialData()));
map.insert(QLatin1String(".CanTryAgain"),
           QVariant::fromValue(mPriv->adaptee->canTryAgain()));
map.insert(QLatin1String(".AuthorizationIdentity"),
           QVariant::fromValue(mPriv->adaptee->authorizationIdentity()));
map.insert(QLatin1String(".DefaultUsername"),
           QVariant::fromValue(mPriv->adaptee->defaultUsername()));
map.insert(QLatin1String(".DefaultRealm"),
           QVariant::fromValue(mPriv->adaptee->defaultRealm()));
map.insert(QLatin1String(".MaySaveResponse"),
           QVariant::fromValue(mPriv->adaptee->maySaveResponse()));
return map;

Kaffeine avatar Jan 19 '20 23:01 Kaffeine

For the old-style connects we could look into automating most of the work using clazy. The harder part will be the spec code generator.

jbruechert avatar Jan 19 '20 23:01 jbruechert