From 6e62c8b430b70c1aaf92e7f9cc793719afdbfafb Mon Sep 17 00:00:00 2001 From: Kevin Ottens Date: Wed, 27 May 2020 14:36:07 +0200 Subject: [PATCH] Use the return braced init list pattern This way we avoid repeating the return type while it is already known. Signed-off-by: Kevin Ottens --- .../QProgressIndicator/QProgressIndicator.cpp | 2 +- src/gui/folderstatusdelegate.cpp | 2 +- src/gui/folderstatusmodel.cpp | 22 +++++++++---------- src/gui/folderstatusview.cpp | 2 +- src/gui/generalsettings.cpp | 5 ++++- src/gui/networksettings.cpp | 5 ++++- src/gui/wizard/slideshow.cpp | 5 ++++- src/libsync/syncengine.cpp | 2 +- src/libsync/syncfilestatustracker.cpp | 2 +- src/libsync/theme.cpp | 6 ++--- test/testsyncfilestatustracker.cpp | 2 +- 11 files changed, 32 insertions(+), 23 deletions(-) diff --git a/src/3rdparty/QProgressIndicator/QProgressIndicator.cpp b/src/3rdparty/QProgressIndicator/QProgressIndicator.cpp index ec2a6fe84..3d536f243 100644 --- a/src/3rdparty/QProgressIndicator/QProgressIndicator.cpp +++ b/src/3rdparty/QProgressIndicator/QProgressIndicator.cpp @@ -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 diff --git a/src/gui/folderstatusdelegate.cpp b/src/gui/folderstatusdelegate.cpp index 9aa41e74e..6ff03300e 100644 --- a/src/gui/folderstatusdelegate.cpp +++ b/src/gui/folderstatusdelegate.cpp @@ -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) diff --git a/src/gui/folderstatusmodel.cpp b/src/gui/folderstatusmodel.cpp index ef200277a..350e5c308 100644 --- a/src/gui/folderstatusmodel.cpp +++ b/src/gui/folderstatusmodel.cpp @@ -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(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; diff --git a/src/gui/folderstatusview.cpp b/src/gui/folderstatusview.cpp index 6af4283fd..a353bc49f 100644 --- a/src/gui/folderstatusview.cpp +++ b/src/gui/folderstatusview.cpp @@ -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; } diff --git a/src/gui/generalsettings.cpp b/src/gui/generalsettings.cpp index 901e50a39..df7a9d7d0 100644 --- a/src/gui/generalsettings.cpp +++ b/src/gui/generalsettings.cpp @@ -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() diff --git a/src/gui/networksettings.cpp b/src/gui/networksettings.cpp index ff80b05c7..b2b72ed08 100644 --- a/src/gui/networksettings.cpp +++ b/src/gui/networksettings.cpp @@ -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() diff --git a/src/gui/wizard/slideshow.cpp b/src/gui/wizard/slideshow.cpp index 994e4d9ca..ab87be502 100644 --- a/src/gui/wizard/slideshow.cpp +++ b/src/gui/wizard/slideshow.cpp @@ -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) diff --git a/src/libsync/syncengine.cpp b/src/libsync/syncengine.cpp index 3ca2563a5..6f7fca1cf 100644 --- a/src/libsync/syncengine.cpp +++ b/src/libsync/syncengine.cpp @@ -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) diff --git a/src/libsync/syncfilestatustracker.cpp b/src/libsync/syncfilestatustracker.cpp index c492b34d5..03233e1de 100644 --- a/src/libsync/syncfilestatustracker.cpp +++ b/src/libsync/syncfilestatustracker.cpp @@ -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)) diff --git a/src/libsync/theme.cpp b/src/libsync/theme.cpp index 11d7a1065..645ccff8a 100644 --- a/src/libsync/theme.cpp +++ b/src/libsync/theme.cpp @@ -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() diff --git a/test/testsyncfilestatustracker.cpp b/test/testsyncfilestatustracker.cpp index ab63e3bb5..b55876fad 100644 --- a/test/testsyncfilestatustracker.cpp +++ b/test/testsyncfilestatustracker.cpp @@ -26,7 +26,7 @@ public: if (QFileInfo(at(i)[0].toString()) == file) return at(i)[1].value(); } - return SyncFileStatus(); + return {}; } bool statusEmittedBefore(const QString &firstPath, const QString &secondPath) const {