From ae53c9b0a4f6f07ad47eb04177b00b2ee1850d63 Mon Sep 17 00:00:00 2001 From: berniev <618593+berniev@users.noreply.github.com> Date: Thu, 15 Sep 2022 04:25:13 +1000 Subject: [PATCH] Gui: Use auto and range-based for (#7481) * On lines where the variable type is obvious from inspection, avoid repeating the type using auto. * When possible use a ranged for loop instead of begin() and end() iterators --- src/Gui/3Dconnexion/GuiNativeEventMac.cpp | 2 +- src/Gui/Action.cpp | 22 +- src/Gui/ActionFunction.cpp | 6 +- src/Gui/Application.cpp | 30 +- src/Gui/ApplicationPy.cpp | 16 +- src/Gui/AutoSaver.cpp | 8 +- src/Gui/AxisOrigin.cpp | 6 +- src/Gui/AxisOriginPyImp.cpp | 4 +- src/Gui/BitmapFactory.cpp | 8 +- src/Gui/BlenderNavigationStyle.cpp | 8 +- src/Gui/CADNavigationStyle.cpp | 8 +- src/Gui/CallTips.cpp | 36 +- src/Gui/Clipping.cpp | 6 +- src/Gui/ComboView.cpp | 4 +- src/Gui/Command.cpp | 70 ++-- src/Gui/CommandDoc.cpp | 12 +- src/Gui/CommandFeat.cpp | 28 +- src/Gui/CommandLink.cpp | 4 +- src/Gui/CommandPyImp.cpp | 10 +- src/Gui/CommandStd.cpp | 16 +- src/Gui/CommandTest.cpp | 10 +- src/Gui/CommandView.cpp | 119 ++++--- src/Gui/CommandWindow.cpp | 2 +- src/Gui/Control.cpp | 20 +- src/Gui/DAGView/DAGModel.cpp | 44 +-- src/Gui/DAGView/DAGView.cpp | 4 +- src/Gui/DemoMode.cpp | 6 +- src/Gui/DlgActionsImp.cpp | 105 +++--- src/Gui/DlgActivateWindowImp.cpp | 2 +- src/Gui/DlgCheckableMessageBox.cpp | 4 +- src/Gui/DlgCommandsImp.cpp | 44 +-- src/Gui/DlgCustomizeImp.cpp | 2 +- src/Gui/DlgCustomizeSpNavSettings.cpp | 8 +- src/Gui/DlgCustomizeSpaceball.cpp | 56 +-- src/Gui/DlgDisplayPropertiesImp.cpp | 101 +++--- src/Gui/DlgEditorImp.cpp | 6 +- src/Gui/DlgExpressionInput.cpp | 4 +- src/Gui/DlgGeneralImp.cpp | 23 +- src/Gui/DlgKeyboardImp.cpp | 74 ++-- src/Gui/DlgMacroExecuteImp.cpp | 48 +-- src/Gui/DlgMaterialPropertiesImp.cpp | 14 +- src/Gui/DlgParameterFind.cpp | 4 +- src/Gui/DlgParameterImp.cpp | 74 ++-- src/Gui/DlgPreferencesImp.cpp | 28 +- src/Gui/DlgSettingsColorGradientImp.cpp | 2 +- src/Gui/DlgSettingsLazyLoadedImp.cpp | 4 +- src/Gui/DlgSettingsMacroImp.cpp | 2 +- src/Gui/DlgSettingsNavigation.cpp | 19 +- src/Gui/DlgToolbarsImp.cpp | 116 +++---- src/Gui/DlgUndoRedo.cpp | 4 +- src/Gui/DlgWorkbenchesImp.cpp | 2 +- src/Gui/DockWindowManager.cpp | 2 +- src/Gui/Document.cpp | 122 +++---- src/Gui/DocumentModel.cpp | 58 ++-- src/Gui/DocumentPyImp.cpp | 6 +- src/Gui/DocumentRecovery.cpp | 2 +- src/Gui/DownloadItem.cpp | 2 +- src/Gui/DownloadManager.cpp | 6 +- src/Gui/EditorView.cpp | 4 +- src/Gui/ExpressionBindingPy.cpp | 4 +- src/Gui/ExpressionCompleter.cpp | 4 +- src/Gui/FileDialog.cpp | 67 ++-- src/Gui/Flag.cpp | 2 +- src/Gui/GLBuffer.cpp | 8 +- src/Gui/GestureNavigationStyle.cpp | 4 +- src/Gui/GraphicsViewZoom.cpp | 4 +- src/Gui/GuiApplication.cpp | 4 +- src/Gui/GuiApplicationNativeEventAware.cpp | 12 +- src/Gui/InputField.cpp | 36 +- src/Gui/InputVector.cpp | 4 +- src/Gui/InputVector.h | 6 +- src/Gui/Inventor/SmSwitchboard.cpp | 2 +- src/Gui/InventorNavigationStyle.cpp | 8 +- src/Gui/Language/Translator.cpp | 10 +- src/Gui/LinkViewPyImp.cpp | 4 +- src/Gui/MDIView.cpp | 8 +- src/Gui/MainWindow.cpp | 174 +++++----- src/Gui/MainWindowPy.cpp | 4 +- src/Gui/ManualAlignment.cpp | 52 +-- src/Gui/MayaGestureNavigationStyle.cpp | 24 +- src/Gui/MenuManager.cpp | 4 +- src/Gui/MouseSelection.cpp | 2 +- src/Gui/NaviCube.cpp | 22 +- src/Gui/NavigationStyle.cpp | 46 +-- src/Gui/OnlineDocumentation.cpp | 6 +- src/Gui/OpenCascadeNavigationStyle.cpp | 8 +- src/Gui/OpenSCADNavigationStyle.cpp | 8 +- src/Gui/Placement.cpp | 62 ++-- src/Gui/PrefWidgets.cpp | 4 +- src/Gui/ProgressBar.cpp | 8 +- src/Gui/PropertyPage.cpp | 2 +- src/Gui/PropertyView.cpp | 10 +- src/Gui/PythonConsole.cpp | 30 +- src/Gui/PythonDebugger.cpp | 12 +- src/Gui/PythonEditor.cpp | 4 +- src/Gui/PythonWrapper.cpp | 16 +- src/Gui/QuantitySpinBox.cpp | 24 +- src/Gui/ReportView.cpp | 36 +- src/Gui/RevitNavigationStyle.cpp | 8 +- src/Gui/SceneInspector.cpp | 24 +- src/Gui/Selection.cpp | 45 ++- src/Gui/Selection.h | 2 +- src/Gui/SelectionFilter.cpp | 12 +- src/Gui/SelectionObjectPyImp.cpp | 12 +- src/Gui/SoAxisCrossKit.cpp | 24 +- src/Gui/SoFCBoundingBox.cpp | 14 +- src/Gui/SoFCCSysDragger.cpp | 86 ++--- src/Gui/SoFCColorBar.cpp | 8 +- src/Gui/SoFCColorGradient.cpp | 16 +- src/Gui/SoFCColorLegend.cpp | 22 +- src/Gui/SoFCDB.cpp | 12 +- src/Gui/SoFCInteractiveElement.cpp | 14 +- src/Gui/SoFCOffscreenRenderer.cpp | 2 +- src/Gui/SoFCSelection.cpp | 34 +- src/Gui/SoFCSelectionAction.cpp | 10 +- src/Gui/SoFCUnifiedSelection.cpp | 40 +-- src/Gui/SoNavigationDragger.cpp | 10 +- src/Gui/SoTextLabel.cpp | 2 +- src/Gui/SoTouchEvents.cpp | 8 +- src/Gui/SpinBox.cpp | 6 +- src/Gui/Splashscreen.cpp | 30 +- src/Gui/SplitView3DInventor.cpp | 10 +- src/Gui/TaskCSysDragger.cpp | 8 +- src/Gui/TaskElementColors.cpp | 4 +- src/Gui/TaskView/TaskAppearance.cpp | 64 ++-- src/Gui/TaskView/TaskDialogPython.cpp | 8 +- src/Gui/TaskView/TaskSelectLinkProperty.cpp | 18 +- src/Gui/TaskView/TaskView.cpp | 40 +-- src/Gui/TaskView/TaskWatcher.cpp | 2 +- src/Gui/TextEdit.cpp | 14 +- src/Gui/TinkerCADNavigationStyle.cpp | 8 +- src/Gui/ToolBarManager.cpp | 4 +- src/Gui/ToolBox.cpp | 2 +- src/Gui/ToolBoxManager.cpp | 2 +- src/Gui/TouchpadNavigationStyle.cpp | 8 +- src/Gui/Transform.cpp | 54 ++- src/Gui/Tree.cpp | 72 ++-- src/Gui/TreeView.cpp | 2 +- src/Gui/Utilities.cpp | 6 +- src/Gui/VectorListEditor.cpp | 6 +- src/Gui/View3DInventor.cpp | 16 +- src/Gui/View3DInventorExamples.cpp | 34 +- src/Gui/View3DInventorViewer.cpp | 92 ++--- src/Gui/View3DPy.cpp | 48 +-- src/Gui/View3DViewerPy.cpp | 4 +- src/Gui/ViewProvider.cpp | 18 +- src/Gui/ViewProviderAnnotation.cpp | 30 +- src/Gui/ViewProviderBuilder.cpp | 14 +- src/Gui/ViewProviderDocumentObject.cpp | 11 +- src/Gui/ViewProviderDocumentObjectGroup.cpp | 6 +- src/Gui/ViewProviderDragger.cpp | 34 +- src/Gui/ViewProviderGeometryObject.cpp | 16 +- src/Gui/ViewProviderGroupExtension.cpp | 2 +- src/Gui/ViewProviderInventorObject.cpp | 20 +- src/Gui/ViewProviderLine.cpp | 8 +- src/Gui/ViewProviderLink.cpp | 32 +- src/Gui/ViewProviderMeasureDistance.cpp | 26 +- src/Gui/ViewProviderOrigin.cpp | 6 +- src/Gui/ViewProviderOriginFeature.cpp | 14 +- src/Gui/ViewProviderPart.cpp | 4 +- src/Gui/ViewProviderPlane.cpp | 8 +- src/Gui/ViewProviderPyImp.cpp | 18 +- src/Gui/ViewProviderPythonFeature.cpp | 12 +- src/Gui/ViewProviderTextDocument.cpp | 6 +- src/Gui/ViewProviderVRMLObject.cpp | 24 +- src/Gui/WaitCursor.cpp | 4 +- src/Gui/WidgetFactory.cpp | 12 +- src/Gui/Widgets.cpp | 38 +- src/Gui/Workbench.cpp | 176 +++++----- src/Gui/WorkbenchFactory.cpp | 4 +- src/Gui/WorkbenchPyImp.cpp | 12 +- src/Gui/propertyeditor/PropertyEditor.cpp | 24 +- src/Gui/propertyeditor/PropertyItem.cpp | 324 +++++++++--------- .../propertyeditor/PropertyItemDelegate.cpp | 12 +- src/Gui/propertyeditor/PropertyModel.cpp | 24 +- 175 files changed, 2051 insertions(+), 2057 deletions(-) diff --git a/src/Gui/3Dconnexion/GuiNativeEventMac.cpp b/src/Gui/3Dconnexion/GuiNativeEventMac.cpp index 5f8d0ed4b9..cbdb49751d 100644 --- a/src/Gui/3Dconnexion/GuiNativeEventMac.cpp +++ b/src/Gui/3Dconnexion/GuiNativeEventMac.cpp @@ -65,7 +65,7 @@ Gui::GuiNativeEvent::tdx_drv_handler(io_connect_t connection, //printf("tdx_drv_handler\n"); //printf("connection: %X\n", connection); //printf("messageType %c%c%c%c\n", messageType/0x1000000, messageType/0x10000, messageType/0x100, messageType); - ConnexionDeviceStatePtr msg = (ConnexionDeviceStatePtr)messageArgument; + auto msg = (ConnexionDeviceStatePtr)messageArgument; switch(messageType) { case kConnexionMsgDeviceState: diff --git a/src/Gui/Action.cpp b/src/Gui/Action.cpp index f80458abef..261a5612fc 100644 --- a/src/Gui/Action.cpp +++ b/src/Gui/Action.cpp @@ -247,7 +247,7 @@ void ActionGroup::addTo(QWidget *w) // and adding this action to the widget doesn't work. if (_dropDown) { if (w->inherits("QMenu")) { - QMenu *menu = new QMenu(w); + auto menu = new QMenu(w); QAction* action = qobject_cast(w)->addMenu(menu); action->setMenuRole(_action->menuRole()); menu->setTitle(_action->text()); @@ -259,7 +259,7 @@ void ActionGroup::addTo(QWidget *w) tb->setPopupMode(QToolButton::MenuButtonPopup); tb->setObjectName(QString::fromLatin1("qt_toolbutton_menubutton")); QList acts = _group->actions(); - QMenu* menu = new QMenu(tb); + auto menu = new QMenu(tb); menu->addActions(acts); tb->setMenu(menu); //tb->addActions(_group->actions()); @@ -468,7 +468,7 @@ void WorkbenchComboBox::onActivated(int i) { // Send the event to the workbench group to delay the destruction of the emitting widget. int index = itemData(i).toInt(); - WorkbenchActionEvent* ev = new WorkbenchActionEvent(this->actions().at(index)); + auto ev = new WorkbenchActionEvent(this->actions().at(index)); QApplication::postEvent(this->group, ev); // TODO: Test if we can use this instead //QTimer::singleShot(20, this->actions()[i], SLOT(trigger())); @@ -529,7 +529,7 @@ void WorkbenchGroup::addTo(QWidget *w) { refreshWorkbenchList(); if (w->inherits("QToolBar")) { - QToolBar* bar = qobject_cast(w); + auto bar = qobject_cast(w); QComboBox* box = new WorkbenchComboBox(this, w); box->setIconSize(QSize(16, 16)); box->setToolTip(_action->toolTip()); @@ -540,7 +540,7 @@ void WorkbenchGroup::addTo(QWidget *w) bar->addWidget(box); } else if (w->inherits("QMenu")) { - QMenu* menu = qobject_cast(w); + auto menu = qobject_cast(w); menu = menu->addMenu(_action->text()); menu->addActions(_group->actions()); } @@ -613,7 +613,7 @@ void WorkbenchGroup::refreshWorkbenchList() void WorkbenchGroup::customEvent( QEvent* e ) { if (e->type() == QEvent::User) { - Gui::WorkbenchActionEvent* ce = (Gui::WorkbenchActionEvent*)e; + auto ce = (Gui::WorkbenchActionEvent*)e; ce->action()->trigger(); } } @@ -826,8 +826,8 @@ void RecentFilesAction::restore() _group->addAction(QLatin1String(""))->setVisible(false); std::vector MRU = hGrp->GetASCIIs("MRU"); QStringList files; - for (std::vector::iterator it = MRU.begin(); it!=MRU.end();++it) - files.append(QString::fromUtf8(it->c_str())); + for(const auto& it : MRU) + files.append(QString::fromUtf8(it.c_str())); setFiles(files); } @@ -969,9 +969,9 @@ void RecentMacrosAction::activateFile(int id) } else { if (QApplication::keyboardModifiers() == Qt::ShiftModifier){ //open for editing on Shift+click - PythonEditor* editor = new PythonEditor(); + auto editor = new PythonEditor(); editor->setWindowIcon(Gui::BitmapFactory().iconFromTheme("applications-python")); - PythonEditorView* edit = new PythonEditorView(editor, getMainWindow()); + auto edit = new PythonEditorView(editor, getMainWindow()); edit->setDisplayName(PythonEditorView::FileName); edit->open(filename); edit->resize(400, 300); @@ -1212,7 +1212,7 @@ WindowAction::~WindowAction() void WindowAction::addTo ( QWidget * w ) { - QMenu* menu = qobject_cast(w); + auto menu = qobject_cast(w); if (!menu) { if (!_menu) { _menu = new QMenu(); diff --git a/src/Gui/ActionFunction.cpp b/src/Gui/ActionFunction.cpp index d64dc0aa71..b28744327c 100644 --- a/src/Gui/ActionFunction.cpp +++ b/src/Gui/ActionFunction.cpp @@ -65,7 +65,7 @@ void ActionFunction::triggered() { Q_D(ActionFunction); - QAction* a = qobject_cast(sender()); + auto a = qobject_cast(sender()); QMap >::iterator it = d->triggerMap.find(a); if (it != d->triggerMap.end()) { // invoke the class function here @@ -85,7 +85,7 @@ void ActionFunction::toggled(bool on) { Q_D(ActionFunction); - QAction* a = qobject_cast(sender()); + auto a = qobject_cast(sender()); QMap >::iterator it = d->toggleMap.find(a); if (it != d->toggleMap.end()) { // invoke the class function here @@ -105,7 +105,7 @@ void ActionFunction::hovered() { Q_D(ActionFunction); - QAction* a = qobject_cast(sender()); + auto a = qobject_cast(sender()); QMap >::iterator it = d->hoverMap.find(a); if (it != d->hoverMap.end()) { // invoke the class function here diff --git a/src/Gui/Application.cpp b/src/Gui/Application.cpp index d6061f06cb..53c167b790 100644 --- a/src/Gui/Application.cpp +++ b/src/Gui/Application.cpp @@ -208,7 +208,7 @@ FreeCADGui_subgraphFromObject(PyObject * /*self*/, PyObject *args) std::string vp = obj->getViewProviderName(); SoNode* node = nullptr; try { - Base::BaseClass* base = static_cast(Base::Type::createInstanceByName(vp.c_str(), true)); + auto base = static_cast(Base::Type::createInstanceByName(vp.c_str(), true)); if (base && base->getTypeId().isDerivedFrom(Gui::ViewProviderDocumentObject::getClassTypeId())) { std::unique_ptr vp(static_cast(base)); std::map Map; @@ -221,8 +221,8 @@ FreeCADGui_subgraphFromObject(PyObject * /*self*/, PyObject *args) static_cast(pyproxy)->setValue(Py::Long(1)); } - for (std::map::iterator it = Map.begin(); it != Map.end(); ++it) { - vp->updateData(it->second); + for (const auto & it : Map){ + vp->updateData(it.second); } std::vector modes = vp->getDisplayModes(); @@ -268,7 +268,7 @@ FreeCADGui_exportSubgraph(PyObject * /*self*/, PyObject *args) void* ptr = nullptr; try { Base::Interpreter().convertSWIGPointerObj("pivy.coin", "SoNode *", proxy, &ptr, 0); - SoNode* node = static_cast(ptr); + auto node = static_cast(ptr); if (node) { std::string formatStr(format); std::string buffer; @@ -695,7 +695,7 @@ void Application::exportTo(const char* FileName, const char* DocName, const char std::stringstream str; std::set unique_objs; str << "__objs__=[]" << std::endl; - for (std::vector::iterator it = sel.begin(); it != sel.end(); ++it) { + for (auto it = sel.begin(); it != sel.end(); ++it) { if (unique_objs.insert(*it).second) { str << "__objs__.append(FreeCAD.getDocument(\"" << DocName << "\").getObject(\"" << (*it)->getNameInDocument() << "\"))" << std::endl; @@ -760,7 +760,7 @@ void Application::slotNewDocument(const App::Document& Doc, bool isMainDoc) std::map::const_iterator it = d->documents.find(&Doc); assert(it==d->documents.end()); #endif - Gui::Document* pDoc = new Gui::Document(const_cast(&Doc),this); + auto pDoc = new Gui::Document(const_cast(&Doc),this); d->documents[&Doc] = pDoc; // connect the signals to the application for the new document @@ -1552,9 +1552,9 @@ QStringList Application::workbenches() const { // If neither 'HiddenWorkbench' nor 'ExtraWorkbench' is set then all workbenches are returned. const std::map& config = App::Application::Config(); - std::map::const_iterator ht = config.find("HiddenWorkbench"); - std::map::const_iterator et = config.find("ExtraWorkbench"); - std::map::const_iterator st = config.find("StartWorkbench"); + auto ht = config.find("HiddenWorkbench"); + auto et = config.find("ExtraWorkbench"); + auto st = config.find("StartWorkbench"); const char* start = (st != config.end() ? st->second.c_str() : ""); QStringList hidden, extra; if (ht != config.end()) { @@ -1914,8 +1914,8 @@ void Application::runApplication() // opens them QDir cwd = QDir::current(); std::list files = App::Application::getCmdLineFiles(); - for (std::list::iterator jt = files.begin(); jt != files.end(); ++jt) { - QString fn = QString::fromUtf8(jt->c_str(), static_cast(jt->size())); + for (const auto & file : files) { + QString fn = QString::fromUtf8(file.c_str(), static_cast(file.size())); QFileInfo fi(fn); // if path name is relative make it absolute because the running instance // cannot determine the full path when trying to load the file @@ -2041,13 +2041,13 @@ void Application::runApplication() // filter wheel events for combo boxes if (hGrp->GetBool("ComboBoxWheelEventFilter", false)) { - WheelEventFilter* filter = new WheelEventFilter(&mainApp); + auto filter = new WheelEventFilter(&mainApp); mainApp.installEventFilter(filter); } //filter keyboard events to substitute decimal separator if (hGrp->GetBool("SubstituteDecimalSeparator", false)) { - KeyboardFilter* filter = new KeyboardFilter(&mainApp); + auto filter = new KeyboardFilter(&mainApp); mainApp.installEventFilter(filter); } @@ -2112,7 +2112,7 @@ void Application::runApplication() } QPixmap px(path); if (!px.isNull()) { - QLabel* logo = new QLabel(); + auto logo = new QLabel(); logo->setPixmap(px.scaledToHeight(32)); mw.statusBar()->addPermanentWidget(logo, 0); logo->setFrameShape(QFrame::NoFrame); @@ -2290,7 +2290,7 @@ void Application::runApplication() void Application::setStyleSheet(const QString& qssFile, bool tiledBackground) { Gui::MainWindow* mw = getMainWindow(); - QMdiArea* mdi = mw->findChild(); + auto mdi = mw->findChild(); mdi->setProperty("showImage", tiledBackground); // Qt's style sheet doesn't support it to define the link color of a QLabel diff --git a/src/Gui/ApplicationPy.cpp b/src/Gui/ApplicationPy.cpp index 4710b78f86..bded2ca619 100644 --- a/src/Gui/ApplicationPy.cpp +++ b/src/Gui/ApplicationPy.cpp @@ -645,9 +645,9 @@ PyObject* Application::sOpen(PyObject * /*self*/, PyObject *args) else if (ext == QLatin1String("py") || ext == QLatin1String("fcmacro") || ext == QLatin1String("fcscript")) { - PythonEditor* editor = new PythonEditor(); + auto editor = new PythonEditor(); editor->setWindowIcon(Gui::BitmapFactory().iconFromTheme("applications-python")); - PythonEditorView* edit = new PythonEditorView(editor, getMainWindow()); + auto edit = new PythonEditorView(editor, getMainWindow()); edit->open(fileName); edit->resize(400, 300); getMainWindow()->addWindow( edit ); @@ -719,9 +719,9 @@ PyObject* Application::sInsert(PyObject * /*self*/, PyObject *args) else if (ext == QLatin1String("py") || ext == QLatin1String("fcmacro") || ext == QLatin1String("fcscript")) { - PythonEditor* editor = new PythonEditor(); + auto editor = new PythonEditor(); editor->setWindowIcon(Gui::BitmapFactory().iconFromTheme("applications-python")); - PythonEditorView* edit = new PythonEditorView(editor, getMainWindow()); + auto edit = new PythonEditorView(editor, getMainWindow()); edit->open(fileName); edit->resize(400, 300); getMainWindow()->addWindow( edit ); @@ -769,7 +769,7 @@ PyObject* Application::sExport(PyObject * /*self*/, PyObject *args) ext == QLatin1String("xhtml")) { // build up the graph - SoSeparator* sep = new SoSeparator(); + auto sep = new SoSeparator(); sep->ref(); for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) { @@ -804,7 +804,7 @@ PyObject* Application::sExport(PyObject * /*self*/, PyObject *args) if (gui_doc) { Gui::MDIView* view = gui_doc->getActiveView(); if (view) { - View3DInventor* view3d = qobject_cast(view); + auto view3d = qobject_cast(view); if (view3d) view3d->viewAll(); QPrinter printer(QPrinter::ScreenResolution); @@ -1495,14 +1495,14 @@ PyObject* Application::sCreateViewer(PyObject * /*self*/, PyObject *args) return nullptr; } else if (num_of_views == 1) { - View3DInventor* viewer = new View3DInventor(nullptr, nullptr); + auto viewer = new View3DInventor(nullptr, nullptr); if (title) viewer->setWindowTitle(QString::fromUtf8(title)); Gui::getMainWindow()->addWindow(viewer); return viewer->getPyObject(); } else { - SplitView3DInventor* viewer = new SplitView3DInventor(num_of_views, nullptr, nullptr); + auto viewer = new SplitView3DInventor(num_of_views, nullptr, nullptr); if (title) viewer->setWindowTitle(QString::fromUtf8(title)); Gui::getMainWindow()->addWindow(viewer); diff --git a/src/Gui/AutoSaver.cpp b/src/Gui/AutoSaver.cpp index 634664f52a..38e49ae04b 100644 --- a/src/Gui/AutoSaver.cpp +++ b/src/Gui/AutoSaver.cpp @@ -260,8 +260,8 @@ void AutoSaveProperty::slotNewObject(const App::DocumentObject& obj) // if an object was deleted and then restored by an undo then add all properties // because this might be the data files which we may want to re-write - for (std::vector::iterator it = props.begin(); it != props.end(); ++it) { - slotChangePropertyData(*(*it)); + for (const auto & prop : props) { + slotChangePropertyData(*prop); } } @@ -289,7 +289,7 @@ bool RecoveryWriter::shouldWrite(const std::string& name, const Base::Persistenc // Property files of a view provider can always be written because // these are rather small files. if (object->isDerivedFrom(App::Property::getClassTypeId())) { - const App::Property* prop = static_cast(object); + const auto* prop = static_cast(object); const App::PropertyContainer* parent = prop->getContainer(); if (parent && parent->isDerivedFrom(Gui::ViewProvider::getClassTypeId())) return true; @@ -381,7 +381,7 @@ void RecoveryWriter::writeFiles() // For properties a copy can be created and then this can be written to disk in a thread if (entry.Object->isDerivedFrom(App::Property::getClassTypeId())) { - const App::Property* prop = static_cast(entry.Object); + const auto* prop = static_cast(entry.Object); QThreadPool::globalInstance()->start(new RecoveryRunnable(getModes(), DirName.c_str(), entry.FileName.c_str(), prop)); } else { diff --git a/src/Gui/AxisOrigin.cpp b/src/Gui/AxisOrigin.cpp index 82b54667f7..7851dc66d8 100644 --- a/src/Gui/AxisOrigin.cpp +++ b/src/Gui/AxisOrigin.cpp @@ -87,14 +87,14 @@ SoGroup *AxisOrigin::getNode() { pCoords->point.setNum(3); pCoords->point.setValues(0, 13, verts); - SoAutoZoomTranslation *zoom = new SoAutoZoomTranslation; + auto zoom = new SoAutoZoomTranslation; zoom->scaleFactor = scale; - SoDrawStyle* style = new SoDrawStyle(); + auto style = new SoDrawStyle(); style->lineWidth = lineSize; style->pointSize = pointSize; - SoMaterialBinding* matBinding = new SoMaterialBinding; + auto matBinding = new SoMaterialBinding; matBinding->value = SoMaterialBinding::PER_FACE_INDEXED; node->addChild(zoom); diff --git a/src/Gui/AxisOriginPyImp.cpp b/src/Gui/AxisOriginPyImp.cpp index 78d7f2345e..e80873b23c 100644 --- a/src/Gui/AxisOriginPyImp.cpp +++ b/src/Gui/AxisOriginPyImp.cpp @@ -63,7 +63,7 @@ PyObject* AxisOriginPy::getElementPicked(PyObject* args) return nullptr; } - SoPickedPoint *pp = static_cast(ptr); + auto pp = static_cast(ptr); std::string name; if (!getAxisOriginPtr()->getElementPicked(pp,name)) Py_Return; @@ -85,7 +85,7 @@ PyObject* AxisOriginPy::getDetailPath(PyObject* args) return nullptr; } - SoPath *pPath = static_cast(ptr); + auto pPath = static_cast(ptr); SoDetail *det = nullptr; if (!getAxisOriginPtr()->getDetailPath(sub, static_cast(pPath), det)) { delete det; diff --git a/src/Gui/BitmapFactory.cpp b/src/Gui/BitmapFactory.cpp index 0d9519c109..2746c3f5a7 100644 --- a/src/Gui/BitmapFactory.cpp +++ b/src/Gui/BitmapFactory.cpp @@ -136,8 +136,8 @@ void BitmapFactoryInst::restoreCustomPaths() Base::Reference group = App::GetApplication().GetParameterGroupByPath ("User parameter:BaseApp/Preferences/Bitmaps"); std::vector paths = group->GetASCIIs("CustomPath"); - for (std::vector::iterator it = paths.begin(); it != paths.end(); ++it) { - addPath(QString::fromUtf8(it->c_str())); + for (auto & path : paths) { + addPath(QString::fromUtf8(path.c_str())); } } @@ -469,12 +469,12 @@ QPixmap BitmapFactoryInst::merge(const QPixmap& p1, const QPixmap& p2, bool vert QBitmap mask2 = p2.mask(); mask.fill( Qt::color0 ); - QPainter* pt1 = new QPainter(&res); + auto* pt1 = new QPainter(&res); pt1->drawPixmap(0, 0, p1); pt1->drawPixmap(x, y, p2); delete pt1; - QPainter* pt2 = new QPainter(&mask); + auto* pt2 = new QPainter(&mask); pt2->drawPixmap(0, 0, mask1); pt2->drawPixmap(x, y, mask2); delete pt2; diff --git a/src/Gui/BlenderNavigationStyle.cpp b/src/Gui/BlenderNavigationStyle.cpp index ccccc0d008..0ef5bb4e8f 100644 --- a/src/Gui/BlenderNavigationStyle.cpp +++ b/src/Gui/BlenderNavigationStyle.cpp @@ -106,13 +106,13 @@ SbBool BlenderNavigationStyle::processSoEvent(const SoEvent * const ev) // Keyboard handling if (type.isDerivedFrom(SoKeyboardEvent::getClassTypeId())) { - const SoKeyboardEvent * const event = static_cast(ev); + const auto event = static_cast(ev); processed = processKeyboardEvent(event); } // Mouse Button / Spaceball Button handling if (type.isDerivedFrom(SoMouseButtonEvent::getClassTypeId())) { - const SoMouseButtonEvent * const event = (const SoMouseButtonEvent *) ev; + const auto * const event = (const SoMouseButtonEvent *) ev; const int button = event->getButton(); const SbBool press = event->getState() == SoButtonEvent::DOWN ? true : false; @@ -197,7 +197,7 @@ SbBool BlenderNavigationStyle::processSoEvent(const SoEvent * const ev) // Mouse Movement handling if (type.isDerivedFrom(SoLocation2Event::getClassTypeId())) { this->lockrecenter = true; - const SoLocation2Event * const event = (const SoLocation2Event *) ev; + const auto * const event = (const SoLocation2Event *) ev; if (this->currentmode == NavigationStyle::ZOOMING) { this->zoomByCursor(posn, prevnormalized); newmode = NavigationStyle::SELECTION; @@ -219,7 +219,7 @@ SbBool BlenderNavigationStyle::processSoEvent(const SoEvent * const ev) // Spaceball & Joystick handling if (type.isDerivedFrom(SoMotion3Event::getClassTypeId())) { - const SoMotion3Event * const event = static_cast(ev); + const auto * const event = static_cast(ev); if (event) this->processMotionEvent(event); processed = true; diff --git a/src/Gui/CADNavigationStyle.cpp b/src/Gui/CADNavigationStyle.cpp index f6abc32ae8..3cd1f7942e 100644 --- a/src/Gui/CADNavigationStyle.cpp +++ b/src/Gui/CADNavigationStyle.cpp @@ -100,13 +100,13 @@ SbBool CADNavigationStyle::processSoEvent(const SoEvent * const ev) // Keyboard handling if (type.isDerivedFrom(SoKeyboardEvent::getClassTypeId())) { - const SoKeyboardEvent * const event = static_cast(ev); + const auto * const event = static_cast(ev); processed = processKeyboardEvent(event); } // Mouse Button / Spaceball Button handling if (type.isDerivedFrom(SoMouseButtonEvent::getClassTypeId())) { - const SoMouseButtonEvent * const event = (const SoMouseButtonEvent *) ev; + const auto * const event = (const SoMouseButtonEvent *) ev; const int button = event->getButton(); const SbBool press = event->getState() == SoButtonEvent::DOWN ? true : false; @@ -207,7 +207,7 @@ SbBool CADNavigationStyle::processSoEvent(const SoEvent * const ev) // Mouse Movement handling if (type.isDerivedFrom(SoLocation2Event::getClassTypeId())) { this->lockrecenter = true; - const SoLocation2Event * const event = (const SoLocation2Event *) ev; + const auto * const event = (const SoLocation2Event *) ev; if (this->currentmode == NavigationStyle::ZOOMING) { this->zoomByCursor(posn, prevnormalized); processed = true; @@ -227,7 +227,7 @@ SbBool CADNavigationStyle::processSoEvent(const SoEvent * const ev) // Spaceball & Joystick handling if (type.isDerivedFrom(SoMotion3Event::getClassTypeId())) { - const SoMotion3Event * const event = static_cast(ev); + const auto * const event = static_cast(ev); if (event) this->processMotionEvent(event); processed = true; diff --git a/src/Gui/CallTips.cpp b/src/Gui/CallTips.cpp index fb51c3ff5c..8be8fccf48 100644 --- a/src/Gui/CallTips.cpp +++ b/src/Gui/CallTips.cpp @@ -277,7 +277,7 @@ QMap CallTipsList::extractTips(const QString& context) const // If we have an instance of PyObjectBase then determine whether it's valid or not if (PyObject_IsInstance(inst.ptr(), typeobj) == 1) { - Base::PyObjectBase* baseobj = static_cast(inst.ptr()); + auto baseobj = static_cast(inst.ptr()); validObject = baseobj->isValid(); } else { @@ -300,14 +300,14 @@ QMap CallTipsList::extractTips(const QString& context) const // names. So, we add these names to the list, too. PyObject* appdoctypeobj = Base::getTypeAsObject(&App::DocumentPy::Type); if (PyObject_IsSubclass(type.ptr(), appdoctypeobj) == 1) { - App::DocumentPy* docpy = (App::DocumentPy*)(inst.ptr()); - App::Document* document = docpy->getDocumentPtr(); + auto docpy = (App::DocumentPy*)(inst.ptr()); + auto document = docpy->getDocumentPtr(); // Make sure that the C++ object is alive if (document) { std::vector objects = document->getObjects(); Py::List list; - for (std::vector::iterator it = objects.begin(); it != objects.end(); ++it) - list.append(Py::String((*it)->getNameInDocument())); + for (const auto & object : objects) + list.append(Py::String(object->getNameInDocument())); extractTipsFromObject(inst, list, tips); } } @@ -316,15 +316,15 @@ QMap CallTipsList::extractTips(const QString& context) const // names. So, we add these names to the list, too. PyObject* guidoctypeobj = Base::getTypeAsObject(&Gui::DocumentPy::Type); if (PyObject_IsSubclass(type.ptr(), guidoctypeobj) == 1) { - Gui::DocumentPy* docpy = (Gui::DocumentPy*)(inst.ptr()); + auto docpy = (Gui::DocumentPy*)(inst.ptr()); if (docpy->getDocumentPtr()) { App::Document* document = docpy->getDocumentPtr()->getDocument(); // Make sure that the C++ object is alive if (document) { std::vector objects = document->getObjects(); Py::List list; - for (std::vector::iterator it = objects.begin(); it != objects.end(); ++it) - list.append(Py::String((*it)->getNameInDocument())); + for (const auto & object : objects) + list.append(Py::String(object->getNameInDocument())); extractTipsFromObject(inst, list, tips); } } @@ -426,7 +426,7 @@ void CallTipsList::extractTipsFromObject(Py::Object& obj, Py::List& list, QMap& tips) const { - App::PropertyContainerPy* cont = (App::PropertyContainerPy*)(obj.ptr()); + auto cont = (App::PropertyContainerPy*)(obj.ptr()); App::PropertyContainer* container = cont->getPropertyContainerPtr(); // Make sure that the C++ object is alive if (!container) @@ -434,15 +434,15 @@ void CallTipsList::extractTipsFromProperties(Py::Object& obj, QMap Map; container->getPropertyMap(Map); - for (std::map::const_iterator It=Map.begin();It!=Map.end();++It) { + for (const auto & It : Map) { CallTip tip; - QString str = QString::fromLatin1(It->first.c_str()); + QString str = QString::fromLatin1(It.first.c_str()); tip.name = str; tip.type = CallTip::Property; - QString longdoc = QString::fromUtf8(container->getPropertyDocumentation(It->second)); + QString longdoc = QString::fromUtf8(container->getPropertyDocumentation(It.second)); // a point, mesh or shape property - if (It->second->isDerivedFrom(Base::Type::fromName("App::PropertyComplexGeoData"))) { - Py::Object data(It->second->getPyObject(), true); + if (It.second->isDerivedFrom(Base::Type::fromName("App::PropertyComplexGeoData"))) { + Py::Object data(It.second->getPyObject(), true); if (data.hasAttr("__doc__")) { Py::Object help = data.getAttr("__doc__"); if (help.isString()) { @@ -594,7 +594,7 @@ bool CallTipsList::eventFilter(QObject * watched, QEvent * event) // This is a trick to avoid to hide the tooltip window after the defined time span // of 10 seconds. We just filter out all timer events to keep the label visible. if (watched->inherits("QLabel")) { - QLabel* label = qobject_cast(watched); + auto label = qobject_cast(watched); // Ignore the timer events to prevent from being closed if (label->windowFlags() & Qt::ToolTip && event->type() == QEvent::Timer) return true; @@ -605,7 +605,7 @@ bool CallTipsList::eventFilter(QObject * watched, QEvent * event) } else if (isVisible() && watched == textEdit) { if (event->type() == QEvent::KeyPress) { - QKeyEvent* ke = (QKeyEvent*)event; + auto ke = (QKeyEvent*)event; if (ke->key() == Qt::Key_Up || ke->key() == Qt::Key_Down) { keyPressEvent(ke); return true; @@ -648,7 +648,7 @@ bool CallTipsList::eventFilter(QObject * watched, QEvent * event) } } else if (event->type() == QEvent::KeyRelease) { - QKeyEvent* ke = (QKeyEvent*)event; + auto* ke = (QKeyEvent*)event; if (ke->key() == Qt::Key_Up || ke->key() == Qt::Key_Down || ke->key() == Qt::Key_PageUp || ke->key() == Qt::Key_PageDown) { QList items = selectedItems(); @@ -694,7 +694,7 @@ void CallTipsList::callTipItemActivated(QListWidgetItem *item) cursor.insertText( text ); // get CallTip from item's UserRole-data - CallTip callTip = item->data(Qt::UserRole).value(); + auto callTip = item->data(Qt::UserRole).value(); // if call completion enabled and we've something callable (method or class constructor) ... if (this->doCallCompletion diff --git a/src/Gui/Clipping.cpp b/src/Gui/Clipping.cpp index 7e4f33bcd0..1a30c4bb63 100644 --- a/src/Gui/Clipping.cpp +++ b/src/Gui/Clipping.cpp @@ -88,7 +88,7 @@ public: static void moveCallback(void * data, SoSensor * sensor) { Q_UNUSED(sensor); - Private* self = static_cast(data); + auto self = static_cast(data); if (self->view) { Gui::View3DInventorViewer* view = self->view->getViewer(); SoClipPlane* clip = self->clipView; @@ -187,7 +187,7 @@ Clipping::Clipping(Gui::View3DInventor* view, QWidget* parent) Clipping* Clipping::makeDockWidget(Gui::View3DInventor* view) { // embed this dialog into a QDockWidget - Clipping* clipping = new Clipping(view); + auto clipping = new Clipping(view); Gui::DockWindowManager* pDockMgr = Gui::DockWindowManager::instance(); QDockWidget* dw = pDockMgr->addDockWindow("Clipping", clipping, Qt::LeftDockWidgetArea); dw->setFeatures(QDockWidget::DockWidgetMovable|QDockWidget::DockWidgetFloatable); @@ -210,7 +210,7 @@ Clipping::~Clipping() void Clipping::reject() { QDialog::reject(); - QDockWidget* dw = qobject_cast(parent()); + auto dw = qobject_cast(parent()); if (dw) { dw->deleteLater(); } diff --git a/src/Gui/ComboView.cpp b/src/Gui/ComboView.cpp index 59ff363ba4..41cc522afe 100644 --- a/src/Gui/ComboView.cpp +++ b/src/Gui/ComboView.cpp @@ -48,7 +48,7 @@ ComboView::ComboView(bool showModel, Gui::Document* pcDocument, QWidget *parent) { setWindowTitle(tr("Combo View")); - QGridLayout* pLayout = new QGridLayout(this); + auto pLayout = new QGridLayout(this); pLayout->setSpacing( 0 ); pLayout->setMargin ( 0 ); @@ -61,7 +61,7 @@ ComboView::ComboView(bool showModel, Gui::Document* pcDocument, QWidget *parent) connect(tabs, SIGNAL(currentChanged(int)), this, SLOT(onCurrentTabChanged(int))); if (showModel) { // splitter between tree and property view - QSplitter *splitter = new QSplitter(); + auto splitter = new QSplitter(); splitter->setOrientation(Qt::Vertical); tree = new TreePanel("ComboView", this); diff --git a/src/Gui/Command.cpp b/src/Gui/Command.cpp index b7481bc4f4..4340e61b40 100644 --- a/src/Gui/Command.cpp +++ b/src/Gui/Command.cpp @@ -331,7 +331,7 @@ private: void Command::setupCheckable(int iMsg) { QAction *action = nullptr; - Gui::ActionGroup* pcActionGroup = qobject_cast(_pcAction); + auto pcActionGroup = qobject_cast(_pcAction); if(pcActionGroup) { QList a = pcActionGroup->actions(); assert(iMsg < a.size()); @@ -495,7 +495,7 @@ void Command::testActive() } } - Gui::ActionGroup* pcAction = qobject_cast(_pcAction); + auto pcAction = qobject_cast(_pcAction); if(pcAction) { Gui::CommandManager &rcCmdMgr = Gui::Application::Instance->commandManager(); const auto actions = pcAction->actions(); @@ -802,9 +802,9 @@ void Command::_copyVisual(const char *file, int line, const App::DocumentObject std::string Command::getPythonTuple(const std::string& name, const std::vector& subnames) { std::stringstream str; - std::vector::const_iterator last = --subnames.end(); + auto last = --subnames.end(); str << "(App.ActiveDocument." << name << ",["; - for (std::vector::const_iterator it = subnames.begin();it!=subnames.end();++it){ + for (auto it = subnames.cbegin(); it!=subnames.cend(); ++it){ str << "\"" << *it << "\""; if (it != last) str << ","; @@ -839,8 +839,8 @@ bool Command::isActiveObjectValid() void Command::updateAll(std::list cList) { if (!cList.empty()) { - for (std::list::iterator It= cList.begin();It!=cList.end();++It) - (*It)->onUpdate(); + for (auto & it : cList) + it->onUpdate(); } else { Gui::Application::Instance->onUpdate(); @@ -922,12 +922,12 @@ const char* Command::keySequenceToAccel(int sk) const /* Local class to ensure free()'ing the strings allocated below */ using StringMap = std::map; static StringMap strings; - StringMap::iterator i = strings.find(sk); + auto i = strings.find(sk); if (i != strings.end()) return i->second.c_str(); - QKeySequence::StandardKey type = (QKeySequence::StandardKey)sk; + auto type = (QKeySequence::StandardKey)sk; QKeySequence ks(type); QString qs = ks.toString(); QByteArray data = qs.toLatin1(); @@ -939,7 +939,7 @@ void Command::adjustCameraPosition() { Gui::Document* doc = Gui::Application::Instance->activeDocument(); if (doc) { - Gui::View3DInventor* view = static_cast(doc->getActiveView()); + auto view = static_cast(doc->getActiveView()); Gui::View3DInventorViewer* viewer = view->getViewer(); SoCamera* camera = viewer->getSoRenderManager()->getCamera(); if (!camera || !camera->isOfType(SoOrthographicCamera::getClassTypeId())) @@ -1031,7 +1031,7 @@ Command *GroupCommand::addCommand(const char *name) { } Action * GroupCommand::createAction() { - ActionGroup* pcAction = new ActionGroup(this, getMainWindow()); + auto pcAction = new ActionGroup(this, getMainWindow()); pcAction->setMenuRole(QAction::NoRole); pcAction->setDropDownMenu(true); pcAction->setExclusive(false); @@ -1190,17 +1190,17 @@ void MacroCommand::load() if (hGrp->HasGroup("Macros")) { hGrp = hGrp->GetGroup("Macros"); std::vector > macros = hGrp->GetGroups(); - for (std::vector >::iterator it = macros.begin(); it!=macros.end(); ++it ) { - MacroCommand* macro = new MacroCommand((*it)->GetGroupName()); - macro->setScriptName ( (*it)->GetASCII( "Script" ).c_str() ); - macro->setMenuText ( (*it)->GetASCII( "Menu" ).c_str() ); - macro->setToolTipText ( (*it)->GetASCII( "Tooltip" ).c_str() ); - macro->setWhatsThis ( (*it)->GetASCII( "WhatsThis" ).c_str() ); - macro->setStatusTip ( (*it)->GetASCII( "Statustip" ).c_str() ); - if ((*it)->GetASCII("Pixmap", "nix") != "nix") - macro->setPixmap ( (*it)->GetASCII( "Pixmap" ).c_str() ); - macro->setAccel ( (*it)->GetASCII( "Accel",nullptr ).c_str() ); - macro->systemMacro = (*it)->GetBool("System", false); + for (const auto & it : macros) { + auto macro = new MacroCommand(it->GetGroupName()); + macro->setScriptName ( it->GetASCII( "Script" ).c_str() ); + macro->setMenuText ( it->GetASCII( "Menu" ).c_str() ); + macro->setToolTipText ( it->GetASCII( "Tooltip" ).c_str() ); + macro->setWhatsThis ( it->GetASCII( "WhatsThis" ).c_str() ); + macro->setStatusTip ( it->GetASCII( "Statustip" ).c_str() ); + if (it->GetASCII("Pixmap", "nix") != "nix") + macro->setPixmap ( it->GetASCII( "Pixmap" ).c_str() ); + macro->setAccel ( it->GetASCII( "Accel",nullptr ).c_str() ); + macro->systemMacro = it->GetBool("System", false); Application::Instance->commandManager().addCommand( macro ); } } @@ -1213,8 +1213,8 @@ void MacroCommand::save() std::vector macros = Application::Instance->commandManager().getGroupCommands("Macros"); if ( !macros.empty() ) { - for (std::vector::iterator it = macros.begin(); it!=macros.end(); ++it ) { - MacroCommand* macro = (MacroCommand*)(*it); + for (const auto & it : macros) { + auto macro = (MacroCommand*)it; ParameterGrp::handle hMacro = hGrp->GetGroup(macro->getName()); hMacro->SetASCII( "Script", macro->getScriptName () ); hMacro->SetASCII( "Menu", macro->getMenuText () ); @@ -1358,7 +1358,7 @@ const char* PythonCommand::getHelpUrl() const Action * PythonCommand::createAction() { - QAction* qtAction = new QAction(nullptr); + auto qtAction = new QAction(nullptr); Action *pcAction; pcAction = new Action(this, qtAction, getMainWindow()); @@ -1489,7 +1489,7 @@ PythonGroupCommand::~PythonGroupCommand() void PythonGroupCommand::activated(int iMsg) { try { - Gui::ActionGroup* pcAction = qobject_cast(_pcAction); + auto pcAction = qobject_cast(_pcAction); QList a = pcAction->actions(); assert(iMsg < a.size()); QAction* act = a[iMsg]; @@ -1549,7 +1549,7 @@ bool PythonGroupCommand::isActive() Action * PythonGroupCommand::createAction() { - Gui::ActionGroup* pcAction = new Gui::ActionGroup(this, Gui::getMainWindow()); + auto pcAction = new Gui::ActionGroup(this, Gui::getMainWindow()); pcAction->setDropDownMenu(hasDropDownMenu()); pcAction->setExclusive(isExclusive()); @@ -1636,10 +1636,10 @@ void PythonGroupCommand::languageChange() applyCommandData(this->getName(), _pcAction); Gui::CommandManager &rcCmdMgr = Gui::Application::Instance->commandManager(); - Gui::ActionGroup* pcAction = qobject_cast(_pcAction); + auto* pcAction = qobject_cast(_pcAction); QList a = pcAction->actions(); - for (QList::iterator it = a.begin(); it != a.end(); ++it) { - Gui::Command* cmd = rcCmdMgr.getCommandByName((*it)->property("CommandName").toByteArray()); + for (const auto & it : a) { + Gui::Command* cmd = rcCmdMgr.getCommandByName(it->property("CommandName").toByteArray()); if (cmd) { // Python command use getName as context const char *context = dynamic_cast(cmd) ? cmd->getName() : cmd->className(); @@ -1649,10 +1649,10 @@ void PythonGroupCommand::languageChange() statustip = tooltip; } - (*it)->setIcon(Gui::BitmapFactory().iconFromTheme(cmd->getPixmap())); - (*it)->setText(QApplication::translate(context, cmd->getMenuText())); - (*it)->setToolTip(QApplication::translate(context, tooltip)); - (*it)->setStatusTip(QApplication::translate(context, statustip)); + it->setIcon(Gui::BitmapFactory().iconFromTheme(cmd->getPixmap())); + it->setText(QApplication::translate(context, cmd->getMenuText())); + it->setToolTip(QApplication::translate(context, tooltip)); + it->setStatusTip(QApplication::translate(context, statustip)); } } } @@ -1887,8 +1887,8 @@ void CommandManager::updateCommands(const char* sContext, int mode) { std::map >::iterator it = _sCommandModes.find(sContext); if (it != _sCommandModes.end()) { - for (std::list::iterator jt = it->second.begin(); jt != it->second.end(); ++jt) { - Command* cmd = getCommandByName(jt->c_str()); + for (const auto & jt : it->second) { + Command* cmd = getCommandByName(jt.c_str()); if (cmd) { cmd->updateAction(mode); } diff --git a/src/Gui/CommandDoc.cpp b/src/Gui/CommandDoc.cpp index 33e607d639..2b4feb1cde 100644 --- a/src/Gui/CommandDoc.cpp +++ b/src/Gui/CommandDoc.cpp @@ -235,8 +235,8 @@ void StdCmdImport::activated(int iMsg) if (emptyDoc) { // only do a view fit if the document was empty before. See also parameter 'AutoFitToView' in importFrom() std::list views = getActiveGuiDocument()->getMDIViewsOfType(Gui::View3DInventor::getClassTypeId()); - for (std::list::iterator it = views.begin(); it != views.end(); ++it) { - (*it)->viewAll(); + for (const auto & view : views) { + view->viewAll(); } } } @@ -571,7 +571,7 @@ void StdCmdDependencyGraph::activated(int iMsg) { Q_UNUSED(iMsg); App::Document* doc = App::GetApplication().getActiveDocument(); - Gui::GraphvizView* view = new Gui::GraphvizView(*doc); + auto view = new Gui::GraphvizView(*doc); view->setWindowTitle(qApp->translate("Std_DependencyGraph","Dependency graph")); getMainWindow()->addWindow(view); } @@ -1495,7 +1495,7 @@ void StdCmdPlacement::activated(int iMsg) { Q_UNUSED(iMsg); std::vector sel = Gui::Selection().getObjectsOfType(App::GeoFeature::getClassTypeId()); - Gui::Dialog::TaskPlacement* plm = new Gui::Dialog::TaskPlacement(); + auto plm = new Gui::Dialog::TaskPlacement(); if (!sel.empty()) { App::Property* prop = sel.front()->getPropertyByName("Placement"); if (prop && prop->getTypeId() == App::PropertyPlacement::getClassTypeId()) @@ -1585,7 +1585,7 @@ void StdCmdAlignment::activated(int iMsg) Base::Vector3d upDir(0,1,0), viewDir(0,0,-1); Gui::Document* doc = Application::Instance->activeDocument(); if (doc) { - View3DInventor* mdi = qobject_cast(doc->getActiveView()); + auto mdi = qobject_cast(doc->getActiveView()); if (mdi) { View3DInventorViewer* viewer = mdi->getViewer(); SoCamera* camera = viewer->getSoRenderManager()->getCamera(); @@ -1706,7 +1706,7 @@ protected: } Gui::Action * createAction() override { - ActionGroup* pcAction = new ActionGroup(this, getMainWindow()); + auto pcAction = new ActionGroup(this, getMainWindow()); pcAction->setDropDownMenu(true); applyCommandData(this->className(), pcAction); diff --git a/src/Gui/CommandFeat.cpp b/src/Gui/CommandFeat.cpp index 79f7a0bef7..8d19c41a7a 100644 --- a/src/Gui/CommandFeat.cpp +++ b/src/Gui/CommandFeat.cpp @@ -88,24 +88,24 @@ void StdCmdRandomColor::activated(int iMsg) // get the complete selection std::vector sel = Selection().getCompleteSelection(); - for (std::vector::iterator it = sel.begin(); it != sel.end(); ++it) { - float fMax = (float)RAND_MAX; - float fRed = (float)rand()/fMax; - float fGrn = (float)rand()/fMax; - float fBlu = (float)rand()/fMax; + for (const auto & it : sel) { + auto fMax = (float)RAND_MAX; + auto fRed = (float)rand()/fMax; + auto fGrn = (float)rand()/fMax; + auto fBlu = (float)rand()/fMax; - ViewProvider* view = Application::Instance->getDocument(it->pDoc)->getViewProvider(it->pObject); + ViewProvider* view = Application::Instance->getDocument(it.pDoc)->getViewProvider(it.pObject); auto vpLink = dynamic_cast(view); if(vpLink) { if(!vpLink->OverrideMaterial.getValue()) - cmdGuiObjectArgs(it->pObject, "OverrideMaterial = True"); - cmdGuiObjectArgs(it->pObject, "ShapeMaterial.DiffuseColor=(%.2f,%.2f,%.2f)", fRed, fGrn, fBlu); + cmdGuiObjectArgs(it.pObject, "OverrideMaterial = True"); + cmdGuiObjectArgs(it.pObject, "ShapeMaterial.DiffuseColor=(%.2f,%.2f,%.2f)", fRed, fGrn, fBlu); continue; } auto color = dynamic_cast(view->getPropertyByName("ShapeColor")); if (color) { // get the view provider of the selected object and set the shape color - cmdGuiObjectArgs(it->pObject, "ShapeColor=(%.2f,%.2f,%.2f)", fRed, fGrn, fBlu); + cmdGuiObjectArgs(it.pObject, "ShapeColor=(%.2f,%.2f,%.2f)", fRed, fGrn, fBlu); } } } @@ -165,14 +165,14 @@ void StdCmdSendToPythonConsole::activated(int iMsg) Gui::Command::runCommand(Gui::Command::Gui,cmd.toLatin1()); cmd = QString::fromLatin1("obj = lnk.getLinkedObject()"); Gui::Command::runCommand(Gui::Command::Gui,cmd.toLatin1()); - const App::Link* link = static_cast(obj); + const auto link = static_cast(obj); obj = link->getLinkedObject(); } else { cmd = QString::fromLatin1("obj = doc.getObject(\"%1\")").arg(objname); Gui::Command::runCommand(Gui::Command::Gui,cmd.toLatin1()); } if (obj->getTypeId().isDerivedFrom(App::GeoFeature::getClassTypeId())) { - const App::GeoFeature* geoObj = static_cast(obj); + const auto geoObj = static_cast(obj); const App::PropertyGeometry* geo = geoObj->getPropertyOfGeometry(); if (geo){ cmd = QString::fromLatin1("shp = obj.") + QLatin1String(geo->getName()); //"Shape", "Mesh", "Points", etc. @@ -185,8 +185,8 @@ void StdCmdSendToPythonConsole::activated(int iMsg) if (subnames.size() > 1) { std::ostringstream strm; strm << "subs = ["; - for (std::vector::iterator it = subnames.begin(); it != subnames.end(); ++it) { - strm << "obj.getSubObject(\"" << *it << "\"),"; + for (const auto & subname : subnames) { + strm << "obj.getSubObject(\"" << subname << "\"),"; } strm << "]"; Gui::Command::runCommand(Gui::Command::Gui, strm.str().c_str()); @@ -196,7 +196,7 @@ void StdCmdSendToPythonConsole::activated(int iMsg) } //show the python console if it's not already visible, and set the keyboard focus to it QWidget* pc = DockWindowManager::instance()->getDockWindow("Python console"); - PythonConsole *pcPython = qobject_cast(pc); + auto pcPython = qobject_cast(pc); if (pcPython) { DockWindowManager::instance()->activate(pcPython); pcPython->setFocus(); diff --git a/src/Gui/CommandLink.cpp b/src/Gui/CommandLink.cpp index 4bfc0f13df..6769641e7a 100644 --- a/src/Gui/CommandLink.cpp +++ b/src/Gui/CommandLink.cpp @@ -88,7 +88,7 @@ bool StdCmdLinkMakeGroup::isActive() { Action * StdCmdLinkMakeGroup::createAction() { - ActionGroup* pcAction = new ActionGroup(this, getMainWindow()); + auto pcAction = new ActionGroup(this, getMainWindow()); pcAction->setDropDownMenu(true); applyCommandData(this->className(), pcAction); @@ -109,7 +109,7 @@ void StdCmdLinkMakeGroup::languageChange() if (!_pcAction) return; - ActionGroup* pcAction = qobject_cast(_pcAction); + auto pcAction = qobject_cast(_pcAction); QList acts = pcAction->actions(); acts[0]->setText(QObject::tr("Simple group")); acts[1]->setText(QObject::tr("Group with links")); diff --git a/src/Gui/CommandPyImp.cpp b/src/Gui/CommandPyImp.cpp index 22e6c5bb81..45402d36c0 100644 --- a/src/Gui/CommandPyImp.cpp +++ b/src/Gui/CommandPyImp.cpp @@ -52,7 +52,7 @@ PyObject* CommandPy::get(PyObject *args) Command* cmd = Application::Instance->commandManager().getCommandByName(pName); if (cmd) { - CommandPy* cmdPy = new CommandPy(cmd); + auto cmdPy = new CommandPy(cmd); return cmdPy; } @@ -76,8 +76,8 @@ PyObject* CommandPy::listAll(PyObject *args) std::vector cmds = Application::Instance->commandManager().getAllCommands(); PyObject* pyList = PyList_New(cmds.size()); int i=0; - for ( std::vector::iterator it = cmds.begin(); it != cmds.end(); ++it ) { - PyObject* str = PyUnicode_FromString((*it)->getName()); + for (const auto & cmd : cmds) { + PyObject* str = PyUnicode_FromString(cmd->getName()); PyList_SetItem(pyList, i++, str); } return pyList; @@ -302,7 +302,7 @@ PyObject* CommandPy::getAction(PyObject *args) Command* cmd = this->getCommandPtr(); if (cmd) { Action* action = cmd->getAction(); - ActionGroup* group = qobject_cast(action); + auto* group = qobject_cast(action); PythonWrapper wrap; wrap.loadWidgetsModule(); @@ -342,7 +342,7 @@ PyObject* CommandPy::createCustomCommand(PyObject* args, PyObject* kw) auto name = Application::Instance->commandManager().newMacroName(); CommandManager& commandManager = Application::Instance->commandManager(); - MacroCommand* macro = new MacroCommand(name.c_str(), false); + auto macro = new MacroCommand(name.c_str(), false); commandManager.addCommand(macro); macro->setScriptName(macroFile); diff --git a/src/Gui/CommandStd.cpp b/src/Gui/CommandStd.cpp index db5c4b9e4b..238996a5bb 100644 --- a/src/Gui/CommandStd.cpp +++ b/src/Gui/CommandStd.cpp @@ -145,7 +145,7 @@ StdCmdRecentFiles::StdCmdRecentFiles() */ void StdCmdRecentFiles::activated(int iMsg) { - RecentFilesAction* act = qobject_cast(_pcAction); + auto act = qobject_cast(_pcAction); if (act) act->activateFile( iMsg ); } @@ -154,7 +154,7 @@ void StdCmdRecentFiles::activated(int iMsg) */ Action * StdCmdRecentFiles::createAction() { - RecentFilesAction* pcAction = new RecentFilesAction(this, getMainWindow()); + auto pcAction = new RecentFilesAction(this, getMainWindow()); pcAction->setObjectName(QLatin1String("recentFiles")); pcAction->setDropDownMenu(true); applyCommandData(this->className(), pcAction); @@ -185,7 +185,7 @@ StdCmdRecentMacros::StdCmdRecentMacros() */ void StdCmdRecentMacros::activated(int iMsg) { - RecentMacrosAction* act = qobject_cast(_pcAction); + auto act = qobject_cast(_pcAction); if (act) act->activateFile( iMsg ); } @@ -194,7 +194,7 @@ void StdCmdRecentMacros::activated(int iMsg) */ Action * StdCmdRecentMacros::createAction() { - RecentMacrosAction* pcAction = new RecentMacrosAction(this, getMainWindow()); + auto pcAction = new RecentMacrosAction(this, getMainWindow()); pcAction->setObjectName(QLatin1String("recentMacros")); pcAction->setDropDownMenu(true); applyCommandData(this->className(), pcAction); @@ -828,7 +828,7 @@ StdCmdUnitsCalculator::StdCmdUnitsCalculator() void StdCmdUnitsCalculator::activated(int iMsg) { Q_UNUSED(iMsg); - Gui::Dialog::DlgUnitsCalculator *dlg = new Gui::Dialog::DlgUnitsCalculator( getMainWindow() ); + auto dlg = new Gui::Dialog::DlgUnitsCalculator( getMainWindow() ); dlg->show(); } @@ -865,7 +865,7 @@ StdCmdUserEditMode::StdCmdUserEditMode() Gui::Action * StdCmdUserEditMode::createAction() { - Gui::ActionGroup* pcAction = new Gui::ActionGroup(this, Gui::getMainWindow()); + auto pcAction = new Gui::ActionGroup(this, Gui::getMainWindow()); pcAction->setDropDownMenu(true); pcAction->setIsMode(true); applyCommandData(this->className(), pcAction); @@ -900,7 +900,7 @@ void StdCmdUserEditMode::languageChange() if (!_pcAction) return; - Gui::ActionGroup* pcAction = qobject_cast(_pcAction); + auto pcAction = qobject_cast(_pcAction); QList a = pcAction->actions(); for (int i = 0 ; i < a.count() ; i++) { @@ -914,7 +914,7 @@ void StdCmdUserEditMode::languageChange() void StdCmdUserEditMode::updateIcon(int mode) { - Gui::ActionGroup *actionGroup = dynamic_cast(_pcAction); + auto actionGroup = dynamic_cast(_pcAction); if (!actionGroup) return; diff --git a/src/Gui/CommandTest.cpp b/src/Gui/CommandTest.cpp index d0a7a7c6c1..b42e3a7c0a 100644 --- a/src/Gui/CommandTest.cpp +++ b/src/Gui/CommandTest.cpp @@ -78,7 +78,7 @@ void Std_TestQM::activated(int iMsg) for (QList::Iterator it = i18n.begin(); it != i18n.end(); ++it) qApp->removeTranslator(*it); for (QStringList::Iterator it = files.begin(); it != files.end(); ++it) { - QTranslator* translator = new QTranslator(qApp); + auto translator = new QTranslator(qApp); if (translator->load(*it)) { qApp->installTranslator(translator); } @@ -515,7 +515,7 @@ void CmdTestProgress4::activated(int iMsg) try { unsigned long steps = 50; - Base::SequencerLauncher* seq = new Base::SequencerLauncher("Starting progress bar", steps); + auto seq = new Base::SequencerLauncher("Starting progress bar", steps); for (unsigned long i=0; istart(); loop.exec(); - BarThread* thr2 = new BarThread(1500); + auto thr2 = new BarThread(1500); QTimer timer; timer.setSingleShot(true); @@ -616,7 +616,7 @@ void CmdTestProgress5::activated(int iMsg) timer.start(2000); // 2s timeout loop.exec(); - BarThread* thr3 = new BarThread(1000); + auto thr3 = new BarThread(1000); thr3->start(); } diff --git a/src/Gui/CommandView.cpp b/src/Gui/CommandView.cpp index 71510f406e..0aef32e356 100644 --- a/src/Gui/CommandView.cpp +++ b/src/Gui/CommandView.cpp @@ -106,7 +106,7 @@ StdOrthographicCamera::StdOrthographicCamera() void StdOrthographicCamera::activated(int iMsg) { if (iMsg == 1) { - View3DInventor* view = qobject_cast(getMainWindow()->activeWindow()); + auto view = qobject_cast(getMainWindow()->activeWindow()); SoCamera* cam = view->getViewer()->getSoRenderManager()->getCamera(); if (!cam || cam->getTypeId() != SoOrthographicCamera::getClassTypeId()) @@ -116,7 +116,7 @@ void StdOrthographicCamera::activated(int iMsg) bool StdOrthographicCamera::isActive() { - View3DInventor* view = qobject_cast(getMainWindow()->activeWindow()); + auto view = qobject_cast(getMainWindow()->activeWindow()); if (view) { // update the action group if needed bool check = _pcAction->isChecked(); @@ -156,7 +156,7 @@ StdPerspectiveCamera::StdPerspectiveCamera() void StdPerspectiveCamera::activated(int iMsg) { if (iMsg == 1) { - View3DInventor* view = qobject_cast(getMainWindow()->activeWindow()); + auto view = qobject_cast(getMainWindow()->activeWindow()); SoCamera* cam = view->getViewer()->getSoRenderManager()->getCamera(); if (!cam || cam->getTypeId() != SoPerspectiveCamera::getClassTypeId()) @@ -166,7 +166,7 @@ void StdPerspectiveCamera::activated(int iMsg) bool StdPerspectiveCamera::isActive() { - View3DInventor* view = qobject_cast(getMainWindow()->activeWindow()); + auto view = qobject_cast(getMainWindow()->activeWindow()); if (view) { // update the action group if needed bool check = _pcAction->isChecked(); @@ -215,7 +215,7 @@ void StdCmdViewSaveCamera::activated(int iMsg) { Q_UNUSED(iMsg); - Gui::View3DInventor* view = qobject_cast(Gui::getMainWindow()->activeWindow()); + auto view = qobject_cast(Gui::getMainWindow()->activeWindow()); if (view) { view->getViewer()->saveHomePosition(); } @@ -241,7 +241,7 @@ void StdCmdViewRestoreCamera::activated(int iMsg) { Q_UNUSED(iMsg); - Gui::View3DInventor* view = qobject_cast(Gui::getMainWindow()->activeWindow()); + auto view = qobject_cast(Gui::getMainWindow()->activeWindow()); if (view) { view->getViewer()->resetToHomePosition(); } @@ -299,7 +299,7 @@ StdCmdFreezeViews::StdCmdFreezeViews() Action * StdCmdFreezeViews::createAction() { - ActionGroup* pcAction = new ActionGroup(this, getMainWindow()); + auto pcAction = new ActionGroup(this, getMainWindow()); pcAction->setDropDownMenu(true); applyCommandData(this->className(), pcAction); @@ -327,7 +327,7 @@ Action * StdCmdFreezeViews::createAction() void StdCmdFreezeViews::activated(int iMsg) { - ActionGroup* pcAction = qobject_cast(_pcAction); + auto pcAction = qobject_cast(_pcAction); if (iMsg == 0) { onSaveViews(); @@ -382,7 +382,7 @@ void StdCmdFreezeViews::onSaveViews() if (file.open(QFile::WriteOnly)) { QTextStream str(&file); - ActionGroup* pcAction = qobject_cast(_pcAction); + auto pcAction = qobject_cast(_pcAction); QList acts = pcAction->actions(); str << "\n" << "\n"; @@ -474,7 +474,7 @@ void StdCmdFreezeViews::onRestoreViews() // use this rather than the attribute 'Count' because it could be // changed from outside int ct = cameras.count(); - ActionGroup* pcAction = qobject_cast(_pcAction); + auto pcAction = qobject_cast(_pcAction); QList acts = pcAction->actions(); int numRestoredViews = std::min(ct, acts.size()-offset); @@ -501,7 +501,7 @@ void StdCmdFreezeViews::onRestoreViews() bool StdCmdFreezeViews::isActive() { - View3DInventor* view = qobject_cast(getMainWindow()->activeWindow()); + auto view = qobject_cast(getMainWindow()->activeWindow()); if (view) { saveView->setEnabled(savedViews > 0); freezeView->setEnabled(savedViews < maxViews); @@ -522,7 +522,7 @@ void StdCmdFreezeViews::languageChange() if (!_pcAction) return; - ActionGroup* pcAction = qobject_cast(_pcAction); + auto pcAction = qobject_cast(_pcAction); QList acts = pcAction->actions(); acts[0]->setText(QObject::tr("Save views...")); acts[1]->setText(QObject::tr("Load views...")); @@ -558,7 +558,7 @@ StdCmdToggleClipPlane::StdCmdToggleClipPlane() Action * StdCmdToggleClipPlane::createAction() { - Action *pcAction = (Action*)Command::createAction(); + auto pcAction = (Action*)Command::createAction(); return pcAction; } @@ -567,7 +567,7 @@ void StdCmdToggleClipPlane::activated(int iMsg) Q_UNUSED(iMsg); static QPointer clipping = nullptr; if (!clipping) { - View3DInventor* view = qobject_cast(getMainWindow()->activeWindow()); + auto view = qobject_cast(getMainWindow()->activeWindow()); if (view) { clipping = Gui::Dialog::Clipping::makeDockWidget(view); } @@ -576,7 +576,7 @@ void StdCmdToggleClipPlane::activated(int iMsg) bool StdCmdToggleClipPlane::isActive() { - View3DInventor* view = qobject_cast(getMainWindow()->activeWindow()); + auto view = qobject_cast(getMainWindow()->activeWindow()); return view ? true : false; } @@ -613,7 +613,7 @@ StdCmdDrawStyle::StdCmdDrawStyle() Gui::Action * StdCmdDrawStyle::createAction() { - Gui::ActionGroup* pcAction = new Gui::ActionGroup(this, Gui::getMainWindow()); + auto pcAction = new Gui::ActionGroup(this, Gui::getMainWindow()); pcAction->setDropDownMenu(true); pcAction->setIsMode(true); applyCommandData(this->className(), pcAction); @@ -675,7 +675,7 @@ void StdCmdDrawStyle::languageChange() if (!_pcAction) return; - Gui::ActionGroup* pcAction = qobject_cast(_pcAction); + auto pcAction = qobject_cast(_pcAction); QList a = pcAction->actions(); a[0]->setText(QCoreApplication::translate( @@ -716,14 +716,14 @@ void StdCmdDrawStyle::languageChange() void StdCmdDrawStyle::updateIcon(const MDIView *view) { - const Gui::View3DInventor *view3d = dynamic_cast(view); + const auto view3d = dynamic_cast(view); if (!view3d) return; Gui::View3DInventorViewer *viewer = view3d->getViewer(); if (!viewer) return; std::string mode(viewer->getOverrideMode()); - Gui::ActionGroup *actionGroup = dynamic_cast(_pcAction); + auto actionGroup = dynamic_cast(_pcAction); if (!actionGroup) return; @@ -768,7 +768,7 @@ void StdCmdDrawStyle::activated(int iMsg) bool oneChangedSignal(false); for (viewIt = views.begin(); viewIt != views.end(); ++viewIt) { - View3DInventor* view = qobject_cast(*viewIt); + auto view = qobject_cast(*viewIt); if (view) { View3DInventorViewer* viewer; @@ -862,21 +862,20 @@ void StdCmdToggleSelectability::activated(int iMsg) Q_UNUSED(iMsg); // go through all documents const std::vector docs = App::GetApplication().getDocuments(); - for (std::vector::const_iterator it = docs.begin(); it != docs.end(); ++it) { - Document *pcDoc = Application::Instance->getDocument(*it); + for (const auto & doc : docs) { + Document *pcDoc = Application::Instance->getDocument(doc); std::vector sel = Selection().getObjectsOfType - (App::DocumentObject::getClassTypeId(), (*it)->getName()); + (App::DocumentObject::getClassTypeId(), doc->getName()); - - for (std::vector::const_iterator ft=sel.begin();ft!=sel.end();++ft) { - ViewProvider *pr = pcDoc->getViewProviderByName((*ft)->getNameInDocument()); + for (const auto & ft : sel) { + ViewProvider *pr = pcDoc->getViewProviderByName(ft->getNameInDocument()); if (pr && pr->isDerivedFrom(ViewProviderGeometryObject::getClassTypeId())){ if (static_cast(pr)->Selectable.getValue()) doCommand(Gui,"Gui.getDocument(\"%s\").getObject(\"%s\").Selectable=False" - , (*it)->getName(), (*ft)->getNameInDocument()); + , doc->getName(), ft->getNameInDocument()); else doCommand(Gui,"Gui.getDocument(\"%s\").getObject(\"%s\").Selectable=True" - , (*it)->getName(), (*ft)->getNameInDocument()); + , doc->getName(), ft->getNameInDocument()); } } } @@ -971,9 +970,9 @@ void StdCmdSelectVisibleObjects::activated(int iMsg) std::vector visible; visible.reserve(obj.size()); - for (std::vector::const_iterator it=obj.begin();it!=obj.end();++it) { - if (doc->isShow((*it)->getNameInDocument())) - visible.push_back(*it); + for (const auto & it : obj) { + if (doc->isShow(it->getNameInDocument())) + visible.push_back(it); } SelectionSingleton& rSel = Selection(); @@ -1011,13 +1010,13 @@ void StdCmdToggleObjects::activated(int iMsg) const std::vector obj = app->getObjectsOfType (App::DocumentObject::getClassTypeId()); - for (std::vector::const_iterator it=obj.begin();it!=obj.end();++it) { - if (doc->isShow((*it)->getNameInDocument())) + for (const auto & it : obj) { + if (doc->isShow(it->getNameInDocument())) doCommand(Gui,"Gui.getDocument(\"%s\").getObject(\"%s\").Visibility=False" - , app->getName(), (*it)->getNameInDocument()); + , app->getName(), it->getNameInDocument()); else doCommand(Gui,"Gui.getDocument(\"%s\").getObject(\"%s\").Visibility=True" - , app->getName(), (*it)->getNameInDocument()); + , app->getName(), it->getNameInDocument()); } } @@ -1052,9 +1051,9 @@ void StdCmdShowObjects::activated(int iMsg) const std::vector obj = app->getObjectsOfType (App::DocumentObject::getClassTypeId()); - for (std::vector::const_iterator it=obj.begin();it!=obj.end();++it) { + for (const auto & it : obj) { doCommand(Gui,"Gui.getDocument(\"%s\").getObject(\"%s\").Visibility=True" - , app->getName(), (*it)->getNameInDocument()); + , app->getName(), it->getNameInDocument()); } } @@ -1089,9 +1088,9 @@ void StdCmdHideObjects::activated(int iMsg) const std::vector obj = app->getObjectsOfType (App::DocumentObject::getClassTypeId()); - for (std::vector::const_iterator it=obj.begin();it!=obj.end();++it) { + for (const auto & it : obj) { doCommand(Gui,"Gui.getDocument(\"%s\").getObject(\"%s\").Visibility=False" - , app->getName(), (*it)->getNameInDocument()); + , app->getName(), it->getNameInDocument()); } } @@ -1625,7 +1624,7 @@ StdViewDockUndockFullscreen::StdViewDockUndockFullscreen() Action * StdViewDockUndockFullscreen::createAction() { - ActionGroup* pcAction = new ActionGroup(this, getMainWindow()); + auto pcAction = new ActionGroup(this, getMainWindow()); pcAction->setDropDownMenu(true); pcAction->setText(QCoreApplication::translate( this->className(), getMenuText())); @@ -1698,7 +1697,7 @@ bool StdViewDockUndockFullscreen::isActive() MDIView* view = getMainWindow()->activeWindow(); if (qobject_cast(view)) { // update the action group if needed - ActionGroup* pActGrp = qobject_cast(_pcAction); + auto pActGrp = qobject_cast(_pcAction); if (pActGrp) { int index = pActGrp->checkedAction(); int mode = (int)(view->currentViewMode()); @@ -1764,7 +1763,7 @@ StdViewScreenShot::StdViewScreenShot() void StdViewScreenShot::activated(int iMsg) { Q_UNUSED(iMsg); - View3DInventor* view = qobject_cast(getMainWindow()->activeWindow()); + auto view = qobject_cast(getMainWindow()->activeWindow()); if (view) { QStringList formats; SbViewportRegion vp(view->getViewer()->getSoRenderManager()->getViewportRegion()); @@ -1800,7 +1799,7 @@ void StdViewScreenShot::activated(int iMsg) fd.selectNameFilter(selFilter); // create the image options widget - DlgSettingsImageImp* opt = new DlgSettingsImageImp(&fd); + auto opt = new DlgSettingsImageImp(&fd); SbVec2s sz = vp.getWindowSize(); opt->setImageSize((int)sz[0], (int)sz[1]); opt->setBackgroundType(backtype); @@ -2014,7 +2013,7 @@ StdCmdAxisCross::StdCmdAxisCross() void StdCmdAxisCross::activated(int iMsg) { Q_UNUSED(iMsg); - Gui::View3DInventor* view = qobject_cast(Gui::getMainWindow()->activeWindow()); + auto view = qobject_cast(Gui::getMainWindow()->activeWindow()); if (view) { if (!view->getViewer()->hasAxisCross()) doCommand(Command::Gui,"Gui.ActiveDocument.ActiveView.setAxisCross(True)"); @@ -2025,7 +2024,7 @@ void StdCmdAxisCross::activated(int iMsg) bool StdCmdAxisCross::isActive() { - Gui::View3DInventor* view = qobject_cast(Gui::getMainWindow()->activeWindow()); + auto view = qobject_cast(Gui::getMainWindow()->activeWindow()); if (view && view->getViewer()->hasAxisCross()) { if (!_pcAction->isChecked()) _pcAction->setChecked(true); @@ -2338,7 +2337,7 @@ StdViewZoomIn::StdViewZoomIn() void StdViewZoomIn::activated(int iMsg) { Q_UNUSED(iMsg); - View3DInventor* view = qobject_cast(getMainWindow()->activeWindow()); + auto view = qobject_cast(getMainWindow()->activeWindow()); if ( view ) { View3DInventorViewer* viewer = view->getViewer(); viewer->navigationStyle()->zoomIn(); @@ -2371,7 +2370,7 @@ StdViewZoomOut::StdViewZoomOut() void StdViewZoomOut::activated(int iMsg) { Q_UNUSED(iMsg); - View3DInventor* view = qobject_cast(getMainWindow()->activeWindow()); + auto view = qobject_cast(getMainWindow()->activeWindow()); if (view) { View3DInventorViewer* viewer = view->getViewer(); viewer->navigationStyle()->zoomOut(); @@ -2431,15 +2430,15 @@ public: // Also supports aborting the selection mode by pressing (releasing) the Escape key. static void selectionCallback(void * ud, SoEventCallback * n) { - SelectionCallbackHandler* selectionHandler = static_cast(ud); - Gui::View3DInventorViewer* view = static_cast(n->getUserData()); + auto selectionHandler = static_cast(ud); + auto view = static_cast(n->getUserData()); const SoEvent* ev = n->getEvent(); if (ev->isOfType(SoKeyboardEvent::getClassTypeId())) { n->setHandled(); n->getAction()->setHandled(); - const SoKeyboardEvent * ke = static_cast(ev); + const auto ke = static_cast(ev); const SbBool press = ke->getState() == SoButtonEvent::DOWN ? true : false; if (ke->getKey() == SoKeyboardEvent::ESCAPE) { @@ -2450,7 +2449,7 @@ public: } } else if (ev->isOfType(SoMouseButtonEvent::getClassTypeId())) { - const SoMouseButtonEvent * mbe = static_cast(ev); + const auto mbe = static_cast(ev); // Mark all incoming mouse button events as handled, especially, to deactivate the selection node n->getAction()->setHandled(); @@ -2541,7 +2540,7 @@ StdViewBoxZoom::StdViewBoxZoom() void StdViewBoxZoom::activated(int iMsg) { Q_UNUSED(iMsg); - View3DInventor* view = qobject_cast(getMainWindow()->activeWindow()); + auto view = qobject_cast(getMainWindow()->activeWindow()); if ( view ) { View3DInventorViewer* viewer = view->getViewer(); if (!viewer->isSelecting()) { @@ -2736,7 +2735,7 @@ static std::vector getBoxSelection( static void doSelect(void* ud, SoEventCallback * cb) { bool selectElement = ud ? true : false; - Gui::View3DInventorViewer* viewer = static_cast(cb->getUserData()); + auto viewer = static_cast(cb->getUserData()); SoNode* root = viewer->getSceneGraph(); static_cast(root)->selectionRole.setValue(true); @@ -2762,8 +2761,8 @@ static void doSelect(void* ud, SoEventCallback * cb) selectionMode = INTERSECT; } else { - for (std::vector::const_iterator it = picked.begin(); it != picked.end(); ++it) - polygon.Add(Base::Vector2d((*it)[0],(*it)[1])); + for (const auto & it : picked) + polygon.Add(Base::Vector2d(it[0],it[1])); } App::Document* doc = App::GetApplication().getActiveDocument(); @@ -2793,7 +2792,7 @@ static void doSelect(void* ud, SoEventCallback * cb) void StdBoxSelection::activated(int iMsg) { Q_UNUSED(iMsg); - View3DInventor* view = qobject_cast(getMainWindow()->activeWindow()); + auto view = qobject_cast(getMainWindow()->activeWindow()); if (view) { View3DInventorViewer* viewer = view->getViewer(); if (!viewer->isSelecting()) { @@ -2874,7 +2873,7 @@ StdBoxElementSelection::StdBoxElementSelection() void StdBoxElementSelection::activated(int iMsg) { Q_UNUSED(iMsg); - View3DInventor* view = qobject_cast(getMainWindow()->activeWindow()); + auto view = qobject_cast(getMainWindow()->activeWindow()); if (view) { View3DInventorViewer* viewer = view->getViewer(); if (!viewer->isSelecting()) { @@ -3080,7 +3079,7 @@ void StdCmdMeasureDistance::activated(int iMsg) { Q_UNUSED(iMsg); Gui::Document* doc = Gui::Application::Instance->activeDocument(); - Gui::View3DInventor* view = static_cast(doc->getActiveView()); + auto view = static_cast(doc->getActiveView()); if (view) { Gui::View3DInventorViewer* viewer = view->getViewer(); viewer->setEditing(true); @@ -3088,7 +3087,7 @@ void StdCmdMeasureDistance::activated(int iMsg) // Derives from QObject and we have a parent object, so we don't // require a delete. - PointMarker* marker = new PointMarker(viewer); + auto marker = new PointMarker(viewer); viewer->addEventCallback(SoEvent::getClassTypeId(), ViewProviderMeasureDistance::measureDistanceCallback, marker); } @@ -3218,7 +3217,7 @@ CmdViewMeasureClearAll::CmdViewMeasureClearAll() void CmdViewMeasureClearAll::activated(int iMsg) { Q_UNUSED(iMsg); - Gui::View3DInventor *view = dynamic_cast(Gui::Application::Instance-> + auto view = dynamic_cast(Gui::Application::Instance-> activeDocument()->getActiveView()); if (!view) return; diff --git a/src/Gui/CommandWindow.cpp b/src/Gui/CommandWindow.cpp index e592a70642..e32c965cf9 100644 --- a/src/Gui/CommandWindow.cpp +++ b/src/Gui/CommandWindow.cpp @@ -401,7 +401,7 @@ Action * StdCmdStatusBar::createAction() Action *pcAction = Command::createAction(); pcAction->setCheckable(true); pcAction->setChecked(false, true); - FilterStatusBar *fsb = new FilterStatusBar(pcAction); + auto fsb = new FilterStatusBar(pcAction); getMainWindow()->statusBar()->installEventFilter(fsb); return pcAction; diff --git a/src/Gui/Control.cpp b/src/Gui/Control.cpp index 85ed4d3aac..f911e541dc 100644 --- a/src/Gui/Control.cpp +++ b/src/Gui/Control.cpp @@ -61,7 +61,7 @@ ControlSingleton::~ControlSingleton() Gui::TaskView::TaskView* ControlSingleton::taskPanel() const { - Gui::DockWnd::ComboView* pcComboView = qobject_cast + auto pcComboView = qobject_cast (Gui::DockWindowManager::instance()->getDockWindow("Combo View")); // should return the pointer to combo view if (pcComboView) @@ -76,7 +76,7 @@ Gui::TaskView::TaskView* ControlSingleton::taskPanel() const void ControlSingleton::showTaskView() { - Gui::DockWnd::ComboView* pcComboView = qobject_cast + auto pcComboView = qobject_cast (Gui::DockWindowManager::instance()->getDockWindow("Combo View")); if (pcComboView) pcComboView->showTaskView(); @@ -86,7 +86,7 @@ void ControlSingleton::showTaskView() void ControlSingleton::showModelView() { - Gui::DockWnd::ComboView* pcComboView = qobject_cast + auto pcComboView = qobject_cast (Gui::DockWindowManager::instance()->getDockWindow("Combo View")); if (pcComboView) pcComboView->showTreeView(); @@ -116,13 +116,13 @@ void ControlSingleton::showDialog(Gui::TaskView::TaskDialog *dlg) // which may open a transaction but fails when auto transaction is still active. App::AutoTransaction::setEnable(false); - Gui::DockWnd::ComboView* pcComboView = qobject_cast + auto pcComboView = qobject_cast (Gui::DockWindowManager::instance()->getDockWindow("Combo View")); // should return the pointer to combo view if (pcComboView) { pcComboView->showDialog(dlg); // make sure that the combo view is shown - QDockWidget* dw = qobject_cast(pcComboView->parentWidget()); + auto dw = qobject_cast(pcComboView->parentWidget()); if (dw) { dw->setVisible(true); dw->toggleViewAction()->setVisible(true); @@ -136,7 +136,7 @@ void ControlSingleton::showDialog(Gui::TaskView::TaskDialog *dlg) } // not all workbenches have the combo view enabled else if (!_taskPanel) { - QDockWidget* dw = new QDockWidget(); + auto dw = new QDockWidget(); dw->setWindowTitle(tr("Task panel")); dw->setFeatures(QDockWidget::DockWidgetMovable); _taskPanel = new Gui::TaskView::TaskView(dw); @@ -175,7 +175,7 @@ Gui::TaskView::TaskDialog* ControlSingleton::activeDialog() const Gui::TaskView::TaskView* ControlSingleton::getTaskPanel() { // should return the pointer to combo view - Gui::DockWnd::ComboView* pcComboView = qobject_cast + auto pcComboView = qobject_cast (Gui::DockWindowManager::instance()->getDockWindow("Combo View")); if (pcComboView) return pcComboView->getTaskPanel(); @@ -205,7 +205,7 @@ void ControlSingleton::reject() void ControlSingleton::closeDialog() { - Gui::DockWnd::ComboView* pcComboView = qobject_cast + auto pcComboView = qobject_cast (Gui::DockWindowManager::instance()->getDockWindow("Combo View")); // should return the pointer to combo view if (pcComboView) @@ -217,13 +217,13 @@ void ControlSingleton::closeDialog() void ControlSingleton::closedDialog() { ActiveDialog = nullptr; - Gui::DockWnd::ComboView* pcComboView = qobject_cast + auto pcComboView = qobject_cast (Gui::DockWindowManager::instance()->getDockWindow("Combo View")); // should return the pointer to combo view assert(pcComboView); pcComboView->closedDialog(); // make sure that the combo view is shown - QDockWidget* dw = qobject_cast(pcComboView->parentWidget()); + auto dw = qobject_cast(pcComboView->parentWidget()); if (dw) dw->setFeatures(QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetMovable diff --git a/src/Gui/DAGView/DAGModel.cpp b/src/Gui/DAGView/DAGModel.cpp index 75509c1d18..406373d55e 100644 --- a/src/Gui/DAGView/DAGModel.cpp +++ b/src/Gui/DAGView/DAGModel.cpp @@ -241,7 +241,7 @@ void Model::slotNewObject(const ViewProviderDocumentObject &VPDObjectIn) graphLink->insert(virginRecord); //setup rectangle. - auto *rectangle = (*theGraph)[virginVertex].rectangle.get(); + auto rectangle = (*theGraph)[virginVertex].rectangle.get(); rectangle->setEditingBrush(QBrush(Qt::yellow)); auto icon = (*theGraph)[virginVertex].icon; @@ -305,7 +305,7 @@ void Model::slotChangeObject(const ViewProviderDocumentObject &VPDObjectIn, cons if (std::string("Label") == name) { const GraphLinkRecord &record = findRecord(&VPDObjectIn, *graphLink); - auto *text = (*theGraph)[record.vertex].text.get(); + auto text = (*theGraph)[record.vertex].text.get(); text->setPlainText(QString::fromUtf8(record.DObject->Label.getValue())); } else if (propertyIn.isDerivedFrom(App::PropertyLinkBase::getClassTypeId())) @@ -635,12 +635,12 @@ void Model::updateSlot() maxColumn = std::max(currentColumn, maxColumn); QBrush currentBrush(forgroundBrushes.at(currentColumn % forgroundBrushes.size())); - auto *rectangle = (*theGraph)[currentVertex].rectangle.get(); + auto rectangle = (*theGraph)[currentVertex].rectangle.get(); rectangle->setRect(-rowPadding, 0.0, rowPadding, rowHeight); //calculate actual length later. rectangle->setTransform(QTransform::fromTranslate(0, rowHeight * currentRow)); rectangle->setBackgroundBrush(backgroundBrushes[currentRow % backgroundBrushes.size()]); - auto *point = (*theGraph)[currentVertex].point.get(); + auto point = (*theGraph)[currentVertex].point.get(); point->setRect(0.0, 0.0, pointSize, pointSize); point->setTransform(QTransform::fromTranslate(pointSpacing * currentColumn, rowHeight * currentRow + rowHeight / 2.0 - pointSize / 2.0)); @@ -650,16 +650,16 @@ void Model::updateSlot() if (direction == -1) cheat = rowHeight; - auto *visiblePixmap = (*theGraph)[currentVertex].visibleIcon.get(); + auto visiblePixmap = (*theGraph)[currentVertex].visibleIcon.get(); visiblePixmap->setTransform(QTransform::fromTranslate(0.0, rowHeight * currentRow + cheat)); //calculate x location later. - auto *statePixmap = (*theGraph)[currentVertex].stateIcon.get(); + auto statePixmap = (*theGraph)[currentVertex].stateIcon.get(); statePixmap->setTransform(QTransform::fromTranslate(0.0, rowHeight * currentRow + cheat)); //calculate x location later. - auto *pixmap = (*theGraph)[currentVertex].icon.get(); + auto pixmap = (*theGraph)[currentVertex].icon.get(); pixmap->setTransform(QTransform::fromTranslate(0.0, rowHeight * currentRow + cheat)); //calculate x location later. - auto *text = (*theGraph)[currentVertex].text.get(); + auto text = (*theGraph)[currentVertex].text.get(); text->setPlainText(QString::fromUtf8(findRecord(currentVertex, *graphLink).DObject->Label.getValue())); text->setDefaultTextColor(currentBrush.color()); maxTextLength = std::max(maxTextLength, static_cast(text->boundingRect().width())); @@ -730,26 +730,26 @@ void Model::updateSlot() { float localCurrentX = columnSpacing; localCurrentX += pointToIcon; - auto *visiblePixmap = (*theGraph)[currentVertex].visibleIcon.get(); + auto visiblePixmap = (*theGraph)[currentVertex].visibleIcon.get(); QTransform visibleIconTransform = QTransform::fromTranslate(localCurrentX, 0.0); visiblePixmap->setTransform(visiblePixmap->transform() * visibleIconTransform); localCurrentX += iconSize + iconToIcon; - auto *statePixmap = (*theGraph)[currentVertex].stateIcon.get(); + auto statePixmap = (*theGraph)[currentVertex].stateIcon.get(); QTransform stateIconTransform = QTransform::fromTranslate(localCurrentX, 0.0); statePixmap->setTransform(statePixmap->transform() * stateIconTransform); localCurrentX += iconSize + iconToIcon; - auto *pixmap = (*theGraph)[currentVertex].icon.get(); + auto pixmap = (*theGraph)[currentVertex].icon.get(); QTransform iconTransform = QTransform::fromTranslate(localCurrentX, 0.0); pixmap->setTransform(pixmap->transform() * iconTransform); localCurrentX += iconSize + iconToText; - auto *text = (*theGraph)[currentVertex].text.get(); + auto text = (*theGraph)[currentVertex].text.get(); QTransform textTransform = QTransform::fromTranslate(localCurrentX, 0.0); text->setTransform(text->transform() * textTransform); - auto *rectangle = (*theGraph)[currentVertex].rectangle.get(); + auto rectangle = (*theGraph)[currentVertex].rectangle.get(); QRectF rect = rectangle->rect(); rect.setWidth(localCurrentX + maxTextLength + 2.0 * rowPadding); rectangle->setRect(rect); @@ -835,7 +835,7 @@ void Model::updateStates() { const GraphLinkRecord &record = findRecord(currentVertex, *graphLink); - auto *visiblePixmap = (*theGraph)[currentVertex].visibleIcon.get(); + auto visiblePixmap = (*theGraph)[currentVertex].visibleIcon.get(); VisibilityState currentVisibilityState = (record.VPDObject->isShow()) ? (VisibilityState::On) : (VisibilityState::Off); if ( @@ -884,7 +884,7 @@ RectItem* Model::getRectFromPosition(const QPointF& position) { RectItem *rect = nullptr; auto theItems = this->items(position, Qt::IntersectsItemBoundingRect, Qt::DescendingOrder); - for (auto *currentItem : theItems) + for (auto currentItem : theItems) { rect = dynamic_cast(currentItem); if (rect) break; @@ -931,7 +931,7 @@ void Model::mousePressEvent(QGraphicsSceneMouseEvent* event) QListselection = collidingItems(&intersectionLine); for (auto currentItem = selection.begin(); currentItem != selection.end(); ++currentItem) { - RectItem *rect = dynamic_cast(*currentItem); + auto rect = dynamic_cast(*currentItem); if (!rect) continue; const GraphLinkRecord &selectionRecord = findRecord(rect, *graphLink); Gui::Selection().addSelection(selectionRecord.DObject->getDocument()->getName(), @@ -959,7 +959,7 @@ void Model::mousePressEvent(QGraphicsSceneMouseEvent* event) //don't like that I am doing this again here after getRectFromPosition call. QGraphicsItem *item = itemAt(event->scenePos(), QTransform()); - QGraphicsPixmapItem *pixmapItem = dynamic_cast(item); + auto pixmapItem = dynamic_cast(item); if (pixmapItem && (pixmapItem == (*theGraph)[record.vertex].visibleIcon.get())) { //get all selections, but for now just the current pick. @@ -1053,7 +1053,7 @@ void Model::contextMenuEvent(QGraphicsSceneContextMenuEvent* event) //don't like that I am doing this again here after getRectFromPosition call. QGraphicsItem *item = itemAt(event->scenePos(), QTransform()); - QGraphicsPixmapItem *pixmapItem = dynamic_cast(item); + auto pixmapItem = dynamic_cast(item); if (pixmapItem && (pixmapItem == (*theGraph)[record.vertex].visibleIcon.get())) { visiblyIsolate(record.vertex); @@ -1099,8 +1099,8 @@ void Model::onRenameSlot() std::vector selections = getAllSelected(); assert(selections.size() == 1); - LineEdit *lineEdit = new LineEdit(); - auto *text = (*theGraph)[selections.front()].text.get(); + auto lineEdit = new LineEdit(); + auto text = (*theGraph)[selections.front()].text.get(); lineEdit->setText(text->toPlainText()); connect(lineEdit, SIGNAL(acceptedSignal()), this, SLOT(renameAcceptedSlot())); connect(lineEdit, SIGNAL(rejectedSignal()), this, SLOT(renameRejectedSlot())); @@ -1120,7 +1120,7 @@ void Model::renameAcceptedSlot() assert(selections.size() == 1); const GraphLinkRecord &record = findRecord(selections.front(), *graphLink); - LineEdit *lineEdit = dynamic_cast(proxy->widget()); + auto lineEdit = dynamic_cast(proxy->widget()); assert(lineEdit); const_cast(record.DObject)->Label.setValue(lineEdit->text().toUtf8().constData()); //const hack @@ -1143,7 +1143,7 @@ void Model::finishRename() void Model::editingStartSlot() { - QAction* action = qobject_cast(sender()); + auto action = qobject_cast(sender()); if (action) { int edit = action->data().toInt(); diff --git a/src/Gui/DAGView/DAGView.cpp b/src/Gui/DAGView/DAGView.cpp index 3fbffeb5ef..a6dafa8d89 100644 --- a/src/Gui/DAGView/DAGView.cpp +++ b/src/Gui/DAGView/DAGView.cpp @@ -41,7 +41,7 @@ namespace bp = boost::placeholders; DAG::DockWindow::DockWindow(Gui::Document* gDocumentIn, QWidget* parent): Gui::DockWindow(gDocumentIn, parent) { dagView = new View(this); - QVBoxLayout *layout = new QVBoxLayout(); + auto layout = new QVBoxLayout(); layout->addWidget(dagView); this->setLayout(layout); } @@ -80,7 +80,7 @@ void View::slotActiveDocument(const Document &documentIn) void View::slotDeleteDocument(const Document &documentIn) { - ModelMap::iterator it = modelMap.find(&documentIn); + ModelMap::const_iterator it = modelMap.find(&documentIn); if (it != modelMap.end()) modelMap.erase(it); } diff --git a/src/Gui/DemoMode.cpp b/src/Gui/DemoMode.cpp index 73beef6d03..6b75b2b529 100644 --- a/src/Gui/DemoMode.cpp +++ b/src/Gui/DemoMode.cpp @@ -140,7 +140,7 @@ float DemoMode::getSpeed(int v) const SbVec3f DemoMode::getDirection(Gui::View3DInventor* view) const { SoCamera* cam = view->getViewer()->getSoRenderManager()->getCamera(); - if (!cam) + if (!cam) return this->viewAxis; SbRotation rot = cam->orientation.getValue(); SbRotation inv = rot.inverse(); @@ -157,9 +157,9 @@ void DemoMode::on_angleSlider_valueChanged(int v) Gui::View3DInventor* view = activeView(); if (view) { SoCamera* cam = view->getViewer()->getSoRenderManager()->getCamera(); - if (!cam) + if (!cam) return; - float angle = Base::toRadians(/*90-v*/v - this->oldvalue); + auto angle = Base::toRadians(/*90-v*/v - this->oldvalue); SbRotation rot(SbVec3f(-1, 0, 0), angle); reorientCamera(cam ,rot); this->oldvalue = v; diff --git a/src/Gui/DlgActionsImp.cpp b/src/Gui/DlgActionsImp.cpp index d531f0608c..2621398440 100644 --- a/src/Gui/DlgActionsImp.cpp +++ b/src/Gui/DlgActionsImp.cpp @@ -143,15 +143,15 @@ void DlgCustomActionsImp::showActions() { CommandManager& rclMan = Application::Instance->commandManager(); std::vector aclCurMacros = rclMan.getGroupCommands("Macros"); - for (std::vector::iterator it = aclCurMacros.begin(); it != aclCurMacros.end(); ++it) + for (const auto & aclCurMacro : aclCurMacros) { - QTreeWidgetItem* item = new QTreeWidgetItem(ui->actionListWidget); - QByteArray actionName = (*it)->getName(); + auto item = new QTreeWidgetItem(ui->actionListWidget); + QByteArray actionName = aclCurMacro->getName(); item->setData(1, Qt::UserRole, actionName); - item->setText(1, QString::fromUtf8((*it)->getMenuText())); + item->setText(1, QString::fromUtf8(aclCurMacro->getMenuText())); item->setSizeHint(0, QSize(32, 32)); - if ( (*it)->getPixmap() ) - item->setIcon(0, BitmapFactory().pixmap((*it)->getPixmap())); + if ( aclCurMacro->getPixmap() ) + item->setIcon(0, BitmapFactory().pixmap(aclCurMacro->getPixmap())); } } @@ -164,7 +164,7 @@ void DlgCustomActionsImp::on_actionListWidget_itemActivated(QTreeWidgetItem *ite QByteArray actionName = item->data(1, Qt::UserRole).toByteArray(); CommandManager& rclMan = Application::Instance->commandManager(); Command* pCmd = rclMan.getCommandByName(actionName.constData()); - MacroCommand* pScript = dynamic_cast(pCmd); + auto pScript = dynamic_cast(pCmd); // if valid command if ( pScript ) @@ -222,11 +222,11 @@ void DlgCustomActionsImp::on_buttonAddAction_clicked() // search for the command in the manager CommandManager& rclMan = Application::Instance->commandManager(); QByteArray actionName = QString::fromStdString(rclMan.newMacroName()).toLatin1(); - MacroCommand* macro = new MacroCommand(actionName, ui->actionMacros->itemData(ui->actionMacros->currentIndex()).toBool()); + auto macro = new MacroCommand(actionName, ui->actionMacros->itemData(ui->actionMacros->currentIndex()).toBool()); rclMan.addCommand( macro ); // add new action - QTreeWidgetItem* item = new QTreeWidgetItem(ui->actionListWidget); + auto item = new QTreeWidgetItem(ui->actionListWidget); item->setData(1, Qt::UserRole, actionName); item->setText(1, ui->actionMenu->text()); item->setSizeHint(0, QSize(32, 32)); @@ -291,7 +291,7 @@ void DlgCustomActionsImp::on_buttonReplaceAction_clicked() item->setText(1, ui->actionMenu->text()); CommandManager& rclMan = Application::Instance->commandManager(); Command* pCmd = rclMan.getCommandByName(actionName.constData()); - MacroCommand* macro = dynamic_cast(pCmd); + auto macro = dynamic_cast(pCmd); if (!macro) return; @@ -373,14 +373,14 @@ void DlgCustomActionsImp::on_buttonRemoveAction_clicked() // if the command is registered in the manager just remove it CommandManager& rclMan = Application::Instance->commandManager(); std::vector aclCurMacros = rclMan.getGroupCommands("Macros"); - for (std::vector::iterator it2 = aclCurMacros.begin(); it2!= aclCurMacros.end(); ++it2) + for (auto & aclCurMacro : aclCurMacros) { - if (actionName == (*it2)->getName()) + if (actionName == aclCurMacro->getName()) { // emit signal to notify the container widget Q_EMIT removeMacroAction(actionName); // remove from manager and delete it immediately - rclMan.removeCommand(*it2); + rclMan.removeCommand(aclCurMacro); break; } } @@ -399,12 +399,12 @@ IconDialog::IconDialog(QWidget* parent) QListWidgetItem* item; QStringList names = BitmapFactory().findIconFiles(); - for (QStringList::Iterator it = names.begin(); it != names.end(); ++it) { + for (const auto & name : names) { item = new QListWidgetItem(ui->listWidget); //item->setIcon(QIcon(*it)); - item->setIcon(QIcon(BitmapFactory().pixmap((const char*)it->toUtf8()))); - item->setText(QFileInfo(*it).baseName()); - item->setToolTip(*it); + item->setIcon(QIcon(BitmapFactory().pixmap((const char*)name.toUtf8()))); + item->setText(QFileInfo(name).baseName()); + item->setToolTip(name); } } @@ -430,8 +430,8 @@ void IconDialog::onAddIconPath() ("User parameter:BaseApp/Preferences/Bitmaps"); std::vector paths = group->GetASCIIs("CustomPath"); QStringList pathList; - for (std::vector::iterator it = paths.begin(); it != paths.end(); ++it) - pathList << QString::fromUtf8(it->c_str()); + for (const auto & path : paths) + pathList << QString::fromUtf8(path.c_str()); IconFolders dlg(pathList, this); dlg.setWindowTitle(tr("Icon folders")); @@ -448,28 +448,27 @@ void IconDialog::onAddIconPath() } QStringList search = BitmapFactory().getPaths(); - for (QStringList::iterator it = search.begin(); it != search.end(); ++it) { - *it = QDir::toNativeSeparators(*it); + for (auto & it : search) { + it = QDir::toNativeSeparators(it); } - for (QStringList::iterator it = paths.begin(); it != paths.end(); ++it) { - if (search.indexOf(*it) < 0) { + for (const auto & path : paths) { + if (search.indexOf(path) < 0) { QStringList filters; QList formats = QImageReader::supportedImageFormats(); - for (QList::iterator jt = formats.begin(); jt != formats.end(); ++jt) - filters << QString::fromLatin1("*.%1").arg(QString::fromLatin1(*jt).toLower()); - QDir d(*it); + for (const auto & format : formats) + filters << QString::fromLatin1("*.%1").arg(QString::fromLatin1(format).toLower()); + QDir d(path); d.setNameFilters(filters); QFileInfoList fi = d.entryInfoList(); - for (QFileInfoList::iterator jt = fi.begin(); jt != fi.end(); ++jt) { - QListWidgetItem* item; - QString file = jt->absoluteFilePath(); - item = new QListWidgetItem(ui->listWidget); + for (const auto & jt : fi) { + QString file = jt.absoluteFilePath(); + auto item = new QListWidgetItem(ui->listWidget); item->setIcon(QIcon(file)); - item->setText(jt->baseName()); + item->setText(jt.baseName()); item->setToolTip(file); } - BitmapFactory().addPath(*it); + BitmapFactory().addPath(path); } } } @@ -508,7 +507,7 @@ IconFolders::IconFolders(const QStringList& paths, QWidget* parent) : QDialog(parent), restart(false), maxLines(10) { resize(600,400); - QDialogButtonBox* buttonBox = new QDialogButtonBox(this); + auto buttonBox = new QDialogButtonBox(this); buttonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept())); @@ -516,10 +515,10 @@ IconFolders::IconFolders(const QStringList& paths, QWidget* parent) this, SLOT(reject())); gridLayout = new QGridLayout(); - QGridLayout* mainLayout = new QGridLayout(this); + auto mainLayout = new QGridLayout(this); mainLayout->addLayout(gridLayout, 0, 0, 1, 1); - QSpacerItem* verticalSpacer = new QSpacerItem(20, 108, QSizePolicy::Minimum, QSizePolicy::Expanding); + auto verticalSpacer = new QSpacerItem(20, 108, QSizePolicy::Minimum, QSizePolicy::Expanding); mainLayout->addItem(verticalSpacer, 1, 0, 1, 1); mainLayout->addWidget(buttonBox, 2, 0, 1, 1); @@ -527,10 +526,10 @@ IconFolders::IconFolders(const QStringList& paths, QWidget* parent) int numPaths = static_cast(paths.size()); int maxRow = this->maxLines; for (int row=0; rowsetReadOnly(true); gridLayout->addWidget(edit, row, 0, 1, 1); - QPushButton* removeButton = new QPushButton(this); + auto removeButton = new QPushButton(this); removeButton->setIcon(BitmapFactory().iconFromTheme("list-remove")); gridLayout->addWidget(removeButton, row, 1, 1, 1); @@ -567,22 +566,22 @@ void IconFolders::addFolder() { int countHidden = -1; QStringList paths; - for (QList< QPair >::iterator it = buttonMap.begin(); it != buttonMap.end(); ++it) { - if (it->first->isHidden()) { + for (const auto & it : buttonMap) { + if (it.first->isHidden()) { countHidden++; if (countHidden == 0) { QString dir = QFileDialog::getExistingDirectory(this, IconDialog::tr("Add icon folder"), QString()); if (!dir.isEmpty() && paths.indexOf(dir) < 0) { - QLineEdit* edit = it->first; + QLineEdit* edit = it.first; edit->setVisible(true); edit->setText(dir); - QPushButton* removeButton = it->second; + QPushButton* removeButton = it.second; removeButton->setVisible(true); } } } else { - paths << QDir::toNativeSeparators(it->first->text()); + paths << QDir::toNativeSeparators(it.first->text()); } } @@ -600,19 +599,19 @@ void IconFolders::removeFolder() } addButton->setEnabled(true); - QPushButton* remove = static_cast(sender()); + auto remove = static_cast(sender()); QLineEdit* edit = nullptr; - for (QList< QPair >::iterator it = buttonMap.begin(); it != buttonMap.end(); ++it) { - if (it->second == remove) { - edit = it->first; + for (const auto & it : buttonMap) { + if (it.second == remove) { + edit = it.first; } else if (edit) { // move up the text of the line edits - edit->setText(it->first->text()); + edit->setText(it.first->text()); - if (it->first->isVisible()) { - edit = it->first; - remove = it->second; + if (it.first->isVisible()) { + edit = it.first; + remove = it.second; } else { edit->hide(); @@ -626,9 +625,9 @@ void IconFolders::removeFolder() QStringList IconFolders::getPaths() const { QStringList paths; - for (QList< QPair >::const_iterator it = buttonMap.begin(); it != buttonMap.end(); ++it) { - if (!it->first->isHidden()) { - paths << QDir::toNativeSeparators(it->first->text()); + for (const auto & it : buttonMap) { + if (!it.first->isHidden()) { + paths << QDir::toNativeSeparators(it.first->text()); } else { break; diff --git a/src/Gui/DlgActivateWindowImp.cpp b/src/Gui/DlgActivateWindowImp.cpp index f42b39bcda..ded4999f32 100644 --- a/src/Gui/DlgActivateWindowImp.cpp +++ b/src/Gui/DlgActivateWindowImp.cpp @@ -64,7 +64,7 @@ DlgActivateWindowImp::DlgActivateWindowImp(QWidget* parent, Qt::WindowFlags fl) QWidget* activeWnd = getMainWindow()->activeWindow(); for (QList::Iterator it = windows.begin(); it != windows.end(); ++it) { - QTreeWidgetItem* item = new QTreeWidgetItem(ui->treeWidget); + auto item = new QTreeWidgetItem(ui->treeWidget); QString title = (*it)->windowTitle(); title.replace(QLatin1String("[*]"), QLatin1String("")); if ((*it)->isWindowModified()) diff --git a/src/Gui/DlgCheckableMessageBox.cpp b/src/Gui/DlgCheckableMessageBox.cpp index 44a992b847..7cca4e6946 100644 --- a/src/Gui/DlgCheckableMessageBox.cpp +++ b/src/Gui/DlgCheckableMessageBox.cpp @@ -53,7 +53,7 @@ void DlgCheckableMessageBox::showMessage(const QString& header, const QString& m bool checked = App::GetApplication().GetParameterGroupByPath(QByteArray("User parameter:BaseApp/CheckMessages"))->GetBool(toParamEntry(header)); if (!checked) { - DlgCheckableMessageBox *mb = new DlgCheckableMessageBox(Gui::getMainWindow()); + auto mb = new DlgCheckableMessageBox(Gui::getMainWindow()); mb->setWindowTitle(header); mb->setIconPixmap(QMessageBox::standardIcon(QMessageBox::Warning)); mb->setText(message); @@ -200,7 +200,7 @@ void DlgCheckableMessageBox::setStandardButtons(QDialogButtonBox::StandardButton QDialogButtonBox::StandardButton DlgCheckableMessageBox::defaultButton() const { Q_FOREACH (QAbstractButton *b, m_d->ui.buttonBox->buttons()) - if (QPushButton *pb = qobject_cast(b)) + if (auto pb = qobject_cast(b)) if (pb->isDefault()) return m_d->ui.buttonBox->standardButton(pb); return QDialogButtonBox::NoButton; diff --git a/src/Gui/DlgCommandsImp.cpp b/src/Gui/DlgCommandsImp.cpp index 61d5f3e2c4..9df306a0eb 100644 --- a/src/Gui/DlgCommandsImp.cpp +++ b/src/Gui/DlgCommandsImp.cpp @@ -91,9 +91,9 @@ DlgCustomCommandsImp::DlgCustomCommandsImp( QWidget* parent ) groupMap.push_back(std::make_pair(QLatin1String("Help"), QString())); groupMap.push_back(std::make_pair(QLatin1String("Macros"), qApp->translate("Gui::MacroCommand", "Macros"))); - for (std::map::iterator it = sCommands.begin(); it != sCommands.end(); ++it) { - QLatin1String group(it->second->getGroupName()); - QString text = it->second->translatedGroupName(); + for (const auto & sCommand : sCommands) { + QLatin1String group(sCommand.second->getGroupName()); + QString text = sCommand.second->translatedGroupName(); GroupMap::iterator jt; jt = std::find_if(groupMap.begin(), groupMap.end(), GroupMap_find(group)); if (jt != groupMap.end()) { @@ -107,10 +107,10 @@ DlgCustomCommandsImp::DlgCustomCommandsImp( QWidget* parent ) QStringList labels; labels << tr("Category"); ui->categoryTreeWidget->setHeaderLabels(labels); - for (GroupMap::iterator it = groupMap.begin(); it != groupMap.end(); ++it) { - QTreeWidgetItem* item = new QTreeWidgetItem(ui->categoryTreeWidget); - item->setText(0, it->second); - item->setData(0, Qt::UserRole, QVariant(it->first)); + for (const auto & it : groupMap) { + auto item = new QTreeWidgetItem(ui->categoryTreeWidget); + item->setText(0, it.second); + item->setData(0, Qt::UserRole, QVariant(it.first)); } labels.clear(); @@ -150,25 +150,25 @@ void DlgCustomCommandsImp::onGroupActivated(QTreeWidgetItem* groupItem) CommandManager & cCmdMgr = Application::Instance->commandManager(); std::vector aCmds = cCmdMgr.getGroupCommands(group.toLatin1()); if (group == QLatin1String("Macros")) { - for (std::vector::iterator it = aCmds.begin(); it != aCmds.end(); ++it) { - QTreeWidgetItem* item = new QTreeWidgetItem(ui->commandTreeWidget); - item->setText(1, QString::fromUtf8((*it)->getMenuText())); - item->setToolTip(1, QString::fromUtf8((*it)->getToolTipText())); - item->setData(1, Qt::UserRole, QByteArray((*it)->getName())); + for (const auto & aCmd : aCmds) { + auto item = new QTreeWidgetItem(ui->commandTreeWidget); + item->setText(1, QString::fromUtf8(aCmd->getMenuText())); + item->setToolTip(1, QString::fromUtf8(aCmd->getToolTipText())); + item->setData(1, Qt::UserRole, QByteArray(aCmd->getName())); item->setSizeHint(0, QSize(32, 32)); - if ((*it)->getPixmap()) - item->setIcon(0, BitmapFactory().iconFromTheme((*it)->getPixmap())); + if (aCmd->getPixmap()) + item->setIcon(0, BitmapFactory().iconFromTheme(aCmd->getPixmap())); } } else { - for (std::vector::iterator it = aCmds.begin(); it != aCmds.end(); ++it) { - QTreeWidgetItem* item = new QTreeWidgetItem(ui->commandTreeWidget); - item->setText(1, qApp->translate((*it)->className(), (*it)->getMenuText())); - item->setToolTip(1, qApp->translate((*it)->className(), (*it)->getToolTipText())); - item->setData(1, Qt::UserRole, QByteArray((*it)->getName())); + for (const auto & aCmd : aCmds) { + auto item = new QTreeWidgetItem(ui->commandTreeWidget); + item->setText(1, qApp->translate(aCmd->className(), aCmd->getMenuText())); + item->setToolTip(1, qApp->translate(aCmd->className(), aCmd->getToolTipText())); + item->setData(1, Qt::UserRole, QByteArray(aCmd->getName())); item->setSizeHint(0, QSize(32, 32)); - if ((*it)->getPixmap()) - item->setIcon(0, BitmapFactory().iconFromTheme((*it)->getPixmap())); + if (aCmd->getPixmap()) + item->setIcon(0, BitmapFactory().iconFromTheme(aCmd->getPixmap())); } } @@ -188,7 +188,7 @@ void DlgCustomCommandsImp::onAddMacroAction(const QByteArray& macro) CommandManager & cCmdMgr = Application::Instance->commandManager(); Command* pCmd = cCmdMgr.getCommandByName(macro); - QTreeWidgetItem* item = new QTreeWidgetItem(ui->commandTreeWidget); + auto item = new QTreeWidgetItem(ui->commandTreeWidget); item->setText(1, QString::fromUtf8(pCmd->getMenuText())); item->setToolTip(1, QString::fromUtf8(pCmd->getToolTipText())); item->setData(1, Qt::UserRole, macro); diff --git a/src/Gui/DlgCustomizeImp.cpp b/src/Gui/DlgCustomizeImp.cpp index c620b275c0..cbe2c6f686 100644 --- a/src/Gui/DlgCustomizeImp.cpp +++ b/src/Gui/DlgCustomizeImp.cpp @@ -69,7 +69,7 @@ DlgCustomizeImp::DlgCustomizeImp(QWidget* parent, Qt::WindowFlags fl) buttonHelp->setText(tr("&Help")); layout->addWidget( buttonHelp ); - QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + auto spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); layout->addItem(spacer); buttonClose = new QPushButton( this ); diff --git a/src/Gui/DlgCustomizeSpNavSettings.cpp b/src/Gui/DlgCustomizeSpNavSettings.cpp index 4c95771317..61994c1cea 100644 --- a/src/Gui/DlgCustomizeSpNavSettings.cpp +++ b/src/Gui/DlgCustomizeSpNavSettings.cpp @@ -35,7 +35,7 @@ DlgCustomizeSpNavSettings::DlgCustomizeSpNavSettings(QWidget *parent) : , ui(new Ui_DlgCustomizeSpNavSettings) , init(false) { - GUIApplicationNativeEventAware *app = qobject_cast(QApplication::instance()); + auto app = qobject_cast(QApplication::instance()); if (!app) return; @@ -56,9 +56,9 @@ DlgCustomizeSpNavSettings::~DlgCustomizeSpNavSettings() void DlgCustomizeSpNavSettings::setMessage(const QString& message) { - QLabel *messageLabel = new QLabel(message,this); - QVBoxLayout *layout = new QVBoxLayout(); - QHBoxLayout *layout2 = new QHBoxLayout(); + auto messageLabel = new QLabel(message,this); + auto layout = new QVBoxLayout(); + auto layout2 = new QHBoxLayout(); layout2->addStretch(); layout2->addWidget(messageLabel); layout2->addStretch(); diff --git a/src/Gui/DlgCustomizeSpaceball.cpp b/src/Gui/DlgCustomizeSpaceball.cpp index bf184902b0..1af906404a 100644 --- a/src/Gui/DlgCustomizeSpaceball.cpp +++ b/src/Gui/DlgCustomizeSpaceball.cpp @@ -73,7 +73,7 @@ void ButtonView::goSelectionChanged(const QItemSelection &selected, const QItemS void ButtonView::goChangedCommand(const QString& commandName) { QModelIndex index(this->currentIndex()); - ButtonModel *model = dynamic_cast(this->model()); + auto model = dynamic_cast(this->model()); if (model && index.isValid()) model->setCommand(index.row(), commandName); } @@ -252,9 +252,9 @@ void ButtonModel::goButtonPress(int number) void ButtonModel::goMacroRemoved(const QByteArray& macroName) { GroupVector groupVector = spaceballButtonGroup()->GetGroups(); - for (GroupVector::iterator it = groupVector.begin(); it != groupVector.end(); ++it) - if (std::string(macroName.data()) == (*it)->GetASCII("Command")) - (*it)->SetASCII("Command", ""); + for (auto & it : groupVector) + if (std::string(macroName.data()) == it->GetASCII("Command")) + it->SetASCII("Command", ""); } void ButtonModel::goClear() @@ -500,7 +500,7 @@ void CommandModel::goAddMacro(const QByteArray ¯oName) location = groups.size(); //add row this->beginInsertRows(QModelIndex(), location, location); - CommandNode *macroNode = new CommandNode(CommandNode::GroupType); + auto macroNode = new CommandNode(CommandNode::GroupType); macroNode->parent = rootNode; rootNode->children.insert(location, macroNode); this->endInsertRows(); @@ -519,7 +519,7 @@ void CommandModel::goAddMacro(const QByteArray ¯oName) return; this->beginInsertRows(macrosIndex, parentNode->children.size(), parentNode->children.size()); - CommandNode *childNode = new CommandNode(CommandNode::CommandType); + auto childNode = new CommandNode(CommandNode::CommandType); childNode->parent = parentNode; parentNode->children.push_back(childNode); childNode->aCommand = command; @@ -559,22 +559,22 @@ void CommandModel::initialize() { rootNode = new CommandNode(CommandNode::RootType); QStringList groups(orderedGroups()); - for (QStringList::iterator it = groups.begin(); it != groups.end(); ++it) - groupCommands(*it); + for (const auto & group : groups) + groupCommands(group); } void CommandModel::groupCommands(const QString& groupName) { - CommandNode *parentNode = new CommandNode(CommandNode::GroupType); + auto parentNode = new CommandNode(CommandNode::GroupType); parentNode->parent = rootNode; rootNode->children.push_back(parentNode); std::vector commands = Application::Instance->commandManager().getGroupCommands(groupName.toLatin1()); - for (std::vector ::iterator it = commands.begin(); it != commands.end(); ++it) + for (const auto & command : commands) { - CommandNode *childNode = new CommandNode(CommandNode::CommandType); + auto childNode = new CommandNode(CommandNode::CommandType); childNode->parent = parentNode; parentNode->children.push_back(childNode); - childNode->aCommand = *it; + childNode->aCommand = command; } } @@ -582,9 +582,9 @@ QStringList CommandModel::orderedGroups() { QStringList groups; std::vector commands = Application::Instance->commandManager().getAllCommands(); - for (std::vector ::iterator it = commands.begin(); it != commands.end(); ++it) + for (const auto & command : commands) { - QString groupName(QString::fromLatin1((*it)->getGroupName())); + QString groupName(QString::fromLatin1(command->getGroupName())); if (!groups.contains(groupName)) groups << groupName; } @@ -663,7 +663,7 @@ DlgCustomizeSpaceball::DlgCustomizeSpaceball(QWidget *parent) , devModel(nullptr) { this->setWindowTitle(tr("Spaceball Buttons")); - GUIApplicationNativeEventAware *app = qobject_cast(QApplication::instance()); + auto app = qobject_cast(QApplication::instance()); if (!app) return; if (!app->isSpaceballPresent()) @@ -690,9 +690,9 @@ DlgCustomizeSpaceball::~DlgCustomizeSpaceball() void DlgCustomizeSpaceball::setMessage(const QString& message) { - QLabel *messageLabel = new QLabel(message,this); - QVBoxLayout *layout = new QVBoxLayout(); - QHBoxLayout *layout2 = new QHBoxLayout(); + auto messageLabel = new QLabel(message,this); + auto layout = new QVBoxLayout(); + auto layout2 = new QHBoxLayout(); layout2->addStretch(); layout2->addWidget(messageLabel); layout2->addStretch(); @@ -720,7 +720,7 @@ void DlgCustomizeSpaceball::setupCommandModelView() void DlgCustomizeSpaceball::setupLayout() { - QLabel *buttonLabel = new QLabel(tr("Buttons"), this); + auto buttonLabel = new QLabel(tr("Buttons"), this); clearButton = new QPushButton(tr("Reset"), this); devModel = new QComboBox(this); @@ -736,27 +736,27 @@ void DlgCustomizeSpaceball::setupLayout() devModel->setCurrentIndex(0); } - QVBoxLayout *buttonGroup = new QVBoxLayout(); + auto buttonGroup = new QVBoxLayout(); buttonGroup->addWidget(buttonLabel); buttonGroup->addWidget(buttonView); - QHBoxLayout *clearLayout = new QHBoxLayout(); + auto clearLayout = new QHBoxLayout(); clearLayout->addWidget(devModel); clearLayout->addWidget(clearButton); clearLayout->addStretch(); buttonGroup->addLayout(clearLayout); - QSplitter *splitter = new QSplitter(this); - QWidget *leftPane = new QWidget(this); + auto splitter = new QSplitter(this); + auto leftPane = new QWidget(this); leftPane->setLayout(buttonGroup); splitter->addWidget(leftPane); splitter->addWidget(commandView); printReference = new QPushButton(tr("Print Reference"), this); - QHBoxLayout *printLayout = new QHBoxLayout(); + auto printLayout = new QHBoxLayout(); printLayout->addStretch(); printLayout->addWidget(printReference); - QVBoxLayout *layout = new QVBoxLayout(); + auto layout = new QVBoxLayout(); layout->addWidget(splitter); layout->addLayout(printLayout); @@ -783,8 +783,8 @@ void DlgCustomizeSpaceball::goClear() void DlgCustomizeSpaceball::goPrint() { - QTableView *view = new QTableView(this); - PrintModel *model = new PrintModel(this, buttonModel, commandModel); + auto view = new QTableView(this); + auto model = new PrintModel(this, buttonModel, commandModel); view->horizontalHeader()->setSectionResizeMode(QHeaderView::Fixed); view->setModel(model); view->horizontalHeader()->resizeSection(0, 150); @@ -804,7 +804,7 @@ bool DlgCustomizeSpaceball::event(QEvent *event) { if (event->type() != Spaceball::ButtonEvent::ButtonEventType) return CustomizeActionPage::event(event); - Spaceball::ButtonEvent *buttonEvent = dynamic_cast(event); + auto buttonEvent = dynamic_cast(event); if (!buttonEvent) return true; buttonEvent->setHandled(true); diff --git a/src/Gui/DlgDisplayPropertiesImp.cpp b/src/Gui/DlgDisplayPropertiesImp.cpp index 783aa91132..17f4c7dae4 100644 --- a/src/Gui/DlgDisplayPropertiesImp.cpp +++ b/src/Gui/DlgDisplayPropertiesImp.cpp @@ -158,8 +158,9 @@ void DlgDisplayPropertiesImp::slotChangedObject(const Gui::ViewProvider& obj, // This method gets called if a property of any view provider is changed. // We pick out all the properties for which we need to update this dialog. std::vector Provider = getSelection(); - std::vector::const_iterator vp = std::find_if - (Provider.begin(), Provider.end(), [&obj](Gui::ViewProvider* v) { return v == &obj; }); + auto vp = std::find_if(Provider.begin(), + Provider.end(), + [&obj](Gui::ViewProvider* v) { return v == &obj; }); if (vp != Provider.end()) { const char* name = obj.getPropertyName(&prop); @@ -273,10 +274,10 @@ void DlgDisplayPropertiesImp::on_changeMaterial_activated(int index) (int)(diffuseColor.g*255.0f), (int)(diffuseColor.b*255.0f))); - for (std::vector::iterator It= Provider.begin();It!=Provider.end();++It) { + for (auto It= Provider.begin(); It != Provider.end(); ++It) { App::Property* prop = (*It)->getPropertyByName("ShapeMaterial"); if (prop && prop->getTypeId() == App::PropertyMaterial::getClassTypeId()) { - App::PropertyMaterial* ShapeMaterial = (App::PropertyMaterial*)prop; + auto ShapeMaterial = (App::PropertyMaterial*)prop; ShapeMaterial->setValue(mat); } } @@ -289,10 +290,10 @@ void DlgDisplayPropertiesImp::on_changeMode_activated(const QString& s) { Gui::WaitCursor wc; std::vector Provider = getSelection(); - for (std::vector::iterator It= Provider.begin();It!=Provider.end();++It) { + for (auto It= Provider.begin();It!=Provider.end();++It) { App::Property* prop = (*It)->getPropertyByName("DisplayMode"); if (prop && prop->getTypeId() == App::PropertyEnumeration::getClassTypeId()) { - App::PropertyEnumeration* Display = (App::PropertyEnumeration*)prop; + auto Display = (App::PropertyEnumeration*)prop; Display->setValue((const char*)s.toLatin1()); } } @@ -311,10 +312,10 @@ void DlgDisplayPropertiesImp::on_buttonColor_changed() std::vector Provider = getSelection(); QColor s = d->ui.buttonColor->color(); App::Color c(s.red()/255.0,s.green()/255.0,s.blue()/255.0); - for (std::vector::iterator It= Provider.begin();It!=Provider.end();++It) { + for (auto It= Provider.begin();It!=Provider.end();++It) { App::Property* prop = (*It)->getPropertyByName("ShapeColor"); if (prop && prop->getTypeId() == App::PropertyColor::getClassTypeId()) { - App::PropertyColor* ShapeColor = (App::PropertyColor*)prop; + auto ShapeColor = (App::PropertyColor*)prop; ShapeColor->setValue(c); } } @@ -326,10 +327,10 @@ void DlgDisplayPropertiesImp::on_buttonColor_changed() void DlgDisplayPropertiesImp::on_spinTransparency_valueChanged(int transparency) { std::vector Provider = getSelection(); - for (std::vector::iterator It= Provider.begin();It!=Provider.end();++It) { + for (auto It= Provider.begin();It!=Provider.end();++It) { App::Property* prop = (*It)->getPropertyByName("Transparency"); if (prop && prop->getTypeId().isDerivedFrom(App::PropertyInteger::getClassTypeId())) { - App::PropertyInteger* Transparency = (App::PropertyInteger*)prop; + auto Transparency = (App::PropertyInteger*)prop; Transparency->setValue(transparency); } } @@ -341,10 +342,10 @@ void DlgDisplayPropertiesImp::on_spinTransparency_valueChanged(int transparency) void DlgDisplayPropertiesImp::on_spinPointSize_valueChanged(int pointsize) { std::vector Provider = getSelection(); - for (std::vector::iterator It= Provider.begin();It!=Provider.end();++It) { - App::Property* prop = (*It)->getPropertyByName("PointSize"); + for (const auto & It : Provider) { + App::Property* prop = It->getPropertyByName("PointSize"); if (prop && prop->getTypeId().isDerivedFrom(App::PropertyFloat::getClassTypeId())) { - App::PropertyFloat* PointSize = (App::PropertyFloat*)prop; + auto PointSize = (App::PropertyFloat*)prop; PointSize->setValue((double)pointsize); } } @@ -356,10 +357,10 @@ void DlgDisplayPropertiesImp::on_spinPointSize_valueChanged(int pointsize) void DlgDisplayPropertiesImp::on_spinLineWidth_valueChanged(int linewidth) { std::vector Provider = getSelection(); - for (std::vector::iterator It= Provider.begin();It!=Provider.end();++It) { - App::Property* prop = (*It)->getPropertyByName("LineWidth"); + for (const auto & It : Provider) { + App::Property* prop = It->getPropertyByName("LineWidth"); if (prop && prop->getTypeId().isDerivedFrom(App::PropertyFloat::getClassTypeId())) { - App::PropertyFloat* LineWidth = (App::PropertyFloat*)prop; + auto LineWidth = (App::PropertyFloat*)prop; LineWidth->setValue((double)linewidth); } } @@ -370,10 +371,10 @@ void DlgDisplayPropertiesImp::on_buttonLineColor_changed() std::vector Provider = getSelection(); QColor s = d->ui.buttonLineColor->color(); App::Color c(s.red()/255.0,s.green()/255.0,s.blue()/255.0); - for (std::vector::iterator It= Provider.begin();It!=Provider.end();++It) { - App::Property* prop = (*It)->getPropertyByName("LineColor"); + for (const auto & It : Provider) { + App::Property* prop = It->getPropertyByName("LineColor"); if (prop && prop->getTypeId() == App::PropertyColor::getClassTypeId()) { - App::PropertyColor* ShapeColor = (App::PropertyColor*)prop; + auto ShapeColor = (App::PropertyColor*)prop; ShapeColor->setValue(c); } } @@ -382,10 +383,10 @@ void DlgDisplayPropertiesImp::on_buttonLineColor_changed() void DlgDisplayPropertiesImp::on_spinLineTransparency_valueChanged(int transparency) { std::vector Provider = getSelection(); - for (std::vector::iterator It= Provider.begin();It!=Provider.end();++It) { - App::Property* prop = (*It)->getPropertyByName("LineTransparency"); + for (const auto & It : Provider) { + App::Property* prop = It->getPropertyByName("LineTransparency"); if (prop && prop->getTypeId().isDerivedFrom(App::PropertyInteger::getClassTypeId())) { - App::PropertyInteger* Transparency = (App::PropertyInteger*)prop; + auto Transparency = (App::PropertyInteger*)prop; Transparency->setValue(transparency); } } @@ -394,21 +395,21 @@ void DlgDisplayPropertiesImp::on_spinLineTransparency_valueChanged(int transpare void DlgDisplayPropertiesImp::setDisplayModes(const std::vector& views) { QStringList commonModes, modes; - for (std::vector::const_iterator it = views.begin(); it != views.end(); ++it) { + for (auto it = views.begin(); it != views.end(); ++it) { App::Property* prop = (*it)->getPropertyByName("DisplayMode"); if (prop && prop->getTypeId() == App::PropertyEnumeration::getClassTypeId()) { - App::PropertyEnumeration* display = static_cast(prop); + auto display = static_cast(prop); if (!display->hasEnums()) return; std::vector value = display->getEnumVector(); if (it == views.begin()) { - for (std::vector::const_iterator jt = value.begin(); jt != value.end(); ++jt) - commonModes << QLatin1String(jt->c_str()); + for (const auto & jt : value) + commonModes << QLatin1String(jt.c_str()); } else { - for (std::vector::const_iterator jt = value.begin(); jt != value.end(); ++jt) { - if (commonModes.contains(QLatin1String(jt->c_str()))) - modes << QLatin1String(jt->c_str()); + for (const auto & jt : value) { + if (commonModes.contains(QLatin1String(jt.c_str()))) + modes << QLatin1String(jt.c_str()); } commonModes = modes; @@ -422,10 +423,10 @@ void DlgDisplayPropertiesImp::setDisplayModes(const std::vectorui.changeMode->setDisabled(commonModes.isEmpty()); // find the display mode to activate - for (std::vector::const_iterator it = views.begin(); it != views.end(); ++it) { - App::Property* prop = (*it)->getPropertyByName("DisplayMode"); + for (const auto & view : views) { + App::Property* prop = view->getPropertyByName("DisplayMode"); if (prop && prop->getTypeId() == App::PropertyEnumeration::getClassTypeId()) { - App::PropertyEnumeration* display = static_cast(prop); + auto display = static_cast(prop); QString activeMode = QString::fromLatin1(display->getValueAsString()); int index = d->ui.changeMode->findText(activeMode); if (index != -1) { @@ -440,8 +441,8 @@ void DlgDisplayPropertiesImp::setMaterial(const std::vector& { bool material = false; App::Material::MaterialType matType = App::Material::DEFAULT; - for (std::vector::const_iterator it = views.begin(); it != views.end(); ++it) { - App::Property* prop = (*it)->getPropertyByName("ShapeMaterial"); + for (const auto & view : views) { + App::Property* prop = view->getPropertyByName("ShapeMaterial"); if (prop && prop->getTypeId() == App::PropertyMaterial::getClassTypeId()) { material = true; matType = static_cast(prop)->getValue().getType(); @@ -460,8 +461,8 @@ void DlgDisplayPropertiesImp::setMaterial(const std::vector& void DlgDisplayPropertiesImp::setColorPlot(const std::vector& views) { bool material = false; - for (std::vector::const_iterator it = views.begin(); it != views.end(); ++it) { - App::Property* prop = (*it)->getPropertyByName("TextureMaterial"); + for (const auto & view : views) { + App::Property* prop = view->getPropertyByName("TextureMaterial"); if (prop && prop->getTypeId() == App::PropertyMaterial::getClassTypeId()) { material = true; break; @@ -500,8 +501,8 @@ void DlgDisplayPropertiesImp::fillupMaterials() void DlgDisplayPropertiesImp::setShapeColor(const std::vector& views) { bool shapeColor = false; - for (std::vector::const_iterator it = views.begin(); it != views.end(); ++it) { - App::Property* prop = (*it)->getPropertyByName("ShapeColor"); + for (const auto & view : views) { + App::Property* prop = view->getPropertyByName("ShapeColor"); if (prop && prop->getTypeId() == App::PropertyColor::getClassTypeId()) { App::Color c = static_cast(prop)->getValue(); QColor shape; @@ -520,8 +521,8 @@ void DlgDisplayPropertiesImp::setShapeColor(const std::vector& views) { bool shapeColor = false; - for (std::vector::const_iterator it = views.begin(); it != views.end(); ++it) { - App::Property* prop = (*it)->getPropertyByName("LineColor"); + for (const auto & view : views) { + App::Property* prop = view->getPropertyByName("LineColor"); if (prop && prop->getTypeId() == App::PropertyColor::getClassTypeId()) { App::Color c = static_cast(prop)->getValue(); QColor shape; @@ -540,8 +541,8 @@ void DlgDisplayPropertiesImp::setLineColor(const std::vector void DlgDisplayPropertiesImp::setPointSize(const std::vector& views) { bool pointSize = false; - for (std::vector::const_iterator it = views.begin(); it != views.end(); ++it) { - App::Property* prop = (*it)->getPropertyByName("PointSize"); + for (const auto & view : views) { + App::Property* prop = view->getPropertyByName("PointSize"); if (prop && prop->getTypeId().isDerivedFrom(App::PropertyFloat::getClassTypeId())) { bool blocked = d->ui.spinPointSize->blockSignals(true); d->ui.spinPointSize->setValue((int)static_cast(prop)->getValue()); @@ -557,8 +558,8 @@ void DlgDisplayPropertiesImp::setPointSize(const std::vector void DlgDisplayPropertiesImp::setLineWidth(const std::vector& views) { bool lineWidth = false; - for (std::vector::const_iterator it = views.begin(); it != views.end(); ++it) { - App::Property* prop = (*it)->getPropertyByName("LineWidth"); + for (const auto & view : views) { + App::Property* prop = view->getPropertyByName("LineWidth"); if (prop && prop->getTypeId().isDerivedFrom(App::PropertyFloat::getClassTypeId())) { bool blocked = d->ui.spinLineWidth->blockSignals(true); d->ui.spinLineWidth->setValue((int)static_cast(prop)->getValue()); @@ -574,8 +575,8 @@ void DlgDisplayPropertiesImp::setLineWidth(const std::vector void DlgDisplayPropertiesImp::setTransparency(const std::vector& views) { bool transparency = false; - for (std::vector::const_iterator it = views.begin(); it != views.end(); ++it) { - App::Property* prop = (*it)->getPropertyByName("Transparency"); + for (const auto & view : views) { + App::Property* prop = view->getPropertyByName("Transparency"); if (prop && prop->getTypeId().isDerivedFrom(App::PropertyInteger::getClassTypeId())) { bool blocked = d->ui.spinTransparency->blockSignals(true); d->ui.spinTransparency->setValue(static_cast(prop)->getValue()); @@ -596,8 +597,8 @@ void DlgDisplayPropertiesImp::setTransparency(const std::vector& views) { bool transparency = false; - for (std::vector::const_iterator it = views.begin(); it != views.end(); ++it) { - App::Property* prop = (*it)->getPropertyByName("LineTransparency"); + for (const auto & view : views) { + App::Property* prop = view->getPropertyByName("LineTransparency"); if (prop && prop->getTypeId().isDerivedFrom(App::PropertyInteger::getClassTypeId())) { bool blocked = d->ui.spinLineTransparency->blockSignals(true); d->ui.spinLineTransparency->setValue(static_cast(prop)->getValue()); @@ -621,8 +622,8 @@ std::vector DlgDisplayPropertiesImp::getSelection() const // get the complete selection std::vector sel = Selection().getCompleteSelection(); - for (std::vector::iterator it = sel.begin(); it != sel.end(); ++it) { - Gui::ViewProvider* view = Application::Instance->getDocument(it->pDoc)->getViewProvider(it->pObject); + for (const auto & it : sel) { + Gui::ViewProvider* view = Application::Instance->getDocument(it.pDoc)->getViewProvider(it.pObject); views.push_back(view); } diff --git a/src/Gui/DlgEditorImp.cpp b/src/Gui/DlgEditorImp.cpp index 79d79f48c1..f9f29e02ba 100644 --- a/src/Gui/DlgEditorImp.cpp +++ b/src/Gui/DlgEditorImp.cpp @@ -133,7 +133,7 @@ DlgSettingsEditorImp::DlgSettingsEditorImp( QWidget* parent ) ui->displayItems->setHeaderLabels(labels); ui->displayItems->header()->hide(); for (QVector >::Iterator it = d->colormap.begin(); it != d->colormap.end(); ++it) { - QTreeWidgetItem* item = new QTreeWidgetItem(ui->displayItems); + auto item = new QTreeWidgetItem(ui->displayItems); item->setText(0, tr((*it).first.toLatin1())); } pythonSyntax = new PythonSyntaxHighlighter(ui->textEdit1); @@ -194,7 +194,7 @@ void DlgSettingsEditorImp::saveSettings() // Saves the color map ParameterGrp::handle hGrp = WindowParameter::getDefaultParameter()->GetGroup("Editor"); for (QVector >::Iterator it = d->colormap.begin(); it != d->colormap.end(); ++it) { - unsigned long col = static_cast((*it).second); + auto col = static_cast((*it).second); hGrp->SetUnsigned((*it).first.toLatin1(), col); } @@ -232,7 +232,7 @@ void DlgSettingsEditorImp::loadSettings() // Restores the color map ParameterGrp::handle hGrp = WindowParameter::getDefaultParameter()->GetGroup("Editor"); for (QVector >::Iterator it = d->colormap.begin(); it != d->colormap.end(); ++it){ - unsigned long col = static_cast((*it).second); + auto col = static_cast((*it).second); col = hGrp->GetUnsigned((*it).first.toLatin1(), col); (*it).second = static_cast(col); QColor color; diff --git a/src/Gui/DlgExpressionInput.cpp b/src/Gui/DlgExpressionInput.cpp index e342ad7022..76658d645d 100644 --- a/src/Gui/DlgExpressionInput.cpp +++ b/src/Gui/DlgExpressionInput.cpp @@ -156,7 +156,7 @@ void DlgExpressionInput::textChanged(const QString &text) //set default palette as we may have read text right now ui->msg->setPalette(ui->okBtn->palette()); - NumberExpression * n = Base::freecad_dynamic_cast(result.get()); + auto * n = Base::freecad_dynamic_cast(result.get()); if (n) { Base::Quantity value = n->getQuantity(); QString msg = value.getUserString(); @@ -252,7 +252,7 @@ bool DlgExpressionInput::eventFilter(QObject *obj, QEvent *ev) // cursor is on this or an underlying widget or outside. if (!underMouse()) { // if the expression fields context-menu is open do not close the dialog - QMenu* menu = qobject_cast(obj); + auto menu = qobject_cast(obj); if (menu && menu->parentWidget() == ui->expression) { return false; } diff --git a/src/Gui/DlgGeneralImp.cpp b/src/Gui/DlgGeneralImp.cpp index 174f7300c0..18b5f54bb0 100644 --- a/src/Gui/DlgGeneralImp.cpp +++ b/src/Gui/DlgGeneralImp.cpp @@ -62,9 +62,9 @@ DlgGeneralImp::DlgGeneralImp( QWidget* parent ) // sorted by their menu text QStringList work = Application::Instance->workbenches(); QMap menuText; - for (QStringList::Iterator it = work.begin(); it != work.end(); ++it) { - QString text = Application::Instance->workbenchMenuText(*it); - menuText[text] = *it; + for (const auto & it : work) { + QString text = Application::Instance->workbenchMenuText(it); + menuText[text] = it; } { // add special workbench to selection @@ -113,7 +113,8 @@ DlgGeneralImp::~DlgGeneralImp() */ void DlgGeneralImp::setRecentFileSize() { - RecentFilesAction *recent = getMainWindow()->findChild(QLatin1String("recentFiles")); + auto recent = getMainWindow()->findChild + (QLatin1String("recentFiles")); if (recent) { ParameterGrp::handle hGrp = WindowParameter::getDefaultParameter()->GetGroup("RecentFiles"); recent->resizeList(hGrp->GetInt("RecentFiles", 4)); @@ -236,7 +237,7 @@ void DlgGeneralImp::loadSettings() TStringMap list = Translator::instance()->supportedLocales(); ui->Languages->clear(); ui->Languages->addItem(QString::fromLatin1("English"), QByteArray("English")); - for (TStringMap::iterator it = list.begin(); it != list.end(); ++it, index++) { + for (auto it = list.begin(); it != list.end(); ++it, index++) { QByteArray lang = it->first.c_str(); QString langname = QString::fromLatin1(lang.constData()); @@ -300,12 +301,12 @@ void DlgGeneralImp::loadSettings() // read from user, resource and built-in directory QStringList qssPaths = QDir::searchPaths(QString::fromLatin1("qss")); - for (QStringList::iterator it = qssPaths.begin(); it != qssPaths.end(); ++it) { - dir.setPath(*it); + for (const auto & qssPath : qssPaths) { + dir.setPath(qssPath); fileNames = dir.entryInfoList(filter, QDir::Files, QDir::Name); - for (QFileInfoList::iterator jt = fileNames.begin(); jt != fileNames.end(); ++jt) { - if (cssFiles.find(jt->baseName()) == cssFiles.end()) { - cssFiles[jt->baseName()] = jt->fileName(); + for (const auto & fileName : fileNames) { + if (cssFiles.find(fileName.baseName()) == cssFiles.end()) { + cssFiles[fileName.baseName()] = fileName.fileName(); } } } @@ -389,7 +390,7 @@ void DlgGeneralImp::recreatePreferencePackMenu() else tagString.append(QStringLiteral(", ") + QString::fromStdString(tag)); } - QTableWidgetItem* kind = new QTableWidgetItem(tagString); + auto kind = new QTableWidgetItem(tagString); ui->PreferencePacks->setItem(row, 1, kind); auto button = new QPushButton(icon, tr("Apply")); button->setToolTip(tr("Apply the %1 preference pack").arg(QString::fromStdString(pack.first))); diff --git a/src/Gui/DlgKeyboardImp.cpp b/src/Gui/DlgKeyboardImp.cpp index 175449d364..7d8db1e5d8 100644 --- a/src/Gui/DlgKeyboardImp.cpp +++ b/src/Gui/DlgKeyboardImp.cpp @@ -84,9 +84,9 @@ DlgCustomKeyboardImp::DlgCustomKeyboardImp( QWidget* parent ) groupMap.push_back(std::make_pair(QLatin1String("Help"), QString())); groupMap.push_back(std::make_pair(QLatin1String("Macros"), qApp->translate("Gui::MacroCommand", "Macros"))); - for (std::map::iterator it = sCommands.begin(); it != sCommands.end(); ++it) { - QLatin1String group(it->second->getGroupName()); - QString text = it->second->translatedGroupName(); + for (const auto & sCommand : sCommands) { + QLatin1String group(sCommand.second->getGroupName()); + QString text = sCommand.second->translatedGroupName(); GroupMap::iterator jt; jt = std::find_if(groupMap.begin(), groupMap.end(), GroupMap_find(group)); if (jt != groupMap.end()) { @@ -99,7 +99,7 @@ DlgCustomKeyboardImp::DlgCustomKeyboardImp( QWidget* parent ) } int index = 0; - for (GroupMap::iterator it = groupMap.begin(); it != groupMap.end(); ++it, ++index) { + for (auto it = groupMap.begin(); it != groupMap.end(); ++it, ++index) { ui->categoryBox->addItem(it->second); ui->categoryBox->setItemData(index, QVariant(it->first), Qt::UserRole); } @@ -184,25 +184,25 @@ void DlgCustomKeyboardImp::on_categoryBox_activated(int index) std::vector aCmds = cCmdMgr.getGroupCommands( group.toLatin1() ); if (group == QLatin1String("Macros")) { - for (std::vector::iterator it = aCmds.begin(); it != aCmds.end(); ++it) { - QTreeWidgetItem* item = new QTreeWidgetItem(ui->commandTreeWidget); - item->setText(1, QString::fromUtf8((*it)->getMenuText())); - item->setToolTip(1, QString::fromUtf8((*it)->getToolTipText())); - item->setData(1, Qt::UserRole, QByteArray((*it)->getName())); + for (const auto & aCmd : aCmds) { + auto item = new QTreeWidgetItem(ui->commandTreeWidget); + item->setText(1, QString::fromUtf8(aCmd->getMenuText())); + item->setToolTip(1, QString::fromUtf8(aCmd->getToolTipText())); + item->setData(1, Qt::UserRole, QByteArray(aCmd->getName())); item->setSizeHint(0, QSize(32, 32)); - if ((*it)->getPixmap()) - item->setIcon(0, BitmapFactory().iconFromTheme((*it)->getPixmap())); + if (aCmd->getPixmap()) + item->setIcon(0, BitmapFactory().iconFromTheme(aCmd->getPixmap())); } } else { - for (std::vector::iterator it = aCmds.begin(); it != aCmds.end(); ++it) { - QTreeWidgetItem* item = new QTreeWidgetItem(ui->commandTreeWidget); - item->setText(1, qApp->translate((*it)->className(), (*it)->getMenuText())); - item->setToolTip(1, qApp->translate((*it)->className(), (*it)->getToolTipText())); - item->setData(1, Qt::UserRole, QByteArray((*it)->getName())); + for (const auto & aCmd : aCmds) { + auto item = new QTreeWidgetItem(ui->commandTreeWidget); + item->setText(1, qApp->translate(aCmd->className(), aCmd->getMenuText())); + item->setToolTip(1, qApp->translate(aCmd->className(), aCmd->getToolTipText())); + item->setData(1, Qt::UserRole, QByteArray(aCmd->getName())); item->setSizeHint(0, QSize(32, 32)); - if ((*it)->getPixmap()) - item->setIcon(0, BitmapFactory().iconFromTheme((*it)->getPixmap())); + if (aCmd->getPixmap()) + item->setIcon(0, BitmapFactory().iconFromTheme(aCmd->getPixmap())); } } } @@ -299,14 +299,14 @@ void DlgCustomKeyboardImp::on_buttonResetAll_clicked() { CommandManager & cCmdMgr = Application::Instance->commandManager(); std::vector cmds = cCmdMgr.getAllCommands(); - for (std::vector::iterator it = cmds.begin(); it != cmds.end(); ++it) { - if ((*it)->getAction()) { - (*it)->getAction()->setShortcut(QKeySequence(QString::fromLatin1((*it)->getAccel())) + for (const auto & cmd : cmds) { + if (cmd->getAction()) { + cmd->getAction()->setShortcut(QKeySequence(QString::fromLatin1(cmd->getAccel())) .toString(QKeySequence::NativeText)); // update the tool tip (and status tip) - (*it)->recreateTooltip((*it)->className(), (*it)->getAction()); + cmd->recreateTooltip(cmd->className(), cmd->getAction()); } } @@ -342,24 +342,24 @@ void DlgCustomKeyboardImp::on_editShortcut_textChanged(const QString& sc) CommandManager & cCmdMgr = Application::Instance->commandManager(); std::vector cmds = cCmdMgr.getAllCommands(); - for (std::vector::iterator it = cmds.begin(); it != cmds.end(); ++it) { - if ((*it)->getAction()) { + for (const auto & cmd : cmds) { + if (cmd->getAction()) { // A command may have several QAction's. So, check all of them if one of them matches (See bug #0002160) - QList acts = (*it)->getAction()->findChildren(); - for (QList::iterator jt = acts.begin(); jt != acts.end(); ++jt) { - if ((*jt)->shortcut() == ks) { + QList acts = cmd->getAction()->findChildren(); + for (const auto & act : acts) { + if (act->shortcut() == ks) { ++countAmbiguous; - ambiguousCommands.push_back(*it); - ambiguousCommand = QString::fromLatin1((*it)->getName()); // store the last one - ambiguousMenu = qApp->translate((*it)->className(), (*it)->getMenuText()); + ambiguousCommands.push_back(cmd); + ambiguousCommand = QString::fromLatin1(cmd->getName()); // store the last one + ambiguousMenu = qApp->translate(cmd->className(), cmd->getMenuText()); - QTreeWidgetItem* item = new QTreeWidgetItem(ui->assignedTreeWidget); - item->setText(1, qApp->translate((*it)->className(), (*it)->getMenuText())); - item->setToolTip(1, qApp->translate((*it)->className(), (*it)->getToolTipText())); - item->setData(1, Qt::UserRole, QByteArray((*it)->getName())); + auto item = new QTreeWidgetItem(ui->assignedTreeWidget); + item->setText(1, qApp->translate(cmd->className(), cmd->getMenuText())); + item->setToolTip(1, qApp->translate(cmd->className(), cmd->getToolTipText())); + item->setData(1, Qt::UserRole, QByteArray(cmd->getName())); item->setSizeHint(0, QSize(32, 32)); - if ((*it)->getPixmap()) - item->setIcon(0, BitmapFactory().iconFromTheme((*it)->getPixmap())); + if (cmd->getPixmap()) + item->setIcon(0, BitmapFactory().iconFromTheme(cmd->getPixmap())); break; } } @@ -419,7 +419,7 @@ void DlgCustomKeyboardImp::onAddMacroAction(const QByteArray& macro) CommandManager & cCmdMgr = Application::Instance->commandManager(); Command* pCmd = cCmdMgr.getCommandByName(macro); - QTreeWidgetItem* item = new QTreeWidgetItem(ui->commandTreeWidget); + auto item = new QTreeWidgetItem(ui->commandTreeWidget); item->setText(1, QString::fromUtf8(pCmd->getMenuText())); item->setToolTip(1, QString::fromUtf8(pCmd->getToolTipText())); item->setData(1, Qt::UserRole, macro); diff --git a/src/Gui/DlgMacroExecuteImp.cpp b/src/Gui/DlgMacroExecuteImp.cpp index 4c8344fb28..47e4166548 100644 --- a/src/Gui/DlgMacroExecuteImp.cpp +++ b/src/Gui/DlgMacroExecuteImp.cpp @@ -118,7 +118,7 @@ void DlgMacroExecuteImp::fillUpList() // fill up with the directory ui->userMacroListBox->clear(); for (unsigned int i=0; iuserMacroListBox,false); + auto item = new MacroItem(ui->userMacroListBox,false); item->setText(0, dir[i]); } @@ -128,7 +128,7 @@ void DlgMacroExecuteImp::fillUpList() ui->systemMacroListBox->clear(); if (dir.exists()) { for (unsigned int i=0; isystemMacroListBox,true); + auto item = new MacroItem(ui->systemMacroListBox,true); item->setText(0, dir[i]); } } @@ -261,7 +261,7 @@ void DlgMacroExecuteImp::accept() QDialog::accept(); - MacroItem * mitem = static_cast(item); + auto mitem = static_cast(item); QDir dir; @@ -326,12 +326,12 @@ void DlgMacroExecuteImp::on_editButton_clicked() if (!item) return; - MacroItem * mitem = static_cast(item); + auto mitem = static_cast(item); QString file = QString::fromLatin1("%1/%2").arg(dir.absolutePath(), item->text(0)); - PythonEditor* editor = new PythonEditor(); + auto editor = new PythonEditor(); editor->setWindowIcon(Gui::BitmapFactory().iconFromTheme("applications-python")); - PythonEditorView* edit = new PythonEditorView(editor, getMainWindow()); + auto edit = new PythonEditorView(editor, getMainWindow()); edit->setDisplayName(PythonEditorView::FileName); edit->open(file); edit->resize(400, 300); @@ -386,9 +386,9 @@ void DlgMacroExecuteImp::on_createButton_clicked() return; } file.close(); - PythonEditor* editor = new PythonEditor(); + auto editor = new PythonEditor(); editor->setWindowIcon(Gui::BitmapFactory().iconFromTheme("applications-python")); - PythonEditorView* edit = new PythonEditorView(editor, getMainWindow()); + auto edit = new PythonEditorView(editor, getMainWindow()); edit->open(fi.absoluteFilePath()); getMainWindow()->appendRecentMacro(fi.absoluteFilePath()); edit->setWindowTitle(QString::fromLatin1("%1[*]").arg(fn)); @@ -406,7 +406,7 @@ void DlgMacroExecuteImp::on_deleteButton_clicked() if (!item) return; - MacroItem * mitem = static_cast(item); + auto mitem = static_cast(item); if (mitem->systemWide) { QMessageBox::critical(Gui::getMainWindow(), QObject::tr("Delete macro"), @@ -481,8 +481,8 @@ Note: your changes will be applied when you next switch workbenches\n")); QString macroMenuText; CommandManager & cCmdMgr = Application::Instance->commandManager(); std::vector aCmds = cCmdMgr.getGroupCommands("Macros"); - for (std::vector::iterator it = aCmds.begin(); it != aCmds.end(); ++it) { - MacroCommand* mc = dynamic_cast(*it); + for (const auto & aCmd : aCmds) { + auto mc = dynamic_cast(aCmd); if (mc && fn.compare(QLatin1String(mc->getScriptName())) == 0) { hasMacroCommand = true; macroMenuText = QString::fromLatin1(mc->getMenuText()); @@ -504,14 +504,14 @@ Note: your changes will be applied when you next switch workbenches\n")); return; } - QWidget* setupCustomMacrosPage = tabWidget->findChild(QString::fromLatin1("Gui__Dialog__DlgCustomActions")); + auto setupCustomMacrosPage = tabWidget->findChild(QString::fromLatin1("Gui__Dialog__DlgCustomActions")); if (!setupCustomMacrosPage) { std::cerr << "Toolbar walkthrough error: Unable to find setupCustomMacrosPage" << std::endl; return; } tabWidget->setCurrentWidget(setupCustomMacrosPage); - QGroupBox* groupBox7 = setupCustomMacrosPage->findChild(QString::fromLatin1("GroupBox7")); + auto groupBox7 = setupCustomMacrosPage->findChild(QString::fromLatin1("GroupBox7")); if (!groupBox7) { Base::Console().Warning("Toolbar walkthrough: Unable to find groupBox7\n"); //just warn when not a fatal error @@ -521,14 +521,14 @@ Note: your changes will be applied when you next switch workbenches\n")); groupBox7->setStyleSheet(QString::fromLatin1("QGroupBox::title {color:red}")); } - QPushButton* buttonAddAction = setupCustomMacrosPage->findChild(QString::fromLatin1("buttonAddAction")); + auto buttonAddAction = setupCustomMacrosPage->findChild(QString::fromLatin1("buttonAddAction")); if (!buttonAddAction) { Base::Console().Warning("Toolbar walkthrough: Unable to find buttonAddAction\n"); } else { buttonAddAction->setStyleSheet(QString::fromLatin1("color:red")); } - QComboBox* macroListBox = setupCustomMacrosPage->findChild(QString::fromLatin1("actionMacros")); + auto macroListBox = setupCustomMacrosPage->findChild(QString::fromLatin1("actionMacros")); if (!macroListBox) { Base::Console().Warning("Toolbar walkthrough: Unable to find actionMacros combo box\n"); } else { @@ -536,7 +536,7 @@ Note: your changes will be applied when you next switch workbenches\n")); macroListBox->setCurrentIndex(macroIndex); //select it for the user so they don't have to } - QLineEdit* menuText = setupCustomMacrosPage->findChild(QString::fromLatin1("actionMenu")); + auto menuText = setupCustomMacrosPage->findChild(QString::fromLatin1("actionMenu")); if (!menuText) { Base::Console().Warning("Toolbar walkthrough: Unable to find actionMenu menuText\n"); } else { @@ -563,14 +563,14 @@ Note: your changes will be applied when you next switch workbenches\n")); return; } - DlgCustomToolbars* setupToolbarPage = tabWidget->findChild(QString::fromLatin1("Gui__Dialog__DlgCustomToolbars")); + auto setupToolbarPage = tabWidget->findChild(QString::fromLatin1("Gui__Dialog__DlgCustomToolbars")); if (!setupToolbarPage){ std::cerr << "Toolbar walkthrough: Unable to find setupToolbarPage Gui__Dialog__DlgCustomToolbars" << std::endl; return; } tabWidget->setCurrentWidget(setupToolbarPage); - QPushButton* moveActionRightButton = setupToolbarPage->findChild(QString::fromLatin1("moveActionRightButton")); + auto moveActionRightButton = setupToolbarPage->findChild(QString::fromLatin1("moveActionRightButton")); if (!moveActionRightButton){ Base::Console().Warning("Toolbar walkthrough: Unable to find moveActionRightButton\n"); } else { @@ -581,7 +581,7 @@ Note: your changes will be applied when you next switch workbenches\n")); **/ QString instructions2 = tr("Walkthrough instructions: Click right arrow button (->), then Close."); - QComboBox* workbenchBox = setupToolbarPage->findChild(QString::fromLatin1("workbenchBox")); + auto workbenchBox = setupToolbarPage->findChild(QString::fromLatin1("workbenchBox")); if (!workbenchBox) { Base::Console().Warning("Toolbar walkthrough: Unable to find workbenchBox\n"); } @@ -600,7 +600,7 @@ Note: your changes will be applied when you next switch workbenches\n")); } if (!hasCustomToolbar){ - QPushButton* newButton = setupToolbarPage->findChild(QString::fromLatin1("newButton")); + auto newButton = setupToolbarPage->findChild(QString::fromLatin1("newButton")); if (!newButton){ Base::Console().Warning("Toolbar walkthrough: Unable to find newButton\n"); } else { @@ -611,7 +611,7 @@ Note: your changes will be applied when you next switch workbenches\n")); } /** "label" normally says "Note: the changes become active the next time you load the appropriate workbench" **/ - QLabel *label = setupToolbarPage->findChild(QString::fromLatin1("label")); + auto label = setupToolbarPage->findChild(QString::fromLatin1("label")); if (!label){ Base::Console().Warning("Toolbar walkthrough: Unable to find label\n"); } else { @@ -620,7 +620,7 @@ Note: your changes will be applied when you next switch workbenches\n")); } /** find Macros category and select it for the user **/ - QComboBox* categoryBox = setupToolbarPage->findChild(QString::fromLatin1("categoryBox")); + auto categoryBox = setupToolbarPage->findChild(QString::fromLatin1("categoryBox")); if (!categoryBox){ Base::Console().Warning("Toolbar walkthrough: Unable to find categoryBox\n"); } else { @@ -637,7 +637,7 @@ Note: your changes will be applied when you next switch workbenches\n")); } /** expand custom toolbar items **/ - QTreeWidget* toolbarTreeWidget = setupToolbarPage->findChild(QString::fromLatin1("toolbarTreeWidget")); + auto toolbarTreeWidget = setupToolbarPage->findChild(QString::fromLatin1("toolbarTreeWidget")); if (!toolbarTreeWidget) { Base::Console().Warning("Toolbar walkthrough: Unable to find toolbarTreeWidget\n"); } else { @@ -646,7 +646,7 @@ Note: your changes will be applied when you next switch workbenches\n")); /** preselect macro command for user **/ - QTreeWidget* commandTreeWidget = setupToolbarPage->findChild(QString::fromLatin1("commandTreeWidget")); + auto commandTreeWidget = setupToolbarPage->findChild(QString::fromLatin1("commandTreeWidget")); if (!commandTreeWidget) { Base::Console().Warning("Toolbar walkthrough: Unable to find commandTreeWidget\n"); } else { diff --git a/src/Gui/DlgMaterialPropertiesImp.cpp b/src/Gui/DlgMaterialPropertiesImp.cpp index abe0f4b361..ae16c78a73 100644 --- a/src/Gui/DlgMaterialPropertiesImp.cpp +++ b/src/Gui/DlgMaterialPropertiesImp.cpp @@ -81,10 +81,10 @@ void DlgMaterialPropertiesImp::on_ambientColor_changed() float b = (float)col.blue()/255.0f; App::Color ambient(r,g,b); - for (std::vector::iterator it= Objects.begin();it!=Objects.end();++it) { + for (std::vector::iterator it= Objects.begin(); it != Objects.end(); ++it) { App::Property* prop = (*it)->getPropertyByName(material.c_str()); if (prop && prop->getTypeId().isDerivedFrom(App::PropertyMaterial::getClassTypeId())) { - App::PropertyMaterial* ShapeMaterial = (App::PropertyMaterial*)prop; + auto ShapeMaterial = (App::PropertyMaterial*)prop; App::Material mat = ShapeMaterial->getValue(); mat.ambientColor = ambient; ShapeMaterial->setValue(mat); @@ -106,7 +106,7 @@ void DlgMaterialPropertiesImp::on_diffuseColor_changed() for (std::vector::iterator it= Objects.begin();it!=Objects.end();++it) { App::Property* prop = (*it)->getPropertyByName(material.c_str()); if (prop && prop->getTypeId().isDerivedFrom(App::PropertyMaterial::getClassTypeId())) { - App::PropertyMaterial* ShapeMaterial = (App::PropertyMaterial*)prop; + auto ShapeMaterial = (App::PropertyMaterial*)prop; App::Material mat = ShapeMaterial->getValue(); mat.diffuseColor = diffuse; ShapeMaterial->setValue(mat); @@ -128,7 +128,7 @@ void DlgMaterialPropertiesImp::on_emissiveColor_changed() for (std::vector::iterator it= Objects.begin();it!=Objects.end();++it) { App::Property* prop = (*it)->getPropertyByName(material.c_str()); if (prop && prop->getTypeId().isDerivedFrom(App::PropertyMaterial::getClassTypeId())) { - App::PropertyMaterial* ShapeMaterial = (App::PropertyMaterial*)prop; + auto ShapeMaterial = (App::PropertyMaterial*)prop; App::Material mat = ShapeMaterial->getValue(); mat.emissiveColor = emissive; ShapeMaterial->setValue(mat); @@ -150,7 +150,7 @@ void DlgMaterialPropertiesImp::on_specularColor_changed() for (std::vector::iterator it= Objects.begin();it!=Objects.end();++it) { App::Property* prop = (*it)->getPropertyByName(material.c_str()); if (prop && prop->getTypeId().isDerivedFrom(App::PropertyMaterial::getClassTypeId())) { - App::PropertyMaterial* ShapeMaterial = (App::PropertyMaterial*)prop; + auto ShapeMaterial = (App::PropertyMaterial*)prop; App::Material mat = ShapeMaterial->getValue(); mat.specularColor = specular; ShapeMaterial->setValue(mat); @@ -167,7 +167,7 @@ void DlgMaterialPropertiesImp::on_shininess_valueChanged(int sh) for (std::vector::iterator it= Objects.begin();it!=Objects.end();++it) { App::Property* prop = (*it)->getPropertyByName(material.c_str()); if (prop && prop->getTypeId().isDerivedFrom(App::PropertyMaterial::getClassTypeId())) { - App::PropertyMaterial* ShapeMaterial = (App::PropertyMaterial*)prop; + auto ShapeMaterial = (App::PropertyMaterial*)prop; App::Material mat = ShapeMaterial->getValue(); mat.shininess = shininess; ShapeMaterial->setValue(mat); @@ -185,7 +185,7 @@ void DlgMaterialPropertiesImp::setViewProviders(const std::vector::iterator it= Objects.begin();it!=Objects.end();++it) { App::Property* prop = (*it)->getPropertyByName(material.c_str()); if (prop && prop->getTypeId().isDerivedFrom(App::PropertyMaterial::getClassTypeId())) { - App::PropertyMaterial* ShapeMaterial = (App::PropertyMaterial*)prop; + auto ShapeMaterial = (App::PropertyMaterial*)prop; App::Material mat = ShapeMaterial->getValue(); int r = int(mat.ambientColor.r * 255.0f); int g = int(mat.ambientColor.g * 255.0f); diff --git a/src/Gui/DlgParameterFind.cpp b/src/Gui/DlgParameterFind.cpp index 6298c3a880..c5ad7677c5 100644 --- a/src/Gui/DlgParameterFind.cpp +++ b/src/Gui/DlgParameterFind.cpp @@ -120,7 +120,7 @@ bool DlgParameterFind::matches(QTreeWidgetItem* item, const Options& opt) const } if (opt.name || opt.value) { - ParameterGroupItem* group = static_cast(item); + auto group = static_cast(item); Base::Reference hGrp = group->_hcGrp; auto boolMap = hGrp->GetBoolMap(); @@ -235,7 +235,7 @@ QTreeWidgetItem* DlgParameterFind::findItem(QTreeWidgetItem* root, const Options void DlgParameterFind::accept() { - ParameterGroup* groupTree = dialog->findChild(); + auto groupTree = dialog->findChild(); if (groupTree) { Options opt; opt.text = ui->lineEdit->text(); diff --git a/src/Gui/DlgParameterImp.cpp b/src/Gui/DlgParameterImp.cpp index f64f84e0c1..cb5447787f 100644 --- a/src/Gui/DlgParameterImp.cpp +++ b/src/Gui/DlgParameterImp.cpp @@ -93,9 +93,9 @@ DlgParameterImp::DlgParameterImp( QWidget* parent, Qt::WindowFlags fl ) ParameterManager* sys = App::GetApplication().GetParameterSet("System parameter"); const std::map& rcList = App::GetApplication().GetParameterSetList(); - for (std::map::const_iterator it= rcList.begin();it!=rcList.end();++it) { - if (it->second != sys) // for now ignore system parameters because they are nowhere used - ui->parameterSet->addItem(tr(it->first.c_str()), QVariant(QByteArray(it->first.c_str()))); + for (const auto & it : rcList) { + if (it.second != sys) // for now ignore system parameters because they are nowhere used + ui->parameterSet->addItem(tr(it.first.c_str()), QVariant(QByteArray(it.first.c_str()))); } QByteArray cStr("User parameter"); @@ -307,38 +307,38 @@ void DlgParameterImp::onGroupSelected( QTreeWidgetItem * item ) // filling up Text nodes std::vector > mcTextMap = _hcGrp->GetASCIIMap(); - for(std::vector >::iterator It2=mcTextMap.begin();It2!=mcTextMap.end();++It2) + for(const auto & It2 : mcTextMap) { - (void)new ParameterText(paramValue,QString::fromUtf8(It2->first.c_str()), - It2->second.c_str(), _hcGrp); + (void)new ParameterText(paramValue,QString::fromUtf8(It2.first.c_str()), + It2.second.c_str(), _hcGrp); } // filling up Int nodes std::vector > mcIntMap = _hcGrp->GetIntMap(); - for(std::vector >::iterator It3=mcIntMap.begin();It3!=mcIntMap.end();++It3) + for(const auto & It3 : mcIntMap) { - (void)new ParameterInt(paramValue,QString::fromUtf8(It3->first.c_str()),It3->second, _hcGrp); + (void)new ParameterInt(paramValue,QString::fromUtf8(It3.first.c_str()),It3.second, _hcGrp); } // filling up Float nodes std::vector > mcFloatMap = _hcGrp->GetFloatMap(); - for(std::vector >::iterator It4=mcFloatMap.begin();It4!=mcFloatMap.end();++It4) + for(const auto & It4 : mcFloatMap) { - (void)new ParameterFloat(paramValue,QString::fromUtf8(It4->first.c_str()),It4->second, _hcGrp); + (void)new ParameterFloat(paramValue,QString::fromUtf8(It4.first.c_str()),It4.second, _hcGrp); } // filling up bool nodes std::vector > mcBoolMap = _hcGrp->GetBoolMap(); - for(std::vector >::iterator It5=mcBoolMap.begin();It5!=mcBoolMap.end();++It5) + for(const auto & It5 : mcBoolMap) { - (void)new ParameterBool(paramValue,QString::fromUtf8(It5->first.c_str()),It5->second, _hcGrp); + (void)new ParameterBool(paramValue,QString::fromUtf8(It5.first.c_str()),It5.second, _hcGrp); } // filling up UInt nodes std::vector > mcUIntMap = _hcGrp->GetUnsignedMap(); - for(std::vector >::iterator It6=mcUIntMap.begin();It6!=mcUIntMap.end();++It6) + for(const auto & It6 : mcUIntMap) { - (void)new ParameterUInt(paramValue,QString::fromUtf8(It6->first.c_str()),It6->second, _hcGrp); + (void)new ParameterUInt(paramValue,QString::fromUtf8(It6.first.c_str()),It6.second, _hcGrp); } paramValue->setSortingEnabled(sortingEnabled); } @@ -370,8 +370,8 @@ void DlgParameterImp::onChangeParameterSet(int itemPos) // root labels std::vector > grps = rcParMngr->GetGroups(); - for ( std::vector >::iterator it = grps.begin(); it != grps.end(); ++it ) { - QTreeWidgetItem* item = new ParameterGroupItem(paramGroup, *it); + for (const auto & grp : grps) { + auto item = new ParameterGroupItem(paramGroup, grp); paramGroup->expandItem(item); item->setIcon(0, QApplication::style()->standardPixmap(QStyle::SP_ComputerIcon)); } @@ -516,7 +516,7 @@ void ParameterGroup::onDeleteSelectedItem() // hold a reference to the parameter group delete sel; - ParameterGroupItem* para = static_cast(parent); + auto para = static_cast(parent); para->_hcGrp->RemoveGrp(groupName.c_str()); } } @@ -545,7 +545,7 @@ void ParameterGroup::onCreateSubgroup() QTreeWidgetItem* item = currentItem(); if (item && item->isSelected()) { - ParameterGroupItem* para = static_cast(item); + auto para = static_cast(item); Base::Reference hGrp = para->_hcGrp; if ( hGrp->HasGroup( name.toLatin1() ) ) @@ -571,7 +571,7 @@ void ParameterGroup::onExportToFile() QTreeWidgetItem* item = currentItem(); if (item && item->isSelected()) { - ParameterGroupItem* para = static_cast(item); + auto para = static_cast(item); Base::Reference hGrp = para->_hcGrp; hGrp->exportTo( file.toUtf8() ); } @@ -587,23 +587,23 @@ void ParameterGroup::onImportFromFile() QTreeWidgetItem* item = currentItem(); if (item && item->isSelected()) { - ParameterGroupItem* para = static_cast(item); + auto para = static_cast(item); Base::Reference hGrp = para->_hcGrp; // remove the items and internal parameter values QList childs = para->takeChildren(); - for (QList::iterator it = childs.begin(); it != childs.end(); ++it) + for (auto & child : childs) { - delete *it; + delete child; } try { hGrp->importFrom( file.toUtf8() ); std::vector > cSubGrps = hGrp->GetGroups(); - for ( std::vector >::iterator it = cSubGrps.begin(); it != cSubGrps.end(); ++it ) + for (const auto & cSubGrp : cSubGrps) { - new ParameterGroupItem(para,*it); + new ParameterGroupItem(para,cSubGrp); } para->setExpanded(para->childCount()); @@ -768,8 +768,8 @@ void ParameterValue::onCreateTextItem() return; std::vector > smap = _hcGrp->GetASCIIMap(); - for (std::vector >::iterator it = smap.begin(); it != smap.end(); ++it) { - if (name == QLatin1String(it->first.c_str())) + for (const auto & it : smap) { + if (name == QLatin1String(it.first.c_str())) { QMessageBox::critical( this, tr("Existing item"), tr("The item '%1' already exists.").arg( name ) ); @@ -797,8 +797,8 @@ void ParameterValue::onCreateIntItem() return; std::vector > lmap = _hcGrp->GetIntMap(); - for (std::vector >::iterator it = lmap.begin(); it != lmap.end(); ++it) { - if (name == QLatin1String(it->first.c_str())) + for (const auto & it : lmap) { + if (name == QLatin1String(it.first.c_str())) { QMessageBox::critical( this, tr("Existing item"), tr("The item '%1' already exists.").arg( name ) ); @@ -827,8 +827,8 @@ void ParameterValue::onCreateUIntItem() return; std::vector > lmap = _hcGrp->GetUnsignedMap(); - for (std::vector >::iterator it = lmap.begin(); it != lmap.end(); ++it) { - if (name == QLatin1String(it->first.c_str())) + for (const auto & it : lmap) { + if (name == QLatin1String(it.first.c_str())) { QMessageBox::critical( this, tr("Existing item"), tr("The item '%1' already exists.").arg( name ) ); @@ -863,8 +863,8 @@ void ParameterValue::onCreateFloatItem() return; std::vector > fmap = _hcGrp->GetFloatMap(); - for (std::vector >::iterator it = fmap.begin(); it != fmap.end(); ++it) { - if (name == QLatin1String(it->first.c_str())) + for (const auto & it : fmap) { + if (name == QLatin1String(it.first.c_str())) { QMessageBox::critical( this, tr("Existing item"), tr("The item '%1' already exists.").arg( name ) ); @@ -892,8 +892,8 @@ void ParameterValue::onCreateBoolItem() return; std::vector > bmap = _hcGrp->GetBoolMap(); - for (std::vector >::iterator it = bmap.begin(); it != bmap.end(); ++it) { - if (name == QLatin1String(it->first.c_str())) + for (const auto & it : bmap) { + if (name == QLatin1String(it.first.c_str())) { QMessageBox::critical( this, tr("Existing item"), tr("The item '%1' already exists.").arg( name ) ); @@ -943,8 +943,8 @@ void ParameterGroupItem::fillUp() std::vector > vhcParamGrp = _hcGrp->GetGroups(); setText(0,QString::fromUtf8(_hcGrp->GetGroupName())); - for(std::vector >::iterator It=vhcParamGrp.begin();It!=vhcParamGrp.end();++It) - (void)new ParameterGroupItem(this,*It); + for(const auto & It : vhcParamGrp) + (void)new ParameterGroupItem(this,It); } void ParameterGroupItem::setData ( int column, int role, const QVariant & value ) @@ -959,7 +959,7 @@ void ParameterGroupItem::setData ( int column, int role, const QVariant & value return; // first check if there is already a group with name "newName" - ParameterGroupItem* item = static_cast(parent()); + auto item = static_cast(parent()); if ( !item ) { QMessageBox::critical( treeWidget(), QObject::tr("Rename group"), diff --git a/src/Gui/DlgPreferencesImp.cpp b/src/Gui/DlgPreferencesImp.cpp index 6309950a2d..423d2c6a73 100644 --- a/src/Gui/DlgPreferencesImp.cpp +++ b/src/Gui/DlgPreferencesImp.cpp @@ -137,11 +137,11 @@ QTabWidget* DlgPreferencesImp::createTabForGroup(const std::string &groupName) QString tooltip; getGroupData(groupName, fileName, tooltip); - QTabWidget* tabWidget = new QTabWidget; + auto tabWidget = new QTabWidget; ui->tabWidgetStack->addWidget(tabWidget); tabWidget->setProperty("GroupName", QVariant(groupNameQString)); - QListWidgetItem* item = new QListWidgetItem(ui->listBox); + auto item = new QListWidgetItem(ui->listBox); item->setData(GroupNameRole, QVariant(groupNameQString)); item->setText(QObject::tr(groupNameQString.toLatin1())); item->setToolTip(tooltip); @@ -205,7 +205,7 @@ void DlgPreferencesImp::changeGroup(QListWidgetItem *current, QListWidgetItem *p void DlgPreferencesImp::addPage(const std::string& className, const std::string& group) { std::list::iterator groupToAddTo = _pages.end(); - for (std::list::iterator it = _pages.begin(); it != _pages.end(); ++it) { + for (auto it = _pages.begin(); it != _pages.end(); ++it) { if (it->first == group) { groupToAddTo = it; break; @@ -239,7 +239,7 @@ void DlgPreferencesImp::removePage(const std::string& className, const std::stri } else { std::list& p = it->second; - for (std::list::iterator jt = p.begin(); jt != p.end(); ++jt) { + for (auto jt = p.begin(); jt != p.end(); ++jt) { if (*jt == className) { p.erase(jt); if (p.empty()) @@ -292,7 +292,7 @@ void DlgPreferencesImp::activateGroupPage(const QString& group, int index) QListWidgetItem* item = ui->listBox->item(i); if (item->data(GroupNameRole).toString() == group) { ui->listBox->setCurrentItem(item); - QTabWidget* tabWidget = (QTabWidget*)ui->tabWidgetStack->widget(i); + auto tabWidget = (QTabWidget*)ui->tabWidgetStack->widget(i); tabWidget->setCurrentIndex(index); break; } @@ -376,7 +376,7 @@ void DlgPreferencesImp::reloadPages() QString pageName = QString::fromStdString(page); bool pageExists = false; for (int pageNumber = 0; pageNumber < tabWidget->count(); ++pageNumber) { - PreferencePage* prefPage = qobject_cast(tabWidget->widget(pageNumber)); + auto prefPage = qobject_cast(tabWidget->widget(pageNumber)); if (prefPage && prefPage->property("PageName").toString() == pageName) { pageExists = true; break; @@ -400,7 +400,7 @@ void DlgPreferencesImp::applyChanges() // cancel further operation in other methods (like in accept()). try { for (int i=0; itabWidgetStack->count(); i++) { - QTabWidget* tabWidget = (QTabWidget*)ui->tabWidgetStack->widget(i); + auto tabWidget = (QTabWidget*)ui->tabWidgetStack->widget(i); for (int j=0; jcount(); j++) { QWidget* page = tabWidget->widget(j); int index = page->metaObject()->indexOfMethod("checkSettings()"); @@ -425,9 +425,9 @@ void DlgPreferencesImp::applyChanges() // If everything is ok (i.e., no validation problem), call method // saveSettings() in every subpage (DlgSetting*) object. for (int i=0; itabWidgetStack->count(); i++) { - QTabWidget* tabWidget = (QTabWidget*)ui->tabWidgetStack->widget(i); + auto tabWidget = (QTabWidget*)ui->tabWidgetStack->widget(i); for (int j=0; jcount(); j++) { - PreferencePage* page = qobject_cast(tabWidget->widget(j)); + auto page = qobject_cast(tabWidget->widget(j)); if (page) page->saveSettings(); } @@ -458,7 +458,7 @@ void DlgPreferencesImp::resizeEvent(QResizeEvent* ev) if (height() > maxHeight || width() > maxWidth) { canEmbedScrollArea = false; ui->hboxLayout->removeWidget(ui->tabWidgetStack); - QScrollArea* scrollArea = new QScrollArea(this); + auto scrollArea = new QScrollArea(this); scrollArea->setFrameShape(QFrame::NoFrame); scrollArea->setWidgetResizable(true); scrollArea->setWidget(ui->tabWidgetStack); @@ -466,7 +466,7 @@ void DlgPreferencesImp::resizeEvent(QResizeEvent* ev) // if possible the minimum width should so that it doesn't show // a horizontal scroll bar. - QScrollBar* bar = scrollArea->verticalScrollBar(); + auto bar = scrollArea->verticalScrollBar(); if (bar) { int newWidth = width() + bar->width(); newWidth = std::min(newWidth, maxWidth); @@ -495,7 +495,7 @@ void DlgPreferencesImp::changeEvent(QEvent *e) ui->retranslateUi(this); // update the widgets' tabs for (int i=0; itabWidgetStack->count(); i++) { - QTabWidget* tabWidget = (QTabWidget*)ui->tabWidgetStack->widget(i); + auto tabWidget = (QTabWidget*)ui->tabWidgetStack->widget(i); for (int j=0; jcount(); j++) { QWidget* page = tabWidget->widget(j); tabWidget->setTabText(j, page->windowTitle()); @@ -515,9 +515,9 @@ void DlgPreferencesImp::changeEvent(QEvent *e) void DlgPreferencesImp::reload() { for (int i = 0; i < ui->tabWidgetStack->count(); i++) { - QTabWidget* tabWidget = (QTabWidget*)ui->tabWidgetStack->widget(i); + auto tabWidget = (QTabWidget*)ui->tabWidgetStack->widget(i); for (int j = 0; j < tabWidget->count(); j++) { - PreferencePage* page = qobject_cast(tabWidget->widget(j)); + auto page = qobject_cast(tabWidget->widget(j)); if (page) page->loadSettings(); } diff --git a/src/Gui/DlgSettingsColorGradientImp.cpp b/src/Gui/DlgSettingsColorGradientImp.cpp index ce34225208..97ef8a1aea 100644 --- a/src/Gui/DlgSettingsColorGradientImp.cpp +++ b/src/Gui/DlgSettingsColorGradientImp.cpp @@ -84,7 +84,7 @@ DlgSettingsColorGradientImp::~DlgSettingsColorGradientImp() void DlgSettingsColorGradientImp::setupConnections() { - QButtonGroup* group = new QButtonGroup(this); + auto group = new QButtonGroup(this); group->setExclusive(true); group->addButton(ui->radioButtonFlow); group->addButton(ui->radioButtonZero); diff --git a/src/Gui/DlgSettingsLazyLoadedImp.cpp b/src/Gui/DlgSettingsLazyLoadedImp.cpp index 7b15d3a431..886c1efcda 100644 --- a/src/Gui/DlgSettingsLazyLoadedImp.cpp +++ b/src/Gui/DlgSettingsLazyLoadedImp.cpp @@ -150,12 +150,12 @@ void DlgSettingsLazyLoadedImp::buildUnloadedWorkbenchList() // Column 3: Autoloaded checkbox // // To get the checkbox centered, we have to jump through some hoops... - QWidget* checkWidget = new QWidget(this); + auto checkWidget = new QWidget(this); auto autoloadCheckbox = new QCheckBox(this); autoloadCheckbox->setToolTip(tr("If checked") + QString::fromUtf8(", ") + wbDisplayName + QString::fromUtf8(" ") + tr("will be loaded automatically when FreeCAD starts up")); - QHBoxLayout* checkLayout = new QHBoxLayout(checkWidget); + auto checkLayout = new QHBoxLayout(checkWidget); checkLayout->addWidget(autoloadCheckbox); checkLayout->setAlignment(Qt::AlignCenter); checkLayout->setContentsMargins(0, 0, 0, 0); diff --git a/src/Gui/DlgSettingsMacroImp.cpp b/src/Gui/DlgSettingsMacroImp.cpp index 4f86e7ea07..bf57d012d3 100644 --- a/src/Gui/DlgSettingsMacroImp.cpp +++ b/src/Gui/DlgSettingsMacroImp.cpp @@ -65,7 +65,7 @@ DlgSettingsMacroImp::~DlgSettingsMacroImp() */ void DlgSettingsMacroImp::setRecentMacroSize() { - RecentMacrosAction *recent = getMainWindow()->findChild(QLatin1String("recentMacros")); + auto recent = getMainWindow()->findChild(QLatin1String("recentMacros")); if (recent) { ParameterGrp::handle hGrp = WindowParameter::getDefaultParameter()->GetGroup("RecentMacros"); recent->resizeList(hGrp->GetInt("RecentMacros", 4)); diff --git a/src/Gui/DlgSettingsNavigation.cpp b/src/Gui/DlgSettingsNavigation.cpp index a2a7f27fcf..549889c6d9 100644 --- a/src/Gui/DlgSettingsNavigation.cpp +++ b/src/Gui/DlgSettingsNavigation.cpp @@ -211,9 +211,9 @@ void DlgSettingsNavigation::retranslate() // add submenu at the end to select navigation style std::map styles = UserNavigationStyle::getUserFriendlyNames(); - for (std::map::iterator it = styles.begin(); it != styles.end(); ++it) { - QByteArray data(it->first.getName()); - QString name = QApplication::translate(it->first.getName(), it->second.c_str()); + for (const auto & style : styles) { + QByteArray data(style.first.getName()); + QString name = QApplication::translate(style.first.getName(), style.second.c_str()); ui->comboNavigationStyle->addItem(name, data); } @@ -256,7 +256,7 @@ CameraDialog::CameraDialog(QWidget* parent) layout = new QGridLayout(groupBox); // Q0 - QLabel* label0 = new QLabel(groupBox); + auto label0 = new QLabel(groupBox); label0->setText(tr("Q0")); layout->addWidget(label0, 0, 0, 1, 1); @@ -266,7 +266,7 @@ CameraDialog::CameraDialog(QWidget* parent) layout->addWidget(sb0, 0, 1, 1, 1); // Q1 - QLabel* label1 = new QLabel(groupBox); + auto label1 = new QLabel(groupBox); label1->setText(tr("Q1")); layout->addWidget(label1, 1, 0, 1, 1); @@ -276,7 +276,7 @@ CameraDialog::CameraDialog(QWidget* parent) layout->addWidget(sb1, 1, 1, 1, 1); // Q2 - QLabel* label2 = new QLabel(groupBox); + auto label2 = new QLabel(groupBox); label2->setText(tr("Q2")); layout->addWidget(label2, 2, 0, 1, 1); @@ -286,7 +286,7 @@ CameraDialog::CameraDialog(QWidget* parent) layout->addWidget(sb2, 2, 1, 1, 1); // Q3 - QLabel* label3 = new QLabel(groupBox); + auto label3 = new QLabel(groupBox); label3->setText(tr("Q3")); layout->addWidget(label3, 3, 0, 1, 1); @@ -295,8 +295,7 @@ CameraDialog::CameraDialog(QWidget* parent) sb3->setSingleStep(0.1); layout->addWidget(sb3, 3, 1, 1, 1); - QPushButton *currentViewButton; - currentViewButton = new QPushButton(this); + auto currentViewButton = new QPushButton(this); currentViewButton->setText(tr("Current view")); currentViewButton->setObjectName(QString::fromLatin1("currentView")); layout->addWidget(currentViewButton, 4, 1, 2, 1); @@ -328,7 +327,7 @@ void CameraDialog::getValues(double& q0, double& q1, double& q2, double& q3) con void CameraDialog::on_currentView_clicked() { - View3DInventor* mdi = qobject_cast(getMainWindow()->activeWindow()); + auto mdi = qobject_cast(getMainWindow()->activeWindow()); if (mdi) { SbRotation rot = mdi->getViewer()->getCameraOrientation(); const float* q = rot.getValue(); diff --git a/src/Gui/DlgToolbarsImp.cpp b/src/Gui/DlgToolbarsImp.cpp index fff8ea82c3..f3c6a41300 100644 --- a/src/Gui/DlgToolbarsImp.cpp +++ b/src/Gui/DlgToolbarsImp.cpp @@ -91,9 +91,9 @@ DlgCustomToolbars::DlgCustomToolbars(DlgCustomToolbars::Type t, QWidget* parent) groupMap.push_back(std::make_pair(QLatin1String("Help"), QString())); groupMap.push_back(std::make_pair(QLatin1String("Macros"), qApp->translate("Gui::MacroCommand", "Macros"))); - for (std::map::iterator it = sCommands.begin(); it != sCommands.end(); ++it) { - QLatin1String group(it->second->getGroupName()); - QString text = it->second->translatedGroupName(); + for (const auto & sCommand : sCommands) { + QLatin1String group(sCommand.second->getGroupName()); + QString text = sCommand.second->translatedGroupName(); GroupMap::iterator jt; jt = std::find_if(groupMap.begin(), groupMap.end(), GroupMap_find(group)); if (jt != groupMap.end()) { @@ -106,7 +106,7 @@ DlgCustomToolbars::DlgCustomToolbars(DlgCustomToolbars::Type t, QWidget* parent) } int index = 0; - for (GroupMap::iterator it = groupMap.begin(); it != groupMap.end(); ++it, ++index) { + for (auto it = groupMap.begin(); it != groupMap.end(); ++it, ++index) { ui->categoryBox->addItem(it->second); ui->categoryBox->setItemData(index, QVariant(it->first), Qt::UserRole); } @@ -117,15 +117,15 @@ DlgCustomToolbars::DlgCustomToolbars(DlgCustomToolbars::Type t, QWidget* parent) index = 1; ui->workbenchBox->addItem(QApplication::windowIcon(), tr("Global")); ui->workbenchBox->setItemData(0, QVariant(QString::fromLatin1("Global")), Qt::UserRole); - for (QStringList::Iterator it = workbenches.begin(); it != workbenches.end(); ++it) { - QPixmap px = Application::Instance->workbenchIcon(*it); - QString mt = Application::Instance->workbenchMenuText(*it); + for (const auto & workbench : workbenches) { + QPixmap px = Application::Instance->workbenchIcon(workbench); + QString mt = Application::Instance->workbenchMenuText(workbench); if (mt != QLatin1String("")) { if (px.isNull()) ui->workbenchBox->addItem(mt); else ui->workbenchBox->addItem(px, mt); - ui->workbenchBox->setItemData(index, QVariant(*it), Qt::UserRole); + ui->workbenchBox->setItemData(index, QVariant(workbench), Qt::UserRole); index++; } } @@ -203,31 +203,31 @@ void DlgCustomToolbars::on_categoryBox_activated(int index) std::vector aCmds = cCmdMgr.getGroupCommands(group.toLatin1()); // Create a separator item - QTreeWidgetItem* sepitem = new QTreeWidgetItem(ui->commandTreeWidget); + auto sepitem = new QTreeWidgetItem(ui->commandTreeWidget); sepitem->setText(1, tr("")); sepitem->setData(1, Qt::UserRole, QByteArray("Separator")); sepitem->setSizeHint(0, QSize(32, 32)); if (group == QLatin1String("Macros")) { - for (std::vector::iterator it = aCmds.begin(); it != aCmds.end(); ++it) { - QTreeWidgetItem* item = new QTreeWidgetItem(ui->commandTreeWidget); - item->setText(1, QString::fromUtf8((*it)->getMenuText())); - item->setToolTip(1, QString::fromUtf8((*it)->getToolTipText())); - item->setData(1, Qt::UserRole, QByteArray((*it)->getName())); + for (const auto & aCmd : aCmds) { + auto item = new QTreeWidgetItem(ui->commandTreeWidget); + item->setText(1, QString::fromUtf8(aCmd->getMenuText())); + item->setToolTip(1, QString::fromUtf8(aCmd->getToolTipText())); + item->setData(1, Qt::UserRole, QByteArray(aCmd->getName())); item->setSizeHint(0, QSize(32, 32)); - if ((*it)->getPixmap()) - item->setIcon(0, BitmapFactory().iconFromTheme((*it)->getPixmap())); + if (aCmd->getPixmap()) + item->setIcon(0, BitmapFactory().iconFromTheme(aCmd->getPixmap())); } } else { - for (std::vector::iterator it = aCmds.begin(); it != aCmds.end(); ++it) { - QTreeWidgetItem* item = new QTreeWidgetItem(ui->commandTreeWidget); - item->setText(1, qApp->translate((*it)->className(), (*it)->getMenuText())); - item->setToolTip(1, qApp->translate((*it)->className(), (*it)->getToolTipText())); - item->setData(1, Qt::UserRole, QByteArray((*it)->getName())); + for (const auto & aCmd : aCmds) { + auto item = new QTreeWidgetItem(ui->commandTreeWidget); + item->setText(1, qApp->translate(aCmd->className(), aCmd->getMenuText())); + item->setToolTip(1, qApp->translate(aCmd->className(), aCmd->getToolTipText())); + item->setData(1, Qt::UserRole, QByteArray(aCmd->getName())); item->setSizeHint(0, QSize(32, 32)); - if ((*it)->getPixmap()) - item->setIcon(0, BitmapFactory().iconFromTheme((*it)->getPixmap())); + if (aCmd->getPixmap()) + item->setIcon(0, BitmapFactory().iconFromTheme(aCmd->getPixmap())); } } } @@ -256,45 +256,45 @@ void DlgCustomToolbars::importCustomToolbars(const QByteArray& name) std::vector > hGrps = hGrp->GetGroups(); CommandManager& rMgr = Application::Instance->commandManager(); - for (std::vector >::iterator it = hGrps.begin(); it != hGrps.end(); ++it) { + for (const auto & hGrp : hGrps) { // create a toplevel item - QTreeWidgetItem* toplevel = new QTreeWidgetItem(ui->toolbarTreeWidget); - bool active = (*it)->GetBool("Active", true); + auto toplevel = new QTreeWidgetItem(ui->toolbarTreeWidget); + bool active = hGrp->GetBool("Active", true); toplevel->setCheckState(0, (active ? Qt::Checked : Qt::Unchecked)); // get the elements of the subgroups - std::vector > items = (*it)->GetASCIIMap(); - for (std::vector >::iterator it2 = items.begin(); it2 != items.end(); ++it2) { + std::vector > items = hGrp->GetASCIIMap(); + for (const auto & it2 : items) { // since we have stored the separators to the user parameters as (key, pair) we had to // make sure to use a unique key because otherwise we cannot store more than // one. - if (it2->first.substr(0, separator.size()) == separator) { - QTreeWidgetItem* item = new QTreeWidgetItem(toplevel); + if (it2.first.substr(0, separator.size()) == separator) { + auto item = new QTreeWidgetItem(toplevel); item->setText(0, tr("")); item->setData(0, Qt::UserRole, QByteArray("Separator")); item->setSizeHint(0, QSize(32, 32)); } - else if (it2->first == "Name") { - QString toolbarName = QString::fromUtf8(it2->second.c_str()); + else if (it2.first == "Name") { + QString toolbarName = QString::fromUtf8(it2.second.c_str()); toplevel->setText(0, toolbarName); } else { - Command* pCmd = rMgr.getCommandByName(it2->first.c_str()); + Command* pCmd = rMgr.getCommandByName(it2.first.c_str()); if (pCmd) { // command name - QTreeWidgetItem* item = new QTreeWidgetItem(toplevel); + auto item = new QTreeWidgetItem(toplevel); item->setText(0, qApp->translate(pCmd->className(), pCmd->getMenuText())); - item->setData(0, Qt::UserRole, QByteArray(it2->first.c_str())); + item->setData(0, Qt::UserRole, QByteArray(it2.first.c_str())); if (pCmd->getPixmap()) item->setIcon(0, BitmapFactory().iconFromTheme(pCmd->getPixmap())); item->setSizeHint(0, QSize(32, 32)); } else { // If corresponding module is not yet loaded do not lose the entry - QTreeWidgetItem* item = new QTreeWidgetItem(toplevel); - item->setText(0, tr("%1 module not loaded").arg(QString::fromStdString(it2->second))); - item->setData(0, Qt::UserRole, QByteArray(it2->first.c_str())); - item->setData(0, Qt::WhatsThisPropertyRole, QByteArray(it2->second.c_str())); + auto item = new QTreeWidgetItem(toplevel); + item->setText(0, tr("%1 module not loaded").arg(QString::fromStdString(it2.second))); + item->setData(0, Qt::UserRole, QByteArray(it2.first.c_str())); + item->setData(0, Qt::WhatsThisPropertyRole, QByteArray(it2.second.c_str())); item->setSizeHint(0, QSize(32, 32)); } } @@ -355,7 +355,7 @@ void DlgCustomToolbars::on_moveActionRightButton_clicked() else if (current->parent()) current = current->parent(); if (current && !current->parent()) { - QTreeWidgetItem* copy = new QTreeWidgetItem(current); + auto copy = new QTreeWidgetItem(current); copy->setText(0, item->text(1)); copy->setIcon(0, item->icon(0)); QByteArray data = item->data(1, Qt::UserRole).toByteArray(); @@ -496,7 +496,7 @@ void DlgCustomToolbars::on_newButton_clicked() } } - QTreeWidgetItem* item = new QTreeWidgetItem(ui->toolbarTreeWidget); + auto item = new QTreeWidgetItem(ui->toolbarTreeWidget); item->setText(0, text); item->setCheckState(0, Qt::Checked); item->setExpanded(true); @@ -565,7 +565,7 @@ void DlgCustomToolbars::onAddMacroAction(const QByteArray& macro) CommandManager & cCmdMgr = Application::Instance->commandManager(); Command* pCmd = cCmdMgr.getCommandByName(macro); - QTreeWidgetItem* item = new QTreeWidgetItem(ui->commandTreeWidget); + auto item = new QTreeWidgetItem(ui->commandTreeWidget); item->setText(1, QString::fromUtf8(pCmd->getMenuText())); item->setToolTip(1, QString::fromUtf8(pCmd->getToolTipText())); item->setData(1, Qt::UserRole, macro); @@ -716,8 +716,8 @@ QList DlgCustomToolbarsImp::getActionGroup(QAction* action) { QList group; QList widgets = action->associatedWidgets(); - for (QList::iterator it = widgets.begin(); it != widgets.end(); ++it) { - QToolButton* tb = qobject_cast(*it); + for (const auto & widget : widgets) { + auto tb = qobject_cast(widget); if (tb) { QMenu* menu = tb->menu(); if (menu) { @@ -733,14 +733,14 @@ void DlgCustomToolbarsImp::setActionGroup(QAction* action, const QList { // See also ActionGroup::addTo() QList widgets = action->associatedWidgets(); - for (QList::iterator it = widgets.begin(); it != widgets.end(); ++it) { - QToolButton* tb = qobject_cast(*it); + for (const auto & widget : widgets) { + auto tb = qobject_cast(widget); if (tb) { QMenu* menu = tb->menu(); if (!menu) { tb->setPopupMode(QToolButton::MenuButtonPopup); tb->setObjectName(QString::fromLatin1("qt_toolbutton_menubutton")); - QMenu* menu = new QMenu(tb); + auto menu = new QMenu(tb); menu->addActions(group); tb->setMenu(menu); } @@ -791,14 +791,14 @@ void DlgCustomToolbarsImp::removeCustomCommand(const QString& name, const QByteA cmd = "Separator"; } QList actions = bars.front()->actions(); - for (QList::Iterator it = actions.begin(); it != actions.end(); ++it) { - if ((*it)->data().toByteArray() == cmd) { + for (const auto & action : actions) { + if (action->data().toByteArray() == cmd) { // if we move a separator then make sure to pick up the right one if (numSep > 0) { if (++indexSep < numSep) continue; } - bars.front()->removeAction(*it); + bars.front()->removeAction(action); break; } } @@ -822,26 +822,26 @@ void DlgCustomToolbarsImp::moveUpCustomCommand(const QString& name, const QByteA } QList actions = bars.front()->actions(); QAction* before=nullptr; - for (QList::Iterator it = actions.begin(); it != actions.end(); ++it) { - if ((*it)->data().toByteArray() == cmd) { + for (const auto & action : actions) { + if (action->data().toByteArray() == cmd) { // if we move a separator then make sure to pick up the right one if (numSep > 0) { if (++indexSep < numSep) { - before = *it; + before = action; continue; } } if (before) { - QList group = getActionGroup(*it); - bars.front()->removeAction(*it); - bars.front()->insertAction(before, *it); + QList group = getActionGroup(action); + bars.front()->removeAction(action); + bars.front()->insertAction(before, action); if (!group.isEmpty()) - setActionGroup(*it, group); + setActionGroup(action, group); break; } } - before = *it; + before = action; } } } diff --git a/src/Gui/DlgUndoRedo.cpp b/src/Gui/DlgUndoRedo.cpp index e0ca6df7cd..7d7910d3c6 100644 --- a/src/Gui/DlgUndoRedo.cpp +++ b/src/Gui/DlgUndoRedo.cpp @@ -74,7 +74,7 @@ void UndoDialog::onFetchInfo() /** Closes the dialog and sends the message 'Undo' to the currently active MDI view. */ void UndoDialog::onSelected() { - QAction* a = static_cast(sender()); + auto a = static_cast(sender()); QList acts = this->actions(); for (QList::Iterator it = acts.begin(); it != acts.end(); ++it) { Gui::Application::Instance->sendMsgToActiveView("Undo"); @@ -122,7 +122,7 @@ void RedoDialog::onFetchInfo() /** Closes the dialog and sends the message 'Redo' to the currently active MDI view. */ void RedoDialog::onSelected() { - QAction* a = static_cast(sender()); + auto a = static_cast(sender()); QList acts = this->actions(); for (QList::Iterator it = acts.begin(); it != acts.end(); ++it) { Gui::Application::Instance->sendMsgToActiveView("Redo"); diff --git a/src/Gui/DlgWorkbenchesImp.cpp b/src/Gui/DlgWorkbenchesImp.cpp index 9eeb066290..45da472f35 100644 --- a/src/Gui/DlgWorkbenchesImp.cpp +++ b/src/Gui/DlgWorkbenchesImp.cpp @@ -99,7 +99,7 @@ void DlgWorkbenchesImp::add_workbench(QListWidgetCustom *lw, const QString& it) { QPixmap px = Application::Instance->workbenchIcon(it); QString mt = Application::Instance->workbenchMenuText(it); - QListWidgetItem *wi = (new QListWidgetItem(QIcon(px), mt)); + auto wi = (new QListWidgetItem(QIcon(px), mt)); wi->setData(Qt::UserRole, QVariant(it)); lw->addItem(wi); } diff --git a/src/Gui/DockWindowManager.cpp b/src/Gui/DockWindowManager.cpp index 3a4bce1854..7a5b080c3d 100644 --- a/src/Gui/DockWindowManager.cpp +++ b/src/Gui/DockWindowManager.cpp @@ -131,7 +131,7 @@ QDockWidget* DockWindowManager::addDockWindow(const char* name, QWidget* widget, { // creates the dock widget as container to embed this widget MainWindow* mw = getMainWindow(); - QDockWidget* dw = new QDockWidget(mw); + auto dw = new QDockWidget(mw); // Note: By default all dock widgets are hidden but the user can show them manually in the view menu. // First, hide immediately the dock widget to avoid flickering, after setting up the dock widgets // MainWindow::loadLayoutSettings() is called to restore the layout. diff --git a/src/Gui/Document.cpp b/src/Gui/Document.cpp index 732348ae95..d8790be87f 100644 --- a/src/Gui/Document.cpp +++ b/src/Gui/Document.cpp @@ -258,8 +258,8 @@ Document::~Document() d->_isClosing = true; // calls Document::detachView() and alter the view list std::list temp = d->baseViews; - for(std::list::iterator it=temp.begin();it!=temp.end();++it) - (*it)->deleteSelf(); + for(auto & it : temp) + it->deleteSelf(); std::map::iterator jt; for (jt = d->_ViewProviderMap.begin();jt != d->_ViewProviderMap.end(); ++jt) @@ -281,7 +281,7 @@ Document::~Document() bool Document::setEdit(Gui::ViewProvider* p, int ModNum, const char *subname) { - ViewProviderDocumentObject* vp = dynamic_cast(p); + auto vp = dynamic_cast(p); if (!vp) { FC_ERR("cannot edit non ViewProviderDocumentObject"); return false; @@ -391,7 +391,7 @@ bool Document::setEdit(Gui::ViewProvider* p, int ModNum, const char *subname) } } - View3DInventor *view3d = dynamic_cast(getActiveView()); + auto view3d = dynamic_cast(getActiveView()); // if the currently active view is not the 3d view search for it and activate it if (view3d) getMainWindow()->setActiveWindow(view3d); @@ -452,7 +452,7 @@ const Base::Matrix4D &Document::getEditingTransform() const { void Document::setEditingTransform(const Base::Matrix4D &mat) { d->_editObjs.clear(); d->_editingTransform = mat; - View3DInventor *activeView = dynamic_cast(getActiveView()); + auto activeView = dynamic_cast(getActiveView()); if (activeView) activeView->getViewer()->setEditingTransform(mat); } @@ -466,7 +466,7 @@ void Document::_resetEdit() std::list::iterator it; if (d->_editViewProvider) { for (it = d->baseViews.begin();it != d->baseViews.end();++it) { - View3DInventor *activeView = dynamic_cast(*it); + auto activeView = dynamic_cast(*it); if (activeView) activeView->getViewer()->resetEditingViewProvider(); } @@ -508,7 +508,7 @@ ViewProvider *Document::getInEdit(ViewProviderDocumentObject **parentVp, if (d->_editViewProvider) { // there is only one 3d view which is in edit mode - View3DInventor *activeView = dynamic_cast(getActiveView()); + auto activeView = dynamic_cast(getActiveView()); if (activeView && activeView->getViewer()->isEditingViewProvider()) return d->_editViewProvider; } @@ -537,7 +537,7 @@ void Document::setAnnotationViewProvider(const char* name, ViewProvider *pcProvi // cycling to all views of the document for (vIt = d->baseViews.begin();vIt != d->baseViews.end();++vIt) { - View3DInventor *activeView = dynamic_cast(*vIt); + auto activeView = dynamic_cast(*vIt); if (activeView) activeView->getViewer()->addViewProvider(pcProvider); } @@ -556,7 +556,7 @@ void Document::removeAnnotationViewProvider(const char* name) // cycling to all views of the document for (vIt = d->baseViews.begin();vIt != d->baseViews.end();++vIt) { - View3DInventor *activeView = dynamic_cast(*vIt); + auto activeView = dynamic_cast(*vIt); if (activeView) activeView->getViewer()->removeViewProvider(it->second); } @@ -647,7 +647,7 @@ void Document::setPos(const char* name, const Base::Matrix4D& rclMtrx) //***************************************************************************************************** void Document::slotNewObject(const App::DocumentObject& Obj) { - ViewProviderDocumentObject* pcProvider = static_cast(getViewProvider(&Obj)); + auto pcProvider = static_cast(getViewProvider(&Obj)); if (!pcProvider) { //Base::Console().Log("Document::slotNewObject() called\n"); std::string cName = Obj.getViewProviderNameStored(); @@ -710,7 +710,7 @@ void Document::slotNewObject(const App::DocumentObject& Obj) std::list::iterator vIt; // cycling to all views of the document for (vIt = d->baseViews.begin();vIt != d->baseViews.end();++vIt) { - View3DInventor *activeView = dynamic_cast(*vIt); + auto activeView = dynamic_cast(*vIt); if (activeView) activeView->getViewer()->addViewProvider(pcProvider); } @@ -753,7 +753,7 @@ void Document::slotDeletedObject(const App::DocumentObject& Obj) (ViewProviderDocumentObject::getClassTypeId())) { // go through the views for (vIt = d->baseViews.begin();vIt != d->baseViews.end();++vIt) { - View3DInventor *activeView = dynamic_cast(*vIt); + auto activeView = dynamic_cast(*vIt); if (activeView) activeView->getViewer()->removeViewProvider(viewProvider); } @@ -959,8 +959,8 @@ void Document::setModified(bool b) d->_isModified = b; std::list mdis = getMDIViews(); - for (std::list::iterator it = mdis.begin(); it != mdis.end(); ++it) { - (*it)->setWindowModified(b); + for (auto & mdi : mdis) { + mdi->setWindowModified(b); } } @@ -1350,9 +1350,9 @@ void Document::Save (Base::Writer &writer) const int size = hGrp->GetInt("ThumbnailSize", 128); size = Base::clamp(size, 64, 512); std::list mdi = getMDIViews(); - for (std::list::iterator it = mdi.begin(); it != mdi.end(); ++it) { - if ((*it)->getTypeId().isDerivedFrom(View3DInventor::getClassTypeId())) { - View3DInventorViewer* view = static_cast(*it)->getViewer(); + for (const auto & it : mdi) { + if (it->getTypeId().isDerivedFrom(View3DInventor::getClassTypeId())) { + View3DInventorViewer* view = static_cast(it)->getViewer(); d->thumb.setFileName(d->_pcDocument->FileName.getValue()); d->thumb.setSize(size); d->thumb.setViewer(view); @@ -1424,7 +1424,7 @@ void Document::RestoreDocFile(Base::Reader &reader) if (pObj) // check if this feature has been registered pObj->Restore(*localreader); if (pObj && expanded) { - Gui::ViewProviderDocumentObject* vp = static_cast(pObj); + auto vp = static_cast(pObj); this->signalExpandObject(*vp, TreeItemMode::ExpandItem,0,0); } localreader->readEndElement("ViewProvider"); @@ -1440,9 +1440,9 @@ void Document::RestoreDocFile(Base::Reader &reader) try { const char** pReturnIgnore=nullptr; std::list mdi = getMDIViews(); - for (std::list::iterator it = mdi.begin(); it != mdi.end(); ++it) { - if ((*it)->onHasMsg("SetCamera")) - (*it)->onMsg(cameraSettings.c_str(), pReturnIgnore); + for (const auto & it : mdi) { + if (it->onHasMsg("SetCamera")) + it->onMsg(cameraSettings.c_str(), pReturnIgnore); } } catch (const Base::Exception& e) { @@ -1558,10 +1558,10 @@ void Document::SaveDocFile (Base::Writer &writer) const // save camera settings std::list mdi = getMDIViews(); - for (std::list::iterator it = mdi.begin(); it != mdi.end(); ++it) { - if ((*it)->onHasMsg("GetCamera")) { + for (const auto & it : mdi) { + if (it->onHasMsg("GetCamera")) { const char* ppReturn=nullptr; - (*it)->onMsg("GetCamera",&ppReturn); + it->onMsg("GetCamera",&ppReturn); if(saveCameraSettings(ppReturn)) break; } @@ -1580,11 +1580,11 @@ void Document::exportObjects(const std::vector& obj, Base: writer.Stream() << "" << std::endl; std::map views; - for (std::vector::const_iterator it = obj.begin(); it != obj.end(); ++it) { - Document* doc = Application::Instance->getDocument((*it)->getDocument()); + for (const auto & it : obj) { + Document* doc = Application::Instance->getDocument(it->getDocument()); if (doc) { - ViewProvider* vp = doc->getViewProvider(*it); - if (vp) views[*it] = vp; + ViewProvider* vp = doc->getViewProvider(it); + if (vp) views[it] = vp; } } @@ -1637,14 +1637,14 @@ void Document::importObjects(const std::vector& obj, Base: // read the viewproviders itself localreader->readElement("ViewProviderData"); int Cnt = localreader->getAttributeAsInteger("Count"); - std::vector::const_iterator it = obj.begin(); + auto it = obj.begin(); for (int i=0;ireadElement("ViewProvider"); std::string name = localreader->getAttribute("name"); - std::map::const_iterator jt = nameMapping.find(name); + auto jt = nameMapping.find(name); if (jt != nameMapping.end()) name = jt->second; bool expanded = false; @@ -1694,16 +1694,16 @@ void Document::slotFinishImportObjects(const std::vector & void Document::addRootObjectsToGroup(const std::vector& obj, App::DocumentObjectGroup* grp) { std::map rootMap; - for (std::vector::const_iterator it = obj.begin(); it != obj.end(); ++it) { - rootMap[*it] = true; + for (const auto it : obj) { + rootMap[it] = true; } // get the view providers and check which objects are children - for (std::vector::const_iterator it = obj.begin(); it != obj.end(); ++it) { - Gui::ViewProvider* vp = getViewProvider(*it); + for (const auto it : obj) { + Gui::ViewProvider* vp = getViewProvider(it); if (vp) { std::vector child = vp->claimChildren(); - for (std::vector::iterator jt = child.begin(); jt != child.end(); ++jt) { - std::map::iterator kt = rootMap.find(*jt); + for (const auto & jt : child) { + auto kt = rootMap.find(jt); if (kt != rootMap.end()) { kt->second = false; } @@ -1712,9 +1712,9 @@ void Document::addRootObjectsToGroup(const std::vector& ob } // all objects that are not children of other objects can be added to the group - for (std::map::iterator it = rootMap.begin(); it != rootMap.end(); ++it) { - if (it->second) - grp->addObject(it->first); + for (const auto & it : rootMap) { + if (it.second) + grp->addObject(it.first); } } @@ -1729,7 +1729,7 @@ MDIView *Document::createView(const Base::Type& typeId) QtGLWidget* shareWidget = nullptr; // VBO rendering doesn't work correctly when we don't share the OpenGL widgets if (!theViews.empty()) { - View3DInventor* firstView = static_cast(theViews.front()); + auto firstView = static_cast(theViews.front()); shareWidget = qobject_cast(firstView->getViewer()->getGLWidget()); const char *ppReturn = nullptr; @@ -1737,9 +1737,9 @@ MDIView *Document::createView(const Base::Type& typeId) saveCameraSettings(ppReturn); } - View3DInventor* view3D = new View3DInventor(this, getMainWindow(), shareWidget); + auto view3D = new View3DInventor(this, getMainWindow(), shareWidget); if (!theViews.empty()) { - View3DInventor* firstView = static_cast(theViews.front()); + auto firstView = static_cast(theViews.front()); std::string overrideMode = firstView->getViewer()->getOverrideMode(); view3D->getViewer()->setOverrideMode(overrideMode); } @@ -1791,9 +1791,9 @@ Gui::MDIView* Document::cloneView(Gui::MDIView* oldview) return nullptr; if (oldview->getTypeId() == View3DInventor::getClassTypeId()) { - View3DInventor* view3D = new View3DInventor(this, getMainWindow()); + auto view3D = new View3DInventor(this, getMainWindow()); - View3DInventor* firstView = static_cast(oldview); + auto firstView = static_cast(oldview); std::string overrideMode = firstView->getViewer()->getOverrideMode(); view3D->getViewer()->setOverrideMode(overrideMode); @@ -2036,7 +2036,7 @@ std::list Document::getMDIViews() const std::list views; for (std::list::const_iterator it = d->baseViews.begin(); it != d->baseViews.end(); ++it) { - MDIView* view = dynamic_cast(*it); + auto view = dynamic_cast(*it); if (view) views.push_back(view); } @@ -2049,7 +2049,7 @@ std::list Document::getMDIViewsOfType(const Base::Type& typeId) const std::list views; for (std::list::const_iterator it = d->baseViews.begin(); it != d->baseViews.end(); ++it) { - MDIView* view = dynamic_cast(*it); + auto view = dynamic_cast(*it); if (view && view->isDerivedFrom(typeId)) views.push_back(view); } @@ -2089,8 +2089,8 @@ bool Document::sendMsgToFirstView(const Base::Type& typeId, const char* pMsg, co // now try the other views std::list views = getMDIViewsOfType(typeId); - for (std::list::iterator it = views.begin(); it != views.end(); ++it) { - if ((*it != view) && (*it)->onMsg(pMsg, ppReturn)) { + for (const auto & it : views) { + if ((it != view) && it->onMsg(pMsg, ppReturn)) { return true; } } @@ -2109,8 +2109,8 @@ MDIView* Document::getActiveView() const // check whether the active view is part of this document bool ok=false; - for (std::list::const_iterator it = mdis.begin(); it != mdis.end(); ++it) { - if ((*it) == active) { + for (const auto & mdi : mdis) { + if (mdi == active) { ok = true; break; } @@ -2218,10 +2218,10 @@ void Document::setActiveWindow(Gui::MDIView* view) Gui::MDIView* Document::getViewOfNode(SoNode* node) const { std::list mdis = getMDIViewsOfType(View3DInventor::getClassTypeId()); - for (std::list::const_iterator it = mdis.begin(); it != mdis.end(); ++it) { - View3DInventor* view = static_cast(*it); + for (const auto & mdi : mdis) { + auto view = static_cast(mdi); if (view->getViewer()->searchNode(node)) - return *it; + return mdi; } return nullptr; @@ -2235,12 +2235,12 @@ Gui::MDIView* Document::getViewOfViewProvider(const Gui::ViewProvider* vp) const Gui::MDIView* Document::getEditingViewOfViewProvider(Gui::ViewProvider* vp) const { std::list mdis = getMDIViewsOfType(View3DInventor::getClassTypeId()); - for (std::list::const_iterator it = mdis.begin(); it != mdis.end(); ++it) { - View3DInventor* view = static_cast(*it); + for (const auto & mdi : mdis) { + auto view = static_cast(mdi); View3DInventorViewer* viewer = view->getViewer(); // there is only one 3d view which is in edit mode if (viewer->hasViewProvider(vp) && viewer->isEditingViewProvider()) - return *it; + return mdi; } return nullptr; @@ -2415,8 +2415,8 @@ void Document::handleChildren3D(ViewProvider* viewProvider, bool deleting) Gui::coinRemoveAllChildren(backGroup); if(!deleting) { - for (std::vector::iterator it=children.begin();it!=children.end();++it) { - ViewProvider* ChildViewProvider = getViewProvider(*it); + for (const auto & it : children) { + ViewProvider* ChildViewProvider = getViewProvider(it); if (ChildViewProvider) { auto itOld = oldChildren.find(static_cast(ChildViewProvider)); if(itOld!=oldChildren.end()) oldChildren.erase(itOld); @@ -2434,7 +2434,7 @@ void Document::handleChildren3D(ViewProvider* viewProvider, bool deleting) // cycling to all views of the document to remove the viewprovider from the viewer itself for (std::list::iterator vIt = d->baseViews.begin();vIt != d->baseViews.end();++vIt) { - View3DInventor *activeView = dynamic_cast(*vIt); + auto activeView = dynamic_cast(*vIt); if (activeView && activeView->getViewer()->hasViewProvider(ChildViewProvider)) { // @Note hasViewProvider() // remove the viewprovider serves the purpose of detaching the inventor nodes from the @@ -2454,7 +2454,7 @@ void Document::handleChildren3D(ViewProvider* viewProvider, bool deleting) continue; for (BaseView* view : d->baseViews) { - View3DInventor *activeView = dynamic_cast(view); + auto activeView = dynamic_cast(view); if (activeView && !activeView->getViewer()->hasViewProvider(vpd)) activeView->getViewer()->addViewProvider(vpd); } @@ -2468,7 +2468,7 @@ void Document::toggleInSceneGraph(ViewProvider *vp) // FIXME: What's the point of having this function? // for (auto view : d->baseViews) { - View3DInventor *activeView = dynamic_cast(view); + auto activeView = dynamic_cast(view); if (!activeView) continue; diff --git a/src/Gui/DocumentModel.cpp b/src/Gui/DocumentModel.cpp index 5cc4c66c59..52d0f1de67 100644 --- a/src/Gui/DocumentModel.cpp +++ b/src/Gui/DocumentModel.cpp @@ -178,7 +178,7 @@ namespace Gui { int child=0; QList::const_iterator it; for (it = childItems.begin(); it != childItems.end(); ++it, ++child) { - DocumentIndex* doc = static_cast(*it); + auto doc = static_cast(*it); if (&doc->d == &d) return child; } @@ -237,7 +237,7 @@ namespace Gui { { QList::const_iterator it; for (it = childItems.begin(); it != childItems.end(); ++it) { - ViewProviderIndex* v = static_cast(*it); + auto v = static_cast(*it); v->findViewProviders(vp, index); } } @@ -247,7 +247,7 @@ namespace Gui { QList::const_iterator it; int index=0; for (it = childItems.begin(); it != childItems.end(); ++it, ++index) { - ViewProviderIndex* v = static_cast(*it); + auto v = static_cast(*it); if (&v->v == &vp) return index; } @@ -291,9 +291,9 @@ namespace Gui { ViewProviderIndex* ViewProviderIndex::clone() const { - ViewProviderIndex* copy = new ViewProviderIndex(this->v, this->d); - for (QList::const_iterator it = childItems.begin(); it != childItems.end(); ++it) { - ViewProviderIndex* c = static_cast(*it)->clone(); + auto copy = new ViewProviderIndex(this->v, this->d); + for (const auto & childItem : childItems) { + ViewProviderIndex* c = static_cast(childItem)->clone(); copy->appendChild(c); } return copy; @@ -306,7 +306,7 @@ namespace Gui { index.push_back(const_cast(this)); QList::const_iterator it; for (it = childItems.begin(); it != childItems.end(); ++it) { - ViewProviderIndex* v = static_cast(*it); + auto v = static_cast(*it); v->findViewProviders(vp, index); } } @@ -448,7 +448,7 @@ void DocumentModel::slotNewObject(const Gui::ViewProviderDocumentObject& obj) Gui::Document* gdc = Application::Instance->getDocument(doc); int row = d->rootItem->findChild(*gdc); if (row > -1) { - DocumentIndex* index = static_cast(d->rootItem->child(row)); + auto index = static_cast(d->rootItem->child(row)); QModelIndex parent = createIndex(index->row(),0,index); int count_obj = index->childCount(); beginInsertRows(parent, count_obj, count_obj); @@ -463,16 +463,16 @@ void DocumentModel::slotDeleteObject(const Gui::ViewProviderDocumentObject& obj) Gui::Document* gdc = Application::Instance->getDocument(doc); int row = d->rootItem->findChild(*gdc); if (row > -1) { - DocumentIndex* doc_index = static_cast(d->rootItem->child(row)); + auto doc_index = static_cast(d->rootItem->child(row)); QList views; doc_index->findViewProviders(obj, views); - for (QList::iterator it = views.begin(); it != views.end(); ++it) { - DocumentModelIndex* parentitem = (*it)->parent(); + for (auto & view : views) { + DocumentModelIndex* parentitem = view->parent(); QModelIndex parent = createIndex(doc_index->row(), 0, parentitem); - int row = (*it)->row(); + int row = view->row(); beginRemoveRows(parent, row, row); parentitem->removeChild(row); - delete *it; + delete view; endRemoveRows(); } } @@ -486,13 +486,13 @@ void DocumentModel::slotChangeObject(const Gui::ViewProviderDocumentObject& obj, Gui::Document* gdc = Application::Instance->getDocument(doc); int row = d->rootItem->findChild(*gdc); if (row > -1) { - DocumentIndex* doc_index = static_cast(d->rootItem->child(row)); + auto doc_index = static_cast(d->rootItem->child(row)); QList views; doc_index->findViewProviders(obj, views); - for (QList::iterator it = views.begin(); it != views.end(); ++it) { - DocumentModelIndex* parentitem = (*it)->parent(); + for (const auto & view : views) { + DocumentModelIndex* parentitem = view->parent(); QModelIndex parent = createIndex(0,0,parentitem); - int row = (*it)->row(); + int row = view->row(); QModelIndex item = index (row, 0, parent); Q_EMIT dataChanged(item, item); } @@ -506,9 +506,9 @@ void DocumentModel::slotChangeObject(const Gui::ViewProviderDocumentObject& obj, int row = d->rootItem->findChild(*gdc); if (row > -1) { QList del_items; - DocumentIndex* doc_index = static_cast(d->rootItem->child(row)); - for (std::vector::iterator vp = views.begin(); vp != views.end(); ++vp) { - int row = doc_index->rowOfViewProvider(**vp); + auto doc_index = static_cast(d->rootItem->child(row)); + for (const auto & view : views) { + int row = doc_index->rowOfViewProvider(*view); // is it a top-level child in the document if (row >= 0) { DocumentModelIndex* child = doc_index->child(row); @@ -523,18 +523,18 @@ void DocumentModel::slotChangeObject(const Gui::ViewProviderDocumentObject& obj, // get all occurrences of the view provider in the tree structure QList obj_index; doc_index->findViewProviders(obj, obj_index); - for (QList::iterator it = obj_index.begin(); it != obj_index.end(); ++it) { - QModelIndex parent = createIndex((*it)->row(),0,*it); - int count_obj = (*it)->childCount(); + for (const auto & it : obj_index) { + QModelIndex parent = createIndex(it->row(),0,it); + int count_obj = it->childCount(); beginRemoveRows(parent, 0, count_obj); // remove all children but do not yet delete them - QList items = (*it)->removeAll(); + QList items = it->removeAll(); endRemoveRows(); beginInsertRows(parent, 0, (int)views.size()); - for (std::vector::iterator vp = views.begin(); vp != views.end(); ++vp) { - ViewProviderIndex* clone = doc_index->cloneViewProvider(**vp); - (*it)->appendChild(clone); + for (const auto & view : views) { + ViewProviderIndex* clone = doc_index->cloneViewProvider(*view); + it->appendChild(clone); } endInsertRows(); @@ -591,8 +591,8 @@ DocumentModel::claimChildren(const Gui::Document& doc, const ViewProviderDocumen { std::vector views; std::vector childs = obj.claimChildren(); - for (std::vector::iterator it = childs.begin(); it != childs.end(); ++it) { - ViewProvider* view = doc.getViewProvider(*it); + for (const auto & child : childs) { + ViewProvider* view = doc.getViewProvider(child); if (view && view->getTypeId().isDerivedFrom(ViewProviderDocumentObject::getClassTypeId())) views.push_back(static_cast(view)); } diff --git a/src/Gui/DocumentPyImp.cpp b/src/Gui/DocumentPyImp.cpp index 7e520d4a09..e31e3bb0e7 100644 --- a/src/Gui/DocumentPyImp.cpp +++ b/src/Gui/DocumentPyImp.cpp @@ -179,7 +179,7 @@ PyObject* DocumentPy::addAnnotation(PyObject *args) return nullptr; PY_TRY { - ViewProviderExtern *pcExt = new ViewProviderExtern(); + auto pcExt = new ViewProviderExtern(); pcExt->setModeByFile(psModName ? psModName : "Main", psFileName); pcExt->adjustDocumentName(getDocumentPtr()->getDocument()->getName()); @@ -269,7 +269,7 @@ PyObject* DocumentPy::mdiViewsOfType(PyObject *args) PY_TRY { std::list views = getDocumentPtr()->getMDIViewsOfType(type); Py::List list; - for (std::list::iterator it = views.begin(); it != views.end(); ++it) + for (auto it = views.begin(); it != views.end(); ++it) list.append(Py::asObject((*it)->getPyObject())); return Py::new_reference_to(list); } @@ -331,7 +331,7 @@ PyObject* DocumentPy::toggleTreeItem(PyObject *args) // get the gui document of the Assembly Item //ActiveAppDoc = Item->getDocument(); //ActiveGuiDoc = Gui::Application::Instance->getDocument(getDocumentPtr()); - Gui::ViewProviderDocumentObject* ActiveVp = dynamic_cast(getDocumentPtr()->getViewProvider(Object)); + auto ActiveVp = dynamic_cast(getDocumentPtr()->getViewProvider(Object)); switch (mod) { case 0: getDocumentPtr()->signalExpandObject(*ActiveVp, TreeItemMode::ToggleItem, parent, subname); diff --git a/src/Gui/DocumentRecovery.cpp b/src/Gui/DocumentRecovery.cpp index 6282259b4d..c080a727ac 100644 --- a/src/Gui/DocumentRecovery.cpp +++ b/src/Gui/DocumentRecovery.cpp @@ -186,7 +186,7 @@ DocumentRecovery::DocumentRecovery(const QList& dirs, QWidget* parent if (info.status == DocumentRecoveryPrivate::Created) { d_ptr->recoveryInfo << info; - QTreeWidgetItem* item = new QTreeWidgetItem(d_ptr->ui.treeWidget); + auto item = new QTreeWidgetItem(d_ptr->ui.treeWidget); item->setText(0, info.label); item->setToolTip(0, info.tooltip); item->setText(1, tr("Not yet recovered")); diff --git a/src/Gui/DownloadItem.cpp b/src/Gui/DownloadItem.cpp index 35fb3ecf97..db886c086c 100644 --- a/src/Gui/DownloadItem.cpp +++ b/src/Gui/DownloadItem.cpp @@ -165,7 +165,7 @@ NetworkAccessManager::NetworkAccessManager(QObject *parent) connect(this, SIGNAL(proxyAuthenticationRequired(const QNetworkProxy&, QAuthenticator*)), SLOT(proxyAuthenticationRequired(const QNetworkProxy&, QAuthenticator*))); - QNetworkDiskCache *diskCache = new QNetworkDiskCache(this); + auto diskCache = new QNetworkDiskCache(this); QString location = QStandardPaths::writableLocation(QStandardPaths::CacheLocation); diskCache->setCacheDirectory(location); setCache(diskCache); diff --git a/src/Gui/DownloadManager.cpp b/src/Gui/DownloadManager.cpp index 05ed7b4064..a4a62c569d 100644 --- a/src/Gui/DownloadManager.cpp +++ b/src/Gui/DownloadManager.cpp @@ -161,7 +161,7 @@ void DownloadManager::handleUnsupportedContent(QNetworkReply *reply, bool reques if (ok && size == 0) return; - DownloadItem *item = new DownloadItem(reply, requestFileName, this); + auto item = new DownloadItem(reply, requestFileName, this); addItem(item); } @@ -182,7 +182,7 @@ void DownloadManager::addItem(DownloadItem *item) void DownloadManager::updateRow() { - DownloadItem *item = qobject_cast(sender()); + auto item = qobject_cast(sender()); int row = m_downloads.indexOf(item); if (-1 == row) return; @@ -264,7 +264,7 @@ void DownloadManager::load() QString fileName = settings.value(key + QLatin1String("location")).toString(); bool done = settings.value(key + QLatin1String("done"), true).toBool(); if (!url.isEmpty() && !fileName.isEmpty()) { - DownloadItem *item = new DownloadItem(nullptr, false, this); + auto item = new DownloadItem(nullptr, false, this); item->m_output.setFileName(fileName); item->fileNameLabel->setText(QFileInfo(item->m_output.fileName()).fileName()); item->m_url = url; diff --git a/src/Gui/EditorView.cpp b/src/Gui/EditorView.cpp index f8449620ba..003e9ad7ef 100644 --- a/src/Gui/EditorView.cpp +++ b/src/Gui/EditorView.cpp @@ -110,10 +110,10 @@ EditorView::EditorView(QPlainTextEdit* editor, QWidget* parent) connect(editor, SIGNAL(findPrevious()), d->searchBar, SLOT(findPrevious())); // Create the layout containing the workspace and a tab bar - QFrame* hbox = new QFrame(this); + auto hbox = new QFrame(this); hbox->setFrameShape(QFrame::StyledPanel); hbox->setFrameShadow(QFrame::Sunken); - QVBoxLayout* layout = new QVBoxLayout(); + auto layout = new QVBoxLayout(); layout->setMargin(1); layout->addWidget(d->textEdit); layout->addWidget(d->searchBar); diff --git a/src/Gui/ExpressionBindingPy.cpp b/src/Gui/ExpressionBindingPy.cpp index f8e7a5e5c4..5c98dc9ab2 100644 --- a/src/Gui/ExpressionBindingPy.cpp +++ b/src/Gui/ExpressionBindingPy.cpp @@ -64,12 +64,12 @@ PyObject *ExpressionBindingPy::PyMake(struct _typeobject *, PyObject * args, PyO QWidget* obj = dynamic_cast(wrap.toQObject(Py::Object(pyObj))); if (obj) { do { - QuantitySpinBox* qsb = qobject_cast(obj); + auto qsb = qobject_cast(obj); if (qsb) { expr = qsb; break; } - InputField* inp = qobject_cast(obj); + auto inp = qobject_cast(obj); if (inp) { expr = inp; break; diff --git a/src/Gui/ExpressionCompleter.cpp b/src/Gui/ExpressionCompleter.cpp index d6c6f3b45e..72dc442610 100644 --- a/src/Gui/ExpressionCompleter.cpp +++ b/src/Gui/ExpressionCompleter.cpp @@ -406,7 +406,7 @@ QStringList ExpressionCompleter::splitPath ( const QString & input ) const currentObj.getObject(), path); std::vector sl = p.getStringList(); - std::vector::const_iterator sli = sl.begin(); + auto sli = sl.begin(); if(retry && !sl.empty()) sl.pop_back(); if(!trim.empty() && boost::ends_with(sl.back(),trim)) @@ -779,7 +779,7 @@ void ExpressionTextEdit::contextMenuEvent(QContextMenuEvent *event) ExpressionParameter* ExpressionParameter::instance() { - static ExpressionParameter* inst = new ExpressionParameter(); + static auto inst = new ExpressionParameter(); return inst; } diff --git a/src/Gui/FileDialog.cpp b/src/Gui/FileDialog.cpp index 642414744e..36a4f5a0d5 100644 --- a/src/Gui/FileDialog.cpp +++ b/src/Gui/FileDialog.cpp @@ -119,8 +119,7 @@ bool FileDialog::hasSuffix(const QString& ext) const QRegExp rx(QString::fromLatin1("\\*.(%1)\\W").arg(ext)); rx.setCaseSensitivity(Qt::CaseInsensitive); QStringList filters = nameFilters(); - for (QStringList::iterator it = filters.begin(); it != filters.end(); ++it) { - QString str = *it; + for (const auto & str : filters) { if (rx.indexIn(str) != -1) { return true; } @@ -144,7 +143,7 @@ void FileDialog::accept() if (!ext.isEmpty() && (suffix.isEmpty() || !hasSuffix(suffix))) { file = QString::fromLatin1("%1.%2").arg(file, ext); // That's the built-in line edit - QLineEdit* fileNameEdit = this->findChild(QString::fromLatin1("fileNameEdit")); + auto fileNameEdit = this->findChild(QString::fromLatin1("fileNameEdit")); if (fileNameEdit) fileNameEdit->setText(file); } @@ -354,8 +353,8 @@ QStringList FileDialog::getOpenFileNames (QWidget * parent, const QString & capt } else { files = QFileDialog::getOpenFileNames(parent, windowTitle, dirName, filter, selectedFilter, options); - for (QStringList::iterator it = files.begin(); it != files.end(); ++it) { - *it = QDir::fromNativeSeparators(*it); + for (auto & file : files) { + file = QDir::fromNativeSeparators(file); } } @@ -443,7 +442,7 @@ FileOptionsDialog::FileOptionsDialog( QWidget* parent, Qt::WindowFlags fl ) //box->addButton(extensionButton, QDialogButtonBox::ActionRole); //search for the grid layout and add the new button - QGridLayout* grid = this->findChild(); + auto grid = this->findChild(); grid->addWidget(extensionButton, 4, 2, Qt::AlignLeft); connect(extensionButton, SIGNAL(clicked()), this, SLOT(toggleExtension())); @@ -456,7 +455,7 @@ FileOptionsDialog::~FileOptionsDialog() void FileOptionsDialog::accept() { // Fixes a bug of the default implementation when entering an asterisk - QLineEdit* filename = this->findChild(); + auto filename = this->findChild(); QString fn = filename->text(); if (fn.startsWith(QLatin1String("*"))) { QFileInfo fi(fn); @@ -466,9 +465,9 @@ void FileOptionsDialog::accept() bool ok=false; // Compare the given suffix with the suffixes of all filters QString filter; - for (QStringList::ConstIterator it = filters.cbegin(); it != filters.cend(); ++it) { - if ((*it).contains(ext)) { - filter = *it; + for (const auto & it : filters) { + if (it.contains(ext)) { + filter = it; ok = true; break; } @@ -502,7 +501,7 @@ void FileOptionsDialog::accept() fn = QString::fromLatin1("%1.%2").arg(fn, suf); selectFile(fn); // That's the built-in line edit (fixes Debian bug #811200) - QLineEdit* fileNameEdit = this->findChild(QString::fromLatin1("fileNameEdit")); + auto fileNameEdit = this->findChild(QString::fromLatin1("fileNameEdit")); if (fileNameEdit) fileNameEdit->setText(fn); } @@ -543,7 +542,7 @@ void FileOptionsDialog::setOptionsWidget(FileOptionsDialog::ExtensionPosition po if (extensionWidget->parentWidget() != this) extensionWidget->setParent(this); - QGridLayout* grid = this->findChild(); + auto grid = this->findChild(); if (extensionPos == ExtensionRight) { int cols = grid->columnCount(); @@ -654,7 +653,7 @@ FileChooser::FileChooser ( QWidget * parent ) , accMode( AcceptOpen ) , _filter( QString() ) { - QHBoxLayout *layout = new QHBoxLayout( this ); + auto layout = new QHBoxLayout( this ); layout->setMargin( 0 ); layout->setSpacing( 2 ); @@ -857,7 +856,7 @@ SelectModule::SelectModule (const QString& type, const SelectModule::Dict& types int index = 0; for (SelectModule::Dict::const_iterator it = types.begin(); it != types.end(); ++it) { - QRadioButton* button = new QRadioButton(groupBox); + auto button = new QRadioButton(groupBox); QRegExp rx; QString filter = it.key(); @@ -953,8 +952,8 @@ SelectModule::Dict SelectModule::exportHandler(const QStringList& fileNames, con it = filterList.find((const char*)filter.toUtf8()); if (it != filterList.end()) { QString module = QString::fromLatin1(it->second.c_str()); - for (QStringList::const_iterator it = fileNames.begin(); it != fileNames.end(); ++it) { - dict[*it] = module; + for (const auto & fileName : fileNames) { + dict[fileName] = module; } return dict; } @@ -964,8 +963,8 @@ SelectModule::Dict SelectModule::exportHandler(const QStringList& fileNames, con // handled by more than one module and ask to the user to select one. QMap filetypeHandler; QMap fileExtension; - for (QStringList::const_iterator it = fileNames.begin(); it != fileNames.end(); ++it) { - QFileInfo fi(*it); + for (const auto & fileName : fileNames) { + QFileInfo fi(fileName); QString ext = fi.completeSuffix().toLower(); std::map filters = App::GetApplication().getExportFilters(ext.toLatin1()); @@ -974,12 +973,12 @@ SelectModule::Dict SelectModule::exportHandler(const QStringList& fileNames, con filters = App::GetApplication().getExportFilters(ext.toLatin1()); } - fileExtension[ext].push_back(*it); - for (std::map::iterator jt = filters.begin(); jt != filters.end(); ++jt) - filetypeHandler[ext][QString::fromUtf8(jt->first.c_str())] = QString::fromLatin1(jt->second.c_str()); + fileExtension[ext].push_back(fileName); + for (const auto & filter : filters) + filetypeHandler[ext][QString::fromUtf8(filter.first.c_str())] = QString::fromLatin1(filter.second.c_str()); // set the default module handler if (!filters.empty()) - dict[*it] = QString::fromLatin1(filters.begin()->second.c_str()); + dict[fileName] = QString::fromLatin1(filters.begin()->second.c_str()); } for (QMap::const_iterator it = filetypeHandler.cbegin(); @@ -990,8 +989,8 @@ SelectModule::Dict SelectModule::exportHandler(const QStringList& fileNames, con if (dlg.exec()) { QString mod = dlg.getModule(); const QStringList& files = fileExtension[it.key()]; - for (QStringList::const_iterator jt = files.begin(); jt != files.end(); ++jt) - dict[*jt] = mod; + for (const auto & file : files) + dict[file] = mod; } } } @@ -1015,8 +1014,8 @@ SelectModule::Dict SelectModule::importHandler(const QStringList& fileNames, con it = filterList.find((const char*)filter.toUtf8()); if (it != filterList.end()) { QString module = QString::fromLatin1(it->second.c_str()); - for (QStringList::const_iterator it = fileNames.begin(); it != fileNames.end(); ++it) { - dict[*it] = module; + for (const auto & fileName : fileNames) { + dict[fileName] = module; } return dict; } @@ -1026,8 +1025,8 @@ SelectModule::Dict SelectModule::importHandler(const QStringList& fileNames, con // handled by more than one module and ask to the user to select one. QMap filetypeHandler; QMap fileExtension; - for (QStringList::const_iterator it = fileNames.begin(); it != fileNames.end(); ++it) { - QFileInfo fi(*it); + for (const auto & fileName : fileNames) { + QFileInfo fi(fileName); QString ext = fi.completeSuffix().toLower(); std::map filters = App::GetApplication().getImportFilters(ext.toLatin1()); @@ -1036,12 +1035,12 @@ SelectModule::Dict SelectModule::importHandler(const QStringList& fileNames, con filters = App::GetApplication().getImportFilters(ext.toLatin1()); } - fileExtension[ext].push_back(*it); - for (std::map::iterator jt = filters.begin(); jt != filters.end(); ++jt) - filetypeHandler[ext][QString::fromUtf8(jt->first.c_str())] = QString::fromLatin1(jt->second.c_str()); + fileExtension[ext].push_back(fileName); + for (const auto & filter : filters) + filetypeHandler[ext][QString::fromUtf8(filter.first.c_str())] = QString::fromLatin1(filter.second.c_str()); // set the default module handler if (!filters.empty()) - dict[*it] = QString::fromLatin1(filters.begin()->second.c_str()); + dict[fileName] = QString::fromLatin1(filters.begin()->second.c_str()); } for (QMap::const_iterator it = filetypeHandler.cbegin(); @@ -1052,8 +1051,8 @@ SelectModule::Dict SelectModule::importHandler(const QStringList& fileNames, con if (dlg.exec()) { QString mod = dlg.getModule(); const QStringList& files = fileExtension[it.key()]; - for (QStringList::const_iterator jt = files.begin(); jt != files.end(); ++jt) - dict[*jt] = mod; + for (const auto & file : files) + dict[file] = mod; } } } diff --git a/src/Gui/Flag.cpp b/src/Gui/Flag.cpp index 34713a4a25..109c2d431d 100644 --- a/src/Gui/Flag.cpp +++ b/src/Gui/Flag.cpp @@ -134,7 +134,7 @@ void Flag::mouseMoveEvent(QMouseEvent *e) if (e->buttons() & Qt::LeftButton) { move(e->globalPos() - dragPosition); e->accept(); - View3DInventorViewer* viewer = dynamic_cast(parentWidget()); + auto viewer = dynamic_cast(parentWidget()); if (viewer) viewer->getSoRenderManager()->scheduleRedraw(); } diff --git a/src/Gui/GLBuffer.cpp b/src/Gui/GLBuffer.cpp index 11c72c36b3..390dabec60 100644 --- a/src/Gui/GLBuffer.cpp +++ b/src/Gui/GLBuffer.cpp @@ -169,7 +169,7 @@ int OpenGLBuffer::size() const void OpenGLBuffer::context_destruction_cb(uint32_t context, void * userdata) { - OpenGLBuffer * self = static_cast(userdata); + auto self = static_cast(userdata); if (self->context == context && self->bufferId) { const cc_glglue * glue = cc_glglue_instance((int) context); @@ -183,7 +183,7 @@ void OpenGLBuffer::context_destruction_cb(uint32_t context, void * userdata) void OpenGLBuffer::buffer_delete(void * closure, uint32_t contextid) { const cc_glglue * glue = cc_glglue_instance((int) contextid); - GLuint id = (GLuint) ((uintptr_t) closure); + auto id = (GLuint) ((uintptr_t) closure); cc_glglue_glDeleteBuffers(glue, 1, &id); } @@ -288,7 +288,7 @@ int OpenGLMultiBuffer::size() const void OpenGLMultiBuffer::context_destruction_cb(uint32_t context, void * userdata) { - OpenGLMultiBuffer * self = static_cast(userdata); + auto self = static_cast(userdata); auto it = self->bufs.find(context); if (it != self->bufs.end() && it->second) { @@ -304,7 +304,7 @@ void OpenGLMultiBuffer::context_destruction_cb(uint32_t context, void * userdata void OpenGLMultiBuffer::buffer_delete(void * closure, uint32_t contextid) { const cc_glglue * glue = cc_glglue_instance((int) contextid); - GLuint id = (GLuint) ((uintptr_t) closure); + auto id = (GLuint) ((uintptr_t) closure); cc_glglue_glDeleteBuffers(glue, 1, &id); } diff --git a/src/Gui/GestureNavigationStyle.cpp b/src/Gui/GestureNavigationStyle.cpp index 0a5a275e7e..70e87f80a2 100644 --- a/src/Gui/GestureNavigationStyle.cpp +++ b/src/Gui/GestureNavigationStyle.cpp @@ -723,7 +723,7 @@ public: panDist, SbVec2f(0,0)); } else if (ev.inventor_event->isOfType(SoGesturePinchEvent::getClassTypeId())){ - const SoGesturePinchEvent* const pinch = static_cast(ev.inventor_event); + const auto pinch = static_cast(ev.inventor_event); SbVec2f panDist = ns.normalizePixelPos(pinch->deltaCenter.getValue()); ns.panCamera(ns.viewer->getSoRenderManager()->getCamera(), ratio, @@ -963,7 +963,7 @@ bool GestureNavigationStyle::isDraggerUnderCursor(SbVec2s pos) rp.apply(this->viewer->getSoRenderManager()->getSceneGraph()); SoPickedPoint* pick = rp.getPickedPoint(); if (pick){ - const SoFullPath* fullpath = static_cast(pick->getPath()); + const auto fullpath = static_cast(pick->getPath()); for(int i = 0; i < fullpath->getLength(); ++i){ if(fullpath->getNode(i)->isOfType(SoDragger::getClassTypeId())) return true; diff --git a/src/Gui/GraphicsViewZoom.cpp b/src/Gui/GraphicsViewZoom.cpp index 1981a88515..b896b38124 100644 --- a/src/Gui/GraphicsViewZoom.cpp +++ b/src/Gui/GraphicsViewZoom.cpp @@ -69,14 +69,14 @@ void GraphicsViewZoom::set_zoom_factor_base(double value) { bool GraphicsViewZoom::eventFilter(QObject *object, QEvent *event) { if (event->type() == QEvent::MouseMove) { - QMouseEvent* mouse_event = static_cast(event); + auto mouse_event = static_cast(event); QPointF delta = target_viewport_pos - mouse_event->pos(); if (qAbs(delta.x()) > 5 || qAbs(delta.y()) > 5) { target_viewport_pos = mouse_event->pos(); target_scene_pos = _view->mapToScene(mouse_event->pos()); } } else if (event->type() == QEvent::Wheel) { - QWheelEvent* wheel_event = static_cast(event); + auto wheel_event = static_cast(event); if (QApplication::keyboardModifiers() == _modifiers) { QPoint delta = wheel_event->angleDelta(); if (qAbs(delta.y()) > qAbs(delta.x())) { // vertical diff --git a/src/Gui/GuiApplication.cpp b/src/Gui/GuiApplication.cpp index 6c607d5528..8f1fb2076b 100644 --- a/src/Gui/GuiApplication.cpp +++ b/src/Gui/GuiApplication.cpp @@ -308,7 +308,7 @@ bool WheelEventFilter::eventFilter(QObject* obj, QEvent* ev) { if (qobject_cast(obj) && ev->type() == QEvent::Wheel) return true; - QAbstractSpinBox* sb = qobject_cast(obj); + auto sb = qobject_cast(obj); if (sb) { if (ev->type() == QEvent::Show) { sb->setFocusPolicy(Qt::StrongFocus); @@ -328,7 +328,7 @@ KeyboardFilter::KeyboardFilter(QObject* parent) bool KeyboardFilter::eventFilter(QObject* obj, QEvent* ev) { if (ev->type() == QEvent::KeyPress || ev->type() == QEvent::KeyRelease) { - QKeyEvent *kev = static_cast(ev); + auto kev = static_cast(ev); Qt::KeyboardModifiers mod = kev->modifiers(); int key = kev->key(); if ((mod & Qt::KeypadModifier) && (key == Qt::Key_Period || key == Qt::Key_Comma)) diff --git a/src/Gui/GuiApplicationNativeEventAware.cpp b/src/Gui/GuiApplicationNativeEventAware.cpp index beacab9a84..0f972f9665 100644 --- a/src/Gui/GuiApplicationNativeEventAware.cpp +++ b/src/Gui/GuiApplicationNativeEventAware.cpp @@ -79,26 +79,26 @@ bool Gui::GUIApplicationNativeEventAware::processSpaceballEvent(QObject *object, QApplication::notify(object, event); if (event->type() == Spaceball::MotionEvent::MotionEventType) { - Spaceball::MotionEvent *motionEvent = dynamic_cast(event); + auto motionEvent = dynamic_cast(event); if (!motionEvent) return true; if (!motionEvent->isHandled()) { //make a new event and post to parent. - Spaceball::MotionEvent *newEvent = new Spaceball::MotionEvent(*motionEvent); + auto newEvent = new Spaceball::MotionEvent(*motionEvent); postEvent(object->parent(), newEvent); } } if (event->type() == Spaceball::ButtonEvent::ButtonEventType) { - Spaceball::ButtonEvent *buttonEvent = dynamic_cast(event); + auto buttonEvent = dynamic_cast(event); if (!buttonEvent) return true; if (!buttonEvent->isHandled()) { //make a new event and post to parent. - Spaceball::ButtonEvent *newEvent = new Spaceball::ButtonEvent(*buttonEvent); + auto newEvent = new Spaceball::ButtonEvent(*buttonEvent); postEvent(object->parent(), newEvent); } } @@ -113,7 +113,7 @@ void Gui::GUIApplicationNativeEventAware::postMotionEvent(std::vector motio } importSettings(motionDataArray); - Spaceball::MotionEvent *motionEvent = new Spaceball::MotionEvent(); + auto motionEvent = new Spaceball::MotionEvent(); motionEvent->setTranslations(motionDataArray[0], motionDataArray[1], motionDataArray[2]); motionEvent->setRotations(motionDataArray[3], motionDataArray[4], motionDataArray[5]); this->postEvent(currentWidget, motionEvent); @@ -126,7 +126,7 @@ void Gui::GUIApplicationNativeEventAware::postButtonEvent(int buttonNumber, int return; } - Spaceball::ButtonEvent *buttonEvent = new Spaceball::ButtonEvent(); + auto buttonEvent = new Spaceball::ButtonEvent(); buttonEvent->setButtonNumber(buttonNumber); if (buttonPress) { diff --git a/src/Gui/InputField.cpp b/src/Gui/InputField.cpp index 19fbba42e1..118ba14930 100644 --- a/src/Gui/InputField.cpp +++ b/src/Gui/InputField.cpp @@ -105,7 +105,7 @@ void InputField::bind(const App::ObjectIdentifier &_path) { ExpressionBinding::bind(_path); - PropertyQuantity * prop = freecad_dynamic_cast(getPath().getProperty()); + auto * prop = freecad_dynamic_cast(getPath().getProperty()); if (prop) actQuantity = Base::Quantity(prop->getValue()); @@ -189,7 +189,7 @@ void InputField::contextMenuEvent(QContextMenuEvent *event) { QMenu *editMenu = createStandardContextMenu(); editMenu->setTitle(tr("Edit")); - QMenu* menu = new QMenu(QString::fromLatin1("InputFieldContextmenu")); + auto menu = new QMenu(QString::fromLatin1("InputFieldContextmenu")); menu->addMenu(editMenu); menu->addSeparator(); @@ -201,9 +201,9 @@ void InputField::contextMenuEvent(QContextMenuEvent *event) // add the history menu part... std::vector history = getHistory(); - for(std::vector::const_iterator it = history.begin();it!= history.end();++it){ - actions.push_back(menu->addAction(*it)); - values.push_back(*it); + for(const auto & it : history){ + actions.push_back(menu->addAction(it)); + values.push_back(it); } // add the save value portion of the menu @@ -211,9 +211,9 @@ void InputField::contextMenuEvent(QContextMenuEvent *event) QAction *SaveValueAction = menu->addAction(tr("Save value")); std::vector savedValues = getSavedValues(); - for(std::vector::const_iterator it = savedValues.begin();it!= savedValues.end();++it){ - actions.push_back(menu->addAction(*it)); - values.push_back(*it); + for(const auto & savedValue : savedValues){ + actions.push_back(menu->addAction(savedValue)); + values.push_back(savedValue); } // call the menu and wait until its back @@ -224,7 +224,7 @@ void InputField::contextMenuEvent(QContextMenuEvent *event) pushToSavedValues(); else{ int i=0; - for(std::vector::const_iterator it = actions.begin();it!=actions.end();++it,i++) + for(auto it = actions.begin();it!=actions.end();++it,i++) if(*it == saveAction) this->setText(values[i]); } @@ -246,7 +246,7 @@ void InputField::newInput(const QString & text) std::unique_ptr evalRes(getExpression()->eval()); - NumberExpression * value = freecad_dynamic_cast(evalRes.get()); + auto * value = freecad_dynamic_cast(evalRes.get()); if (value) { res.setValue(value->getValue()); res.setUnit(value->getUnit()); @@ -311,8 +311,8 @@ void InputField::pushToHistory(const QString &valueq) // check if already in: std::vector hist = InputField::getHistory(); - for(std::vector::const_iterator it = hist.begin();it!=hist.end();++it) - if( *it == val) + for(const auto & it : hist) + if( it == val) return; std::string value(val.toUtf8()); @@ -600,16 +600,16 @@ void InputField::selectNumber() QChar n = locale().negativeSign(); QChar e = locale().exponential(); - for (QString::const_iterator it = str.cbegin(); it != str.cend(); ++it) { - if (it->isDigit()) + for (const auto & it : str) { + if (it.isDigit()) i++; - else if (*it == d) + else if (it == d) i++; - else if (*it == g) + else if (it == g) i++; - else if (*it == n) + else if (it == n) i++; - else if (*it == e && actQuantity.getFormat().format != Base::QuantityFormat::Fixed) + else if (it == e && actQuantity.getFormat().format != Base::QuantityFormat::Fixed) i++; else // any non-number character break; diff --git a/src/Gui/InputVector.cpp b/src/Gui/InputVector.cpp index 92ea2ac6fc..b7a4024d8f 100644 --- a/src/Gui/InputVector.cpp +++ b/src/Gui/InputVector.cpp @@ -71,7 +71,7 @@ LocationWidget::LocationWidget (QWidget * parent) yValue->setUnit(Base::Unit::Length); zValue->setUnit(Base::Unit::Length); - QGridLayout* gridLayout = new QGridLayout(this); + auto gridLayout = new QGridLayout(this); gridLayout->addLayout(box, 0, 0, 1, 2); connect(dValue, SIGNAL(activated(int)), @@ -151,7 +151,7 @@ void LocationWidget::setDirection(const Base::Vector3d& dir) for (int i=0; icount()-1; i++) { QVariant data = dValue->itemData (i); if (data.canConvert()) { - const Base::Vector3d val = data.value(); + const auto val = data.value(); if (val == dir) { dValue->setCurrentIndex(i); return; diff --git a/src/Gui/InputVector.h b/src/Gui/InputVector.h index 0ef3f512e0..48f0763ec9 100644 --- a/src/Gui/InputVector.h +++ b/src/Gui/InputVector.h @@ -195,7 +195,7 @@ private: for (int i=0; idirection->count()-1; i++) { QVariant data = this->direction->itemData (i); if (data.canConvert()) { - const Base::Vector3d val = data.value(); + const auto val = data.value(); if (val == dir) { this->direction->setCurrentIndex(i); return; @@ -315,7 +315,7 @@ public: for (int i=0; idirection->count()-1; i++) { QVariant data = this->direction->itemData (i); if (data.canConvert()) { - const Base::Vector3d val = data.value(); + const auto val = data.value(); if (val == dir) { this->direction->setCurrentIndex(i); return; @@ -501,7 +501,7 @@ public: for (int i=0; idirection->count()-1; i++) { QVariant data = ui->direction->itemData (i); if (data.canConvert()) { - const Base::Vector3d val = data.value(); + const auto val = data.value(); if (val == dir) { ui->direction->setCurrentIndex(i); return; diff --git a/src/Gui/Inventor/SmSwitchboard.cpp b/src/Gui/Inventor/SmSwitchboard.cpp index bf2a72d669..28df7e10a0 100644 --- a/src/Gui/Inventor/SmSwitchboard.cpp +++ b/src/Gui/Inventor/SmSwitchboard.cpp @@ -125,7 +125,7 @@ SmSwitchboard::doAction(SoAction * action) if (action->isOfType(SoGetBoundingBoxAction::getClassTypeId())) { // calculate center of bbox if bboxaction. This makes the // switchboard node behave exactly like a group node - SoGetBoundingBoxAction * bbaction = (SoGetBoundingBoxAction*) action; + auto bbaction = (SoGetBoundingBoxAction*) action; // Initialize accumulation variables. SbVec3f acccenter(0.0f, 0.0f, 0.0f); int numcenters = 0; diff --git a/src/Gui/InventorNavigationStyle.cpp b/src/Gui/InventorNavigationStyle.cpp index 476d10cc89..19b3e0c6e7 100644 --- a/src/Gui/InventorNavigationStyle.cpp +++ b/src/Gui/InventorNavigationStyle.cpp @@ -113,13 +113,13 @@ SbBool InventorNavigationStyle::processSoEvent(const SoEvent * const ev) // Keyboard handling if (type.isDerivedFrom(SoKeyboardEvent::getClassTypeId())) { - const SoKeyboardEvent * const event = static_cast(ev); + auto event = static_cast(ev); processed = processKeyboardEvent(event); } // Mouse Button / Spaceball Button handling if (type.isDerivedFrom(SoMouseButtonEvent::getClassTypeId())) { - const SoMouseButtonEvent * const event = (const SoMouseButtonEvent *) ev; + const auto event = (const SoMouseButtonEvent *) ev; const int button = event->getButton(); const SbBool press = event->getState() == SoButtonEvent::DOWN ? true : false; @@ -220,7 +220,7 @@ SbBool InventorNavigationStyle::processSoEvent(const SoEvent * const ev) // Mouse Movement handling if (type.isDerivedFrom(SoLocation2Event::getClassTypeId())) { this->lockrecenter = true; - const SoLocation2Event * const event = (const SoLocation2Event *) ev; + const auto event = (const SoLocation2Event *) ev; if (this->currentmode == NavigationStyle::ZOOMING) { this->zoomByCursor(posn, prevnormalized); processed = true; @@ -240,7 +240,7 @@ SbBool InventorNavigationStyle::processSoEvent(const SoEvent * const ev) // Spaceball & Joystick handling if (type.isDerivedFrom(SoMotion3Event::getClassTypeId())) { - const SoMotion3Event * const event = static_cast(ev); + const auto event = static_cast(ev); if (event) this->processMotionEvent(event); processed = true; diff --git a/src/Gui/Language/Translator.cpp b/src/Gui/Language/Translator.cpp index 3ce5221163..97c82df809 100644 --- a/src/Gui/Language/Translator.cpp +++ b/src/Gui/Language/Translator.cpp @@ -303,11 +303,11 @@ void Translator::installQMFiles(const QDir& dir, const char* locale) { QString filter = QString::fromLatin1("*_%1.qm").arg(QLatin1String(locale)); QStringList fileNames = dir.entryList(QStringList(filter), QDir::Files, QDir::Name); - for (QStringList::Iterator it = fileNames.begin(); it != fileNames.end(); ++it){ + for (const auto &it : fileNames){ bool ok=false; for (std::list::const_iterator tt = d->translators.begin(); tt != d->translators.end(); ++tt) { - if ((*tt)->objectName() == *it) { + if ((*tt)->objectName() == it) { ok = true; // this file is already installed break; } @@ -315,9 +315,9 @@ void Translator::installQMFiles(const QDir& dir, const char* locale) // okay, we need to install this file if (!ok) { - QTranslator* translator = new QTranslator; - translator->setObjectName(*it); - if (translator->load(dir.filePath(*it))) { + auto translator = new QTranslator; + translator->setObjectName(it); + if (translator->load(dir.filePath(it))) { qApp->installTranslator(translator); d->translators.push_back(translator); } diff --git a/src/Gui/LinkViewPyImp.cpp b/src/Gui/LinkViewPyImp.cpp index 1fa83985f5..d10860e2eb 100644 --- a/src/Gui/LinkViewPyImp.cpp +++ b/src/Gui/LinkViewPyImp.cpp @@ -277,7 +277,7 @@ PyObject* LinkViewPy::getElementPicked(PyObject* args) return nullptr; void *ptr = nullptr; Base::Interpreter().convertSWIGPointerObj("pivy.coin", "SoPickedPoint *", obj, &ptr, 0); - SoPickedPoint *pp = static_cast(ptr); + auto pp = static_cast(ptr); if(!pp) throw Py::TypeError("type must be of coin.SoPickedPoint"); PY_TRY{ @@ -296,7 +296,7 @@ PyObject* LinkViewPy::getDetailPath(PyObject* args) return nullptr; void *ptr = nullptr; Base::Interpreter().convertSWIGPointerObj("pivy.coin", "SoPath *", path, &ptr, 0); - SoPath *pPath = static_cast(ptr); + auto pPath = static_cast(ptr); if(!pPath) throw Py::TypeError("type must be of coin.SoPath"); PY_TRY{ diff --git a/src/Gui/MDIView.cpp b/src/Gui/MDIView.cpp index 7e09c817ae..4be588a8d2 100644 --- a/src/Gui/MDIView.cpp +++ b/src/Gui/MDIView.cpp @@ -277,8 +277,8 @@ QStringList MDIView::undoActions() const Gui::Document* doc = getGuiDocument(); if (doc) { std::vector vecUndos = doc->getUndoVector(); - for (std::vector::iterator i = vecUndos.begin(); i != vecUndos.end(); ++i) { - actions << QCoreApplication::translate("Command", i->c_str()); + for (const auto & vecUndo : vecUndos) { + actions << QCoreApplication::translate("Command", vecUndo.c_str()); } } @@ -291,8 +291,8 @@ QStringList MDIView::redoActions() const Gui::Document* doc = getGuiDocument(); if (doc) { std::vector vecRedos = doc->getRedoVector(); - for (std::vector::iterator i = vecRedos.begin(); i != vecRedos.end(); ++i) { - actions << QCoreApplication::translate("Command", i->c_str()); + for (const auto & vecRedo : vecRedos) { + actions << QCoreApplication::translate("Command", vecRedo.c_str()); } } diff --git a/src/Gui/MainWindow.cpp b/src/Gui/MainWindow.cpp index a309cfe883..babbae43ce 100644 --- a/src/Gui/MainWindow.cpp +++ b/src/Gui/MainWindow.cpp @@ -270,7 +270,7 @@ MainWindow::MainWindow(QWidget * parent, Qt::WindowFlags f) d->mdiArea->setTabsMovable(true); d->mdiArea->setTabPosition(QTabWidget::South); d->mdiArea->setViewMode(QMdiArea::TabbedView); - QTabBar* tab = d->mdiArea->findChild(); + auto tab = d->mdiArea->findChild(); if (tab) { tab->setTabsClosable(true); // The tabs might be very wide @@ -330,7 +330,7 @@ MainWindow::MainWindow(QWidget * parent, Qt::WindowFlags f) std::string hiddenDockWindows;; const std::map& config = App::Application::Config(); - std::map::const_iterator ht = config.find("HiddenDockWindow"); + auto ht = config.find("HiddenDockWindow"); if (ht != config.end()) hiddenDockWindows = ht->second; @@ -347,7 +347,7 @@ MainWindow::MainWindow(QWidget * parent, Qt::WindowFlags f) group->SetBool("Enabled", enabled); //ensure entry exists. if (enabled) { treeView = true; - TreeDockWidget* tree = new TreeDockWidget(nullptr, this); + auto tree = new TreeDockWidget(nullptr, this); tree->setObjectName (QString::fromLatin1(QT_TRANSLATE_NOOP("QDockWidget","Tree view"))); tree->setMinimumWidth(210); @@ -368,7 +368,7 @@ MainWindow::MainWindow(QWidget * parent, Qt::WindowFlags f) group->SetBool("Enabled", enabled); //ensure entry exists. if (enabled) { propertyView = true; - PropertyDockView* pcPropView = new PropertyDockView(nullptr, this); + auto pcPropView = new PropertyDockView(nullptr, this); pcPropView->setObjectName (QString::fromLatin1(QT_TRANSLATE_NOOP("QDockWidget","Property view"))); pcPropView->setMinimumWidth(210); @@ -378,7 +378,7 @@ MainWindow::MainWindow(QWidget * parent, Qt::WindowFlags f) // Selection view if (hiddenDockWindows.find("Std_SelectionView") == std::string::npos) { - SelectionView* pcSelectionView = new SelectionView(nullptr, this); + auto pcSelectionView = new SelectionView(nullptr, this); pcSelectionView->setObjectName (QString::fromLatin1(QT_TRANSLATE_NOOP("QDockWidget","Selection view"))); pcSelectionView->setMinimumWidth(210); @@ -394,7 +394,7 @@ MainWindow::MainWindow(QWidget * parent, Qt::WindowFlags f) enable = group->GetBool("Enabled", true); } - ComboView* pcComboView = new ComboView(enable, nullptr, this); + auto pcComboView = new ComboView(enable, nullptr, this); pcComboView->setObjectName(QString::fromLatin1(QT_TRANSLATE_NOOP("QDockWidget","Combo View"))); pcComboView->setMinimumWidth(150); pDockMgr->registerDockWindow("Std_ComboView", pcComboView); @@ -402,18 +402,18 @@ MainWindow::MainWindow(QWidget * parent, Qt::WindowFlags f) // Report view (must be created before PythonConsole!) if (hiddenDockWindows.find("Std_ReportView") == std::string::npos) { - ReportOutput* pcReport = new ReportOutput(this); + auto pcReport = new ReportOutput(this); pcReport->setWindowIcon(BitmapFactory().pixmap("MacroEditor")); pcReport->setObjectName (QString::fromLatin1(QT_TRANSLATE_NOOP("QDockWidget","Report view"))); pDockMgr->registerDockWindow("Std_ReportView", pcReport); - ReportOutputObserver* rvObserver = new ReportOutputObserver(pcReport); + auto rvObserver = new ReportOutputObserver(pcReport); qApp->installEventFilter(rvObserver); } // Python console if (hiddenDockWindows.find("Std_PythonView") == std::string::npos) { - PythonConsole* pcPython = new PythonConsole(this); + auto pcPython = new PythonConsole(this); pcPython->setWindowIcon(Gui::BitmapFactory().iconFromTheme("applications-python")); pcPython->setObjectName (QString::fromLatin1(QT_TRANSLATE_NOOP("QDockWidget","Python console"))); @@ -439,7 +439,7 @@ MainWindow::MainWindow(QWidget * parent, Qt::WindowFlags f) enabled = group->GetBool("Enabled", enabled); group->SetBool("Enabled", enabled); //ensure entry exists. if (enabled) { - DAG::DockWindow *dagDockWindow = new DAG::DockWindow(nullptr, this); + auto dagDockWindow = new DAG::DockWindow(nullptr, this); dagDockWindow->setObjectName (QString::fromLatin1(QT_TRANSLATE_NOOP("QDockWidget","DAG View"))); pDockMgr->registerDockWindow("Std_DAGView", dagDockWindow); @@ -474,12 +474,12 @@ QMenu* MainWindow::createPopupMenu () if (item.hasItems()) { menu->addSeparator(); QList items = item.getItems(); - for (QList::iterator it = items.begin(); it != items.end(); ++it) { - if ((*it)->command() == "Separator") { + for (const auto & item : items) { + if (item->command() == "Separator") { menu->addSeparator(); } else { - Command* cmd = Application::Instance->commandManager().getCommandByName((*it)->command().c_str()); + Command* cmd = Application::Instance->commandManager().getCommandByName(item->command().c_str()); if (cmd) cmd->addTo(menu); } } @@ -710,7 +710,7 @@ bool MainWindow::event(QEvent *e) // this in eventFilter(). } else if (e->type() == QEvent::WhatsThisClicked) { - QWhatsThisClickedEvent* wt = static_cast(e); + auto wt = static_cast(e); showDocumentation(wt->href()); } else if (e->type() == QEvent::ApplicationWindowIconChange) { @@ -723,7 +723,7 @@ bool MainWindow::event(QEvent *e) } } else if (e->type() == Spaceball::ButtonEvent::ButtonEventType) { - Spaceball::ButtonEvent *buttonEvent = dynamic_cast(e); + auto buttonEvent = dynamic_cast(e); if (!buttonEvent) return true; buttonEvent->setHandled(true); @@ -745,14 +745,14 @@ bool MainWindow::event(QEvent *e) return true; } else if (e->type() == Spaceball::MotionEvent::MotionEventType) { - Spaceball::MotionEvent *motionEvent = dynamic_cast(e); + auto motionEvent = dynamic_cast(e); if (!motionEvent) return true; motionEvent->setHandled(true); Gui::Document *doc = Application::Instance->activeDocument(); if (!doc) return true; - View3DInventor *temp = dynamic_cast(doc->getActiveView()); + auto temp = dynamic_cast(doc->getActiveView()); if (!temp) return true; View3DInventorViewer *view = temp->getViewer(); @@ -775,7 +775,7 @@ bool MainWindow::eventFilter(QObject* o, QEvent* e) if (e->type() == QEvent::WindowStateChange) { // notify all mdi views when the active view receives a show normal, show minimized // or show maximized event - MDIView * view = qobject_cast(o); + auto view = qobject_cast(o); if (view) { // emit this signal Qt::WindowStates oldstate = static_cast(e)->oldState(); Qt::WindowStates newstate = view->windowState(); @@ -792,7 +792,7 @@ bool MainWindow::eventFilter(QObject* o, QEvent* e) if (!o->isWidgetType()) return false; // clicked on a widget in what's this mode - QWidget * w = static_cast(o); + auto w = static_cast(o); d->whatstext = w->whatsThis(); } if (e->type() == QEvent::WhatsThisClicked) { @@ -807,7 +807,7 @@ bool MainWindow::eventFilter(QObject* o, QEvent* e) if (o->inherits("QMenu") && QWhatsThis::inWhatsThisMode()) { bool whatthis = false; if (e->type() == QEvent::KeyPress) { - QKeyEvent* ke = static_cast(e); + auto ke = static_cast(e); if (ke->key() == Qt::Key_Return || ke->key() == Qt::Key_Enter || ke->key() == Qt::Key_F1) whatthis = true; } @@ -854,7 +854,7 @@ void MainWindow::addWindow(MDIView* view) { // make workspace parent of view bool isempty = d->mdiArea->subWindowList().isEmpty(); - QMdiSubWindow* child = qobject_cast(view->parentWidget()); + auto child = qobject_cast(view->parentWidget()); if(!child) { child = new QMdiSubWindow(d->mdiArea->viewport()); child->setAttribute(Qt::WA_DeleteOnClose); @@ -864,9 +864,9 @@ void MainWindow::addWindow(MDIView* view) // See StdCmdCloseActiveWindow (#0002631) QList acts = menu->actions(); - for (QList::iterator it = acts.begin(); it != acts.end(); ++it) { - if ((*it)->shortcut() == QKeySequence(QKeySequence::Close)) { - (*it)->setShortcuts(QList()); + for (auto & act : acts) { + if (act->shortcut() == QKeySequence(QKeySequence::Close)) { + act->setShortcuts(QList()); break; } } @@ -948,7 +948,7 @@ void MainWindow::tabChanged(MDIView* view) void MainWindow::tabCloseRequested(int index) { - QTabBar* tab = d->mdiArea->findChild(); + auto tab = d->mdiArea->findChild(); if (index < 0 || index >= tab->count()) return; @@ -982,7 +982,7 @@ void MainWindow::onWindowActivated(QMdiSubWindow* w) { if (!w) return; - MDIView* view = dynamic_cast(w->widget()); + auto view = dynamic_cast(w->widget()); ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/View"); bool saveWB = hGrp->GetBool("SaveWBbyTab", false); @@ -1030,10 +1030,10 @@ void MainWindow::onWindowsMenuAboutToShow() if (firstShow) { firstShow = false; QAction* last = actions.isEmpty() ? 0 : actions.last(); - for (QList::Iterator it = actions.begin(); it != actions.end(); ++it) { - if (*it == last) + for (const auto & action : actions) { + if (action == last) break; // this is a separator - connect(*it, SIGNAL(triggered()), d->windowMapper, SLOT(map())); + connect(action, SIGNAL(triggered()), d->windowMapper, SLOT(map())); } } @@ -1069,12 +1069,12 @@ void MainWindow::onWindowsMenuAboutToShow() void MainWindow::onToolBarMenuAboutToShow() { - QMenu* menu = static_cast(sender()); + auto menu = static_cast(sender()); menu->clear(); QList dock = this->findChildren(); - for (QList::Iterator it = dock.begin(); it != dock.end(); ++it) { - if ((*it)->parentWidget() == this) { - QAction* action = (*it)->toggleViewAction(); + for (const auto & it : dock) { + if (it->parentWidget() == this) { + QAction* action = it->toggleViewAction(); action->setToolTip(tr("Toggles this toolbar")); action->setStatusTip(tr("Toggles this toolbar")); action->setWhatsThis(tr("Toggles this toolbar")); @@ -1085,11 +1085,11 @@ void MainWindow::onToolBarMenuAboutToShow() void MainWindow::onDockWindowMenuAboutToShow() { - QMenu* menu = static_cast(sender()); + auto menu = static_cast(sender()); menu->clear(); QList dock = this->findChildren(); - for (QList::Iterator it = dock.begin(); it != dock.end(); ++it) { - QAction* action = (*it)->toggleViewAction(); + for (auto & it : dock) { + QAction* action = it->toggleViewAction(); action->setToolTip(tr("Toggles this dockable window")); action->setStatusTip(tr("Toggles this dockable window")); action->setWhatsThis(tr("Toggles this dockable window")); @@ -1101,8 +1101,8 @@ QList MainWindow::windows(QMdiArea::WindowOrder order) const { QList mdis; QList wnds = d->mdiArea->subWindowList(order); - for (QList::iterator it = wnds.begin(); it != wnds.end(); ++it) { - mdis << (*it)->widget(); + for (const auto & wnd : wnds) { + mdis << wnd->widget(); } return mdis; } @@ -1122,18 +1122,18 @@ void MainWindow::closeEvent (QCloseEvent * e) // It is possible that closing a dialog internally closes further dialogs. Thus, // we have to check the pointer before. QVector< QPointer > dialogs_ptr; - for (QList::iterator it = dialogs.begin(); it != dialogs.end(); ++it) { - dialogs_ptr.append(*it); + for (const auto & dialog : dialogs) { + dialogs_ptr.append(dialog); } - for (QVector< QPointer >::iterator it = dialogs_ptr.begin(); it != dialogs_ptr.end(); ++it) { - if (!(*it).isNull()) - (*it)->close(); + for (auto & it : dialogs_ptr) { + if (!it.isNull()) + it->close(); } QList mdis = this->findChildren(); // Force to close any remaining (passive) MDI child views - for (QList::iterator it = mdis.begin(); it != mdis.end(); ++it) { - (*it)->hide(); - (*it)->deleteLater(); + for (auto & mdi : mdis) { + mdi->hide(); + mdi->deleteLater(); } if (Workbench* wb = WorkbenchManager::instance()->active()) @@ -1186,13 +1186,13 @@ void MainWindow::processMessages(const QList & msg) WaitCursor wc; std::list files; QByteArray action("OpenFile:"); - for (QList::const_iterator it = msg.begin(); it != msg.end(); ++it) { - if (it->startsWith(action)) - files.emplace_back(it->mid(action.size()).constData()); + for (const auto & it : msg) { + if (it.startsWith(action)) + files.emplace_back(it.mid(action.size()).constData()); } files = App::Application::processFiles(files); - for (std::list::iterator it = files.begin(); it != files.end(); ++it) { - QString filename = QString::fromUtf8(it->c_str(), it->size()); + for (const auto & file : files) { + QString filename = QString::fromUtf8(file.c_str(), file.size()); FileDialog::setWorkingDirectory(filename); } } @@ -1220,8 +1220,8 @@ void MainWindow::delayedStartup() try { std::list files = App::Application::getCmdLineFiles(); files = App::Application::processFiles(files); - for (std::list::iterator it = files.begin(); it != files.end(); ++it) { - QString filename = QString::fromUtf8(it->c_str(), it->size()); + for (const auto & file : files) { + QString filename = QString::fromUtf8(file.c_str(), file.size()); FileDialog::setWorkingDirectory(filename); } } @@ -1230,7 +1230,7 @@ void MainWindow::delayedStartup() } const std::map& cfg = App::Application::Config(); - std::map::const_iterator it = cfg.find("StartHidden"); + auto it = cfg.find("StartHidden"); if (it != cfg.end()) { QApplication::quit(); return; @@ -1253,7 +1253,7 @@ void MainWindow::delayedStartup() void MainWindow::appendRecentFile(const QString& filename) { - RecentFilesAction *recent = this->findChild + auto recent = this->findChild (QString::fromLatin1("recentFiles")); if (recent) { recent->appendFile(filename); @@ -1262,7 +1262,7 @@ void MainWindow::appendRecentFile(const QString& filename) void MainWindow::appendRecentMacro(const QString& filename) { - RecentMacrosAction *recent = this->findChild + auto recent = this->findChild (QString::fromLatin1("recentMacros")); if (recent) { recent->appendFile(filename); @@ -1330,14 +1330,14 @@ void MainWindow::updateEditorActions() void MainWindow::switchToTopLevelMode() { QList dw = this->findChildren(); - for (QList::Iterator it = dw.begin(); it != dw.end(); ++it) { - (*it)->setParent(nullptr, Qt::Window); - (*it)->show(); + for (auto & it : dw) { + it->setParent(nullptr, Qt::Window); + it->show(); } QList mdi = getMainWindow()->windows(); - for (QList::Iterator it = mdi.begin(); it != mdi.end(); ++it) { - (*it)->setParent(nullptr, Qt::Window); - (*it)->show(); + for (auto & it : mdi) { + it->setParent(nullptr, Qt::Window); + it->show(); } } @@ -1345,8 +1345,8 @@ void MainWindow::switchToDockedMode() { // Search for all top-level MDI views QWidgetList toplevel = QApplication::topLevelWidgets(); - for (QWidgetList::Iterator it = toplevel.begin(); it != toplevel.end(); ++it) { - Gui::MDIView* view = qobject_cast(*it); + for (const auto & it : toplevel) { + auto view = qobject_cast(it); if (view) view->setCurrentViewMode(MDIView::Child); } @@ -1631,8 +1631,8 @@ QMimeData * MainWindow::createMimeDataFromSelection () const } unsigned int memsize=1000; // ~ for the meta-information - for (std::vector::iterator it = sel.begin(); it != sel.end(); ++it) - memsize += (*it)->getMemSize(); + for (const auto & it : sel) + memsize += it->getMemSize(); // if less than ~10 MB bool use_buffer=(memsize < 0xA00000); @@ -1673,7 +1673,7 @@ QMimeData * MainWindow::createMimeDataFromSelection () const const_cast(this)->setProperty("x-documentobject-file", res); } - QMimeData *mimeData = new QMimeData(); + auto mimeData = new QMimeData(); mimeData->setData(mime,res); return mimeData; } @@ -1772,15 +1772,15 @@ void MainWindow::unsetUrlHandler(const QString &scheme) void MainWindow::loadUrls(App::Document* doc, const QList& urls) { QStringList files; - for (QList::ConstIterator it = urls.begin(); it != urls.end(); ++it) { - QMap >::iterator jt = d->urlHandler.find(it->scheme()); + for (const auto & it : urls) { + QMap >::iterator jt = d->urlHandler.find(it.scheme()); if (jt != d->urlHandler.end() && !jt->isNull()) { // delegate the loading to the url handler - (*jt)->openUrl(doc, *it); + (*jt)->openUrl(doc, it); continue; } - QFileInfo info((*it).toLocalFile()); + QFileInfo info(it.toLocalFile()); if (info.exists() && info.isFile()) { if (info.isSymLink()) info.setFile(info.symLinkTarget()); @@ -1799,13 +1799,13 @@ void MainWindow::loadUrls(App::Document* doc, const QList& urls) (const char*)info.absoluteFilePath().toUtf8()); } } - else if (it->scheme().toLower() == QLatin1String("http")) { + else if (it.scheme().toLower() == QLatin1String("http")) { Gui::Dialog::DownloadManager* dm = Gui::Dialog::DownloadManager::getInstance(); - dm->download(dm->redirectUrl(*it)); + dm->download(dm->redirectUrl(it)); } - else if (it->scheme().toLower() == QLatin1String("https")) { - QUrl url = *it; + else if (it.scheme().toLower() == QLatin1String("https")) { + QUrl url = it; QUrlQuery urlq(url); if (urlq.hasQueryItem(QLatin1String("sid"))) { urlq.removeAllQueryItems(QLatin1String("sid")); @@ -1816,8 +1816,8 @@ void MainWindow::loadUrls(App::Document* doc, const QList& urls) dm->download(dm->redirectUrl(url)); } - else if (it->scheme().toLower() == QLatin1String("ftp")) { - Gui::Dialog::DownloadManager::getInstance()->download(*it); + else if (it.scheme().toLower() == QLatin1String("ftp")) { + Gui::Dialog::DownloadManager::getInstance()->download(it); } } @@ -1837,8 +1837,8 @@ void MainWindow::changeEvent(QEvent *e) CommandManager& rclMan = Application::Instance->commandManager(); std::vector cmd = rclMan.getAllCommands(); - for (std::vector::iterator it = cmd.begin(); it != cmd.end(); ++it) - (*it)->languageChange(); + for (auto & it : cmd) + it->languageChange(); // reload current workbench to retranslate all actions and window titles Workbench* wb = WorkbenchManager::instance()->active(); @@ -1848,7 +1848,7 @@ void MainWindow::changeEvent(QEvent *e) if (isActiveWindow()) { QMdiSubWindow* mdi = d->mdiArea->currentSubWindow(); if (mdi) { - MDIView* view = dynamic_cast(mdi->widget()); + auto view = dynamic_cast(mdi->widget()); if (view && getMainWindow()->activeWindow() != view) { d->activeView = view; Application::Instance->viewActivated(view); @@ -1942,14 +1942,14 @@ void MainWindow::setPaneText(int i, QString text) void MainWindow::customEvent(QEvent* e) { if (e->type() == QEvent::User) { - Gui::CustomMessageEvent* ce = static_cast(e); + auto ce = static_cast(e); QString msg = ce->message(); switch(ce->type()) { case MainWindow::Log: { if (msg.startsWith(QLatin1String("#Inventor V2.1 ascii "))) { Gui::Document *d = Application::Instance->activeDocument(); if (d) { - ViewProviderExtern *view = new ViewProviderExtern(); + auto view = new ViewProviderExtern(); try { view->setModeByString("1",msg.toLatin1().constData()); d->setAnnotationViewProvider("Vdbg",view); @@ -1970,13 +1970,13 @@ void MainWindow::customEvent(QEvent* e) else if (e->type() == ActionStyleEvent::EventType) { QList tasks = findChildren(); if (static_cast(e)->getType() == ActionStyleEvent::Clear) { - for (QList::iterator it = tasks.begin(); it != tasks.end(); ++it) { - (*it)->clearActionStyle(); + for (auto & task : tasks) { + task->clearActionStyle(); } } else { - for (QList::iterator it = tasks.begin(); it != tasks.end(); ++it) { - (*it)->restoreActionStyle(); + for (auto & task : tasks) { + task->restoreActionStyle(); } } } @@ -2038,7 +2038,7 @@ void StatusBarObserver::SendLog(const std::string& msg, Base::LogStyle level) } // Send the event to the main window to allow thread-safety. Qt will delete it when done. - CustomMessageEvent* ev = new CustomMessageEvent(messageType, QString::fromUtf8(msg.c_str())); + auto ev = new CustomMessageEvent(messageType, QString::fromUtf8(msg.c_str())); QApplication::postEvent(getMainWindow(), ev); } diff --git a/src/Gui/MainWindowPy.cpp b/src/Gui/MainWindowPy.cpp index a8d97dcabc..7c0c7c2fba 100644 --- a/src/Gui/MainWindowPy.cpp +++ b/src/Gui/MainWindowPy.cpp @@ -123,7 +123,7 @@ Py::Object MainWindowPy::getWindows(const Py::Tuple& args) if (_mw) { QList windows = _mw->windows(); for (auto it : windows) { - MDIView* view = qobject_cast(it); + auto view = qobject_cast(it); if (view) { mdis.append(Py::asObject(view->getPyObject())); } @@ -145,7 +145,7 @@ Py::Object MainWindowPy::getWindowsOfType(const Py::Tuple& args) if (_mw) { QList windows = _mw->windows(); for (auto it : windows) { - MDIView* view = qobject_cast(it); + auto view = qobject_cast(it); if (view && view->isDerivedFrom(typeId)) { mdis.append(Py::asObject(view->getPyObject())); } diff --git a/src/Gui/ManualAlignment.cpp b/src/Gui/ManualAlignment.cpp index 7e0b8e7fad..4d90868ea4 100644 --- a/src/Gui/ManualAlignment.cpp +++ b/src/Gui/ManualAlignment.cpp @@ -77,7 +77,7 @@ void AlignmentGroup::addView(App::DocumentObject* pView) if (pView) { App::Document* rDoc = pView->getDocument(); Gui::Document* pDoc = Gui::Application::Instance->getDocument(rDoc); - Gui::ViewProviderDocumentObject* pProvider = static_cast + auto pProvider = static_cast (pDoc->getViewProvider(pView)); this->_views.push_back(pProvider); } @@ -149,7 +149,7 @@ void AlignmentGroup::setRandomColor() SoPath* selectionPath = searchAction.getPath(); if (selectionPath) { - SoMaterial* material = static_cast(selectionPath->getTail()); + auto material = static_cast(selectionPath->getTail()); material->diffuseColor.setValue(r, g, b); } } @@ -199,13 +199,13 @@ void AlignmentGroup::setAlignable(bool align) { std::vector::iterator it; for (it = this->_views.begin(); it != this->_views.end(); ++it) { - App::PropertyBool* pAlignMode = dynamic_cast((*it)->getPropertyByName("AlignMode")); + auto pAlignMode = dynamic_cast((*it)->getPropertyByName("AlignMode")); if (pAlignMode) { pAlignMode->setValue(align); } // leaving alignment mode else if (!align){ - App::PropertyColor* pColor = dynamic_cast((*it)->getPropertyByName("ShapeColor")); + auto pColor = dynamic_cast((*it)->getPropertyByName("ShapeColor")); if (pColor) pColor->touch(); // resets to color defined by property } @@ -243,7 +243,7 @@ Base::BoundBox3d AlignmentGroup::getBoundingBox() const std::vector::const_iterator it; for (it = this->_views.begin(); it != this->_views.end(); ++it) { if ((*it)->isDerivedFrom(Gui::ViewProviderGeometryObject::getClassTypeId())) { - App::GeoFeature* geo = static_cast((*it)->getObject()); + auto geo = static_cast((*it)->getObject()); const App::PropertyComplexGeoData* prop = geo->getPropertyOfGeometry(); if (prop) box.Add(prop->getBoundingBox()); @@ -289,8 +289,8 @@ void MovableGroupModel::addGroup(const MovableGroup& grp) void MovableGroupModel::addGroups(const std::map& grps) { - for (std::map::const_iterator it = grps.begin(); it != grps.end(); ++it) - this->_groups.push_back(it->second); + for (const auto & grp : grps) + this->_groups.push_back(grp.second); } void MovableGroupModel::removeActiveGroup() @@ -392,8 +392,8 @@ public: _viewer.back()->setDocument(pcDocument); } - QFrame* vbox = new QFrame(this); - QVBoxLayout* layout = new QVBoxLayout(); + auto vbox = new QFrame(this); + auto layout = new QVBoxLayout(); layout->setMargin(0); layout->setSpacing(0); vbox->setLayout(layout); @@ -420,8 +420,8 @@ public: setupSettings(); if (smoothing) { - for (std::vector::size_type i = 0; i != _viewer.size(); i++) - _viewer[i]->getSoRenderManager()->getGLRenderAction()->setSmoothing(true); + for (const auto & i : _viewer) + i->getSoRenderManager()->getGLRenderAction()->setSmoothing(true); } static_cast(getViewer(0)->getSoRenderManager()->getSceneGraph())-> @@ -442,16 +442,16 @@ public: } SoNode* setupHeadUpDisplay(const QString& text) const { - SoSeparator* hudRoot = new SoSeparator; + auto hudRoot = new SoSeparator; hudRoot->ref(); - SoOrthographicCamera* hudCam = new SoOrthographicCamera(); + auto hudCam = new SoOrthographicCamera(); hudCam->viewportMapping = SoCamera::LEAVE_ALONE; // Set the position in the window. // [0, 0] is in the center of the screen. // - SoTranslation* hudTrans = new SoTranslation; + auto hudTrans = new SoTranslation; hudTrans->translation.setValue(-0.95f, -0.95f, 0.0f); QFont font = this->font(); @@ -474,7 +474,7 @@ public: painter.end(); SoSFImage sfimage; Gui::BitmapFactory().convert(image, sfimage); - SoImage* hudImage = new SoImage(); + auto hudImage = new SoImage(); hudImage->image = sfimage; // Assemble the parts... @@ -575,14 +575,14 @@ public: static void syncCameraCB(void * data, SoSensor * s) { - ManualAlignment* self = static_cast(data); + auto self = static_cast(data); if (!self->myViewer) return; // already destroyed SoCamera* cam1 = self->myViewer->getViewer(0)->getSoRenderManager()->getCamera(); SoCamera* cam2 = self->myViewer->getViewer(1)->getSoRenderManager()->getCamera(); if (!cam1 || !cam2) return; // missing camera - SoNodeSensor* sensor = static_cast(s); + auto sensor = static_cast(s); SoNode* node = sensor->getAttachedNode(); if (node && node->getTypeId().isDerivedFrom(SoCamera::getClassTypeId())) { if (node == cam1) { @@ -986,8 +986,8 @@ void ManualAlignment::align() if (ok && myDocument) { // Align views myDocument->openCommand(QT_TRANSLATE_NOOP("Command", "Align")); - for (std::vector::iterator it = pViews.begin(); it != pViews.end(); ++it) - alignObject(*it); + for (const auto & pView : pViews) + alignObject(pView); myDocument->commitCommand(); // the alignment was successful so show it in the right view now @@ -1106,7 +1106,7 @@ bool ManualAlignment::computeAlignment(const std::vector& movPts, void ManualAlignment::alignObject(App::DocumentObject *obj) { if (obj->getTypeId().isDerivedFrom(App::GeoFeature::getClassTypeId())) { - App::GeoFeature* geom = static_cast(obj); + auto geom = static_cast(obj); geom->transformPlacement(this->myTransform); } } @@ -1131,7 +1131,7 @@ SoNode* ManualAlignment::pickedPointsSubGraph(const SbVec3f& p, const SbVec3f& n int index = (id-1) % 10; - SoRegPoint* probe = new SoRegPoint(); + auto probe = new SoRegPoint(); probe->base.setValue(p); probe->normal.setValue(n); probe->color.setValue(color_table[index][0],color_table[index][1],color_table[index][2]); @@ -1158,7 +1158,7 @@ void ManualAlignment::slotDeletedObject(const Gui::ViewProvider& Obj) if (Obj.getTypeId().isDerivedFrom(Gui::ViewProviderDocumentObject::getClassTypeId())) { // remove the view provider immediately from the split window bool found = false; - Gui::ViewProviderDocumentObject* vp = const_cast + auto vp = const_cast (static_cast(&Obj)); if (myAlignModel.activeGroup().hasView(vp)) { myViewer->getViewer(0)->removeViewProvider(vp); @@ -1215,14 +1215,14 @@ void ManualAlignment::probePickedCallback(void * ud, SoEventCallback * n) { Q_UNUSED(ud); - Gui::View3DInventorViewer* view = static_cast(n->getUserData()); + auto view = static_cast(n->getUserData()); const SoEvent* ev = n->getEvent(); if (ev->getTypeId() == SoMouseButtonEvent::getClassTypeId()) { // set as handled n->getAction()->setHandled(); n->setHandled(); - const SoMouseButtonEvent * mbe = static_cast(ev); + auto mbe = static_cast(ev); if (mbe->getButton() == SoMouseButtonEvent::BUTTON1 && mbe->getState() == SoButtonEvent::DOWN) { // if we are in 'align' mode then handle the click event ManualAlignment* self = ManualAlignment::instance(); @@ -1231,9 +1231,9 @@ void ManualAlignment::probePickedCallback(void * ud, SoEventCallback * n) Gui::WaitCursor wc; const SoPickedPoint * point = view->getPickedPoint(n); if (point) { - Gui::ViewProvider* vp = static_cast(view->getViewProviderByPath(point->getPath())); + auto vp = static_cast(view->getViewProviderByPath(point->getPath())); if (vp && vp->getTypeId().isDerivedFrom(Gui::ViewProviderDocumentObject::getClassTypeId())) { - Gui::ViewProviderDocumentObject* that = static_cast(vp); + auto that = static_cast(vp); if (self->applyPickedProbe(that, point)) { const SbVec3f& vec = point->getPoint(); Gui::getMainWindow()->showMessage( diff --git a/src/Gui/MayaGestureNavigationStyle.cpp b/src/Gui/MayaGestureNavigationStyle.cpp index 30bc333d94..3fe368d8b8 100644 --- a/src/Gui/MayaGestureNavigationStyle.cpp +++ b/src/Gui/MayaGestureNavigationStyle.cpp @@ -185,7 +185,7 @@ SbBool MayaGestureNavigationStyle::processSoEvent(const SoEvent * const ev) //before this block, mouse button states in NavigationStyle::buttonXdown reflected those before current event arrived. //track mouse button states if (evIsButton) { - const SoMouseButtonEvent * const event = (const SoMouseButtonEvent *) ev; + auto const event = (const SoMouseButtonEvent *) ev; const int button = event->getButton(); const SbBool press //the button was pressed (if false -> released) = event->getState() == SoButtonEvent::DOWN ? true : false; @@ -226,7 +226,7 @@ SbBool MayaGestureNavigationStyle::processSoEvent(const SoEvent * const ev) //track gestures if (evIsGesture) { - const SoGestureEvent* gesture = static_cast(ev); + auto gesture = static_cast(ev); switch(gesture->state) { case SoGestureEvent::SbGSStart: //assert(!inGesture);//start of another gesture before the first finished? Happens all the time for Pan gesture... No idea why! --DeepSOIC @@ -277,7 +277,7 @@ SbBool MayaGestureNavigationStyle::processSoEvent(const SoEvent * const ev) // Mode-independent keyboard handling if (evIsKeyboard) { - const SoKeyboardEvent * const event = (const SoKeyboardEvent *) ev; + auto const event = (const SoKeyboardEvent *) ev; const SbBool press = event->getState() == SoButtonEvent::DOWN ? true : false; switch (event->getKey()) { case SoKeyboardEvent::H: @@ -300,7 +300,7 @@ SbBool MayaGestureNavigationStyle::processSoEvent(const SoEvent * const ev) //mode-independent spaceball/joystick handling if (evIsLoc3) { - const SoMotion3Event * const event = static_cast(ev); + auto const event = static_cast(ev); if (event) this->processMotionEvent(event); processed = true; @@ -317,7 +317,7 @@ SbBool MayaGestureNavigationStyle::processSoEvent(const SoEvent * const ev) //keyboard if (evIsKeyboard) { - const SoKeyboardEvent * const event = (const SoKeyboardEvent *) ev; + auto const event = (const SoKeyboardEvent *) ev; const SbBool press = event->getState() == SoButtonEvent::DOWN ? true : false; switch(event->getKey()){ @@ -352,7 +352,7 @@ SbBool MayaGestureNavigationStyle::processSoEvent(const SoEvent * const ev) // Mouse Button / Spaceball Button handling if (evIsButton) { - const SoMouseButtonEvent * const event = (const SoMouseButtonEvent *) ev; + auto const event = (const SoMouseButtonEvent *) ev; const int button = event->getButton(); const SbBool press //the button was pressed (if false -> released) = event->getState() == SoButtonEvent::DOWN ? true : false; @@ -445,7 +445,7 @@ SbBool MayaGestureNavigationStyle::processSoEvent(const SoEvent * const ev) //gesture start if (evIsGesture && /*!this->button1down &&*/ !this->button2down){//ignore gestures when mouse buttons are down. Button1down check was disabled because of wrong state after doubleclick on sketcher constraint to edit datum - const SoGestureEvent* gesture = static_cast(ev); + auto gesture = static_cast(ev); if (gesture->state == SoGestureEvent::SbGSStart || gesture->state == SoGestureEvent::SbGSUpdate) {//even if we didn't get a start, assume the first update is a start (sort-of fail-safe). if (type.isDerivedFrom(SoGesturePanEvent::getClassTypeId())) { @@ -472,7 +472,7 @@ SbBool MayaGestureNavigationStyle::processSoEvent(const SoEvent * const ev) // Mouse Button / Spaceball Button handling if (evIsButton) { - const SoMouseButtonEvent * const event = (const SoMouseButtonEvent *) ev; + auto const event = (const SoMouseButtonEvent *) ev; const int button = event->getButton(); switch(button){ case SoMouseButtonEvent::BUTTON1: @@ -520,14 +520,14 @@ SbBool MayaGestureNavigationStyle::processSoEvent(const SoEvent * const ev) //the essence part 2! //gesture into camera motion if (evIsGesture){ - const SoGestureEvent* gesture = static_cast(ev); + auto gesture = static_cast(ev); assert(gesture); if (gesture->state == SoGestureEvent::SbGSEnd) { setViewingMode(NavigationStyle::SELECTION); processed=true; } else if (gesture->state == SoGestureEvent::SbGSUpdate){ if(type.isDerivedFrom(SoGesturePinchEvent::getClassTypeId())){ - const SoGesturePinchEvent* const event = static_cast(ev); + auto const event = static_cast(ev); if (this->zoomAtCursor){ //this is just dealing with the pan part of pinch gesture. Taking care of zooming to pos is done in doZoom. SbVec2f panDist = this->normalizePixelPos(event->deltaCenter.getValue()); @@ -539,7 +539,7 @@ SbBool MayaGestureNavigationStyle::processSoEvent(const SoEvent * const ev) processed = true; } if(type.isDerivedFrom(SoGesturePanEvent::getClassTypeId())){ - const SoGesturePanEvent* const event = static_cast(ev); + auto const event = static_cast(ev); //this is just dealing with the pan part of pinch gesture. Taking care of zooming to pos is done in doZoom. SbVec2f panDist = this->normalizePixelPos(event->deltaOffset); NavigationStyle::panCamera(viewer->getSoRenderManager()->getCamera(), ratio, this->panningplane, panDist, SbVec2f(0,0)); @@ -555,7 +555,7 @@ SbBool MayaGestureNavigationStyle::processSoEvent(const SoEvent * const ev) } break;//end of actual navigation case NavigationStyle::SEEK_WAIT_MODE:{ if (evIsButton) { - const SoMouseButtonEvent * const event = (const SoMouseButtonEvent *) ev; + auto const event = (const SoMouseButtonEvent *) ev; const int button = event->getButton(); const SbBool press = event->getState() == SoButtonEvent::DOWN ? true : false; if (button == SoMouseButtonEvent::BUTTON1 && press) { diff --git a/src/Gui/MenuManager.cpp b/src/Gui/MenuManager.cpp index 9b648f818c..9ac8c888df 100644 --- a/src/Gui/MenuManager.cpp +++ b/src/Gui/MenuManager.cpp @@ -103,7 +103,7 @@ MenuItem* MenuItem::findParentOf(const std::string& name) MenuItem* MenuItem::copy() const { - MenuItem* root = new MenuItem; + auto root = new MenuItem; root->setCommand(command()); QList items = getItems(); @@ -161,7 +161,7 @@ void MenuItem::clear() MenuItem& MenuItem::operator << (const std::string& command) { - MenuItem* item = new MenuItem(this); + auto item = new MenuItem(this); item->setCommand(command); return *this; } diff --git a/src/Gui/MouseSelection.cpp b/src/Gui/MouseSelection.cpp index ee4c5c5f07..8fdd43842d 100644 --- a/src/Gui/MouseSelection.cpp +++ b/src/Gui/MouseSelection.cpp @@ -86,7 +86,7 @@ int AbstractMouseSelection::handleEvent(const SoEvent* const ev, const SbViewpor y = h-y; // the origin is at the left bottom corner (instead of left top corner) if (ev->getTypeId().isDerivedFrom(SoMouseButtonEvent::getClassTypeId())) { - const SoMouseButtonEvent* const event = (const SoMouseButtonEvent*) ev; + const auto event = (const SoMouseButtonEvent*) ev; const SbBool press = event->getState() == SoButtonEvent::DOWN ? true : false; if (press) { diff --git a/src/Gui/NaviCube.cpp b/src/Gui/NaviCube.cpp index 0362baee15..86b86ef0d3 100644 --- a/src/Gui/NaviCube.cpp +++ b/src/Gui/NaviCube.cpp @@ -420,7 +420,7 @@ GLuint NaviCubeImplementation::createCubeFaceTex(QtGLWidget* gl, float gap, cons paint.end(); Q_UNUSED(gl); - QOpenGLTexture* texture = new QOpenGLTexture(image.mirrored()); + auto texture = new QOpenGLTexture(image.mirrored()); m_glTextures.push_back(texture); texture->generateMipMaps(); texture->setMinificationFilter(QOpenGLTexture::LinearMipMapLinear); @@ -526,7 +526,7 @@ GLuint NaviCubeImplementation::createButtonTex(QtGLWidget* gl, int button) { //image.save(str(enum2str(button))+str(".png")); Q_UNUSED(gl); - QOpenGLTexture* texture = new QOpenGLTexture(image.mirrored()); + auto texture = new QOpenGLTexture(image.mirrored()); m_glTextures.push_back(texture); texture->generateMipMaps(); texture->setMinificationFilter(QOpenGLTexture::LinearMipMapLinear); @@ -599,7 +599,7 @@ GLuint NaviCubeImplementation::createMenuTex(QtGLWidget* gl, bool forPicking) { } painter.end(); Q_UNUSED(gl); - QOpenGLTexture* texture = new QOpenGLTexture(image.mirrored()); + auto texture = new QOpenGLTexture(image.mirrored()); m_glTextures.push_back(texture); texture->generateMipMaps(); texture->setMinificationFilter(QOpenGLTexture::LinearMipMapLinear); @@ -852,8 +852,8 @@ void NaviCubeImplementation::createContextMenu(const std::vector& c CommandManager& rcCmdMgr = Application::Instance->commandManager(); m_Menu->clear(); - for (vector::const_iterator i = cmd.begin(); i != cmd.end(); i++) { - Command* cmd = rcCmdMgr.getCommandByName(i->c_str()); + for (const auto & i : cmd) { + Command* cmd = rcCmdMgr.getCommandByName(i.c_str()); if (cmd) cmd->addTo(m_Menu); } @@ -902,7 +902,7 @@ void NaviCubeImplementation::drawNaviCube(bool pickMode) { // initializes stuff here when we actually have a context // FIXME actually now that we have Qt5, we could probably do this earlier (as we do not need the opengl context) if (!m_NaviCubeInitialised) { - QtGLWidget* gl = static_cast(m_View3DInventorViewer->viewport()); + auto gl = static_cast(m_View3DInventorViewer->viewport()); if (!gl) return; initNaviCube(gl); @@ -1662,7 +1662,7 @@ bool NaviCubeImplementation::processSoEvent(const SoEvent* ev) { // y += 4; // x -= 2; if (ev->getTypeId().isDerivedFrom(SoMouseButtonEvent::getClassTypeId())) { - const SoMouseButtonEvent* mbev = static_cast(ev); + const auto mbev = static_cast(ev); if (mbev->isButtonPressEvent(mbev, SoMouseButtonEvent::BUTTON1)) return mousePressed(x, y); if (mbev->isButtonReleaseEvent(mbev, SoMouseButtonEvent::BUTTON1)) @@ -1774,7 +1774,7 @@ void ViewZoomToFitCmd::activated(int iMsg) QMenu* NaviCubeImplementation::createNaviCubeMenu() { - QMenu* menu = new QMenu(getMainWindow()); + auto menu = new QMenu(getMainWindow()); menu->setObjectName(str("NaviCube_Menu")); CommandManager& rcCmdMgr = Application::Instance->commandManager(); @@ -1796,12 +1796,12 @@ QMenu* NaviCubeImplementation::createNaviCubeMenu() { commands.emplace_back("ViewZoomToFit"); } - for (vector::iterator i = commands.begin(); i != commands.end(); ++i) { - if (*i == "Separator") { + for (const auto & command : commands) { + if (command == "Separator") { menu->addSeparator(); } else { - Command* cmd = rcCmdMgr.getCommandByName(i->c_str()); + Command* cmd = rcCmdMgr.getCommandByName(command.c_str()); if (cmd) cmd->addTo(menu); } diff --git a/src/Gui/NavigationStyle.cpp b/src/Gui/NavigationStyle.cpp index ffdc8a9122..64e7d8a770 100644 --- a/src/Gui/NavigationStyle.cpp +++ b/src/Gui/NavigationStyle.cpp @@ -282,13 +282,13 @@ int NavigationStyle::getInteractiveCount() const void NavigationStyle::setOrbitStyle(NavigationStyle::OrbitStyle style) { - FCSphereSheetProjector* projector = static_cast(this->spinprojector); + auto projector = static_cast(this->spinprojector); projector->setOrbitStyle(FCSphereSheetProjector::OrbitStyle(style)); } NavigationStyle::OrbitStyle NavigationStyle::getOrbitStyle() const { - FCSphereSheetProjector* projector = static_cast(this->spinprojector); + auto projector = static_cast(this->spinprojector); return NavigationStyle::OrbitStyle(projector->getOrbitStyle()); } @@ -477,7 +477,7 @@ void NavigationStyle::setCameraOrientation(const SbRotation& rot, SbBool moveToC void NavigationStyleP::viewAnimationCB(void * data, SoSensor * sensor) { Q_UNUSED(sensor); - NavigationStyle* that = static_cast(data); + auto that = static_cast(data); if (PRIVATE(that)->animationsteps > 0) { // here the camera rotates from the current rotation to a given // rotation (e.g. the standard views). To get this movement animated @@ -584,7 +584,7 @@ void NavigationStyle::viewAll() float aspect = cam->aspectRatio.getValue(); if (cam->getTypeId() == SoOrthographicCamera::getClassTypeId()) { - SoOrthographicCamera* ocam = (SoOrthographicCamera *)cam; // safe downward cast, knows the type + auto ocam = (SoOrthographicCamera *)cam; // safe downward cast, knows the type if (aspect < 1.0f) ocam->height = cam_height / aspect; else @@ -684,7 +684,7 @@ void NavigationStyle::zoom(SoCamera * cam, float diffvalue) SbName tname = t.getName(); // This will be in the range of <0, ->>. - float multiplicator = float(exp(diffvalue)); + auto multiplicator = float(exp(diffvalue)); if (t.isDerivedFrom(SoOrthographicCamera::getClassTypeId())) { @@ -692,7 +692,7 @@ void NavigationStyle::zoom(SoCamera * cam, float diffvalue) // of the word won't have any visible effect. So we just increase // or decrease the field-of-view values of the camera instead, to // "shrink" the projection size of the model / scene. - SoOrthographicCamera * oc = (SoOrthographicCamera *)cam; + auto oc = (SoOrthographicCamera *)cam; oc->height = oc->height.getValue() * multiplicator; } @@ -1072,8 +1072,8 @@ void NavigationStyle::saveCursorPosition(const SoEvent * const ev) SbViewVolume vv = cam->getViewVolume(ratio); vv.projectToScreen(boundingBoxCenter, boundingBoxCenter); SbVec2s size = vp.getViewportSizePixels(); - short tox = static_cast(boundingBoxCenter[0] * size[0]); - short toy = static_cast(boundingBoxCenter[1] * size[1]); + auto tox = static_cast(boundingBoxCenter[0] * size[0]); + auto toy = static_cast(boundingBoxCenter[1] * size[1]); this->localPos.setValue(tox, toy); } } @@ -1479,7 +1479,7 @@ SbBool NavigationStyle::processEvent(const SoEvent * const ev) if ((curmode == NavigationStyle::SELECTION || curmode == NavigationStyle::IDLE) && !processed) { if (ev->getTypeId().isDerivedFrom(SoMouseButtonEvent::getClassTypeId())) { - SoMouseButtonEvent * const e = (SoMouseButtonEvent *) ev; + auto const e = (SoMouseButtonEvent *) ev; if (SoMouseButtonEvent::isButtonReleaseEvent(e,SoMouseButtonEvent::BUTTON1)) { Gui::Selection().clearSelection(); } @@ -1496,7 +1496,7 @@ SbBool NavigationStyle::processSoEvent(const SoEvent * const ev) //handle mouse wheel zoom if (ev->isOfType(SoMouseWheelEvent::getClassTypeId())) { - const SoMouseWheelEvent * const event = static_cast(ev); + auto const event = static_cast(ev); processed = processWheelEvent(event); viewer->processSoEventBase(ev); offeredtoViewerEventBase = true; @@ -1526,7 +1526,7 @@ void NavigationStyle::syncWithEvent(const SoEvent * const ev) // Keyboard handling if (type.isDerivedFrom(SoKeyboardEvent::getClassTypeId())) { - const SoKeyboardEvent * const event = (const SoKeyboardEvent *) ev; + auto const event = (const SoKeyboardEvent *) ev; const SbBool press = event->getState() == SoButtonEvent::DOWN ? true : false; switch (event->getKey()) { case SoKeyboardEvent::LEFT_CONTROL: @@ -1548,7 +1548,7 @@ void NavigationStyle::syncWithEvent(const SoEvent * const ev) // Mouse Button / Spaceball Button handling if (type.isDerivedFrom(SoMouseButtonEvent::getClassTypeId())) { - const SoMouseButtonEvent * const event = (const SoMouseButtonEvent *) ev; + auto const event = (const SoMouseButtonEvent *) ev; const int button = event->getButton(); const SbBool press = event->getState() == SoButtonEvent::DOWN ? true : false; @@ -1583,7 +1583,7 @@ SbBool NavigationStyle::processMotionEvent(const SoMotion3Event * const ev) SbVec3f dir = ev->getTranslation(); if (camera->getTypeId().isDerivedFrom(SoOrthographicCamera::getClassTypeId())){ - SoOrthographicCamera *oCam = static_cast(camera); + auto oCam = static_cast(camera); oCam->scaleHeight(1.0 + (dir[2] * 0.0001)); dir[2] = 0.0;//don't move the cam for z translation. } @@ -1713,7 +1713,7 @@ void NavigationStyle::openPopupMenu(const SbVec2s& position) { Q_UNUSED(position); // ask workbenches and view provider, ... - MenuItem* view = new MenuItem; + auto view = new MenuItem; Gui::Application::Instance->setupContextMenu("View", view); QMenu contextMenu(viewer->getGLWidget()); @@ -1727,14 +1727,14 @@ void NavigationStyle::openPopupMenu(const SbVec2s& position) // add submenu at the end to select navigation style std::map styles = UserNavigationStyle::getUserFriendlyNames(); - for (std::map::iterator it = styles.begin(); it != styles.end(); ++it) { - QByteArray data(it->first.getName()); - QString name = QApplication::translate(it->first.getName(), it->second.c_str()); + for (const auto & style : styles) { + QByteArray data(style.first.getName()); + QString name = QApplication::translate(style.first.getName(), style.second.c_str()); QAction* item = subMenuGroup.addAction(name); item->setData(data); item->setCheckable(true); - if (it->first == this->getTypeId()) + if (style.first == this->getTypeId()) item->setChecked(true); subMenu.addAction(item); } @@ -1782,11 +1782,11 @@ std::map UserNavigationStyle::getUserFriendlyNames() std::vector types; Base::Type::getAllDerivedFrom(UserNavigationStyle::getClassTypeId(), types); - for (std::vector::iterator it = types.begin(); it != types.end(); ++it) { - if (*it != UserNavigationStyle::getClassTypeId()) { - std::unique_ptr inst(static_cast(it->createInstance())); - if (inst.get()) { - names[*it] = inst->userFriendlyName(); + for (auto & type : types) { + if (type != UserNavigationStyle::getClassTypeId()) { + std::unique_ptr inst(static_cast(type.createInstance())); + if (inst) { + names[type] = inst->userFriendlyName(); } } } diff --git a/src/Gui/OnlineDocumentation.cpp b/src/Gui/OnlineDocumentation.cpp index c6f98accbc..adeff98e7a 100644 --- a/src/Gui/OnlineDocumentation.cpp +++ b/src/Gui/OnlineDocumentation.cpp @@ -287,7 +287,7 @@ void HttpServer::incomingConnection(qintptr socket) // communication with the client is done over this QTcpSocket. QTcpSocket // works asynchronously, this means that all the communication is done // in the two slots readClient() and discardClient(). - QTcpSocket* s = new QTcpSocket(this); + auto s = new QTcpSocket(this); connect(s, SIGNAL(readyRead()), this, SLOT(readClient())); connect(s, SIGNAL(disconnected()), this, SLOT(discardClient())); s->setSocketDescriptor(socket); @@ -311,7 +311,7 @@ void HttpServer::readClient() // This slot is called when the client sent data to the server. The // server looks if it was a GET request and sends back the // corresponding HTML document from the ZIP file. - QTcpSocket* socket = (QTcpSocket*)sender(); + auto socket = (QTcpSocket*)sender(); if (socket->canReadLine()) { QString httpRequestHeader = QString::fromLatin1(socket->readLine()); QStringList lst = httpRequestHeader.simplified().split(QLatin1String(" ")); @@ -345,7 +345,7 @@ void HttpServer::readClient() void HttpServer::discardClient() { - QTcpSocket* socket = (QTcpSocket*)sender(); + auto socket = (QTcpSocket*)sender(); socket->deleteLater(); } diff --git a/src/Gui/OpenCascadeNavigationStyle.cpp b/src/Gui/OpenCascadeNavigationStyle.cpp index 8869703f86..1d219da314 100644 --- a/src/Gui/OpenCascadeNavigationStyle.cpp +++ b/src/Gui/OpenCascadeNavigationStyle.cpp @@ -105,13 +105,13 @@ SbBool OpenCascadeNavigationStyle::processSoEvent(const SoEvent * const ev) // Keyboard handling if (type.isDerivedFrom(SoKeyboardEvent::getClassTypeId())) { - const SoKeyboardEvent * const event = static_cast(ev); + auto const event = static_cast(ev); processed = processKeyboardEvent(event); } // Mouse Button / Spaceball Button handling if (type.isDerivedFrom(SoMouseButtonEvent::getClassTypeId())) { - const SoMouseButtonEvent * const event = (const SoMouseButtonEvent *) ev; + const auto event = (const SoMouseButtonEvent *) ev; const int button = event->getButton(); const SbBool press = event->getState() == SoButtonEvent::DOWN ? true : false; @@ -206,7 +206,7 @@ SbBool OpenCascadeNavigationStyle::processSoEvent(const SoEvent * const ev) // Mouse Movement handling if (type.isDerivedFrom(SoLocation2Event::getClassTypeId())) { this->lockrecenter = true; - const SoLocation2Event * const event = (const SoLocation2Event *) ev; + const auto event = (const SoLocation2Event *) ev; if (this->currentmode == NavigationStyle::ZOOMING) { // OCCT uses horizontal mouse position, not vertical // this->zoomByCursor(posn, prevnormalized); @@ -234,7 +234,7 @@ SbBool OpenCascadeNavigationStyle::processSoEvent(const SoEvent * const ev) // Spaceball & Joystick handling if (type.isDerivedFrom(SoMotion3Event::getClassTypeId())) { - const SoMotion3Event * const event = static_cast(ev); + const auto event = static_cast(ev); if (event) this->processMotionEvent(event); processed = true; diff --git a/src/Gui/OpenSCADNavigationStyle.cpp b/src/Gui/OpenSCADNavigationStyle.cpp index 76a8dc5891..e013541367 100644 --- a/src/Gui/OpenSCADNavigationStyle.cpp +++ b/src/Gui/OpenSCADNavigationStyle.cpp @@ -105,13 +105,13 @@ SbBool OpenSCADNavigationStyle::processSoEvent(const SoEvent * const ev) // Keyboard handling if (type.isDerivedFrom(SoKeyboardEvent::getClassTypeId())) { - const SoKeyboardEvent * const event = static_cast(ev); + const auto event = static_cast(ev); processed = processKeyboardEvent(event); } // Mouse Button / Spaceball Button handling if (type.isDerivedFrom(SoMouseButtonEvent::getClassTypeId())) { - const SoMouseButtonEvent * const event = (const SoMouseButtonEvent *) ev; + const auto event = (const SoMouseButtonEvent *) ev; const int button = event->getButton(); const SbBool press = event->getState() == SoButtonEvent::DOWN ? true : false; @@ -192,7 +192,7 @@ SbBool OpenSCADNavigationStyle::processSoEvent(const SoEvent * const ev) // Mouse Movement handling if (type.isDerivedFrom(SoLocation2Event::getClassTypeId())) { this->lockrecenter = true; - const SoLocation2Event * const event = (const SoLocation2Event *) ev; + const auto event = (const SoLocation2Event *) ev; if (curmode == NavigationStyle::SELECTION) { newmode = NavigationStyle::DRAGGING; saveCursorPosition(ev); @@ -222,7 +222,7 @@ SbBool OpenSCADNavigationStyle::processSoEvent(const SoEvent * const ev) // Spaceball & Joystick handling if (type.isDerivedFrom(SoMotion3Event::getClassTypeId())) { - const SoMotion3Event * const event = static_cast(ev); + const auto event = static_cast(ev); if (event) this->processMotionEvent(event); processed = true; diff --git a/src/Gui/Placement.cpp b/src/Gui/Placement.cpp index 0e3fb59865..cb83affe1d 100644 --- a/src/Gui/Placement.cpp +++ b/src/Gui/Placement.cpp @@ -113,9 +113,9 @@ Placement::Placement(QWidget* parent, Qt::WindowFlags fl) int id = 1; QList sb = this->findChildren(); - for (QList::iterator it = sb.begin(); it != sb.end(); ++it) { - connect(*it, SIGNAL(valueChanged(double)), signalMapper, SLOT(map())); - signalMapper->setMapping(*it, id++); + for (const auto & it : sb) { + connect(it, SIGNAL(valueChanged(double)), signalMapper, SLOT(map())); + signalMapper->setMapping(it, id++); } connect(signalMapper, SIGNAL(mapped(int)), @@ -178,33 +178,33 @@ void Placement::openTransaction() QWidget* Placement::getInvalidInput() const { QList sb = this->findChildren(); - for (QList::iterator it = sb.begin(); it != sb.end(); ++it) { - if (!(*it)->hasValidInput()) - return (*it); + for (const auto & it : sb) { + if (!it->hasValidInput()) + return it; } return nullptr; } void Placement::revertTransformation() { - for (std::set::iterator it = documents.begin(); it != documents.end(); ++it) { - Gui::Document* document = Application::Instance->getDocument(it->c_str()); + for (const auto & it : documents) { + Gui::Document* document = Application::Instance->getDocument(it.c_str()); if (!document) continue; if (!changeProperty) { std::vector obj = document->getDocument()-> getObjectsOfType(App::DocumentObject::getClassTypeId()); if (!obj.empty()) { - for (std::vector::iterator it=obj.begin();it!=obj.end();++it) { + for (const auto & it : obj) { std::map props; - (*it)->getPropertyMap(props); + it->getPropertyMap(props); // search for the placement property std::map::iterator jt; jt = std::find_if(props.begin(), props.end(), find_placement(this->propertyName)); if (jt != props.end()) { - App::PropertyPlacement* property = static_cast(jt->second); + auto property = static_cast(jt->second); Base::Placement cur = property->getValue(); - Gui::ViewProvider* vp = document->getViewProvider(*it); + Gui::ViewProvider* vp = document->getViewProvider(it); if (vp) vp->setTransformation(cur.toMatrix()); } } @@ -226,14 +226,14 @@ void Placement::applyPlacement(const Base::Placement& p, bool incremental) (App::DocumentObject::getClassTypeId(), document->getDocument()->getName()); if (!sel.empty()) { // apply transformation only on view matrix not on placement property - for (std::vector::iterator it=sel.begin();it!=sel.end();++it) { + for (const auto & it : sel) { std::map props; - (*it)->getPropertyMap(props); + it->getPropertyMap(props); // search for the placement property std::map::iterator jt; jt = std::find_if(props.begin(), props.end(), find_placement(this->propertyName)); if (jt != props.end()) { - App::PropertyPlacement* property = static_cast(jt->second); + auto property = static_cast(jt->second); Base::Placement cur = property->getValue(); if (incremental) cur = p * cur; @@ -241,7 +241,7 @@ void Placement::applyPlacement(const Base::Placement& p, bool incremental) cur = p; if (!changeProperty) { - Gui::ViewProvider* vp = document->getViewProvider(*it); + Gui::ViewProvider* vp = document->getViewProvider(it); if (vp) vp->setTransformation(cur.toMatrix()); } else { @@ -277,9 +277,9 @@ void Placement::applyPlacement(const QString& data, bool incremental) (App::DocumentObject::getClassTypeId(), document->getDocument()->getName()); if (!sel.empty()) { document->openCommand(QT_TRANSLATE_NOOP("Command", "Placement")); - for (std::vector::iterator it=sel.begin();it!=sel.end();++it) { + for (const auto & it : sel) { std::map props; - (*it)->getPropertyMap(props); + it->getPropertyMap(props); // search for the placement property std::map::iterator jt; jt = std::find_if(props.begin(), props.end(), find_placement(this->propertyName)); @@ -288,15 +288,15 @@ void Placement::applyPlacement(const QString& data, bool incremental) if (incremental) cmd = QString::fromLatin1( "App.getDocument(\"%1\").%2.%3=%4.multiply(App.getDocument(\"%1\").%2.%3)") - .arg(QString::fromLatin1((*it)->getDocument()->getName()), - QString::fromLatin1((*it)->getNameInDocument()), + .arg(QString::fromLatin1(it->getDocument()->getName()), + QString::fromLatin1(it->getNameInDocument()), QString::fromLatin1(this->propertyName.c_str()), data); else { cmd = QString::fromLatin1( "App.getDocument(\"%1\").%2.%3=%4") - .arg(QString::fromLatin1((*it)->getDocument()->getName()), - QString::fromLatin1((*it)->getNameInDocument()), + .arg(QString::fromLatin1(it->getDocument()->getName()), + QString::fromLatin1(it->getNameInDocument()), QString::fromLatin1(this->propertyName.c_str()), data); } @@ -369,7 +369,7 @@ void Placement::on_selectedVertex_clicked() //combine all pickedpoints into single vector //even if points are from separate objects Base::Vector3d firstSelected; //first selected will be central point when 3 points picked - for (std::vector::iterator it=selection.begin(); it!=selection.end(); ++it){ + for (auto it=selection.begin(); it!=selection.end(); ++it){ std::vector points = it->getPickedPoints(); if (it==selection.begin() && !points.empty()){ firstSelected=points[0]; @@ -615,10 +615,10 @@ bool Placement::onApply() if (ui->applyIncrementalPlacement->isChecked()) { QList sb = this->findChildren(); - for (QList::iterator it = sb.begin(); it != sb.end(); ++it) { - (*it)->blockSignals(true); - (*it)->setValue(0); - (*it)->blockSignals(false); + for (auto & it : sb) { + it->blockSignals(true); + it->setValue(0); + it->blockSignals(false); } } @@ -631,10 +631,10 @@ bool Placement::onApply() void Placement::on_resetButton_clicked() { QList sb = this->findChildren(); - for (QList::iterator it = sb.begin(); it != sb.end(); ++it) { - (*it)->blockSignals(true); - (*it)->setValue(0); - (*it)->blockSignals(false); + for (auto & it : sb) { + it->blockSignals(true); + it->setValue(0); + it->blockSignals(false); } onPlacementChanged(0); diff --git a/src/Gui/PrefWidgets.cpp b/src/Gui/PrefWidgets.cpp index 0765983b2c..a4df5f0fd4 100644 --- a/src/Gui/PrefWidgets.cpp +++ b/src/Gui/PrefWidgets.cpp @@ -494,7 +494,7 @@ void PrefColorButton::restorePreferences() unsigned int icol = (col.red() << 24) | (col.green() << 16) | (col.blue() << 8); - unsigned long lcol = static_cast(icol); + auto lcol = static_cast(icol); lcol = getWindowParameter()->GetUnsigned( entryName(), lcol ); icol = static_cast(lcol); int r = (icol >> 24)&0xff; @@ -515,7 +515,7 @@ void PrefColorButton::savePreferences() QColor col = color(); // (r,g,b,a) with a = 255 (opaque) unsigned int icol = (col.red() << 24) | (col.green() << 16) | (col.blue() << 8) | 255; - unsigned long lcol = static_cast(icol); + auto lcol = static_cast(icol); getWindowParameter()->SetUnsigned( entryName(), lcol ); } diff --git a/src/Gui/ProgressBar.cpp b/src/Gui/ProgressBar.cpp index 685d9cebc9..4ebd809056 100644 --- a/src/Gui/ProgressBar.cpp +++ b/src/Gui/ProgressBar.cpp @@ -70,10 +70,10 @@ struct ProgressBarPrivate parent = QWidget::find(window->winId()); } while (parent) { - QMessageBox* dlg = qobject_cast(parent); + auto* dlg = qobject_cast(parent); if (dlg && dlg->isModal()) return true; - QProgressDialog* pd = qobject_cast(parent); + auto* pd = qobject_cast(parent); if (pd) return true; parent = parent->parentWidget(); @@ -558,7 +558,7 @@ bool ProgressBar::eventFilter(QObject* o, QEvent* e) QThread* thr = this->thread(); // this is the main thread if (thr != currentThread) { if (e->type() == QEvent::KeyPress) { - QKeyEvent* ke = static_cast(e); + auto ke = static_cast(e); if (ke->key() == Qt::Key_Escape) { // cancel the operation sequencer->tryToCancel(); @@ -574,7 +574,7 @@ bool ProgressBar::eventFilter(QObject* o, QEvent* e) // check for ESC case QEvent::KeyPress: { - QKeyEvent* ke = static_cast(e); + auto ke = static_cast(e); if (ke->key() == Qt::Key_Escape) { // eventFilter() was called from the application 50 times without performing a new step (app could hang) if (d->observeEventFilter > 50) { diff --git a/src/Gui/PropertyPage.cpp b/src/Gui/PropertyPage.cpp index 388bd8e12c..b5e92d6ae0 100644 --- a/src/Gui/PropertyPage.cpp +++ b/src/Gui/PropertyPage.cpp @@ -128,7 +128,7 @@ PreferenceUiForm::PreferenceUiForm(const QString& fn, QWidget* parent) file.close(); if (form) { this->setWindowTitle(form->windowTitle()); - QVBoxLayout *layout = new QVBoxLayout; + auto layout = new QVBoxLayout; layout->addWidget(form); setLayout(layout); } diff --git a/src/Gui/PropertyView.cpp b/src/Gui/PropertyView.cpp index 196a58ff13..cbdf15c2bc 100644 --- a/src/Gui/PropertyView.cpp +++ b/src/Gui/PropertyView.cpp @@ -68,7 +68,7 @@ static ParameterGrp::handle _GetParam() { PropertyView::PropertyView(QWidget *parent) : QWidget(parent), SelectionObserver(false, ResolveMode::NoResolve) { - QGridLayout* pLayout = new QGridLayout( this ); + auto pLayout = new QGridLayout( this ); pLayout->setSpacing(0); pLayout->setMargin (0); @@ -412,7 +412,7 @@ void PropertyView::onTimer() { nameType.propName = prop->getName(); nameType.propId = prop->getTypeId().getKey(); - std::vector::iterator pi = std::find_if(propDataMap.begin(), propDataMap.end(), PropFind(nameType)); + auto pi = std::find_if(propDataMap.begin(), propDataMap.end(), PropFind(nameType)); if (pi != propDataMap.end()) { pi->propList.push_back(prop); } @@ -433,7 +433,7 @@ void PropertyView::onTimer() { nameType.propName = pt->first; nameType.propId = pt->second->getTypeId().getKey(); - std::vector::iterator pi = std::find_if(propViewMap.begin(), propViewMap.end(), PropFind(nameType)); + auto pi = std::find_if(propViewMap.begin(), propViewMap.end(), PropFind(nameType)); if (pi != propViewMap.end()) { pi->propList.push_back(pt->second); } @@ -548,8 +548,8 @@ PropertyDockView::PropertyDockView(Gui::Document* pcDocument, QWidget *parent) { setWindowTitle(tr("Property View")); - PropertyView* view = new PropertyView(this); - QGridLayout* pLayout = new QGridLayout(this); + auto view = new PropertyView(this); + auto pLayout = new QGridLayout(this); pLayout->setSpacing(0); pLayout->setMargin (0); pLayout->addWidget(view, 0, 0); diff --git a/src/Gui/PythonConsole.cpp b/src/Gui/PythonConsole.cpp index 95653adf6c..a0506cd1f4 100644 --- a/src/Gui/PythonConsole.cpp +++ b/src/Gui/PythonConsole.cpp @@ -511,7 +511,7 @@ void PythonConsole::OnChange(Base::Subject &rCaller, const char* sR if (it != d->colormap.end()) { QColor color = it.value(); unsigned int col = (color.red() << 24) | (color.green() << 16) | (color.blue() << 8); - unsigned long value = static_cast(col); + auto value = static_cast(col); value = rGrp.GetUnsigned(sReason, value); col = static_cast(value); color.setRgb((col>>24)&0xff, (col>>16)&0xff, (col>>8)&0xff); @@ -897,11 +897,11 @@ void PythonConsole::printStatement( const QString& cmd ) QTextCursor cursor = textCursor(); QStringList statements = cmd.split(QLatin1String("\n")); - for (QStringList::Iterator it = statements.begin(); it != statements.end(); ++it) { + for (const auto & statement : statements) { // go to the end before inserting new text cursor.movePosition(QTextCursor::End); - cursor.insertText( *it ); - d->history.append( *it ); + cursor.insertText( statement ); + d->history.append( statement ); printPrompt(PythonConsole::Complete); } } @@ -925,7 +925,7 @@ void PythonConsole::visibilityChanged (bool visible) void PythonConsole::changeEvent(QEvent *e) { if (e->type() == QEvent::ParentChange) { - QDockWidget* dw = qobject_cast(this->parentWidget()); + auto dw = qobject_cast(this->parentWidget()); if (dw) { connect(dw, SIGNAL(visibilityChanged(bool)), this, SLOT(visibilityChanged(bool))); @@ -935,7 +935,7 @@ void PythonConsole::changeEvent(QEvent *e) QPalette pal = palette(); QColor color = pal.windowText().color(); unsigned int text = (color.red() << 24) | (color.green() << 16) | (color.blue() << 8); - unsigned long value = static_cast(text); + auto value = static_cast(text); // if this parameter is not already set use the style's window text color value = getWindowParameter()->GetUnsigned("Text", value); getWindowParameter()->SetUnsigned("Text", value); @@ -1029,8 +1029,8 @@ bool PythonConsole::canInsertFromMimeData (const QMimeData * source) const return true; if (source->hasUrls()) { QList uri = source->urls(); - for (QList::Iterator it = uri.begin(); it != uri.end(); ++it) { - QFileInfo info((*it).toLocalFile()); + for (const auto & it : uri) { + QFileInfo info(it.toLocalFile()); if (info.exists() && info.isFile()) { QString ext = info.suffix().toLower(); if (ext == QLatin1String("py") || ext == QLatin1String("fcmacro")) @@ -1054,9 +1054,9 @@ void PythonConsole::insertFromMimeData (const QMimeData * source) bool existingFile = false; if (source->hasUrls()) { QList uri = source->urls(); - for (QList::Iterator it = uri.begin(); it != uri.end(); ++it) { + for (const auto & it : uri) { // get the file name and check the extension - QFileInfo info((*it).toLocalFile()); + QFileInfo info(it.toLocalFile()); QString ext = info.suffix().toLower(); if (info.exists()) { existingFile = true; @@ -1098,7 +1098,7 @@ QTextCursor PythonConsole::inputBegin() const QMimeData * PythonConsole::createMimeDataFromSelection () const { - QMimeData* mime = new QMimeData(); + auto mime = new QMimeData(); switch (d->type) { case PythonConsoleP::Normal: @@ -1321,8 +1321,8 @@ void PythonConsole::onSaveHistoryAs() if (f.open(QIODevice::WriteOnly)) { QTextStream t (&f); const QStringList& hist = d->history.values(); - for (QStringList::ConstIterator it = hist.begin(); it != hist.end(); ++it) - t << *it << "\n"; + for (const auto & it : hist) + t << it << "\n"; f.close(); } } @@ -1420,8 +1420,8 @@ void PythonConsole::saveHistory() const // only save last 100 entries so we don't inflate forever... if (hist.length() > 100) hist = hist.mid(hist.length()-100); - for (QStringList::ConstIterator it = hist.cbegin(); it != hist.cend(); ++it) - t << *it << "\n"; + for (const auto & it : hist) + t << it << "\n"; f.close(); } } diff --git a/src/Gui/PythonDebugger.cpp b/src/Gui/PythonDebugger.cpp index 8a50016fe8..81c472b379 100644 --- a/src/Gui/PythonDebugger.cpp +++ b/src/Gui/PythonDebugger.cpp @@ -531,14 +531,14 @@ void PythonDebugger::showDebugMarker(const QString& fn, int line) { PythonEditorView* edit = nullptr; QList mdis = getMainWindow()->windows(); - for (QList::iterator it = mdis.begin(); it != mdis.end(); ++it) { - edit = qobject_cast(*it); + for (const auto & mdi : mdis) { + edit = qobject_cast(mdi); if (edit && edit->fileName() == fn) break; } if (!edit) { - PythonEditor* editor = new PythonEditor(); + auto editor = new PythonEditor(); editor->setWindowIcon(Gui::BitmapFactory().iconFromTheme("applications-python")); edit = new PythonEditorView(editor, getMainWindow()); edit->open(fn); @@ -554,8 +554,8 @@ void PythonDebugger::hideDebugMarker(const QString& fn) { PythonEditorView* edit = nullptr; QList mdis = getMainWindow()->windows(); - for (QList::iterator it = mdis.begin(); it != mdis.end(); ++it) { - edit = qobject_cast(*it); + for (const auto & mdi : mdis) { + edit = qobject_cast(mdi); if (edit && edit->fileName() == fn) { edit->hideDebugMarker(); break; @@ -577,7 +577,7 @@ static PyCodeObject* PyFrame_GetCode(PyFrameObject *frame) // http://stuff.mit.edu/afs/sipb/project/python/src/python2.2-2.2.2/Modules/_hotshot.c int PythonDebugger::tracer_callback(PyObject *obj, PyFrameObject *frame, int what, PyObject * /*arg*/) { - PythonDebuggerPy* self = static_cast(obj); + auto self = static_cast(obj); PythonDebugger* dbg = self->dbg; if (dbg->d->trystop) PyErr_SetInterrupt(); diff --git a/src/Gui/PythonEditor.cpp b/src/Gui/PythonEditor.cpp index 8c34fd62de..4446deb3e5 100644 --- a/src/Gui/PythonEditor.cpp +++ b/src/Gui/PythonEditor.cpp @@ -72,10 +72,10 @@ PythonEditor::PythonEditor(QWidget* parent) this->setSyntaxHighlighter(new PythonSyntaxHighlighter(this)); // set acelerators - QShortcut* comment = new QShortcut(this); + auto comment = new QShortcut(this); comment->setKey(QKeySequence(QString::fromLatin1("ALT+C"))); - QShortcut* uncomment = new QShortcut(this); + auto uncomment = new QShortcut(this); uncomment->setKey(QKeySequence(QString::fromLatin1("ALT+U"))); connect(comment, SIGNAL(activated()), diff --git a/src/Gui/PythonWrapper.cpp b/src/Gui/PythonWrapper.cpp index ced8eb0295..49aae19090 100644 --- a/src/Gui/PythonWrapper.cpp +++ b/src/Gui/PythonWrapper.cpp @@ -181,7 +181,7 @@ PythonToCppFunc isBaseQuantity_PythonToCpp_QVariantConvertible(PyObject* obj) #if defined (HAVE_PYSIDE) Base::Quantity convertWrapperToQuantity(const PySide::PyObjectWrapper &w) { - PyObject* pyIn = static_cast(w); + auto pyIn = static_cast(w); if (PyObject_TypeCheck(pyIn, &(Base::QuantityPy::Type))) { return *static_cast(pyIn)->getQuantityPtr(); } @@ -351,7 +351,7 @@ QObject* PythonWrapper::toQObject(const Py::Object& pyobject) PyTypeObject * type = getPyTypeObjectForTypeName(); if (type) { if (Shiboken::Object::checkType(pyobject.ptr())) { - SbkObject* sbkobject = reinterpret_cast(pyobject.ptr()); + auto sbkobject = reinterpret_cast(pyobject.ptr()); void* cppobject = Shiboken::Object::cppPointer(sbkobject, type); return reinterpret_cast(cppobject); } @@ -377,7 +377,7 @@ QGraphicsItem* PythonWrapper::toQGraphicsItem(PyObject* pyPtr) PyTypeObject* type = getPyTypeObjectForTypeName(); if (type) { if (Shiboken::Object::checkType(pyPtr)) { - SbkObject* sbkobject = reinterpret_cast(pyPtr); + auto sbkobject = reinterpret_cast(pyPtr); void* cppobject = Shiboken::Object::cppPointer(sbkobject, type); return reinterpret_cast(cppobject); } @@ -397,7 +397,7 @@ QGraphicsObject* PythonWrapper::toQGraphicsObject(PyObject* pyPtr) PyTypeObject* type = getPyTypeObjectForTypeName(); if (type) { if (Shiboken::Object::checkType(pyPtr)) { - SbkObject* sbkobject = reinterpret_cast(pyPtr); + auto sbkobject = reinterpret_cast(pyPtr); void* cppobject = Shiboken::Object::cppPointer(sbkobject, type); return reinterpret_cast(cppobject); } @@ -433,7 +433,7 @@ QIcon *PythonWrapper::toQIcon(PyObject *pyobj) PyTypeObject * type = getPyTypeObjectForTypeName(); if(type) { if (Shiboken::Object::checkType(pyobj)) { - SbkObject* sbkobject = reinterpret_cast(pyobj); + auto sbkobject = reinterpret_cast(pyobj); void* cppobject = Shiboken::Object::cppPointer(sbkobject, type); return reinterpret_cast(cppobject); } @@ -464,7 +464,7 @@ QDir* PythonWrapper::toQDir(PyObject* pyobj) PyTypeObject* type = getPyTypeObjectForTypeName(); if (type) { if (Shiboken::Object::checkType(pyobj)) { - SbkObject* sbkobject = reinterpret_cast(pyobj); + auto sbkobject = reinterpret_cast(pyobj); void* cppobject = Shiboken::Object::cppPointer(sbkobject, type); return reinterpret_cast(cppobject); } @@ -484,7 +484,7 @@ Py::Object PythonWrapper::fromQObject(QObject* object, const char* className) // PyTypeObject * type = getPyTypeObjectForTypeName(); if (type) { - SbkObjectType* sbk_type = reinterpret_cast(type); + auto sbk_type = reinterpret_cast(type); std::string typeName; if (className) typeName = className; @@ -512,7 +512,7 @@ Py::Object PythonWrapper::fromQWidget(QWidget* widget, const char* className) // PyTypeObject * type = getPyTypeObjectForTypeName(); if (type) { - SbkObjectType* sbk_type = reinterpret_cast(type); + auto sbk_type = reinterpret_cast(type); std::string typeName; if (className) typeName = className; diff --git a/src/Gui/QuantitySpinBox.cpp b/src/Gui/QuantitySpinBox.cpp index 82d11bd677..3c6e472fce 100644 --- a/src/Gui/QuantitySpinBox.cpp +++ b/src/Gui/QuantitySpinBox.cpp @@ -212,8 +212,8 @@ public: } else if (len > 1) { bool decOccurred = false; - for (int i = 0; igetName()), true); path.setDocumentObjectName(std::string(obj->getNameInDocument()), true); - for (QStringList::iterator it = list.begin(); it != list.end(); ++it) { - path << App::ObjectIdentifier::Component::SimpleComponent(it->toLatin1().constData()); + for (const auto & it : list) { + path << App::ObjectIdentifier::Component::SimpleComponent(it.toLatin1().constData()); } if (path.getProperty()) @@ -563,7 +563,7 @@ void QuantitySpinBox::openFormulaDialog() Q_ASSERT(isBound()); Q_D(const QuantitySpinBox); - Gui::Dialog::DlgExpressionInput* box = new Gui::Dialog::DlgExpressionInput(getPath(), getExpression(), d->unit, this); + auto box = new Gui::Dialog::DlgExpressionInput(getPath(), getExpression(), d->unit, this); QObject::connect(box, &Gui::Dialog::DlgExpressionInput::finished, [=]() { if (box->result() == QDialog::Accepted) setExpression(box->getExpression()); @@ -904,7 +904,7 @@ void QuantitySpinBox::focusInEvent(QFocusEvent * event) event->reason() == Qt::ShortcutFocusReason) { if (isBound() && getExpression() && lineEdit()->isReadOnly()) { - QHelpEvent * helpEvent = new QHelpEvent(QEvent::ToolTip, QPoint( 0, rect().height() ), mapToGlobal( QPoint( 0, rect().height() ) )); + auto helpEvent = new QHelpEvent(QEvent::ToolTip, QPoint( 0, rect().height() ), mapToGlobal( QPoint( 0, rect().height() ) )); QApplication::postEvent(this, helpEvent); lineEdit()->setSelection(0, 0); } @@ -937,14 +937,14 @@ void QuantitySpinBox::selectNumber() QChar g = locale().groupSeparator(); QChar n = locale().negativeSign(); - for (QString::const_iterator it = str.cbegin(); it != str.cend(); ++it) { - if (it->isDigit()) + for (auto it : str) { + if (it.isDigit()) i++; - else if (*it == d) + else if (it == d) i++; - else if (*it == g) + else if (it == g) i++; - else if (*it == n) + else if (it == n) i++; else // any non-number character break; diff --git a/src/Gui/ReportView.cpp b/src/Gui/ReportView.cpp index 82a8dfc1b5..b27a400227 100644 --- a/src/Gui/ReportView.cpp +++ b/src/Gui/ReportView.cpp @@ -58,7 +58,7 @@ ReportView::ReportView( QWidget* parent ) setObjectName(QLatin1String("ReportOutput")); resize( 529, 162 ); - QGridLayout* tabLayout = new QGridLayout( this ); + auto tabLayout = new QGridLayout( this ); tabLayout->setSpacing( 0 ); tabLayout->setMargin( 0 ); @@ -141,7 +141,7 @@ void ReportHighlighter::highlightBlock (const QString & text) { if (text.isEmpty()) return; - TextBlockData* ud = static_cast(this->currentBlockUserData()); + auto ud = static_cast(this->currentBlockUserData()); if (!ud) { ud = new TextBlockData; this->setCurrentBlockUserData(ud); @@ -154,26 +154,26 @@ void ReportHighlighter::highlightBlock (const QString & text) QVector block = ud->block; int start = 0; - for (QVector::Iterator it = block.begin(); it != block.end(); ++it) { - switch (it->type) + for (const auto & it : block) { + switch (it.type) { case Message: - setFormat(start, it->length-start, txtCol); + setFormat(start, it.length-start, txtCol); break; case Warning: - setFormat(start, it->length-start, warnCol); + setFormat(start, it.length-start, warnCol); break; case Error: - setFormat(start, it->length-start, errCol); + setFormat(start, it.length-start, errCol); break; case LogText: - setFormat(start, it->length-start, logCol); + setFormat(start, it.length-start, logCol); break; default: break; } - start = it->length; + start = it.length; } } @@ -305,7 +305,7 @@ void ReportOutputObserver::showReportView() bool ReportOutputObserver::eventFilter(QObject *obj, QEvent *event) { if (event->type() == QEvent::User && obj == reportView.data()) { - CustomReportEvent* cr = dynamic_cast(event); + auto cr = dynamic_cast(event); if (cr) { ReportHighlighter::Paragraph msgType = cr->messageType(); if (msgType == ReportHighlighter::Warning) { @@ -478,7 +478,7 @@ void ReportOutput::SendLog(const std::string& msg, Base::LogStyle level) } // Send the event to itself to allow thread-safety. Qt will delete it when done. - CustomReportEvent* ev = new CustomReportEvent(style, qMsg); + auto ev = new CustomReportEvent(style, qMsg); QApplication::postEvent(this, ev); } @@ -486,7 +486,7 @@ void ReportOutput::customEvent ( QEvent* ev ) { // Appends the text stored in the event to the text view if ( ev->type() == QEvent::User ) { - CustomReportEvent* ce = (CustomReportEvent*)ev; + auto ce = (CustomReportEvent*)ev; reportHl->setParagraphType(ce->messageType()); bool showTimecode = getWindowParameter()->GetBool("checkShowReportTimecode", true); @@ -516,7 +516,7 @@ void ReportOutput::customEvent ( QEvent* ev ) bool ReportOutput::event(QEvent* event) { if (event && event->type() == QEvent::ShortcutOverride) { - QKeyEvent * kevent = static_cast(event); + auto kevent = static_cast(event); if (kevent == QKeySequence::Copy) kevent->accept(); } @@ -529,7 +529,7 @@ void ReportOutput::changeEvent(QEvent *ev) QPalette pal = palette(); QColor color = pal.windowText().color(); unsigned int text = (color.red() << 24) | (color.green() << 16) | (color.blue() << 8); - unsigned long value = static_cast(text); + auto value = static_cast(text); // if this parameter is not already set use the style's window text color value = getWindowParameter()->GetUnsigned("colorText", value); getWindowParameter()->SetUnsigned("colorText", value); @@ -544,13 +544,13 @@ void ReportOutput::contextMenuEvent ( QContextMenuEvent * e ) bool bShowOnWarn = ReportOutputParameter::showOnWarning(); bool bShowOnError = ReportOutputParameter::showOnError(); - QMenu* menu = new QMenu(this); - QMenu* optionMenu = new QMenu( menu ); + auto menu = new QMenu(this); + auto optionMenu = new QMenu( menu ); optionMenu->setTitle(tr("Options")); menu->addMenu(optionMenu); menu->addSeparator(); - QMenu* displayMenu = new QMenu(optionMenu); + auto displayMenu = new QMenu(optionMenu); displayMenu->setTitle(tr("Display message types")); optionMenu->addMenu(displayMenu); @@ -570,7 +570,7 @@ void ReportOutput::contextMenuEvent ( QContextMenuEvent * e ) errAct->setCheckable(true); errAct->setChecked(bErr); - QMenu* showOnMenu = new QMenu (optionMenu); + auto showOnMenu = new QMenu (optionMenu); showOnMenu->setTitle(tr("Show output window on")); optionMenu->addMenu(showOnMenu); diff --git a/src/Gui/RevitNavigationStyle.cpp b/src/Gui/RevitNavigationStyle.cpp index f8e337ebbc..ef1518814a 100644 --- a/src/Gui/RevitNavigationStyle.cpp +++ b/src/Gui/RevitNavigationStyle.cpp @@ -105,13 +105,13 @@ SbBool RevitNavigationStyle::processSoEvent(const SoEvent * const ev) // Keyboard handling if (type.isDerivedFrom(SoKeyboardEvent::getClassTypeId())) { - const SoKeyboardEvent * const event = static_cast(ev); + const auto event = static_cast(ev); processed = processKeyboardEvent(event); } // Mouse Button / Spaceball Button handling if (type.isDerivedFrom(SoMouseButtonEvent::getClassTypeId())) { - const SoMouseButtonEvent * const event = (const SoMouseButtonEvent *) ev; + const auto event = (const SoMouseButtonEvent *) ev; const int button = event->getButton(); const SbBool press = event->getState() == SoButtonEvent::DOWN ? true : false; @@ -196,7 +196,7 @@ SbBool RevitNavigationStyle::processSoEvent(const SoEvent * const ev) // Mouse Movement handling if (type.isDerivedFrom(SoLocation2Event::getClassTypeId())) { this->lockrecenter = true; - const SoLocation2Event * const event = (const SoLocation2Event *) ev; + const auto event = (const SoLocation2Event *) ev; if (this->currentmode == NavigationStyle::ZOOMING) { this->zoomByCursor(posn, prevnormalized); processed = true; @@ -216,7 +216,7 @@ SbBool RevitNavigationStyle::processSoEvent(const SoEvent * const ev) // Spaceball & Joystick handling if (type.isDerivedFrom(SoMotion3Event::getClassTypeId())) { - const SoMotion3Event * const event = static_cast(ev); + const auto event = static_cast(ev); if (event) this->processMotionEvent(event); processed = true; diff --git a/src/Gui/SceneInspector.cpp b/src/Gui/SceneInspector.cpp index d75a25b65b..fa2bff7173 100644 --- a/src/Gui/SceneInspector.cpp +++ b/src/Gui/SceneInspector.cpp @@ -93,7 +93,7 @@ void SceneModel::setNode(QModelIndex index, SoNode* node) { this->setData(index, QVariant(QString::fromLatin1(node->getTypeId().getName()))); if (node->getTypeId().isDerivedFrom(SoGroup::getClassTypeId())) { - SoGroup *group = static_cast(node); + auto group = static_cast(node); // insert SoGroup icon this->insertColumns(0,2,index); this->insertRows(0,group->getNumChildren(), index); @@ -137,7 +137,7 @@ DlgInspector::DlgInspector(QWidget* parent, Qt::WindowFlags fl) ui->setupUi(this); setWindowTitle(tr("Scene Inspector")); - SceneModel* model = new SceneModel(this); + auto model = new SceneModel(this); ui->treeView->setModel(model); ui->treeView->setRootIsDecorated(true); } @@ -155,7 +155,7 @@ void DlgInspector::setDocument(Gui::Document* doc) { setNodeNames(doc); - View3DInventor* view = qobject_cast(doc->getActiveView()); + auto view = qobject_cast(doc->getActiveView()); if (view) { View3DInventorViewer* viewer = view->getViewer(); setNode(viewer->getSceneGraph()); @@ -165,7 +165,7 @@ void DlgInspector::setDocument(Gui::Document* doc) void DlgInspector::setNode(SoNode* node) { - SceneModel* model = static_cast(ui->treeView->model()); + auto model = static_cast(ui->treeView->model()); model->setNode(node); QHeaderView* header = ui->treeView->header(); @@ -178,8 +178,8 @@ void DlgInspector::setNodeNames(Gui::Document* doc) std::vector vps = doc->getViewProvidersOfType (Gui::ViewProviderDocumentObject::getClassTypeId()); QHash nodeNames; - for (std::vector::iterator it = vps.begin(); it != vps.end(); ++it) { - Gui::ViewProviderDocumentObject* vp = static_cast(*it); + for (const auto & it : vps) { + auto vp = static_cast(it); App::DocumentObject* obj = vp->getObject(); if (obj) { QString label = QString::fromUtf8(obj->Label.getValue()); @@ -187,15 +187,15 @@ void DlgInspector::setNodeNames(Gui::Document* doc) } std::vector modes = vp->getDisplayMaskModes(); - for (std::vector::iterator jt = modes.begin(); jt != modes.end(); ++jt) { - SoNode* node = vp->getDisplayMaskMode(jt->c_str()); + for (const auto & mode : modes) { + SoNode* node = vp->getDisplayMaskMode(mode.c_str()); if (node) { - nodeNames[node] = QString::fromStdString(*jt); + nodeNames[node] = QString::fromStdString(mode); } } } - SceneModel* model = static_cast(ui->treeView->model()); + auto model = static_cast(ui->treeView->model()); model->setNodeNames(nodeNames); } @@ -214,7 +214,7 @@ void DlgInspector::on_refreshButton_clicked() if (doc) { setNodeNames(doc); - View3DInventor* view = qobject_cast(doc->getActiveView()); + auto view = qobject_cast(doc->getActiveView()); if (view) { View3DInventorViewer* viewer = view->getViewer(); setNode(viewer->getSceneGraph()); @@ -222,7 +222,7 @@ void DlgInspector::on_refreshButton_clicked() } } else { - SceneModel* model = static_cast(ui->treeView->model()); + auto model = static_cast(ui->treeView->model()); model->clear(); } } diff --git a/src/Gui/Selection.cpp b/src/Gui/Selection.cpp index ec45a76e80..2346d1b158 100644 --- a/src/Gui/Selection.cpp +++ b/src/Gui/Selection.cpp @@ -626,8 +626,7 @@ int SelectionSingleton::getAsPropertyLinkSubList(App::PropertyLinkSubList &prop) std::vector sel = this->getSelectionEx(); std::vector objs; objs.reserve(sel.size() * 2); std::vector subs; subs.reserve(sel.size()*2); - for (std::size_t iobj = 0; iobj < sel.size(); iobj++) { - Gui::SelectionObject &selitem = sel[iobj]; + for (auto & selitem : sel) { App::DocumentObject* obj = selitem.getObject(); const std::vector &subnames = selitem.getSubNames(); @@ -637,9 +636,9 @@ int SelectionSingleton::getAsPropertyLinkSubList(App::PropertyLinkSubList &prop) subs.emplace_back(); } else { - for (std::size_t isub = 0; isub < subnames.size(); isub++) { + for (const auto & subname : subnames) { objs.push_back(obj); - subs.push_back(subnames[isub]); + subs.push_back(subname); } } } @@ -1259,9 +1258,9 @@ bool SelectionSingleton::addSelections(const char* pDocName, const char* pObject } bool update = false; - for(std::vector::const_iterator it = pSubNames.begin(); it != pSubNames.end(); ++it) { + for(const auto & pSubName : pSubNames) { _SelObj temp; - int ret = checkSelection(pDocName, pObjectName, it->c_str(), ResolveMode::NoResolve, temp); + int ret = checkSelection(pDocName, pObjectName, pSubName.c_str(), ResolveMode::NoResolve, temp); if (ret!=0) continue; @@ -2069,7 +2068,7 @@ PyObject *SelectionSingleton::sAddSelection(PyObject * /*self*/, PyObject *args) x = 0, y = 0, z = 0; if (PyArg_ParseTuple(args, "O!|sfffO!", &(App::DocumentObjectPy::Type),&object, &subname,&x,&y,&z,&PyBool_Type,&clearPreselect)) { - App::DocumentObjectPy* docObjPy = static_cast(object); + auto docObjPy = static_cast(object); App::DocumentObject* docObj = docObjPy->getDocumentObjectPtr(); if (!docObj || !docObj->getNameInDocument()) { PyErr_SetString(Base::PyExc_FC_GeneralError, "Cannot check invalid object"); @@ -2087,7 +2086,7 @@ PyObject *SelectionSingleton::sAddSelection(PyObject * /*self*/, PyObject *args) if (PyArg_ParseTuple(args, "O!O|O!", &(App::DocumentObjectPy::Type),&object, &sequence,&PyBool_Type,&clearPreselect)) { - App::DocumentObjectPy* docObjPy = static_cast(object); + auto docObjPy = static_cast(object); App::DocumentObject* docObj = docObjPy->getDocumentObjectPtr(); if (!docObj || !docObj->getNameInDocument()) { PyErr_SetString(Base::PyExc_FC_GeneralError, "Cannot check invalid object"); @@ -2125,7 +2124,7 @@ PyObject *SelectionSingleton::sUpdateSelection(PyObject * /*self*/, PyObject *ar &object, &subname)) return nullptr; - App::DocumentObjectPy* docObjPy = static_cast(object); + auto docObjPy = static_cast(object); App::DocumentObject* docObj = docObjPy->getDocumentObjectPtr(); if (!docObj || !docObj->getNameInDocument()) { PyErr_SetString(Base::PyExc_FC_GeneralError, "Cannot check invalid object"); @@ -2155,7 +2154,7 @@ PyObject *SelectionSingleton::sRemoveSelection(PyObject * /*self*/, PyObject *ar if (!PyArg_ParseTuple(args, "O!|s", &(App::DocumentObjectPy::Type),&object,&subname)) return nullptr; - App::DocumentObjectPy* docObjPy = static_cast(object); + auto docObjPy = static_cast(object); App::DocumentObject* docObj = docObjPy->getDocumentObjectPtr(); if (!docObj || !docObj->getNameInDocument()) { PyErr_SetString(Base::PyExc_FC_GeneralError, "Cannot check invalid object"); @@ -2210,7 +2209,7 @@ PyObject *SelectionSingleton::sIsSelected(PyObject * /*self*/, PyObject *args) return nullptr; try { - App::DocumentObjectPy* docObj = static_cast(object); + auto docObj = static_cast(object); bool ok = Selection().isSelected(docObj->getDocumentObjectPtr(), subname, toEnum(resolve)); return Py_BuildValue("O", (ok ? Py_True : Py_False)); @@ -2254,13 +2253,13 @@ PyObject *SelectionSingleton::sGetSelection(PyObject * /*self*/, PyObject *args) std::set noduplicates; std::vector selectedObjects; // keep the order of selection Py::List list; - for (std::vector::iterator it = sel.begin(); it != sel.end(); ++it) { - if (noduplicates.insert(it->pObject).second) { - selectedObjects.push_back(it->pObject); + for (const auto & it : sel) { + if (noduplicates.insert(it.pObject).second) { + selectedObjects.push_back(it.pObject); } } - for (std::vector::iterator it = selectedObjects.begin(); it != selectedObjects.end(); ++it) { - list.append(Py::asObject((*it)->getPyObject())); + for (const auto & selectedObject : selectedObjects) { + list.append(Py::asObject(selectedObject->getPyObject())); } return Py::new_reference_to(list); } @@ -2293,7 +2292,7 @@ PyObject *SelectionSingleton::sSetPreselection(PyObject * /*self*/, PyObject *ar static char *kwlist[] = {"obj","subname","x","y","z","tp",nullptr}; if (PyArg_ParseTupleAndKeywords(args, kwd, "O!|sfffi", kwlist, &(App::DocumentObjectPy::Type),&object,&subname,&x,&y,&z,&type)) { - App::DocumentObjectPy* docObjPy = static_cast(object); + auto docObjPy = static_cast(object); App::DocumentObject* docObj = docObjPy->getDocumentObjectPtr(); if (!docObj || !docObj->getNameInDocument()) { PyErr_SetString(Base::PyExc_FC_GeneralError, "Cannot check invalid object"); @@ -2343,8 +2342,8 @@ PyObject *SelectionSingleton::sGetCompleteSelection(PyObject * /*self*/, PyObjec sel = Selection().getCompleteSelection(toEnum(resolve)); Py::List list; - for (std::vector::iterator it = sel.begin(); it != sel.end(); ++it) { - list.append(Py::asObject(it->pObject->getPyObject())); + for (const auto & it : sel) { + list.append(Py::asObject(it.pObject->getPyObject())); } return Py::new_reference_to(list); } @@ -2371,8 +2370,8 @@ PyObject *SelectionSingleton::sGetSelectionEx(PyObject * /*self*/, PyObject *arg App::DocumentObject::getClassTypeId(), toEnum(resolve), Base::asBoolean(single)); Py::List list; - for (std::vector::iterator it = sel.begin(); it != sel.end(); ++it) { - list.append(Py::asObject(it->getPyObject())); + for (auto & it : sel) { + list.append(Py::asObject(it.getPyObject())); } return Py::new_reference_to(list); } @@ -2396,8 +2395,8 @@ PyObject *SelectionSingleton::sGetPickedList(PyObject * /*self*/, PyObject *args try { Py::List list; - for (std::vector::iterator it = sel.begin(); it != sel.end(); ++it) { - list.append(Py::asObject(it->getPyObject())); + for (auto & it : sel) { + list.append(Py::asObject(it.getPyObject())); } return Py::new_reference_to(list); } diff --git a/src/Gui/Selection.h b/src/Gui/Selection.h index c1245d7b8a..002b808ed7 100644 --- a/src/Gui/Selection.h +++ b/src/Gui/Selection.h @@ -756,7 +756,7 @@ inline std::vector SelectionSingleton::getObjectsOfType(const char* pDocName std::vector type; std::vector obj = this->getObjectsOfType(T::getClassTypeId(), pDocName, resolve); type.reserve(obj.size()); - for (std::vector::iterator it = obj.begin(); it != obj.end(); ++it) + for (auto it = obj.begin(); it != obj.end(); ++it) type.push_back(static_cast(*it)); return type; } diff --git a/src/Gui/SelectionFilter.cpp b/src/Gui/SelectionFilter.cpp index fc4e3b4bdc..e3b127d105 100644 --- a/src/Gui/SelectionFilter.cpp +++ b/src/Gui/SelectionFilter.cpp @@ -187,12 +187,12 @@ bool SelectionFilter::match() else { // if subnames present count all subs over the selected object of type std::size_t subCount = 0; - for (std::vector::const_iterator it2=temp.begin();it2!=temp.end();++it2) { - const std::vector& subNames = it2->getSubNames(); + for (const auto & it2 : temp) { + const std::vector& subNames = it2.getSubNames(); if (subNames.empty()) return false; - for (std::vector::const_iterator it3=subNames.begin();it3!=subNames.end();++it3) { - if (it3->find(it->SubName) != 0) + for (const auto & subName : subNames) { + if (subName.find(it->SubName) != 0) return false; } subCount += subNames.size(); @@ -304,7 +304,7 @@ Py::Object SelectionFilterPy::test(const Py::Tuple& args) if (!PyArg_ParseTuple(args.ptr(), "O!|s",&(App::DocumentObjectPy::Type),&pcObj,&text)) throw Py::Exception(); - App::DocumentObjectPy* docObj = static_cast(pcObj); + auto docObj = static_cast(pcObj); return Py::Boolean(filter.test(docObj->getDocumentObjectPtr(),text)); } @@ -368,7 +368,7 @@ class StringFactory { std::size_t max_elements = 20; public: static StringFactory* instance() { - static StringFactory* inst = new StringFactory(); + static auto inst = new StringFactory(); return inst; } std::string* make(const std::string& str) { diff --git a/src/Gui/SelectionObjectPyImp.cpp b/src/Gui/SelectionObjectPyImp.cpp index d7efc14e92..2de0a3e2d0 100644 --- a/src/Gui/SelectionObjectPyImp.cpp +++ b/src/Gui/SelectionObjectPyImp.cpp @@ -79,8 +79,8 @@ Py::Tuple SelectionObjectPy::getSubElementNames() const Py::Tuple temp(objs.size()); Py::sequence_index_type index = 0; - for(std::vector::const_iterator it= objs.begin();it!=objs.end();++it) - temp.setItem(index++, Py::String(*it)); + for(const auto & obj : objs) + temp.setItem(index++, Py::String(obj)); return temp; } @@ -134,8 +134,8 @@ Py::Tuple SelectionObjectPy::getSubObjects() const Py::Tuple temp(subObjs.size()); Py::sequence_index_type index = 0; - for(std::vector::const_iterator it= subObjs.begin();it!=subObjs.end();++it) - temp.setItem(index++, Py::asObject(*it)); + for(const auto & subObj : subObjs) + temp.setItem(index++, Py::asObject(subObj)); return temp; } @@ -151,8 +151,8 @@ Py::Tuple SelectionObjectPy::getPickedPoints() const Py::Tuple temp(points.size()); Py::sequence_index_type index = 0; - for(std::vector::const_iterator it= points.begin();it!=points.end();++it) - temp.setItem(index++, Py::Vector(*it)); + for(const auto & point : points) + temp.setItem(index++, Py::Vector(point)); return temp; } diff --git a/src/Gui/SoAxisCrossKit.cpp b/src/Gui/SoAxisCrossKit.cpp index 6daac87e49..930363f8a2 100644 --- a/src/Gui/SoAxisCrossKit.cpp +++ b/src/Gui/SoAxisCrossKit.cpp @@ -175,7 +175,7 @@ void SoAxisCrossKit::createAxes() { // Create the heads. - SoCone *head = new SoCone; + auto head = new SoCone; head->bottomRadius.setValue(5); head->height.setValue(10); setPart("xHead.shape", head); @@ -183,14 +183,14 @@ SoAxisCrossKit::createAxes() setPart("zHead.shape", head); // Create the axes. - SoCoordinate3* coords = new SoCoordinate3; + auto coords = new SoCoordinate3; coords->point.set1Value(0, SbVec3f(0,0,0)); coords->point.set1Value(1, SbVec3f(90,0,0)); setPart("xAxis.coordinate3", coords); setPart("yAxis.coordinate3", coords); setPart("zAxis.coordinate3", coords); - SoLineSet *shape = new SoLineSet; + auto shape = new SoLineSet; setPart("xAxis.shape", shape); setPart("yAxis.shape", shape); setPart("zAxis.shape", shape); @@ -260,18 +260,18 @@ SoRegPoint::SoRegPoint() root->ref(); // translation - SoTranslation* move = new SoTranslation(); + auto move = new SoTranslation(); move->translation.setValue(base.getValue() + normal.getValue() * length.getValue()); root->addChild(move); // sub-group - SoBaseColor* col = new SoBaseColor(); + auto col = new SoBaseColor(); col->rgb.setValue(this->color.getValue()); - SoFontStyle* font = new SoFontStyle; + auto font = new SoFontStyle; font->size = 14; - SoSeparator* sub = new SoSeparator(); + auto sub = new SoSeparator(); sub->addChild(col); sub->addChild(font); sub->addChild(new SoText2()); @@ -346,17 +346,17 @@ void SoRegPoint::notify(SoNotList * node) { SoField * f = node->getLastField(); if (f == &this->base || f == &this->normal || f == &this->length) { - SoTranslation* move = static_cast(root->getChild(0)); + auto move = static_cast(root->getChild(0)); move->translation.setValue(base.getValue() + normal.getValue() * length.getValue()); } else if (f == &this->color) { - SoSeparator* sub = static_cast(root->getChild(1)); - SoBaseColor* col = static_cast(sub->getChild(0)); + auto sub = static_cast(root->getChild(1)); + auto col = static_cast(sub->getChild(0)); col->rgb = this->color.getValue(); } else if (f == &this->text) { - SoSeparator* sub = static_cast(root->getChild(1)); - SoText2* label = static_cast(sub->getChild(2)); + auto sub = static_cast(root->getChild(1)); + auto label = static_cast(sub->getChild(2)); label->string = this->text.getValue(); } diff --git a/src/Gui/SoFCBoundingBox.cpp b/src/Gui/SoFCBoundingBox.cpp index 07bfa024a9..8dce00ae19 100644 --- a/src/Gui/SoFCBoundingBox.cpp +++ b/src/Gui/SoFCBoundingBox.cpp @@ -78,7 +78,7 @@ SoFCBoundingBox::SoFCBoundingBox () SO_NODE_ADD_FIELD(dimensionsOn, (true)); root = new SoSeparator(); - SoSeparator *bboxSep = new SoSeparator(); + auto bboxSep = new SoSeparator(); bboxCoords = new SoCoordinate3(); bboxCoords->point.setNum(8); @@ -95,10 +95,10 @@ SoFCBoundingBox::SoFCBoundingBox () // create the text nodes, including a transform for each vertice offset textSep = new SoSeparator(); for (int i = 0; i < 8; i++) { - SoSeparator *temp = new SoSeparator(); - SoTransform *trans = new SoTransform(); + auto temp = new SoSeparator(); + auto trans = new SoTransform(); temp->addChild(trans); - SoText2* text = new SoText2(); + auto text = new SoText2(); text->justification.setValue(SoText2::CENTER); temp->addChild(text); textSep->addChild(temp); @@ -107,10 +107,10 @@ SoFCBoundingBox::SoFCBoundingBox () // create the text nodes, including a transform for each dimension dimSep = new SoSeparator(); for (int i = 0; i < 3; i++) { - SoSeparator *temp = new SoSeparator(); - SoTransform *trans = new SoTransform(); + auto temp = new SoSeparator(); + auto trans = new SoTransform(); temp->addChild(trans); - SoText2* text = new SoText2(); + auto text = new SoText2(); text->justification.setValue(SoText2::CENTER); temp->addChild(text); dimSep->addChild(temp); diff --git a/src/Gui/SoFCCSysDragger.cpp b/src/Gui/SoFCCSysDragger.cpp index 27a3a1c8ca..27e91c55a8 100644 --- a/src/Gui/SoFCCSysDragger.cpp +++ b/src/Gui/SoFCCSysDragger.cpp @@ -135,14 +135,14 @@ void TDragger::buildFirstInstance() { SoGroup *geometryGroup = buildGeometry(); - SoSeparator *localTranslator = new SoSeparator(); + auto localTranslator = new SoSeparator(); localTranslator->setName("CSysDynamics_TDragger_Translator"); localTranslator->addChild(geometryGroup); SoFCDB::getStorage()->addChild(localTranslator); - SoSeparator *localTranslatorActive = new SoSeparator(); + auto localTranslatorActive = new SoSeparator(); localTranslatorActive->setName("CSysDynamics_TDragger_TranslatorActive"); - SoBaseColor *colorActive = new SoBaseColor(); + auto colorActive = new SoBaseColor(); colorActive->rgb.setValue(1.0, 1.0, 0.0); localTranslatorActive->addChild(colorActive); localTranslatorActive->addChild(geometryGroup); @@ -154,19 +154,19 @@ SoGroup* TDragger::buildGeometry() //this builds one leg in the Y+ direction because of default done direction. //the location anchor for shapes is the center of shape. - SoGroup *root = new SoGroup(); + auto root = new SoGroup(); //cylinder float cylinderHeight = 10.0; float cylinderRadius = 0.2f; - SoSeparator *cylinderSeparator = new SoSeparator(); + auto cylinderSeparator = new SoSeparator(); root->addChild(cylinderSeparator); - SoTranslation *cylinderTranslation = new SoTranslation(); + auto cylinderTranslation = new SoTranslation(); cylinderTranslation->translation.setValue(0.0, cylinderHeight / 2.0, 0.0); cylinderSeparator->addChild(cylinderTranslation); - SoCylinder *cylinder = new SoCylinder(); + auto cylinder = new SoCylinder(); cylinder->radius.setValue(cylinderRadius); cylinder->height.setValue(cylinderHeight); cylinderSeparator->addChild(cylinder); @@ -174,19 +174,19 @@ SoGroup* TDragger::buildGeometry() //cone float coneBottomRadius = 1.0; float coneHeight = 2.0; - SoSeparator *coneSeparator = new SoSeparator(); + auto coneSeparator = new SoSeparator(); root->addChild(coneSeparator); - SoPickStyle *pickStyle = new SoPickStyle(); + auto pickStyle = new SoPickStyle(); pickStyle->style.setValue(SoPickStyle::SHAPE); pickStyle->setOverride(TRUE); coneSeparator->addChild(pickStyle); - SoTranslation *coneTranslation = new SoTranslation(); + auto coneTranslation = new SoTranslation(); coneTranslation->translation.setValue(0.0, cylinderHeight + coneHeight / 2.0, 0.0); coneSeparator->addChild(coneTranslation); - SoCone *cone = new SoCone(); + auto cone = new SoCone(); cone->bottomRadius.setValue(coneBottomRadius); cone->height.setValue(coneHeight); coneSeparator->addChild(cone); @@ -196,25 +196,25 @@ SoGroup* TDragger::buildGeometry() void TDragger::startCB(void *, SoDragger *d) { - TDragger *sudoThis = static_cast(d); + auto sudoThis = static_cast(d); sudoThis->dragStart(); } void TDragger::motionCB(void *, SoDragger *d) { - TDragger *sudoThis = static_cast(d); + auto sudoThis = static_cast(d); sudoThis->drag(); } void TDragger::finishCB(void *, SoDragger *d) { - TDragger *sudoThis = static_cast(d); + auto sudoThis = static_cast(d); sudoThis->dragFinish(); } void TDragger::fieldSensorCB(void *f, SoSensor *) { - TDragger *sudoThis = static_cast(f); + auto sudoThis = static_cast(f); SbMatrix matrix = sudoThis->getMotionMatrix(); // clazy:exclude=rule-of-two-soft sudoThis->workFieldsIntoTransform(matrix); @@ -223,7 +223,7 @@ void TDragger::fieldSensorCB(void *f, SoSensor *) void TDragger::valueChangedCB(void *, SoDragger *d) { - TDragger *sudoThis = dynamic_cast(d); + auto sudoThis = dynamic_cast(d); assert(sudoThis); SbMatrix matrix = sudoThis->getMotionMatrix(); // clazy:exclude=rule-of-two-soft @@ -409,14 +409,14 @@ void RDragger::buildFirstInstance() { SoGroup *geometryGroup = buildGeometry(); - SoSeparator *localRotator = new SoSeparator(); + auto localRotator = new SoSeparator(); localRotator->setName("CSysDynamics_RDragger_Rotator"); localRotator->addChild(geometryGroup); SoFCDB::getStorage()->addChild(localRotator); - SoSeparator *localRotatorActive = new SoSeparator(); + auto localRotatorActive = new SoSeparator(); localRotatorActive->setName("CSysDynamics_RDragger_RotatorActive"); - SoBaseColor *colorActive = new SoBaseColor(); + auto colorActive = new SoBaseColor(); colorActive->rgb.setValue(1.0, 1.0, 0.0); localRotatorActive->addChild(colorActive); localRotatorActive->addChild(geometryGroup); @@ -425,10 +425,10 @@ void RDragger::buildFirstInstance() SoGroup* RDragger::buildGeometry() { - SoGroup *root = new SoGroup(); + auto root = new SoGroup(); //arc - SoCoordinate3 *coordinates = new SoCoordinate3(); + auto coordinates = new SoCoordinate3(); unsigned int segments = 6; @@ -442,11 +442,11 @@ SoGroup* RDragger::buildGeometry() } root->addChild(coordinates); - SoLineSet *lineSet = new SoLineSet(); + auto lineSet = new SoLineSet(); lineSet->numVertices.setValue(segments + 1); root->addChild(lineSet); - SoPickStyle *pickStyle = new SoPickStyle(); + auto pickStyle = new SoPickStyle(); pickStyle->style.setValue(SoPickStyle::SHAPE); pickStyle->setOverride(TRUE); root->addChild(pickStyle); @@ -455,11 +455,11 @@ SoGroup* RDragger::buildGeometry() SbVec3f origin(1.0, 1.0, 0.0); origin.normalize(); origin *= arcRadius; - SoTranslation *sphereTranslation = new SoTranslation(); + auto sphereTranslation = new SoTranslation(); sphereTranslation->translation.setValue(origin); root->addChild(sphereTranslation); - SoSphere *sphere = new SoSphere(); + auto sphere = new SoSphere(); sphere->radius.setValue(1.0); root->addChild(sphere); @@ -468,25 +468,25 @@ SoGroup* RDragger::buildGeometry() void RDragger::startCB(void *, SoDragger *d) { - RDragger *sudoThis = static_cast(d); + auto sudoThis = static_cast(d); sudoThis->dragStart(); } void RDragger::motionCB(void *, SoDragger *d) { - RDragger *sudoThis = static_cast(d); + auto sudoThis = static_cast(d); sudoThis->drag(); } void RDragger::finishCB(void *, SoDragger *d) { - RDragger *sudoThis = static_cast(d); + auto sudoThis = static_cast(d); sudoThis->dragFinish(); } void RDragger::fieldSensorCB(void *f, SoSensor *) { - RDragger *sudoThis = static_cast(f); + auto sudoThis = static_cast(f); SbMatrix matrix = sudoThis->getMotionMatrix(); // clazy:exclude=rule-of-two-soft sudoThis->workFieldsIntoTransform(matrix); @@ -495,7 +495,7 @@ void RDragger::fieldSensorCB(void *f, SoSensor *) void RDragger::valueChangedCB(void *, SoDragger *d) { - RDragger *sudoThis = dynamic_cast(d); + auto sudoThis = dynamic_cast(d); assert(sudoThis); SbMatrix matrix = sudoThis->getMotionMatrix(); // clazy:exclude=rule-of-two-soft @@ -615,7 +615,7 @@ int RDragger::roundIncrement(const float &radiansIn) { int rCount = 0; - float increment = static_cast(rotationIncrement.getValue()); + auto increment = static_cast(rotationIncrement.getValue()); if (fabs(radiansIn) > (increment / 2.0)) { rCount = static_cast(radiansIn / increment); @@ -758,7 +758,7 @@ SoFCCSysDragger::SoFCCSysDragger() SoRotation *localRotation; SbRotation tempRotation; - float angle = static_cast(M_PI / 2.0); + auto angle = static_cast(M_PI / 2.0); localRotation = SO_GET_ANY_PART(this, "xTranslatorRotation", SoRotation); localRotation->rotation.setValue(SbVec3f(0.0, 0.0, -1.0), angle); localRotation = SO_GET_ANY_PART(this, "yTranslatorRotation", SoRotation); @@ -781,7 +781,7 @@ SoFCCSysDragger::SoFCCSysDragger() //this is for non-autoscale mode. this will be disconnected for autoscale //and won't be used. see setUpAutoScale. - SoComposeVec3f *scaleEngine = new SoComposeVec3f(); //uses coin ref scheme. + auto scaleEngine = new SoComposeVec3f(); //uses coin ref scheme. scaleEngine->x.connectFrom(&draggerSize); scaleEngine->y.connectFrom(&draggerSize); scaleEngine->z.connectFrom(&draggerSize); @@ -868,7 +868,7 @@ SbBool SoFCCSysDragger::setUpConnections(SbBool onoff, SbBool doitalways) void SoFCCSysDragger::translationSensorCB(void *f, SoSensor *) { - SoFCCSysDragger *sudoThis = static_cast(f); + auto sudoThis = static_cast(f); SbMatrix matrix = sudoThis->getMotionMatrix(); // clazy:exclude=rule-of-two-soft sudoThis->workFieldsIntoTransform(matrix); @@ -877,7 +877,7 @@ void SoFCCSysDragger::translationSensorCB(void *f, SoSensor *) void SoFCCSysDragger::rotationSensorCB(void *f, SoSensor *) { - SoFCCSysDragger *sudoThis = static_cast(f); + auto sudoThis = static_cast(f); SbMatrix matrix = sudoThis->getMotionMatrix(); // clazy:exclude=rule-of-two-soft sudoThis->workFieldsIntoTransform(matrix); @@ -886,7 +886,7 @@ void SoFCCSysDragger::rotationSensorCB(void *f, SoSensor *) void SoFCCSysDragger::valueChangedCB(void *, SoDragger *d) { - SoFCCSysDragger *sudoThis = dynamic_cast(d); + auto sudoThis = dynamic_cast(d); assert(sudoThis); SbMatrix matrix = sudoThis->getMotionMatrix(); // clazy:exclude=rule-of-two-soft @@ -913,7 +913,7 @@ void SoFCCSysDragger::setUpAutoScale(SoCamera *cameraIn) //checking current attachment state. if (cameraIn->getTypeId() == SoOrthographicCamera::getClassTypeId()) { - SoOrthographicCamera *localCamera = dynamic_cast(cameraIn); + auto localCamera = dynamic_cast(cameraIn); assert(localCamera); cameraSensor.attach(&localCamera->height); SoScale *localScaleNode = SO_GET_ANY_PART(this, "scaleNode", SoScale); @@ -923,7 +923,7 @@ void SoFCCSysDragger::setUpAutoScale(SoCamera *cameraIn) } else if (cameraIn->getTypeId() == SoPerspectiveCamera::getClassTypeId()) { - SoPerspectiveCamera *localCamera = dynamic_cast(cameraIn); + auto localCamera = dynamic_cast(cameraIn); assert(localCamera); cameraSensor.attach(&localCamera->position); SoScale *localScaleNode = SO_GET_ANY_PART(this, "scaleNode", SoScale); @@ -935,7 +935,7 @@ void SoFCCSysDragger::setUpAutoScale(SoCamera *cameraIn) void SoFCCSysDragger::cameraCB(void *data, SoSensor *) { - SoFCCSysDragger *sudoThis = static_cast(data); + auto sudoThis = static_cast(data); if (!sudoThis->idleSensor.isScheduled()) sudoThis->idleSensor.schedule(); } @@ -980,11 +980,11 @@ void SoFCCSysDragger::handleEvent(SoHandleEventAction * action) void SoFCCSysDragger::idleCB(void *data, SoSensor *) { - SoFCCSysDragger *sudoThis = static_cast(data); + auto sudoThis = static_cast(data); SoField* field = sudoThis->cameraSensor.getAttachedField(); if (field) { - SoCamera* camera = static_cast(field->getContainer()); + auto camera = static_cast(field->getContainer()); SbMatrix localToWorld = sudoThis->getLocalToWorldMatrix(); SbVec3f origin; localToWorld.multVecMatrix(SbVec3f(0.0, 0.0, 0.0), origin); @@ -1003,7 +1003,7 @@ void SoFCCSysDragger::idleCB(void *data, SoSensor *) void SoFCCSysDragger::finishDragCB(void *data, SoDragger *) { - SoFCCSysDragger *sudoThis = static_cast(data); + auto sudoThis = static_cast(data); // note: when creating a second view of the document and then closing // the first viewer it deletes the camera. However, the attached field @@ -1011,7 +1011,7 @@ void SoFCCSysDragger::finishDragCB(void *data, SoDragger *) SoField* field = sudoThis->cameraSensor.getAttachedField(); if (field) { - SoCamera* camera = static_cast(field->getContainer()); + auto camera = static_cast(field->getContainer()); if (camera->getTypeId() == SoPerspectiveCamera::getClassTypeId()) cameraCB(sudoThis, nullptr); } diff --git a/src/Gui/SoFCColorBar.cpp b/src/Gui/SoFCColorBar.cpp index ed021c8d4d..830313e04b 100644 --- a/src/Gui/SoFCColorBar.cpp +++ b/src/Gui/SoFCColorBar.cpp @@ -94,13 +94,13 @@ float SoFCColorBarBase::getBoundingWidth(const SbVec2s& size) } // These are the same camera settings for front nodes as defined in the 3d view - SoOrthographicCamera* cam = new SoOrthographicCamera; + auto cam = new SoOrthographicCamera; cam->position = SbVec3f(0, 0, 5); // the 5 is just a value > 0 cam->height = 10; // sets the coordinate range of the screen to [-5, +5] cam->nearDistance = 0; cam->farDistance = 10; - SoGroup* group = new SoGroup(); + auto group = new SoGroup(); group->ref(); group->addChild(cam); group->addChild(this); @@ -276,7 +276,7 @@ void SoFCColorBar::eventCallback(void * /*userdata*/, SoEventCallback * node) { const SoEvent * event = node->getEvent(); if (event->getTypeId().isDerivedFrom(SoMouseButtonEvent::getClassTypeId())) { - const SoMouseButtonEvent* e = static_cast(event); + const auto e = static_cast(event); if ((e->getButton() == SoMouseButtonEvent::BUTTON2)) { if (e->getState() == SoButtonEvent::UP) { // do nothing here @@ -291,7 +291,7 @@ void SoFCColorBar::handleEvent (SoHandleEventAction *action) // check for mouse button events if (event->getTypeId().isDerivedFrom(SoMouseButtonEvent::getClassTypeId())) { - const SoMouseButtonEvent* e = static_cast(event); + const auto e = static_cast(event); // check if the cursor is near to the color bar if (!action->getPickedPoint()) diff --git a/src/Gui/SoFCColorGradient.cpp b/src/Gui/SoFCColorGradient.cpp index fbee2fc31a..369060bdd5 100644 --- a/src/Gui/SoFCColorGradient.cpp +++ b/src/Gui/SoFCColorGradient.cpp @@ -92,14 +92,14 @@ void SoFCColorGradient::setMarkerLabel(const SoMFString& label) SbVec2f maxPt = _bbox.getMax(); SbVec2f minPt = _bbox.getMin(); float fStep = (maxPt[1] - minPt[1]) / ((float)num - 1); - SoTransform* trans = new SoTransform; + auto trans = new SoTransform; trans->translation.setValue(maxPt[0] + 0.1f, maxPt[1] - 0.05f + fStep, 0.0f); labels->addChild(trans); for (int i = 0; i < num; i++) { - SoTransform* trans = new SoTransform; - SoBaseColor* color = new SoBaseColor; - SoText2 * text2 = new SoColorBarLabel; + auto trans = new SoTransform; + auto color = new SoBaseColor; + auto text2 = new SoColorBarLabel; trans->translation.setValue(0, -fStep, 0); color->rgb.setValue(0, 0, 0); @@ -253,7 +253,7 @@ void SoFCColorGradient::rebuildGradient() // for uCtColors colors we need 2*(uCtColors-1) facets and therefore an array with // 8*(uCtColors-1) face indices - SoIndexedFaceSet* faceset = new SoIndexedFaceSet; + auto faceset = new SoIndexedFaceSet; faceset->coordIndex.setNum(8 * (uCtColors - 1)); for (int j = 0; j < uCtColors - 1; j++) { faceset->coordIndex.set1Value(8 * j, 2 * j); @@ -267,9 +267,9 @@ void SoFCColorGradient::rebuildGradient() } // set an own transparency type for this color bar only - SoTransparencyType* ttype = new SoTransparencyType; + auto ttype = new SoTransparencyType; ttype->value = SoGLRenderAction::DELAYED_BLEND; - SoMaterial* mat = new SoMaterial; + auto mat = new SoMaterial; //mat->transparency = 0.3f; mat->diffuseColor.setNum(2 * uCtColors); for (int k = 0; k < uCtColors; k++) { @@ -278,7 +278,7 @@ void SoFCColorGradient::rebuildGradient() mat->diffuseColor.set1Value(2 * k + 1, col.r, col.g, col.b); } - SoMaterialBinding* matBinding = new SoMaterialBinding; + auto matBinding = new SoMaterialBinding; matBinding->value = SoMaterialBinding::PER_VERTEX_INDEXED; // first clear the children diff --git a/src/Gui/SoFCColorLegend.cpp b/src/Gui/SoFCColorLegend.cpp index 9085644874..621aae0e17 100644 --- a/src/Gui/SoFCColorLegend.cpp +++ b/src/Gui/SoFCColorLegend.cpp @@ -142,14 +142,14 @@ void SoFCColorLegend::setMarkerLabel(const SoMFString& label) if (num > 1) { std::vector pos = getLabelPositions(num, _bbox); - SoTransform* trans = new SoTransform; + auto trans = new SoTransform; trans->translation.setValue(pos[0]); labelGroup->addChild(trans); for (int i=0; itranslation.setValue(pos[i+1]); color->rgb.setValue(0, 0, 0); @@ -169,14 +169,14 @@ void SoFCColorLegend::setMarkerValue(const SoMFString& value) if (num > 1) { std::vector pos = getValuePositions(num, _bbox); - SoTransform* trans = new SoTransform; + auto trans = new SoTransform; trans->translation.setValue(pos[0]); valueGroup->addChild(trans); for (int i=0; itranslation.setValue(pos[i+1]); color->rgb.setValue(0, 0, 0); @@ -320,7 +320,7 @@ void SoFCColorLegend::setColorLegend(const App::ColorLegend& legend) modifyPoints(_bbox); // for numFields colors we need numFields quads - SoIndexedFaceSet * faceset = new SoIndexedFaceSet; + auto faceset = new SoIndexedFaceSet; faceset->coordIndex.setNum(5 * intFields); for (int j = 0; j < intFields; j++) { faceset->coordIndex.set1Value(5*j, 4*j); @@ -330,14 +330,14 @@ void SoFCColorLegend::setColorLegend(const App::ColorLegend& legend) faceset->coordIndex.set1Value(5*j+4, SO_END_FACE_INDEX); } - SoMaterial* mat = new SoMaterial; + auto mat = new SoMaterial; mat->diffuseColor.setNum(intFields); for (std::size_t k = 0; k < numFields; k++) { App::Color col = legend.getColor(k); mat->diffuseColor.set1Value(k, col.r, col.g, col.b); } - SoMaterialBinding* matBinding = new SoMaterialBinding; + auto matBinding = new SoMaterialBinding; matBinding->value = SoMaterialBinding::PER_FACE; // first clear the children diff --git a/src/Gui/SoFCDB.cpp b/src/Gui/SoFCDB.cpp index 36e4f0657c..4df76c4fe3 100644 --- a/src/Gui/SoFCDB.cpp +++ b/src/Gui/SoFCDB.cpp @@ -272,11 +272,11 @@ SoNode* replaceSwitches(SoNodeList* children, SoGroup* parent) SoNode* node = (*children)[i]; if (node->getTypeId().isDerivedFrom(SoGroup::getClassTypeId())) { if (node->getTypeId().isDerivedFrom(SoSwitch::getClassTypeId())) { - SoSwitch* group = static_cast(node); + auto group = static_cast(node); int which = group->whichChild.getValue(); if (which == SO_SWITCH_NONE) continue; - SoGroup* newParent = new SoGroup(); + auto newParent = new SoGroup(); SoNodeList c; if (which >= 0) { c.append(group->getChild(which)); @@ -291,7 +291,7 @@ SoNode* replaceSwitches(SoNodeList* children, SoGroup* parent) parent->addChild(newParent); } else { - SoGroup* newParent = static_cast(node->getTypeId().createInstance()); + auto newParent = static_cast(node->getTypeId().createInstance()); replaceSwitches(node->getChildren(), newParent); parent->addChild(newParent); } @@ -428,7 +428,7 @@ bool Gui::SoFCDB::writeToX3D(SoNode* node, bool exportViewpoints, std::string& b SoPathList& paths = sa.getPaths(); for (int i=0; i(path->getTail()); + auto shape = static_cast(path->getTail()); SoNode* geom = shape->geometry.getValue(); if (geom && geom->getTypeId() == SoVRMLIndexedFaceSet::getClassTypeId()) { SoNode* norm = static_cast(geom)->normal.getValue(); @@ -519,11 +519,11 @@ void Gui::SoFCDB::writeX3DFields(SoNode* node, std::map& n SoField* field = fielddata->getField(node, i); if (!field->isDefault()) { if (field->isOfType(SoSFNode::getClassTypeId())) { - SoSFNode* sfNode = static_cast(field); + auto sfNode = static_cast(field); writeX3DChild(sfNode->getValue(), nodeMap, numDEF, spaces+2, out); } else if (field->isOfType(SoMFNode::getClassTypeId())) { - SoMFNode* mfNode = static_cast(field); + auto mfNode = static_cast(field); for (int j=0; jgetNum(); j++) { writeX3DChild(mfNode->getNode(j), nodeMap, numDEF, spaces+2, out); } diff --git a/src/Gui/SoFCInteractiveElement.cpp b/src/Gui/SoFCInteractiveElement.cpp index 0c0ca65e08..364d1b0de8 100644 --- a/src/Gui/SoFCInteractiveElement.cpp +++ b/src/Gui/SoFCInteractiveElement.cpp @@ -49,7 +49,7 @@ SoFCInteractiveElement::~SoFCInteractiveElement() void SoFCInteractiveElement::set(SoState * const state, SoNode * const node, SbBool mode) { - SoFCInteractiveElement * elem = (SoFCInteractiveElement *) + auto elem = (SoFCInteractiveElement *) SoReplacedElement::getElement(state, classStackIndex, node); elem->setElt(mode); } @@ -92,14 +92,14 @@ SoGLWidgetElement::~SoGLWidgetElement() void SoGLWidgetElement::set(SoState * state, QtGLWidget * window) { - SoGLWidgetElement * elem = static_cast + auto elem = static_cast (SoElement::getElement(state, classStackIndex)); elem->window = window; } void SoGLWidgetElement::get(SoState * state, QtGLWidget *& window) { - const SoGLWidgetElement* that = static_cast + const auto that = static_cast (SoElement::getConstElement(state, classStackIndex)); window = that->window; } @@ -147,14 +147,14 @@ SoGLRenderActionElement::~SoGLRenderActionElement() void SoGLRenderActionElement::set(SoState * state, SoGLRenderAction * action) { - SoGLRenderActionElement * elem = static_cast + auto elem = static_cast (SoElement::getElement(state, classStackIndex)); elem->glRenderAction = action; } void SoGLRenderActionElement::get(SoState * state, SoGLRenderAction * & action) { - const SoGLRenderActionElement* that = static_cast + const auto that = static_cast (SoElement::getConstElement(state, classStackIndex)); action = that->glRenderAction; } @@ -241,14 +241,14 @@ SoGLVBOActivatedElement::~SoGLVBOActivatedElement() void SoGLVBOActivatedElement::set(SoState * state, SbBool active) { - SoGLVBOActivatedElement * elem = static_cast + auto elem = static_cast (SoElement::getElement(state, classStackIndex)); elem->active = active; } void SoGLVBOActivatedElement::get(SoState * state, SbBool& active) { - const SoGLVBOActivatedElement* self = static_cast + const auto self = static_cast (SoElement::getConstElement(state, classStackIndex)); active = self->active; if(active) { diff --git a/src/Gui/SoFCOffscreenRenderer.cpp b/src/Gui/SoFCOffscreenRenderer.cpp index dde06d2211..fe8d0c26dd 100644 --- a/src/Gui/SoFCOffscreenRenderer.cpp +++ b/src/Gui/SoFCOffscreenRenderer.cpp @@ -897,7 +897,7 @@ Py::Object SoQtOffscreenRendererPy::render(const Py::Tuple& args) try { void* ptr = nullptr; Base::Interpreter().convertSWIGPointerObj("pivy.coin", "SoNode *", proxy, &ptr, 0); - SoNode* node = static_cast(ptr); + auto node = static_cast(ptr); bool ok = false; if (node) { ok = renderer.render(node); diff --git a/src/Gui/SoFCSelection.cpp b/src/Gui/SoFCSelection.cpp index ee349263c0..5cd3805273 100644 --- a/src/Gui/SoFCSelection.cpp +++ b/src/Gui/SoFCSelection.cpp @@ -150,7 +150,7 @@ void SoFCSelection::doAction(SoAction *action) { if(useNewSelection.getValue() && action->getCurPathCode()!=SoAction::OFF_PATH) { if (action->getTypeId() == Gui::SoHighlightElementAction::getClassTypeId()) { - Gui::SoHighlightElementAction* hlaction = static_cast(action); + auto hlaction = static_cast(action); if (!hlaction->isHighlighted()) { auto ctx = Gui::SoFCSelectionRoot::getActionContext(action,this,selContext,false); if (ctx && ctx->isHighlighted()) { @@ -171,7 +171,7 @@ void SoFCSelection::doAction(SoAction *action) return; } else if (action->getTypeId() == Gui::SoSelectionElementAction::getClassTypeId()) { - Gui::SoSelectionElementAction* selaction = static_cast(action); + auto selaction = static_cast(action); if (selaction->getType() == Gui::SoSelectionElementAction::All || selaction->getType() == Gui::SoSelectionElementAction::Append) { SelContextPtr ctx = Gui::SoFCSelectionRoot::getActionContext(action,this,selContext); @@ -196,12 +196,12 @@ void SoFCSelection::doAction(SoAction *action) } if (action->getTypeId() == SoFCDocumentAction::getClassTypeId()) { - SoFCDocumentAction *docaction = (SoFCDocumentAction*)action; + auto docaction = (SoFCDocumentAction*)action; this->documentName = docaction->documentName; } if (action->getTypeId() == SoFCDocumentObjectAction::getClassTypeId()) { - SoFCDocumentObjectAction* objaction = static_cast(action); + auto objaction = static_cast(action); objaction->documentName = this->documentName.getValue(); objaction->objectName = this->objectName.getValue(); objaction->componentName = this->subElementName.getValue(); @@ -211,7 +211,7 @@ void SoFCSelection::doAction(SoAction *action) if(!useNewSelection.getValue()) { if (action->getTypeId() == SoFCEnableHighlightAction::getClassTypeId()) { - SoFCEnableHighlightAction *preaction = (SoFCEnableHighlightAction*)action; + auto preaction = (SoFCEnableHighlightAction*)action; if (preaction->highlight) { this->highlightMode = SoFCSelection::AUTO; } @@ -221,7 +221,7 @@ void SoFCSelection::doAction(SoAction *action) } if (action->getTypeId() == SoFCEnableSelectionAction::getClassTypeId()) { - SoFCEnableSelectionAction *selaction = (SoFCEnableSelectionAction*)action; + auto selaction = (SoFCEnableSelectionAction*)action; if (selaction->selection) { this->selectionMode = SoFCSelection::SEL_ON; } @@ -234,17 +234,17 @@ void SoFCSelection::doAction(SoAction *action) } if (action->getTypeId() == SoFCSelectionColorAction::getClassTypeId()) { - SoFCSelectionColorAction *colaction = (SoFCSelectionColorAction*)action; + auto colaction = (SoFCSelectionColorAction*)action; this->colorSelection = colaction->selectionColor; } if (action->getTypeId() == SoFCHighlightColorAction::getClassTypeId()) { - SoFCHighlightColorAction *colaction = (SoFCHighlightColorAction*)action; + auto colaction = (SoFCHighlightColorAction*)action; this->colorHighlight = colaction->highlightColor; } if (selectionMode.getValue() == SEL_ON && action->getTypeId() == SoFCSelectionAction::getClassTypeId()) { - SoFCSelectionAction *selaction = static_cast(action); + auto selaction = static_cast(action); if (selaction->SelChange.Type == SelectionChanges::AddSelection || selaction->SelChange.Type == SelectionChanges::RmvSelection) { @@ -353,7 +353,7 @@ SoFCSelection::handleEvent(SoHandleEventAction * action) } static char buf[513]; - HighlightModes mymode = (HighlightModes) this->highlightMode.getValue(); + auto mymode = (HighlightModes) this->highlightMode.getValue(); const SoEvent * event = action->getEvent(); #ifdef NO_FRONTBUFFER // mouse move events for preselection @@ -406,7 +406,7 @@ SoFCSelection::handleEvent(SoHandleEventAction * action) } } // key press events else if (event->isOfType(SoKeyboardEvent ::getClassTypeId())) { - SoKeyboardEvent * const e = (SoKeyboardEvent *) event; + auto const e = (SoKeyboardEvent *) event; if (SoKeyboardEvent::isKeyPressEvent(e,SoKeyboardEvent::LEFT_SHIFT) || SoKeyboardEvent::isKeyPressEvent(e,SoKeyboardEvent::RIGHT_SHIFT) ) bShift = true; @@ -421,7 +421,7 @@ SoFCSelection::handleEvent(SoHandleEventAction * action) bCtrl = false; } // mouse press events for (de)selection else if (event->isOfType(SoMouseButtonEvent::getClassTypeId())) { - SoMouseButtonEvent * const e = (SoMouseButtonEvent *) event; + auto const e = (SoMouseButtonEvent *) event; if (SoMouseButtonEvent::isButtonReleaseEvent(e,SoMouseButtonEvent::BUTTON1)) { //FIXME: Shouldn't we remove the preselection for newly selected objects? // Otherwise the tree signals that an object is preselected even though it is hidden. (Werner) @@ -928,7 +928,7 @@ SoFCSelection::readInstance ( SoInput * in, unsigned short flags ) bool SoFCSelection::setOverride(SoGLRenderAction * action, SelContextPtr ctx) { - HighlightModes mymode = (HighlightModes) this->highlightMode.getValue(); + auto mymode = (HighlightModes) this->highlightMode.getValue(); bool preselected = ctx && ctx->isHighlighted() && (useNewSelection.getValue()||mymode == AUTO); if (!preselected && mymode!=ON && (!ctx || !ctx->isSelected())) return false; @@ -940,7 +940,7 @@ SoFCSelection::setOverride(SoGLRenderAction * action, SelContextPtr ctx) auto oldId = this->uniqueId; this->uniqueId ^= std::hash()(ctx.get()) + 0x9e3779b9 + (oldId << 6) + (oldId >> 2); - Styles mystyle = (Styles) this->style.getValue(); + auto mystyle = (Styles) this->style.getValue(); if (mystyle == SoFCSelection::BOX) { if (ctx) { @@ -1022,7 +1022,7 @@ SoFCSelection::isHighlighted(SoAction *action) // //////////////////////////////////////////////////////////////////////// { - SoFullPath *actionPath = (SoFullPath *) action->getCurPath(); + auto actionPath = (SoFullPath *) action->getCurPath(); return (currenthighlight != nullptr && currenthighlight->getTail() == actionPath->getTail() && // nested SoHL! *currenthighlight == *actionPath); @@ -1042,7 +1042,7 @@ void SoFCSelection::applySettings () else { // Search for a user defined value with the current color as default SbColor highlightColor = this->colorHighlight.getValue(); - unsigned long highlight = (unsigned long)(highlightColor.getPackedValue()); + auto highlight = (unsigned long)(highlightColor.getPackedValue()); highlight = hGrp->GetUnsigned("HighlightColor", highlight); highlightColor.setPackedValue((uint32_t)highlight, transparency); this->colorHighlight.setValue(highlightColor); @@ -1053,7 +1053,7 @@ void SoFCSelection::applySettings () else { // Do the same with the selection color SbColor selectionColor = this->colorSelection.getValue(); - unsigned long selection = (unsigned long)(selectionColor.getPackedValue()); + auto selection = (unsigned long)(selectionColor.getPackedValue()); selection = hGrp->GetUnsigned("SelectionColor", selection); selectionColor.setPackedValue((uint32_t)selection, transparency); this->colorSelection.setValue(selectionColor); diff --git a/src/Gui/SoFCSelectionAction.cpp b/src/Gui/SoFCSelectionAction.cpp index 1fef87e8be..e45d33020c 100644 --- a/src/Gui/SoFCSelectionAction.cpp +++ b/src/Gui/SoFCSelectionAction.cpp @@ -1008,10 +1008,10 @@ SoBoxSelectionRenderActionP::initBoxGraph() this->drawstyle->style = SoDrawStyleElement::LINES; this->basecolor = new SoBaseColor; - SoLightModel * lightmodel = new SoLightModel; + auto lightmodel = new SoLightModel; lightmodel->model = SoLightModel::BASE_COLOR; - SoComplexity * complexity = new SoComplexity; + auto complexity = new SoComplexity; complexity->textureQuality = 0.0f; complexity->type = SoComplexityTypeElement::BOUNDING_BOX; @@ -1164,7 +1164,7 @@ SoBoxSelectionRenderAction::apply(SoNode * node) for (int i = 0; i < pathlist.getLength(); i++ ) { SoPath * path = pathlist[i]; assert(path); - SoFCSelection * selection = (SoFCSelection *) path->getTail(); + auto selection = (SoFCSelection *) path->getTail(); assert(selection->getTypeId().isDerivedFrom(SoFCSelection::getClassTypeId())); if (selection->selected.getValue() && selection->style.getValue() == SoFCSelection::BOX) { PRIVATE(this)->basecolor->rgb.setValue(selection->colorSelection.getValue()); @@ -1219,7 +1219,7 @@ SoBoxSelectionRenderAction::apply(SoPath * path) SoGLRenderAction::apply(path); SoNode* node = path->getTail(); if (node && node->getTypeId() == SoFCSelection::getClassTypeId()) { - SoFCSelection * selection = (SoFCSelection *) node; + auto selection = (SoFCSelection *) node; // This happens when dehighlighting the current shape if (PRIVATE(this)->highlightPath == path) { @@ -1321,7 +1321,7 @@ SoBoxSelectionRenderAction::drawBoxes(SoPath * pathtothis, const SoPathList * pa thestate->push(); for (i = 0; i < pathlist->getLength(); i++) { - SoFullPath * path = (SoFullPath *)(*pathlist)[i]; + auto path = (SoFullPath *)(*pathlist)[i]; for (int j = 0; j < path->getLength(); j++) { PRIVATE(this)->postprocpath->append(path->getNode(j)); diff --git a/src/Gui/SoFCUnifiedSelection.cpp b/src/Gui/SoFCUnifiedSelection.cpp index 0b2bbad987..327761fb9b 100644 --- a/src/Gui/SoFCUnifiedSelection.cpp +++ b/src/Gui/SoFCUnifiedSelection.cpp @@ -175,7 +175,7 @@ void SoFCUnifiedSelection::applySettings() else { // Search for a user defined value with the current color as default SbColor highlightColor = this->colorHighlight.getValue(); - unsigned long highlight = (unsigned long)(highlightColor.getPackedValue()); + auto highlight = (unsigned long)(highlightColor.getPackedValue()); highlight = hGrp->GetUnsigned("HighlightColor", highlight); highlightColor.setPackedValue((uint32_t)highlight, transparency); this->colorHighlight.setValue(highlightColor); @@ -187,7 +187,7 @@ void SoFCUnifiedSelection::applySettings() else { // Do the same with the selection color SbColor selectionColor = this->colorSelection.getValue(); - unsigned long selection = (unsigned long)(selectionColor.getPackedValue()); + auto selection = (unsigned long)(selectionColor.getPackedValue()); selection = hGrp->GetUnsigned("SelectionColor", selection); selectionColor.setPackedValue((uint32_t)selection, transparency); this->colorSelection.setValue(selectionColor); @@ -239,7 +239,7 @@ SoFCUnifiedSelection::getPickedList(SoHandleEventAction* action, bool singlePick info.pp = points[i]; info.vpd = nullptr; ViewProvider *vp = nullptr; - SoFullPath *path = static_cast(info.pp->getPath()); + auto path = static_cast(info.pp->getPath()); if (this->pcDocument && path && path->containsPath(action->getCurPath())) { vp = this->pcDocument->getViewProviderByPathFromHead(path); if(singlePick && last_vp && last_vp!=vp) @@ -306,7 +306,7 @@ SoFCUnifiedSelection::getPickedList(SoHandleEventAction* action, bool singlePick void SoFCUnifiedSelection::doAction(SoAction *action) { if (action->getTypeId() == SoFCEnableHighlightAction::getClassTypeId()) { - SoFCEnableHighlightAction *preaction = (SoFCEnableHighlightAction*)action; + auto preaction = (SoFCEnableHighlightAction*)action; if (preaction->highlight) { this->highlightMode = SoFCUnifiedSelection::AUTO; } @@ -316,7 +316,7 @@ void SoFCUnifiedSelection::doAction(SoAction *action) } if (action->getTypeId() == SoFCEnableSelectionAction::getClassTypeId()) { - SoFCEnableSelectionAction *selaction = (SoFCEnableSelectionAction*)action; + auto selaction = (SoFCEnableSelectionAction*)action; if (selaction->selection) { this->selectionMode = SoFCUnifiedSelection::ON; } @@ -326,17 +326,17 @@ void SoFCUnifiedSelection::doAction(SoAction *action) } if (action->getTypeId() == SoFCSelectionColorAction::getClassTypeId()) { - SoFCSelectionColorAction *colaction = (SoFCSelectionColorAction*)action; + auto colaction = (SoFCSelectionColorAction*)action; this->colorSelection = colaction->selectionColor; } if (action->getTypeId() == SoFCHighlightColorAction::getClassTypeId()) { - SoFCHighlightColorAction *colaction = (SoFCHighlightColorAction*)action; + auto colaction = (SoFCHighlightColorAction*)action; this->colorHighlight = colaction->highlightColor; } if (action->getTypeId() == SoFCHighlightAction::getClassTypeId()) { - SoFCHighlightAction *hilaction = static_cast(action); + auto hilaction = static_cast(action); // Do not clear currently highlighted object when setting new pre-selection if (!setPreSelection && hilaction->SelChange.Type == SelectionChanges::RmvPreselect) { if (currenthighlight) { @@ -379,7 +379,7 @@ void SoFCUnifiedSelection::doAction(SoAction *action) } if (action->getTypeId() == SoFCSelectionAction::getClassTypeId()) { - SoFCSelectionAction *selaction = static_cast(action); + auto selaction = static_cast(action); if(selectionMode.getValue() == ON && (selaction->SelChange.Type == SelectionChanges::AddSelection || selaction->SelChange.Type == SelectionChanges::RmvSelection)) @@ -430,8 +430,8 @@ void SoFCUnifiedSelection::doAction(SoAction *action) std::vector vps; if (this->pcDocument) vps = this->pcDocument->getViewProvidersOfType(ViewProviderDocumentObject::getClassTypeId()); - for (std::vector::iterator it = vps.begin(); it != vps.end(); ++it) { - ViewProviderDocumentObject* vpd = static_cast(*it); + for (const auto & vp : vps) { + auto vpd = static_cast(vp); if (useNewSelection.getValue() || vpd->useNewSelectionModel()) { SoSelectionElementAction::Type type; if(Selection().isSelected(vpd->getObject()) && vpd->isSelectable()) @@ -577,10 +577,10 @@ bool SoFCUnifiedSelection::setSelection(const std::vector &infos, bo const SoPickedPoint * pp = info.pp; const SoDetail *det = pp->getDetail(); SoDetail *detNext = nullptr; - SoFullPath *pPath = static_cast(pp->getPath()); + auto pPath = static_cast(pp->getPath()); const auto &pt = pp->getPoint(); SoSelectionElementAction::Type type = SoSelectionElementAction::None; - HighlightModes mymode = (HighlightModes) this->highlightMode.getValue(); + auto mymode = (HighlightModes) this->highlightMode.getValue(); static char buf[513]; if (ctrlDown) { @@ -700,7 +700,7 @@ SoFCUnifiedSelection::handleEvent(SoHandleEventAction * action) return; } - HighlightModes mymode = (HighlightModes) this->highlightMode.getValue(); + auto mymode = (HighlightModes) this->highlightMode.getValue(); const SoEvent * event = action->getEvent(); // If we don't need to pick for locate highlighting, @@ -739,7 +739,7 @@ SoFCUnifiedSelection::handleEvent(SoHandleEventAction * action) // mouse press events for (de)selection else if (event->isOfType(SoMouseButtonEvent::getClassTypeId()) && selectionMode.getValue() == SoFCUnifiedSelection::ON) { - const SoMouseButtonEvent* e = static_cast(event); + const auto e = static_cast(event); if (SoMouseButtonEvent::isButtonReleaseEvent(e,SoMouseButtonEvent::BUTTON1)) { // check to see if the mouse is over a geometry... auto infos = this->getPickedList(action,!Selection().needPickedList()); @@ -959,9 +959,9 @@ SbBool SoVRMLAction::isOverrideMode() const void SoVRMLAction::callDoAction(SoAction *action, SoNode *node) { if (node->getTypeId().isDerivedFrom(SoNormalBinding::getClassTypeId()) && action->isOfType(SoVRMLAction::getClassTypeId())) { - SoVRMLAction* vrmlAction = static_cast(action); + auto vrmlAction = static_cast(action); if (vrmlAction->overrideMode) { - SoNormalBinding* bind = static_cast(node); + auto bind = static_cast(node); vrmlAction->bindList.push_back(bind->value.getValue()); // this normal binding causes some problems for the part view provider // See also #0002222: Number of normals in exported VRML is wrong @@ -1038,7 +1038,7 @@ typedef struct { static void so_bbox_construct_data(void * closure) { - SoFCBBoxRenderInfo * data = (SoFCBBoxRenderInfo*) closure; + auto data = (SoFCBBoxRenderInfo*) closure; data->bboxaction = nullptr; data->cube = nullptr; data->packer = nullptr; @@ -1046,7 +1046,7 @@ static void so_bbox_construct_data(void * closure) static void so_bbox_destruct_data(void * closure) { - SoFCBBoxRenderInfo * data = (SoFCBBoxRenderInfo*) closure; + auto data = (SoFCBBoxRenderInfo*) closure; delete data->bboxaction; if(data->cube) data->cube->unref(); @@ -1769,7 +1769,7 @@ void SoFCPathAnnotation::GLRenderBelowPath(SoGLRenderAction * action) } else { SoCacheElement::invalidate(action->getState()); auto curPath = action->getCurPath(); - SoPath *newPath = new SoPath(curPath->getLength()+path->getLength()); + auto newPath = new SoPath(curPath->getLength()+path->getLength()); newPath->append(curPath); newPath->append(path); action->addDelayedPath(newPath); diff --git a/src/Gui/SoNavigationDragger.cpp b/src/Gui/SoNavigationDragger.cpp index f2556dbeb9..14a3531ed3 100644 --- a/src/Gui/SoNavigationDragger.cpp +++ b/src/Gui/SoNavigationDragger.cpp @@ -139,12 +139,12 @@ RotTransDragger::RotTransDragger() // By calling 'setAnyPartAsDefault' instead of 'setAnyPart' // we ensure that they will not be written out, unless // they are changed later on. - SoRotation *XRot = new SoRotation; + auto XRot = new SoRotation; XRot->rotation.setValue( SbRotation(SbVec3f(0,1,0), SbVec3f(1,0,0))); setAnyPartAsDefault("XRotatorRot", XRot); - SoRotation *ZRot = new SoRotation; + auto ZRot = new SoRotation; ZRot->rotation.setValue( SbRotation(SbVec3f(0,1,0), SbVec3f(0,0,1))); setAnyPartAsDefault("ZRotatorRot", ZRot); @@ -331,7 +331,7 @@ RotTransDragger::setUpConnections(SbBool onOff, SbBool doItAlways) void RotTransDragger::valueChangedCB(void *, SoDragger *inDragger) { - RotTransDragger *myself = (RotTransDragger *) inDragger; + auto myself = (RotTransDragger *) inDragger; // Factor the motionMatrix into its parts SbMatrix motMat = myself->getMotionMatrix(); // clazy:exclude=rule-of-two-soft @@ -355,7 +355,7 @@ RotTransDragger::valueChangedCB(void *, SoDragger *inDragger) void RotTransDragger::fieldSensorCB(void *inDragger, SoSensor *) { - RotTransDragger *myself = (RotTransDragger *) inDragger; + auto myself = (RotTransDragger *) inDragger; SbMatrix motMat = myself->getMotionMatrix(); // clazy:exclude=rule-of-two-soft myself->workFieldsIntoTransform(motMat); @@ -369,7 +369,7 @@ RotTransDragger::fieldSensorCB(void *inDragger, SoSensor *) void RotTransDragger::invalidateSurroundScaleCB(void *parent, SoDragger *) { - RotTransDragger *myParentDragger = (RotTransDragger *) parent; + auto myParentDragger = (RotTransDragger *) parent; // Invalidate the surroundScale, if it exists. SoSurroundScale *mySS = SO_CHECK_PART( diff --git a/src/Gui/SoTextLabel.cpp b/src/Gui/SoTextLabel.cpp index 528b565c59..759ab9191c 100644 --- a/src/Gui/SoTextLabel.cpp +++ b/src/Gui/SoTextLabel.cpp @@ -481,7 +481,7 @@ TranslateManip::TranslateManip() { SO_NODE_CONSTRUCTOR(TranslateManip); - SoTranslate2Dragger *myDrag = new SoTranslate2Dragger; + auto myDrag = new SoTranslate2Dragger; setDragger(myDrag); } diff --git a/src/Gui/SoTouchEvents.cpp b/src/Gui/SoTouchEvents.cpp index e4a98f036f..b2a94bf025 100644 --- a/src/Gui/SoTouchEvents.cpp +++ b/src/Gui/SoTouchEvents.cpp @@ -180,21 +180,21 @@ const SoEvent* GesturesDevice::translateEvent(QEvent* event) { if (event->type() == QEvent::Gesture || event->type() == QEvent::GestureOverride) { - QGestureEvent* gevent = static_cast(event); + auto gevent = static_cast(event); - QPinchGesture* zg = static_cast(gevent->gesture(Qt::PinchGesture)); + auto zg = static_cast(gevent->gesture(Qt::PinchGesture)); if(zg){ gevent->setAccepted(Qt::PinchGesture,true);//prefer it over pan return new SoGesturePinchEvent(zg,this->widget); } - QPanGesture* pg = static_cast(gevent->gesture(Qt::PanGesture)); + auto pg = static_cast(gevent->gesture(Qt::PanGesture)); if(pg){ gevent->setAccepted(Qt::PanGesture,true); return new SoGesturePanEvent(pg,this->widget); } - QSwipeGesture* sg = static_cast(gevent->gesture(Qt::SwipeGesture)); + auto sg = static_cast(gevent->gesture(Qt::SwipeGesture)); if(sg){ gevent->setAccepted(Qt::SwipeGesture,true); return new SoGesturePanEvent(pg,this->widget); diff --git a/src/Gui/SpinBox.cpp b/src/Gui/SpinBox.cpp index b958e0fb07..4c24c9db19 100644 --- a/src/Gui/SpinBox.cpp +++ b/src/Gui/SpinBox.cpp @@ -83,7 +83,7 @@ void ExpressionSpinBox::showInvalidExpression(const QString& tip) void ExpressionSpinBox::showValidExpression(ExpressionSpinBox::Number number) { std::unique_ptr result(getExpression()->eval()); - NumberExpression * value = freecad_dynamic_cast(result.get()); + auto * value = freecad_dynamic_cast(result.get()); if (value) { switch (number) { @@ -168,13 +168,13 @@ void ExpressionSpinBox::openFormulaDialog() { Q_ASSERT(isBound()); - PropertyQuantity * qprop = freecad_dynamic_cast(getPath().getProperty()); + auto * qprop = freecad_dynamic_cast(getPath().getProperty()); Unit unit; if (qprop) unit = qprop->getUnit(); - Gui::Dialog::DlgExpressionInput* box = new Gui::Dialog::DlgExpressionInput(getPath(), getExpression(), unit, spinbox); + auto box = new Gui::Dialog::DlgExpressionInput(getPath(), getExpression(), unit, spinbox); QObject::connect(box, &Gui::Dialog::DlgExpressionInput::finished, [=]() { if (box->result() == QDialog::Accepted) setExpression(box->getExpression()); diff --git a/src/Gui/Splashscreen.cpp b/src/Gui/Splashscreen.cpp index 70a0992f23..11fc8f4066 100644 --- a/src/Gui/Splashscreen.cpp +++ b/src/Gui/Splashscreen.cpp @@ -68,7 +68,7 @@ public: // allow to customize text position and color const std::map& cfg = App::GetApplication().Config(); - std::map::const_iterator al = cfg.find("SplashAlignment"); + auto al = cfg.find("SplashAlignment"); if (al != cfg.end()) { QString alt = QString::fromLatin1(al->second.c_str()); int align=0; @@ -90,7 +90,7 @@ public: } // choose text color - std::map::const_iterator tc = cfg.find("SplashTextColor"); + auto tc = cfg.find("SplashTextColor"); if (tc != cfg.end()) { QColor col; col.setNamedColor(QString::fromLatin1(tc->second.c_str())); if (col.isValid()) @@ -390,11 +390,11 @@ void AboutDialog::showCredits() return; } - QWidget* tab_credits = new QWidget(); + auto tab_credits = new QWidget(); tab_credits->setObjectName(QString::fromLatin1("tab_credits")); ui->tabWidget->addTab(tab_credits, tr("Credits")); - QVBoxLayout* hlayout = new QVBoxLayout(tab_credits); - QTextBrowser* textField = new QTextBrowser(tab_credits); + auto hlayout = new QVBoxLayout(tab_credits); + auto textField = new QTextBrowser(tab_credits); textField->setOpenExternalLinks(false); textField->setOpenLinks(false); hlayout->addWidget(textField); @@ -442,11 +442,11 @@ void AboutDialog::showLicenseInformation() ui->tabWidget->removeTab(1); // Hide the license placeholder widget - QWidget* tab_license = new QWidget(); + auto tab_license = new QWidget(); tab_license->setObjectName(QString::fromLatin1("tab_license")); ui->tabWidget->addTab(tab_license, tr("License")); - QVBoxLayout* hlayout = new QVBoxLayout(tab_license); - QTextBrowser* textField = new QTextBrowser(tab_license); + auto hlayout = new QVBoxLayout(tab_license); + auto textField = new QTextBrowser(tab_license); textField->setOpenExternalLinks(true); textField->setOpenLinks(true); hlayout->addWidget(textField); @@ -481,11 +481,11 @@ QString AboutDialog::getAdditionalLicenseInformation() const void AboutDialog::showLibraryInformation() { - QWidget *tab_library = new QWidget(); + auto tab_library = new QWidget(); tab_library->setObjectName(QString::fromLatin1("tab_library")); ui->tabWidget->addTab(tab_library, tr("Libraries")); - QVBoxLayout* hlayout = new QVBoxLayout(tab_library); - QTextBrowser* textField = new QTextBrowser(tab_library); + auto hlayout = new QVBoxLayout(tab_library); + auto textField = new QTextBrowser(tab_library); textField->setOpenExternalLinks(false); textField->setOpenLinks(false); hlayout->addWidget(textField); @@ -648,11 +648,11 @@ void AboutDialog::showCollectionInformation() if (!QFile::exists(path)) return; - QWidget *tab_collection = new QWidget(); + auto tab_collection = new QWidget(); tab_collection->setObjectName(QString::fromLatin1("tab_collection")); ui->tabWidget->addTab(tab_collection, tr("Collection")); - QVBoxLayout* hlayout = new QVBoxLayout(tab_collection); - QTextBrowser* textField = new QTextBrowser(tab_collection); + auto hlayout = new QVBoxLayout(tab_collection); + auto textField = new QTextBrowser(tab_collection); textField->setOpenExternalLinks(true); hlayout->addWidget(textField); textField->setSource(path); @@ -660,7 +660,7 @@ void AboutDialog::showCollectionInformation() void AboutDialog::linkActivated(const QUrl& link) { - LicenseView* licenseView = new LicenseView(); + auto licenseView = new LicenseView(); licenseView->setAttribute(Qt::WA_DeleteOnClose); licenseView->show(); QString title = tr("License"); diff --git a/src/Gui/SplitView3DInventor.cpp b/src/Gui/SplitView3DInventor.cpp index 9945cbe0d6..490baeec98 100644 --- a/src/Gui/SplitView3DInventor.cpp +++ b/src/Gui/SplitView3DInventor.cpp @@ -198,7 +198,7 @@ void AbstractSplitView::OnChange(ParameterGrp::SubjectType &rCaller,ParameterGrp else if (strcmp(Reason,"HighlightColor") == 0) { float transparency; SbColor highlightColor(0.8f, 0.1f, 0.1f); - unsigned long highlight = (unsigned long)(highlightColor.getPackedValue()); + auto highlight = (unsigned long)(highlightColor.getPackedValue()); highlight = rGrp.GetUnsigned("HighlightColor", highlight); highlightColor.setPackedValue((uint32_t)highlight, transparency); SoSFColor col; col.setValue(highlightColor); @@ -209,7 +209,7 @@ void AbstractSplitView::OnChange(ParameterGrp::SubjectType &rCaller,ParameterGrp else if (strcmp(Reason,"SelectionColor") == 0) { float transparency; SbColor selectionColor(0.1f, 0.8f, 0.1f); - unsigned long selection = (unsigned long)(selectionColor.getPackedValue()); + auto selection = (unsigned long)(selectionColor.getPackedValue()); selection = rGrp.GetUnsigned("SelectionColor", selection); selectionColor.setPackedValue((uint32_t)selection, transparency); SoSFColor col; col.setValue(selectionColor); @@ -519,7 +519,7 @@ Py::Object AbstractSplitViewPy::getattr(const char * attr) AbstractSplitView* AbstractSplitViewPy::getSplitViewPtr() { - AbstractSplitView* view = qobject_cast(base.getMDIViewPtr()); + auto view = qobject_cast(base.getMDIViewPtr()); if (!(view && view->getViewer(0))) throw Py::RuntimeError("Object already deleted"); return view; @@ -790,8 +790,8 @@ SplitView3DInventor::SplitView3DInventor(int views, Gui::Document* pcDocument, Q } else { mainSplitter = new QSplitter(Qt::Vertical, this); - QSplitter *topSplitter = new QSplitter(Qt::Horizontal, mainSplitter); - QSplitter *botSplitter = new QSplitter(Qt::Horizontal, mainSplitter); + auto topSplitter = new QSplitter(Qt::Horizontal, mainSplitter); + auto botSplitter = new QSplitter(Qt::Horizontal, mainSplitter); if (glformat) { _viewer.push_back(new View3DInventorViewer(f, topSplitter)); diff --git a/src/Gui/TaskCSysDragger.cpp b/src/Gui/TaskCSysDragger.cpp index 244b5e2f53..85e7460a38 100644 --- a/src/Gui/TaskCSysDragger.cpp +++ b/src/Gui/TaskCSysDragger.cpp @@ -69,14 +69,14 @@ TaskCSysDragger::~TaskCSysDragger() void TaskCSysDragger::setupGui() { - Gui::TaskView::TaskBox *incrementsBox = new Gui::TaskView::TaskBox( + auto incrementsBox = new Gui::TaskView::TaskBox( Gui::BitmapFactory().pixmap("button_valid"), tr("Increments"), true, nullptr); - QGridLayout *gridLayout = new QGridLayout(); + auto gridLayout = new QGridLayout(); gridLayout->setColumnStretch(1, 1); - QLabel *tLabel = new QLabel(tr("Translation Increment:"), incrementsBox); + auto tLabel = new QLabel(tr("Translation Increment:"), incrementsBox); gridLayout->addWidget(tLabel, 0, 0, Qt::AlignRight); int spinBoxWidth = QApplication::fontMetrics().averageCharWidth() * 20; @@ -87,7 +87,7 @@ void TaskCSysDragger::setupGui() tSpinBox->setMinimumWidth(spinBoxWidth); gridLayout->addWidget(tSpinBox, 0, 1, Qt::AlignLeft); - QLabel *rLabel = new QLabel(tr("Rotation Increment:"), incrementsBox); + auto rLabel = new QLabel(tr("Rotation Increment:"), incrementsBox); gridLayout->addWidget(rLabel, 1, 0, Qt::AlignRight); rSpinBox = new QuantitySpinBox(incrementsBox); diff --git a/src/Gui/TaskElementColors.cpp b/src/Gui/TaskElementColors.cpp index 62120e54d7..605af83848 100644 --- a/src/Gui/TaskElementColors.cpp +++ b/src/Gui/TaskElementColors.cpp @@ -142,7 +142,7 @@ public: const char *marker = ViewProvider::hasHiddenMarker(sub); if(marker) { auto icon = BitmapFactory().pixmap("Invisible"); - QListWidgetItem* item = new QListWidgetItem(icon, + auto item = new QListWidgetItem(icon, QString::fromLatin1(std::string(sub,marker-sub).c_str()), ui->elementList); item->setData(Qt::UserRole,QColor()); item->setData(Qt::UserRole+1,QString::fromLatin1(sub)); @@ -161,7 +161,7 @@ public: QColor c; c.setRgbF(color.r,color.g,color.b,1.0-color.a); px.fill(c); - QListWidgetItem* item = new QListWidgetItem(QIcon(px), + auto item = new QListWidgetItem(QIcon(px), QString::fromLatin1(Data::ComplexGeoData::oldElementName(v.first.c_str()).c_str()), ui->elementList); item->setData(Qt::UserRole,c); diff --git a/src/Gui/TaskView/TaskAppearance.cpp b/src/Gui/TaskView/TaskAppearance.cpp index fbe3b194c1..ac48b92bcc 100644 --- a/src/Gui/TaskView/TaskAppearance.cpp +++ b/src/Gui/TaskView/TaskAppearance.cpp @@ -96,8 +96,8 @@ void TaskAppearance::slotChangedObject(const Gui::ViewProvider& obj, { // This method gets called if a property of any view provider is changed. // We pick out all the properties for which we need to update this dialog. - std::vector Provider = getSelection(); - std::vector::const_iterator vp = std::find_if + const std::vector Provider = getSelection(); + auto vp = std::find_if (Provider.begin(), Provider.end(), [&obj](Gui::ViewProvider* v) { return v == &obj; }); if (vp != Provider.end()) { @@ -136,10 +136,10 @@ void TaskAppearance::on_changeMode_activated(const QString& s) { Gui::WaitCursor wc; std::vector Provider = getSelection(); - for (std::vector::iterator It= Provider.begin();It!=Provider.end();++It) { - App::Property* prop = (*It)->getPropertyByName("DisplayMode"); + for (const auto & It : Provider) { + App::Property* prop = It->getPropertyByName("DisplayMode"); if (prop && prop->getTypeId() == App::PropertyEnumeration::getClassTypeId()) { - App::PropertyEnumeration* Display = (App::PropertyEnumeration*)prop; + auto Display = (App::PropertyEnumeration*)prop; Display->setValue((const char*)s.toLatin1()); } } @@ -156,10 +156,10 @@ void TaskAppearance::on_changePlot_activated(const QString&s) void TaskAppearance::on_spinTransparency_valueChanged(int transparency) { std::vector Provider = getSelection(); - for (std::vector::iterator It= Provider.begin();It!=Provider.end();++It) { - App::Property* prop = (*It)->getPropertyByName("Transparency"); + for (const auto & It : Provider) { + App::Property* prop = It->getPropertyByName("Transparency"); if (prop && prop->getTypeId().isDerivedFrom(App::PropertyInteger::getClassTypeId())) { - App::PropertyInteger* Transparency = (App::PropertyInteger*)prop; + auto Transparency = (App::PropertyInteger*)prop; Transparency->setValue(transparency); } } @@ -171,10 +171,10 @@ void TaskAppearance::on_spinTransparency_valueChanged(int transparency) void TaskAppearance::on_spinPointSize_valueChanged(int pointsize) { std::vector Provider = getSelection(); - for (std::vector::iterator It= Provider.begin();It!=Provider.end();++It) { - App::Property* prop = (*It)->getPropertyByName("PointSize"); + for (const auto & It : Provider) { + App::Property* prop = It->getPropertyByName("PointSize"); if (prop && prop->getTypeId().isDerivedFrom(App::PropertyFloat::getClassTypeId())) { - App::PropertyFloat* PointSize = (App::PropertyFloat*)prop; + auto PointSize = (App::PropertyFloat*)prop; PointSize->setValue((float)pointsize); } } @@ -186,10 +186,10 @@ void TaskAppearance::on_spinPointSize_valueChanged(int pointsize) void TaskAppearance::on_spinLineWidth_valueChanged(int linewidth) { std::vector Provider = getSelection(); - for (std::vector::iterator It= Provider.begin();It!=Provider.end();++It) { - App::Property* prop = (*It)->getPropertyByName("LineWidth"); + for (const auto & It : Provider) { + App::Property* prop = It->getPropertyByName("LineWidth"); if (prop && prop->getTypeId().isDerivedFrom(App::PropertyFloat::getClassTypeId())) { - App::PropertyFloat* LineWidth = (App::PropertyFloat*)prop; + auto LineWidth = (App::PropertyFloat*)prop; LineWidth->setValue((float)linewidth); } } @@ -198,21 +198,21 @@ void TaskAppearance::on_spinLineWidth_valueChanged(int linewidth) void TaskAppearance::setDisplayModes(const std::vector& views) { QStringList commonModes, modes; - for (std::vector::const_iterator it = views.begin(); it != views.end(); ++it) { + for (auto it = views.begin(); it != views.end(); ++it) { App::Property* prop = (*it)->getPropertyByName("DisplayMode"); if (prop && prop->getTypeId() == App::PropertyEnumeration::getClassTypeId()) { - App::PropertyEnumeration* display = static_cast(prop); + auto display = static_cast(prop); if (!display->hasEnums()) return; std::vector value = display->getEnumVector(); if (it == views.begin()) { - for (std::vector::const_iterator jt = value.begin(); jt != value.end(); ++jt) - commonModes << QLatin1String(jt->c_str()); + for (const auto & jt : value) + commonModes << QLatin1String(jt.c_str()); } else { - for (std::vector::const_iterator jt = value.begin(); jt != value.end(); ++jt) { - if (commonModes.contains(QLatin1String(jt->c_str()))) - modes << QLatin1String(jt->c_str()); + for (const auto & jt : value) { + if (commonModes.contains(QLatin1String(jt.c_str()))) + modes << QLatin1String(jt.c_str()); } commonModes = modes; @@ -226,10 +226,10 @@ void TaskAppearance::setDisplayModes(const std::vector& view ui->changeMode->setDisabled(commonModes.isEmpty()); // find the display mode to activate - for (std::vector::const_iterator it = views.begin(); it != views.end(); ++it) { - App::Property* prop = (*it)->getPropertyByName("DisplayMode"); + for (const auto view : views) { + App::Property* prop = view->getPropertyByName("DisplayMode"); if (prop && prop->getTypeId() == App::PropertyEnumeration::getClassTypeId()) { - App::PropertyEnumeration* display = static_cast(prop); + auto display = static_cast(prop); QString activeMode = QString::fromLatin1(display->getValueAsString()); int index = ui->changeMode->findText(activeMode); if (index != -1) { @@ -243,8 +243,8 @@ void TaskAppearance::setDisplayModes(const std::vector& view void TaskAppearance::setPointSize(const std::vector& views) { bool pointSize = false; - for (std::vector::const_iterator it = views.begin(); it != views.end(); ++it) { - App::Property* prop = (*it)->getPropertyByName("PointSize"); + for (const auto & view : views) { + App::Property* prop = view->getPropertyByName("PointSize"); if (prop && prop->getTypeId().isDerivedFrom(App::PropertyFloat::getClassTypeId())) { bool blocked = ui->spinPointSize->blockSignals(true); ui->spinPointSize->setValue((int)static_cast(prop)->getValue()); @@ -260,8 +260,8 @@ void TaskAppearance::setPointSize(const std::vector& views) void TaskAppearance::setLineWidth(const std::vector& views) { bool lineWidth = false; - for (std::vector::const_iterator it = views.begin(); it != views.end(); ++it) { - App::Property* prop = (*it)->getPropertyByName("LineWidth"); + for (const auto & view : views) { + App::Property* prop = view->getPropertyByName("LineWidth"); if (prop && prop->getTypeId().isDerivedFrom(App::PropertyFloat::getClassTypeId())) { bool blocked = ui->spinLineWidth->blockSignals(true); ui->spinLineWidth->setValue((int)static_cast(prop)->getValue()); @@ -277,8 +277,8 @@ void TaskAppearance::setLineWidth(const std::vector& views) void TaskAppearance::setTransparency(const std::vector& views) { bool transparency = false; - for (std::vector::const_iterator it = views.begin(); it != views.end(); ++it) { - App::Property* prop = (*it)->getPropertyByName("Transparency"); + for (const auto & view : views) { + App::Property* prop = view->getPropertyByName("Transparency"); if (prop && prop->getTypeId().isDerivedFrom(App::PropertyInteger::getClassTypeId())) { bool blocked = ui->spinTransparency->blockSignals(true); ui->spinTransparency->setValue(static_cast(prop)->getValue()); @@ -298,8 +298,8 @@ std::vector TaskAppearance::getSelection() const // get the complete selection std::vector sel = Selection().getCompleteSelection(); - for (std::vector::iterator it = sel.begin(); it != sel.end(); ++it) { - Gui::ViewProvider* view = Application::Instance->getDocument(it->pDoc)->getViewProvider(it->pObject); + for (const auto & it : sel) { + Gui::ViewProvider* view = Application::Instance->getDocument(it.pDoc)->getViewProvider(it.pObject); if (view) views.push_back(view); } diff --git a/src/Gui/TaskView/TaskDialogPython.cpp b/src/Gui/TaskView/TaskDialogPython.cpp index e1588b3b61..d080900a2e 100644 --- a/src/Gui/TaskView/TaskDialogPython.cpp +++ b/src/Gui/TaskView/TaskDialogPython.cpp @@ -118,7 +118,7 @@ Py::Object ControlPy::showDialog(const Py::Tuple& args) Gui::TaskView::TaskDialog* act = Gui::Control().activeDialog(); if (act) throw Py::RuntimeError("Active task dialog found"); - TaskDialogPython* dlg = new TaskDialogPython(Py::Object(arg0)); + auto dlg = new TaskDialogPython(Py::Object(arg0)); Gui::Control().showDialog(dlg); return Py::None(); } @@ -148,7 +148,7 @@ Py::Object ControlPy::addTaskWatcher(const Py::Tuple& args) std::vector watcher; Py::Sequence list(arg0); for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) { - TaskWatcherPython* w = new TaskWatcherPython(*it); + auto w = new TaskWatcherPython(*it); watcher.push_back(w); } @@ -322,7 +322,7 @@ TaskDialogPython::TaskDialogPython(const Py::Object& o) : dlg(o) form = loader.load(&file, nullptr); file.close(); if (form) { - Gui::TaskView::TaskBox* taskbox = new Gui::TaskView::TaskBox( + auto taskbox = new Gui::TaskView::TaskBox( QPixmap(icon), form->windowTitle(), true, nullptr); taskbox->groupLayout()->addWidget(form); Content.push_back(taskbox); @@ -349,7 +349,7 @@ TaskDialogPython::TaskDialogPython(const Py::Object& o) : dlg(o) if (object) { QWidget* form = qobject_cast(object); if (form) { - Gui::TaskView::TaskBox* taskbox = new Gui::TaskView::TaskBox( + auto taskbox = new Gui::TaskView::TaskBox( form->windowIcon().pixmap(32), form->windowTitle(), true, nullptr); taskbox->groupLayout()->addWidget(form); Content.push_back(taskbox); diff --git a/src/Gui/TaskView/TaskSelectLinkProperty.cpp b/src/Gui/TaskView/TaskSelectLinkProperty.cpp index 93f03e51cc..53e20ac55f 100644 --- a/src/Gui/TaskView/TaskSelectLinkProperty.cpp +++ b/src/Gui/TaskView/TaskSelectLinkProperty.cpp @@ -129,10 +129,10 @@ void TaskSelectLinkProperty::activate() else if (LinkList) { // save the start values for a cnacel operation (reject()) const std::vector &Values = LinkList->getValues(); - for(std::vector::const_iterator it = Values.begin();it!=Values.end();++it) + for(const auto & Value : Values) { - std::string ObjName = (*it)->getNameInDocument(); - std::string DocName = (*it)->getDocument()->getName(); + std::string ObjName = Value->getNameInDocument(); + std::string DocName = Value->getDocument()->getName(); Gui::Selection().addSelection(DocName.c_str(),ObjName.c_str()); } } @@ -174,8 +174,8 @@ void TaskSelectLinkProperty::sendSelection2Property() else if (LinkList) { std::vector sel = Gui::Selection().getSelectionEx(); std::vector temp; - for (std::vector::iterator it=sel.begin();it!=sel.end();++it) - temp.push_back(it->getObject()); + for (auto & it : sel) + temp.push_back(it.getObject()); LinkList->setValues(temp); } @@ -208,12 +208,12 @@ void TaskSelectLinkProperty::OnChange(Gui::SelectionSingleton::SubjectType &rCal Reason.Type == SelectionChanges::ClrSelection) { ui->listWidget->clear(); std::vector sel = Gui::Selection().getSelection(); - for (std::vector::const_iterator it=sel.begin();it!=sel.end();++it){ + for (const auto & it : sel){ std::string temp; - temp += it->FeatName; - if (strcmp(it->SubName, "") != 0){ + temp += it.FeatName; + if (strcmp(it.SubName, "") != 0){ temp += "::"; - temp += it->SubName; + temp += it.SubName; } new QListWidgetItem(QString::fromLatin1(temp.c_str()), ui->listWidget); } diff --git a/src/Gui/TaskView/TaskView.cpp b/src/Gui/TaskView/TaskView.cpp index 28bed5fc13..2f72394c0a 100644 --- a/src/Gui/TaskView/TaskView.cpp +++ b/src/Gui/TaskView/TaskView.cpp @@ -219,7 +219,7 @@ void TaskBox::actionEvent (QActionEvent* e) switch (e->type()) { case QEvent::ActionAdded: { - QSint::ActionLabel *label = new QSint::ActionLabel(action, this); + auto label = new QSint::ActionLabel(action, this); this->addActionLabel(label, true, false); break; } @@ -327,7 +327,7 @@ bool TaskView::event(QEvent* event) bool isSpinBox = qobject_cast(focusWidget); if (isLineEdit || isSpinBox) { - QKeyEvent * kevent = static_cast(event); + auto kevent = static_cast(event); Qt::KeyboardModifiers ShiftKeypadModifier = Qt::ShiftModifier | Qt::KeypadModifier; if (kevent->modifiers() == Qt::NoModifier || kevent->modifiers() == Qt::ShiftModifier || @@ -356,8 +356,7 @@ void TaskView::keyPressEvent(QKeyEvent* ke) if (ke->key() == Qt::Key_Return || ke->key() == Qt::Key_Enter) { // get all buttons of the complete task dialog QList list = this->findChildren(); - for (int i=0; iisDefault() && pb->isVisible()) { if (pb->isEnabled()) { #if defined(FC_OS_MACOSX) @@ -378,8 +377,7 @@ void TaskView::keyPressEvent(QKeyEvent* ke) // get only the buttons of the button box QDialogButtonBox* box = ActiveCtrl->standardButtons(); QList list = box->buttons(); - for (int i=0; ibuttonRole(pb) == QDialogButtonBox::RejectRole) { if (pb->isEnabled()) { #if defined(FC_OS_MACOSX) @@ -399,7 +397,7 @@ void TaskView::keyPressEvent(QKeyEvent* ke) // In case a task panel has no Close or Cancel button // then invoke resetEdit() directly // See also ViewProvider::eventCallback - Gui::TimerFunction* func = new Gui::TimerFunction(); + auto func = new Gui::TimerFunction(); func->setAutoDelete(true); Gui::Document* doc = Gui::Application::Instance->getDocument(ActiveDialog->getDocumentName().c_str()); if (doc) { @@ -499,13 +497,13 @@ void TaskView::showDialog(TaskDialog *dlg) if (dlg->buttonPosition() == TaskDialog::North) { taskPanel->addWidget(ActiveCtrl); - for (std::vector::const_iterator it=cont.begin();it!=cont.end();++it){ - taskPanel->addWidget(*it); + for (const auto & it : cont){ + taskPanel->addWidget(it); } } else { - for (std::vector::const_iterator it=cont.begin();it!=cont.end();++it){ - taskPanel->addWidget(*it); + for (const auto & it : cont){ + taskPanel->addWidget(it); } taskPanel->addWidget(ActiveCtrl); } @@ -538,8 +536,8 @@ void TaskView::removeDialog() // See 'accept' and 'reject' if (ActiveDialog->property("taskview_accept_or_reject").isNull()) { const std::vector &cont = ActiveDialog->getDialogContent(); - for(std::vector::const_iterator it=cont.begin();it!=cont.end();++it){ - taskPanel->removeWidget(*it); + for(const auto & it : cont){ + taskPanel->removeWidget(it); } remove = ActiveDialog; ActiveDialog = nullptr; @@ -581,14 +579,14 @@ void TaskView::updateWatcher() } // add all widgets for all watcher to the task view - for (std::vector::iterator it=ActiveWatcher.begin();it!=ActiveWatcher.end();++it) { - bool match = (*it)->shouldShow(); - std::vector &cont = (*it)->getWatcherContent(); - for (std::vector::iterator it2=cont.begin();it2!=cont.end();++it2) { + for (const auto & it : ActiveWatcher) { + bool match = it->shouldShow(); + std::vector &cont = it->getWatcherContent(); + for (auto & it2 : cont) { if (match) - (*it2)->show(); + it2->show(); else - (*it2)->hide(); + it2->hide(); } } @@ -622,7 +620,7 @@ void TaskView::addTaskWatcher() for (std::vector::iterator it=ActiveWatcher.begin();it!=ActiveWatcher.end();++it){ std::vector &cont = (*it)->getWatcherContent(); for (std::vector::iterator it2=cont.begin();it2!=cont.end();++it2){ - taskPanel->addWidget(*it2); + taskPanel->addWidget(*it2); } } @@ -636,7 +634,7 @@ void TaskView::addTaskWatcher() // // Notify the button box about a style change so that it can // safely delete the style animation of its push buttons. - QDialogButtonBox* box = taskPanel->findChild(); + auto box = taskPanel->findChild(); if (box) { QEvent event(QEvent::StyleChange); QApplication::sendEvent(box, &event); diff --git a/src/Gui/TaskView/TaskWatcher.cpp b/src/Gui/TaskView/TaskWatcher.cpp index 014e9c32f7..6cba74287f 100644 --- a/src/Gui/TaskView/TaskWatcher.cpp +++ b/src/Gui/TaskView/TaskWatcher.cpp @@ -82,7 +82,7 @@ TaskWatcherCommands::TaskWatcherCommands(const char* Filter,const char* commands { if (commands) { CommandManager &mgr = Gui::Application::Instance->commandManager(); - Gui::TaskView::TaskBox *tb = new Gui::TaskView::TaskBox + auto tb = new Gui::TaskView::TaskBox (BitmapFactory().pixmap(pixmap), tr(name), true, nullptr); for (const char** i=commands;*i;i++) { diff --git a/src/Gui/TextEdit.cpp b/src/Gui/TextEdit.cpp index 923e2cf7ec..4d7845ba0c 100644 --- a/src/Gui/TextEdit.cpp +++ b/src/Gui/TextEdit.cpp @@ -44,22 +44,22 @@ TextEdit::TextEdit(QWidget* parent) { //Note: Set the correct context to this shortcut as we may use several instances of this //class at a time - QShortcut* shortcut = new QShortcut(this); + auto shortcut = new QShortcut(this); shortcut->setKey(QKeySequence(QString::fromLatin1("CTRL+Space"))); shortcut->setContext(Qt::WidgetShortcut); connect(shortcut, SIGNAL(activated()), this, SLOT(complete())); - QShortcut* shortcutFind = new QShortcut(this); + auto shortcutFind = new QShortcut(this); shortcutFind->setKey(QKeySequence::Find); shortcutFind->setContext(Qt::WidgetShortcut); connect(shortcutFind, SIGNAL(activated()), this, SIGNAL(showSearchBar())); - QShortcut* shortcutNext = new QShortcut(this); + auto shortcutNext = new QShortcut(this); shortcutNext->setKey(QKeySequence::FindNext); shortcutNext->setContext(Qt::WidgetShortcut); connect(shortcutNext, SIGNAL(activated()), this, SIGNAL(findNext())); - QShortcut* shortcutPrev = new QShortcut(this); + auto shortcutPrev = new QShortcut(this); shortcutPrev->setKey(QKeySequence::FindPrevious); shortcutPrev->setContext(Qt::WidgetShortcut); connect(shortcutPrev, SIGNAL(activated()), this, SIGNAL(findPrevious())); @@ -290,7 +290,7 @@ void TextEditor::highlightCurrentLine() QColor lineColor = d->colormap[QLatin1String("Current line highlight")]; unsigned int col = (lineColor.red() << 24) | (lineColor.green() << 16) | (lineColor.blue() << 8); ParameterGrp::handle hPrefGrp = getWindowParameter(); - unsigned long value = static_cast(col); + auto value = static_cast(col); value = hPrefGrp->GetUnsigned( "Current line highlight", value); col = static_cast(value); lineColor.setRgb((col>>24)&0xff, (col>>16)&0xff, (col>>8)&0xff); @@ -454,7 +454,7 @@ void TextEditor::OnChange(Base::Subject &rCaller,const char* sReaso if (it != d->colormap.end()) { QColor color = it.value(); unsigned int col = (color.red() << 24) | (color.green() << 16) | (color.blue() << 8); - unsigned long value = static_cast(col); + auto value = static_cast(col); value = hPrefGrp->GetUnsigned(sReason, value); col = static_cast(value); color.setRgb((col>>24)&0xff, (col>>16)&0xff, (col>>8)&0xff); @@ -565,7 +565,7 @@ bool CompletionList::eventFilter(QObject * watched, QEvent * event) hide(); } else if (isVisible() && watched == textEdit) { if (event->type() == QEvent::KeyPress) { - QKeyEvent* ke = (QKeyEvent*)event; + auto ke = (QKeyEvent*)event; if (ke->key() == Qt::Key_Up || ke->key() == Qt::Key_Down) { keyPressEvent(ke); return true; diff --git a/src/Gui/TinkerCADNavigationStyle.cpp b/src/Gui/TinkerCADNavigationStyle.cpp index f3d6159a7b..a8afd7aef7 100644 --- a/src/Gui/TinkerCADNavigationStyle.cpp +++ b/src/Gui/TinkerCADNavigationStyle.cpp @@ -105,13 +105,13 @@ SbBool TinkerCADNavigationStyle::processSoEvent(const SoEvent * const ev) // Keyboard handling if (type.isDerivedFrom(SoKeyboardEvent::getClassTypeId())) { - const SoKeyboardEvent * const event = static_cast(ev); + const auto event = static_cast(ev); processed = processKeyboardEvent(event); } // Mouse Button / Spaceball Button handling if (type.isDerivedFrom(SoMouseButtonEvent::getClassTypeId())) { - const SoMouseButtonEvent * const event = (const SoMouseButtonEvent *) ev; + const auto event = (const SoMouseButtonEvent *) ev; const int button = event->getButton(); const SbBool press = event->getState() == SoButtonEvent::DOWN ? true : false; SbBool canOpenPopupMenu = false; @@ -186,7 +186,7 @@ SbBool TinkerCADNavigationStyle::processSoEvent(const SoEvent * const ev) // Mouse Movement handling if (type.isDerivedFrom(SoLocation2Event::getClassTypeId())) { - const SoLocation2Event * const event = (const SoLocation2Event *) ev; + const auto event = (const SoLocation2Event *) ev; if (curmode == NavigationStyle::PANNING) { float ratio = vp.getViewportAspectRatio(); panCamera(viewer->getSoRenderManager()->getCamera(), ratio, this->panningplane, posn, prevnormalized); @@ -202,7 +202,7 @@ SbBool TinkerCADNavigationStyle::processSoEvent(const SoEvent * const ev) // Spaceball & Joystick handling if (type.isDerivedFrom(SoMotion3Event::getClassTypeId())) { - const SoMotion3Event * const event = static_cast(ev); + const auto event = static_cast(ev); if (event) this->processMotionEvent(event); processed = true; diff --git a/src/Gui/ToolBarManager.cpp b/src/Gui/ToolBarManager.cpp index 4f99f6d88d..242305f9e6 100644 --- a/src/Gui/ToolBarManager.cpp +++ b/src/Gui/ToolBarManager.cpp @@ -83,7 +83,7 @@ ToolBarItem* ToolBarItem::findItem(const std::string& name) ToolBarItem* ToolBarItem::copy() const { - ToolBarItem* root = new ToolBarItem; + auto root = new ToolBarItem; root->setCommand( command() ); QList items = getItems(); @@ -138,7 +138,7 @@ ToolBarItem& ToolBarItem::operator << (ToolBarItem* item) ToolBarItem& ToolBarItem::operator << (const std::string& command) { - ToolBarItem* item = new ToolBarItem(this); + auto item = new ToolBarItem(this); item->setCommand(command); return *this; } diff --git a/src/Gui/ToolBox.cpp b/src/Gui/ToolBox.cpp index 61213bb963..13b2518334 100644 --- a/src/Gui/ToolBox.cpp +++ b/src/Gui/ToolBox.cpp @@ -42,7 +42,7 @@ ToolBox::ToolBox( QWidget *parent ) _pToolBox = new QToolBox( this ); connect( _pToolBox, SIGNAL( currentChanged(int) ), this, SIGNAL( currentChanged(int) ) ); - QGridLayout* pGrid = new QGridLayout(this); + auto pGrid = new QGridLayout(this); pGrid->addWidget(_pToolBox, 0, 0); } diff --git a/src/Gui/ToolBoxManager.cpp b/src/Gui/ToolBoxManager.cpp index aa9e3ac549..716846afbe 100644 --- a/src/Gui/ToolBoxManager.cpp +++ b/src/Gui/ToolBoxManager.cpp @@ -85,7 +85,7 @@ void ToolBoxManager::setup( ToolBarItem* toolBar ) const for ( QList::Iterator item = items.begin(); item != items.end(); ++item ) { - QToolBar* bar = new QToolBar(); + auto bar = new QToolBar(); bar->setOrientation(Qt::Vertical); bar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); std::string toolbarName = (*item)->command(); diff --git a/src/Gui/TouchpadNavigationStyle.cpp b/src/Gui/TouchpadNavigationStyle.cpp index 8f9ed4b552..71d81e688d 100644 --- a/src/Gui/TouchpadNavigationStyle.cpp +++ b/src/Gui/TouchpadNavigationStyle.cpp @@ -104,13 +104,13 @@ SbBool TouchpadNavigationStyle::processSoEvent(const SoEvent * const ev) // Keyboard handling if (type.isDerivedFrom(SoKeyboardEvent::getClassTypeId())) { - const SoKeyboardEvent * const event = static_cast(ev); + const auto event = static_cast(ev); processed = processKeyboardEvent(event); } // Mouse Button / Spaceball Button handling if (type.isDerivedFrom(SoMouseButtonEvent::getClassTypeId())) { - const SoMouseButtonEvent * const event = (const SoMouseButtonEvent *) ev; + const auto event = (const SoMouseButtonEvent *) ev; const int button = event->getButton(); const SbBool press = event->getState() == SoButtonEvent::DOWN ? true : false; @@ -173,7 +173,7 @@ SbBool TouchpadNavigationStyle::processSoEvent(const SoEvent * const ev) // Mouse Movement handling if (type.isDerivedFrom(SoLocation2Event::getClassTypeId())) { this->lockrecenter = true; - const SoLocation2Event * const event = (const SoLocation2Event *) ev; + const auto event = (const SoLocation2Event *) ev; if (this->currentmode == NavigationStyle::ZOOMING) { this->zoomByCursor(posn, prevnormalized); processed = true; @@ -193,7 +193,7 @@ SbBool TouchpadNavigationStyle::processSoEvent(const SoEvent * const ev) // Spaceball & Joystick handling if (type.isDerivedFrom(SoMotion3Event::getClassTypeId())) { - const SoMotion3Event * const event = static_cast(ev); + const auto event = static_cast(ev); if (event) this->processMotionEvent(event); processed = true; diff --git a/src/Gui/Transform.cpp b/src/Gui/Transform.cpp index 444e87b166..3adf6dd37a 100644 --- a/src/Gui/Transform.cpp +++ b/src/Gui/Transform.cpp @@ -74,10 +74,10 @@ Base::Vector3d TransformStrategy::getRotationCenter() const if (!objects.empty()) { Base::BoundBox3d bbox; bool first=true; - for (std::set::const_iterator it=objects.begin();it!=objects.end();++it) { - if ((*it)->getTypeId().isDerivedFrom(App::GeoFeature::getClassTypeId())) { + for (const auto & object : objects) { + if (object->getTypeId().isDerivedFrom(App::GeoFeature::getClassTypeId())) { // search for a data property - const App::PropertyGeometry* geo = static_cast(*it)->getPropertyOfGeometry(); + const App::PropertyGeometry* geo = static_cast(object)->getPropertyOfGeometry(); if (geo) { if (first) bbox = geo->getBoundingBox(); @@ -102,8 +102,8 @@ void TransformStrategy::commitTransform(const Base::Matrix4D& mat) Gui::Document* doc = Gui::Application::Instance->activeDocument(); if (doc) { doc->openCommand(QT_TRANSLATE_NOOP("Command", "Transform")); - for (std::set::iterator it=objects.begin();it!=objects.end();++it) { - acceptDataTransform(mat, *it); + for (const auto & object : objects) { + acceptDataTransform(mat, object); } doc->commitCommand(); } @@ -141,16 +141,16 @@ void TransformStrategy::acceptDataTransform(const Base::Matrix4D& mat, App::Docu void TransformStrategy::applyTransform(const Base::Placement& plm) { std::set objects = transformObjects(); - for (std::set::iterator it=objects.begin();it!=objects.end();++it) { - applyViewTransform(plm, *it); + for (const auto & object : objects) { + applyViewTransform(plm, object); } } void TransformStrategy::resetTransform() { std::set objects = transformObjects(); - for (std::set::iterator it=objects.begin();it!=objects.end();++it) { - resetViewTransform(*it); + for (const auto & object : objects) { + resetViewTransform(object); } } @@ -220,9 +220,8 @@ void DefaultTransformStrategy::onSelectionChanged(const Gui::SelectionChanges& m return; // nothing to do if (msg.Type == SelectionChanges::ClrSelection) { widget->setDisabled(true); - for (std::set::iterator it = selection.begin(); - it != selection.end(); ++it) - resetViewTransform(*it); + for (const auto & it : selection) + resetViewTransform(it); selection.clear(); return; } @@ -230,12 +229,12 @@ void DefaultTransformStrategy::onSelectionChanged(const Gui::SelectionChanges& m std::set update_selection; std::vector sel = Gui::Selection().getObjectsOfType (App::DocumentObject::getClassTypeId()); - for (std::vector::iterator it=sel.begin();it!=sel.end();++it) { - if ((*it)->getTypeId().isDerivedFrom(App::GeoFeature::getClassTypeId())) { + for (const auto & it : sel) { + if (it->getTypeId().isDerivedFrom(App::GeoFeature::getClassTypeId())) { // search for a data property - const App::PropertyGeometry* geo = static_cast(*it)->getPropertyOfGeometry(); + const App::PropertyGeometry* geo = static_cast(it)->getPropertyOfGeometry(); if (geo) { - update_selection.insert(*it); + update_selection.insert(it); } } } @@ -245,8 +244,7 @@ void DefaultTransformStrategy::onSelectionChanged(const Gui::SelectionChanges& m // it is touched and thus a recompute later would overwrite the // changes here anyway std::set filter; - for (std::set::iterator it=update_selection.begin(); - it!=update_selection.end();++it) { + for (auto it = update_selection.begin(); it != update_selection.end(); ++it) { std::vector deps = (*it)->getOutList(); std::vector::iterator jt; for (jt = deps.begin(); jt != deps.end(); ++jt) { @@ -270,8 +268,8 @@ void DefaultTransformStrategy::onSelectionChanged(const Gui::SelectionChanges& m std::back_insert_iterator< std::vector > biit(diff); std::set_difference(selection.begin(), selection.end(), update_selection.begin(), update_selection.end(), biit); - for (std::vector::iterator it = diff.begin(); it != diff.end(); ++it) - resetViewTransform(*it); + for (const auto & it : diff) + resetViewTransform(it); selection = update_selection; widget->setDisabled(selection.empty()); @@ -292,15 +290,15 @@ Transform::Transform(QWidget* parent, Qt::WindowFlags fl) this->setWindowTitle(tr("Transform")); // create a signal mapper in order to have one slot to perform the change - QSignalMapper* signalMapper = new QSignalMapper(this); + auto signalMapper = new QSignalMapper(this); connect(this, SIGNAL(directionChanged()), signalMapper, SLOT(map())); signalMapper->setMapping(this, 0); int id = 1; QList sb = this->findChildren(); - for (QList::iterator it = sb.begin(); it != sb.end(); ++it) { - connect(*it, SIGNAL(valueChanged(double)), signalMapper, SLOT(map())); - signalMapper->setMapping(*it, id++); + for (const auto & it : sb) { + connect(it, SIGNAL(valueChanged(double)), signalMapper, SLOT(map())); + signalMapper->setMapping(it, id++); } connect(signalMapper, SIGNAL(mapped(int)), @@ -363,10 +361,10 @@ void Transform::on_applyButton_clicked() // nullify the values QList sb = this->findChildren(); - for (QList::iterator it = sb.begin(); it != sb.end(); ++it) { - (*it)->blockSignals(true); - (*it)->setValue(0.0); - (*it)->blockSignals(false); + for (auto & it : sb) { + it->blockSignals(true); + it->setValue(0.0); + it->blockSignals(false); } Base::Vector3d cnt = strategy->getRotationCenter(); diff --git a/src/Gui/Tree.cpp b/src/Gui/Tree.cpp index af35c1f617..d53735e354 100644 --- a/src/Gui/Tree.cpp +++ b/src/Gui/Tree.cpp @@ -413,7 +413,7 @@ QWidget* TreeWidgetEditDelegate::createEditor( auto ti = static_cast(index.internalPointer()); if (ti->type() != TreeWidget::ObjectType || index.column() > 1) return nullptr; - DocumentObjectItem* item = static_cast(ti); + auto item = static_cast(ti); App::DocumentObject* obj = item->object()->getObject(); auto& prop = index.column() ? obj->Label2 : obj->Label; @@ -422,7 +422,7 @@ QWidget* TreeWidgetEditDelegate::createEditor( App::GetApplication().setActiveTransaction(str.str().c_str()); FC_LOG("create editor transaction " << App::GetApplication().getActiveTransaction()); - ExpLineEdit* le = new ExpLineEdit(parent); + auto le = new ExpLineEdit(parent); le->setFrame(false); le->setReadOnly(prop.isReadOnly()); le->bind(App::ObjectIdentifier(prop)); @@ -843,7 +843,7 @@ void TreeWidget::contextMenuEvent(QContextMenuEvent* e) this->contextItem = itemAt(e->pos()); if (this->contextItem && this->contextItem->type() == DocumentType) { - DocumentItem* docitem = static_cast(this->contextItem); + auto docitem = static_cast(this->contextItem); App::Document* doc = docitem->document()->getDocument(); App::GetApplication().setActiveDocument(doc); showHiddenAction->setChecked(docitem->showHidden()); @@ -871,7 +871,7 @@ void TreeWidget::contextMenuEvent(QContextMenuEvent* e) contextMenu.addSeparator(); } else if (this->contextItem && this->contextItem->type() == ObjectType) { - DocumentObjectItem* objitem = static_cast + auto objitem = static_cast (this->contextItem); // check that the selection is not across several documents @@ -936,7 +936,7 @@ void TreeWidget::contextMenuEvent(QContextMenuEvent* e) subMenu.setTitle(tr("Activate document")); contextMenu.addMenu(&subMenu); QAction* active = nullptr; - for (std::vector::iterator it = docs.begin(); it != docs.end(); ++it) { + for (auto it = docs.begin(); it != docs.end(); ++it) { QString label = QString::fromUtf8((*it)->Label.getValue()); QAction* action = subMenuGroup.addAction(label); action->setCheckable(true); @@ -980,7 +980,7 @@ void TreeWidget::onCreateGroup() QString name = tr("Group"); App::AutoTransaction trans("Create group"); if (this->contextItem->type() == DocumentType) { - DocumentItem* docitem = static_cast(this->contextItem); + auto docitem = static_cast(this->contextItem); App::Document* doc = docitem->document()->getDocument(); QString cmd = QString::fromLatin1("App.getDocument(\"%1\").addObject" "(\"App::DocumentObjectGroup\",\"Group\").Label=\"%2\"") @@ -988,7 +988,7 @@ void TreeWidget::onCreateGroup() Gui::Command::runCommand(Gui::Command::App, cmd.toUtf8()); } else if (this->contextItem->type() == ObjectType) { - DocumentObjectItem* objitem = static_cast + auto objitem = static_cast (this->contextItem); App::DocumentObject* obj = objitem->object()->getObject(); App::Document* doc = obj->getDocument(); @@ -1010,10 +1010,10 @@ void TreeWidget::onRelabelObject() void TreeWidget::onStartEditing() { - QAction* action = qobject_cast(sender()); + auto action = qobject_cast(sender()); if (action) { if (this->contextItem && this->contextItem->type() == ObjectType) { - DocumentObjectItem* objitem = static_cast + auto objitem = static_cast (this->contextItem); int edit = action->data().toInt(); @@ -1034,7 +1034,7 @@ void TreeWidget::onStartEditing() void TreeWidget::onFinishEditing() { if (this->contextItem && this->contextItem->type() == ObjectType) { - DocumentObjectItem* objitem = static_cast + auto objitem = static_cast (this->contextItem); App::DocumentObject* obj = objitem->object()->getObject(); if (!obj) @@ -1058,7 +1058,7 @@ bool TreeWidget::CheckForDependents() QList items = this->selectedItems(); for (QList::iterator it = items.begin(); it != items.end(); ++it) { if ((*it)->type() == ObjectType) { - DocumentObjectItem* objitem = static_cast(*it); + auto objitem = static_cast(*it); App::DocumentObject* obj = objitem->object()->getObject(); // get dependents auto subObjectList = obj->getOutList(); @@ -1092,10 +1092,10 @@ void TreeWidget::onSelectDependents() // if the selected object is a document if (this->contextItem && this->contextItem->type() == DocumentType) { - DocumentItem* docitem = static_cast(this->contextItem); + auto docitem = static_cast(this->contextItem); doc = docitem->document()->getDocument(); std::vector obj = doc->getObjects(); - for (std::vector::iterator it = obj.begin(); it != obj.end(); ++it) + for (auto it = obj.begin(); it != obj.end(); ++it) Selection().addSelection(doc->getName(), (*it)->getNameInDocument()); } // it can be an object @@ -1103,7 +1103,7 @@ void TreeWidget::onSelectDependents() QList items = this->selectedItems(); for (QList::iterator it = items.begin(); it != items.end(); ++it) { if ((*it)->type() == ObjectType) { - DocumentObjectItem* objitem = static_cast(*it); + auto objitem = static_cast(*it); doc = objitem->object()->getObject()->getDocument(); App::DocumentObject* obj = objitem->object()->getObject(); // the dependents can also have dependents, thus add them recursively via a separate void @@ -1117,7 +1117,7 @@ void TreeWidget::onSkipRecompute(bool on) { // if a document item is selected then touch all objects if (this->contextItem && this->contextItem->type() == DocumentType) { - DocumentItem* docitem = static_cast(this->contextItem); + auto docitem = static_cast(this->contextItem); App::Document* doc = docitem->document()->getDocument(); doc->setStatus(App::Document::SkipRecompute, on); } @@ -1127,7 +1127,7 @@ void TreeWidget::onAllowPartialRecompute(bool on) { // if a document item is selected then touch all objects if (this->contextItem && this->contextItem->type() == DocumentType) { - DocumentItem* docitem = static_cast(this->contextItem); + auto docitem = static_cast(this->contextItem); App::Document* doc = docitem->document()->getDocument(); doc->setStatus(App::Document::AllowPartialRecompute, on); } @@ -1137,10 +1137,10 @@ void TreeWidget::onMarkRecompute() { // if a document item is selected then touch all objects if (this->contextItem && this->contextItem->type() == DocumentType) { - DocumentItem* docitem = static_cast(this->contextItem); + auto docitem = static_cast(this->contextItem); App::Document* doc = docitem->document()->getDocument(); std::vector obj = doc->getObjects(); - for (std::vector::iterator it = obj.begin(); it != obj.end(); ++it) + for (auto it = obj.begin(); it != obj.end(); ++it) (*it)->enforceRecompute(); } // mark all selected objects @@ -1148,7 +1148,7 @@ void TreeWidget::onMarkRecompute() QList items = this->selectedItems(); for (QList::iterator it = items.begin(); it != items.end(); ++it) { if ((*it)->type() == ObjectType) { - DocumentObjectItem* objitem = static_cast(*it); + auto objitem = static_cast(*it); App::DocumentObject* obj = objitem->object()->getObject(); obj->enforceRecompute(); } @@ -1161,7 +1161,7 @@ void TreeWidget::onRecomputeObject() { const auto items = selectedItems(); for (auto ti : items) { if (ti->type() == ObjectType) { - DocumentObjectItem* objitem = static_cast(ti); + auto objitem = static_cast(ti); objs.push_back(objitem->object()->getObject()); objs.back()->enforceRecompute(); } @@ -1324,11 +1324,11 @@ bool TreeWidget::eventFilter(QObject*, QEvent* ev) { switch (ev->type()) { case QEvent::KeyPress: case QEvent::KeyRelease: { - QKeyEvent* ke = static_cast(ev); + auto ke = static_cast(ev); if (ke->key() != Qt::Key_Escape) { // Qt 5 only recheck key modifier on mouse move, so generate a fake // event to trigger drag cursor change - QMouseEvent* mouseEvent = new QMouseEvent(QEvent::MouseMove, + auto mouseEvent = new QMouseEvent(QEvent::MouseMove, mapFromGlobal(QCursor::pos()), QCursor::pos(), Qt::NoButton, QApplication::mouseButtons(), QApplication::queryKeyboardModifiers()); QApplication::postEvent(this, mouseEvent); @@ -1424,7 +1424,7 @@ void TreeWidget::mouseDoubleClickEvent(QMouseEvent* event) doc->setActiveView(nullptr, View3DInventor::getClassTypeId()); } else if (item->type() == TreeWidget::ObjectType) { - DocumentObjectItem* objitem = static_cast(item); + auto objitem = static_cast(item); ViewProviderDocumentObject* vp = objitem->object(); objitem->getOwnerDocument()->document()->setActiveView(vp); @@ -1543,7 +1543,7 @@ void TreeWidget::dragMoveEvent(QDragMoveEvent* event) else if (targetItem->type() == TreeWidget::ObjectType) { onItemEntered(targetItem); - DocumentObjectItem* targetItemObj = static_cast(targetItem); + auto targetItemObj = static_cast(targetItem); Gui::ViewProviderDocumentObject* vp = targetItemObj->object(); try { @@ -1715,7 +1715,7 @@ void TreeWidget::dropEvent(QDropEvent* event) if (targetItem->type() == TreeWidget::ObjectType) { // add object to group - DocumentObjectItem* targetItemObj = static_cast(targetItem); + auto targetItemObj = static_cast(targetItem); thisDoc = targetItemObj->getOwnerDocument()->document()->getDocument(); Gui::ViewProviderDocumentObject* vp = targetItemObj->object(); @@ -2292,7 +2292,7 @@ void TreeWidget::slotNewDocument(const Gui::Document& Doc, bool isMainDoc) { if (Doc.getDocument()->testStatus(App::Document::TempDoc)) return; - DocumentItem* item = new DocumentItem(&Doc, this->rootItem); + auto item = new DocumentItem(&Doc, this->rootItem); if (isMainDoc) this->expandItem(item); item->setIcon(0, *documentPixmap); @@ -2314,7 +2314,7 @@ void TreeWidget::slotFinishOpenDocument() { void TreeWidget::onReloadDoc() { if (!this->contextItem || this->contextItem->type() != DocumentType) return; - DocumentItem* docitem = static_cast(this->contextItem); + auto docitem = static_cast(this->contextItem); App::Document* doc = docitem->document()->getDocument(); std::string name = doc->FileName.getValue(); Application::Instance->reopen(doc); @@ -2332,7 +2332,7 @@ void TreeWidget::onCloseDoc() if (!this->contextItem || this->contextItem->type() != DocumentType) return; try { - DocumentItem* docitem = static_cast(this->contextItem); + auto docitem = static_cast(this->contextItem); Gui::Document* gui = docitem->document(); App::Document* doc = gui->getDocument(); if (gui->canClose(true, true)) @@ -2627,7 +2627,7 @@ void TreeWidget::onItemEntered(QTreeWidgetItem* item) { // object item selected if (item && item->type() == TreeWidget::ObjectType) { - DocumentObjectItem* objItem = static_cast(item); + auto objItem = static_cast(item); objItem->displayStatusInfo(); if (TreeParams::Instance()->PreSelection()) { @@ -2664,7 +2664,7 @@ void TreeWidget::onPreSelectTimer() { return; preselectTime.restart(); - DocumentObjectItem* objItem = static_cast(item); + auto objItem = static_cast(item); auto vp = objItem->object(); auto obj = vp->getObject(); std::ostringstream ss; @@ -2690,7 +2690,7 @@ void TreeWidget::onItemExpanded(QTreeWidgetItem* item) { // object item expanded if (item && item->type() == TreeWidget::ObjectType) { - DocumentObjectItem* objItem = static_cast(item); + auto objItem = static_cast(item); objItem->setExpandedStatus(true); objItem->getOwnerDocument()->populateItem(objItem, false, false); } @@ -3026,7 +3026,7 @@ TreePanel::TreePanel(const char* name, QWidget* parent) if (indent) this->treeWidget->setIndentation(indent); - QVBoxLayout* pLayout = new QVBoxLayout(this); + auto pLayout = new QVBoxLayout(this); pLayout->setSpacing(0); pLayout->setMargin(0); pLayout->addWidget(this->treeWidget); @@ -3114,7 +3114,7 @@ TreeDockWidget::TreeDockWidget(Gui::Document* pcDocument, QWidget* parent) { setWindowTitle(tr("Tree view")); auto panel = new TreePanel("TreeView", this); - QGridLayout* pLayout = new QGridLayout(this); + auto pLayout = new QGridLayout(this); pLayout->setSpacing(0); pLayout->setMargin(0); pLayout->addWidget(panel, 0, 0); @@ -3317,7 +3317,7 @@ bool DocumentItem::createNewItem(const Gui::ViewProviderDocumentObject& obj, data = pdata; } - DocumentObjectItem* item = new DocumentObjectItem(this, data); + auto item = new DocumentObjectItem(this, data); if (!parent || parent == this) { parent = this; data->rootItem = item; @@ -3520,7 +3520,7 @@ void DocumentItem::populateItem(DocumentObjectItem* item, bool refresh, bool del if (ci->type() != TreeWidget::ObjectType) continue; - DocumentObjectItem* childItem = static_cast(ci); + auto childItem = static_cast(ci); if (childItem->object()->getObject() != child) continue; @@ -3596,7 +3596,7 @@ void DocumentItem::populateItem(DocumentObjectItem* item, bool refresh, bool del for (++i; item->childCount() > i;) { QTreeWidgetItem* ci = item->child(i); if (ci->type() == TreeWidget::ObjectType) { - DocumentObjectItem* childItem = static_cast(ci); + auto childItem = static_cast(ci); if (childItem->requiredAtRoot()) { item->removeChild(childItem); auto index = findRootIndex(childItem->object()->getObject()); diff --git a/src/Gui/TreeView.cpp b/src/Gui/TreeView.cpp index 4afbc484c5..dd3261b6e1 100644 --- a/src/Gui/TreeView.cpp +++ b/src/Gui/TreeView.cpp @@ -79,7 +79,7 @@ void TreeView::rowsInserted (const QModelIndex & parent, int start, int end) { QTreeView::rowsInserted(parent, start, end); if (parent.isValid()) { - Base::BaseClass* ptr = static_cast(parent.internalPointer()); + auto ptr = static_cast(parent.internalPointer()); // type is defined in DocumentModel.cpp if (ptr->getTypeId() == Base::Type::fromName("Gui::ApplicationIndex")) { for (int i=start; i<=end;i++) { diff --git a/src/Gui/Utilities.cpp b/src/Gui/Utilities.cpp index d9abd84f8d..f87e7e9313 100644 --- a/src/Gui/Utilities.cpp +++ b/src/Gui/Utilities.cpp @@ -59,7 +59,7 @@ Base::Vector3f ViewVolumeProjection::operator()(const Base::Vector3f &pt) const Base::Vector3d ViewVolumeProjection::operator()(const Base::Vector3d &pt) const { - Base::Vector3f ptf = Base::convertTo(pt); + auto ptf = Base::convertTo(pt); ptf = operator()(ptf); return Base::convertTo(ptf); } @@ -73,7 +73,7 @@ Base::Vector3f ViewVolumeProjection::inverse (const Base::Vector3f &pt) const Base::Vector3d ViewVolumeProjection::inverse (const Base::Vector3d &pt) const { - Base::Vector3f ptf = Base::convertTo(pt); + auto ptf = Base::convertTo(pt); ptf = inverse(ptf); return Base::convertTo(ptf); } @@ -99,7 +99,7 @@ void Tessellator::tessCB(void * v0, void * v1, void * v2, void * cbdata) int * vtx1 = (int *)v1; int * vtx2 = (int *)v2; - std::vector* array = (std::vector *)cbdata; + auto array = (std::vector *)cbdata; array->push_back(*vtx0); array->push_back(*vtx1); array->push_back(*vtx2); diff --git a/src/Gui/VectorListEditor.cpp b/src/Gui/VectorListEditor.cpp index 6a27bcaf99..d9d7db87f4 100644 --- a/src/Gui/VectorListEditor.cpp +++ b/src/Gui/VectorListEditor.cpp @@ -175,7 +175,7 @@ VectorTableDelegate::VectorTableDelegate(int decimals, QObject *parent) QWidget *VectorTableDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &/* option */, const QModelIndex & /*index*/) const { - QDoubleSpinBox *editor = new QDoubleSpinBox(parent); + auto editor = new QDoubleSpinBox(parent); editor->setDecimals(decimals); editor->setMinimum(INT_MIN); editor->setMaximum(INT_MAX); @@ -188,14 +188,14 @@ void VectorTableDelegate::setEditorData(QWidget *editor, const QModelIndex &inde { double value = index.model()->data(index, Qt::EditRole).toDouble(); - QDoubleSpinBox *spinBox = static_cast(editor); + auto spinBox = static_cast(editor); spinBox->setValue(value); } void VectorTableDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const { - QDoubleSpinBox *spinBox = static_cast(editor); + auto spinBox = static_cast(editor); spinBox->interpretText(); double value = spinBox->value(); model->setData(index, value, Qt::EditRole); diff --git a/src/Gui/View3DInventor.cpp b/src/Gui/View3DInventor.cpp index 8fc2c42840..2f8c95c256 100644 --- a/src/Gui/View3DInventor.cpp +++ b/src/Gui/View3DInventor.cpp @@ -289,7 +289,7 @@ void View3DInventor::OnChange(ParameterGrp::SubjectType &rCaller,ParameterGrp::M else if (strcmp(Reason,"HighlightColor") == 0) { float transparency; SbColor highlightColor(0.8f, 0.1f, 0.1f); - unsigned long highlight = (unsigned long)(highlightColor.getPackedValue()); + auto highlight = (unsigned long)(highlightColor.getPackedValue()); highlight = rGrp.GetUnsigned("HighlightColor", highlight); highlightColor.setPackedValue((uint32_t)highlight, transparency); SoSFColor col; col.setValue(highlightColor); @@ -299,7 +299,7 @@ void View3DInventor::OnChange(ParameterGrp::SubjectType &rCaller,ParameterGrp::M else if (strcmp(Reason,"SelectionColor") == 0) { float transparency; SbColor selectionColor(0.1f, 0.8f, 0.1f); - unsigned long selection = (unsigned long)(selectionColor.getPackedValue()); + auto selection = (unsigned long)(selectionColor.getPackedValue()); selection = rGrp.GetUnsigned("SelectionColor", selection); selectionColor.setPackedValue((uint32_t)selection, transparency); SoSFColor col; col.setValue(selectionColor); @@ -570,19 +570,19 @@ bool View3DInventor::onMsg(const char* pMsg, const char** ppReturn) return true; } else if(strcmp("Example1",pMsg) == 0 ) { - SoSeparator * root = new SoSeparator; + auto root = new SoSeparator; Texture3D(root); _viewer->setSceneGraph(root); return true; } else if(strcmp("Example2",pMsg) == 0 ) { - SoSeparator * root = new SoSeparator; + auto root = new SoSeparator; LightManip(root); _viewer->setSceneGraph(root); return true; } else if(strcmp("Example3",pMsg) == 0 ) { - SoSeparator * root = new SoSeparator; + auto root = new SoSeparator; AnimationTexture(root); _viewer->setSceneGraph(root); return true; @@ -976,7 +976,7 @@ void View3DInventor::setCurrentViewMode(ViewMode newmode) this->removeAction(*it); // Step two - QMdiSubWindow* mdi = qobject_cast(parentWidget()); + auto mdi = qobject_cast(parentWidget()); if (mdi && mdi->layout()) mdi->layout()->invalidate(); } @@ -990,7 +990,7 @@ bool View3DInventor::eventFilter(QObject* watched, QEvent* e) // Note: We don't need to care about removing an action if its parent widget gets destroyed. // This does the action itself for us. if (watched != this && e->type() == QEvent::ActionAdded) { - QActionEvent* a = static_cast(e); + auto a = static_cast(e); QAction* action = a->action(); if (!action->isSeparator()) { @@ -1032,7 +1032,7 @@ void View3DInventor::contextMenuEvent (QContextMenuEvent*e) void View3DInventor::customEvent(QEvent * e) { if (e->type() == QEvent::User) { - NavigationStyleEvent* se = static_cast(e); + auto se = static_cast(e); ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath ("User parameter:BaseApp/Preferences/View"); if (hGrp->GetBool("SameStyleForAllViews", true)) diff --git a/src/Gui/View3DInventorExamples.cpp b/src/Gui/View3DInventorExamples.cpp index df8b4904a7..10c7f28f8c 100644 --- a/src/Gui/View3DInventorExamples.cpp +++ b/src/Gui/View3DInventorExamples.cpp @@ -52,7 +52,7 @@ unsigned char * generateTexture(int w, int h, int d) int val; float x,y,z; // unsigned char pixval; - unsigned char * bitmap = new unsigned char[w*h*d]; + auto bitmap = new unsigned char[w*h*d]; for (int k = 0;ktranslation.getValue(), drag->rotation.getValue()); } @@ -202,11 +202,11 @@ void Texture3D(SoSeparator * root) // SoSeparator * root = new SoSeparator; // root->ref(); - SoComplexity * comp = new SoComplexity; + auto comp = new SoComplexity; comp->textureQuality.setValue((float)0.9); root->addChild(comp); - SoTexture3 * texture = new SoTexture3; + auto texture = new SoTexture3; texture->wrapR.setValue(SoTexture3::CLAMP); texture->wrapS.setValue(SoTexture3::CLAMP); texture->wrapT.setValue(SoTexture3::CLAMP); @@ -218,37 +218,37 @@ void Texture3D(SoSeparator * root) texture->images.setValue(SbVec3s(256,256,256), 1, img); root->addChild(texture); - SoMaterial * mat = new SoMaterial; + auto mat = new SoMaterial; mat->emissiveColor.setValue(1,1,1); root->addChild(mat); - SoTransformerDragger * dragger = new SoTransformerDragger; + auto dragger = new SoTransformerDragger; dragger->scaleFactor.setValue(5,5,5); dragger->addValueChangedCallback(draggerCB, nullptr); root->addChild(dragger); - SoCoordinate3 * clippedCoords = new SoCoordinate3; + auto clippedCoords = new SoCoordinate3; clippedCoords->point.connectFrom((SoMFVec3f *) SoDB::getGlobalField("globalVerts")); root->addChild(clippedCoords); - SoTextureCoordinate3 * clippedTCoords = new SoTextureCoordinate3; + auto clippedTCoords = new SoTextureCoordinate3; clippedTCoords->point.connectFrom((SoMFVec3f *) SoDB::getGlobalField("globalTVerts")); root->addChild(clippedTCoords); - SoFaceSet * clippedFS = new SoFaceSet; + auto clippedFS = new SoFaceSet; clippedFS->numVertices.connectFrom((SoMFInt32 *) SoDB::getGlobalField("globalnv")); root->addChild(clippedFS); - SoCoordinate3 * planeCoords = new SoCoordinate3; + auto planeCoords = new SoCoordinate3; planeCoords->point.connectFrom((SoMFVec3f *) SoDB::getGlobalField("planeVerts")); root->addChild(planeCoords); - SoTextureCoordinate3 * planeTCoords = new SoTextureCoordinate3; + auto planeTCoords = new SoTextureCoordinate3; planeTCoords->point.connectFrom((SoMFVec3f *) SoDB::getGlobalField("planeTVerts")); root->addChild(planeTCoords); - SoFaceSet * planeFS = new SoFaceSet; + auto planeFS = new SoFaceSet; root->addChild(planeFS); } @@ -293,7 +293,7 @@ void LightManip(SoSeparator * root) if (!path) // Shouldn't happen. return; - SoPointLightManip * manip = new SoPointLightManip; + auto manip = new SoPointLightManip; manip->replaceNode( path ); } @@ -356,7 +356,7 @@ julia(double crr, double cii, float zoom, int width, int height, int mult, SoTexture2 * texture() { - SoTexture2 * texture = new SoTexture2; + auto texture = new SoTexture2; texture->image.setValue(SbVec2s(texturewidth, textureheight), 1, bitmap); texture->model = SoTexture2::MODULATE; texture->blendColor.setValue(1.0, 0.0, 0.0); @@ -369,7 +369,7 @@ timersensorcallback(void * data, SoSensor *) { static SbBool direction = false; - SoTexture2 * texnode = (SoTexture2*) data; + auto texnode = (SoTexture2*) data; if (!direction) { global_cr -= 0.0005; @@ -406,13 +406,13 @@ void AnimationTexture(SoSeparator * root) SoTexture2 * texnode = texture(); // Enable backface culling - SoShapeHints * hints = new SoShapeHints; + auto hints = new SoShapeHints; hints->vertexOrdering = SoShapeHints::COUNTERCLOCKWISE; hints->shapeType = SoShapeHints::SOLID; // Timer sensor - SoTimerSensor * texturetimer = new SoTimerSensor(timersensorcallback, texnode); + auto texturetimer = new SoTimerSensor(timersensorcallback, texnode); texturetimer->setInterval(0.05); texturetimer->schedule(); diff --git a/src/Gui/View3DInventorViewer.cpp b/src/Gui/View3DInventorViewer.cpp index 18bdeb2f25..441f13eb0c 100644 --- a/src/Gui/View3DInventorViewer.cpp +++ b/src/Gui/View3DInventorViewer.cpp @@ -207,12 +207,12 @@ public: // lead to some unwanted zooming when pressing the MMB for panning. // Thus, we filter out horizontal scrolling. if (event->type() == QEvent::Wheel) { - QWheelEvent* we = static_cast(event); + auto we = static_cast(event); if (qAbs(we->angleDelta().x()) > qAbs(we->angleDelta().y())) return true; } else if (event->type() == QEvent::KeyPress) { - QKeyEvent* ke = static_cast(event); + auto ke = static_cast(event); if (ke->matches(QKeySequence::SelectAll)) { static_cast(obj)->selectAll(); return true; @@ -222,14 +222,14 @@ public: return false; if (event->type() == Spaceball::ButtonEvent::ButtonEventType) { - Spaceball::ButtonEvent* buttonEvent = static_cast(event); + auto buttonEvent = static_cast(event); if (!buttonEvent) { Base::Console().Log("invalid spaceball button event\n"); return true; } } else if (event->type() == Spaceball::MotionEvent::MotionEventType) { - Spaceball::MotionEvent* motionEvent = static_cast(event); + auto motionEvent = static_cast(event); if (!motionEvent) { Base::Console().Log("invalid spaceball motion event\n"); return true; @@ -247,7 +247,7 @@ public: const SoEvent* translateEvent(QEvent* event) override { if (event->type() == Spaceball::MotionEvent::MotionEventType) { - Spaceball::MotionEvent* motionEvent = static_cast(event); + auto motionEvent = static_cast(event); if (!motionEvent) { Base::Console().Log("invalid spaceball motion event\n"); return nullptr; @@ -267,7 +267,7 @@ public: yRot.setValue(SbVec3f(0.0, 1.0, 0.0), static_cast(motionEvent->rotationY()) * rotationConstant); zRot.setValue(SbVec3f(0.0, 0.0, 1.0), static_cast(motionEvent->rotationZ()) * rotationConstant); - SoMotion3Event* motion3Event = new SoMotion3Event; + auto motion3Event = new SoMotion3Event; motion3Event->setTranslation(translationVector); motion3Event->setRotation(xRot * yRot * zRot); motion3Event->setPosition(this->mousepos); @@ -350,7 +350,7 @@ void View3DInventorViewer::init() // setting up the defaults for the spin rotation initialize(); - SoOrthographicCamera* cam = new SoOrthographicCamera; + auto cam = new SoOrthographicCamera; cam->position = SbVec3f(0, 0, 1); cam->height = 1; cam->nearDistance = 0.5; @@ -377,10 +377,10 @@ void View3DInventorViewer::init() this->foregroundroot = new SoSeparator; this->foregroundroot->ref(); - SoLightModel* lm = new SoLightModel; + auto lm = new SoLightModel; lm->model = SoLightModel::BASE_COLOR; - SoBaseColor* bc = new SoBaseColor; + auto bc = new SoBaseColor; bc->rgb = SbColor(1, 1, 0); cam = new SoOrthographicCamera; @@ -625,7 +625,7 @@ void View3DInventorViewer::createStandardCursors(double dpr) void View3DInventorViewer::aboutToDestroyGLContext() { if (naviCube) { - QtGLWidget* gl = qobject_cast(this->viewport()); + auto gl = qobject_cast(this->viewport()); if (gl) gl->makeCurrent(); delete naviCube; @@ -1081,13 +1081,13 @@ SoPickedPoint* View3DInventorViewer::getPointOnRay(const SbVec2s& pos, const Vie SoGetMatrixAction gm(getSoRenderManager()->getViewportRegion()); gm.apply(path); - SoTransform* trans = new SoTransform; + auto trans = new SoTransform; trans->setMatrix(gm.getMatrix()); trans->ref(); // build a temporary scenegraph only keeping this viewproviders nodes and the accumulated // transformation - SoSeparator* root = new SoSeparator; + auto root = new SoSeparator; root->ref(); root->addChild(getSoRenderManager()->getCamera()); root->addChild(trans); @@ -1133,11 +1133,11 @@ SoPickedPoint* View3DInventorViewer::getPointOnRay(const SbVec3f& pos, const SbV // build a temporary scenegraph only keeping this viewproviders nodes and the accumulated // transformation - SoTransform* trans = new SoTransform; + auto trans = new SoTransform; trans->ref(); trans->setMatrix(gm.getMatrix()); - SoSeparator* root = new SoSeparator; + auto root = new SoSeparator; root->ref(); root->addChild(getSoRenderManager()->getCamera()); root->addChild(trans); @@ -1269,14 +1269,14 @@ void View3DInventorViewer::setGLWidgetCB(void* userdata, SoAction* action) // Coin error in SoNode::GLRenderS(): GL error: 'GL_STACK_UNDERFLOW', nodetype: // Separator (set envvar COIN_GLERROR_DEBUGGING=1 and re-run to get more information) if (action->isOfType(SoGLRenderAction::getClassTypeId())) { - QWidget* gl = static_cast(userdata); + auto gl = static_cast(userdata); SoGLWidgetElement::set(action->getState(), qobject_cast(gl)); } } void View3DInventorViewer::handleEventCB(void* ud, SoEventCallback* n) { - View3DInventorViewer* that = static_cast(ud); + auto that = static_cast(ud); SoGLRenderAction* glra = that->getSoRenderManager()->getGLRenderAction(); SoAction* action = n->getAction(); SoGLRenderActionElement::set(action->getState(), glra); @@ -1392,12 +1392,12 @@ NaviCube* View3DInventorViewer::getNavigationCube() const void View3DInventorViewer::setAxisCross(bool on) { SoNode* scene = getSceneGraph(); - SoSeparator* sep = static_cast(scene); + auto sep = static_cast(scene); if (on) { if (!axisGroup) { axisCross = new Gui::SoShapeScale; - Gui::SoAxisCrossKit* axisKit = new Gui::SoAxisCrossKit(); + auto axisKit = new Gui::SoAxisCrossKit(); axisKit->set("xAxis.appearance.drawStyle", "lineWidth 2"); axisKit->set("yAxis.appearance.drawStyle", "lineWidth 2"); axisKit->set("zAxis.appearance.drawStyle", "lineWidth 2"); @@ -1428,7 +1428,7 @@ void View3DInventorViewer::setNavigationType(Base::Type t) return; // nothing to do Base::Type type = Base::Type::getTypeIfDerivedFrom(t.getName(), NavigationStyle::getClassTypeId()); - NavigationStyle* ns = static_cast(type.createInstance()); + auto ns = static_cast(type.createInstance()); // createInstance could return a null pointer if (!ns) { #if FC_DEBUG @@ -1510,12 +1510,12 @@ void View3DInventorViewer::savePicture(int w, int h, int s, const QColor& bg, QI } if (useFramebufferObject) { - View3DInventorViewer* self = const_cast(this); + auto self = const_cast(this); self->imageFromFramebuffer(w, h, s, bg, img); return; } else if (useGrabFramebuffer) { - View3DInventorViewer* self = const_cast(this); + auto self = const_cast(this); img = self->grabFramebuffer(); img = img.mirrored(); img = img.scaledToWidth(w); @@ -1552,7 +1552,7 @@ void View3DInventorViewer::savePicture(int w, int h, int s, const QColor& bg, QI bgColor = bg; } - SoSeparator* root = new SoSeparator; + auto root = new SoSeparator; root->ref(); #if (COIN_MAJOR_VERSION >= 4) @@ -1560,7 +1560,7 @@ void View3DInventorViewer::savePicture(int w, int h, int s, const QColor& bg, QI // multiple times internally the biggest viewport size is stored and set to the SoGLRenderAction. // The trick is to add a callback node and override the viewport size with what we want. if (useCoinOffscreenRenderer) { - SoCallback* cbvp = new SoCallback; + auto cbvp = new SoCallback; cbvp->setCallback(setViewportCB); root->addChild(cbvp); } @@ -1574,14 +1574,14 @@ void View3DInventorViewer::savePicture(int w, int h, int s, const QColor& bg, QI } if (!this->shading) { - SoLightModel* lm = new SoLightModel; + auto lm = new SoLightModel; lm->model = SoLightModel::BASE_COLOR; root->addChild(lm); } root->addChild(getHeadlight()); root->addChild(camera); - SoCallback* gl = new SoCallback; + auto gl = new SoCallback; gl->setCallback(setGLWidgetCB, this->getGLWidget()); root->addChild(gl); root->addChild(pcViewProviderRoot); @@ -1776,8 +1776,8 @@ std::vector View3DInventorViewer::getGLPolygon(const std::vector poly; - for (std::vector::const_iterator it = pnts.begin(); it != pnts.end(); ++it) { - SbVec2s loc = *it - op; + for (const auto & pnt : pnts) { + SbVec2s loc = pnt - op; SbVec2f pos((float)loc[0] / (float)sp[0], (float)loc[1] / (float)sp[1]); float pX, pY; pos.getValue(pX, pY); @@ -1985,12 +1985,12 @@ void View3DInventorViewer::setRenderType(const RenderType type) int width = size[0]; int height = size[1]; - QtGLWidget* gl = static_cast(this->viewport()); + auto gl = static_cast(this->viewport()); gl->makeCurrent(); QOpenGLFramebufferObjectFormat fboFormat; fboFormat.setSamples(getNumSamples()); fboFormat.setAttachment(QtGLFramebufferObject::Depth); - QtGLFramebufferObject* fbo = new QtGLFramebufferObject(width, height, fboFormat); + auto fbo = new QtGLFramebufferObject(width, height, fboFormat); if (fbo->format().samples() > 0) { renderToFramebuffer(fbo); framebuffer = new QtGLFramebufferObject(fbo->size()); @@ -2019,7 +2019,7 @@ View3DInventorViewer::RenderType View3DInventorViewer::getRenderType() const QImage View3DInventorViewer::grabFramebuffer() { - QtGLWidget* gl = static_cast(this->viewport()); + auto gl = static_cast(this->viewport()); gl->makeCurrent(); QImage res; @@ -2061,7 +2061,7 @@ QImage View3DInventorViewer::grabFramebuffer() void View3DInventorViewer::imageFromFramebuffer(int width, int height, int samples, const QColor& bgcolor, QImage& img) { - QtGLWidget* gl = static_cast(this->viewport()); + auto gl = static_cast(this->viewport()); gl->makeCurrent(); const QtGLContext* context = QtGLContext::currentContext(); @@ -2423,7 +2423,7 @@ void View3DInventorViewer::selectAll() for (std::set::iterator it = _ViewProviderSet.begin(); it != _ViewProviderSet.end(); ++it) { if ((*it)->getTypeId().isDerivedFrom(ViewProviderDocumentObject::getClassTypeId())) { - ViewProviderDocumentObject* vp = static_cast(*it); + auto vp = static_cast(*it); App::DocumentObject* obj = vp->getObject(); if (obj) objs.push_back(obj); @@ -2449,7 +2449,7 @@ bool View3DInventorViewer::processSoEvent(const SoEvent* ev) if (ev->getTypeId().isDerivedFrom(SoKeyboardEvent::getClassTypeId())) { // filter out 'Q' and 'ESC' keys - const SoKeyboardEvent* const ke = static_cast(ev); + const auto ke = static_cast(ev); switch (ke->getKey()) { case SoKeyboardEvent::ESCAPE: @@ -2571,8 +2571,8 @@ SbVec2s View3DInventorViewer::getPointOnScreen(const SbVec3f& pnt) const SbVec3f pt(pnt); vv.projectToScreen(pt, pt); - short x = short(std::roundf(pt[0] * sp[0])); - short y = short(std::roundf(pt[1] * sp[1])); + auto x = short(std::roundf(pt[0] * sp[0])); + auto y = short(std::roundf(pt[1] * sp[1])); return SbVec2s(x, y); } @@ -2671,7 +2671,7 @@ void View3DInventorViewer::toggleClippingPlane(int toggle, bool beforeEditing, Base::Vector3d base = pla.getPosition(); if(!noManip) { - SoClipPlaneManip* clip = new SoClipPlaneManip; + auto clip = new SoClipPlaneManip; pcClipPlane = clip; SbBox3f box = getBoundingBox(); @@ -2954,7 +2954,7 @@ void View3DInventorViewer::viewAll() for (int i = 0; i < pathlist.getLength(); i++) { SoPath* path = pathlist[i]; - SoSkipBoundingGroup* group = static_cast(path->getTail()); + auto group = static_cast(path->getTail()); group->mode = SoSkipBoundingGroup::EXCLUDE_BBOX; } @@ -2973,7 +2973,7 @@ void View3DInventorViewer::viewAll() for (int i = 0; i < pathlist.getLength(); i++) { SoPath* path = pathlist[i]; - SoSkipBoundingGroup* group = static_cast(path->getTail()); + auto group = static_cast(path->getTail()); group->mode = SoSkipBoundingGroup::INCLUDE_BBOX; } } @@ -2997,7 +2997,7 @@ void View3DInventorViewer::viewAll(float factor) for (int i = 0; i < pathlist.getLength(); i++) { SoPath* path = pathlist[i]; - SoSkipBoundingGroup* group = static_cast(path->getTail()); + auto group = static_cast(path->getTail()); group->mode = SoSkipBoundingGroup::EXCLUDE_BBOX; } @@ -3007,19 +3007,19 @@ void View3DInventorViewer::viewAll(float factor) for (int i = 0; i < pathlist.getLength(); i++) { SoPath* path = pathlist[i]; - SoSkipBoundingGroup* group = static_cast(path->getTail()); + auto group = static_cast(path->getTail()); group->mode = SoSkipBoundingGroup::INCLUDE_BBOX; } - SoCube* cube = new SoCube(); + auto cube = new SoCube(); cube->width = factor*(maxx-minx); cube->height = factor*(maxy-miny); cube->depth = factor*(maxz-minz); // fake a scenegraph with the desired bounding size - SoSeparator* graph = new SoSeparator(); + auto graph = new SoSeparator(); graph->ref(); - SoTranslation* tr = new SoTranslation(); + auto tr = new SoTranslation(); tr->translation.setValue(box.getCenter()); graph->addChild(tr); @@ -3325,16 +3325,16 @@ void View3DInventorViewer::drawAxisCross() assert((val[0] >= val[1]) && (val[1] >= val[2])); // Just checking.. - for (int i=0; i < 3; i++) { + for (const int & i : idx) { glPushMatrix(); - if (idx[i] == XAXIS) { // X axis. + if (i == XAXIS) { // X axis. if (stereoMode() != Quarter::SoQTQuarterAdaptor::MONO) glColor3f(0.500f, 0.5f, 0.5f); else glColor3f(0.500f, 0.125f, 0.125f); } - else if (idx[i] == YAXIS) { // Y axis. + else if (i == YAXIS) { // Y axis. glRotatef(90, 0, 0, 1); if (stereoMode() != Quarter::SoQTQuarterAdaptor::MONO) diff --git a/src/Gui/View3DPy.cpp b/src/Gui/View3DPy.cpp index d5fe267162..2827814e2a 100644 --- a/src/Gui/View3DPy.cpp +++ b/src/Gui/View3DPy.cpp @@ -314,7 +314,7 @@ Py::Object View3DInventorPy::getattr(const char * attr) // else looking for a method with the name and call it Py::Object obj = getattribute(attr); if (PyCFunction_Check(obj.ptr())) { - PyCFunctionObject* op = reinterpret_cast(obj.ptr()); + auto op = reinterpret_cast(obj.ptr()); if (op->m_ml->ml_flags == METH_VARARGS) { if (!pycxx_handler) pycxx_handler = op->m_ml->ml_meth; @@ -445,11 +445,11 @@ SbRotation Camera::rotation(Camera::Orientation view) case Bottom: return SbRotation(1, 0, 0, 0); case Front: { - float root = (float)(sqrt(2.0)/2.0); + auto root = (float)(sqrt(2.0)/2.0); return SbRotation(root, 0, 0, root); } case Rear: { - float root = (float)(sqrt(2.0)/2.0); + auto root = (float)(sqrt(2.0)/2.0); return SbRotation(0, root, root, 0); } case Left: @@ -722,10 +722,10 @@ Py::Object View3DInventorPy::viewDefaultOrientation(const Py::Tuple& args) } else if (newDocView == "Custom") { ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/View/Custom"); - float q0 = static_cast(hGrp->GetFloat("Q0", 0)); - float q1 = static_cast(hGrp->GetFloat("Q1", 0)); - float q2 = static_cast(hGrp->GetFloat("Q2", 0)); - float q3 = static_cast(hGrp->GetFloat("Q3", 1)); + auto q0 = static_cast(hGrp->GetFloat("Q0", 0)); + auto q1 = static_cast(hGrp->GetFloat("Q1", 0)); + auto q2 = static_cast(hGrp->GetFloat("Q2", 0)); + auto q3 = static_cast(hGrp->GetFloat("Q3", 1)); rot.setValue(q0, q1, q2, q3); } @@ -1324,7 +1324,7 @@ Py::Object View3DInventorPy::dumpNode(const Py::Tuple& args) catch (const Base::Exception& e) { throw Py::RuntimeError(e.what()); } - SoNode* node = static_cast(ptr); + auto node = static_cast(ptr); return Py::String(SoFCDB::writeNodesToString(node)); } @@ -1475,7 +1475,7 @@ Py::Object View3DInventorPy::getObjectInfo(const Py::Tuple& args) if (vp && vp->isDerivedFrom(ViewProviderDocumentObject::getClassTypeId())) { if (!vp->isSelectable()) return ret; - ViewProviderDocumentObject* vpd = static_cast(vp); + auto vpd = static_cast(vp); if (vp->useNewSelectionModel()) { std::string subname; if (!vp->getElementPicked(Point,subname)) @@ -1576,7 +1576,7 @@ Py::Object View3DInventorPy::getObjectsInfo(const Py::Tuple& args) Py::List list; for (int i=0; i(pp.get(i)); + auto point = static_cast(pp.get(i)); SbVec3f pt = point->getPoint(); dict.setItem("x", Py::Float(pt[0])); dict.setItem("y", Py::Float(pt[1])); @@ -1587,7 +1587,7 @@ Py::Object View3DInventorPy::getObjectsInfo(const Py::Tuple& args) if(vp && vp->isDerivedFrom(ViewProviderDocumentObject::getClassTypeId())) { if(!vp->isSelectable()) continue; - ViewProviderDocumentObject* vpd = static_cast(vp); + auto vpd = static_cast(vp); if (vp->useNewSelectionModel()) { std::string subname; if (!vp->getElementPicked(point,subname)) @@ -1756,7 +1756,7 @@ Py::Object View3DInventorPy::listNavigationTypes(const Py::Tuple&) std::vector types; Py::List styles; Base::Type::getAllDerivedFrom(UserNavigationStyle::getClassTypeId(), types); - for (std::vector::iterator it = types.begin()+1; it != types.end(); ++it) { + for (auto it = types.begin() + 1; it != types.end(); ++it) { styles.append(Py::String(it->getName())); } return styles; @@ -1802,7 +1802,7 @@ void View3DInventorPy::eventCallback(void * ud, SoEventCallback * n) dict.setItem("AltDown", Py::Object((e->wasAltDown() ? Py_True : Py_False))); if (e->isOfType(SoButtonEvent::getClassTypeId())) { std::string state; - const SoButtonEvent* be = static_cast(e); + const auto be = static_cast(e); switch (be->getState()) { case SoButtonEvent::UP: state = "UP"; @@ -1818,7 +1818,7 @@ void View3DInventorPy::eventCallback(void * ud, SoEventCallback * n) dict.setItem("State", Py::String(state)); } if (e->isOfType(SoKeyboardEvent::getClassTypeId())) { - const SoKeyboardEvent* ke = static_cast(e); + const auto ke = static_cast(e); switch (ke->getKey()) { case SoKeyboardEvent::ANY: dict.setItem("Key", Py::String("ANY")); @@ -2039,7 +2039,7 @@ void View3DInventorPy::eventCallback(void * ud, SoEventCallback * n) } } if (e->isOfType(SoMouseButtonEvent::getClassTypeId())) { - const SoMouseButtonEvent* mbe = static_cast(e); + const auto mbe = static_cast(e); std::string button; switch (mbe->getButton()) { case SoMouseButtonEvent::BUTTON1: @@ -2065,11 +2065,11 @@ void View3DInventorPy::eventCallback(void * ud, SoEventCallback * n) dict.setItem("Button", Py::String(button)); } if (e->isOfType(SoMouseWheelEvent::getClassTypeId())){ - const SoMouseWheelEvent* mwe = static_cast(e); + const auto mwe = static_cast(e); dict.setItem("Delta", Py::Long(mwe->getDelta())); } if (e->isOfType(SoSpaceballButtonEvent::getClassTypeId())) { - const SoSpaceballButtonEvent* sbe = static_cast(e); + const auto sbe = static_cast(e); std::string button; switch (sbe->getButton()) { case SoSpaceballButtonEvent::BUTTON1: @@ -2101,7 +2101,7 @@ void View3DInventorPy::eventCallback(void * ud, SoEventCallback * n) dict.setItem("Button", Py::String(button)); } if (e->isOfType(SoMotion3Event::getClassTypeId())) { - const SoMotion3Event* me = static_cast(e); + const auto me = static_cast(e); const SbVec3f& m = me->getTranslation(); const SbRotation& r = me->getRotation(); Py::Tuple mov(3); @@ -2342,7 +2342,7 @@ Py::Object View3DInventorPy::addEventCallbackPivy(const Py::Tuple& args) throw Py::RuntimeError(e.what()); } - SoType* eventId = static_cast(ptr); + auto eventId = static_cast(ptr); if (eventId->isBad() || !eventId->isDerivedFrom(SoEvent::getClassTypeId())) { std::string s; std::ostringstream s_out; @@ -2384,7 +2384,7 @@ Py::Object View3DInventorPy::removeEventCallbackPivy(const Py::Tuple& args) throw Py::RuntimeError(e.what()); } - SoType* eventId = static_cast(ptr); + auto eventId = static_cast(ptr); if (eventId->isBad() || !eventId->isDerivedFrom(SoEvent::getClassTypeId())) { std::string s; std::ostringstream s_out; @@ -2475,7 +2475,7 @@ Py::Object View3DInventorPy::addDraggerCallback(const Py::Tuple& args) catch (const Base::Exception&) { throw Py::TypeError("The first argument must be of type SoDragger"); } - SoDragger* drag = static_cast(ptr); + auto drag = static_cast(ptr); //Check if method is callable if (PyCallable_Check(method) == 0) { @@ -2528,7 +2528,7 @@ Py::Object View3DInventorPy::removeDraggerCallback(const Py::Tuple& args) throw Py::TypeError("The first argument must be of type SoDragger"); } - SoDragger* drag = static_cast(ptr); + auto drag = static_cast(ptr); try { if (strcmp(type, "addFinishCallback") == 0) { drag->removeFinishCallback(draggerCallback, method); @@ -2609,8 +2609,8 @@ Py::Object View3DInventorPy::getViewProvidersOfType(const Py::Tuple& args) std::vector vps = getView3DIventorPtr()->getViewer()->getViewProvidersOfType(Base::Type::fromName(name)); Py::List list; - for (std::vector::iterator it = vps.begin(); it != vps.end(); ++it) { - list.append(Py::asObject((*it)->getPyObject())); + for (const auto & vp : vps) { + list.append(Py::asObject(vp->getPyObject())); } return list; diff --git a/src/Gui/View3DViewerPy.cpp b/src/Gui/View3DViewerPy.cpp index afe5287547..d16a1208c7 100644 --- a/src/Gui/View3DViewerPy.cpp +++ b/src/Gui/View3DViewerPy.cpp @@ -149,7 +149,7 @@ Py::Object View3DInventorViewerPy::getattr(const char * attr) else { Py::Object obj = Py::PythonExtension::getattr(attr); if (PyCFunction_Check(obj.ptr())) { - PyCFunctionObject* op = reinterpret_cast(obj.ptr()); + auto op = reinterpret_cast(obj.ptr()); if (!pycxx_handler) pycxx_handler = op->m_ml->ml_meth; op->m_ml->ml_meth = method_varargs_ext_handler; @@ -213,7 +213,7 @@ Py::Object View3DInventorViewerPy::setSceneGraph(const Py::Tuple& args) void* ptr = nullptr; try { Base::Interpreter().convertSWIGPointerObj("pivy.coin", "SoNode *", proxy, &ptr, 0); - SoNode* node = static_cast(ptr); + auto node = static_cast(ptr); _viewer->setSceneGraph(node); return Py::None(); } diff --git a/src/Gui/ViewProvider.cpp b/src/Gui/ViewProvider.cpp index fd78b5f799..873f67e27e 100644 --- a/src/Gui/ViewProvider.cpp +++ b/src/Gui/ViewProvider.cpp @@ -197,14 +197,14 @@ void highlight(const HighlightMode& high) void ViewProvider::eventCallback(void * ud, SoEventCallback * node) { const SoEvent * ev = node->getEvent(); - Gui::View3DInventorViewer* viewer = static_cast(node->getUserData()); - ViewProvider *self = static_cast(ud); + auto viewer = static_cast(node->getUserData()); + auto self = static_cast(ud); assert(self); try { // Keyboard events if (ev->getTypeId().isDerivedFrom(SoKeyboardEvent::getClassTypeId())) { - SoKeyboardEvent * ke = (SoKeyboardEvent *)ev; + auto ke = (SoKeyboardEvent *)ev; const SbBool press = ke->getState() == SoButtonEvent::DOWN ? true : false; switch (ke->getKey()) { case SoKeyboardEvent::ESCAPE: @@ -221,7 +221,7 @@ void ViewProvider::eventCallback(void * ud, SoEventCallback * node) // react only on key release // Let first selection mode terminate Gui::Document* doc = Gui::Application::Instance->activeDocument(); - Gui::View3DInventor* view = static_cast(doc->getActiveView()); + auto view = static_cast(doc->getActiveView()); if (view) { Gui::View3DInventorViewer* viewer = view->getViewer(); @@ -231,7 +231,7 @@ void ViewProvider::eventCallback(void * ud, SoEventCallback * node) } } - Gui::TimerFunction* func = new Gui::TimerFunction(); + auto func = new Gui::TimerFunction(); func->setAutoDelete(true); func->setFunction(std::bind(&Document::resetEdit, doc)); QTimer::singleShot(0, func, SLOT(timeout())); @@ -251,7 +251,7 @@ void ViewProvider::eventCallback(void * ud, SoEventCallback * node) // switching the mouse buttons else if (ev->getTypeId().isDerivedFrom(SoMouseButtonEvent::getClassTypeId())) { - const SoMouseButtonEvent * const event = (const SoMouseButtonEvent *) ev; + const auto event = (const SoMouseButtonEvent *) ev; const int button = event->getButton(); const SbBool press = event->getState() == SoButtonEvent::DOWN ? true : false; @@ -260,7 +260,7 @@ void ViewProvider::eventCallback(void * ud, SoEventCallback * node) node->setHandled(); } else if (ev->getTypeId().isDerivedFrom(SoMouseWheelEvent::getClassTypeId())) { - const SoMouseWheelEvent * const event = (const SoMouseWheelEvent *) ev; + const auto event = (const SoMouseWheelEvent *) ev; if (self->mouseWheelEvent(event->getDelta(), event->getPosition(), viewer)) node->setHandled(); @@ -587,7 +587,7 @@ using Edge = boost::graph_traits::edge_descriptor; void addNodes(Graph& graph, std::map& vertexNodeMap, SoNode* node) { if (node->getTypeId().isDerivedFrom(SoGroup::getClassTypeId())) { - SoGroup* group = static_cast(node); + auto group = static_cast(node); Vertex groupV = vertexNodeMap[group]; for (int i=0; igetNumChildren(); i++) { @@ -953,7 +953,7 @@ int ViewProvider::partialRender(const std::vector &elements, bool c } } int count = 0; - SoFullPath *path = static_cast(new SoPath); + auto path = static_cast(new SoPath); path->ref(); SoSelectionElementAction action; action.setSecondary(true); diff --git a/src/Gui/ViewProviderAnnotation.cpp b/src/Gui/ViewProviderAnnotation.cpp index bf2d3b159e..94dbc9c2da 100644 --- a/src/Gui/ViewProviderAnnotation.cpp +++ b/src/Gui/ViewProviderAnnotation.cpp @@ -186,22 +186,22 @@ void ViewProviderAnnotation::attach(App::DocumentObject* f) { ViewProviderDocumentObject::attach(f); - SoAnnotation* anno = new SoAnnotation(); - SoAnnotation* anno3d = new SoAnnotation(); + auto anno = new SoAnnotation(); + auto anno3d = new SoAnnotation(); - SoFCSelection* textsep = new SoFCSelection(); + auto textsep = new SoFCSelection(); // set selection/highlight colors float transparency; ParameterGrp::handle hGrp = Gui::WindowParameter::getDefaultParameter()->GetGroup("View"); SbColor highlightColor = textsep->colorHighlight.getValue(); - unsigned long highlight = (unsigned long)(highlightColor.getPackedValue()); + auto highlight = (unsigned long)(highlightColor.getPackedValue()); highlight = hGrp->GetUnsigned("HighlightColor", highlight); highlightColor.setPackedValue((uint32_t)highlight, transparency); textsep->colorHighlight.setValue(highlightColor); // Do the same with the selection color SbColor selectionColor = textsep->colorSelection.getValue(); - unsigned long selection = (unsigned long)(selectionColor.getPackedValue()); + auto selection = (unsigned long)(selectionColor.getPackedValue()); selection = hGrp->GetUnsigned("SelectionColor", selection); selectionColor.setPackedValue((uint32_t)selection, transparency); textsep->colorSelection.setValue(selectionColor); @@ -215,7 +215,7 @@ void ViewProviderAnnotation::attach(App::DocumentObject* f) textsep->addChild(pFont); // causes problems textsep->addChild(pLabel); - SoFCSelection* textsep3d = new SoFCSelection(); + auto textsep3d = new SoFCSelection(); // set sel/highlight color here too textsep3d->colorHighlight.setValue(highlightColor); @@ -245,9 +245,9 @@ void ViewProviderAnnotation::updateData(const App::Property* prop) int index=0; pLabel->string.setNum((int)lines.size()); pLabel3d->string.setNum((int)lines.size()); - for (std::vector::const_iterator it = lines.begin(); it != lines.end(); ++it) { - const char* cs = it->c_str(); - if (it->empty()) + for (const auto & line : lines) { + const char* cs = line.c_str(); + if (line.empty()) cs = " "; // empty lines make coin crash, we use a space instead #if (COIN_MAJOR_VERSION <= 3) QByteArray latin1str; @@ -367,7 +367,7 @@ void ViewProviderAnnotationLabel::attach(App::DocumentObject* f) linesep->addChild(pColor); linesep->addChild(pCoords); linesep->addChild(new SoLineSet()); - SoDrawStyle *ds = new SoDrawStyle(); + auto ds = new SoDrawStyle(); ds->pointSize.setValue(3.0f); linesep->addChild(ds); linesep->addChild(new SoPointSet()); @@ -424,7 +424,7 @@ void ViewProviderAnnotationLabel::dragFinishCallback(void *, SoDragger *) void ViewProviderAnnotationLabel::dragMotionCallback(void *data, SoDragger *drag) { - ViewProviderAnnotationLabel* that = static_cast(data); + auto that = static_cast(data); const SbMatrix& mat = drag->getMotionMatrix(); App::DocumentObject* obj = that->getObject(); if (obj && obj->getTypeId() == App::AnnotationLabel::getClassTypeId()) { @@ -442,7 +442,7 @@ bool ViewProviderAnnotationLabel::setEdit(int ModNum) sa.apply(pcRoot); SoPath * path = sa.getPath(); if (path) { - TranslateManip * manip = new TranslateManip; + auto manip = new TranslateManip; SoDragger* dragger = manip->getDragger(); dragger->addStartCallback(dragStartCallback, this); dragger->addFinishCallback(dragFinishCallback, this); @@ -466,7 +466,7 @@ void ViewProviderAnnotationLabel::unsetEdit(int ModNum) if (!path) return; - TranslateManip * manip = static_cast(path->getTail()); + auto manip = static_cast(path->getTail()); SoTransform* transform = this->pTextTranslation; manip->replaceManip(path, transform); } @@ -491,8 +491,8 @@ void ViewProviderAnnotationLabel::drawImage(const std::vector& s) front.setRgbF(t.r,t.g,t.b); QStringList lines; - for (std::vector::const_iterator it = s.begin(); it != s.end(); ++it) { - QString line = QString::fromUtf8(it->c_str()); + for (const auto & it : s) { + QString line = QString::fromUtf8(it.c_str()); w = std::max(w, QtTools::horizontalAdvance(fm, line)); lines << line; } diff --git a/src/Gui/ViewProviderBuilder.cpp b/src/Gui/ViewProviderBuilder.cpp index fa776352a4..a1b006347c 100644 --- a/src/Gui/ViewProviderBuilder.cpp +++ b/src/Gui/ViewProviderBuilder.cpp @@ -60,7 +60,7 @@ ViewProvider* ViewProviderBuilder::create(const Base::Type& type) Gui::SoFCSelection* ViewProviderBuilder::createSelection() { - Gui::SoFCSelection* sel = new Gui::SoFCSelection(); + auto sel = new Gui::SoFCSelection(); float transparency; ParameterGrp::handle hGrp = Gui::WindowParameter::getDefaultParameter()->GetGroup("View"); @@ -72,7 +72,7 @@ Gui::SoFCSelection* ViewProviderBuilder::createSelection() else { // Search for a user defined value with the current color as default SbColor highlightColor = sel->colorHighlight.getValue(); - unsigned long highlight = (unsigned long)(highlightColor.getPackedValue()); + auto highlight = (unsigned long)(highlightColor.getPackedValue()); highlight = hGrp->GetUnsigned("HighlightColor", highlight); highlightColor.setPackedValue((uint32_t)highlight, transparency); sel->colorHighlight.setValue(highlightColor); @@ -83,7 +83,7 @@ Gui::SoFCSelection* ViewProviderBuilder::createSelection() else { // Do the same with the selection color SbColor selectionColor = sel->colorSelection.getValue(); - unsigned long selection = (unsigned long)(selectionColor.getPackedValue()); + auto selection = (unsigned long)(selectionColor.getPackedValue()); selection = hGrp->GetUnsigned("SelectionColor", selection); selectionColor.setPackedValue((uint32_t)selection, transparency); sel->colorSelection.setValue(selectionColor); @@ -104,16 +104,16 @@ ViewProviderColorBuilder::~ViewProviderColorBuilder() void ViewProviderColorBuilder::buildNodes(const App::Property* prop, std::vector& node) const { - const App::PropertyColorList* color = static_cast(prop); + const auto color = static_cast(prop); const std::vector& val = color->getValues(); unsigned long i=0; - SoMaterial* material = new SoMaterial(); + auto material = new SoMaterial(); material->diffuseColor.setNum(val.size()); SbColor* colors = material->diffuseColor.startEditing(); - for (std::vector::const_iterator it = val.begin(); it != val.end(); ++it) { - colors[i].setValue(it->r, it->g, it->b); + for (const auto & it : val) { + colors[i].setValue(it.r, it.g, it.b); i++; } material->diffuseColor.finishEditing(); diff --git a/src/Gui/ViewProviderDocumentObject.cpp b/src/Gui/ViewProviderDocumentObject.cpp index 08fa38ea32..9e3672b008 100644 --- a/src/Gui/ViewProviderDocumentObject.cpp +++ b/src/Gui/ViewProviderDocumentObject.cpp @@ -271,7 +271,7 @@ void ViewProviderDocumentObject::addDefaultAction(QMenu* menu, const QString& te { QAction* act = menu->addAction(text); act->setData(QVariant((int)ViewProvider::Default)); - Gui::ActionFunction* func = new Gui::ActionFunction(menu); + auto func = new Gui::ActionFunction(menu); func->trigger(act, std::bind(&ViewProviderDocumentObject::startDefaultEditMode, this)); } @@ -320,8 +320,8 @@ void ViewProviderDocumentObject::updateView() // Hide the object temporarily to speed up the update bool vis = ViewProvider::isShow(); if (vis) ViewProvider::hide(); - for (std::map::iterator it = Map.begin(); it != Map.end(); ++it) { - updateData(it->second); + for (const auto & it : Map) { + updateData(it.second); } if (vis && Visibility.getValue()) ViewProvider::show(); } @@ -343,6 +343,7 @@ void ViewProviderDocumentObject::attach(App::DocumentObject *pcObj) // We must collect the const char* of the strings and give it to PropertyEnumeration, // but we are still responsible for them, i.e. the property class must not delete the literals. + //for (auto it = aDisplayModesArray.begin(); it != aDisplayModesArray.end(); ++it) { for (std::vector::iterator it = aDisplayModesArray.begin(); it != aDisplayModesArray.end(); ++it) { aDisplayEnumsArray.push_back( it->c_str() ); } @@ -452,8 +453,8 @@ SoNode* ViewProviderDocumentObject::findFrontRootOfType(const SoType& type) cons // search in all view providers for the node type std::vector obj = pAppDoc->getObjects(); - for (std::vector::iterator it = obj.begin(); it != obj.end(); ++it) { - const ViewProvider* vp = pGuiDoc->getViewProvider(*it); + for (auto & it : obj) { + const ViewProvider* vp = pGuiDoc->getViewProvider(it); // Ignore 'this' view provider. It could also happen that vp is 0, e.g. when // several objects have been added to the App::Document before notifying the // Gui::Document diff --git a/src/Gui/ViewProviderDocumentObjectGroup.cpp b/src/Gui/ViewProviderDocumentObjectGroup.cpp index 986f129c21..51a3ac491d 100644 --- a/src/Gui/ViewProviderDocumentObjectGroup.cpp +++ b/src/Gui/ViewProviderDocumentObjectGroup.cpp @@ -74,10 +74,10 @@ void ViewProviderDocumentObjectGroup::getViewProviders(std::vectorgetTypeId().isDerivedFrom(App::DocumentObjectGroup::getClassTypeId())) { Gui::Document* gd = Application::Instance->getDocument(doc->getDocument()); - App::DocumentObjectGroup* grp = (App::DocumentObjectGroup*)doc; + auto grp = (App::DocumentObjectGroup*)doc; std::vector obj = grp->getObjects(); - for (std::vector::iterator it = obj.begin(); it != obj.end(); ++it) { - ViewProvider* v = gd->getViewProvider(*it); + for (const auto & it : obj) { + ViewProvider* v = gd->getViewProvider(it); if (v && v->getTypeId().isDerivedFrom(ViewProviderDocumentObject::getClassTypeId())) vp.push_back((ViewProviderDocumentObject*)v); } diff --git a/src/Gui/ViewProviderDragger.cpp b/src/Gui/ViewProviderDragger.cpp index 1d3ed1c713..dcfaf0e2ab 100644 --- a/src/Gui/ViewProviderDragger.cpp +++ b/src/Gui/ViewProviderDragger.cpp @@ -133,9 +133,9 @@ bool ViewProviderDragger::setEdit(int ModNum) App::DocumentObject *genericObject = this->getObject(); if (genericObject->isDerivedFrom(App::GeoFeature::getClassTypeId())) { - App::GeoFeature *geoFeature = static_cast(genericObject); + auto geoFeature = static_cast(genericObject); const Base::Placement &placement = geoFeature->Placement.getValue(); - SoTransform *tempTransform = new SoTransform(); + auto tempTransform = new SoTransform(); tempTransform->ref(); updateTransform(placement, tempTransform); @@ -157,7 +157,7 @@ bool ViewProviderDragger::setEdit(int ModNum) // pcRoot->insertChild(csysDragger, 0); csysDragger->ref(); - TaskCSysDragger *task = new TaskCSysDragger(this, csysDragger); + auto task = new TaskCSysDragger(this, csysDragger); Gui::Control().showDialog(task); } @@ -187,9 +187,9 @@ void ViewProviderDragger::setEditViewer(Gui::View3DInventorViewer* viewer, int M if (csysDragger && viewer) { - SoPickStyle *rootPickStyle = new SoPickStyle(); + auto rootPickStyle = new SoPickStyle(); rootPickStyle->style = SoPickStyle::UNPICKABLE; - SoFCUnifiedSelection* selection = static_cast(viewer->getSceneGraph()); + auto selection = static_cast(viewer->getSceneGraph()); selection->insertChild(rootPickStyle, 0); selection->selectionRole.setValue(false); csysDragger->setUpAutoScale(viewer->getSoRenderManager()->getCamera()); @@ -208,8 +208,8 @@ void ViewProviderDragger::setEditViewer(Gui::View3DInventorViewer* viewer, int M void ViewProviderDragger::unsetEditViewer(Gui::View3DInventorViewer* viewer) { - SoFCUnifiedSelection* selection = static_cast(viewer->getSceneGraph()); - SoNode *child = selection->getChild(0); + auto selection = static_cast(viewer->getSceneGraph()); + SoNode *child = selection->getChild(0); if (child && child->isOfType(SoPickStyle::getClassTypeId())) { selection->removeChild(child); selection->selectionRole.setValue(true); @@ -226,8 +226,8 @@ void ViewProviderDragger::dragFinishCallback(void *data, SoDragger *d) { // This is called when a manipulator has done manipulating - ViewProviderDragger* sudoThis = static_cast(data); - SoFCCSysDragger *dragger = static_cast(d); + auto sudoThis = static_cast(data); + auto dragger = static_cast(d); updatePlacementFromDragger(sudoThis, dragger); Gui::Application::Instance->activeDocument()->commitCommand(); @@ -238,7 +238,7 @@ void ViewProviderDragger::updatePlacementFromDragger(ViewProviderDragger* sudoTh App::DocumentObject *genericObject = sudoThis->getObject(); if (!genericObject->isDerivedFrom(App::GeoFeature::getClassTypeId())) return; - App::GeoFeature *geoFeature = static_cast(genericObject); + auto geoFeature = static_cast(genericObject); Base::Placement originalPlacement = geoFeature->Placement.getValue(); double pMatrix[16]; originalPlacement.toMatrix().getMatrix(pMatrix); @@ -319,13 +319,13 @@ void ViewProviderDragger::updatePlacementFromDragger(ViewProviderDragger* sudoTh void ViewProviderDragger::updateTransform(const Base::Placement& from, SoTransform* to) { - float q0 = (float)from.getRotation().getValue()[0]; - float q1 = (float)from.getRotation().getValue()[1]; - float q2 = (float)from.getRotation().getValue()[2]; - float q3 = (float)from.getRotation().getValue()[3]; - float px = (float)from.getPosition().x; - float py = (float)from.getPosition().y; - float pz = (float)from.getPosition().z; + auto q0 = (float)from.getRotation().getValue()[0]; + auto q1 = (float)from.getRotation().getValue()[1]; + auto q2 = (float)from.getRotation().getValue()[2]; + auto q3 = (float)from.getRotation().getValue()[3]; + auto px = (float)from.getPosition().x; + auto py = (float)from.getPosition().y; + auto pz = (float)from.getPosition().z; to->rotation.setValue(q0,q1,q2,q3); to->translation.setValue(px,py,pz); to->center.setValue(0.0f,0.0f,0.0f); diff --git a/src/Gui/ViewProviderGeometryObject.cpp b/src/Gui/ViewProviderGeometryObject.cpp index 7b3977710c..a99a34646b 100644 --- a/src/Gui/ViewProviderGeometryObject.cpp +++ b/src/Gui/ViewProviderGeometryObject.cpp @@ -64,7 +64,7 @@ ViewProviderGeometryObject::ViewProviderGeometryObject() float r, g, b; if (randomColor){ - float fMax = (float)RAND_MAX; + auto fMax = (float)RAND_MAX; r = (float)rand()/fMax; g = (float)rand()/fMax; b = (float)rand()/fMax; @@ -175,7 +175,7 @@ void ViewProviderGeometryObject::updateData(const App::Property* prop) pcBoundingBox->maxBounds.setValue(box.MaxX, box.MaxY, box.MaxZ); } else if (prop->isDerivedFrom(App::PropertyPlacement::getClassTypeId())) { - App::GeoFeature* geometry = dynamic_cast(getObject()); + auto geometry = dynamic_cast(getObject()); if (geometry && prop == &geometry->Placement) { const App::PropertyComplexGeoData* data = geometry->getPropertyOfGeometry(); if (data) { @@ -191,7 +191,7 @@ void ViewProviderGeometryObject::updateData(const App::Property* prop) SoPickedPointList ViewProviderGeometryObject::getPickedPoints(const SbVec2s& pos, const View3DInventorViewer& viewer,bool pickAll) const { - SoSeparator* root = new SoSeparator; + auto root = new SoSeparator; root->ref(); root->addChild(viewer.getHeadlight()); root->addChild(viewer.getSoRenderManager()->getCamera()); @@ -210,7 +210,7 @@ SoPickedPointList ViewProviderGeometryObject::getPickedPoints(const SbVec2s& pos SoPickedPoint* ViewProviderGeometryObject::getPickedPoint(const SbVec2s& pos, const View3DInventorViewer& viewer) const { - SoSeparator* root = new SoSeparator; + auto root = new SoSeparator; root->ref(); root->addChild(viewer.getHeadlight()); root->addChild(viewer.getSoRenderManager()->getCamera()); @@ -251,14 +251,14 @@ void ViewProviderGeometryObject::showBoundingBox(bool show) r = ((bbcol >> 24) & 0xff) / 255.0; g = ((bbcol >> 16) & 0xff) / 255.0; b = ((bbcol >> 8) & 0xff) / 255.0; pcBoundSwitch = new SoSwitch(); - SoSeparator* pBoundingSep = new SoSeparator(); - SoDrawStyle* lineStyle = new SoDrawStyle; + auto pBoundingSep = new SoSeparator(); + auto lineStyle = new SoDrawStyle; lineStyle->lineWidth = 2.0f; pBoundingSep->addChild(lineStyle); pcBoundColor->rgb.setValue(r, g, b); pBoundingSep->addChild(pcBoundColor); - SoFont* font = new SoFont(); + auto font = new SoFont(); font->size.setValue(getBoundBoxFontSize()); pBoundingSep->addChild(font); @@ -288,7 +288,7 @@ void ViewProviderGeometryObject::setSelectable(bool selectable) SoPathList & pathList = sa.getPaths(); for (int i=0;i(pathList[i]->getTail()); + auto selNode = dynamic_cast(pathList[i]->getTail()); if (selectable) { if (selNode) { selNode->selectionMode = SoFCSelection::SEL_ON; diff --git a/src/Gui/ViewProviderGroupExtension.cpp b/src/Gui/ViewProviderGroupExtension.cpp index 3653896784..698bcdc1d1 100644 --- a/src/Gui/ViewProviderGroupExtension.cpp +++ b/src/Gui/ViewProviderGroupExtension.cpp @@ -94,7 +94,7 @@ bool ViewProviderGroupExtension::extensionCanDropObject(App::DocumentObject* obj void ViewProviderGroupExtension::extensionDropObject(App::DocumentObject* obj) { - App::DocumentObject* grp = static_cast(getExtendedViewProvider()->getObject()); + auto grp = static_cast(getExtendedViewProvider()->getObject()); App::Document* doc = grp->getDocument(); // build Python command for execution diff --git a/src/Gui/ViewProviderInventorObject.cpp b/src/Gui/ViewProviderInventorObject.cpp index 46b8778cbe..19e55469bf 100644 --- a/src/Gui/ViewProviderInventorObject.cpp +++ b/src/Gui/ViewProviderInventorObject.cpp @@ -58,7 +58,7 @@ ViewProviderInventorObject::~ViewProviderInventorObject() void ViewProviderInventorObject::attach(App::DocumentObject *pcObj) { ViewProviderDocumentObject::attach(pcObj); - SoGroup* pcFileBuf = new SoGroup(); + auto pcFileBuf = new SoGroup(); pcFileBuf->addChild(pcBuffer); pcFileBuf->addChild(pcFile); addDisplayMaskMode(pcFileBuf, "FileBuffer"); @@ -88,7 +88,7 @@ std::vector ViewProviderInventorObject::getDisplayModes() const void ViewProviderInventorObject::updateData(const App::Property* prop) { - App::InventorObject* ivObj = static_cast(pcObject); + auto ivObj = static_cast(pcObject); if (prop == &ivObj->Buffer) { // read from buffer SoInput in; @@ -135,13 +135,13 @@ void ViewProviderInventorObject::updateData(const App::Property* prop) // <==> (I-R) * c = 0 ==> c = 0 // This means that the center point must be the origin! Base::Placement p = static_cast(prop)->getValue(); - float q0 = (float)p.getRotation().getValue()[0]; - float q1 = (float)p.getRotation().getValue()[1]; - float q2 = (float)p.getRotation().getValue()[2]; - float q3 = (float)p.getRotation().getValue()[3]; - float px = (float)p.getPosition().x; - float py = (float)p.getPosition().y; - float pz = (float)p.getPosition().z; + auto q0 = (float)p.getRotation().getValue()[0]; + auto q1 = (float)p.getRotation().getValue()[1]; + auto q2 = (float)p.getRotation().getValue()[2]; + auto q3 = (float)p.getRotation().getValue()[3]; + auto px = (float)p.getPosition().x; + auto py = (float)p.getPosition().y; + auto pz = (float)p.getPosition().z; pcTransform->rotation.setValue(q0,q1,q2,q3); pcTransform->translation.setValue(px,py,pz); pcTransform->center.setValue(0.0f,0.0f,0.0f); @@ -157,7 +157,7 @@ void ViewProviderInventorObject::adjustSelectionNodes(SoNode* child, const char* static_cast(child)->objectName = objname; } else if (child->getTypeId().isDerivedFrom(SoGroup::getClassTypeId())) { - SoGroup* group = static_cast(child); + auto group = static_cast(child); for (int i=0; igetNumChildren(); i++) { SoNode* subchild = group->getChild(i); adjustSelectionNodes(subchild, docname, objname); diff --git a/src/Gui/ViewProviderLine.cpp b/src/Gui/ViewProviderLine.cpp index 8e49c61139..89fa0aa4aa 100644 --- a/src/Gui/ViewProviderLine.cpp +++ b/src/Gui/ViewProviderLine.cpp @@ -61,21 +61,21 @@ void ViewProviderLine::attach ( App::DocumentObject *obj ) { SoSeparator *sep = getOriginFeatureRoot (); - SoCoordinate3 *pCoords = new SoCoordinate3 (); + auto pCoords = new SoCoordinate3 (); pCoords->point.setNum (2); pCoords->point.setValues ( 0, 2, verts ); sep->addChild ( pCoords ); - SoIndexedLineSet *pLines = new SoIndexedLineSet (); + auto pLines = new SoIndexedLineSet (); pLines->coordIndex.setNum(3); pLines->coordIndex.setValues(0, 3, lines); sep->addChild ( pLines ); - SoTranslation *textTranslation = new SoTranslation (); + auto textTranslation = new SoTranslation (); textTranslation->translation.setValue ( SbVec3f ( -size * 49. / 50., size / 30., 0 ) ); sep->addChild ( textTranslation ); - SoPickStyle *ps = new SoPickStyle(); + auto ps = new SoPickStyle(); ps->style.setValue(SoPickStyle::BOUNDING_BOX); sep->addChild(ps); diff --git a/src/Gui/ViewProviderLink.cpp b/src/Gui/ViewProviderLink.cpp index 60f9700017..301ac66fec 100644 --- a/src/Gui/ViewProviderLink.cpp +++ b/src/Gui/ViewProviderLink.cpp @@ -403,7 +403,7 @@ public: auto transform = pcLinked->getTransformNode(); const auto &scale = transform->scaleFactor.getValue(); if(scale[0]!=1.0 || scale[1]!=1.0 || scale[2]!=1.0) { - SoTransform *trans = new SoTransform; + auto trans = new SoTransform; pcSnapshot->addChild(trans); trans->scaleFactor.setValue(scale); trans->scaleOrientation = transform->scaleOrientation; @@ -896,7 +896,7 @@ PyObject *LinkView::getPyObject() void LinkView::setInvalid() { if (!PythonObject.is(Py::_None())){ - Base::PyObjectBase* obj = (Base::PyObjectBase*)PythonObject.ptr(); + auto obj = (Base::PyObjectBase*)PythonObject.ptr(); obj->setInvalid(); obj->DecRef(); }else @@ -2436,7 +2436,7 @@ void ViewProviderLink::setupContextMenu(QMenu* menu, QObject* receiver, const ch DlgObjectSelection dlg({src}, excludes, getMainWindow()); dlg.setMessage(QObject::tr( "Please select which objects to copy when the configuration is changed")); - QCheckBox *box = new QCheckBox(QObject::tr("Apply to all"), &dlg); + auto box = new QCheckBox(QObject::tr("Apply to all"), &dlg); box->setToolTip(QObject::tr("Apply the setting to all links. Or, uncheck this\n" "option to apply only to this link.")); box->setChecked(App::LinkParams::getCopyOnChangeApplyToAll()); @@ -2453,10 +2453,10 @@ void ViewProviderLink::setupContextMenu(QMenu* menu, QObject* receiver, const ch App::AutoTransaction guard("Setup configurable object"); auto sels = dlg.getSelections(DlgObjectSelection::SelectionOptions::InvertSort); - for (auto it=excludes.begin(); it!=excludes.end(); ++it) { - auto iter = std::lower_bound(sels.begin(), sels.end(), *it); - if (iter == sels.end() || *iter != *it) { - ext->setOnChangeCopyObject(*it, options); + for (const auto & exclude : excludes) { + auto iter = std::lower_bound(sels.begin(), sels.end(), exclude); + if (iter == sels.end() || *iter != exclude) { + ext->setOnChangeCopyObject(exclude, options); } else sels.erase(iter); } @@ -2818,15 +2818,15 @@ void ViewProviderLink::setEditViewer(Gui::View3DInventorViewer* viewer, int ModN if (pcDragger && viewer) { - SoPickStyle *rootPickStyle = new SoPickStyle(); + auto rootPickStyle = new SoPickStyle(); rootPickStyle->style = SoPickStyle::UNPICKABLE; static_cast( viewer->getSceneGraph())->insertChild(rootPickStyle, 0); if(useCenterballDragger) { auto dragger = static_cast(pcDragger.get()); - SoSeparator *group = new SoAnnotation; - SoPickStyle *pickStyle = new SoPickStyle; + auto group = new SoAnnotation; + auto pickStyle = new SoPickStyle; pickStyle->setOverride(true); group->addChild(pickStyle); group->addChild(pcDragger); @@ -2855,12 +2855,12 @@ void ViewProviderLink::setEditViewer(Gui::View3DInventorViewer* viewer, int ModN viewer->setupEditingRoot(group,&dragCtx->preTransform); }else{ - SoFCCSysDragger* dragger = static_cast(pcDragger.get()); + auto dragger = static_cast(pcDragger.get()); dragger->draggerSize.setValue(0.05f); dragger->setUpAutoScale(viewer->getSoRenderManager()->getCamera()); viewer->setupEditingRoot(pcDragger,&dragCtx->preTransform); - TaskCSysDragger *task = new TaskCSysDragger(this, dragger); + auto task = new TaskCSysDragger(this, dragger); Gui::Control().showDialog(task); } } @@ -2885,12 +2885,12 @@ Base::Placement ViewProviderLink::currentDraggingPlacement() const SbVec3f v; SbRotation r; if (useCenterballDragger) { - SoCenterballDragger *dragger = static_cast(pcDragger.get()); + auto dragger = static_cast(pcDragger.get()); v = dragger->center.getValue(); r = dragger->rotation.getValue(); } else { - SoFCCSysDragger *dragger = static_cast(pcDragger.get()); + auto dragger = static_cast(pcDragger.get()); v = dragger->translation.getValue(); r = dragger->rotation.getValue(); } @@ -2914,7 +2914,7 @@ void ViewProviderLink::updateDraggingPlacement(const Base::Placement &pla, bool const auto &rot = pla.getRotation(); FC_LOG("updating dragger placement (" << pos.x << ", " << pos.y << ", " << pos.z << ')'); if(useCenterballDragger) { - SoCenterballDragger *dragger = static_cast(pcDragger.get()); + auto dragger = static_cast(pcDragger.get()); SbBool wasenabled = dragger->enableValueChangedCallbacks(FALSE); SbMatrix matrix; matrix = convert(pla.toMatrix()); @@ -2925,7 +2925,7 @@ void ViewProviderLink::updateDraggingPlacement(const Base::Placement &pla, bool dragger->valueChanged(); } }else{ - SoFCCSysDragger *dragger = static_cast(pcDragger.get()); + auto dragger = static_cast(pcDragger.get()); dragger->translation.setValue(SbVec3f(pos.x,pos.y,pos.z)); dragger->rotation.setValue(rot[0],rot[1],rot[2],rot[3]); } diff --git a/src/Gui/ViewProviderMeasureDistance.cpp b/src/Gui/ViewProviderMeasureDistance.cpp index b965ff7fa4..2c486d95dd 100644 --- a/src/Gui/ViewProviderMeasureDistance.cpp +++ b/src/Gui/ViewProviderMeasureDistance.cpp @@ -160,30 +160,30 @@ void ViewProviderMeasureDistance::attach(App::DocumentObject* pcObject) { ViewProviderDocumentObject::attach(pcObject); - SoPickStyle* ps = new SoPickStyle(); + auto ps = new SoPickStyle(); ps->style = SoPickStyle::UNPICKABLE; - SoSeparator *lineSep = new SoSeparator(); - SoDrawStyle* style = new SoDrawStyle(); + auto lineSep = new SoSeparator(); + auto style = new SoDrawStyle(); style->lineWidth = 2.0f; lineSep->addChild(ps); lineSep->addChild(style); lineSep->addChild(pColor); lineSep->addChild(pCoords); lineSep->addChild(pLines); - SoMarkerSet* points = new SoMarkerSet(); + auto points = new SoMarkerSet(); points->markerIndex = Gui::Inventor::MarkerBitmaps::getMarkerIndex("CROSS", ViewParams::instance()->getMarkerSize()); points->numPoints=2; lineSep->addChild(points); - SoSeparator* textsep = new SoSeparator(); + auto textsep = new SoSeparator(); textsep->addChild(pTranslation); textsep->addChild(pTextColor); textsep->addChild(pFont); textsep->addChild(pLabel); - SoSeparator* sep = new SoAnnotation(); + auto sep = new SoAnnotation(); sep->addChild(lineSep); sep->addChild(textsep); addDisplayMaskMode(sep, "Base"); @@ -273,7 +273,7 @@ void PointMarker::customEvent(QEvent*) App::DocumentObject* obj = doc->getDocument()->addObject (App::MeasureDistance::getClassTypeId().getName(),"Distance"); - App::MeasureDistance* md = static_cast(obj); + auto md = static_cast(obj); const SbVec3f& pt1 = vp->pCoords->point[0]; const SbVec3f& pt2 = vp->pCoords->point[1]; md->P1.setValue(Base::Vector3d(pt1[0],pt1[1],pt1[2])); @@ -300,7 +300,7 @@ ViewProviderPointMarker::ViewProviderPointMarker() pMarker->numPoints=0; pMarker->ref(); - SoGroup* grp = new SoGroup(); + auto grp = new SoGroup(); grp->addChild(pCoords); grp->addChild(pMarker); addDisplayMaskMode(grp, "Base"); @@ -315,11 +315,11 @@ ViewProviderPointMarker::~ViewProviderPointMarker() void ViewProviderMeasureDistance::measureDistanceCallback(void * ud, SoEventCallback * n) { - Gui::View3DInventorViewer* view = static_cast(n->getUserData()); - PointMarker *pm = static_cast(ud); + auto view = static_cast(n->getUserData()); + auto pm = static_cast(ud); const SoEvent* ev = n->getEvent(); if (ev->isOfType(SoKeyboardEvent::getClassTypeId())) { - const SoKeyboardEvent * ke = static_cast(ev); + const auto ke = static_cast(ev); const SbBool press = ke->getState() == SoButtonEvent::DOWN ? true : false; if (ke->getKey() == SoKeyboardEvent::ESCAPE) { n->setHandled(); @@ -330,7 +330,7 @@ void ViewProviderMeasureDistance::measureDistanceCallback(void * ud, SoEventCall } } else if (ev->isOfType(SoMouseButtonEvent::getClassTypeId())) { - const SoMouseButtonEvent * mbe = static_cast(ev); + const auto mbe = static_cast(ev); // Mark all incoming mouse button events as handled, especially, to deactivate the selection node n->getAction()->setHandled(); @@ -345,7 +345,7 @@ void ViewProviderMeasureDistance::measureDistanceCallback(void * ud, SoEventCall n->setHandled(); pm->addPoint(point->getPoint()); if (pm->countPoints() == 2) { - QEvent *e = new QEvent(QEvent::User); + auto e = new QEvent(QEvent::User); QApplication::postEvent(pm, e); // leave mode view->setEditing(false); diff --git a/src/Gui/ViewProviderOrigin.cpp b/src/Gui/ViewProviderOrigin.cpp index 129043a574..ff4056e944 100644 --- a/src/Gui/ViewProviderOrigin.cpp +++ b/src/Gui/ViewProviderOrigin.cpp @@ -93,7 +93,7 @@ void ViewProviderOrigin::setDisplayMode(const char* ModeName) } void ViewProviderOrigin::setTemporaryVisibility(bool axis, bool plane) { - App::Origin* origin = static_cast( getObject() ); + auto origin = static_cast( getObject() ); bool saveState = tempVisMap.empty(); @@ -155,7 +155,7 @@ void ViewProviderOrigin::onChanged(const App::Property* prop) { try { Gui::Application *app = Gui::Application::Instance; Base::Vector3d sz = Size.getValue (); - App::Origin* origin = static_cast ( getObject() ); + auto origin = static_cast ( getObject() ); // Calculate axes and planes sizes double szXY = std::max ( sz.x, sz.y ); @@ -199,7 +199,7 @@ void ViewProviderOrigin::onChanged(const App::Property* prop) { } bool ViewProviderOrigin::onDelete(const std::vector &) { - App::Origin* origin = static_cast( getObject() ); + auto origin = static_cast( getObject() ); if ( !origin->getInList().empty() ) { return false; diff --git a/src/Gui/ViewProviderOriginFeature.cpp b/src/Gui/ViewProviderOriginFeature.cpp index a0fb33c50d..a02f676e89 100644 --- a/src/Gui/ViewProviderOriginFeature.cpp +++ b/src/Gui/ViewProviderOriginFeature.cpp @@ -82,13 +82,13 @@ void ViewProviderOriginFeature::attach(App::DocumentObject* pcObject) float sz = Size.getValue () / defaultSz; // Create an external separator - SoSeparator *sep = new SoSeparator(); + auto sep = new SoSeparator(); // Add material from the base class sep->addChild(pcShapeMaterial); // Bind same material to all part - SoMaterialBinding* matBinding = new SoMaterialBinding; + auto matBinding = new SoMaterialBinding; matBinding->value = SoMaterialBinding::OVERALL; sep->addChild(matBinding); @@ -97,12 +97,12 @@ void ViewProviderOriginFeature::attach(App::DocumentObject* pcObject) sep->addChild (pScale); // Setup font size - SoFont *font = new SoFont (); + auto font = new SoFont (); font->size.setValue ( defaultSz/10.); sep->addChild ( font ); // Create the selection node - SoFCSelection *highlight = new SoFCSelection (); + auto highlight = new SoFCSelection (); highlight->applySettings (); if ( !Selectable.getValue() ) { highlight->selectionMode = Gui::SoFCSelection::SEL_OFF; @@ -112,7 +112,7 @@ void ViewProviderOriginFeature::attach(App::DocumentObject* pcObject) highlight->style = SoFCSelection::EMISSIVE_DIFFUSE; // Style for normal (visible) lines - SoDrawStyle* style = new SoDrawStyle (); + auto style = new SoDrawStyle (); style->lineWidth = 2.0f; highlight->addChild ( style ); @@ -120,7 +120,7 @@ void ViewProviderOriginFeature::attach(App::DocumentObject* pcObject) highlight->addChild ( pOriginFeatureRoot ); // Hidden features - SoAnnotation *hidden = new SoAnnotation (); + auto hidden = new SoAnnotation (); // Style for hidden lines style = new SoDrawStyle (); @@ -172,7 +172,7 @@ void ViewProviderOriginFeature::setDisplayMode (const char* ModeName) } bool ViewProviderOriginFeature::onDelete(const std::vector &) { - App::OriginFeature *feat = static_cast ( getObject() ); + auto feat = static_cast ( getObject() ); // Forbid deletion if there is an origin this feature belongs to if ( feat->getOrigin () ) { diff --git a/src/Gui/ViewProviderPart.cpp b/src/Gui/ViewProviderPart.cpp index bcac0fc3b1..a2d3f2fad4 100644 --- a/src/Gui/ViewProviderPart.cpp +++ b/src/Gui/ViewProviderPart.cpp @@ -69,7 +69,7 @@ void ViewProviderPart::onChanged(const App::Property* prop) { void ViewProviderPart::setupContextMenu(QMenu* menu, QObject* receiver, const char* member) { - Gui::ActionFunction* func = new Gui::ActionFunction(menu); + auto func = new Gui::ActionFunction(menu); QAction* act = menu->addAction(QObject::tr("Toggle active part")); func->trigger(act, std::bind(&ViewProviderPart::doubleClicked, this)); @@ -111,7 +111,7 @@ bool ViewProviderPart::doubleClicked() QIcon ViewProviderPart::getIcon() const { // the original Part object for this ViewProviderPart - App::Part* part = static_cast(this->getObject()); + auto part = static_cast(this->getObject()); // the normal case for Std_Part const char* pixmap = sPixmap; // if it's flagged as an Assembly in its Type, it gets another icon diff --git a/src/Gui/ViewProviderPlane.cpp b/src/Gui/ViewProviderPlane.cpp index 5a5ed1c611..e827175fc4 100644 --- a/src/Gui/ViewProviderPlane.cpp +++ b/src/Gui/ViewProviderPlane.cpp @@ -63,21 +63,21 @@ void ViewProviderPlane::attach ( App::DocumentObject *obj ) { SoSeparator *sep = getOriginFeatureRoot (); - SoCoordinate3 *pCoords = new SoCoordinate3 (); + auto pCoords = new SoCoordinate3 (); pCoords->point.setNum (4); pCoords->point.setValues ( 0, 4, verts ); sep->addChild ( pCoords ); - SoIndexedLineSet *pLines = new SoIndexedLineSet (); + auto pLines = new SoIndexedLineSet (); pLines->coordIndex.setNum(6); pLines->coordIndex.setValues(0, 6, lines); sep->addChild ( pLines ); - SoTranslation *textTranslation = new SoTranslation (); + auto textTranslation = new SoTranslation (); textTranslation->translation.setValue ( SbVec3f ( -size * 49. / 50., size * 9./10., 0 ) ); sep->addChild ( textTranslation ); - SoPickStyle *ps = new SoPickStyle(); + auto ps = new SoPickStyle(); ps->style.setValue(SoPickStyle::BOUNDING_BOX); sep->addChild(ps); diff --git a/src/Gui/ViewProviderPyImp.cpp b/src/Gui/ViewProviderPyImp.cpp index f795203e7e..8643508201 100644 --- a/src/Gui/ViewProviderPyImp.cpp +++ b/src/Gui/ViewProviderPyImp.cpp @@ -114,11 +114,11 @@ PyObject* ViewProviderPy::supportedProperties(PyObject *args) std::vector ary; Base::Type::getAllDerivedFrom(App::Property::getClassTypeId(), ary); Py::List res; - for (std::vector::iterator it = ary.begin(); it != ary.end(); ++it) { - Base::BaseClass *data = static_cast(it->createInstance()); + for (auto & it : ary) { + auto data = static_cast(it.createInstance()); if (data) { delete data; - res.append(Py::String(it->getName())); + res.append(Py::String(it.getName())); } } return Py::new_reference_to(res); @@ -317,7 +317,7 @@ PyObject* ViewProviderPy::addDisplayMode(PyObject * args) } PY_TRY { - SoNode* node = static_cast(ptr); + auto node = static_cast(ptr); getViewProviderPtr()->addDisplayMaskMode(node,mode); Py_Return; } @@ -334,8 +334,8 @@ PyObject* ViewProviderPy::listDisplayModes(PyObject *args) PyObject* pyList = PyList_New(modes.size()); int i=0; - for ( std::vector::iterator it = modes.begin(); it != modes.end(); ++it ) { - PyObject* str = PyUnicode_FromString(it->c_str()); + for (const auto & mode : modes) { + PyObject* str = PyUnicode_FromString(mode.c_str()); PyList_SetItem(pyList, i++, str); } @@ -368,7 +368,7 @@ PyObject* ViewProviderPy::setTransformation(PyObject *args) PyErr_Clear(); if (PyArg_ParseTuple(args, "O!",&(Base::PlacementPy::Type),&p)) { - Base::PlacementPy* plc = static_cast(p); + auto plc = static_cast(p); getViewProviderPtr()->setTransformation(plc->getPlacementPtr()->toMatrix()); Py_Return; } @@ -478,7 +478,7 @@ PyObject* ViewProviderPy::getElementPicked(PyObject* args) void *ptr = nullptr; Base::Interpreter().convertSWIGPointerObj("pivy.coin", "_p_SoPickedPoint", obj, &ptr, 0); - SoPickedPoint *pp = static_cast(ptr); + auto pp = static_cast(ptr); if(!pp) throw Base::TypeError("type must be coin.SoPickedPoint"); @@ -499,7 +499,7 @@ PyObject* ViewProviderPy::getDetailPath(PyObject* args) void *ptr = nullptr; Base::Interpreter().convertSWIGPointerObj("pivy.coin", "_p_SoPath", path, &ptr, 0); - SoPath *pPath = static_cast(ptr); + auto pPath = static_cast(ptr); if(!pPath) throw Base::TypeError("'path' must be a coin.SoPath"); SoDetail *det = nullptr; diff --git a/src/Gui/ViewProviderPythonFeature.cpp b/src/Gui/ViewProviderPythonFeature.cpp index 9416d90d33..cf65b1e1bd 100644 --- a/src/Gui/ViewProviderPythonFeature.cpp +++ b/src/Gui/ViewProviderPythonFeature.cpp @@ -118,8 +118,8 @@ QIcon ViewProviderPythonFeatureImp::getIcon() const QList lines = ary.split('\n'); QByteArray buffer; buffer.reserve(ary.size()+lines.size()); - for (QList::iterator it = lines.begin(); it != lines.end(); ++it) { - QByteArray trim = it->trimmed(); + for (const auto & line : lines) { + QByteArray trim = line.trimmed(); if (!trim.isEmpty()) { buffer.append(trim); buffer.append('\n'); @@ -278,7 +278,7 @@ bool ViewProviderPythonFeatureImp::getDetail(const char* name, SoDetail *&det) c Py::Object pydet(Base::pyCall(py_getDetail.ptr(),args.ptr())); void* ptr = nullptr; Base::Interpreter().convertSWIGPointerObj("pivy.coin", "SoDetail *", pydet.ptr(), &ptr, 0); - SoDetail* detail = static_cast(ptr); + auto detail = static_cast(ptr); det = detail ? detail->copy() : nullptr; return true; } @@ -319,7 +319,7 @@ ViewProviderPythonFeatureImp::ValueT ViewProviderPythonFeatureImp::getDetailPath return Accepted; void* ptr = nullptr; Base::Interpreter().convertSWIGPointerObj("pivy.coin", "SoDetail *", pyDet.ptr(), &ptr, 0); - SoDetail* detail = static_cast(ptr); + auto detail = static_cast(ptr); det = detail ? detail->copy() : nullptr; if(det) return Accepted; @@ -668,8 +668,8 @@ ViewProviderPythonFeatureImp::onDelete(const std::vector & sub) try { Py::Tuple seq(sub.size()); int index=0; - for (std::vector::const_iterator it = sub.begin(); it != sub.end(); ++it) { - seq.setItem(index++, Py::String(*it)); + for (const auto & it : sub) { + seq.setItem(index++, Py::String(it)); } if (has__object__) { diff --git a/src/Gui/ViewProviderTextDocument.cpp b/src/Gui/ViewProviderTextDocument.cpp index 4e0a517379..237be31b77 100644 --- a/src/Gui/ViewProviderTextDocument.cpp +++ b/src/Gui/ViewProviderTextDocument.cpp @@ -72,7 +72,7 @@ ViewProviderTextDocument::ViewProviderTextDocument() void ViewProviderTextDocument::setupContextMenu(QMenu* menu, QObject* receiver, const char* member) { - Gui::ActionFunction* func = new Gui::ActionFunction(menu); + auto func = new Gui::ActionFunction(menu); QAction* act = menu->addAction(QObject::tr("Edit text")); func->trigger(act, std::bind(&ViewProviderTextDocument::doubleClicked, this)); @@ -108,11 +108,11 @@ void ViewProviderTextDocument::onChanged(const App::Property* prop) else if (prop == &SyntaxHighlighter) { long value = SyntaxHighlighter.getValue(); if (value == 1) { - PythonSyntaxHighlighter* pythonSyntax = new PythonSyntaxHighlighter(editorWidget); + auto pythonSyntax = new PythonSyntaxHighlighter(editorWidget); pythonSyntax->setDocument(editorWidget->document()); } else { - QSyntaxHighlighter* shl = editorWidget->findChild(); + auto shl = editorWidget->findChild(); if (shl) shl->deleteLater(); } diff --git a/src/Gui/ViewProviderVRMLObject.cpp b/src/Gui/ViewProviderVRMLObject.cpp index 40f9ce9188..f99e8d98ed 100644 --- a/src/Gui/ViewProviderVRMLObject.cpp +++ b/src/Gui/ViewProviderVRMLObject.cpp @@ -103,7 +103,7 @@ void ViewProviderVRMLObject::getResourceFile(SoNode* node, std::list(pathlist[i]); + auto path = static_cast(pathlist[i]); if (path->getTail()->isOfType(T::getClassTypeId())) { T * tex = static_cast(path->getTail()); for (int j = 0; j < tex->url.getNum(); j++) { @@ -125,9 +125,9 @@ void ViewProviderVRMLObject::getResourceFile(SoNode* node, std sa.apply(node); const SoPathList & pathlist = sa.getPaths(); for (int i = 0; i < pathlist.getLength(); i++ ) { - SoFullPath * path = static_cast(pathlist[i]); + auto path = static_cast(pathlist[i]); if (path->getTail()->isOfType(SoVRMLBackground::getClassTypeId())) { - SoVRMLBackground * vrml = static_cast(path->getTail()); + auto vrml = static_cast(path->getTail()); // backUrl for (int j = 0; j < vrml->backUrl.getNum(); j++) { addResource(vrml->backUrl[j], resources); @@ -182,7 +182,7 @@ void ViewProviderVRMLObject::getLocalResources(SoNode* node, std::list(path->getTail()); + auto vrml = static_cast(path->getTail()); const SbString& url = vrml->getFullURLName(); if (url.getLength() > 0) { // add the resource file if not yet listed @@ -208,7 +208,7 @@ void ViewProviderVRMLObject::getLocalResources(SoNode* node, std::list(pcObject); + auto ivObj = static_cast(pcObject); if (prop == &ivObj->VrmlFile) { // read also from file const char* filename = ivObj->VrmlFile.getValue(); @@ -260,13 +260,13 @@ void ViewProviderVRMLObject::updateData(const App::Property* prop) // <==> (I-R) * c = 0 ==> c = 0 // This means that the center point must be the origin! Base::Placement p = static_cast(prop)->getValue(); - float q0 = (float)p.getRotation().getValue()[0]; - float q1 = (float)p.getRotation().getValue()[1]; - float q2 = (float)p.getRotation().getValue()[2]; - float q3 = (float)p.getRotation().getValue()[3]; - float px = (float)p.getPosition().x; - float py = (float)p.getPosition().y; - float pz = (float)p.getPosition().z; + auto q0 = (float)p.getRotation().getValue()[0]; + auto q1 = (float)p.getRotation().getValue()[1]; + auto q2 = (float)p.getRotation().getValue()[2]; + auto q3 = (float)p.getRotation().getValue()[3]; + auto px = (float)p.getPosition().x; + auto py = (float)p.getPosition().y; + auto pz = (float)p.getPosition().z; pcTransform->rotation.setValue(q0,q1,q2,q3); pcTransform->translation.setValue(px,py,pz); pcTransform->center.setValue(0.0f,0.0f,0.0f); diff --git a/src/Gui/WaitCursor.cpp b/src/Gui/WaitCursor.cpp index 593801043a..4d0f4a4d08 100644 --- a/src/Gui/WaitCursor.cpp +++ b/src/Gui/WaitCursor.cpp @@ -107,10 +107,10 @@ bool WaitCursorP::isModalDialog(QObject* o) const parent = QWidget::find(window->winId()); } while (parent) { - QMessageBox* dlg = qobject_cast(parent); + auto dlg = qobject_cast(parent); if (dlg && dlg->isModal()) return true; - QProgressDialog* pd = qobject_cast(parent); + auto pd = qobject_cast(parent); if (pd) return true; parent = parent->parentWidget(); diff --git a/src/Gui/WidgetFactory.cpp b/src/Gui/WidgetFactory.cpp index 83d76281f8..6e706eb13e 100644 --- a/src/Gui/WidgetFactory.cpp +++ b/src/Gui/WidgetFactory.cpp @@ -72,7 +72,7 @@ void WidgetFactoryInst::destruct () */ QWidget* WidgetFactoryInst::createWidget (const char* sName, QWidget* parent) const { - QWidget* w = (QWidget*)Produce(sName); + auto w = (QWidget*)Produce(sName); // this widget class is not registered if (!w) { @@ -114,7 +114,7 @@ QWidget* WidgetFactoryInst::createWidget (const char* sName, QWidget* parent) co */ Gui::Dialog::PreferencePage* WidgetFactoryInst::createPreferencePage (const char* sName, QWidget* parent) const { - Gui::Dialog::PreferencePage* w = (Gui::Dialog::PreferencePage*)Produce(sName); + auto w = (Gui::Dialog::PreferencePage*)Produce(sName); // this widget class is not registered if (!w) { @@ -164,7 +164,7 @@ QWidget* WidgetFactoryInst::createPrefWidget(const char* sName, QWidget* parent, w->setParent(parent); try { - PrefWidget* pw = dynamic_cast(w); + auto pw = dynamic_cast(w); if (pw) { pw->setEntryName(sPref); pw->restorePreferences(); @@ -285,7 +285,7 @@ PreferencePagePython::PreferencePagePython(const Py::Object& p, QWidget* parent) QWidget* form = qobject_cast(object); if (form) { this->setWindowTitle(form->windowTitle()); - QVBoxLayout *layout = new QVBoxLayout; + auto layout = new QVBoxLayout; layout->addWidget(form); setLayout(layout); } @@ -361,7 +361,7 @@ ContainerDialog::ContainerDialog( QWidget* templChild ) buttonOk->setDefault( true ); MyDialogLayout->addWidget( buttonOk, 1, 0 ); - QSpacerItem* spacer = new QSpacerItem( 210, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + auto spacer = new QSpacerItem( 210, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); MyDialogLayout->addItem( spacer, 1, 1 ); buttonCancel = new QPushButton(this); @@ -510,7 +510,7 @@ bool PyResource::connect(const char* sender, const char* signal, PyObject* cb) } if (objS) { - SignalConnect* sc = new SignalConnect(this, cb); + auto sc = new SignalConnect(this, cb); mySignals.push_back(sc); return QObject::connect(objS, sigStr.toLatin1(), sc, SLOT ( onExecute() ) ); } diff --git a/src/Gui/Widgets.cpp b/src/Gui/Widgets.cpp index ace41e8ba3..1379f52ebc 100644 --- a/src/Gui/Widgets.cpp +++ b/src/Gui/Widgets.cpp @@ -95,10 +95,10 @@ void CommandIconView::startDrag (Qt::DropActions supportedActions) dataStream << (*it)->text(); } - QMimeData *mimeData = new QMimeData; + auto mimeData = new QMimeData; mimeData->setData(QString::fromLatin1("text/x-action-items"), itemData); - QDrag *drag = new QDrag(this); + auto drag = new QDrag(this); drag->setMimeData(mimeData); drag->setHotSpot(QPoint(pixmap.width()/2, pixmap.height()/2)); drag->setPixmap(pixmap); @@ -573,9 +573,9 @@ CheckListDialog::~CheckListDialog() */ void CheckListDialog::setCheckableItems( const QStringList& items ) { - for ( QStringList::ConstIterator it = items.begin(); it != items.end(); ++it ) { - QTreeWidgetItem* item = new QTreeWidgetItem(ui->treeWidget); - item->setText(0, *it); + for (const auto & it : items) { + auto item = new QTreeWidgetItem(ui->treeWidget); + item->setText(0, it); item->setCheckState(0, Qt::Unchecked); } } @@ -586,10 +586,10 @@ void CheckListDialog::setCheckableItems( const QStringList& items ) */ void CheckListDialog::setCheckableItems( const QList& items ) { - for ( QList::ConstIterator it = items.begin(); it != items.end(); ++it ) { - QTreeWidgetItem* item = new QTreeWidgetItem(ui->treeWidget); - item->setText(0, (*it).first); - item->setCheckState(0, ( (*it).second ? Qt::Checked : Qt::Unchecked)); + for (const auto & it : items) { + auto item = new QTreeWidgetItem(ui->treeWidget); + item->setText(0, it.first); + item->setCheckState(0, ( it.second ? Qt::Checked : Qt::Unchecked)); } } @@ -1037,7 +1037,7 @@ void StatefulLabel::setState(QString state) LabelButton::LabelButton (QWidget * parent) : QWidget(parent) { - QHBoxLayout *layout = new QHBoxLayout(this); + auto layout = new QHBoxLayout(this); layout->setMargin(0); layout->setSpacing(1); @@ -1165,7 +1165,7 @@ bool ToolTip::eventFilter(QObject* o, QEvent*e) // after it gets visible. We just filter out all timer events to keep the // label visible. if (o->inherits("QLabel")) { - QLabel* label = qobject_cast(o); + auto label = qobject_cast(o); // Ignore the timer events to prevent from being closed if (label->windowFlags() & Qt::ToolTip) { if (e->type() == QEvent::Show) { @@ -1192,7 +1192,7 @@ StatusWidget::StatusWidget(QWidget* parent) label = new QLabel(this); label->setAlignment(Qt::AlignCenter); - QGridLayout* gridLayout = new QGridLayout(this); + auto gridLayout = new QGridLayout(this); gridLayout->setSpacing(6); gridLayout->setMargin(9); gridLayout->addWidget(label, 0, 0, 1, 1); @@ -1361,7 +1361,7 @@ public: void accept() override { - PropertyListEditor* edit = this->findChild(); + auto edit = this->findChild(); QStringList lines; if (edit) { QString inputText = edit->toPlainText(); @@ -1402,7 +1402,7 @@ LabelEditor::LabelEditor (QWidget * parent) : QWidget(parent) { type = String; - QHBoxLayout *layout = new QHBoxLayout(this); + auto layout = new QHBoxLayout(this); layout->setMargin(0); layout->setSpacing(2); @@ -1450,11 +1450,11 @@ void LabelEditor::changeText() { PropertyListDialog dlg(static_cast(type), this); dlg.setWindowTitle(tr("List")); - QVBoxLayout* hboxLayout = new QVBoxLayout(&dlg); - QDialogButtonBox* buttonBox = new QDialogButtonBox(&dlg); + auto hboxLayout = new QVBoxLayout(&dlg); + auto buttonBox = new QDialogButtonBox(&dlg); buttonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); - PropertyListEditor *edit = new PropertyListEditor(&dlg); + auto edit = new PropertyListEditor(&dlg); edit->setPlainText(this->plainText); hboxLayout->addWidget(edit); @@ -1625,7 +1625,7 @@ void ExpLineEdit::openFormulaDialog() { Q_ASSERT(isBound()); - Gui::Dialog::DlgExpressionInput* box = new Gui::Dialog::DlgExpressionInput( + auto box = new Gui::Dialog::DlgExpressionInput( getPath(), getExpression(),Unit(), this); connect(box, SIGNAL(finished(int)), this, SLOT(finishFormulaDialog())); box->show(); @@ -1637,7 +1637,7 @@ void ExpLineEdit::openFormulaDialog() void ExpLineEdit::finishFormulaDialog() { - Gui::Dialog::DlgExpressionInput* box = qobject_cast(sender()); + auto box = qobject_cast(sender()); if (!box) { qWarning() << "Sender is not a Gui::Dialog::DlgExpressionInput"; return; diff --git a/src/Gui/Workbench.cpp b/src/Gui/Workbench.cpp index d545611a7a..17f81bc82a 100644 --- a/src/Gui/Workbench.cpp +++ b/src/Gui/Workbench.cpp @@ -257,31 +257,31 @@ void Workbench::setupCustomToolbars(ToolBarItem* root, const Base::Reference > hGrps = hGrp->GetGroups(); CommandManager& rMgr = Application::Instance->commandManager(); std::string separator = "Separator"; - for (std::vector >::iterator it = hGrps.begin(); it != hGrps.end(); ++it) { - bool active = (*it)->GetBool("Active", true); + for (const auto & it : hGrps) { + bool active = it->GetBool("Active", true); if (!active) // ignore this toolbar continue; - ToolBarItem* bar = new ToolBarItem(root); + auto bar = new ToolBarItem(root); bar->setCommand("Custom"); // get the elements of the subgroups - std::vector > items = hGrp->GetGroup((*it)->GetGroupName())->GetASCIIMap(); - for (std::vector >::iterator it2 = items.begin(); it2 != items.end(); ++it2) { - if (it2->first.substr(0, separator.size()) == separator) { + std::vector > items = hGrp->GetGroup(it->GetGroupName())->GetASCIIMap(); + for (const auto & item : items) { + if (item.first.substr(0, separator.size()) == separator) { *bar << "Separator"; } - else if (it2->first == "Name") { - bar->setCommand(it2->second); + else if (item.first == "Name") { + bar->setCommand(item.second); } else { - Command* pCmd = rMgr.getCommandByName(it2->first.c_str()); + Command* pCmd = rMgr.getCommandByName(item.first.c_str()); if (!pCmd) { // unknown command // first try the module name as is - std::string pyMod = it2->second; + std::string pyMod = item.second; try { Base::Interpreter().loadModule(pyMod.c_str()); // Try again - pCmd = rMgr.getCommandByName(it2->first.c_str()); + pCmd = rMgr.getCommandByName(item.first.c_str()); } catch(const Base::Exception&) { } @@ -290,18 +290,18 @@ void Workbench::setupCustomToolbars(ToolBarItem* root, const Base::Referencesecond + "Gui"; + std::string pyMod = item.second + "Gui"; try { Base::Interpreter().loadModule(pyMod.c_str()); // Try again - pCmd = rMgr.getCommandByName(it2->first.c_str()); + pCmd = rMgr.getCommandByName(item.first.c_str()); } catch(const Base::Exception&) { } } if (pCmd) { - *bar << it2->first; // command name + *bar << item.first; // command name } } } @@ -317,14 +317,14 @@ void Workbench::setupCustomShortcuts() const // Get all user defined shortcuts const CommandManager& cCmdMgr = Application::Instance->commandManager(); std::vector > items = hGrp->GetASCIIMap(); - for (std::vector >::iterator it = items.begin(); it != items.end(); ++it) { - Command* cmd = cCmdMgr.getCommandByName(it->first.c_str()); + for (const auto & item : items) { + Command* cmd = cCmdMgr.getCommandByName(item.first.c_str()); if (cmd && cmd->getAction()) { // may be UTF-8 encoded - QString str = QString::fromUtf8(it->second.c_str()); + QString str = QString::fromUtf8(item.second.c_str()); QKeySequence shortcut = str; cmd->getAction()->setShortcut(shortcut.toString(QKeySequence::NativeText)); - cmd->recreateTooltip(it->first.c_str(), cmd->getAction()); // The tooltip has the shortcut in it... + cmd->recreateTooltip(item.first.c_str(), cmd->getAction()); // The tooltip has the shortcut in it... } } } @@ -343,7 +343,7 @@ void Workbench::createMainWindowPopupMenu(MenuItem*) const void Workbench::createLinkMenu(MenuItem *item) { if(!item || !App::GetApplication().getActiveDocument()) return; - MenuItem* linkMenu = new MenuItem; + auto linkMenu = new MenuItem; linkMenu->setCommand("Link actions"); *linkMenu << "Std_LinkMakeGroup" << "Std_LinkMake"; @@ -352,18 +352,18 @@ void Workbench::createLinkMenu(MenuItem *item) { "Std_LinkImport","Std_LinkImportAll",nullptr,"Std_LinkSelectLinked", "Std_LinkSelectLinkedFinal","Std_LinkSelectAllLinks"}; bool separator = true; - for(size_t i=0;iisActive()) { separator = true; - *linkMenu << cmds[i]; + *linkMenu << i; } } *item << linkMenu; @@ -394,7 +394,7 @@ void Workbench::addPermanentMenuItems(MenuItem* mb) const Gui::MenuItem* item = par->findItem(it.second); item = par->afterItem(item); - Gui::MenuItem* add = new Gui::MenuItem(); + auto add = new Gui::MenuItem(); add->setCommand(it.first); par->insertItem(item, add); } @@ -467,8 +467,8 @@ std::list Workbench::listToolbars() const std::unique_ptr tb(setupToolBars()); std::list bars; QList items = tb->getItems(); - for (QList::ConstIterator item = items.cbegin(); item != items.cend(); ++item) - bars.push_back((*item)->command()); + for (const auto & item : items) + bars.push_back(item->command()); return bars; } @@ -478,14 +478,14 @@ std::list>> Workbench::getToolbarI std::list>> itemsList; QList items = tb->getItems(); - for (QList::ConstIterator it = items.cbegin(); it != items.cend(); ++it) { - QList sub = (*it)->getItems(); + for (const auto & item : items) { + QList sub = item->getItems(); std::list cmds; - for (QList::ConstIterator jt = sub.cbegin(); jt != sub.cend(); ++jt) { - cmds.push_back((*jt)->command()); + for (const auto & jt : sub) { + cmds.push_back(jt->command()); } - itemsList.emplace_back((*it)->command(), cmds); + itemsList.emplace_back(item->command(), cmds); } return itemsList; } @@ -495,8 +495,8 @@ std::list Workbench::listMenus() const std::unique_ptr mb(setupMenuBar()); std::list menus; QList items = mb->getItems(); - for ( QList::ConstIterator it = items.cbegin(); it != items.cend(); ++it ) - menus.push_back((*it)->command()); + for (const auto & item : items) + menus.push_back(item->command()); return menus; } @@ -505,8 +505,8 @@ std::list Workbench::listCommandbars() const std::unique_ptr cb(setupCommandBars()); std::list bars; QList items = cb->getItems(); - for (QList::ConstIterator item = items.cbegin(); item != items.cend(); ++item) - bars.push_back((*item)->command()); + for (const auto & item : items) + bars.push_back(item->command()); return bars; } @@ -578,14 +578,14 @@ void StdWorkbench::setupContextMenu(const char* recipient, MenuItem* item) const createLinkMenu(item); *item << "Separator"; - MenuItem* StdViews = new MenuItem; + auto StdViews = new MenuItem; StdViews->setCommand( "Standard views" ); *StdViews << "Std_ViewIsometric" << "Separator" << "Std_ViewHome" << "Std_ViewFront" << "Std_ViewTop" << "Std_ViewRight" << "Std_ViewRear" << "Std_ViewBottom" << "Std_ViewLeft" << "Separator" << "Std_ViewRotateLeft" << "Std_ViewRotateRight"; - MenuItem *measure = new MenuItem(); + auto measure = new MenuItem(); measure->setCommand("Measure"); *measure << "View_Measure_Toggle_All" << "View_Measure_Clear_All"; @@ -619,10 +619,10 @@ void StdWorkbench::createMainWindowPopupMenu(MenuItem* item) const MenuItem* StdWorkbench::setupMenuBar() const { // Setup the default menu bar - MenuItem* menuBar = new MenuItem; + auto menuBar = new MenuItem; // File - MenuItem* file = new MenuItem( menuBar ); + auto file = new MenuItem( menuBar ); file->setCommand("&File"); *file << "Std_New" << "Std_Open" << "Separator" << "Std_CloseActiveWindow" << "Std_CloseAllWindows" << "Separator" << "Std_Save" << "Std_SaveAs" @@ -632,7 +632,7 @@ MenuItem* StdWorkbench::setupMenuBar() const << "Separator" << "Std_RecentFiles" << "Separator" << "Std_Quit"; // Edit - MenuItem* edit = new MenuItem( menuBar ); + auto edit = new MenuItem( menuBar ); edit->setCommand("&Edit"); *edit << "Std_Undo" << "Std_Redo" << "Separator" << "Std_Cut" << "Std_Copy" << "Std_Paste" << "Std_DuplicateSelection" << "Separator" @@ -641,14 +641,14 @@ MenuItem* StdWorkbench::setupMenuBar() const << "Separator" << "Std_Placement" << "Std_TransformManip" << "Std_Alignment" << "Std_Edit" << "Separator" << "Std_UserEditMode" << "Separator" << "Std_DlgPreferences"; - MenuItem* axoviews = new MenuItem; + auto axoviews = new MenuItem; axoviews->setCommand("Axonometric"); *axoviews << "Std_ViewIsometric" << "Std_ViewDimetric" << "Std_ViewTrimetric"; // Standard views - MenuItem* stdviews = new MenuItem; + auto stdviews = new MenuItem; stdviews->setCommand("Standard views"); *stdviews << "Std_ViewFitAll" << "Std_ViewFitSelection" << axoviews << "Separator" << "Std_ViewHome" << "Std_ViewFront" << "Std_ViewTop" @@ -657,19 +657,19 @@ MenuItem* StdWorkbench::setupMenuBar() const << "Separator" << "Std_ViewRotateLeft" << "Std_ViewRotateRight"; // stereo - MenuItem* view3d = new MenuItem; + auto view3d = new MenuItem; view3d->setCommand("&Stereo"); *view3d << "Std_ViewIvStereoRedGreen" << "Std_ViewIvStereoQuadBuff" << "Std_ViewIvStereoInterleavedRows" << "Std_ViewIvStereoInterleavedColumns" << "Std_ViewIvStereoOff" << "Separator" << "Std_ViewIvIssueCamPos"; // zoom - MenuItem* zoom = new MenuItem; + auto zoom = new MenuItem; zoom->setCommand("&Zoom"); *zoom << "Std_ViewZoomIn" << "Std_ViewZoomOut" << "Separator" << "Std_ViewBoxZoom"; // Visibility - MenuItem* visu = new MenuItem; + auto visu = new MenuItem; visu->setCommand("Visibility"); *visu << "Std_ToggleVisibility" << "Std_ShowSelection" << "Std_HideSelection" << "Std_SelectVisibleObjects" @@ -678,7 +678,7 @@ MenuItem* StdWorkbench::setupMenuBar() const << "Separator" << "View_Measure_Toggle_All" << "View_Measure_Clear_All"; // View - MenuItem* view = new MenuItem( menuBar ); + auto view = new MenuItem( menuBar ); view->setCommand("&View"); *view << "Std_ViewCreate" << "Std_OrthographicCamera" << "Std_PerspectiveCamera" << "Std_MainFullscreen" << "Separator" << stdviews << "Std_FreezeViews" << "Std_DrawStyle" << "Std_SelBoundingBox" @@ -696,7 +696,7 @@ MenuItem* StdWorkbench::setupMenuBar() const << "Std_ViewStatusBar"; // Tools - MenuItem* tool = new MenuItem( menuBar ); + auto tool = new MenuItem( menuBar ); tool->setCommand("&Tools"); *tool << "Std_DlgParameter" << "Separator" @@ -718,7 +718,7 @@ MenuItem* StdWorkbench::setupMenuBar() const #endif // Macro - MenuItem* macro = new MenuItem( menuBar ); + auto macro = new MenuItem( menuBar ); macro->setCommand("&Macro"); *macro << "Std_DlgMacroRecord" << "Std_MacroStopRecord" @@ -734,18 +734,18 @@ MenuItem* StdWorkbench::setupMenuBar() const << "Std_ToggleBreakpoint"; // Windows - MenuItem* wnd = new MenuItem( menuBar ); + auto wnd = new MenuItem( menuBar ); wnd->setCommand("&Windows"); *wnd << "Std_ActivateNextWindow" << "Std_ActivatePrevWindow" << "Separator" << "Std_TileWindows" << "Std_CascadeWindows" << "Std_ArrangeIcons" << "Separator" << "Std_WindowsMenu" << "Std_Windows"; // Separator - MenuItem* sep = new MenuItem( menuBar ); + auto sep = new MenuItem( menuBar ); sep->setCommand( "Separator" ); // Help - MenuItem* help = new MenuItem( menuBar ); + auto help = new MenuItem( menuBar ); help->setCommand("&Help"); *help << "Std_OnlineHelp" << "Std_FreeCADWebsite" << "Std_FreeCADDonation" << "Std_FreeCADUserHub" << "Std_FreeCADPowerUserHub" @@ -757,28 +757,28 @@ MenuItem* StdWorkbench::setupMenuBar() const ToolBarItem* StdWorkbench::setupToolBars() const { - ToolBarItem* root = new ToolBarItem; + auto root = new ToolBarItem; // File - ToolBarItem* file = new ToolBarItem( root ); + auto file = new ToolBarItem( root ); file->setCommand("File"); *file << "Std_New" << "Std_Open" << "Std_Save" << "Std_Print" << "Separator" << "Std_Cut" << "Std_Copy" << "Std_Paste" << "Separator" << "Std_Undo" << "Std_Redo" << "Separator" << "Std_UserEditMode" << "Separator" << "Std_Refresh" << "Separator" << "Std_WhatsThis"; // Workbench switcher - ToolBarItem* wb = new ToolBarItem( root ); + auto wb = new ToolBarItem( root ); wb->setCommand("Workbench"); *wb << "Std_Workbench"; // Macro - ToolBarItem* macro = new ToolBarItem( root ); + auto macro = new ToolBarItem( root ); macro->setCommand("Macro"); *macro << "Std_DlgMacroRecord" << "Std_MacroStopRecord" << "Std_DlgMacroExecute" << "Std_DlgMacroExecuteDirect"; // View - ToolBarItem* view = new ToolBarItem( root ); + auto view = new ToolBarItem( root ); view->setCommand("View"); *view << "Std_ViewFitAll" << "Std_ViewFitSelection" << "Std_DrawStyle" << "Std_SelBoundingBox" << "Separator" << "Std_SelBack" << "Std_SelForward" << "Std_LinkSelectActions" @@ -787,7 +787,7 @@ ToolBarItem* StdWorkbench::setupToolBars() const << "Std_ViewLeft" << "Separator" << "Std_MeasureDistance" ; // Structure - ToolBarItem* structure = new ToolBarItem( root ); + auto structure = new ToolBarItem( root ); structure->setCommand("Structure"); *structure << "Std_Part" << "Std_Group" << "Std_LinkMake" << "Std_LinkActions"; @@ -796,16 +796,16 @@ ToolBarItem* StdWorkbench::setupToolBars() const ToolBarItem* StdWorkbench::setupCommandBars() const { - ToolBarItem* root = new ToolBarItem; + auto root = new ToolBarItem; // View - ToolBarItem* view = new ToolBarItem( root ); + auto view = new ToolBarItem( root ); view->setCommand("Standard views"); *view << "Std_ViewFitAll" << "Std_ViewFitSelection" << "Std_ViewIsometric" << "Separator" << "Std_ViewFront" << "Std_ViewRight" << "Std_ViewTop" << "Separator" << "Std_ViewRear" << "Std_ViewLeft" << "Std_ViewBottom"; // Special Ops - ToolBarItem* macro = new ToolBarItem( root ); + auto macro = new ToolBarItem( root ); macro->setCommand("Special Ops"); *macro << "Std_DlgParameter" << "Std_DlgPreferences" << "Std_DlgMacroRecord" << "Std_MacroStopRecord" << "Std_DlgMacroExecute" << "Std_DlgCustomize"; @@ -815,7 +815,7 @@ ToolBarItem* StdWorkbench::setupCommandBars() const DockWindowItems* StdWorkbench::setupDockWindows() const { - DockWindowItems* root = new DockWindowItems(); + auto root = new DockWindowItems(); root->addDockWidget("Std_ToolBox", Qt::RightDockWidgetArea, false, false); //root->addDockWidget("Std_HelpView", Qt::RightDockWidgetArea, true, false); root->addDockWidget("Std_TreeView", Qt::LeftDockWidgetArea, true, false); @@ -852,8 +852,8 @@ BlankWorkbench::~BlankWorkbench() void BlankWorkbench::activated() { QList dw = getMainWindow()->findChildren(); - for (QList::iterator it = dw.begin(); it != dw.end(); ++it) - (*it)->toggleViewAction()->setVisible(false); + for (auto & it : dw) + it->toggleViewAction()->setVisible(false); getMainWindow()->statusBar()->hide(); } @@ -910,29 +910,29 @@ void NoneWorkbench::setupContextMenu(const char* recipient,MenuItem* item) const MenuItem* NoneWorkbench::setupMenuBar() const { // Setup the default menu bar - MenuItem* menuBar = new MenuItem; + auto menuBar = new MenuItem; // File - MenuItem* file = new MenuItem( menuBar ); + auto file = new MenuItem( menuBar ); file->setCommand("&File"); *file << "Std_Quit"; // Edit - MenuItem* edit = new MenuItem( menuBar ); + auto edit = new MenuItem( menuBar ); edit->setCommand("&Edit"); *edit << "Std_DlgPreferences"; // View - MenuItem* view = new MenuItem( menuBar ); + auto view = new MenuItem( menuBar ); view->setCommand("&View"); *view << "Std_Workbench"; // Separator - MenuItem* sep = new MenuItem( menuBar ); + auto sep = new MenuItem( menuBar ); sep->setCommand("Separator"); // Help - MenuItem* help = new MenuItem( menuBar ); + auto help = new MenuItem( menuBar ); help->setCommand("&Help"); *help << "Std_OnlineHelp" << "Std_About"; @@ -941,19 +941,19 @@ MenuItem* NoneWorkbench::setupMenuBar() const ToolBarItem* NoneWorkbench::setupToolBars() const { - ToolBarItem* root = new ToolBarItem; + auto root = new ToolBarItem; return root; } ToolBarItem* NoneWorkbench::setupCommandBars() const { - ToolBarItem* root = new ToolBarItem; + auto root = new ToolBarItem; return root; } DockWindowItems* NoneWorkbench::setupDockWindows() const { - DockWindowItems* root = new DockWindowItems(); + auto root = new DockWindowItems(); root->addDockWidget("Std_ReportView", Qt::BottomDockWidgetArea, true, false); return root; } @@ -980,14 +980,14 @@ MenuItem* TestWorkbench::setupMenuBar() const item->removeItem(item->findItem("Std_WhatsThis")); // Test commands - MenuItem* test = new MenuItem; + auto test = new MenuItem; menuBar->insertItem( item, test ); test->setCommand( "Test &Commands" ); *test << "Std_Test1" << "Std_Test2" << "Std_Test3" << "Std_Test4" << "Std_Test5" << "Std_Test6" << "Std_Test7" << "Std_Test8"; // Inventor View - MenuItem* opiv = new MenuItem; + auto opiv = new MenuItem; menuBar->insertItem( item, opiv ); opiv->setCommand("&Inventor View"); *opiv << "Std_ViewExample1" << "Std_ViewExample2" << "Std_ViewExample3"; @@ -1063,8 +1063,8 @@ void PythonBaseWorkbench::setupContextMenu(const char* recipient, MenuItem* item { Q_UNUSED(recipient); QList items = _contextMenu->getItems(); - for (QList::Iterator it = items.begin(); it != items.end(); ++it) { - item->appendItem((*it)->copy()); + for (const auto & it : items) { + item->appendItem(it->copy()); } } @@ -1073,7 +1073,7 @@ void PythonBaseWorkbench::appendMenu(const std::list& menu, const s if ( menu.empty() || items.empty() ) return; - std::list::const_iterator jt=menu.begin(); + auto jt=menu.begin(); MenuItem* item = _menuBar->findItem( *jt ); if (!item) { @@ -1098,8 +1098,8 @@ void PythonBaseWorkbench::appendMenu(const std::list& menu, const s item = subitem; } - for (std::list::const_iterator it = items.begin(); it != items.end(); ++it) - *item << *it; + for (const auto & it : items) + *item << it; } void PythonBaseWorkbench::removeMenu(const std::string& menu) const @@ -1114,17 +1114,17 @@ void PythonBaseWorkbench::removeMenu(const std::string& menu) const void PythonBaseWorkbench::appendContextMenu(const std::list& menu, const std::list& items) const { MenuItem* item = _contextMenu; - for (std::list::const_iterator jt=menu.begin();jt!=menu.end();++jt) { - MenuItem* subitem = item->findItem(*jt); + for (const auto & jt : menu) { + MenuItem* subitem = item->findItem(jt); if (!subitem) { subitem = new MenuItem(item); - subitem->setCommand(*jt); + subitem->setCommand(jt); } item = subitem; } - for (std::list::const_iterator it = items.begin(); it != items.end(); ++it) - *item << *it; + for (const auto & it : items) + *item << it; } void PythonBaseWorkbench::removeContextMenu(const std::string& menu) const @@ -1150,8 +1150,8 @@ void PythonBaseWorkbench::appendToolbar(const std::string& bar, const std::list< item->setCommand(bar); } - for (std::list::const_iterator it = items.begin(); it != items.end(); ++it) - *item << *it; + for (const auto & it : items) + *item << it; } void PythonBaseWorkbench::removeToolbar(const std::string& bar) const @@ -1172,8 +1172,8 @@ void PythonBaseWorkbench::appendCommandbar(const std::string& bar, const std::li item->setCommand(bar); } - for (std::list::const_iterator it = items.begin(); it != items.end(); ++it) - *item << *it; + for (const auto & it : items) + *item << it; } void PythonBaseWorkbench::removeCommandbar(const std::string& bar) const diff --git a/src/Gui/WorkbenchFactory.cpp b/src/Gui/WorkbenchFactory.cpp index f8a364c2fa..4ceac26a63 100644 --- a/src/Gui/WorkbenchFactory.cpp +++ b/src/Gui/WorkbenchFactory.cpp @@ -46,8 +46,8 @@ void WorkbenchFactoryInst::destruct () Workbench* WorkbenchFactoryInst::createWorkbench ( const char* sName ) const { - Workbench* obj = (Workbench*)Produce( sName ); - Workbench* w = dynamic_cast(obj); + auto obj = (Workbench*)Produce( sName ); + auto w = dynamic_cast(obj); if ( !w ) { delete obj; // delete the unknown object as no workbench object diff --git a/src/Gui/WorkbenchPyImp.cpp b/src/Gui/WorkbenchPyImp.cpp index a9beff4a50..08366caf10 100644 --- a/src/Gui/WorkbenchPyImp.cpp +++ b/src/Gui/WorkbenchPyImp.cpp @@ -83,8 +83,8 @@ PyObject* WorkbenchPy::listMenus(PyObject *args) std::list menus = getWorkbenchPtr()->listMenus(); Py::List list; - for (std::list::iterator it = menus.begin(); it != menus.end(); ++it) { - list.append(Py::String(*it)); + for (const auto & menu : menus) { + list.append(Py::String(menu)); } return Py::new_reference_to(list); } PY_CATCH; @@ -100,8 +100,8 @@ PyObject* WorkbenchPy::listToolbars(PyObject *args) std::list bars = getWorkbenchPtr()->listToolbars(); Py::List list; - for (std::list::iterator it = bars.begin(); it != bars.end(); ++it) { - list.append(Py::String(*it)); + for (const auto & bar : bars) { + list.append(Py::String(bar)); } return Py::new_reference_to(list); } PY_CATCH; @@ -138,8 +138,8 @@ PyObject* WorkbenchPy::listCommandbars(PyObject *args) std::list bars = getWorkbenchPtr()->listCommandbars(); Py::List list; - for (std::list::iterator it = bars.begin(); it != bars.end(); ++it) { - list.append(Py::String(*it)); + for (const auto & bar : bars) { + list.append(Py::String(bar)); } return Py::new_reference_to(list); } PY_CATCH; diff --git a/src/Gui/propertyeditor/PropertyEditor.cpp b/src/Gui/propertyeditor/PropertyEditor.cpp index 9e30f98e39..9c3b89ab68 100644 --- a/src/Gui/propertyeditor/PropertyEditor.cpp +++ b/src/Gui/propertyeditor/PropertyEditor.cpp @@ -109,7 +109,7 @@ bool PropertyEditor::isAutomaticExpand(bool) const void PropertyEditor::onItemExpanded(const QModelIndex &index) { - PropertyItem* item = static_cast(index.internalPointer()); + auto item = static_cast(index.internalPointer()); item->setExpanded(true); for(int i=0, c=item->childCount(); iindex(i, 0, index), item->child(i)->isExpanded()); @@ -117,7 +117,7 @@ void PropertyEditor::onItemExpanded(const QModelIndex &index) void PropertyEditor::onItemCollapsed(const QModelIndex &index) { - PropertyItem* item = static_cast(index.internalPointer()); + auto item = static_cast(index.internalPointer()); item->setExpanded(false); } @@ -161,7 +161,7 @@ QStyleOptionViewItem PropertyEditor::viewOptions() const bool PropertyEditor::event(QEvent* event) { if (event->type() == QEvent::ShortcutOverride) { - QKeyEvent * kevent = static_cast(event); + auto kevent = static_cast(event); Qt::KeyboardModifiers ShiftKeypadModifier = Qt::ShiftModifier | Qt::KeypadModifier; if (kevent->modifiers() == Qt::NoModifier || kevent->modifiers() == Qt::ShiftModifier || @@ -251,7 +251,7 @@ void PropertyEditor::openEditor(const QModelIndex &index) FC_LOG("editor already transacting " << app.getActiveTransaction()); return; } - PropertyItem* item = static_cast(editingIndex.internalPointer()); + auto item = static_cast(editingIndex.internalPointer()); auto items = item->getPropertyData(); for(auto propItem=item->parent();items.empty() && propItem;propItem=propItem->parent()) items = propItem->getPropertyData(); @@ -392,7 +392,7 @@ void PropertyEditor::closeEditor (QWidget * editor, QAbstractItemDelegate::EndEd lastIndex = index; setCurrentIndex(propertyModel->buddy(index)); - PropertyItem *item = static_cast(index.internalPointer()); + auto item = static_cast(index.internalPointer()); // Skip readonly item, because the editor will be disabled and hence // does not accept focus, and in turn break Tab/Backtab navigation. if (item && item->isReadOnly()) @@ -413,7 +413,7 @@ void PropertyEditor::reset() int numRows = propertyModel->rowCount(parent); for (int i=0; iindex(i, 0, parent); - PropertyItem *item = static_cast(index.internalPointer()); + auto item = static_cast(index.internalPointer()); if (item->childCount() == 0) { if(item->isSeparator()) setRowHidden(i, parent, true); @@ -427,7 +427,7 @@ void PropertyEditor::reset() void PropertyEditor::onRowsMoved(const QModelIndex &parent, int start, int end, const QModelIndex &dst, int) { if(parent != dst) { - PropertyItem *item = static_cast(parent.internalPointer()); + auto item = static_cast(parent.internalPointer()); if(item && item->isSeparator() && item->childCount()==0) setRowHidden(parent.row(), propertyModel->parent(parent), true); item = static_cast(dst.internalPointer()); @@ -442,7 +442,7 @@ void PropertyEditor::rowsInserted (const QModelIndex & parent, int start, int en { QTreeView::rowsInserted(parent, start, end); - PropertyItem *item = static_cast(parent.internalPointer()); + auto item = static_cast(parent.internalPointer()); if (item && item->isSeparator() && item->childCount() == end-start+1) { setRowHidden(parent.row(), propertyModel->parent(parent), false); if(item->isExpanded()) @@ -451,7 +451,7 @@ void PropertyEditor::rowsInserted (const QModelIndex & parent, int start, int en for (int i=start; iindex(i, 0, parent); - PropertyItem *child = static_cast(index.internalPointer()); + auto child = static_cast(index.internalPointer()); if(child->isSeparator()) { // Set group header rows to span all columns setFirstColumnSpanned(i, parent, true); @@ -468,7 +468,7 @@ void PropertyEditor::rowsAboutToBeRemoved (const QModelIndex & parent, int start { QTreeView::rowsAboutToBeRemoved(parent, start, end); - PropertyItem *item = static_cast(parent.internalPointer()); + auto item = static_cast(parent.internalPointer()); if (item && item->isSeparator() && item->childCount() == end-start+1) setRowHidden(parent.row(), propertyModel->parent(parent), true); @@ -499,7 +499,7 @@ void PropertyEditor::drawBranches(QPainter *painter, const QRect &rect, const QM QTreeView::drawBranches(painter, rect, index); QStyleOptionViewItem opt = viewOptions(); - PropertyItem *property = static_cast(index.internalPointer()); + auto property = static_cast(index.internalPointer()); if (property && property->isSeparator()) { painter->fillRect(rect, this->background); //} else if (selectionModel()->isSelected(index)) { @@ -568,7 +568,7 @@ void PropertyEditor::setEditorMode(const QModelIndex & parent, int start, int en int column = 1; for (int i=start; i<=end; i++) { QModelIndex item = propertyModel->index(i, column, parent); - PropertyItem* propItem = static_cast(item.internalPointer()); + auto propItem = static_cast(item.internalPointer()); if (!PropertyView::showAll() && propItem && propItem->testStatus(App::Property::Hidden)) { setRowHidden (i, parent, true); } diff --git a/src/Gui/propertyeditor/PropertyItem.cpp b/src/Gui/propertyeditor/PropertyItem.cpp index 4a3696cab5..2d71e821d9 100644 --- a/src/Gui/propertyeditor/PropertyItem.cpp +++ b/src/Gui/propertyeditor/PropertyItem.cpp @@ -82,7 +82,7 @@ void PropertyItemFactory::destruct () PropertyItem* PropertyItemFactory::createPropertyItem (const char* sName) const { - PropertyItem* w = static_cast(Produce(sName)); + auto w = static_cast(Produce(sName)); return w; } @@ -151,7 +151,7 @@ void PropertyItem::setPropertyData(const std::vector& items) try { // Check for 'DocumentObject' as parent because otherwise 'ObjectIdentifier' raises an exception - App::DocumentObject * docObj = Base::freecad_dynamic_cast(p.getContainer()); + auto * docObj = Base::freecad_dynamic_cast(p.getContainer()); if (docObj && !docObj->isReadOnly(&p)) { App::ObjectIdentifier id(p); std::vector paths; @@ -456,7 +456,7 @@ QWidget* PropertyItem::createExpressionEditor(QWidget* parent, const QObject* re { if(!isBound()) return nullptr; - ExpLineEdit *le = new ExpLineEdit(parent,true); + auto le = new ExpLineEdit(parent,true); le->setFrame(false); le->setReadOnly(true); QObject::connect(le, SIGNAL(textChanged(const QString&)), receiver, method); @@ -467,14 +467,14 @@ QWidget* PropertyItem::createExpressionEditor(QWidget* parent, const QObject* re void PropertyItem::setExpressionEditorData(QWidget *editor, const QVariant& data) const { - QLineEdit *le = qobject_cast(editor); + auto le = qobject_cast(editor); if(le) le->setText(data.toString()); } QVariant PropertyItem::expressionEditorData(QWidget *editor) const { - QLineEdit *le = qobject_cast(editor); + auto le = qobject_cast(editor); if(le) return QVariant(le->text()); return QVariant(); @@ -482,7 +482,7 @@ QVariant PropertyItem::expressionEditorData(QWidget *editor) const PropertyEditorWidget* PropertyItem::createPropertyEditorWidget(QWidget* parent) const { - PropertyEditorWidget* editor = new PropertyEditorWidget(parent); + auto editor = new PropertyEditorWidget(parent); connect(editor, &PropertyEditorWidget::buttonClick, this, [this]() { const auto &props = this->getPropertyData(); if (!props.empty() @@ -514,8 +514,8 @@ void PropertyItem::setPropertyName(QString name, QString realName) QString display; bool upper = false; - for (int i=0; iisDerivedFrom(App::Document::getClassTypeId())) { - App::Document* doc = static_cast(parent); + auto doc = static_cast(parent); ss << "FreeCAD.getDocument('" << doc->getName() << "')."; } else if (parent->isDerivedFrom(App::DocumentObject::getClassTypeId())) { - App::DocumentObject* obj = static_cast(parent); + auto obj = static_cast(parent); App::Document* doc = obj->getDocument(); ss << "FreeCAD.getDocument('" << doc->getName() << "').getObject('" << obj->getNameInDocument() << "')."; @@ -770,7 +770,7 @@ void PropertyStringItem::setValue(const QVariant& value) QWidget* PropertyStringItem::createEditor(QWidget* parent, const QObject* receiver, const char* method) const { - ExpLineEdit *le = new ExpLineEdit(parent); + auto le = new ExpLineEdit(parent); le->setFrame(false); le->setReadOnly(isReadOnly()); QObject::connect(le, SIGNAL(textChanged(const QString&)), receiver, method); @@ -784,13 +784,13 @@ QWidget* PropertyStringItem::createEditor(QWidget* parent, const QObject* receiv void PropertyStringItem::setEditorData(QWidget *editor, const QVariant& data) const { - QLineEdit *le = qobject_cast(editor); + auto le = qobject_cast(editor); le->setText(data.toString()); } QVariant PropertyStringItem::editorData(QWidget *editor) const { - QLineEdit *le = qobject_cast(editor); + auto le = qobject_cast(editor); return QVariant(le->text()); } @@ -821,7 +821,7 @@ void PropertyFontItem::setValue(const QVariant& value) QWidget* PropertyFontItem::createEditor(QWidget* parent, const QObject* receiver, const char* method) const { - QComboBox *cb = new QComboBox(parent); + auto cb = new QComboBox(parent); cb->setFrame(false); cb->setDisabled(isReadOnly()); QObject::connect(cb, SIGNAL(activated(const QString&)), receiver, method); @@ -830,7 +830,7 @@ QWidget* PropertyFontItem::createEditor(QWidget* parent, const QObject* receiver void PropertyFontItem::setEditorData(QWidget *editor, const QVariant& data) const { - QComboBox *cb = qobject_cast(editor); + auto cb = qobject_cast(editor); QFontDatabase fdb; QStringList familyNames = fdb.families(QFontDatabase::Any); cb->addItems(familyNames); @@ -840,7 +840,7 @@ void PropertyFontItem::setEditorData(QWidget *editor, const QVariant& data) cons QVariant PropertyFontItem::editorData(QWidget *editor) const { - QComboBox *cb = qobject_cast(editor); + auto cb = qobject_cast(editor); return QVariant(cb->currentText()); } @@ -886,7 +886,7 @@ void PropertyIntegerItem::setValue(const QVariant& value) QWidget* PropertyIntegerItem::createEditor(QWidget* parent, const QObject* receiver, const char* method) const { - Gui::IntSpinBox *sb = new Gui::IntSpinBox(parent); + auto sb = new Gui::IntSpinBox(parent); sb->setFrame(false); sb->setReadOnly(isReadOnly()); QObject::connect(sb, SIGNAL(valueChanged(int)), receiver, method); @@ -901,14 +901,14 @@ QWidget* PropertyIntegerItem::createEditor(QWidget* parent, const QObject* recei void PropertyIntegerItem::setEditorData(QWidget *editor, const QVariant& data) const { - QSpinBox *sb = qobject_cast(editor); + auto sb = qobject_cast(editor); sb->setRange(INT_MIN, INT_MAX); sb->setValue(data.toInt()); } QVariant PropertyIntegerItem::editorData(QWidget *editor) const { - QSpinBox *sb = qobject_cast(editor); + auto sb = qobject_cast(editor); return QVariant(sb->value()); } @@ -953,7 +953,7 @@ void PropertyIntegerConstraintItem::setValue(const QVariant& value) QWidget* PropertyIntegerConstraintItem::createEditor(QWidget* parent, const QObject* receiver, const char* method) const { - Gui::IntSpinBox *sb = new Gui::IntSpinBox(parent); + auto sb = new Gui::IntSpinBox(parent); sb->setFrame(false); sb->setReadOnly(isReadOnly()); QObject::connect(sb, SIGNAL(valueChanged(int)), receiver, method); @@ -968,7 +968,7 @@ QWidget* PropertyIntegerConstraintItem::createEditor(QWidget* parent, const QObj void PropertyIntegerConstraintItem::setEditorData(QWidget *editor, const QVariant& data) const { - const App::PropertyIntegerConstraint* prop = static_cast + const auto prop = static_cast (getFirstProperty()); const App::PropertyIntegerConstraint::Constraints* c = nullptr; @@ -976,7 +976,7 @@ void PropertyIntegerConstraintItem::setEditorData(QWidget *editor, const QVarian c = prop->getConstraints(); } - QSpinBox *sb = qobject_cast(editor); + auto sb = qobject_cast(editor); if (c) { sb->setMinimum(c->LowerBound); sb->setMaximum(c->UpperBound); @@ -991,7 +991,7 @@ void PropertyIntegerConstraintItem::setEditorData(QWidget *editor, const QVarian QVariant PropertyIntegerConstraintItem::editorData(QWidget *editor) const { - QSpinBox *sb = qobject_cast(editor); + auto sb = qobject_cast(editor); return QVariant(sb->value()); } @@ -1047,7 +1047,7 @@ void PropertyFloatItem::setValue(const QVariant& value) QWidget* PropertyFloatItem::createEditor(QWidget* parent, const QObject* receiver, const char* method) const { - Gui::DoubleSpinBox *sb = new Gui::DoubleSpinBox(parent); + auto sb = new Gui::DoubleSpinBox(parent); sb->setFrame(false); sb->setDecimals(decimals()); sb->setReadOnly(isReadOnly()); @@ -1063,14 +1063,14 @@ QWidget* PropertyFloatItem::createEditor(QWidget* parent, const QObject* receive void PropertyFloatItem::setEditorData(QWidget *editor, const QVariant& data) const { - QDoubleSpinBox *sb = qobject_cast(editor); + auto sb = qobject_cast(editor); sb->setRange((double)INT_MIN, (double)INT_MAX); sb->setValue(data.toDouble()); } QVariant PropertyFloatItem::editorData(QWidget *editor) const { - QDoubleSpinBox *sb = qobject_cast(editor); + auto sb = qobject_cast(editor); return QVariant(sb->value()); } @@ -1117,7 +1117,7 @@ void PropertyUnitItem::setValue(const QVariant& value) QWidget* PropertyUnitItem::createEditor(QWidget* parent, const QObject* receiver, const char* method) const { - Gui::QuantitySpinBox *infield = new Gui::QuantitySpinBox(parent); + auto infield = new Gui::QuantitySpinBox(parent); infield->setFrame(false); infield->setMinimumHeight(0); infield->setReadOnly(isReadOnly()); @@ -1137,14 +1137,14 @@ void PropertyUnitItem::setEditorData(QWidget *editor, const QVariant& data) cons { const Base::Quantity& value = data.value(); - Gui::QuantitySpinBox *infield = qobject_cast(editor); + auto infield = qobject_cast(editor); infield->setValue(value); infield->selectAll(); } QVariant PropertyUnitItem::editorData(QWidget *editor) const { - Gui::QuantitySpinBox *infield = qobject_cast(editor); + auto infield = qobject_cast(editor); Base::Quantity value = infield->value(); return QVariant::fromValue(value); } @@ -1163,11 +1163,11 @@ void PropertyUnitConstraintItem::setEditorData(QWidget *editor, const QVariant& { const Base::Quantity& value = data.value(); - Gui::QuantitySpinBox *infield = qobject_cast(editor); + auto infield = qobject_cast(editor); infield->setValue(value); infield->selectAll(); - const App::PropertyQuantityConstraint* prop = static_cast + const auto prop = static_cast (getFirstProperty()); const App::PropertyQuantityConstraint::Constraints* c = nullptr; @@ -1223,7 +1223,7 @@ void PropertyFloatConstraintItem::setValue(const QVariant& value) QWidget* PropertyFloatConstraintItem::createEditor(QWidget* parent, const QObject* receiver, const char* method) const { - Gui::DoubleSpinBox *sb = new Gui::DoubleSpinBox(parent); + auto sb = new Gui::DoubleSpinBox(parent); sb->setDecimals(decimals()); sb->setFrame(false); sb->setReadOnly(isReadOnly()); @@ -1239,7 +1239,7 @@ QWidget* PropertyFloatConstraintItem::createEditor(QWidget* parent, const QObjec void PropertyFloatConstraintItem::setEditorData(QWidget *editor, const QVariant& data) const { - const App::PropertyFloatConstraint* prop = static_cast + const auto prop = static_cast (getFirstProperty()); const App::PropertyFloatConstraint::Constraints* c = nullptr; @@ -1247,7 +1247,7 @@ void PropertyFloatConstraintItem::setEditorData(QWidget *editor, const QVariant& c = prop->getConstraints(); } - QDoubleSpinBox *sb = qobject_cast(editor); + auto sb = qobject_cast(editor); if (c) { sb->setMinimum(c->LowerBound); sb->setMaximum(c->UpperBound); @@ -1263,7 +1263,7 @@ void PropertyFloatConstraintItem::setEditorData(QWidget *editor, const QVariant& QVariant PropertyFloatConstraintItem::editorData(QWidget *editor) const { - QDoubleSpinBox *sb = qobject_cast(editor); + auto sb = qobject_cast(editor); return QVariant(sb->value()); } @@ -1321,7 +1321,7 @@ void PropertyBoolItem::setValue(const QVariant& value) QWidget* PropertyBoolItem::createEditor(QWidget* parent, const QObject* receiver, const char* method) const { - QComboBox *cb = new QComboBox(parent); + auto cb = new QComboBox(parent); cb->setFrame(false); cb->addItem(QLatin1String("false")); cb->addItem(QLatin1String("true")); @@ -1332,13 +1332,13 @@ QWidget* PropertyBoolItem::createEditor(QWidget* parent, const QObject* receiver void PropertyBoolItem::setEditorData(QWidget *editor, const QVariant& data) const { - QComboBox *cb = qobject_cast(editor); + auto cb = qobject_cast(editor); cb->setCurrentIndex(cb->findText(data.toString())); } QVariant PropertyBoolItem::editorData(QWidget *editor) const { - QComboBox *cb = qobject_cast(editor); + auto cb = qobject_cast(editor); return QVariant(cb->currentText()); } @@ -1431,7 +1431,7 @@ void PropertyVectorItem::setValue(const QVariant& value) QWidget* PropertyVectorItem::createEditor(QWidget* parent, const QObject* /*receiver*/, const char* /*method*/) const { - VectorLineEdit *le = new VectorLineEdit(decimals(), parent); + auto le = new VectorLineEdit(decimals(), parent); le->setFrame(false); le->setReadOnly(true); @@ -1446,7 +1446,7 @@ QWidget* PropertyVectorItem::createEditor(QWidget* parent, const QObject* /*rece void PropertyVectorItem::setEditorData(QWidget *editor, const QVariant& data) const { QLocale loc; - QLineEdit* le = qobject_cast(editor); + auto le = qobject_cast(editor); const Base::Vector3d& value = data.value(); QString text = QString::fromLatin1("[%1 %2 %3]") .arg(loc.toString(value.x, 'f', 2), @@ -1458,7 +1458,7 @@ void PropertyVectorItem::setEditorData(QWidget *editor, const QVariant& data) co QVariant PropertyVectorItem::editorData(QWidget *editor) const { - QLineEdit *le = qobject_cast(editor); + auto le = qobject_cast(editor); return QVariant(le->text()); } @@ -1504,7 +1504,7 @@ void PropertyVectorItem::propertyBound() PropertyEditorWidget::PropertyEditorWidget (QWidget * parent) : QWidget(parent) { - QHBoxLayout *layout = new QHBoxLayout(this); + auto layout = new QHBoxLayout(this); layout->setMargin(0); layout->setSpacing(2); @@ -1653,7 +1653,7 @@ void PropertyVectorListItem::setValue(const QVariant& value) QWidget* PropertyVectorListItem::createEditor(QWidget* parent, const QObject* receiver, const char* method) const { - VectorListWidget *pe = new VectorListWidget(decimals(), parent); + auto pe = new VectorListWidget(decimals(), parent); QObject::connect(pe, SIGNAL(valueChanged(const QVariant &)), receiver, method); pe->setDisabled(isReadOnly()); return pe; @@ -1661,13 +1661,13 @@ QWidget* PropertyVectorListItem::createEditor(QWidget* parent, const QObject* re void PropertyVectorListItem::setEditorData(QWidget *editor, const QVariant& data) const { - VectorListWidget *pe = qobject_cast(editor); + auto pe = qobject_cast(editor); pe->setValue(data); } QVariant PropertyVectorListItem::editorData(QWidget *editor) const { - VectorListWidget *pe = qobject_cast(editor); + auto pe = qobject_cast(editor); return pe->value(); } @@ -1732,14 +1732,14 @@ void PropertyVectorDistanceItem::setValue(const QVariant& variant) void PropertyVectorDistanceItem::setEditorData(QWidget *editor, const QVariant& data) const { - QLineEdit* le = qobject_cast(editor); + auto le = qobject_cast(editor); le->setProperty("coords", data); le->setText(toString(data).toString()); } QWidget* PropertyVectorDistanceItem::createEditor(QWidget* parent, const QObject* /*receiver*/, const char* /*method*/) const { - VectorLineEdit *le = new VectorLineEdit(decimals(), parent); + auto le = new VectorLineEdit(decimals(), parent); le->setFrame(false); le->setReadOnly(true); @@ -1753,7 +1753,7 @@ QWidget* PropertyVectorDistanceItem::createEditor(QWidget* parent, const QObject QVariant PropertyVectorDistanceItem::editorData(QWidget *editor) const { - QLineEdit *le = qobject_cast(editor); + auto le = qobject_cast(editor); return QVariant(le->text()); } @@ -1957,7 +1957,7 @@ void PropertyMatrixItem::setValue(const QVariant& value) QWidget* PropertyMatrixItem::createEditor(QWidget* parent, const QObject* /*receiver*/, const char* /*method*/) const { - QLineEdit *le = new QLineEdit(parent); + auto le = new QLineEdit(parent); le->setFrame(false); le->setReadOnly(true); return le; @@ -1966,7 +1966,7 @@ QWidget* PropertyMatrixItem::createEditor(QWidget* parent, const QObject* /*rece void PropertyMatrixItem::setEditorData(QWidget *editor, const QVariant& data) const { QLocale loc; - QLineEdit* le = qobject_cast(editor); + auto le = qobject_cast(editor); const Base::Matrix4D& value = data.value(); QString text = QString::fromLatin1("[%1 %2 %3 %4 %5 %6 %7 %8 %9 %10 %11 %12 %13 %14 %15 %16]") .arg(loc.toString(value[0][0], 'f', 2), //(unsigned short usNdx) @@ -1990,7 +1990,7 @@ void PropertyMatrixItem::setEditorData(QWidget *editor, const QVariant& data) co QVariant PropertyMatrixItem::editorData(QWidget *editor) const { - QLineEdit *le = qobject_cast(editor); + auto le = qobject_cast(editor); return QVariant(le->text()); } @@ -2308,7 +2308,7 @@ void PropertyRotationItem::setAxis(const Base::Vector3d& axis) if (!value.canConvert()) return; - Base::Rotation rot = value.value(); + auto rot = value.value(); rot = h.setAxis(rot, axis); setValue(QVariant::fromValue(rot)); } @@ -2565,7 +2565,7 @@ void PropertyPlacementItem::setAngle(Base::Quantity angle) if (!value.canConvert()) return; - Base::Placement val = value.value(); + auto val = value.value(); Base::Rotation rot = h.setAngle(angle.getValue()); val.setRotation(rot); setValue(QVariant::fromValue(val)); @@ -2582,7 +2582,7 @@ void PropertyPlacementItem::setAxis(const Base::Vector3d& axis) if (!value.canConvert()) return; - Base::Placement val = value.value(); + auto val = value.value(); Base::Rotation rot = val.getRotation(); rot = h.setAxis(rot, axis); val.setRotation(rot); @@ -2604,7 +2604,7 @@ void PropertyPlacementItem::setPosition(const Base::Vector3d& pos) if (!value.canConvert()) return; - Base::Placement val = value.value(); + auto val = value.value(); val.setPosition(pos); h.setChanged(true); setValue(QVariant::fromValue(val)); @@ -2736,7 +2736,7 @@ void PropertyPlacementItem::setValue(const QVariant& value) QWidget* PropertyPlacementItem::createEditor(QWidget* parent, const QObject* receiver, const char* method) const { - PlacementEditor *pe = new PlacementEditor(this->propertyName(), parent); + auto pe = new PlacementEditor(this->propertyName(), parent); QObject::connect(pe, SIGNAL(valueChanged(const QVariant &)), receiver, method); pe->setDisabled(isReadOnly()); return pe; @@ -2744,13 +2744,13 @@ QWidget* PropertyPlacementItem::createEditor(QWidget* parent, const QObject* rec void PropertyPlacementItem::setEditorData(QWidget *editor, const QVariant& data) const { - PlacementEditor *pe = qobject_cast(editor); + auto pe = qobject_cast(editor); pe->setValue(data); } QVariant PropertyPlacementItem::editorData(QWidget *editor) const { - PlacementEditor *pe = qobject_cast(editor); + auto pe = qobject_cast(editor); return pe->value(); } @@ -2799,7 +2799,7 @@ QStringList PropertyEnumItem::getEnum() const QStringList res; auto prop = getFirstProperty(); if (prop && prop->getTypeId().isDerivedFrom(App::PropertyEnumeration::getClassTypeId())) { - const App::PropertyEnumeration* prop_enum = static_cast(prop); + const auto prop_enum = static_cast(prop); std::vector enums = prop_enum->getEnumVector(); for (const auto& it : enums) res.push_back(QString::fromStdString(it)); @@ -2811,7 +2811,7 @@ QVariant PropertyEnumItem::value(const App::Property* prop) const { assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyEnumeration::getClassTypeId())); - const App::PropertyEnumeration* prop_enum = static_cast(prop); + const auto prop_enum = static_cast(prop); if(!prop_enum->isValid()) return QVariant(QString()); return QVariant(QString::fromUtf8(prop_enum->getValueAsString())); @@ -2885,22 +2885,22 @@ QWidget* PropertyEnumItem::createEditor(QWidget* parent, const QObject* receiver const std::vector& items = getPropertyData(); QStringList commonModes, modes; - for (std::vector::const_iterator it = items.begin(); it != items.end(); ++it) { + for (auto it = items.begin(); it != items.end(); ++it) { if ((*it)->getTypeId() == App::PropertyEnumeration::getClassTypeId()) { - App::PropertyEnumeration* prop = static_cast(*it); + auto prop = static_cast(*it); if (!prop->hasEnums()) { commonModes.clear(); return nullptr; } const std::vector& value = prop->getEnumVector(); if (it == items.begin()) { - for (std::vector::const_iterator jt = value.begin(); jt != value.end(); ++jt) - commonModes << QString::fromUtf8(jt->c_str()); + for (const auto & jt : value) + commonModes << QString::fromUtf8(jt.c_str()); } else { - for (std::vector::const_iterator jt = value.begin(); jt != value.end(); ++jt) { - if (commonModes.contains(QString::fromUtf8(jt->c_str()))) - modes << QString::fromUtf8(jt->c_str()); + for (const auto & jt : value) { + if (commonModes.contains(QString::fromUtf8(jt.c_str()))) + modes << QString::fromUtf8(jt.c_str()); } commonModes = modes; @@ -2952,7 +2952,7 @@ QWidget* PropertyEnumItem::createEditor(QWidget* parent, const QObject* receiver } if (!enumItems) { - QComboBox *cb = new QComboBox(parent); + auto cb = new QComboBox(parent); cb->setFrame(false); cb->setDisabled(isReadOnly()); cb->addItems(commonModes); @@ -2962,7 +2962,7 @@ QWidget* PropertyEnumItem::createEditor(QWidget* parent, const QObject* receiver auto button = new PropertyEnumButton(parent); button->setDisabled(isReadOnly()); - QMenu *menu = new QMenu(button); + auto menu = new QMenu(button); for (auto &item : *enumItems) item.populate(menu); button->setMenu(menu); @@ -3006,7 +3006,7 @@ PropertyStringListItem::PropertyStringListItem() QWidget* PropertyStringListItem::createEditor(QWidget* parent, const QObject* receiver, const char* method) const { - Gui::LabelEditor* le = new Gui::LabelEditor(parent); + auto le = new Gui::LabelEditor(parent); le->setAutoFillBackground(true); le->setDisabled(isReadOnly()); QObject::connect(le, SIGNAL(textChanged(const QString&)), receiver, method); @@ -3015,14 +3015,14 @@ QWidget* PropertyStringListItem::createEditor(QWidget* parent, const QObject* re void PropertyStringListItem::setEditorData(QWidget *editor, const QVariant& data) const { - Gui::LabelEditor *le = qobject_cast(editor); + auto le = qobject_cast(editor); QStringList list = data.toStringList(); le->setText(list.join(QChar::fromLatin1('\n'))); } QVariant PropertyStringListItem::editorData(QWidget *editor) const { - Gui::LabelEditor *le = qobject_cast(editor); + auto le = qobject_cast(editor); QString complete = le->text(); QStringList list = complete.split(QChar::fromLatin1('\n')); return QVariant(list); @@ -3046,7 +3046,7 @@ QVariant PropertyStringListItem::value(const App::Property* prop) const assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyStringList::getClassTypeId())); QStringList list; const std::vector& value = (static_cast(prop))->getValues(); - for ( std::vector::const_iterator jt = value.begin(); jt != value.end(); ++jt ) { + for (auto jt = value.begin(); jt != value.end(); ++jt ) { list << QString::fromUtf8((*jt).c_str()); } @@ -3083,7 +3083,7 @@ PropertyFloatListItem::PropertyFloatListItem() QWidget* PropertyFloatListItem::createEditor(QWidget* parent, const QObject* receiver, const char* method) const { - Gui::LabelEditor* le = new Gui::LabelEditor(parent); + auto le = new Gui::LabelEditor(parent); le->setAutoFillBackground(true); le->setInputType(Gui::LabelEditor::Float); le->setDisabled(isReadOnly()); @@ -3093,14 +3093,14 @@ QWidget* PropertyFloatListItem::createEditor(QWidget* parent, const QObject* rec void PropertyFloatListItem::setEditorData(QWidget *editor, const QVariant& data) const { - Gui::LabelEditor *le = qobject_cast(editor); + auto le = qobject_cast(editor); QStringList list = data.toStringList(); le->setText(list.join(QChar::fromLatin1('\n'))); } QVariant PropertyFloatListItem::editorData(QWidget *editor) const { - Gui::LabelEditor *le = qobject_cast(editor); + auto le = qobject_cast(editor); QString complete = le->text(); QStringList list = complete.split(QChar::fromLatin1('\n')); return QVariant(list); @@ -3157,7 +3157,7 @@ PropertyIntegerListItem::PropertyIntegerListItem() QWidget* PropertyIntegerListItem::createEditor(QWidget* parent, const QObject* receiver, const char* method) const { - Gui::LabelEditor* le = new Gui::LabelEditor(parent); + auto le = new Gui::LabelEditor(parent); le->setAutoFillBackground(true); le->setInputType(Gui::LabelEditor::Integer); le->setDisabled(isReadOnly()); @@ -3167,14 +3167,14 @@ QWidget* PropertyIntegerListItem::createEditor(QWidget* parent, const QObject* r void PropertyIntegerListItem::setEditorData(QWidget *editor, const QVariant& data) const { - Gui::LabelEditor *le = qobject_cast(editor); + auto le = qobject_cast(editor); QStringList list = data.toStringList(); le->setText(list.join(QChar::fromLatin1('\n'))); } QVariant PropertyIntegerListItem::editorData(QWidget *editor) const { - Gui::LabelEditor *le = qobject_cast(editor); + auto le = qobject_cast(editor); QString complete = le->text(); QStringList list = complete.split(QChar::fromLatin1('\n')); return QVariant(list); @@ -3198,7 +3198,7 @@ QVariant PropertyIntegerListItem::value(const App::Property* prop) const QStringList list; const std::vector& value = static_cast(prop)->getValues(); - for (std::vector::const_iterator jt = value.begin(); jt != value.end(); ++jt) { + for (auto jt = value.begin(); jt != value.end(); ++jt) { list << QString::number(*jt); } @@ -3213,8 +3213,8 @@ void PropertyIntegerListItem::setValue(const QVariant& value) QString data; QTextStream str(&data); str << "["; - for (QStringList::Iterator it = values.begin(); it != values.end(); ++it) { - str << *it << ","; + for (const auto & value : values) { + str << value << ","; } str << "]"; if (data == QString::fromUtf8("[,]")) @@ -3232,7 +3232,7 @@ PropertyColorItem::PropertyColorItem() QVariant PropertyColorItem::decoration(const QVariant& value) const { - QColor color = value.value(); + auto color = value.value(); int size = QApplication::style()->pixelMetric(QStyle::PM_ListViewIconSize); QPixmap p(size, size); @@ -3243,7 +3243,7 @@ QVariant PropertyColorItem::decoration(const QVariant& value) const QVariant PropertyColorItem::toString(const QVariant& prop) const { - QColor value = prop.value(); + auto value = prop.value(); QString color = QString::fromLatin1("[%1, %2, %3]") .arg(value.red()).arg(value.green()).arg(value.blue()); return QVariant(color); @@ -3261,7 +3261,7 @@ void PropertyColorItem::setValue(const QVariant& value) { if (hasExpression() || !value.canConvert()) return; - QColor col = value.value(); + auto col = value.value(); App::Color val; val.setValue(col); QString data = QString::fromLatin1("(%1,%2,%3)") .arg(val.r, 0, 'f', decimals()) @@ -3272,7 +3272,7 @@ void PropertyColorItem::setValue(const QVariant& value) QWidget* PropertyColorItem::createEditor(QWidget* parent, const QObject* receiver, const char* method) const { - Gui::ColorButton* cb = new Gui::ColorButton( parent ); + auto cb = new Gui::ColorButton( parent ); cb->setDisabled(isReadOnly()); QObject::connect(cb, SIGNAL(changed()), receiver, method); return cb; @@ -3280,14 +3280,14 @@ QWidget* PropertyColorItem::createEditor(QWidget* parent, const QObject* receive void PropertyColorItem::setEditorData(QWidget *editor, const QVariant& data) const { - Gui::ColorButton *cb = qobject_cast(editor); - QColor color = data.value(); + auto cb = qobject_cast(editor); + auto color = data.value(); cb->setColor(color); } QVariant PropertyColorItem::editorData(QWidget *editor) const { - Gui::ColorButton *cb = qobject_cast(editor); + auto cb = qobject_cast(editor); QVariant var; var.setValue(cb->color()); return var; @@ -3360,7 +3360,7 @@ QColor PropertyMaterialItem::getDiffuseColor() const if (!value.canConvert()) return QColor(); - Material val = value.value(); + auto val = value.value(); return val.diffuseColor; } @@ -3370,7 +3370,7 @@ void PropertyMaterialItem::setDiffuseColor(const QColor& color) if (!value.canConvert()) return; - Material mat = value.value(); + auto mat = value.value(); mat.diffuseColor = color; setValue(QVariant::fromValue(mat)); } @@ -3381,7 +3381,7 @@ QColor PropertyMaterialItem::getAmbientColor() const if (!value.canConvert()) return QColor(); - Material val = value.value(); + auto val = value.value(); return val.ambientColor; } @@ -3391,7 +3391,7 @@ void PropertyMaterialItem::setAmbientColor(const QColor& color) if (!value.canConvert()) return; - Material mat = value.value(); + auto mat = value.value(); mat.ambientColor = color; setValue(QVariant::fromValue(mat)); } @@ -3402,7 +3402,7 @@ QColor PropertyMaterialItem::getSpecularColor() const if (!value.canConvert()) return QColor(); - Material val = value.value(); + auto val = value.value(); return val.specularColor; } @@ -3412,7 +3412,7 @@ void PropertyMaterialItem::setSpecularColor(const QColor& color) if (!value.canConvert()) return; - Material mat = value.value(); + auto mat = value.value(); mat.specularColor = color; setValue(QVariant::fromValue(mat)); } @@ -3423,7 +3423,7 @@ QColor PropertyMaterialItem::getEmissiveColor() const if (!value.canConvert()) return QColor(); - Material val = value.value(); + auto val = value.value(); return val.emissiveColor; } @@ -3433,7 +3433,7 @@ void PropertyMaterialItem::setEmissiveColor(const QColor& color) if (!value.canConvert()) return; - Material mat = value.value(); + auto mat = value.value(); mat.emissiveColor = color; setValue(QVariant::fromValue(mat)); } @@ -3444,7 +3444,7 @@ float PropertyMaterialItem::getShininess() const if (!value.canConvert()) return 0; - Material val = value.value(); + auto val = value.value(); return val.shininess; } @@ -3454,7 +3454,7 @@ void PropertyMaterialItem::setShininess(float s) if (!value.canConvert()) return; - Material mat = value.value(); + auto mat = value.value(); mat.shininess = s; setValue(QVariant::fromValue(mat)); } @@ -3465,7 +3465,7 @@ float PropertyMaterialItem::getTransparency() const if (!value.canConvert()) return 0; - Material val = value.value(); + auto val = value.value(); return val.transparency; } @@ -3475,7 +3475,7 @@ void PropertyMaterialItem::setTransparency(float t) if (!value.canConvert()) return; - Material mat = value.value(); + auto mat = value.value(); mat.transparency = t; setValue(QVariant::fromValue(mat)); } @@ -3483,7 +3483,7 @@ void PropertyMaterialItem::setTransparency(float t) QVariant PropertyMaterialItem::decoration(const QVariant& value) const { // use the diffuse color - Material val = value.value(); + auto val = value.value(); QColor color = val.diffuseColor; int size = QApplication::style()->pixelMetric(QStyle::PM_ListViewIconSize); @@ -3496,7 +3496,7 @@ QVariant PropertyMaterialItem::decoration(const QVariant& value) const QVariant PropertyMaterialItem::toString(const QVariant& prop) const { // use the diffuse color - Material val = prop.value(); + auto val = prop.value(); QColor value = val.diffuseColor; QString color = QString::fromLatin1("[%1, %2, %3]") .arg(value.red()).arg(value.green()).arg(value.blue()); @@ -3508,10 +3508,10 @@ QVariant PropertyMaterialItem::toolTip(const App::Property* prop) const assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyMaterial::getClassTypeId())); const App::Material& value = static_cast(prop)->getValue(); - QColor dc = value.diffuseColor.asValue(); - QColor ac = value.ambientColor.asValue(); - QColor sc = value.specularColor.asValue(); - QColor ec = value.emissiveColor.asValue(); + auto dc = value.diffuseColor.asValue(); + auto ac = value.ambientColor.asValue(); + auto sc = value.specularColor.asValue(); + auto ec = value.emissiveColor.asValue(); QString data = QString::fromUtf8( "Diffuse color: [%1, %2, %3]\n" @@ -3554,7 +3554,7 @@ void PropertyMaterialItem::setValue(const QVariant& value) if (hasExpression() || !value.canConvert()) return; - Material mat = value.value(); + auto mat = value.value(); App::Color dc; dc.setValue(mat.diffuseColor); App::Color ac; ac.setValue(mat.ambientColor); App::Color sc; sc.setValue(mat.specularColor); @@ -3593,7 +3593,7 @@ void PropertyMaterialItem::setValue(const QVariant& value) QWidget* PropertyMaterialItem::createEditor(QWidget* parent, const QObject* receiver, const char* method) const { - Gui::ColorButton* cb = new Gui::ColorButton(parent); + auto cb = new Gui::ColorButton(parent); cb->setDisabled(isReadOnly()); QObject::connect(cb, SIGNAL(changed()), receiver, method); return cb; @@ -3604,19 +3604,19 @@ void PropertyMaterialItem::setEditorData(QWidget *editor, const QVariant& data) if (!data.canConvert()) return; - Material val = data.value(); - Gui::ColorButton *cb = qobject_cast(editor); + auto val = data.value(); + auto cb = qobject_cast(editor); cb->setColor(val.diffuseColor); } QVariant PropertyMaterialItem::editorData(QWidget *editor) const { - Gui::ColorButton *cb = qobject_cast(editor); + auto cb = qobject_cast(editor); QVariant value = data(1, Qt::EditRole); if (!value.canConvert()) return QVariant(); - Material val = value.value(); + auto val = value.value(); val.diffuseColor = cb->color(); return QVariant::fromValue(val); } @@ -3680,7 +3680,7 @@ QColor PropertyMaterialListItem::getDiffuseColor() const if (!list[0].canConvert()) return QColor(); - Material mat = list[0].value(); + auto mat = list[0].value(); return mat.diffuseColor; } @@ -3697,7 +3697,7 @@ void PropertyMaterialListItem::setDiffuseColor(const QColor& color) if (!list[0].canConvert()) return; - Material mat = list[0].value(); + auto mat = list[0].value(); mat.diffuseColor = color; list[0] = QVariant::fromValue(mat); setValue(list); @@ -3716,7 +3716,7 @@ QColor PropertyMaterialListItem::getAmbientColor() const if (!list[0].canConvert()) return QColor(); - Material mat = list[0].value(); + auto mat = list[0].value(); return mat.ambientColor; } @@ -3733,7 +3733,7 @@ void PropertyMaterialListItem::setAmbientColor(const QColor& color) if (!list[0].canConvert()) return; - Material mat = list[0].value(); + auto mat = list[0].value(); mat.ambientColor = color; list[0] = QVariant::fromValue(mat); setValue(list); @@ -3752,7 +3752,7 @@ QColor PropertyMaterialListItem::getSpecularColor() const if (!list[0].canConvert()) return QColor(); - Material mat = list[0].value(); + auto mat = list[0].value(); return mat.specularColor; } @@ -3769,7 +3769,7 @@ void PropertyMaterialListItem::setSpecularColor(const QColor& color) if (!list[0].canConvert()) return; - Material mat = list[0].value(); + auto mat = list[0].value(); mat.specularColor = color; list[0] = QVariant::fromValue(mat); setValue(list); @@ -3788,7 +3788,7 @@ QColor PropertyMaterialListItem::getEmissiveColor() const if (!list[0].canConvert()) return QColor(); - Material mat = list[0].value(); + auto mat = list[0].value(); return mat.emissiveColor; } @@ -3805,7 +3805,7 @@ void PropertyMaterialListItem::setEmissiveColor(const QColor& color) if (!list[0].canConvert()) return; - Material mat = list[0].value(); + auto mat = list[0].value(); mat.emissiveColor = color; list[0] = QVariant::fromValue(mat); setValue(list); @@ -3824,7 +3824,7 @@ float PropertyMaterialListItem::getShininess() const if (!list[0].canConvert()) return 0; - Material mat = list[0].value(); + auto mat = list[0].value(); return mat.shininess; } @@ -3841,7 +3841,7 @@ void PropertyMaterialListItem::setShininess(float s) if (!list[0].canConvert()) return; - Material mat = list[0].value(); + auto mat = list[0].value(); mat.shininess = s; list[0] = QVariant::fromValue(mat); setValue(list); @@ -3860,7 +3860,7 @@ float PropertyMaterialListItem::getTransparency() const if (!list[0].canConvert()) return 0; - Material mat = list[0].value(); + auto mat = list[0].value(); return mat.transparency; } @@ -3877,7 +3877,7 @@ void PropertyMaterialListItem::setTransparency(float t) if (!list[0].canConvert()) return; - Material mat = list[0].value(); + auto mat = list[0].value(); mat.transparency = t; list[0] = QVariant::fromValue(mat); setValue(list); @@ -3896,7 +3896,7 @@ QVariant PropertyMaterialListItem::decoration(const QVariant& value) const return QVariant(); // use the diffuse color - Material mat = list[0].value(); + auto mat = list[0].value(); QColor color = mat.diffuseColor; int size = QApplication::style()->pixelMetric(QStyle::PM_ListViewIconSize); @@ -3919,7 +3919,7 @@ QVariant PropertyMaterialListItem::toString(const QVariant& prop) const return QVariant(); // use the diffuse color - Material mat = list[0].value(); + 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()); @@ -3935,10 +3935,10 @@ QVariant PropertyMaterialListItem::toolTip(const App::Property* prop) const return QVariant(); App::Material value = values.front(); - QColor dc = value.diffuseColor.asValue(); - QColor ac = value.ambientColor.asValue(); - QColor sc = value.specularColor.asValue(); - QColor ec = value.emissiveColor.asValue(); + auto dc = value.diffuseColor.asValue(); + auto ac = value.ambientColor.asValue(); + auto sc = value.specularColor.asValue(); + auto ec = value.emissiveColor.asValue(); QString data = QString::fromUtf8( "Diffuse color: [%1, %2, %3]\n" @@ -3966,14 +3966,14 @@ QVariant PropertyMaterialListItem::value(const App::Property* prop) const const std::vector& value = static_cast(prop)->getValues(); QVariantList variantList; - for (std::vector::const_iterator it = value.begin(); it != value.end(); ++it) { + for (const auto & it : value) { Material mat; - mat.diffuseColor = it->diffuseColor.asValue(); - mat.ambientColor = it->ambientColor.asValue(); - mat.specularColor = it->specularColor.asValue(); - mat.emissiveColor = it->emissiveColor.asValue(); - mat.shininess = it->shininess; - mat.transparency = it->transparency; + mat.diffuseColor = it.diffuseColor.asValue(); + mat.ambientColor = it.ambientColor.asValue(); + mat.specularColor = it.specularColor.asValue(); + mat.emissiveColor = it.emissiveColor.asValue(); + mat.shininess = it.shininess; + mat.transparency = it.transparency; variantList << QVariant::fromValue(mat); } @@ -3994,8 +3994,8 @@ void PropertyMaterialListItem::setValue(const QVariant& value) QTextStream str(&data); str << "("; - for (QVariantList::iterator it = list.begin(); it != list.end(); ++it) { - Material mat = it->value(); + for (const auto & it : list) { + auto mat = it.value(); App::Color dc; dc.setValue(mat.diffuseColor); App::Color ac; ac.setValue(mat.ambientColor); App::Color sc; sc.setValue(mat.specularColor); @@ -4038,7 +4038,7 @@ void PropertyMaterialListItem::setValue(const QVariant& value) QWidget* PropertyMaterialListItem::createEditor(QWidget* parent, const QObject* receiver, const char* method) const { - Gui::ColorButton* cb = new Gui::ColorButton(parent); + auto cb = new Gui::ColorButton(parent); cb->setDisabled(isReadOnly()); QObject::connect(cb, SIGNAL(changed()), receiver, method); return cb; @@ -4057,16 +4057,16 @@ void PropertyMaterialListItem::setEditorData(QWidget *editor, const QVariant& da return; // use the diffuse color - Material mat = list[0].value(); + auto mat = list[0].value(); QColor color = mat.diffuseColor; - Gui::ColorButton *cb = qobject_cast(editor); + auto cb = qobject_cast(editor); cb->setColor(color); } QVariant PropertyMaterialListItem::editorData(QWidget *editor) const { - Gui::ColorButton *cb = qobject_cast(editor); + auto cb = qobject_cast(editor); QVariant value = data(1, Qt::EditRole); if (!value.canConvert()) return QVariant(); @@ -4079,7 +4079,7 @@ QVariant PropertyMaterialListItem::editorData(QWidget *editor) const return QVariant(); // use the diffuse color - Material mat = list[0].value(); + auto mat = list[0].value(); mat.diffuseColor = cb->color(); list[0] = QVariant::fromValue(mat); @@ -4118,7 +4118,7 @@ QVariant PropertyFileItem::toolTip(const App::Property* prop) const QWidget* PropertyFileItem::createEditor(QWidget* parent, const QObject* receiver, const char* method) const { - Gui::FileChooser *fc = new Gui::FileChooser(parent); + auto fc = new Gui::FileChooser(parent); fc->setAutoFillBackground(true); fc->setDisabled(isReadOnly()); QObject::connect(fc, SIGNAL(fileNameSelected(const QString&)), receiver, method); @@ -4129,9 +4129,9 @@ void PropertyFileItem::setEditorData(QWidget *editor, const QVariant& data) cons { const App::Property* prop = getFirstProperty(); if (prop) { - const App::PropertyFile* propFile = static_cast(prop); + const auto propFile = static_cast(prop); std::string filter = propFile->getFilter(); - Gui::FileChooser *fc = qobject_cast(editor); + auto fc = qobject_cast(editor); if (!filter.empty()) { fc->setFilter(Base::Tools::fromStdString(filter)); } @@ -4141,7 +4141,7 @@ void PropertyFileItem::setEditorData(QWidget *editor, const QVariant& data) cons QVariant PropertyFileItem::editorData(QWidget *editor) const { - Gui::FileChooser *fc = qobject_cast(editor); + auto fc = qobject_cast(editor); return QVariant(fc->fileName()); } @@ -4177,7 +4177,7 @@ QVariant PropertyPathItem::toolTip(const App::Property* prop) const QWidget* PropertyPathItem::createEditor(QWidget* parent, const QObject* receiver, const char* method) const { - Gui::FileChooser *fc = new Gui::FileChooser(parent); + auto fc = new Gui::FileChooser(parent); fc->setMode(FileChooser::Directory); fc->setAutoFillBackground(true); fc->setDisabled(isReadOnly()); @@ -4187,13 +4187,13 @@ QWidget* PropertyPathItem::createEditor(QWidget* parent, const QObject* receiver void PropertyPathItem::setEditorData(QWidget *editor, const QVariant& data) const { - Gui::FileChooser *fc = qobject_cast(editor); + auto fc = qobject_cast(editor); fc->setFileName(data.toString()); } QVariant PropertyPathItem::editorData(QWidget *editor) const { - Gui::FileChooser *fc = qobject_cast(editor); + auto fc = qobject_cast(editor); return QVariant(fc->fileName()); } @@ -4229,7 +4229,7 @@ QVariant PropertyTransientFileItem::toolTip(const App::Property* prop) const QWidget* PropertyTransientFileItem::createEditor(QWidget* parent, const QObject* receiver, const char* method) const { - Gui::FileChooser *fc = new Gui::FileChooser(parent); + auto fc = new Gui::FileChooser(parent); fc->setAutoFillBackground(true); fc->setDisabled(isReadOnly()); QObject::connect(fc, SIGNAL(fileNameSelected(const QString&)), receiver, method); @@ -4238,13 +4238,13 @@ QWidget* PropertyTransientFileItem::createEditor(QWidget* parent, const QObject* void PropertyTransientFileItem::setEditorData(QWidget *editor, const QVariant& data) const { - Gui::FileChooser *fc = qobject_cast(editor); + auto fc = qobject_cast(editor); fc->setFileName(data.toString()); } QVariant PropertyTransientFileItem::editorData(QWidget *editor) const { - Gui::FileChooser *fc = qobject_cast(editor); + auto fc = qobject_cast(editor); return QVariant(fc->fileName()); } @@ -4278,7 +4278,7 @@ void LinkSelection::select() LinkLabel::LinkLabel (QWidget * parent, const App::Property *prop) : QWidget(parent), objProp(prop), dlg(nullptr) { - QHBoxLayout *layout = new QHBoxLayout(this); + auto layout = new QHBoxLayout(this); layout->setMargin(0); layout->setSpacing(1); @@ -4354,7 +4354,7 @@ QVariant LinkLabel::propertyLink() const void LinkLabel::onLinkActivated (const QString& s) { Q_UNUSED(s); - LinkSelection* select = new LinkSelection(qvariant_cast(link)); + auto select = new LinkSelection(qvariant_cast(link)); QTimer::singleShot(50, select, SLOT(select())); } @@ -4448,7 +4448,7 @@ QWidget* PropertyLinkItem::createEditor(QWidget* parent, const QObject* receiver { if(propertyItems.empty()) return nullptr; - LinkLabel *ll = new LinkLabel(parent, propertyItems.front()); + auto ll = new LinkLabel(parent, propertyItems.front()); ll->setAutoFillBackground(true); ll->setDisabled(isReadOnly()); QObject::connect(ll, SIGNAL(linkChanged(const QVariant&)), receiver, method); @@ -4458,13 +4458,13 @@ QWidget* PropertyLinkItem::createEditor(QWidget* parent, const QObject* receiver void PropertyLinkItem::setEditorData(QWidget *editor, const QVariant& data) const { (void)data; - LinkLabel *ll = static_cast(editor); + auto ll = static_cast(editor); return ll->updatePropertyLink(); } QVariant PropertyLinkItem::editorData(QWidget *editor) const { - LinkLabel *ll = static_cast(editor); + auto ll = static_cast(editor); return ll->propertyLink(); } diff --git a/src/Gui/propertyeditor/PropertyItemDelegate.cpp b/src/Gui/propertyeditor/PropertyItemDelegate.cpp index 41539dbae2..41de64d351 100644 --- a/src/Gui/propertyeditor/PropertyItemDelegate.cpp +++ b/src/Gui/propertyeditor/PropertyItemDelegate.cpp @@ -64,7 +64,7 @@ void PropertyItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem & { QStyleOptionViewItem option = opt; - PropertyItem *property = static_cast(index.internalPointer()); + auto property = static_cast(index.internalPointer()); if (property && property->isSeparator()) { QColor color = option.palette.color(QPalette::BrightText); @@ -127,7 +127,7 @@ bool PropertyItemDelegate::editorEvent (QEvent * event, QAbstractItemModel* mode bool PropertyItemDelegate::eventFilter(QObject *o, QEvent *ev) { if (ev->type() == QEvent::FocusOut) { - PropertyEditor *parentEditor = qobject_cast(this->parent()); + auto parentEditor = qobject_cast(this->parent()); auto widget = qobject_cast(o); if (widget && parentEditor && parentEditor->activeEditor && widget != parentEditor->activeEditor) { @@ -148,11 +148,11 @@ QWidget * PropertyItemDelegate::createEditor (QWidget * parent, const QStyleOpti if (!index.isValid()) return nullptr; - PropertyItem *childItem = static_cast(index.internalPointer()); + auto childItem = static_cast(index.internalPointer()); if (!childItem) return nullptr; - PropertyEditor *parentEditor = qobject_cast(this->parent()); + auto parentEditor = qobject_cast(this->parent()); if(parentEditor) parentEditor->closeEditor(); @@ -222,7 +222,7 @@ void PropertyItemDelegate::setEditorData(QWidget *editor, const QModelIndex &ind if (!index.isValid()) return; QVariant data = index.data(Qt::EditRole); - PropertyItem *childItem = static_cast(index.internalPointer()); + auto childItem = static_cast(index.internalPointer()); editor->blockSignals(true); if (expressionEditor == editor) childItem->setExpressionEditorData(editor, data); @@ -238,7 +238,7 @@ void PropertyItemDelegate::setModelData(QWidget* editor, QAbstractItemModel* mod { if (!index.isValid() || !changed || userEditor) return; - PropertyItem *childItem = static_cast(index.internalPointer()); + auto childItem = static_cast(index.internalPointer()); QVariant data; if(expressionEditor == editor) data = childItem->expressionEditorData(editor); diff --git a/src/Gui/propertyeditor/PropertyModel.cpp b/src/Gui/propertyeditor/PropertyModel.cpp index 3bbc507617..8587f4e063 100644 --- a/src/Gui/propertyeditor/PropertyModel.cpp +++ b/src/Gui/propertyeditor/PropertyModel.cpp @@ -69,7 +69,7 @@ QVariant PropertyModel::data ( const QModelIndex & index, int role ) const if (!index.isValid()) return QVariant(); - PropertyItem *item = static_cast(index.internalPointer()); + auto item = static_cast(index.internalPointer()); return item->data(index.column(), role); } @@ -80,7 +80,7 @@ bool PropertyModel::setData(const QModelIndex& index, const QVariant & value, in // we check whether the data has really changed, otherwise we ignore it if (role == Qt::EditRole) { - PropertyItem *item = static_cast(index.internalPointer()); + auto item = static_cast(index.internalPointer()); QVariant data = item->data(index.column(), role); if (data.type() == QVariant::Double && value.type() == QVariant::Double) { // since we store some properties as floats we get some round-off @@ -107,7 +107,7 @@ bool PropertyModel::setData(const QModelIndex& index, const QVariant & value, in Qt::ItemFlags PropertyModel::flags(const QModelIndex &index) const { - PropertyItem *item = static_cast(index.internalPointer()); + auto item = static_cast(index.internalPointer()); return item->flags(index.column()); } @@ -132,7 +132,7 @@ QModelIndex PropertyModel::parent ( const QModelIndex & index ) const if (!index.isValid()) return QModelIndex(); - PropertyItem *childItem = static_cast(index.internalPointer()); + auto childItem = static_cast(index.internalPointer()); PropertyItem *parentItem = childItem->parent(); if (parentItem == rootItem) @@ -176,7 +176,7 @@ QStringList PropertyModel::propertyPathFromIndex(const QModelIndex& index) const { QStringList path; if (index.isValid()) { - PropertyItem* item = static_cast(index.internalPointer()); + auto item = static_cast(index.internalPointer()); while (item && item != this->rootItem) { path.push_front(item->propertyName()); item = item->parent(); @@ -302,11 +302,11 @@ void PropertyModel::buildUp(const PropertyModel::PropertyList& props) // Second step, either find existing items or create new items for the given // properties. There is no signaling of model change at this stage. The // change information is kept pending in GroupInfo::children - for (auto jt = props.begin(); jt != props.end(); ++jt) { - App::Property* prop = jt->second.front(); + for (const auto & jt : props) { + App::Property* prop = jt.second.front(); PropertyItem *item = nullptr; - for (auto prop : jt->second) { + for (auto prop : jt.second) { auto it = itemMap.find(prop); if (it == itemMap.end() || !it->second) continue; @@ -323,16 +323,16 @@ void PropertyModel::buildUp(const PropertyModel::PropertyList& props) GroupInfo &groupInfo = getGroupInfo(prop); groupInfo.children.push_back(item); - item->setLinked(boost::ends_with(jt->first,"*")); + item->setLinked(boost::ends_with(jt.first,"*")); setPropertyItemName(item, prop->getName(), groupInfo.groupItem->propertyName()); - if (jt->second != item->getPropertyData()) { + if (jt.second != item->getPropertyData()) { for (auto prop : item->getPropertyData()) itemMap.erase(prop); - for (auto prop : jt->second) + for (auto prop : jt.second) itemMap[prop] = item; // TODO: is it necessary to make sure the item has no pending commit? - item->setPropertyData(jt->second); + item->setPropertyData(jt.second); } else item->updateData();