Use the return braced init list pattern
authorKevin Ottens <kevin.ottens@nextcloud.com>
Wed, 27 May 2020 12:36:07 +0000 (14:36 +0200)
committerKevin Ottens <kevin.ottens@nextcloud.com>
Wed, 27 May 2020 12:36:07 +0000 (14:36 +0200)
This way we avoid repeating the return type while it is already known.

Signed-off-by: Kevin Ottens <kevin.ottens@nextcloud.com>
src/3rdparty/QProgressIndicator/QProgressIndicator.cpp
src/gui/folderstatusdelegate.cpp
src/gui/folderstatusmodel.cpp
src/gui/folderstatusview.cpp
src/gui/generalsettings.cpp
src/gui/networksettings.cpp
src/gui/wizard/slideshow.cpp
src/libsync/syncengine.cpp
src/libsync/syncfilestatustracker.cpp
src/libsync/theme.cpp
test/testsyncfilestatustracker.cpp

index ec2a6fe84116197b2c2ba22b395f1cd3461dd5fe..3d536f243f1609c06cc7a2dcf78e63d7e4301d38 100644 (file)
@@ -93,7 +93,7 @@ void QProgressIndicator::setColor(const QColor & color)
 
 QSize QProgressIndicator::sizeHint() const
 {
-    return QSize(20,20);
+    return {20, 20};
 }
 
 int QProgressIndicator::heightForWidth(int w) const
index 9aa41e74eafc15145621ba647186098281bd35d8..6ff03300e495ebcf33f921b6524faadf246cb955 100644 (file)
@@ -91,7 +91,7 @@ QSize FolderStatusDelegate::sizeHint(const QStyleOptionViewItem &option,
         h += margin + 2 * margin + errMsgs.count() * fm.height();
     }
 
-    return QSize(0, h);
+    return {0, h};
 }
 
 int FolderStatusDelegate::rootFolderHeightWithoutErrors(const QFontMetrics &fm, const QFontMetrics &aliasFm)
index ef200277a869f1bb8d49562a336d98a361270296..350e5c3084fbebe2ab30215d7ebe6da7978b22e9 100644 (file)
@@ -426,7 +426,7 @@ FolderStatusModel::SubFolderInfo *FolderStatusModel::infoForFileId(const QByteAr
 QModelIndex FolderStatusModel::indexForPath(Folder *f, const QString &path) const
 {
     if (!f) {
-        return QModelIndex();
+        return {};
     }
 
     int slashPos = path.lastIndexOf('/');
@@ -444,10 +444,10 @@ QModelIndex FolderStatusModel::indexForPath(Folder *f, const QString &path) cons
                         return index(j, 0, index(i));
                     }
                 }
-                return QModelIndex();
+                return {};
             }
         }
-        return QModelIndex();
+        return {};
     }
 
     auto parent = indexForPath(f, path.left(slashPos));
@@ -461,7 +461,7 @@ QModelIndex FolderStatusModel::indexForPath(Folder *f, const QString &path) cons
 
     auto parentInfo = infoForIndex(parent);
     if (!parentInfo) {
-        return QModelIndex();
+        return {};
     }
     for (int i = 0; i < parentInfo->_subs.size(); ++i) {
         if (parentInfo->_subs.at(i)._name == path.mid(slashPos + 1)) {
@@ -469,7 +469,7 @@ QModelIndex FolderStatusModel::indexForPath(Folder *f, const QString &path) cons
         }
     }
 
-    return QModelIndex();
+    return {};
 }
 
 QModelIndex FolderStatusModel::index(int row, int column, const QModelIndex &parent) const
