Fix several clazy issues:
* C++11 range-loop might detach Qt container [-Wclazy-range-loop-detach]
This commit is contained in:
@@ -498,7 +498,8 @@ void Command::testActive(void)
|
||||
Gui::ActionGroup* pcAction = qobject_cast<Gui::ActionGroup*>(_pcAction);
|
||||
if(pcAction) {
|
||||
Gui::CommandManager &rcCmdMgr = Gui::Application::Instance->commandManager();
|
||||
for(auto action : pcAction->actions()) {
|
||||
const auto actions = pcAction->actions();
|
||||
for(auto action : actions) {
|
||||
auto name = action->property("CommandName").toByteArray();
|
||||
if(!name.size())
|
||||
continue;
|
||||
|
||||
@@ -755,7 +755,8 @@ void StdCmdLinkSelectLinked::activated(int)
|
||||
doc->setActiveView(vp);
|
||||
}
|
||||
} else {
|
||||
for(auto tree : getMainWindow()->findChildren<TreeWidget*>())
|
||||
const auto trees = getMainWindow()->findChildren<TreeWidget*>();
|
||||
for(auto tree : trees)
|
||||
tree->selectLinkedObject(linked);
|
||||
}
|
||||
Selection().selStackPush();
|
||||
@@ -790,7 +791,8 @@ void StdCmdLinkSelectLinkedFinal::activated(int) {
|
||||
}
|
||||
Selection().selStackPush();
|
||||
Selection().clearCompleteSelection();
|
||||
for(auto tree : getMainWindow()->findChildren<TreeWidget*>())
|
||||
const auto trees = getMainWindow()->findChildren<TreeWidget*>();
|
||||
for(auto tree : trees)
|
||||
tree->selectLinkedObject(linked);
|
||||
Selection().selStackPush();
|
||||
}
|
||||
@@ -825,7 +827,8 @@ void StdCmdLinkSelectAllLinks::activated(int)
|
||||
return;
|
||||
Selection().selStackPush();
|
||||
Selection().clearCompleteSelection();
|
||||
for(auto tree : getMainWindow()->findChildren<TreeWidget*>())
|
||||
const auto trees = getMainWindow()->findChildren<TreeWidget*>();
|
||||
for(auto tree : trees)
|
||||
tree->selectAllLinks(sels[0].pObject);
|
||||
Selection().selStackPush();
|
||||
}
|
||||
|
||||
@@ -309,7 +309,8 @@ PyObject* CommandPy::getAction(PyObject *args)
|
||||
|
||||
Py::List list;
|
||||
if (group) {
|
||||
for (auto a : group->actions())
|
||||
const auto actions = group->actions();
|
||||
for (auto a : actions)
|
||||
list.append(wrap.fromQObject(a));
|
||||
}
|
||||
else if (action) {
|
||||
|
||||
@@ -3013,7 +3013,8 @@ void StdCmdTreeSelectAllInstances::activated(int iMsg)
|
||||
return;
|
||||
Selection().selStackPush();
|
||||
Selection().clearCompleteSelection();
|
||||
for(auto tree : getMainWindow()->findChildren<TreeWidget*>())
|
||||
const auto trees = getMainWindow()->findChildren<TreeWidget*>();
|
||||
for(auto tree : trees)
|
||||
tree->selectAllInstances(*vpd);
|
||||
Selection().selStackPush();
|
||||
}
|
||||
@@ -3521,7 +3522,8 @@ StdTreeDrag::StdTreeDrag()
|
||||
void StdTreeDrag::activated(int)
|
||||
{
|
||||
if(Gui::Selection().hasSelection()) {
|
||||
for(auto tree : getMainWindow()->findChildren<TreeWidget*>()) {
|
||||
const auto trees = getMainWindow()->findChildren<TreeWidget*>();
|
||||
for(auto tree : trees) {
|
||||
if(tree->isVisible()) {
|
||||
tree->startDragging();
|
||||
break;
|
||||
|
||||
@@ -365,7 +365,8 @@ void DlgObjectSelection::onDepItemChanged(QTreeWidgetItem * depItem, int column)
|
||||
QSignalBlocker blocker3(ui->treeWidget);
|
||||
auto state = depItem->checkState(0);
|
||||
if (depItem->isSelected()) {
|
||||
for (auto item : depItem->treeWidget()->selectedItems()) {
|
||||
const auto items = depItem->treeWidget()->selectedItems();
|
||||
for (auto item : items) {
|
||||
auto objT = qvariant_cast<App::SubObjectT>(item->data(0, Qt::UserRole));
|
||||
auto it = itemMap.find(objT);
|
||||
if (it == itemMap.end())
|
||||
@@ -437,7 +438,8 @@ void DlgObjectSelection::onObjItemChanged(QTreeWidgetItem * objItem, int column)
|
||||
onItemSelectionChanged();
|
||||
}
|
||||
else {
|
||||
for (auto item : ui->treeWidget->selectedItems()) {
|
||||
const auto items = ui->treeWidget->selectedItems();
|
||||
for (auto item : items) {
|
||||
setCheckState(item, state);
|
||||
itemChanged[qvariant_cast<App::SubObjectT>(item->data(0, Qt::UserRole))] = state;
|
||||
}
|
||||
@@ -552,7 +554,8 @@ void DlgObjectSelection::onItemSelectionChanged() {
|
||||
inMap.clear();
|
||||
|
||||
std::vector<App::DocumentObject *> sels;
|
||||
for (auto item : ui->treeWidget->selectedItems()) {
|
||||
const auto items = ui->treeWidget->selectedItems();
|
||||
for (auto item : items) {
|
||||
if (item == allItem) {
|
||||
sels.clear();
|
||||
break;
|
||||
|
||||
@@ -145,7 +145,7 @@ void DlgParameterImp::on_findGroupLE_textChanged(const QString &SearchStr)
|
||||
|
||||
// at first reset all items to the default font and expand state
|
||||
if (foundList.size() > 0) {
|
||||
for (QTreeWidgetItem* item : foundList) {
|
||||
for (QTreeWidgetItem* item : qAsConst(foundList)) {
|
||||
item->setFont(0, defaultFont);
|
||||
item->setForeground(0, defaultColor);
|
||||
ExpandItem = item;
|
||||
@@ -176,7 +176,7 @@ void DlgParameterImp::on_findGroupLE_textChanged(const QString &SearchStr)
|
||||
// reset background style sheet
|
||||
if (!ui->findGroupLE->styleSheet().isEmpty())
|
||||
ui->findGroupLE->setStyleSheet(QString());
|
||||
for (QTreeWidgetItem* item : foundList) {
|
||||
for (QTreeWidgetItem* item : qAsConst(foundList)) {
|
||||
item->setFont(0, boldFont);
|
||||
item->setForeground(0, Qt::red);
|
||||
// expand its parent to see the item
|
||||
|
||||
@@ -161,9 +161,9 @@ QString DlgPropertyLink::formatObject(App::Document *ownerDoc, App::DocumentObje
|
||||
QString::fromUtf8(sobj->Label.getValue()));
|
||||
}
|
||||
|
||||
static inline bool isLinkSub(QList<App::SubObjectT> links)
|
||||
static inline bool isLinkSub(const QList<App::SubObjectT>& links)
|
||||
{
|
||||
for(auto &link : links) {
|
||||
for(const auto &link : links) {
|
||||
if(&link == &links.front())
|
||||
continue;
|
||||
if(link.getDocumentName() != links.front().getDocumentName()
|
||||
@@ -353,7 +353,7 @@ void DlgPropertyLink::init(const App::DocumentObjectT &prop, bool tryFilter) {
|
||||
// For link list type property, try to auto filter type
|
||||
if(tryFilter && isLinkList) {
|
||||
Base::Type objType;
|
||||
for(const auto& link : oldLinks) {
|
||||
for(const auto& link : qAsConst(oldLinks)) {
|
||||
auto obj = link.getSubObject();
|
||||
if(!obj)
|
||||
continue;
|
||||
@@ -534,7 +534,8 @@ void DlgPropertyLink::onItemSelectionChanged()
|
||||
// Enforce single parent
|
||||
if(singleParent && currentObj && currentObj!=obj) {
|
||||
ui->treeWidget->blockSignals(true);
|
||||
for(auto item : ui->treeWidget->selectedItems()) {
|
||||
const auto items = ui->treeWidget->selectedItems();
|
||||
for(auto item : items) {
|
||||
if(item != selections.back())
|
||||
item->setSelected(false);
|
||||
}
|
||||
@@ -707,7 +708,8 @@ DlgPropertyLink::getLinkFromItem(QTreeWidgetItem *item, bool needSubName) const
|
||||
return res;
|
||||
}
|
||||
|
||||
for(const QString &element : elements.split(QLatin1Char(','))) {
|
||||
const auto split = elements.split(QLatin1Char(','));
|
||||
for(const QString &element : split) {
|
||||
res.append(App::SubObjectT());
|
||||
res.last() = App::SubObjectT(sobj.getDocumentName().c_str(),
|
||||
sobj.getObjectName().c_str(),
|
||||
@@ -1052,7 +1054,8 @@ void DlgPropertyLink::on_checkObjectType_toggled(bool on)
|
||||
void DlgPropertyLink::on_typeTree_itemSelectionChanged() {
|
||||
|
||||
selectedTypes.clear();
|
||||
for(auto item : ui->typeTree->selectedItems())
|
||||
const auto items = ui->typeTree->selectedItems();
|
||||
for(auto item : items)
|
||||
selectedTypes.insert(item->data(0, Qt::UserRole).toByteArray());
|
||||
|
||||
if(ui->checkObjectType->isChecked())
|
||||
|
||||
@@ -301,14 +301,16 @@ qint64 ApplicationCache::dirSize(QString dirPath) const
|
||||
QDir dir(dirPath);
|
||||
|
||||
QDir::Filters fileFilters = QDir::Files;
|
||||
for (QString filePath : dir.entryList(fileFilters)) {
|
||||
const auto& files = dir.entryList(fileFilters);
|
||||
for (const QString& filePath : files) {
|
||||
QFileInfo fi(dir, filePath);
|
||||
total += fi.size();
|
||||
}
|
||||
|
||||
// traverse sub-directories recursively
|
||||
QDir::Filters dirFilters = QDir::Dirs | QDir::NoDotAndDotDot;
|
||||
for (QString subDirPath : dir.entryList(dirFilters))
|
||||
const auto& dirs = dir.entryList(dirFilters);
|
||||
for (const QString& subDirPath : dirs)
|
||||
total += dirSize(dirPath + QDir::separator() + subDirPath);
|
||||
return total;
|
||||
}
|
||||
|
||||
@@ -723,7 +723,7 @@ void DocumentRecoveryCleaner::subtractFiles(QStringList& files)
|
||||
void DocumentRecoveryCleaner::subtractDirs(QFileInfoList& dirs)
|
||||
{
|
||||
if (!ignoreDirs.isEmpty() && !dirs.isEmpty()) {
|
||||
for (const auto& it : ignoreDirs) {
|
||||
for (const auto& it : qAsConst(ignoreDirs)) {
|
||||
dirs.removeOne(it);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -213,7 +213,7 @@ TStringMap Translator::supportedLocales() const
|
||||
|
||||
// List all .qm files
|
||||
for (const auto& domainMap : d->mapLanguageTopLevelDomain) {
|
||||
for (const auto& directoryName : d->paths) {
|
||||
for (const auto& directoryName : qAsConst(d->paths)) {
|
||||
QDir dir(directoryName);
|
||||
QString filter = QString::fromLatin1("*_%1.qm").arg(QString::fromStdString(domainMap.second));
|
||||
QStringList fileNames = dir.entryList(QStringList(filter), QDir::Files, QDir::Name);
|
||||
|
||||
@@ -161,7 +161,8 @@ bool PropertyView::showAll() {
|
||||
void PropertyView::setShowAll(bool enable) {
|
||||
if(_ShowAll != enable) {
|
||||
_ShowAll = enable;
|
||||
for(auto view : getMainWindow()->findChildren<PropertyView*>()) {
|
||||
const auto views = getMainWindow()->findChildren<PropertyView*>();
|
||||
for(auto view : views) {
|
||||
if(view->isVisible()) {
|
||||
view->propertyEditorData->buildUp();
|
||||
view->propertyEditorView->buildUp();
|
||||
|
||||
@@ -215,7 +215,8 @@ public:
|
||||
}
|
||||
|
||||
void removeItems() {
|
||||
for(auto item : ui->elementList->selectedItems()) {
|
||||
const auto items = ui->elementList->selectedItems();
|
||||
for(auto item : items) {
|
||||
std::string sub = qPrintable(item->data(Qt::UserRole+1).value<QString>());
|
||||
if(sub == hiddenSub)
|
||||
hiddenSub.clear();
|
||||
@@ -259,8 +260,8 @@ public:
|
||||
editObj == msg.pObjectName &&
|
||||
boost::starts_with(msg.pSubName,editSub))
|
||||
{
|
||||
for(auto item : ui->elementList->findItems(
|
||||
QString::fromLatin1(msg.pSubName-editSub.size()), Qt::MatchExactly))
|
||||
const auto items = ui->elementList->findItems(QString::fromLatin1(msg.pSubName-editSub.size()), Qt::MatchExactly);
|
||||
for(auto item : items)
|
||||
item->setSelected(msg.Type==SelectionChanges::AddSelection);
|
||||
}
|
||||
}
|
||||
@@ -285,7 +286,8 @@ public:
|
||||
}
|
||||
break;
|
||||
}
|
||||
for(auto item : ui->elementList->selectedItems()) {
|
||||
const auto items = ui->elementList->selectedItems();
|
||||
for(auto item : items) {
|
||||
std::string name(qPrintable(item->data(Qt::UserRole+1).value<QString>()));
|
||||
if(ViewProvider::hasHiddenMarker(name.c_str()))
|
||||
continue;
|
||||
|
||||
@@ -1158,7 +1158,8 @@ void TreeWidget::onMarkRecompute()
|
||||
|
||||
void TreeWidget::onRecomputeObject() {
|
||||
std::vector<App::DocumentObject*> objs;
|
||||
for (auto ti : selectedItems()) {
|
||||
const auto items = selectedItems();
|
||||
for (auto ti : items) {
|
||||
if (ti->type() == ObjectType) {
|
||||
DocumentObjectItem* objitem = static_cast<DocumentObjectItem*>(ti);
|
||||
objs.push_back(objitem->object()->getObject());
|
||||
@@ -1224,8 +1225,10 @@ std::vector<TreeWidget::SelInfo> TreeWidget::getSelection(App::Document* doc)
|
||||
else
|
||||
tree->_updateStatus(false);
|
||||
|
||||
for (auto ti : tree->selectedItems()) {
|
||||
if (ti->type() != ObjectType) continue;
|
||||
const auto items = tree->selectedItems();
|
||||
for (auto ti : items) {
|
||||
if (ti->type() != ObjectType)
|
||||
continue;
|
||||
auto item = static_cast<DocumentObjectItem*>(ti);
|
||||
auto vp = item->object();
|
||||
auto obj = vp->getObject();
|
||||
@@ -2736,7 +2739,8 @@ void TreeWidget::expandSelectedItems(TreeItemMode mode)
|
||||
if (!isSelectionAttached())
|
||||
return;
|
||||
|
||||
for (auto item : selectedItems()) {
|
||||
const auto items = selectedItems();
|
||||
for (auto item : items) {
|
||||
switch (mode) {
|
||||
case TreeItemMode::ExpandPath: {
|
||||
QTreeWidgetItem* parentItem = item->parent();
|
||||
|
||||
@@ -2582,7 +2582,8 @@ void ViewProviderLink::_setupContextMenu(
|
||||
|| (ext->getLinkPlacementProperty() && !ext->getLinkPlacementProperty()->isReadOnly()))
|
||||
{
|
||||
bool found = false;
|
||||
for(auto action : menu->actions()) {
|
||||
const auto actions = menu->actions();
|
||||
for(auto action : actions) {
|
||||
if(action->data().toInt() == ViewProvider::Transform) {
|
||||
found = true;
|
||||
break;
|
||||
@@ -2598,7 +2599,8 @@ void ViewProviderLink::_setupContextMenu(
|
||||
|
||||
if(ext->getColoredElementsProperty()) {
|
||||
bool found = false;
|
||||
for(auto action : menu->actions()) {
|
||||
const auto actions = menu->actions();
|
||||
for(auto action : actions) {
|
||||
if(action->data().toInt() == ViewProvider::Color) {
|
||||
action->setText(QObject::tr("Override colors..."));
|
||||
found = true;
|
||||
|
||||
@@ -1671,7 +1671,8 @@ ButtonGroup::ButtonGroup(QObject *parent)
|
||||
connect(this, qOverload<QAbstractButton *>(&QButtonGroup::buttonClicked),
|
||||
[=](QAbstractButton *button) {
|
||||
if (exclusive()) {
|
||||
for (auto btn : buttons()) {
|
||||
const auto btns = buttons();
|
||||
for (auto btn : btns) {
|
||||
if (btn && btn != button && btn->isCheckable())
|
||||
btn->setChecked(false);
|
||||
}
|
||||
|
||||
@@ -624,7 +624,8 @@ void PropertyEditor::contextMenuEvent(QContextMenuEvent *) {
|
||||
auto contextIndex = currentIndex();
|
||||
|
||||
std::unordered_set<App::Property*> props;
|
||||
for(auto index : selectedIndexes()) {
|
||||
const auto indexes = selectedIndexes();
|
||||
for(const auto& index : indexes) {
|
||||
auto item = static_cast<PropertyItem*>(index.internalPointer());
|
||||
if(item->isSeparator())
|
||||
continue;
|
||||
|
||||
@@ -193,7 +193,8 @@ QWidget * PropertyItemDelegate::createEditor (QWidget * parent, const QStyleOpti
|
||||
this->pressed = false;
|
||||
|
||||
if (editor) {
|
||||
for (auto w : editor->findChildren<QWidget*>()) {
|
||||
const auto widgets = editor->findChildren<QWidget*>();
|
||||
for (auto w : widgets) {
|
||||
if (qobject_cast<QAbstractButton*>(w)
|
||||
|| qobject_cast<QLabel*>(w))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user