Replace foreach function by for, please try and report problem

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4900 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
scorpio810
2017-02-04 21:43:23 +00:00
parent 6ed750b355
commit 6422dd096f
98 changed files with 606 additions and 606 deletions

View File

@@ -101,7 +101,7 @@ ElementsLocation ECHSFileToFile::copyDirectory(ElementsLocation &source, Element
if (source_dir == destination_dir)
copy_itself = true;
foreach(QString str, source_dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name))
for (QString str : source_dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name))
{
if (copy_itself)
{
@@ -118,7 +118,7 @@ ElementsLocation ECHSFileToFile::copyDirectory(ElementsLocation &source, Element
//Copy all elements found in source_dir to destination_dir
source_dir.setNameFilters(QStringList() << "*.elmt");
foreach(QString str, source_dir.entryList(QDir::Files | QDir::NoDotAndDotDot, QDir::Name))
for (QString str: source_dir.entryList(QDir::Files | QDir::NoDotAndDotDot, QDir::Name))
{
ElementsLocation sub_source(source.fileSystemPath() + "/" + str);
copyElement(sub_source, created_location);
@@ -211,7 +211,7 @@ ElementsLocation ECHSXmlToFile::copyDirectory(ElementsLocation &source, Elements
XmlElementCollection *project_collection = source.projectCollection();
QStringList directories_names = project_collection->directoriesNames( project_collection->directory(source.collectionPath(false)) );
foreach(QString name, directories_names)
for (QString name : directories_names)
{
ElementsLocation sub_source_dir(source.projectCollectionPath() + "/" + name);
copyDirectory(sub_source_dir, created_location);
@@ -219,7 +219,7 @@ ElementsLocation ECHSXmlToFile::copyDirectory(ElementsLocation &source, Elements
//Create all elements found in source to destination
QStringList elements_names = project_collection->elementsNames( project_collection->directory(source.collectionPath(false))) ;
foreach (QString name, elements_names)
for (QString name : elements_names)
{
ElementsLocation source_element(source.projectCollectionPath() + "/" + name);
copyElement(source_element, created_location);

View File

@@ -50,7 +50,7 @@ ElementCollectionItem *ElementCollectionItem::lastItemForPath(const QString &pat
if (str_list.isEmpty()) return nullptr;
ElementCollectionItem *return_eci = this;
foreach (QString str, str_list)
for (QString str: str_list)
{
ElementCollectionItem *eci = return_eci->childWithCollectionName(str);
if (!eci)
@@ -74,7 +74,7 @@ ElementCollectionItem *ElementCollectionItem::lastItemForPath(const QString &pat
ElementCollectionItem *ElementCollectionItem::childWithCollectionName(QString name) const
{
rowCount();
foreach (QStandardItem *qsi, directChilds()) {
for (QStandardItem *qsi: directChilds()) {
ElementCollectionItem *eci = static_cast<ElementCollectionItem *>(qsi);
if (eci->name() == name)
return eci;
@@ -128,7 +128,7 @@ int ElementCollectionItem::rowForInsertItem(const QString &name)
return 0;
}
foreach (ElementCollectionItem *eci, child)
for (ElementCollectionItem *eci: child)
if (eci->name() > name)
return model()->indexFromItem(eci).row();
@@ -147,7 +147,7 @@ ElementCollectionItem *ElementCollectionItem::itemAtPath(const QString &path)
return nullptr;
ElementCollectionItem *match_eci = this;
foreach (QString str, str_list) {
for (QString str: str_list) {
ElementCollectionItem *eci = match_eci->childWithCollectionName(str);
if (!eci)
return nullptr;
@@ -166,7 +166,7 @@ QList<ElementCollectionItem *> ElementCollectionItem::elementsDirectChild() cons
{
QList <ElementCollectionItem *> element_child;
foreach (QStandardItem *qsi, directChilds()) {
for (QStandardItem *qsi: directChilds()) {
ElementCollectionItem *eci = static_cast<ElementCollectionItem *>(qsi);
if (eci->isElement())
element_child.append(eci);
@@ -183,7 +183,7 @@ QList<ElementCollectionItem *> ElementCollectionItem::directoriesDirectChild() c
{
QList <ElementCollectionItem *> dir_child;
foreach (QStandardItem *qsi, directChilds()) {
for (QStandardItem *qsi: directChilds()) {
ElementCollectionItem *eci = static_cast<ElementCollectionItem *>(qsi);
if (eci->isDir())
dir_child.append(eci);
@@ -200,7 +200,7 @@ QList<ElementCollectionItem *> ElementCollectionItem::elementsChild() const
{
QList <ElementCollectionItem *> list = elementsDirectChild();
foreach (ElementCollectionItem *eci, directoriesChild())
for (ElementCollectionItem *eci: directoriesChild())
list.append(eci->elementsDirectChild());
return list;
@@ -214,7 +214,7 @@ QList<ElementCollectionItem *> ElementCollectionItem::directoriesChild() const
{
QList<ElementCollectionItem *> list = directoriesDirectChild();
QList<ElementCollectionItem *> child_list;
foreach (ElementCollectionItem *eci, list) {
for (ElementCollectionItem *eci: list) {
child_list.append(eci->directoriesChild());
}

View File

@@ -236,7 +236,7 @@ void ElementsCollectionModel::loadCollections(bool common_collection, bool custo
list.append(items());
foreach (QETProject *project, projects) {
for (QETProject *project: projects) {
addProject(project, false);
list.append(projectItems(project));
}
@@ -310,7 +310,7 @@ void ElementsCollectionModel::addLocation(ElementsLocation location)
for (int i=0 ; i<rowCount() ; i++)
child_list.append(static_cast<ElementCollectionItem *>(item(i)));
foreach(ElementCollectionItem *eci, child_list) {
for (ElementCollectionItem *eci: child_list) {
if (eci->type() == FileElementCollectionItem::Type) {
FileElementCollectionItem *feci = static_cast<FileElementCollectionItem *>(eci);
@@ -393,14 +393,14 @@ void ElementsCollectionModel::highlightUnusedElement()
{
QList <ElementsLocation> unused;
foreach (QETProject *project, m_project_list)
for (QETProject *project: m_project_list)
unused.append(project->unusedElements());
QBrush brush;
brush.setStyle(Qt::Dense4Pattern);
brush.setColor(Qt::red);
foreach (ElementsLocation location, unused) {
for (ElementsLocation location: unused) {
QModelIndex index = indexFromLocation(location);
if (index.isValid()) {
QStandardItem *qsi = itemFromIndex(index);
@@ -452,7 +452,7 @@ QList<ElementCollectionItem *> ElementsCollectionModel::projectItems(QETProject
void ElementsCollectionModel::hideElement()
{
m_hide_element = true;
foreach(ElementCollectionItem *eci, items()) {
for (ElementCollectionItem *eci: items()) {
if (eci->isElement()) {
removeRow(eci->row(), indexFromItem(eci).parent());
}
@@ -473,7 +473,7 @@ QModelIndex ElementsCollectionModel::indexFromLocation(const ElementsLocation &l
for (int i=0 ; i<rowCount() ; i++)
child_list.append(static_cast<ElementCollectionItem *>(item(i)));
foreach(ElementCollectionItem *eci, child_list) {
foreach (ElementCollectionItem *eci, child_list) {
ElementCollectionItem *match_eci = nullptr;
@@ -514,7 +514,7 @@ void ElementsCollectionModel::elementIntegratedToCollection(QString path)
QETProject *project = nullptr;
//Get the owner project of the collection
foreach (QETProject *prj, m_project_list) {
for (QETProject *prj: m_project_list) {
if (prj->embeddedElementCollection() == collection) {
project = prj;
}
@@ -547,7 +547,7 @@ void ElementsCollectionModel::itemRemovedFromCollection(QString path)
QETProject *project = nullptr;
//Get the owner project of the collection
foreach (QETProject *prj, m_project_list) {
for (QETProject *prj: m_project_list) {
if (prj->embeddedElementCollection() == collection) {
project = prj;
}
@@ -575,7 +575,7 @@ void ElementsCollectionModel::updateItem(QString path)
QETProject *project = nullptr;
//Get the owner project of the collection
foreach (QETProject *prj, m_project_list) {
for (QETProject *prj: m_project_list) {
if (prj->embeddedElementCollection() == collection) {
project = prj;
}

View File

@@ -311,7 +311,7 @@ void ElementsCollectionWidget::editElement()
QETApp *app = QETApp::instance();
app->openElementLocations(QList<ElementsLocation>() << location);
foreach (QETElementEditor *element_editor, app->elementEditors())
for (QETElementEditor *element_editor: app->elementEditors())
connect(element_editor, &QETElementEditor::saveToLocation, this, &ElementsCollectionWidget::locationWasSaved);
}
@@ -442,7 +442,7 @@ void ElementsCollectionWidget::newElement()
elmt_wizard.preselectedLocation(loc);
elmt_wizard.exec();
foreach (QETElementEditor *element_editor, QETApp::instance()->elementEditors())
for (QETElementEditor *element_editor: QETApp::instance()->elementEditors())
connect(element_editor, &QETElementEditor::saveToLocation, this, &ElementsCollectionWidget::locationWasSaved);
}
@@ -609,12 +609,12 @@ void ElementsCollectionWidget::search()
hideCollection(true);
QStringList text_list = text.split("+", QString::SkipEmptyParts);
QModelIndexList match_index;
foreach (QString txt, text_list) {
for (QString txt: text_list) {
match_index << m_model->match(m_showed_index.isValid() ? m_model->index(0,0,m_showed_index) : m_model->index(0,0),
Qt::DisplayRole, QVariant(txt), -1, Qt::MatchContains | Qt::MatchRecursive);
}
foreach(QModelIndex index, match_index)
for (QModelIndex index: match_index)
showAndExpandItem(index);
}

View File

@@ -297,7 +297,7 @@ void FileElementCollectionItem::populate(bool set_data, bool hide_element)
QDir dir (fileSystemPath());
//Get all directory in this directory.
foreach(QString str, dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name))
for (QString str: dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name))
{
FileElementCollectionItem *feci = new FileElementCollectionItem();
appendRow(feci);
@@ -311,7 +311,7 @@ void FileElementCollectionItem::populate(bool set_data, bool hide_element)
//Get all elmt file in this directory
dir.setNameFilters(QStringList() << "*.elmt");
foreach(QString str, dir.entryList(QDir::Files | QDir::NoDotAndDotDot, QDir::Name))
for (QString str: dir.entryList(QDir::Files | QDir::NoDotAndDotDot, QDir::Name))
{
FileElementCollectionItem *feci = new FileElementCollectionItem();
appendRow(feci);

View File

@@ -136,7 +136,7 @@ QDomElement XmlElementCollection::child(const QDomElement &parent_element, const
if (found_dom_element.isEmpty()) return QDomElement();
foreach (QDomElement elmt, found_dom_element)
for (QDomElement elmt: found_dom_element)
if (elmt.attribute("name") == child_name)
return elmt;
@@ -154,7 +154,7 @@ QDomElement XmlElementCollection::child(const QString &path) const
if (path_list.isEmpty()) return QDomElement();
QDomElement parent_element = root();
foreach (QString str, path_list)
for (QString str: path_list)
{
QDomElement child_element = child(parent_element, str);
@@ -198,7 +198,7 @@ QStringList XmlElementCollection::directoriesNames(const QDomElement &parent_ele
QList <QDomElement> childs = directories(parent_element);
QStringList names;
foreach (QDomElement child, childs)
for (QDomElement child: childs)
{
QString name = child.attribute("name");
if (!name.isEmpty())
@@ -239,7 +239,7 @@ QStringList XmlElementCollection::elementsNames(const QDomElement &parent_elemen
QList <QDomElement> childs = elements(parent_element);
QStringList names;
foreach (QDomElement child, childs)
for (QDomElement child: childs)
{
QString name = child.attribute("name");
if (!name.isEmpty())
@@ -325,7 +325,7 @@ QString XmlElementCollection::addElement(ElementsLocation &location)
if (!dir.exists())
return QString();
foreach(QString str, splitted_path) {
for (QString str: splitted_path) {
QDomElement child_element = child(parent_element, str);
//Child doesn't exist, we create it
@@ -369,7 +369,7 @@ QString XmlElementCollection::addElement(ElementsLocation &location)
}
else if (location.isProject()) {
QString path;
foreach(QString str, splitted_path) {
for (QString str: splitted_path) {
if (path.isEmpty())
path = str;
else
@@ -585,7 +585,7 @@ QList<ElementsLocation> XmlElementCollection::elementsLocation(QDomElement dom_e
//get element childs
QList <QDomElement> element_list = elements(dom_element);
foreach (QDomElement elmt, element_list) {
for (QDomElement elmt: element_list) {
ElementsLocation location = domToLocation(elmt);
if (location.exist())
location_list << location;
@@ -594,7 +594,7 @@ QList<ElementsLocation> XmlElementCollection::elementsLocation(QDomElement dom_e
//get directory childs
QList <QDomElement> directory_list = directories(dom_element);
foreach (QDomElement dir, directory_list) {
for (QDomElement dir: directory_list) {
ElementsLocation location = domToLocation(dir);
if (location.exist())
location_list << location;
@@ -638,7 +638,7 @@ ElementsLocation XmlElementCollection::domToLocation(QDomElement dom_element) co
*/
void XmlElementCollection::cleanUnusedElement()
{
foreach (ElementsLocation loc, m_project->unusedElements())
for (ElementsLocation loc: m_project->unusedElements())
removeElement(loc.collectionPath(false));
}
@@ -705,7 +705,7 @@ ElementsLocation XmlElementCollection::copyDirectory(ElementsLocation &source, E
if (deep_copy)
{
//Append all directories of source to the new created directory
foreach(QString str, source_dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name))
for (QString str: source_dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name))
{
ElementsLocation sub_source(source.fileSystemPath() + "/" + str);
copyDirectory(sub_source, created_location);
@@ -713,7 +713,7 @@ ElementsLocation XmlElementCollection::copyDirectory(ElementsLocation &source, E
//Append all elements of source to the new created directory
source_dir.setNameFilters(QStringList() << "*.elmt");
foreach(QString str, source_dir.entryList(QDir::Files | QDir::NoDotAndDotDot, QDir::Name))
for (QString str: source_dir.entryList(QDir::Files | QDir::NoDotAndDotDot, QDir::Name))
{
ElementsLocation sub_source(source.fileSystemPath() + "/" + str);
copyElement(sub_source, created_location);

View File

@@ -227,7 +227,7 @@ void XmlProjectElementCollectionItem::populate(bool set_data, bool hide_element)
QList <QDomElement> dom_category = m_project->embeddedElementCollection()->directories(m_dom_element);
std::sort(dom_category.begin(), dom_category.end(), [](QDomElement a, QDomElement b){return (a.attribute("name") < b.attribute("name"));});
foreach (QDomElement element, dom_category)
for (QDomElement element: dom_category)
{
XmlProjectElementCollectionItem *xpeci = new XmlProjectElementCollectionItem();
appendRow(xpeci);
@@ -242,7 +242,7 @@ void XmlProjectElementCollectionItem::populate(bool set_data, bool hide_element)
QList <QDomElement> dom_elements = m_project->embeddedElementCollection()->elements(m_dom_element);
std::sort(dom_elements.begin(), dom_elements.end(), [](QDomElement a, QDomElement b){return (a.attribute("name") < b.attribute("name"));});
foreach (QDomElement element, dom_elements)
for (QDomElement element: dom_elements)
{
XmlProjectElementCollectionItem *xpeci = new XmlProjectElementCollectionItem();
appendRow(xpeci);