@@ -480,7 +480,7 @@ QModelIndex FolderStatusModel::index(int row, int column, const QModelIndex &par
     switch (classify(parent)) {
     case AddButton:
     case FetchLabel:
-        return QModelIndex();
+        return {};
     case RootFolder:
         if (_folders.count() <= parent.row())
             return QModelIndex(); // should not happen
@@ -488,26 +488,26 @@ QModelIndex FolderStatusModel::index(int row, int column, const QModelIndex &par
     case SubFolder: {
         auto pinfo = static_cast<SubFolderInfo *>(parent.internalPointer());
         if (pinfo->_subs.count() <= parent.row())
-            return QModelIndex(); // should not happen
+            return {}; // should not happen
         auto &info = pinfo->_subs[parent.row()];
         if (!info.hasLabel()
             && info._subs.count() <= row)
-            return QModelIndex(); // should not happen
+            return {}; // should not happen
         return createIndex(row, column, &info);
     }
     }
-    return QModelIndex();
+    return {};
 }
 
 QModelIndex FolderStatusModel::parent(const QModelIndex &child) const
 {
     if (!child.isValid()) {
-        return QModelIndex();
+        return {};
     }
     switch (classify(child)) {
     case RootFolder:
     case AddButton:
-        return QModelIndex();
+        return {};
     case SubFolder:
     case FetchLabel:
         break;
index 6af4283fd430a8a72dd146b59a41060dd33250b7..a353bc49f269a48a4ee6b6325603927ce3ee3f0f 100644 (file)
@@ -25,7 +25,7 @@ QModelIndex FolderStatusView::indexAt(const QPoint &point) const
 {
     QModelIndex index = QTreeView::indexAt(point);
     if (index.data(FolderStatusDelegate::AddButton).toBool() && !visualRect(index).contains(point)) {
-        return QModelIndex();
+        return {};
     }
     return index;
 }
index 901e50a3980575eb3a13f0690dd7a356b8570c3a..df7a9d7d0353de5e0ad39f59fab3bf01c9d07af6 100644 (file)
@@ -135,7 +135,10 @@ GeneralSettings::~GeneralSettings()
 
 QSize GeneralSettings::sizeHint() const
 {
-    return QSize(ownCloudGui::settingsDialogSize().width(), QWidget::sizeHint().height());
+    return {
+        ownCloudGui::settingsDialogSize().width(),
+        QWidget::sizeHint().height()
+    };
 }
 
 void GeneralSettings::loadMiscSettings()
index ff80b05c75398291d99bdbef1ceed3f7a1626dc5..b2b72ed0882a6ce7395596ebab31bc0a7596b3dc 100644 (file)
@@ -89,7 +89,10 @@ NetworkSettings::~NetworkSettings()
 
 QSize NetworkSettings::sizeHint() const
 {
-    return QSize(ownCloudGui::settingsDialogSize().width(), QWidget::sizeHint().height());
+    return {
+        ownCloudGui::settingsDialogSize().width(),
+        QWidget::sizeHint().height()
+    };
 }
 
 void NetworkSettings::loadProxySettings()
index 994e4d9ca9189d2c2134548ac401c6e3d39870c9..ab87be502a6624c5b32f5f723b7099c9aaa8a8df 100644 (file)
@@ -101,7 +101,10 @@ QSize SlideShow::sizeHint() const
         pixmapSize.setWidth(std::max(pixmap.width(), pixmapSize.width()));
         pixmapSize.setHeight(std::max(pixmap.height(), pixmapSize.height()));
     }
-    return QSize(std::max(labelSize.width(), pixmapSize.width()), labelSize.height() + Spacing + pixmapSize.height());
+    return {
+        std::max(labelSize.width(), pixmapSize.width()),
+        labelSize.height() + Spacing + pixmapSize.height()
+    };
 }
 
 void SlideShow::startShow(int interval)
index 3ca2563a57c74d8a078038817f73d9625358d0ca..6f7fca1cf6ecd519713a78f701bed3066e398423 100644 (file)
@@ -1593,7 +1593,7 @@ RemotePermissions SyncEngine::getPermissions(const QString &file) const
     if (it != _csync_ctx->remote.files.end()) {
         return it->second->remotePerm;
     }
-    return RemotePermissions();
+    return {};
 }
 
 void SyncEngine::restoreOldFiles(SyncFileItemVector &syncItems)
index c492b34d54c5041a37078a2f3688ee38548e4a5b..03233e1deb5a4138006f662383f50ffc9e2bb74c 100644 (file)
@@ -139,7 +139,7 @@ SyncFileStatus SyncFileStatusTracker::fileStatus(const QString &relativePath)
     if (_syncEngine->excludedFiles().isExcluded(_syncEngine->localPath() + relativePath,
             _syncEngine->localPath(),
             _syncEngine->ignoreHiddenFiles())) {
-        return SyncFileStatus(SyncFileStatus::StatusWarning);
+        return SyncFileStatus::StatusWarning;
     }
 
     if (_dirtyPaths.contains(relativePath))
index 11d7a10652ebdc997b1e7a6f9078336ada5c6208..645ccff8aba2751238403f0d0e32faac9bfa65eb 100644 (file)
@@ -447,12 +447,12 @@ QIcon Theme::folderOfflineIcon(bool sysTray) const
 
 QColor Theme::wizardHeaderTitleColor() const
 {
-    return QColor(APPLICATION_WIZARD_HEADER_TITLE_COLOR);
+    return {APPLICATION_WIZARD_HEADER_TITLE_COLOR};
 }
 
 QColor Theme::wizardHeaderBackgroundColor() const
 {
-    return QColor(APPLICATION_WIZARD_HEADER_BACKGROUND_COLOR);
+    return {APPLICATION_WIZARD_HEADER_BACKGROUND_COLOR};
 }
 
 QPixmap Theme::wizardHeaderLogo() const
@@ -581,7 +581,7 @@ bool Theme::isDarkColor(const QColor &color)
 
 QColor Theme::getBackgroundAwareLinkColor(const QColor &backgroundColor)
 {
-    return QColor((isDarkColor(backgroundColor) ? QColor("#6193dc") : QGuiApplication::palette().color(QPalette::Link)));
+    return {(isDarkColor(backgroundColor) ? QColor("#6193dc") : QGuiApplication::palette().color(QPalette::Link))};
 }
 
 QColor Theme::getBackgroundAwareLinkColor()
index ab63e3bb5754f08a82823c68556dff276f743e44..b55876fad0c1950fa583420763c90d36be777437 100644 (file)
@@ -26,7 +26,7 @@ public:
             if (QFileInfo(at(i)[0].toString()) == file)
                 return at(i)[1].value<SyncFileStatus>();
         }
-        return SyncFileStatus();
+        return {};
     }
 
     bool statusEmittedBefore(const QString &firstPath, const QString &secondPath) const {