Add missing auto opportunities
authorKevin Ottens <kevin.ottens@nextcloud.com>
Wed, 27 May 2020 18:23:36 +0000 (20:23 +0200)
committerCamila <smayres@gmail.com>
Wed, 3 Jun 2020 14:02:43 +0000 (16:02 +0200)
Somehow forgot to run it on the updater code

Signed-off-by: Kevin Ottens <kevin.ottens@nextcloud.com>
.clang-tidy
src/gui/application.cpp
src/gui/generalsettings.cpp
src/gui/updater/ocupdater.cpp

index 039e5d385625767902f99c31b25342c39589bd9c..071f522fd77441a6335209883f75fbc04ad852eb 100644 (file)
@@ -4,6 +4,7 @@ Checks: '-*,
     modernize-redundant-void-arg,
     modernize-replace-*,
     modernize-shrink-to-fit,
+    modernize-use-auto,
     modernize-use-bool-literals,
     modernize-use-emplace,
     modernize-use-noexcept,
index 9083924fc2d4e332535ba87fa9de26c35fe7f2fa..be5c098fe618e98a2ed34a3461fe2acf6dd4cdb3 100644 (file)
@@ -261,7 +261,7 @@ Application::Application(int &argc, char **argv)
 
 #if defined(BUILD_UPDATER)
     // Update checks
-    UpdaterScheduler *updaterScheduler = new UpdaterScheduler(this);
+    auto *updaterScheduler = new UpdaterScheduler(this);
     connect(updaterScheduler, &UpdaterScheduler::updaterAnnouncement,
         _gui.data(), &ownCloudGui::slotShowTrayMessage);
     connect(updaterScheduler, &UpdaterScheduler::requestRestart,
index 40362cc64c46b12f530ec66d27e19a98b5be2e9c..34672aae7645ca4a5f77bed7a634f247f2176b12 100644 (file)
@@ -163,7 +163,7 @@ void GeneralSettings::loadMiscSettings()
 void GeneralSettings::slotUpdateInfo()
 {
     // Note: the sparkle-updater is not an OCUpdater
-    OCUpdater *updater = qobject_cast<OCUpdater *>(Updater::instance());
+    auto *updater = qobject_cast<OCUpdater *>(Updater::instance());
     if (ConfigFile().skipUpdateCheck()) {
         updater = nullptr; // don't show update info if updates are disabled
     }
@@ -194,7 +194,7 @@ void GeneralSettings::slotUpdateInfo()
 
 void GeneralSettings::slotUpdateCheckNow()
 {
-    OCUpdater *updater = qobject_cast<OCUpdater *>(Updater::instance());
+    auto *updater = qobject_cast<OCUpdater *>(Updater::instance());
     if (ConfigFile().skipUpdateCheck()) {
         updater = nullptr; // don't show update info if updates are disabled
     }
index 18ef64e20fc1dd86f1fc416416d035228891f988..4d3a0d3deddc98d2aec300ccb238ea81f858e3e2 100644 (file)
@@ -43,7 +43,7 @@ UpdaterScheduler::UpdaterScheduler(QObject *parent)
         this, &UpdaterScheduler::slotTimerFired);
 
     // Note: the sparkle-updater is not an OCUpdater
-    if (OCUpdater *updater = qobject_cast<OCUpdater *>(Updater::instance())) {
+    if (auto *updater = qobject_cast<OCUpdater *>(Updater::instance())) {
         connect(updater, &OCUpdater::newUpdateAvailable,
             this, &UpdaterScheduler::updaterAnnouncement);
         connect(updater, &OCUpdater::requestRestart, this, &UpdaterScheduler::requestRestart);
@@ -219,7 +219,7 @@ bool OCUpdater::updateSucceeded() const
 void OCUpdater::slotVersionInfoArrived()
 {
     _timeoutWatchdog->stop();
-    QNetworkReply *reply = qobject_cast<QNetworkReply *>(sender());
+    auto *reply = qobject_cast<QNetworkReply *>(sender());
     reply->deleteLater();
     if (reply->error() != QNetworkReply::NoError) {
         qCWarning(lcUpdater) << "Failed to reach version check url: " << reply->errorString();
@@ -254,7 +254,7 @@ NSISUpdater::NSISUpdater(const QUrl &url)
 
 void NSISUpdater::slotWriteFile()
 {
-    QNetworkReply *reply = qobject_cast<QNetworkReply *>(sender());
+    auto *reply = qobject_cast<QNetworkReply *>(sender());
     if (_file->isOpen()) {
         _file->write(reply->readAll());
     }
@@ -262,7 +262,7 @@ void NSISUpdater::slotWriteFile()
 
 void NSISUpdater::slotDownloadFinished()
 {
-    QNetworkReply *reply = qobject_cast<QNetworkReply *>(sender());
+    auto *reply = qobject_cast<QNetworkReply *>(sender());
     reply->deleteLater();
     if (reply->error() != QNetworkReply::NoError) {
         setDownloadState(DownloadFailed);
@@ -319,7 +319,7 @@ void NSISUpdater::versionInfoArrived(const UpdateInfo &info)
 void NSISUpdater::showDialog(const UpdateInfo &info)
 {
     // if the version tag is set, there is a newer version.
-    QDialog *msgBox = new QDialog;
+    auto *msgBox = new QDialog;
     msgBox->setAttribute(Qt::WA_DeleteOnClose);
 
     QIcon infoIcon = msgBox->style()->standardIcon(QStyle::SP_MessageBoxInformation, nullptr, nullptr);
@@ -327,16 +327,16 @@ void NSISUpdater::showDialog(const UpdateInfo &info)
 
     msgBox->setWindowIcon(infoIcon);
 
-    QVBoxLayout *layout = new QVBoxLayout(msgBox);
-    QHBoxLayout *hlayout = new QHBoxLayout;
+    auto *layout = new QVBoxLayout(msgBox);
+    auto *hlayout = new QHBoxLayout;
     layout->addLayout(hlayout);
 
     msgBox->setWindowTitle(tr("New Version Available"));
 
-    QLabel *ico = new QLabel;
+    auto *ico = new QLabel;
     ico->setFixedSize(iconSize, iconSize);
     ico->setPixmap(infoIcon.pixmap(iconSize));
-    QLabel *lbl = new QLabel;
+    auto *lbl = new QLabel;
     QString txt = tr("<p>A new version of the %1 Client is available.</p>"
                      "<p><b>%2</b> is available for download. The installed version is %3.</p>")
                       .arg(Utility::escape(Theme::instance()->appNameGUI()),
@@ -349,7 +349,7 @@ void NSISUpdater::showDialog(const UpdateInfo &info)
     hlayout->addWidget(ico);
     hlayout->addWidget(lbl);
 
-    QDialogButtonBox *bb = new QDialogButtonBox;
+    auto *bb = new QDialogButtonBox;
     bb->setWindowFlags(bb->windowFlags() & ~Qt::WindowContextHelpButtonHint);
     QPushButton *skip = bb->addButton(tr("Skip this version"), QDialogButtonBox::ResetRole);
     QPushButton *reject = bb->addButton(tr("Skip this time"), QDialogButtonBox::AcceptRole);