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
This commit is contained in:
berniev
2022-09-15 04:25:13 +10:00
committed by GitHub
parent f7c84dfd09
commit ae53c9b0a4
175 changed files with 2051 additions and 2057 deletions

View File

@@ -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<std::string, App::Property*>::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<std::string>::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<App::DocumentObject*> obj = pAppDoc->getObjects();
for (std::vector<App::DocumentObject*>::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