From fa8978ce99ab1b5a9f11c21509f0aec93a0df1cc Mon Sep 17 00:00:00 2001 From: wmayer Date: Thu, 17 Aug 2023 15:12:18 +0200 Subject: [PATCH] Gui: modernize C++: return braced init list --- src/Gui/Application.cpp | 6 +- src/Gui/BitmapFactory.cpp | 2 +- src/Gui/Camera.cpp | 18 +- src/Gui/Command.cpp | 4 +- src/Gui/CommandCompleter.cpp | 6 +- src/Gui/CommandPyImp.cpp | 2 +- src/Gui/DlgCheckableMessageBox.cpp | 2 +- src/Gui/DlgCustomizeSpaceball.cpp | 78 ++++--- src/Gui/DlgPropertyLink.cpp | 2 +- src/Gui/DlgSettingsImageImp.cpp | 4 +- src/Gui/DocumentModel.cpp | 20 +- src/Gui/DocumentPyImp.cpp | 4 +- src/Gui/DownloadManager.cpp | 4 +- src/Gui/ExpressionBinding.cpp | 2 +- src/Gui/ExpressionCompleter.cpp | 12 +- src/Gui/FileDialog.cpp | 4 +- src/Gui/Flag.cpp | 2 +- src/Gui/GraphvizView.cpp | 8 +- src/Gui/InputField.cpp | 4 +- src/Gui/InputVector.cpp | 2 +- src/Gui/MDIView.cpp | 2 +- src/Gui/ManualAlignment.cpp | 2 +- src/Gui/NavigationStyle.cpp | 10 +- src/Gui/NotificationArea.cpp | 2 +- src/Gui/NotificationBox.cpp | 2 +- src/Gui/PythonDebugger.cpp | 2 +- src/Gui/PythonWorkbenchPyImp.cpp | 2 +- src/Gui/QSint/actionpanel/actionbox.cpp | 2 +- src/Gui/QSint/actionpanel/actiongroup.cpp | 2 +- src/Gui/QSint/actionpanel/actionpanel.cpp | 2 +- src/Gui/QuantitySpinBox.cpp | 4 +- src/Gui/Quarter/QuarterWidget.cpp | 6 +- src/Gui/Quarter/SoQTQuarterAdaptor.cpp | 2 +- src/Gui/SceneInspector.cpp | 4 +- src/Gui/Selection.cpp | 2 +- src/Gui/SelectionObjectPyImp.cpp | 10 +- src/Gui/SoFCUnifiedSelection.cpp | 2 +- src/Gui/SyntaxHighlighter.cpp | 4 +- src/Gui/TaskView/TaskDialogPython.cpp | 2 +- src/Gui/TaskView/TaskView.cpp | 4 +- src/Gui/TextEdit.cpp | 2 +- src/Gui/VectorListEditor.cpp | 14 +- src/Gui/View3DInventorViewer.cpp | 22 +- src/Gui/ViewProvider.cpp | 6 +- src/Gui/ViewProvider.h | 6 +- src/Gui/ViewProviderDocumentObjectGroup.cpp | 2 +- src/Gui/ViewProviderDocumentObjectPyImp.cpp | 2 +- src/Gui/ViewProviderExtension.h | 8 +- src/Gui/ViewProviderExtensionPyImp.cpp | 2 +- .../ViewProviderGeoFeatureGroupExtension.cpp | 2 +- src/Gui/ViewProviderGroupExtension.cpp | 2 +- src/Gui/ViewProviderLinkPyImp.cpp | 2 +- src/Gui/ViewProviderPyImp.cpp | 8 +- src/Gui/ViewProviderPythonFeature.cpp | 6 +- src/Gui/Widgets.cpp | 4 +- src/Gui/WorkbenchPyImp.cpp | 2 +- src/Gui/propertyeditor/PropertyItem.cpp | 202 +++++++++--------- src/Gui/propertyeditor/PropertyModel.cpp | 16 +- 58 files changed, 286 insertions(+), 276 deletions(-) diff --git a/src/Gui/Application.cpp b/src/Gui/Application.cpp index 55832f4997..3d81c48b2b 100644 --- a/src/Gui/Application.cpp +++ b/src/Gui/Application.cpp @@ -1573,7 +1573,7 @@ QPixmap Application::workbenchIcon(const QString& wb) const if (!s.isEmpty()) return icon.pixmap(s[0]); } - return QPixmap(); + return {}; } QString Application::workbenchToolTip(const QString& wb) const @@ -1597,7 +1597,7 @@ QString Application::workbenchToolTip(const QString& wb) const } } - return QString(); + return {}; } QString Application::workbenchMenuText(const QString& wb) const @@ -1622,7 +1622,7 @@ QString Application::workbenchMenuText(const QString& wb) const } } - return QString(); + return {}; } QStringList Application::workbenches() const diff --git a/src/Gui/BitmapFactory.cpp b/src/Gui/BitmapFactory.cpp index 2746c3f5a7..7a3adbc7a5 100644 --- a/src/Gui/BitmapFactory.cpp +++ b/src/Gui/BitmapFactory.cpp @@ -239,7 +239,7 @@ bool BitmapFactoryInst::loadPixmap(const QString& filename, QPixmap& icon) const QPixmap BitmapFactoryInst::pixmap(const char* name) const { if (!name || *name == '\0') - return QPixmap(); + return {}; // as very first test check whether the pixmap is in the cache QMap::Iterator it = d->xpmCache.find(name); diff --git a/src/Gui/Camera.cpp b/src/Gui/Camera.cpp index 1084da3e4f..b5a44020c5 100644 --- a/src/Gui/Camera.cpp +++ b/src/Gui/Camera.cpp @@ -95,34 +95,34 @@ vz.z=0 SbRotation Camera::top() { - return SbRotation(0, 0, 0, 1); + return {0, 0, 0, 1}; } SbRotation Camera::bottom() { - return SbRotation(1, 0, 0, 0); + return {1, 0, 0, 0}; } SbRotation Camera::front() { auto root = (float)(sqrt(2.0)/2.0); - return SbRotation(root, 0, 0, root); + return {root, 0, 0, root}; } SbRotation Camera::rear() { auto root = (float)(sqrt(2.0)/2.0); - return SbRotation(0, root, root, 0); + return {0, root, root, 0}; } SbRotation Camera::right() { - return SbRotation(0.5, 0.5, 0.5, 0.5); + return {0.5, 0.5, 0.5, 0.5}; } SbRotation Camera::left() { - return SbRotation(-0.5, 0.5, 0.5, -0.5); + return {-0.5, 0.5, 0.5, -0.5}; } SbRotation Camera::isometric() @@ -146,17 +146,17 @@ SbRotation Camera::isometric() //#p3=App.Rotation(App.Vector(1,1,0),45) //p3=App.Rotation(App.Vector(1,1,0),degrees(asin(-sqrt(1.0/3.0)))) //p4=p3.multiply(p2).multiply(p1) - return SbRotation(0.424708f, 0.17592f, 0.339851f, 0.820473f); + return {0.424708F, 0.17592F, 0.339851F, 0.820473F}; } SbRotation Camera::dimetric() { - return SbRotation(0.567952f, 0.103751f, 0.146726f, 0.803205f); + return {0.567952F, 0.103751F, 0.146726F, 0.803205F}; } SbRotation Camera::trimetric() { - return SbRotation(0.446015f, 0.119509f, 0.229575f, 0.856787f); + return {0.446015F, 0.119509F, 0.229575F, 0.856787F}; } SbRotation Camera::rotation(Camera::Orientation view) diff --git a/src/Gui/Command.cpp b/src/Gui/Command.cpp index a3c70957cf..29da29c69e 100644 --- a/src/Gui/Command.cpp +++ b/src/Gui/Command.cpp @@ -579,7 +579,7 @@ std::string Command::getObjectCmd(const char *Name, const App::Document *doc, { if(!doc) doc = App::GetApplication().getActiveDocument(); if(!doc || !Name) - return std::string("None"); + return {"None"}; std::ostringstream str; if(prefix) str << prefix; @@ -594,7 +594,7 @@ std::string Command::getObjectCmd(const App::DocumentObject *obj, const char *prefix, const char *postfix, bool gui) { if(!obj || !obj->getNameInDocument()) - return std::string("None"); + return {"None"}; return getObjectCmd(obj->getNameInDocument(), obj->getDocument(), prefix, postfix,gui); } diff --git a/src/Gui/CommandCompleter.cpp b/src/Gui/CommandCompleter.cpp index 609fd3fef2..df572b343a 100644 --- a/src/Gui/CommandCompleter.cpp +++ b/src/Gui/CommandCompleter.cpp @@ -87,13 +87,13 @@ public: QModelIndex parent(const QModelIndex &) const override { - return QModelIndex(); + return {}; } QVariant data(const QModelIndex & index, int role) const override { if (index.row() < 0 || index.row() >= (int)_Commands.size()) - return QVariant(); + return {}; auto &info = _Commands[index.row()]; @@ -125,7 +125,7 @@ public: default: break; } - return QVariant(); + return {}; } QModelIndex index(int row, int, const QModelIndex &) const override diff --git a/src/Gui/CommandPyImp.cpp b/src/Gui/CommandPyImp.cpp index f563cb287d..448effd2a6 100644 --- a/src/Gui/CommandPyImp.cpp +++ b/src/Gui/CommandPyImp.cpp @@ -44,7 +44,7 @@ // returns a string which represents the object e.g. when printed in python std::string CommandPy::representation() const { - return std::string(""); + return {""}; } PyObject* CommandPy::get(PyObject *args) diff --git a/src/Gui/DlgCheckableMessageBox.cpp b/src/Gui/DlgCheckableMessageBox.cpp index bda4d147de..c4d206969b 100644 --- a/src/Gui/DlgCheckableMessageBox.cpp +++ b/src/Gui/DlgCheckableMessageBox.cpp @@ -61,7 +61,7 @@ QPixmap getStandardIcon(QWidget* widget, QStyle::StandardPixmap standardPixmap) #endif } - return QPixmap(); + return {}; } void DlgCheckableMessageBox::showMessage(const QString& header, const QString& message, bool check, const QString& checkText) diff --git a/src/Gui/DlgCustomizeSpaceball.cpp b/src/Gui/DlgCustomizeSpaceball.cpp index fdd7535fa6..d650d625d0 100644 --- a/src/Gui/DlgCustomizeSpaceball.cpp +++ b/src/Gui/DlgCustomizeSpaceball.cpp @@ -202,21 +202,21 @@ QVariant ButtonModel::data (const QModelIndex &index, int role) const if (index.row() >= (int)groupVector.size()) { Base::Console().Log("index error in ButtonModel::data\n"); - return QVariant(); + return {}; } if (role == Qt::DisplayRole) - return QVariant(getLabel(index.row())); + return {getLabel(index.row())}; if (role == Qt::DecorationRole) { static QPixmap icon(BitmapFactory().pixmap("spaceball_button").scaled (32, 32, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); - return QVariant(icon); + return {icon}; } if (role == Qt::UserRole) - return QVariant(QString::fromStdString(groupVector.at(index.row())->GetASCII("Command"))); + return {QString::fromStdString(groupVector.at(index.row())->GetASCII("Command"))}; if (role == Qt::SizeHintRole) - return QVariant(QSize(32, 32)); - return QVariant(); + return {QSize(32, 32)}; + return {}; } void ButtonModel::insertButtonRows(int number) @@ -336,10 +336,12 @@ void CommandView::goClicked(const QModelIndex &index) CommandNode::CommandNode(NodeType typeIn) { + //NOLINTBEGIN nodeType = typeIn; parent = nullptr; children.clear(); aCommand = nullptr; + //NOLINTEND } CommandNode::~CommandNode() @@ -351,8 +353,10 @@ CommandNode::~CommandNode() CommandModel::CommandModel(QObject *parent) : QAbstractItemModel(parent) { + //NOLINTBEGIN rootNode = nullptr; initialize(); + //NOLINTEND } CommandModel::~CommandModel() @@ -364,13 +368,13 @@ CommandModel::~CommandModel() QModelIndex CommandModel::index(int row, int column, const QModelIndex &parent) const { if (!rootNode) - return QModelIndex(); + return {}; if (!parent.isValid()) return createIndex(row, column, rootNode->children.at(row)); CommandNode *parentNode = nodeFromIndex(parent); if (!parentNode) - return QModelIndex(); + return {}; return createIndex(row, column, parentNode->children.at(row)); } @@ -378,17 +382,17 @@ QModelIndex CommandModel::parent(const QModelIndex &index) const { CommandNode *base = nodeFromIndex(index); if (!base) - return QModelIndex(); + return {}; CommandNode *parentNode = base->parent; if (!parentNode) - return QModelIndex(); + return {}; CommandNode *grandParentNode = parentNode->parent; if (!grandParentNode) - return QModelIndex(); + return {}; int row = grandParentNode->children.indexOf(parentNode); if (row == -1) - return QModelIndex(); + return {}; return createIndex(row, index.column(), parentNode); } @@ -413,19 +417,19 @@ QVariant CommandModel::data(const QModelIndex &index, int role) const { CommandNode *node = nodeFromIndex(index); if (!node) - return QVariant(); + return {}; if (role == Qt::DisplayRole) { if (node->nodeType == CommandNode::CommandType) - return QVariant(qApp->translate(node->aCommand->className(), node->aCommand->getMenuText())); + return {qApp->translate(node->aCommand->className(), node->aCommand->getMenuText())}; if (node->nodeType == CommandNode::GroupType) { if (node->children.empty()) - return QVariant(); + return {}; CommandNode *childNode = node->children.at(0); - return QVariant(childNode->aCommand->translatedGroupName()); + return {qApp->translate(childNode->aCommand->className(), childNode->aCommand->getGroupName())}; } - return QVariant(); + return {}; } if (role == Qt::DecorationRole) { @@ -436,33 +440,35 @@ QVariant CommandModel::data(const QModelIndex &index, int role) const (32, 32, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); } } - if (role == Qt::SizeHintRole) + if (role == Qt::SizeHintRole) { if (node->nodeType == CommandNode::CommandType) - return QVariant(QSize(32, 32)); + return {QSize(32, 32)}; + } if (role == Qt::UserRole) { if (node->nodeType == CommandNode::CommandType) - return QVariant(QString::fromLatin1(node->aCommand->getName())); + return {QString::fromLatin1(node->aCommand->getName())}; if (node->nodeType == CommandNode::GroupType) { if (node->children.empty()) - return QVariant(); + return {}; CommandNode *childNode = node->children.at(0); - return QVariant(QString::fromLatin1(childNode->aCommand->getGroupName())); + return {QString::fromLatin1(childNode->aCommand->getGroupName())}; } - return QVariant(); + return {}; } - if (role == Qt::ToolTipRole) + if (role == Qt::ToolTipRole) { if (node->nodeType == CommandNode::CommandType) - return QVariant(QString::fromLatin1(node->aCommand->getToolTipText())); - return QVariant(); + return {QString::fromLatin1(node->aCommand->getToolTipText())}; + } + return {}; } QVariant CommandModel::headerData(int section, Qt::Orientation orientation, int role) const { if (role == Qt::DisplayRole && orientation == Qt::Horizontal && section == 0) - return QVariant(tr("Commands")); - return QVariant(); + return {tr("Commands")}; + return {}; } Qt::ItemFlags CommandModel::flags (const QModelIndex &index) const @@ -596,8 +602,10 @@ QStringList CommandModel::orderedGroups() PrintModel::PrintModel(QObject *parent, ButtonModel *buttonModelIn, CommandModel *commandModelIn) : QAbstractTableModel(parent) { + //NOLINTBEGIN buttonModel = buttonModelIn; commandModel = commandModelIn; + //NOLINTEND } int PrintModel::rowCount(const QModelIndex &parent) const @@ -625,28 +633,28 @@ QVariant PrintModel::data(const QModelIndex &index, int role) const //command column; QString commandName(buttonModel->data(buttonModel->index(index.row(), 0), Qt::UserRole).toString()); if (commandName.isEmpty()) - return (QVariant()); + return {}; QModelIndexList indexList(commandModel->match(commandModel->index(0,0), Qt::UserRole, QVariant(commandName), 1, Qt::MatchWrap | Qt::MatchRecursive)); if (indexList.isEmpty()) - return QVariant(); + return {}; return commandModel->data(indexList.at(0), role); } - return QVariant(); + return {}; } QVariant PrintModel::headerData(int section, Qt::Orientation orientation, int role) const { if (role != Qt::DisplayRole || orientation != Qt::Horizontal) - return QVariant(); + return {}; if (section == 0) - return QVariant(tr("Button")); + return {tr("Button")}; if (section == 1) - return QVariant(tr("Command")); + return {tr("Command")}; else - return QVariant(); + return {}; } /////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/Gui/DlgPropertyLink.cpp b/src/Gui/DlgPropertyLink.cpp index e1a5dbf429..507b6d948b 100644 --- a/src/Gui/DlgPropertyLink.cpp +++ b/src/Gui/DlgPropertyLink.cpp @@ -187,7 +187,7 @@ static inline bool isLinkSub(const QList& links) QString DlgPropertyLink::formatLinks(App::Document *ownerDoc, QList links) { if(!ownerDoc || links.empty()) - return QString(); + return {}; auto obj = links.front().getObject(); if(!obj) diff --git a/src/Gui/DlgSettingsImageImp.cpp b/src/Gui/DlgSettingsImageImp.cpp index 2eac9773a5..09b0579e4d 100644 --- a/src/Gui/DlgSettingsImageImp.cpp +++ b/src/Gui/DlgSettingsImageImp.cpp @@ -131,7 +131,7 @@ void DlgSettingsImageImp::setImageSize( const QSize& s ) */ QSize DlgSettingsImageImp::imageSize() const { - return QSize( ui->spinWidth->value(), ui->spinHeight->value() ); + return { ui->spinWidth->value(), ui->spinHeight->value() }; } /** @@ -157,7 +157,7 @@ int DlgSettingsImageImp::imageHeight() const QString DlgSettingsImageImp::comment() const { if ( !ui->textEditComment->isEnabled() ) - return QString(); + return {}; else return ui->textEditComment->toPlainText(); } diff --git a/src/Gui/DocumentModel.cpp b/src/Gui/DocumentModel.cpp index ef7362584d..c254b6253c 100644 --- a/src/Gui/DocumentModel.cpp +++ b/src/Gui/DocumentModel.cpp @@ -82,7 +82,7 @@ namespace Gui { virtual QVariant data(int role) const { Q_UNUSED(role); - return QVariant(); + return {}; } virtual bool setData (const QVariant & value, int role) { @@ -199,7 +199,7 @@ namespace Gui { else if (role == Qt::DisplayRole) { return DocumentModel::tr("Application"); } - return QVariant(); + return {}; } // ------------------------------------------------------------------------ @@ -271,7 +271,7 @@ namespace Gui { return static_cast(font); } - return QVariant(); + return {}; } // ------------------------------------------------------------------------ @@ -326,7 +326,7 @@ namespace Gui { return static_cast(font); } - return QVariant(); + return {}; } // ------------------------------------------------------------------------ @@ -608,7 +608,7 @@ int DocumentModel::columnCount (const QModelIndex & /*parent*/) const QVariant DocumentModel::data (const QModelIndex & index, int role) const { if (!index.isValid()) - return QVariant(); + return {}; return static_cast(index.internalPointer())->data(role); } @@ -625,7 +625,7 @@ Qt::ItemFlags DocumentModel::flags(const QModelIndex &index) const // return Qt::ItemIsEnabled; //return QAbstractItemModel::flags(index); if (!index.isValid()) - return Qt::ItemFlags(); + return {}; return static_cast(index.internalPointer())->flags(); } @@ -637,14 +637,14 @@ QModelIndex DocumentModel::index (int row, int column, const QModelIndex & paren else item = static_cast(parent.internalPointer())->child(row); if (!item) - return QModelIndex(); + return {}; return createIndex(row, column, item); } QModelIndex DocumentModel::parent (const QModelIndex & index) const { if (!index.isValid() || index.internalPointer() == d->rootItem) - return QModelIndex(); + return {}; DocumentModelIndex* item = nullptr; item = static_cast(index.internalPointer()); DocumentModelIndex* parent = item->parent(); @@ -665,11 +665,11 @@ QVariant DocumentModel::headerData (int section, Qt::Orientation orientation, in Q_UNUSED(section); if (orientation == Qt::Horizontal) { if (role != Qt::DisplayRole) - return QVariant(); + return {}; return tr("Labels & Attributes"); } - return QVariant(); + return {}; } bool DocumentModel::setHeaderData (int, Qt::Orientation, const QVariant &, int) diff --git a/src/Gui/DocumentPyImp.cpp b/src/Gui/DocumentPyImp.cpp index b947a61c66..932852672e 100644 --- a/src/Gui/DocumentPyImp.cpp +++ b/src/Gui/DocumentPyImp.cpp @@ -496,12 +496,12 @@ Py::Int DocumentPy::getEditMode() const Py::Boolean DocumentPy::getTransacting() const { - return Py::Boolean(getDocumentPtr()->isPerformingTransaction()); + return {getDocumentPtr()->isPerformingTransaction()}; } Py::Boolean DocumentPy::getModified() const { - return Py::Boolean(getDocumentPtr()->isModified()); + return {getDocumentPtr()->isModified()}; } PyObject *DocumentPy::getCustomAttributes(const char* attr) const diff --git a/src/Gui/DownloadManager.cpp b/src/Gui/DownloadManager.cpp index 37e96ee386..0472745447 100644 --- a/src/Gui/DownloadManager.cpp +++ b/src/Gui/DownloadManager.cpp @@ -310,11 +310,11 @@ DownloadModel::DownloadModel(DownloadManager *downloadManager, QObject *parent) QVariant DownloadModel::data(const QModelIndex &index, int role) const { if (index.row() < 0 || index.row() >= rowCount(index.parent())) - return QVariant(); + return {}; if (role == Qt::ToolTipRole) if (!m_downloadManager->m_downloads.at(index.row())->downloadedSuccessfully()) return m_downloadManager->m_downloads.at(index.row())->downloadInfoLabel->text(); - return QVariant(); + return {}; } int DownloadModel::rowCount(const QModelIndex &parent) const diff --git a/src/Gui/ExpressionBinding.cpp b/src/Gui/ExpressionBinding.cpp index 9f8665e9eb..e1c0f20fa5 100644 --- a/src/Gui/ExpressionBinding.cpp +++ b/src/Gui/ExpressionBinding.cpp @@ -160,7 +160,7 @@ std::string ExpressionBinding::getExpressionString(bool no_throw) const else throw; } - return std::string(); + return {}; } std::string ExpressionBinding::getEscapedExpressionString() const diff --git a/src/Gui/ExpressionCompleter.cpp b/src/Gui/ExpressionCompleter.cpp index 6bd88839fb..7c79c610d8 100644 --- a/src/Gui/ExpressionCompleter.cpp +++ b/src/Gui/ExpressionCompleter.cpp @@ -250,7 +250,7 @@ public: QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override { if (role != Qt::EditRole && role != Qt::DisplayRole && role != Qt::UserRole) - return QVariant(); + return {}; QVariant variant; Info info = getInfo(index); _data(info, index.row(), &variant, nullptr, role == Qt::UserRole); @@ -491,7 +491,7 @@ public: QModelIndex parent(const QModelIndex & index) const override { if (!index.isValid()) - return QModelIndex(); + return {}; Info parentInfo = getInfo(index); Info grandParentInfo = parentInfo; @@ -524,7 +524,7 @@ public: } - return QModelIndex(); + return {}; } // returns true if successful, false if 'element' identifies a Leaf @@ -597,13 +597,13 @@ public: QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex()) const override { if (row < 0) - return QModelIndex(); + return {}; Info myParentInfoEncoded = Info::root; // encode the parent's QModelIndex into an 'Info' structure bool parentCanHaveChildren = modelIndexToParentInfo(parent, myParentInfoEncoded); if (!parentCanHaveChildren) { - return QModelIndex(); + return {}; } return createIndex(row, column, infoId(myParentInfoEncoded)); } @@ -695,7 +695,7 @@ QString ExpressionCompleter::pathFromIndex(const QModelIndex& index) const { auto m = model(); if (!m || !index.isValid()) - return QString(); + return {}; QString res; auto parent = index; diff --git a/src/Gui/FileDialog.cpp b/src/Gui/FileDialog.cpp index 4485d50ff4..0a23c859ba 100644 --- a/src/Gui/FileDialog.cpp +++ b/src/Gui/FileDialog.cpp @@ -245,7 +245,7 @@ QString FileDialog::getSaveFileName (QWidget * parent, const QString & caption, setWorkingDirectory(file); return file; } else { - return QString(); + return {}; } } @@ -314,7 +314,7 @@ QString FileDialog::getOpenFileName(QWidget * parent, const QString & caption, c setWorkingDirectory(file); return file; } else { - return QString(); + return {}; } } diff --git a/src/Gui/Flag.cpp b/src/Gui/Flag.cpp index c1df3397fb..b741a0db63 100644 --- a/src/Gui/Flag.cpp +++ b/src/Gui/Flag.cpp @@ -183,7 +183,7 @@ QSize Flag::sizeHint() const QRect r = metric.boundingRect(text); w = std::max(w, r.width()+20); h = std::max(h, r.height()); - return QSize(w, h); + return {w, h}; } // ------------------------------------------------------------------------ diff --git a/src/Gui/GraphvizView.cpp b/src/Gui/GraphvizView.cpp index a2820ad0d1..8bbfe8221a 100644 --- a/src/Gui/GraphvizView.cpp +++ b/src/Gui/GraphvizView.cpp @@ -415,7 +415,7 @@ QByteArray GraphvizView::exportGraph(const QString& format) dotProc.setEnvironment(QProcess::systemEnvironment()); dotProc.start(exe, args); if (!dotProc.waitForStarted()) { - return QByteArray(); + return {}; } ParameterGrp::handle depGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/DependencyGraph"); @@ -423,12 +423,12 @@ QByteArray GraphvizView::exportGraph(const QString& format) flatProc.setEnvironment(QProcess::systemEnvironment()); flatProc.start(unflatten, flatArgs); if (!flatProc.waitForStarted()) { - return QByteArray(); + return {}; } flatProc.write(graphCode.c_str(), graphCode.size()); flatProc.closeWriteChannel(); if (!flatProc.waitForFinished()) - return QByteArray(); + return {}; dotProc.write(flatProc.readAll()); } @@ -437,7 +437,7 @@ QByteArray GraphvizView::exportGraph(const QString& format) dotProc.closeWriteChannel(); if (!dotProc.waitForFinished()) - return QByteArray(); + return {}; return dotProc.readAll(); } diff --git a/src/Gui/InputField.cpp b/src/Gui/InputField.cpp index 97646d82e4..d97eb9f8c8 100644 --- a/src/Gui/InputField.cpp +++ b/src/Gui/InputField.cpp @@ -416,7 +416,7 @@ QByteArray InputField::paramGrpPath() const { if(_handle.isValid()) return sGroupString.c_str(); - return QByteArray(); + return {}; } /// sets the field with a quantity @@ -567,7 +567,7 @@ void InputField::setPrecision(const int precision) QString InputField::getFormat() const { - return QString(QChar::fromLatin1(actQuantity.getFormat().toFormat())); + return {QChar::fromLatin1(actQuantity.getFormat().toFormat())}; } void InputField::setFormat(const QString& format) diff --git a/src/Gui/InputVector.cpp b/src/Gui/InputVector.cpp index 0e8b1a767c..6e0ca90baf 100644 --- a/src/Gui/InputVector.cpp +++ b/src/Gui/InputVector.cpp @@ -85,7 +85,7 @@ LocationWidget::~LocationWidget() QSize LocationWidget::sizeHint() const { - return QSize(150,100); + return {150,100}; } void LocationWidget::changeEvent(QEvent* e) diff --git a/src/Gui/MDIView.cpp b/src/Gui/MDIView.cpp index 7c8fb85b01..ec427565f7 100644 --- a/src/Gui/MDIView.cpp +++ b/src/Gui/MDIView.cpp @@ -341,7 +341,7 @@ QStringList MDIView::redoActions() const QSize MDIView::minimumSizeHint () const { - return QSize(400, 300); + return {400, 300}; } void MDIView::changeEvent(QEvent *e) diff --git a/src/Gui/ManualAlignment.cpp b/src/Gui/ManualAlignment.cpp index bfb30f8d72..04fe792187 100644 --- a/src/Gui/ManualAlignment.cpp +++ b/src/Gui/ManualAlignment.cpp @@ -609,7 +609,7 @@ public: Base::Vector3d pln_base; rot.multVec(plane1_base,pln_base); Base::Vector3d dif = plane2_base - pln_base; - return Base::Placement(dif, rot); + return {dif, rot}; } static Base::Placement diff --git a/src/Gui/NavigationStyle.cpp b/src/Gui/NavigationStyle.cpp index 4c475be7c7..81bec5ab1d 100644 --- a/src/Gui/NavigationStyle.cpp +++ b/src/Gui/NavigationStyle.cpp @@ -878,7 +878,7 @@ SbVec3f NavigationStyle::getFocalPoint() const { SoCamera* cam = viewer->getSoRenderManager()->getCamera(); if (!cam) - return SbVec3f(0,0,0); + return {0,0,0}; // Find global coordinates of focal point. SbVec3f direction; @@ -1105,16 +1105,16 @@ SbVec2f NavigationStyle::normalizePixelPos(SbVec2s pixpos) { const SbViewportRegion & vp = viewer->getSoRenderManager()->getViewportRegion(); const SbVec2s size(vp.getViewportSizePixels()); - return SbVec2f ((float) pixpos[0] / (float) std::max((int)(size[0] - 1), 1), - (float) pixpos[1] / (float) std::max((int)(size[1] - 1), 1)); + return {(float) pixpos[0] / (float) std::max((int)(size[0] - 1), 1), + (float) pixpos[1] / (float) std::max((int)(size[1] - 1), 1)}; } SbVec2f NavigationStyle::normalizePixelPos(SbVec2f pixpos) { const SbViewportRegion & vp = viewer->getSoRenderManager()->getViewportRegion(); const SbVec2s size(vp.getViewportSizePixels()); - return SbVec2f ( pixpos[0] / (float) std::max((int)(size[0] - 1), 1), - pixpos[1] / (float) std::max((int)(size[1] - 1), 1)); + return {pixpos[0] / (float) std::max((int)(size[0] - 1), 1), + pixpos[1] / (float) std::max((int)(size[1] - 1), 1)}; } void NavigationStyle::moveCursorPosition() diff --git a/src/Gui/NotificationArea.cpp b/src/Gui/NotificationArea.cpp index c53636941f..6f81d656b5 100644 --- a/src/Gui/NotificationArea.cpp +++ b/src/Gui/NotificationArea.cpp @@ -353,7 +353,7 @@ public: return font; } - return QVariant(); + return {}; } Base::LogStyle notificationType; diff --git a/src/Gui/NotificationBox.cpp b/src/Gui/NotificationBox.cpp index f96f58e70d..241332dadc 100644 --- a/src/Gui/NotificationBox.cpp +++ b/src/Gui/NotificationBox.cpp @@ -392,7 +392,7 @@ QString NotificationBox::text() { if (NotificationLabel::instance) return NotificationLabel::instance->text(); - return QString(); + return {}; } Q_GLOBAL_STATIC(QPalette, notificationbox_palette) diff --git a/src/Gui/PythonDebugger.cpp b/src/Gui/PythonDebugger.cpp index 258cb8f627..762e6fe682 100644 --- a/src/Gui/PythonDebugger.cpp +++ b/src/Gui/PythonDebugger.cpp @@ -394,7 +394,7 @@ Breakpoint PythonDebugger::getBreakpoint(const QString& fn) const } } - return Breakpoint(); + return {}; } bool PythonDebugger::toggleBreakpoint(int line, const QString& fn) diff --git a/src/Gui/PythonWorkbenchPyImp.cpp b/src/Gui/PythonWorkbenchPyImp.cpp index 6ba70d6027..33182ddc5a 100644 --- a/src/Gui/PythonWorkbenchPyImp.cpp +++ b/src/Gui/PythonWorkbenchPyImp.cpp @@ -42,7 +42,7 @@ using namespace Gui; // returns a string which represent the object e.g. when printed in python std::string PythonWorkbenchPy::representation() const { - return std::string(""); + return {""}; } /** Appends a new menu */ diff --git a/src/Gui/QSint/actionpanel/actionbox.cpp b/src/Gui/QSint/actionpanel/actionbox.cpp index 88f6665f3c..e1ed69023b 100644 --- a/src/Gui/QSint/actionpanel/actionbox.cpp +++ b/src/Gui/QSint/actionpanel/actionbox.cpp @@ -232,7 +232,7 @@ void ActionBox::addWidget(QWidget * w, QLayout * l) QSize ActionBox::minimumSizeHint() const { - return QSize(150,65); + return {150,65}; } diff --git a/src/Gui/QSint/actionpanel/actiongroup.cpp b/src/Gui/QSint/actionpanel/actiongroup.cpp index 403c570590..2a3ae49a50 100644 --- a/src/Gui/QSint/actionpanel/actiongroup.cpp +++ b/src/Gui/QSint/actionpanel/actiongroup.cpp @@ -251,7 +251,7 @@ void ActionGroup::setHeaderText(const QString & headerText) QSize ActionGroup::minimumSizeHint() const { - return QSize(200,65); + return {200,65}; } diff --git a/src/Gui/QSint/actionpanel/actionpanel.cpp b/src/Gui/QSint/actionpanel/actionpanel.cpp index 3b31e3dc38..2c01e08a72 100644 --- a/src/Gui/QSint/actionpanel/actionpanel.cpp +++ b/src/Gui/QSint/actionpanel/actionpanel.cpp @@ -113,7 +113,7 @@ ActionGroup * ActionPanel::createGroup(const QPixmap &icon, const QString &title QSize ActionPanel::minimumSizeHint() const { - return QSize(200,150); + return {200,150}; } diff --git a/src/Gui/QuantitySpinBox.cpp b/src/Gui/QuantitySpinBox.cpp index ad34fa795b..dbc666e7b9 100644 --- a/src/Gui/QuantitySpinBox.cpp +++ b/src/Gui/QuantitySpinBox.cpp @@ -314,7 +314,7 @@ QString QuantitySpinBox::boundToName() const std::string path = getPath().toString(); return QString::fromStdString(path); } - return QString(); + return {}; } /** @@ -377,7 +377,7 @@ QString Gui::QuantitySpinBox::expressionText() const catch (const Base::Exception& e) { qDebug() << e.what(); } - return QString(); + return {}; } void QuantitySpinBox::evaluateExpression() diff --git a/src/Gui/Quarter/QuarterWidget.cpp b/src/Gui/Quarter/QuarterWidget.cpp index bf97ad6e59..7ad5a46ec5 100644 --- a/src/Gui/Quarter/QuarterWidget.cpp +++ b/src/Gui/Quarter/QuarterWidget.cpp @@ -1062,10 +1062,10 @@ QuarterWidget::backgroundColor() const { SbColor4f bg = PRIVATE(this)->sorendermanager->getBackgroundColor(); - return QColor(SbClamp(int(bg[0] * 255.0), 0, 255), + return {SbClamp(int(bg[0] * 255.0), 0, 255), SbClamp(int(bg[1] * 255.0), 0, 255), SbClamp(int(bg[2] * 255.0), 0, 255), - SbClamp(int(bg[3] * 255.0), 0, 255)); + SbClamp(int(bg[3] * 255.0), 0, 255)}; } /*! @@ -1142,7 +1142,7 @@ QuarterWidget::removeStateMachine(SoScXMLStateMachine * statemachine) QSize QuarterWidget::minimumSizeHint() const { - return QSize(50, 50); + return {50, 50}; } /*! Returns a list of grouped actions that corresponds to the diff --git a/src/Gui/Quarter/SoQTQuarterAdaptor.cpp b/src/Gui/Quarter/SoQTQuarterAdaptor.cpp index c016a6aa88..a52feb389c 100644 --- a/src/Gui/Quarter/SoQTQuarterAdaptor.cpp +++ b/src/Gui/Quarter/SoQTQuarterAdaptor.cpp @@ -754,7 +754,7 @@ SbVec2f SIM::Coin3D::Quarter::SoQTQuarterAdaptor::addFrametime(double starttime) this->frametime = (frametime*FPS_FACTOR) + this->frametime*(1.0-FPS_FACTOR); this->starttime = timeofday; - return SbVec2f(1000 * this->drawtime, 1.0f / this->frametime); + return {1000 * float(this->drawtime), 1.0F / float(this->frametime)}; } #include "moc_SoQTQuarterAdaptor.cpp" diff --git a/src/Gui/SceneInspector.cpp b/src/Gui/SceneInspector.cpp index 2a8b3d3bd5..f7924b218c 100644 --- a/src/Gui/SceneInspector.cpp +++ b/src/Gui/SceneInspector.cpp @@ -64,14 +64,14 @@ QVariant SceneModel::headerData (int section, Qt::Orientation orientation, int r { if (orientation == Qt::Horizontal) { if (role != Qt::DisplayRole) - return QVariant(); + return {}; if (section == 0) return tr("Inventor Tree"); else if (section == 1) return tr("Name"); } - return QVariant(); + return {}; } bool SceneModel::setHeaderData (int, Qt::Orientation, const QVariant &, int) diff --git a/src/Gui/Selection.cpp b/src/Gui/Selection.cpp index c8df935cd8..5d22b11fd0 100644 --- a/src/Gui/Selection.cpp +++ b/src/Gui/Selection.cpp @@ -518,7 +518,7 @@ std::vector SelectionSingleton::getObjectsOfType(const cha { Base::Type typeId = Base::Type::fromName(typeName); if (typeId == Base::Type::badType()) - return std::vector(); + return {}; return getObjectsOfType(typeId, pDocName, resolve); } diff --git a/src/Gui/SelectionObjectPyImp.cpp b/src/Gui/SelectionObjectPyImp.cpp index 085093214b..27b82372ca 100644 --- a/src/Gui/SelectionObjectPyImp.cpp +++ b/src/Gui/SelectionObjectPyImp.cpp @@ -70,7 +70,7 @@ PyObject* SelectionObjectPy::isObjectTypeOf(PyObject * args) Py::String SelectionObjectPy::getObjectName() const { - return Py::String(getSelectionObjectPtr()->getFeatName()); + return {getSelectionObjectPtr()->getFeatName()}; } Py::Tuple SelectionObjectPy::getSubElementNames() const @@ -87,17 +87,17 @@ Py::Tuple SelectionObjectPy::getSubElementNames() const Py::String SelectionObjectPy::getFullName() const { - return Py::String(getSelectionObjectPtr()->getAsPropertyLinkSubString()); + return {getSelectionObjectPtr()->getAsPropertyLinkSubString()}; } Py::String SelectionObjectPy::getTypeName() const { - return Py::String(getSelectionObjectPtr()->getTypeName()); + return {getSelectionObjectPtr()->getTypeName()}; } Py::String SelectionObjectPy::getDocumentName() const { - return Py::String(getSelectionObjectPtr()->getDocName()); + return {getSelectionObjectPtr()->getDocName()}; } Py::Object SelectionObjectPy::getDocument() const @@ -142,7 +142,7 @@ Py::Tuple SelectionObjectPy::getSubObjects() const Py::Boolean SelectionObjectPy::getHasSubObjects() const { - return Py::Boolean(getSelectionObjectPtr()->hasSubNames()); + return {getSelectionObjectPtr()->hasSubNames()}; } Py::Tuple SelectionObjectPy::getPickedPoints() const diff --git a/src/Gui/SoFCUnifiedSelection.cpp b/src/Gui/SoFCUnifiedSelection.cpp index 2bc0581b17..8223a94385 100644 --- a/src/Gui/SoFCUnifiedSelection.cpp +++ b/src/Gui/SoFCUnifiedSelection.cpp @@ -1125,7 +1125,7 @@ SoFCSelectionContextBasePtr SoFCSelectionRoot::getNodeContext( stack.front() = front; if(it!=front->contextMap.end()) return it->second; - return SoFCSelectionContextBasePtr(); + return {}; } SoFCSelectionContextBasePtr diff --git a/src/Gui/SyntaxHighlighter.cpp b/src/Gui/SyntaxHighlighter.cpp index 034807b51f..3f7431d53f 100644 --- a/src/Gui/SyntaxHighlighter.cpp +++ b/src/Gui/SyntaxHighlighter.cpp @@ -131,7 +131,7 @@ QColor SyntaxHighlighter::color(const QString& type) else if (type == QLatin1String("Python error")) return d->cError; else - return QColor(); // not found + return {}; // not found } QColor SyntaxHighlighter::colorByType(SyntaxHighlighter::TColor type) @@ -159,7 +159,7 @@ QColor SyntaxHighlighter::colorByType(SyntaxHighlighter::TColor type) else if (type == SyntaxHighlighter::Error) return d->cError; else - return QColor(); // not found + return {}; // not found } void SyntaxHighlighter::colorChanged(const QString& type, const QColor& col) diff --git a/src/Gui/TaskView/TaskDialogPython.cpp b/src/Gui/TaskView/TaskDialogPython.cpp index 795b7cf43a..6e9e800216 100644 --- a/src/Gui/TaskView/TaskDialogPython.cpp +++ b/src/Gui/TaskView/TaskDialogPython.cpp @@ -742,7 +742,7 @@ QDialogButtonBox::StandardButtons TaskDialogPython::getStandardButtons() const Py::Tuple args; Py::Int ret(method.apply(args)); int value = (int)ret; - return QDialogButtonBox::StandardButtons(value); + return {value}; } } catch (Py::Exception&) { diff --git a/src/Gui/TaskView/TaskView.cpp b/src/Gui/TaskView/TaskView.cpp index e1c8b14a27..17b5422cba 100644 --- a/src/Gui/TaskView/TaskView.cpp +++ b/src/Gui/TaskView/TaskView.cpp @@ -154,7 +154,7 @@ QSize TaskBox::minimumSizeHint() const // respect the layout's minimum size. QSize s1 = QSint::ActionGroup::minimumSizeHint(); QSize s2 = QWidget::minimumSizeHint(); - return QSize(qMax(s1.width(), s2.width()), qMax(s1.height(), s2.height())); + return {qMax(s1.width(), s2.width()), qMax(s1.height(), s2.height())}; } TaskBox::~TaskBox() @@ -263,7 +263,7 @@ QSize TaskPanel::minimumSizeHint() const // respect the layout's minimum size. QSize s1 = QSint::ActionPanel::minimumSizeHint(); QSize s2 = QWidget::minimumSizeHint(); - return QSize(qMax(s1.width(), s2.width()), qMax(s1.height(), s2.height())); + return {qMax(s1.width(), s2.width()), qMax(s1.height(), s2.height())}; } diff --git a/src/Gui/TextEdit.cpp b/src/Gui/TextEdit.cpp index 46e1803383..d6c7956a6d 100644 --- a/src/Gui/TextEdit.cpp +++ b/src/Gui/TextEdit.cpp @@ -517,7 +517,7 @@ LineMarker::~LineMarker() QSize LineMarker::sizeHint() const { - return QSize(textEditor->lineNumberAreaWidth(), 0); + return {textEditor->lineNumberAreaWidth(), 0}; } void LineMarker::paintEvent(QPaintEvent* e) diff --git a/src/Gui/VectorListEditor.cpp b/src/Gui/VectorListEditor.cpp index fd7de57afd..fe75cbf329 100644 --- a/src/Gui/VectorListEditor.cpp +++ b/src/Gui/VectorListEditor.cpp @@ -41,15 +41,15 @@ QVariant VectorTableModel::headerData(int section, Qt::Orientation orientation, return section + 1; if (role != Qt::DisplayRole || orientation != Qt::Horizontal) - return QVariant(); + return {}; if (section == 0) - return QVariant(QLatin1Char('x')); + return {QLatin1Char('x')}; if (section == 1) - return QVariant(QLatin1Char('y')); + return {QLatin1Char('y')}; if (section == 2) - return QVariant(QLatin1Char('z')); + return {QLatin1Char('z')}; else - return QVariant(); + return {}; } int VectorTableModel::columnCount(const QModelIndex&) const @@ -117,12 +117,12 @@ QVariant VectorTableModel::data(const QModelIndex &index, int role) const } } - return QVariant(); + return {}; } QModelIndex VectorTableModel::parent(const QModelIndex &) const { - return QModelIndex(); + return {}; } void VectorTableModel::setValues(const QList& d) diff --git a/src/Gui/View3DInventorViewer.cpp b/src/Gui/View3DInventorViewer.cpp index fe9ceb6030..5746ec3e7a 100644 --- a/src/Gui/View3DInventorViewer.cpp +++ b/src/Gui/View3DInventorViewer.cpp @@ -1695,7 +1695,7 @@ SbVec2f View3DInventorViewer::screenCoordsOfPath(SoPath* path) const imageCoords[1] += (height-width) / 2.0; } - return SbVec2f(imageCoords[0], imageCoords[1]); + return {imageCoords[0], imageCoords[1]}; } std::vector View3DInventorViewer::getGLPolygon(const std::vector& pnts) const @@ -2319,7 +2319,7 @@ void View3DInventorViewer::setSeekMode(SbBool on) SbVec3f View3DInventorViewer::getCenterPointOnFocalPlane() const { SoCamera* cam = getSoRenderManager()->getCamera(); if (!cam) - return SbVec3f(0. ,0. ,0. ); + return {0. ,0. ,0. }; SbVec3f direction; cam->orientation.getValue().multVec(SbVec3f(0, 0, -1), direction); @@ -2439,7 +2439,7 @@ SbVec3f View3DInventorViewer::getViewDirection() const SoCamera* cam = this->getSoRenderManager()->getCamera(); if (!cam) // this is the default - return SbVec3f(0,0,-1); + return {0,0,-1}; SbVec3f projDir = cam->getViewVolume().getProjectionDirection(); return projDir; @@ -2457,7 +2457,7 @@ SbVec3f View3DInventorViewer::getUpDirection() const SoCamera* cam = this->getSoRenderManager()->getCamera(); if (!cam) - return SbVec3f(0,1,0); + return {0,1,0}; SbRotation camrot = cam->orientation.getValue(); SbVec3f upvec(0, 1, 0); // init to default up vector @@ -2470,7 +2470,7 @@ SbRotation View3DInventorViewer::getCameraOrientation() const SoCamera* cam = this->getSoRenderManager()->getCamera(); if (!cam) - return SbRotation(0,0,0,1); // this is the default + return {0,0,0,1}; // this is the default return cam->orientation.getValue(); } @@ -2498,7 +2498,7 @@ SbVec2f View3DInventorViewer::getNormalizedPosition(const SbVec2s& pnt) const pY = (pY - 0.5f*dY) / fRatio + 0.5f*dY; } - return SbVec2f(pX, pY); + return {pX, pY}; } SbVec3f View3DInventorViewer::getPointOnFocalPlane(const SbVec2s& pnt) const @@ -2507,7 +2507,7 @@ SbVec3f View3DInventorViewer::getPointOnFocalPlane(const SbVec2s& pnt) const SoCamera* pCam = this->getSoRenderManager()->getCamera(); if (!pCam) // return invalid point - return SbVec3f(); + return {}; SbViewVolume vol = pCam->getViewVolume(); @@ -2540,7 +2540,7 @@ SbVec2s View3DInventorViewer::getPointOnViewport(const SbVec3f& pnt) const auto x = short(std::roundf(pt[0] * sp[0])); auto y = short(std::roundf(pt[1] * sp[1])); - return SbVec2s(x, y); + return {x, y}; } QPoint View3DInventorViewer::toQPoint(const SbVec2s& pnt) const @@ -2554,7 +2554,7 @@ QPoint View3DInventorViewer::toQPoint(const SbVec2s& pnt) const xpos = int(std::roundf(xpos / dev_pix_ratio)); ypos = int(std::roundf(ypos / dev_pix_ratio)); - return QPoint(xpos, ypos); + return {xpos, ypos}; } SbVec2s View3DInventorViewer::fromQPoint(const QPoint& pnt) const @@ -2615,7 +2615,7 @@ SbVec3f View3DInventorViewer::projectOnNearPlane(const SbVec2f& pt) const SoCamera* cam = this->getSoRenderManager()->getCamera(); if (!cam) // return invalid point - return SbVec3f(); + return {}; SbViewVolume vol = cam->getViewVolume(); vol.projectPointToLine(pt, pt1, pt2); @@ -2628,7 +2628,7 @@ SbVec3f View3DInventorViewer::projectOnFarPlane(const SbVec2f& pt) const SoCamera* cam = this->getSoRenderManager()->getCamera(); if (!cam) // return invalid point - return SbVec3f(); + return {}; SbViewVolume vol = cam->getViewVolume(); vol.projectPointToLine(pt, pt1, pt2); diff --git a/src/Gui/ViewProvider.cpp b/src/Gui/ViewProvider.cpp index db2ce67d65..5d9dacb527 100644 --- a/src/Gui/ViewProvider.cpp +++ b/src/Gui/ViewProvider.cpp @@ -365,12 +365,14 @@ void ViewProvider::setTransformation(const SbMatrix &rcMatrix) SbMatrix ViewProvider::convert(const Base::Matrix4D &rcMatrix) { + //NOLINTBEGIN double dMtrx[16]; rcMatrix.getGLMatrix(dMtrx); - return SbMatrix(dMtrx[0], dMtrx[1], dMtrx[2], dMtrx[3], + return SbMatrix(dMtrx[0], dMtrx[1], dMtrx[2], dMtrx[3], // clazy:exclude=rule-of-two-soft dMtrx[4], dMtrx[5], dMtrx[6], dMtrx[7], dMtrx[8], dMtrx[9], dMtrx[10], dMtrx[11], dMtrx[12],dMtrx[13],dMtrx[14], dMtrx[15]); + //NOLINTEND } Base::Matrix4D ViewProvider::convert(const SbMatrix &smat) @@ -812,7 +814,7 @@ std::string ViewProvider::dropObjectEx(App::DocumentObject* obj, App::DocumentOb return ext->extensionDropObjectEx(obj, owner, subname, elements); } dropObject(obj); - return std::string(); + return {}; } int ViewProvider::replaceObject(App::DocumentObject* oldValue, App::DocumentObject* newValue) diff --git a/src/Gui/ViewProvider.h b/src/Gui/ViewProvider.h index bd295a31af..48f780903b 100644 --- a/src/Gui/ViewProvider.h +++ b/src/Gui/ViewProvider.h @@ -166,7 +166,7 @@ public: /// return a hit element given the picked point which contains the full node path virtual bool getElementPicked(const SoPickedPoint *, std::string &subname) const; /// return a hit element to the selection path or 0 - virtual std::string getElement(const SoDetail *) const { return std::string(); } + virtual std::string getElement(const SoDetail *) const { return {}; } /// return the coin node detail of the subelement virtual SoDetail* getDetail(const char *) const { return nullptr; } @@ -203,7 +203,7 @@ public: /// return the highlight lines for a given element or the whole shape virtual std::vector getSelectionShape(const char* Element) const { (void)Element; - return std::vector(); + return {}; } /** Return the bound box of this view object @@ -312,7 +312,7 @@ public: const char *subname, const std::vector &elements) const; /// return a subname referencing the sub-object holding the dropped objects - virtual std::string getDropPrefix() const { return std::string(); } + virtual std::string getDropPrefix() const { return {}; } /** Add an object with full qualified name to the view provider by drag and drop * diff --git a/src/Gui/ViewProviderDocumentObjectGroup.cpp b/src/Gui/ViewProviderDocumentObjectGroup.cpp index 9826c9fe0e..08c0e81b6d 100644 --- a/src/Gui/ViewProviderDocumentObjectGroup.cpp +++ b/src/Gui/ViewProviderDocumentObjectGroup.cpp @@ -53,7 +53,7 @@ ViewProviderDocumentObjectGroup::~ViewProviderDocumentObjectGroup() std::vector ViewProviderDocumentObjectGroup::getDisplayModes() const { // empty - return std::vector(); + return {}; } bool ViewProviderDocumentObjectGroup::isShow() const diff --git a/src/Gui/ViewProviderDocumentObjectPyImp.cpp b/src/Gui/ViewProviderDocumentObjectPyImp.cpp index 41a7030d6f..0ee5f203ba 100644 --- a/src/Gui/ViewProviderDocumentObjectPyImp.cpp +++ b/src/Gui/ViewProviderDocumentObjectPyImp.cpp @@ -74,7 +74,7 @@ void ViewProviderDocumentObjectPy::setObject(Py::Object pyobj) Py::Boolean ViewProviderDocumentObjectPy::getForceUpdate() const { - return Py::Boolean(getViewProviderDocumentObjectPtr()->isUpdateForced()); + return {getViewProviderDocumentObjectPtr()->isUpdateForced()}; } void ViewProviderDocumentObjectPy::setForceUpdate(Py::Boolean arg) diff --git a/src/Gui/ViewProviderExtension.h b/src/Gui/ViewProviderExtension.h index 2b68a6e8f5..931b4dd534 100644 --- a/src/Gui/ViewProviderExtension.h +++ b/src/Gui/ViewProviderExtension.h @@ -62,13 +62,13 @@ public: const Gui::ViewProviderDocumentObject* getExtendedViewProvider() const; virtual std::vector extensionClaimChildren3D() const { - return std::vector(); } + return {}; } virtual bool extensionOnDelete(const std::vector &){ return true;} virtual void extensionBeforeDelete(){} virtual std::vector extensionClaimChildren() const { - return std::vector(); } + return {}; } virtual bool extensionCanDragObjects() const { return false; } virtual bool extensionCanDragObject(App::DocumentObject*) const { return true; } @@ -82,7 +82,7 @@ public: { return false; } virtual std::string extensionDropObjectEx(App::DocumentObject *obj, App::DocumentObject *, const char *, const std::vector &) - { extensionDropObject(obj); return std::string(); } + { extensionDropObject(obj); return {}; } virtual int extensionReplaceObject(App::DocumentObject* /*oldValue*/, App::DocumentObject* /*newValue*/) { return -1; } @@ -100,7 +100,7 @@ public: virtual void extensionAttach(App::DocumentObject* ) { } virtual void extensionReattach(App::DocumentObject* ) { } virtual void extensionSetDisplayMode(const char* ) { } - virtual std::vector extensionGetDisplayModes() const {return std::vector();} + virtual std::vector extensionGetDisplayModes() const {return {};} virtual void extensionSetupContextMenu(QMenu*, QObject*, const char*) {} // update data of extended object diff --git a/src/Gui/ViewProviderExtensionPyImp.cpp b/src/Gui/ViewProviderExtensionPyImp.cpp index 987267fadb..c14390dc38 100644 --- a/src/Gui/ViewProviderExtensionPyImp.cpp +++ b/src/Gui/ViewProviderExtensionPyImp.cpp @@ -37,7 +37,7 @@ using namespace Gui; // returns a string which represent the object e.g. when printed in python std::string ViewProviderExtensionPy::representation() const { - return std::string(""); + return {""}; } PyObject* ViewProviderExtensionPy::setIgnoreOverlayIcon(PyObject *args) diff --git a/src/Gui/ViewProviderGeoFeatureGroupExtension.cpp b/src/Gui/ViewProviderGeoFeatureGroupExtension.cpp index 35012dff48..062e11b6e9 100644 --- a/src/Gui/ViewProviderGeoFeatureGroupExtension.cpp +++ b/src/Gui/ViewProviderGeoFeatureGroupExtension.cpp @@ -72,7 +72,7 @@ std::vector ViewProviderGeoFeatureGroupExtension::extensio auto objs = ext->Group.getValues(); return objs; } - return std::vector(); + return {}; } std::vector ViewProviderGeoFeatureGroupExtension::extensionClaimChildren() const { diff --git a/src/Gui/ViewProviderGroupExtension.cpp b/src/Gui/ViewProviderGroupExtension.cpp index 698bcdc1d1..8d4929ce4d 100644 --- a/src/Gui/ViewProviderGroupExtension.cpp +++ b/src/Gui/ViewProviderGroupExtension.cpp @@ -111,7 +111,7 @@ void ViewProviderGroupExtension::extensionDropObject(App::DocumentObject* obj) { std::vector< App::DocumentObject* > ViewProviderGroupExtension::extensionClaimChildren() const { auto* group = getExtendedViewProvider()->getObject()->getExtensionByType(); - return std::vector(group->Group.getValues()); + return group->Group.getValues(); } void ViewProviderGroupExtension::extensionShow() { diff --git a/src/Gui/ViewProviderLinkPyImp.cpp b/src/Gui/ViewProviderLinkPyImp.cpp index a81a25fb7a..c1f3588e71 100644 --- a/src/Gui/ViewProviderLinkPyImp.cpp +++ b/src/Gui/ViewProviderLinkPyImp.cpp @@ -57,7 +57,7 @@ void ViewProviderLinkPy::setDraggingPlacement(Py::Object arg) { } Py::Boolean ViewProviderLinkPy::getUseCenterballDragger() const { - return Py::Boolean(getViewProviderLinkPtr()->isUsingCenterballDragger()); + return {getViewProviderLinkPtr()->isUsingCenterballDragger()}; } void ViewProviderLinkPy::setUseCenterballDragger(Py::Boolean arg) { diff --git a/src/Gui/ViewProviderPyImp.cpp b/src/Gui/ViewProviderPyImp.cpp index 8fc2a5f524..8b94c02cc6 100644 --- a/src/Gui/ViewProviderPyImp.cpp +++ b/src/Gui/ViewProviderPyImp.cpp @@ -642,7 +642,7 @@ void ViewProviderPy::setSwitchNode(Py::Object) Py::String ViewProviderPy::getIV() const { std::string buf = Gui::SoFCDB::writeNodesToString(getViewProviderPtr()->getRoot()); - return Py::String(buf); + return {buf}; } Py::Object ViewProviderPy::getIcon() const @@ -666,12 +666,12 @@ void ViewProviderPy::setDefaultMode(Py::Int arg) Py::Boolean ViewProviderPy::getCanRemoveChildrenFromRoot() const { - return Py::Boolean(getViewProviderPtr()->canRemoveChildrenFromRoot()); + return {getViewProviderPtr()->canRemoveChildrenFromRoot()}; } Py::Boolean ViewProviderPy::getLinkVisibility() const { - return Py::Boolean(getViewProviderPtr()->isLinkVisible()); + return {getViewProviderPtr()->isLinkVisible()}; } void ViewProviderPy::setLinkVisibility(Py::Boolean arg) @@ -681,5 +681,5 @@ void ViewProviderPy::setLinkVisibility(Py::Boolean arg) Py::String ViewProviderPy::getDropPrefix() const { - return Py::String(getViewProviderPtr()->getDropPrefix()); + return {getViewProviderPtr()->getDropPrefix()}; } diff --git a/src/Gui/ViewProviderPythonFeature.cpp b/src/Gui/ViewProviderPythonFeature.cpp index c59b51523c..31f07284d6 100644 --- a/src/Gui/ViewProviderPythonFeature.cpp +++ b/src/Gui/ViewProviderPythonFeature.cpp @@ -96,7 +96,7 @@ QIcon ViewProviderPythonFeatureImp::getIcon() const try { Py::Object ret(Base::pyCall(py_getIcon.ptr())); if(ret.isNone()) - return QIcon(); + return {}; if(ret.isString()) { std::string content = Py::String(ret).as_std_string("utf-8"); @@ -148,7 +148,7 @@ QIcon ViewProviderPythonFeatureImp::getIcon() const } } - return QIcon(); + return {}; } bool ViewProviderPythonFeatureImp::claimChildren(std::vector &children) const @@ -343,7 +343,7 @@ ViewProviderPythonFeatureImp::ValueT ViewProviderPythonFeatureImp::getDetailPath std::vector ViewProviderPythonFeatureImp::getSelectionShape(const char* /*Element*/) const { - return std::vector(); + return {}; } ViewProviderPythonFeatureImp::ValueT diff --git a/src/Gui/Widgets.cpp b/src/Gui/Widgets.cpp index 294fe3abdc..1b5b0e2574 100644 --- a/src/Gui/Widgets.cpp +++ b/src/Gui/Widgets.cpp @@ -1263,7 +1263,7 @@ void StatusWidget::showText(int ms) QSize StatusWidget::sizeHint () const { - return QSize(250,100); + return {250,100}; } void StatusWidget::showEvent(QShowEvent* event) @@ -1285,7 +1285,7 @@ public: } QSize sizeHint() const override { - return QSize(codeEditor->lineNumberAreaWidth(), 0); + return {codeEditor->lineNumberAreaWidth(), 0}; } protected: diff --git a/src/Gui/WorkbenchPyImp.cpp b/src/Gui/WorkbenchPyImp.cpp index 08366caf10..542ccec2b2 100644 --- a/src/Gui/WorkbenchPyImp.cpp +++ b/src/Gui/WorkbenchPyImp.cpp @@ -45,7 +45,7 @@ using namespace Gui; // returns a string which represent the object e.g. when printed in python std::string WorkbenchPy::representation() const { - return std::string(""); + return {""}; } /** Retrieves the workbench name */ diff --git a/src/Gui/propertyeditor/PropertyItem.cpp b/src/Gui/propertyeditor/PropertyItem.cpp index 861355c5a7..a48c87a655 100644 --- a/src/Gui/propertyeditor/PropertyItem.cpp +++ b/src/Gui/propertyeditor/PropertyItem.cpp @@ -346,19 +346,19 @@ int PropertyItem::decimals() const QVariant PropertyItem::displayName() const { - return QVariant(displayText); + return {displayText}; } QVariant PropertyItem::toolTip(const App::Property* prop) const { QString str = QApplication::translate("App::Property", prop->getDocumentation()); - return QVariant(str); + return {str}; } QVariant PropertyItem::decoration(const QVariant&) const { - return QVariant(); + return {}; } QVariant PropertyItem::toString(const QVariant& prop) const @@ -431,7 +431,7 @@ QVariant PropertyItem::toString(const QVariant& prop) const QVariant PropertyItem::value(const App::Property* /*prop*/) const { - return QVariant(); + return {}; } void PropertyItem::setValue(const QVariant& /*value*/) @@ -449,7 +449,7 @@ void PropertyItem::setEditorData(QWidget * /*editor*/, const QVariant& /*data*/) QVariant PropertyItem::editorData(QWidget * /*editor*/) const { - return QVariant(); + return {}; } QWidget* PropertyItem::createExpressionEditor(QWidget* parent, const QObject* receiver, const char* method) const @@ -476,8 +476,8 @@ QVariant PropertyItem::expressionEditorData(QWidget *editor) const { auto le = qobject_cast(editor); if(le) - return QVariant(le->text()); - return QVariant(); + return {le->text()}; + return {}; } PropertyEditorWidget* PropertyItem::createPropertyEditorWidget(QWidget* parent) const @@ -604,14 +604,14 @@ QVariant PropertyItem::data(int column, int role) const ? QVariant::fromValue(QColor(0xFF,0xFF,0x99)) : QVariant::fromValue(QColor(0,0,0)); } - return QVariant(); + return {}; } if (role == Qt::DisplayRole) { return displayName(); } // no properties set if (propertyItems.empty()) { - return QVariant(); + return {}; } else if (role == Qt::ToolTipRole) { QString type = QString::fromLatin1("Type: %1\nName: %2").arg( @@ -625,14 +625,14 @@ QVariant PropertyItem::data(int column, int role) const return type; } - return QVariant(); + return {}; } else { // no properties set if (propertyItems.empty()) { PropertyItem* parent = this->parent(); if (!parent || !parent->parent()) { - return QVariant(); + return {}; } if (role == Qt::EditRole) { return parent->property(qPrintable(objectName())); @@ -648,10 +648,10 @@ QVariant PropertyItem::data(int column, int role) const else if (role == Qt::ForegroundRole) { if (hasExpression()) return QVariant::fromValue(QApplication::palette().color(QPalette::Link)); - return QVariant(); + return {}; } - return QVariant(); + return {}; } if (role == Qt::EditRole) { return value(propertyItems[0]); @@ -668,10 +668,10 @@ QVariant PropertyItem::data(int column, int role) const else if( role == Qt::ForegroundRole) { if (hasExpression()) return QVariant::fromValue(QApplication::palette().color(QPalette::Link)); - return QVariant(); + return {}; } - return QVariant(); + return {}; } } @@ -735,7 +735,7 @@ QString PropertyItem::expressionAsString() const } } - return QString(); + return {}; } // -------------------------------------------------------------------- @@ -751,7 +751,7 @@ QVariant PropertyStringItem::value(const App::Property* prop) const assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyString::getClassTypeId())); std::string value = static_cast(prop)->getValue(); - return QVariant(QString::fromUtf8(value.c_str())); + return {QString::fromUtf8(value.c_str())}; } void PropertyStringItem::setValue(const QVariant& value) @@ -789,7 +789,7 @@ void PropertyStringItem::setEditorData(QWidget *editor, const QVariant& data) co QVariant PropertyStringItem::editorData(QWidget *editor) const { auto le = qobject_cast(editor); - return QVariant(le->text()); + return {le->text()}; } // -------------------------------------------------------------------- @@ -805,7 +805,7 @@ QVariant PropertyFontItem::value(const App::Property* prop) const assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyFont::getClassTypeId())); std::string value = static_cast(prop)->getValue(); - return QVariant(QString::fromUtf8(value.c_str())); + return {QString::fromUtf8(value.c_str())}; } void PropertyFontItem::setValue(const QVariant& value) @@ -842,7 +842,7 @@ void PropertyFontItem::setEditorData(QWidget *editor, const QVariant& data) cons QVariant PropertyFontItem::editorData(QWidget *editor) const { auto cb = qobject_cast(editor); - return QVariant(cb->currentText()); + return {cb->currentText()}; } // -------------------------------------------------------------------- @@ -870,7 +870,7 @@ QVariant PropertyIntegerItem::value(const App::Property* prop) const assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyInteger::getClassTypeId())); int value = (int)static_cast(prop)->getValue(); - return QVariant(value); + return {value}; } void PropertyIntegerItem::setValue(const QVariant& value) @@ -910,7 +910,7 @@ void PropertyIntegerItem::setEditorData(QWidget *editor, const QVariant& data) c QVariant PropertyIntegerItem::editorData(QWidget *editor) const { auto sb = qobject_cast(editor); - return QVariant(sb->value()); + return {sb->value()}; } QVariant PropertyIntegerItem::toString(const QVariant& v) const @@ -920,7 +920,7 @@ QVariant PropertyIntegerItem::toString(const QVariant& v) const if (hasExpression()) string += QString::fromLatin1(" ( %1 )").arg(QString::fromStdString(getExpressionString())); - return QVariant(string); + return {string}; } @@ -937,7 +937,7 @@ QVariant PropertyIntegerConstraintItem::value(const App::Property* prop) const assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyIntegerConstraint::getClassTypeId())); int value = (int)static_cast(prop)->getValue(); - return QVariant(value); + return {value}; } void PropertyIntegerConstraintItem::setValue(const QVariant& value) @@ -993,7 +993,7 @@ void PropertyIntegerConstraintItem::setEditorData(QWidget *editor, const QVarian QVariant PropertyIntegerConstraintItem::editorData(QWidget *editor) const { auto sb = qobject_cast(editor); - return QVariant(sb->value()); + return {sb->value()}; } QVariant PropertyIntegerConstraintItem::toString(const QVariant& v) const @@ -1003,7 +1003,7 @@ QVariant PropertyIntegerConstraintItem::toString(const QVariant& v) const if (hasExpression()) string += QString::fromLatin1(" ( %1 )").arg(QString::fromStdString(getExpressionString())); - return QVariant(string); + return {string}; } @@ -1023,7 +1023,7 @@ QVariant PropertyFloatItem::toString(const QVariant& prop) const if (hasExpression()) data += QString::fromLatin1(" ( %1 )").arg(QString::fromStdString(getExpressionString())); - return QVariant(data); + return {data}; } QVariant PropertyFloatItem::value(const App::Property* prop) const @@ -1031,7 +1031,7 @@ QVariant PropertyFloatItem::value(const App::Property* prop) const assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyFloat::getClassTypeId())); double value = static_cast(prop)->getValue(); - return QVariant(value); + return {value}; } void PropertyFloatItem::setValue(const QVariant& value) @@ -1072,7 +1072,7 @@ void PropertyFloatItem::setEditorData(QWidget *editor, const QVariant& data) con QVariant PropertyFloatItem::editorData(QWidget *editor) const { auto sb = qobject_cast(editor); - return QVariant(sb->value()); + return {sb->value()}; } // -------------------------------------------------------------------- @@ -1091,7 +1091,7 @@ QVariant PropertyUnitItem::toString(const QVariant& prop) const if (hasExpression()) string += QString::fromLatin1(" ( %1 )").arg(QString::fromStdString(getExpressionString())); - return QVariant(string); + return {string}; } QVariant PropertyUnitItem::value(const App::Property* prop) const @@ -1199,7 +1199,7 @@ QVariant PropertyFloatConstraintItem::toString(const QVariant& prop) const { double value = prop.toDouble(); QString data = QLocale().toString(value, 'f', decimals()); - return QVariant(data); + return {data}; } QVariant PropertyFloatConstraintItem::value(const App::Property* prop) const @@ -1207,7 +1207,7 @@ QVariant PropertyFloatConstraintItem::value(const App::Property* prop) const assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyFloatConstraint::getClassTypeId())); double value = static_cast(prop)->getValue(); - return QVariant(value); + return {value}; } void PropertyFloatConstraintItem::setValue(const QVariant& value) @@ -1265,7 +1265,7 @@ void PropertyFloatConstraintItem::setEditorData(QWidget *editor, const QVariant& QVariant PropertyFloatConstraintItem::editorData(QWidget *editor) const { auto sb = qobject_cast(editor); - return QVariant(sb->value()); + return {sb->value()}; } // -------------------------------------------------------------------- @@ -1308,7 +1308,7 @@ QVariant PropertyBoolItem::value(const App::Property* prop) const assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyBool::getClassTypeId())); bool value = static_cast(prop)->getValue(); - return QVariant(value); + return {value}; } void PropertyBoolItem::setValue(const QVariant& value) @@ -1340,7 +1340,7 @@ void PropertyBoolItem::setEditorData(QWidget *editor, const QVariant& data) cons QVariant PropertyBoolItem::editorData(QWidget *editor) const { auto cb = qobject_cast(editor); - return QVariant(cb->currentText()); + return {cb->currentText()}; } // --------------------------------------------------------------- @@ -1407,7 +1407,7 @@ QVariant PropertyVectorItem::toString(const QVariant& prop) const loc.toString(value.z, 'f', 2)); if (hasExpression()) data += QString::fromLatin1(" ( %1 )").arg(QString::fromStdString(getExpressionString())); - return QVariant(data); + return {data}; } QVariant PropertyVectorItem::value(const App::Property* prop) const @@ -1460,7 +1460,7 @@ void PropertyVectorItem::setEditorData(QWidget *editor, const QVariant& data) co QVariant PropertyVectorItem::editorData(QWidget *editor) const { auto le = qobject_cast(editor); - return QVariant(le->text()); + return {le->text()}; } double PropertyVectorItem::x() const @@ -1624,7 +1624,7 @@ QVariant PropertyVectorListItem::toString(const QVariant& prop) const if (hasExpression()) data += QString::fromLatin1(" ( %1 )").arg(QString::fromStdString(getExpressionString())); - return QVariant(data); + return {data}; } QVariant PropertyVectorListItem::value(const App::Property* prop) const @@ -1704,7 +1704,7 @@ QVariant PropertyVectorDistanceItem::toString(const QVariant& prop) const Base::Quantity(value.z, Base::Unit::Length).getUserString() + QString::fromLatin1("]"); if (hasExpression()) data += QString::fromLatin1(" ( %1 )").arg(QString::fromStdString(getExpressionString())); - return QVariant(data); + return {data}; } @@ -1758,7 +1758,7 @@ QWidget* PropertyVectorDistanceItem::createEditor(QWidget* parent, const QObject QVariant PropertyVectorDistanceItem::editorData(QWidget *editor) const { auto le = qobject_cast(editor); - return QVariant(le->text()); + return {le->text()}; } Base::Quantity PropertyVectorDistanceItem::x() const @@ -1914,7 +1914,7 @@ QVariant PropertyMatrixItem::toString(const QVariant& prop) const loc.toString(value[3][1], 'f', 2), loc.toString(value[3][2], 'f', 2), loc.toString(value[3][3], 'f', 2)); - return QVariant(text); + return {text}; } QVariant PropertyMatrixItem::value(const App::Property* prop) const @@ -1930,7 +1930,7 @@ QVariant PropertyMatrixItem::toolTip(const App::Property* prop) const assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyMatrix::getClassTypeId())); const Base::Matrix4D& value = static_cast(prop)->getValue(); - return QVariant(QString::fromStdString(value.analyse())); + return {QString::fromStdString(value.analyse())}; } void PropertyMatrixItem::setValue(const QVariant& value) @@ -1994,7 +1994,7 @@ void PropertyMatrixItem::setEditorData(QWidget *editor, const QVariant& data) co QVariant PropertyMatrixItem::editorData(QWidget *editor) const { auto le = qobject_cast(editor); - return QVariant(le->text()); + return {le->text()}; } double PropertyMatrixItem::getA11() const @@ -2381,7 +2381,7 @@ QVariant PropertyRotationItem::toolTip(const App::Property* prop) const loc.toString(dir.y, 'f', decimals()), loc.toString(dir.z, 'f', decimals()), Base::Quantity(angle, Base::Unit::Angle).getUserString()); - return QVariant(data); + return {data}; } QVariant PropertyRotationItem::toString(const QVariant& prop) const @@ -2398,7 +2398,7 @@ QVariant PropertyRotationItem::toString(const QVariant& prop) const loc.toString(dir.y, 'f', 2), loc.toString(dir.z, 'f', 2), Base::Quantity(angle, Base::Unit::Angle).getUserString()); - return QVariant(data); + return {data}; } void PropertyRotationItem::setValue(const QVariant& value) @@ -2439,7 +2439,7 @@ void PropertyRotationItem::setEditorData(QWidget *editor, const QVariant& data) QVariant PropertyRotationItem::editorData(QWidget *editor) const { Q_UNUSED(editor) - return QVariant(); + return {}; } void PropertyRotationItem::propertyBound() @@ -2682,7 +2682,7 @@ QVariant PropertyPlacementItem::toolTip(const App::Property* prop) const Base::Quantity(pos.x, Base::Unit::Length).getUserString(), Base::Quantity(pos.y, Base::Unit::Length).getUserString(), Base::Quantity(pos.z, Base::Unit::Length).getUserString()); - return QVariant(data); + return {data}; } QVariant PropertyPlacementItem::toString(const QVariant& prop) const @@ -2703,7 +2703,7 @@ QVariant PropertyPlacementItem::toString(const QVariant& prop) const Base::Quantity(pos.x, Base::Unit::Length).getUserString(), Base::Quantity(pos.y, Base::Unit::Length).getUserString(), Base::Quantity(pos.z, Base::Unit::Length).getUserString()); - return QVariant(data); + return {data}; } void PropertyPlacementItem::setValue(const QVariant& value) @@ -2815,8 +2815,8 @@ QVariant PropertyEnumItem::value(const App::Property* prop) const const auto prop_enum = static_cast(prop); if(!prop_enum->isValid()) - return QVariant(QString()); - return QVariant(QString::fromUtf8(prop_enum->getValueAsString())); + return {QString()}; + return {QString::fromUtf8(prop_enum->getValueAsString())}; } void PropertyEnumItem::setValue(const QVariant& value) @@ -2992,10 +2992,10 @@ void PropertyEnumItem::setEditorData(QWidget *editor, const QVariant& data) cons QVariant PropertyEnumItem::editorData(QWidget *editor) const { if (auto cb = qobject_cast(editor)) - return QVariant(cb->currentText()); + return {cb->currentText()}; else if (auto btn = qobject_cast(editor)) return btn->text(); - return QVariant(); + return {}; } // --------------------------------------------------------------- @@ -3027,7 +3027,7 @@ QVariant PropertyStringListItem::editorData(QWidget *editor) const auto le = qobject_cast(editor); QString complete = le->text(); QStringList list = complete.split(QChar::fromLatin1('\n')); - return QVariant(list); + return {list}; } QVariant PropertyStringListItem::toString(const QVariant& prop) const @@ -3040,7 +3040,7 @@ QVariant PropertyStringListItem::toString(const QVariant& prop) const QString text = QString::fromUtf8("[%1]").arg(list.join(QLatin1String(","))); - return QVariant(text); + return {text}; } QVariant PropertyStringListItem::value(const App::Property* prop) const @@ -3052,7 +3052,7 @@ QVariant PropertyStringListItem::value(const App::Property* prop) const list << QString::fromUtf8(jt.c_str()); } - return QVariant(list); + return {list}; } void PropertyStringListItem::setValue(const QVariant& value) @@ -3107,7 +3107,7 @@ QVariant PropertyFloatListItem::editorData(QWidget *editor) const auto le = qobject_cast(editor); QString complete = le->text(); QStringList list = complete.split(QChar::fromLatin1('\n')); - return QVariant(list); + return {list}; } QVariant PropertyFloatListItem::toString(const QVariant& prop) const @@ -3118,7 +3118,7 @@ QVariant PropertyFloatListItem::toString(const QVariant& prop) const list.append(QLatin1String("...")); } QString text = QString::fromUtf8("[%1]").arg(list.join(QLatin1String(","))); - return QVariant(text); + return {text}; } QVariant PropertyFloatListItem::value(const App::Property* prop) const @@ -3131,7 +3131,7 @@ QVariant PropertyFloatListItem::value(const App::Property* prop) const list << QString::number(jt, 'f', decimals()); } - return QVariant(list); + return {list}; } void PropertyFloatListItem::setValue(const QVariant& value) @@ -3181,7 +3181,7 @@ QVariant PropertyIntegerListItem::editorData(QWidget *editor) const auto le = qobject_cast(editor); QString complete = le->text(); QStringList list = complete.split(QChar::fromLatin1('\n')); - return QVariant(list); + return {list}; } QVariant PropertyIntegerListItem::toString(const QVariant& prop) const @@ -3193,7 +3193,7 @@ QVariant PropertyIntegerListItem::toString(const QVariant& prop) const } QString text = QString::fromUtf8("[%1]").arg(list.join(QLatin1String(","))); - return QVariant(text); + return {text}; } QVariant PropertyIntegerListItem::value(const App::Property* prop) const @@ -3206,7 +3206,7 @@ QVariant PropertyIntegerListItem::value(const App::Property* prop) const list << QString::number(jt); } - return QVariant(list); + return {list}; } void PropertyIntegerListItem::setValue(const QVariant& value) @@ -3250,7 +3250,7 @@ QVariant PropertyColorItem::toString(const QVariant& prop) const auto value = prop.value(); QString color = QString::fromLatin1("[%1, %2, %3]") .arg(value.red()).arg(value.green()).arg(value.blue()); - return QVariant(color); + return {color}; } QVariant PropertyColorItem::value(const App::Property* prop) const @@ -3361,7 +3361,7 @@ QColor PropertyMaterialItem::getDiffuseColor() const { QVariant value = data(1, Qt::EditRole); if (!value.canConvert()) - return QColor(); + return {}; auto val = value.value(); return val.diffuseColor; @@ -3382,7 +3382,7 @@ QColor PropertyMaterialItem::getAmbientColor() const { QVariant value = data(1, Qt::EditRole); if (!value.canConvert()) - return QColor(); + return {}; auto val = value.value(); return val.ambientColor; @@ -3403,7 +3403,7 @@ QColor PropertyMaterialItem::getSpecularColor() const { QVariant value = data(1, Qt::EditRole); if (!value.canConvert()) - return QColor(); + return {}; auto val = value.value(); return val.specularColor; @@ -3424,7 +3424,7 @@ QColor PropertyMaterialItem::getEmissiveColor() const { QVariant value = data(1, Qt::EditRole); if (!value.canConvert()) - return QColor(); + return {}; auto val = value.value(); return val.emissiveColor; @@ -3503,7 +3503,7 @@ QVariant PropertyMaterialItem::toString(const QVariant& prop) const QColor value = val.diffuseColor; QString color = QString::fromLatin1("[%1, %2, %3]") .arg(value.red()).arg(value.green()).arg(value.blue()); - return QVariant(color); + return {color}; } QVariant PropertyMaterialItem::toolTip(const App::Property* prop) const @@ -3532,7 +3532,7 @@ QVariant PropertyMaterialItem::toolTip(const App::Property* prop) const .arg(value.transparency) ; - return QVariant(data); + return {data}; } QVariant PropertyMaterialItem::value(const App::Property* prop) const @@ -3617,7 +3617,7 @@ QVariant PropertyMaterialItem::editorData(QWidget *editor) const auto cb = qobject_cast(editor); QVariant value = data(1, Qt::EditRole); if (!value.canConvert()) - return QVariant(); + return {}; auto val = value.value(); val.diffuseColor = cb->color(); @@ -3674,14 +3674,14 @@ QColor PropertyMaterialListItem::getDiffuseColor() const { QVariant value = data(1, Qt::EditRole); if (!value.canConvert()) - return QColor(); + return {}; QVariantList list = value.toList(); if (list.isEmpty()) - return QColor(); + return {}; if (!list[0].canConvert()) - return QColor(); + return {}; auto mat = list[0].value(); return mat.diffuseColor; @@ -3710,14 +3710,14 @@ QColor PropertyMaterialListItem::getAmbientColor() const { QVariant value = data(1, Qt::EditRole); if (!value.canConvert()) - return QColor(); + return {}; QVariantList list = value.toList(); if (list.isEmpty()) - return QColor(); + return {}; if (!list[0].canConvert()) - return QColor(); + return {}; auto mat = list[0].value(); return mat.ambientColor; @@ -3746,14 +3746,14 @@ QColor PropertyMaterialListItem::getSpecularColor() const { QVariant value = data(1, Qt::EditRole); if (!value.canConvert()) - return QColor(); + return {}; QVariantList list = value.toList(); if (list.isEmpty()) - return QColor(); + return {}; if (!list[0].canConvert()) - return QColor(); + return {}; auto mat = list[0].value(); return mat.specularColor; @@ -3782,14 +3782,14 @@ QColor PropertyMaterialListItem::getEmissiveColor() const { QVariant value = data(1, Qt::EditRole); if (!value.canConvert()) - return QColor(); + return {}; QVariantList list = value.toList(); if (list.isEmpty()) - return QColor(); + return {}; if (!list[0].canConvert()) - return QColor(); + return {}; auto mat = list[0].value(); return mat.emissiveColor; @@ -3889,14 +3889,14 @@ void PropertyMaterialListItem::setTransparency(float t) QVariant PropertyMaterialListItem::decoration(const QVariant& value) const { if (!value.canConvert()) - return QVariant(); + return {}; QVariantList list = value.toList(); if (list.isEmpty()) - return QVariant(); + return {}; if (!list[0].canConvert()) - return QVariant(); + return {}; // use the diffuse color auto mat = list[0].value(); @@ -3912,21 +3912,21 @@ QVariant PropertyMaterialListItem::decoration(const QVariant& value) const QVariant PropertyMaterialListItem::toString(const QVariant& prop) const { if (!prop.canConvert()) - return QVariant(); + return {}; QVariantList list = prop.toList(); if (list.isEmpty()) - return QVariant(); + return {}; if (!list[0].canConvert()) - return QVariant(); + return {}; // use the diffuse color auto mat = list[0].value(); QColor value = mat.diffuseColor; QString color = QString::fromLatin1("[%1, %2, %3]") .arg(value.red()).arg(value.green()).arg(value.blue()); - return QVariant(color); + return {color}; } QVariant PropertyMaterialListItem::toolTip(const App::Property* prop) const @@ -3935,7 +3935,7 @@ QVariant PropertyMaterialListItem::toolTip(const App::Property* prop) const const std::vector& values = static_cast(prop)->getValues(); if (values.empty()) - return QVariant(); + return {}; App::Material value = values.front(); auto dc = value.diffuseColor.asValue(); @@ -3959,7 +3959,7 @@ QVariant PropertyMaterialListItem::toolTip(const App::Property* prop) const .arg(value.transparency) ; - return QVariant(data); + return {data}; } QVariant PropertyMaterialListItem::value(const App::Property* prop) const @@ -4072,14 +4072,14 @@ QVariant PropertyMaterialListItem::editorData(QWidget *editor) const auto cb = qobject_cast(editor); QVariant value = data(1, Qt::EditRole); if (!value.canConvert()) - return QVariant(); + return {}; QVariantList list = value.toList(); if (list.isEmpty()) - return QVariant(); + return {}; if (!list[0].canConvert()) - return QVariant(); + return {}; // use the diffuse color auto mat = list[0].value(); @@ -4102,7 +4102,7 @@ QVariant PropertyFileItem::value(const App::Property* prop) const assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyFile::getClassTypeId())); std::string value = static_cast(prop)->getValue(); - return QVariant(QString::fromUtf8(value.c_str())); + return {QString::fromUtf8(value.c_str())}; } void PropertyFileItem::setValue(const QVariant& value) @@ -4145,7 +4145,7 @@ void PropertyFileItem::setEditorData(QWidget *editor, const QVariant& data) cons QVariant PropertyFileItem::editorData(QWidget *editor) const { auto fc = qobject_cast(editor); - return QVariant(fc->fileName()); + return {fc->fileName()}; } // -------------------------------------------------------------------- @@ -4161,7 +4161,7 @@ QVariant PropertyPathItem::value(const App::Property* prop) const assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyPath::getClassTypeId())); std::string value = static_cast(prop)->getValue().string(); - return QVariant(QString::fromUtf8(value.c_str())); + return {QString::fromUtf8(value.c_str())}; } void PropertyPathItem::setValue(const QVariant& value) @@ -4197,7 +4197,7 @@ void PropertyPathItem::setEditorData(QWidget *editor, const QVariant& data) cons QVariant PropertyPathItem::editorData(QWidget *editor) const { auto fc = qobject_cast(editor); - return QVariant(fc->fileName()); + return {fc->fileName()}; } // -------------------------------------------------------------------- @@ -4213,7 +4213,7 @@ QVariant PropertyTransientFileItem::value(const App::Property* prop) const assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyFileIncluded::getClassTypeId())); std::string value = static_cast(prop)->getValue(); - return QVariant(QString::fromUtf8(value.c_str())); + return {QString::fromUtf8(value.c_str())}; } void PropertyTransientFileItem::setValue(const QVariant& value) @@ -4258,7 +4258,7 @@ void PropertyTransientFileItem::setEditorData(QWidget *editor, const QVariant& d QVariant PropertyTransientFileItem::editorData(QWidget *editor) const { auto fc = qobject_cast(editor); - return QVariant(fc->fileName()); + return {fc->fileName()}; } // --------------------------------------------------------------- @@ -4445,11 +4445,11 @@ QVariant PropertyLinkItem::value(const App::Property* prop) const { auto propLink = Base::freecad_dynamic_cast(prop); if(!propLink) - return QVariant(); + return {}; auto links = DlgPropertyLink::getLinksFromProperty(propLink); if(links.empty()) - return QVariant(); + return {}; return QVariant::fromValue(links); } diff --git a/src/Gui/propertyeditor/PropertyModel.cpp b/src/Gui/propertyeditor/PropertyModel.cpp index 3be45d4d32..1b9e356c5e 100644 --- a/src/Gui/propertyeditor/PropertyModel.cpp +++ b/src/Gui/propertyeditor/PropertyModel.cpp @@ -67,7 +67,7 @@ int PropertyModel::columnCount ( const QModelIndex & parent ) const QVariant PropertyModel::data ( const QModelIndex & index, int role ) const { if (!index.isValid()) - return QVariant(); + return {}; auto item = static_cast(index.internalPointer()); return item->data(index.column(), role); @@ -124,19 +124,19 @@ QModelIndex PropertyModel::index ( int row, int column, const QModelIndex & pare if (childItem) return createIndex(row, column, childItem); else - return QModelIndex(); + return {}; } QModelIndex PropertyModel::parent ( const QModelIndex & index ) const { if (!index.isValid()) - return QModelIndex(); + return {}; auto childItem = static_cast(index.internalPointer()); PropertyItem *parentItem = childItem->parent(); if (parentItem == rootItem) - return QModelIndex(); + return {}; return createIndex(parentItem->row(), 0, parentItem); } @@ -157,14 +157,14 @@ QVariant PropertyModel::headerData (int section, Qt::Orientation orientation, in { if (orientation == Qt::Horizontal) { if (role != Qt::DisplayRole) - return QVariant(); + return {}; if (section == 0) return tr("Property"); if (section == 1) return tr("Value"); } - return QVariant(); + return {}; } bool PropertyModel::setHeaderData (int, Qt::Orientation, const QVariant &, int) @@ -189,11 +189,11 @@ QStringList PropertyModel::propertyPathFromIndex(const QModelIndex& index) const QModelIndex PropertyModel::propertyIndexFromPath(const QStringList& path) const { if (path.size() < 2) - return QModelIndex(); + return {}; auto it = groupItems.find(path.front()); if (it == groupItems.end()) - return QModelIndex(); + return {}; PropertyItem *item = it->second.groupItem; QModelIndex index = this->index(item->row(), 0, QModelIndex());