Apply clang-tidy's performance-unnecessary-value-param, performance-for-

range-copy


git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@5448 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
scorpio810
2018-07-19 14:14:31 +00:00
parent 05fea9b94a
commit e4b1ba9797
97 changed files with 263 additions and 238 deletions

View File

@@ -76,7 +76,7 @@ ElementsLocation ECHSFileToFile::copy()
return copyDirectory(m_source, m_destination, rename);
}
ElementsLocation ECHSFileToFile::copyDirectory(ElementsLocation &source, ElementsLocation &destination, QString rename)
ElementsLocation ECHSFileToFile::copyDirectory(ElementsLocation &source, ElementsLocation &destination, const QString& rename)
{
QDir source_dir(source.fileSystemPath());
QDir destination_dir(destination.fileSystemPath());
@@ -130,7 +130,7 @@ ElementsLocation ECHSFileToFile::copyDirectory(ElementsLocation &source, Element
return ElementsLocation();
}
ElementsLocation ECHSFileToFile::copyElement(ElementsLocation &source, ElementsLocation &destination, QString rename)
ElementsLocation ECHSFileToFile::copyElement(ElementsLocation &source, ElementsLocation &destination, const QString& rename)
{
QString new_elmt_name = rename.isEmpty() ? source.fileName() : rename;
bool rb = QFile::copy(source.fileSystemPath(), destination.fileSystemPath() + "/" + new_elmt_name);
@@ -184,7 +184,7 @@ ElementsLocation ECHSXmlToFile::copy()
return copyDirectory(m_source, m_destination, rename);
}
ElementsLocation ECHSXmlToFile::copyDirectory(ElementsLocation &source, ElementsLocation &destination, QString rename)
ElementsLocation ECHSXmlToFile::copyDirectory(ElementsLocation &source, ElementsLocation &destination, const QString& rename)
{
QDir destination_dir(destination.fileSystemPath());
@@ -231,7 +231,7 @@ ElementsLocation ECHSXmlToFile::copyDirectory(ElementsLocation &source, Elements
return ElementsLocation();
}
ElementsLocation ECHSXmlToFile::copyElement(ElementsLocation &source, ElementsLocation &destination, QString rename)
ElementsLocation ECHSXmlToFile::copyElement(ElementsLocation &source, ElementsLocation &destination, const QString& rename)
{
if (!(destination.exist() && source.exist())) return ElementsLocation();

View File

@@ -48,8 +48,8 @@ class ECHSFileToFile : public ECHStrategy
ElementsLocation copy() override;
private:
ElementsLocation copyDirectory(ElementsLocation &source, ElementsLocation &destination, QString rename = QString());
ElementsLocation copyElement(ElementsLocation &source, ElementsLocation &destination, QString rename = QString());
ElementsLocation copyDirectory(ElementsLocation &source, ElementsLocation &destination, const QString& rename = QString());
ElementsLocation copyElement(ElementsLocation &source, ElementsLocation &destination, const QString& rename = QString());
};
/**
@@ -63,8 +63,8 @@ class ECHSXmlToFile : public ECHStrategy
ElementsLocation copy() override;
private:
ElementsLocation copyDirectory(ElementsLocation &source, ElementsLocation &destination, QString rename = QString());
ElementsLocation copyElement(ElementsLocation &source, ElementsLocation &destination, QString rename = QString());
ElementsLocation copyDirectory(ElementsLocation &source, ElementsLocation &destination, const QString& rename = QString());
ElementsLocation copyElement(ElementsLocation &source, ElementsLocation &destination, const QString& rename = QString());
};
/**

View File

@@ -71,7 +71,7 @@ ElementCollectionItem *ElementCollectionItem::lastItemForPath(const QString &pat
* @param name
* @return
*/
ElementCollectionItem *ElementCollectionItem::childWithCollectionName(QString name) const
ElementCollectionItem *ElementCollectionItem::childWithCollectionName(const QString& name) const
{
rowCount();
foreach (QStandardItem *qsi, directChilds()) {

View File

@@ -46,7 +46,7 @@ class ElementCollectionItem : public QStandardItem
virtual void clearData();
ElementCollectionItem *lastItemForPath(const QString &path, QString &no_found_path);
ElementCollectionItem *childWithCollectionName(QString name) const;
ElementCollectionItem *childWithCollectionName(const QString& name) const;
QList<QStandardItem *> directChilds() const;
int rowForInsertItem(const QString &name);
ElementCollectionItem *itemAtPath(const QString &path);

View File

@@ -286,7 +286,7 @@ void ElementsCollectionModel::addCustomCollection(bool set_data)
* If the location is already managed by this model, do nothing.
* @param location
*/
void ElementsCollectionModel::addLocation(ElementsLocation location)
void ElementsCollectionModel::addLocation(const ElementsLocation& location)
{
QModelIndex index = indexFromLocation(location);
if (index.isValid())
@@ -504,7 +504,7 @@ QModelIndex ElementsCollectionModel::indexFromLocation(const ElementsLocation &l
* this method create and display the new element
* @param path -The path of the new element in the embedded collection of a project
*/
void ElementsCollectionModel::elementIntegratedToCollection(QString path)
void ElementsCollectionModel::elementIntegratedToCollection(const QString& path)
{
QObject *object = sender();
XmlElementCollection *collection = static_cast<XmlElementCollection *> (object);
@@ -537,7 +537,7 @@ void ElementsCollectionModel::elementIntegratedToCollection(QString path)
* This method must be called by a signal, to get a sender.
* @param path
*/
void ElementsCollectionModel::itemRemovedFromCollection(QString path)
void ElementsCollectionModel::itemRemovedFromCollection(const QString& path)
{
QObject *object = sender();
XmlElementCollection *collection = static_cast<XmlElementCollection *> (object);
@@ -565,7 +565,7 @@ void ElementsCollectionModel::itemRemovedFromCollection(QString path)
* Update the item at path
* @param path
*/
void ElementsCollectionModel::updateItem(QString path)
void ElementsCollectionModel::updateItem(const QString& path)
{
QObject *object = sender();
XmlElementCollection *collection = static_cast<XmlElementCollection *> (object);

View File

@@ -45,7 +45,7 @@ class ElementsCollectionModel : public QStandardItemModel
void addCommonCollection(bool set_data = true);
void addCustomCollection(bool set_data = true);
void addLocation(ElementsLocation location);
void addLocation(const ElementsLocation& location);
void addProject(QETProject *project, bool set_data = true);
void removeProject(QETProject *project);
@@ -64,9 +64,9 @@ class ElementsCollectionModel : public QStandardItemModel
void loadingProgressValue(int);
private:
void elementIntegratedToCollection (QString path);
void itemRemovedFromCollection (QString path);
void updateItem (QString path);
void elementIntegratedToCollection (const QString& path);
void itemRemovedFromCollection (const QString& path);
void updateItem (const QString& path);
private:
QList <QETProject *> m_project_list;

View File

@@ -566,7 +566,7 @@ void ElementsCollectionWidget::reload()
* Update or add the item represented by location to m_model
* @param location
*/
void ElementsCollectionWidget::locationWasSaved(ElementsLocation location)
void ElementsCollectionWidget::locationWasSaved(const ElementsLocation& location)
{
//Because this method update an item in the model, location must
//represente an existing element (in file system of project)

View File

@@ -81,7 +81,7 @@ class ElementsCollectionWidget : public QWidget
void reload();
private:
void locationWasSaved(ElementsLocation location);
void locationWasSaved(const ElementsLocation& location);
private:

View File

@@ -37,7 +37,7 @@ FileElementCollectionItem::FileElementCollectionItem()
* @param path
* @return true if path exist.
*/
bool FileElementCollectionItem::setRootPath(QString path, bool set_data, bool hide_element)
bool FileElementCollectionItem::setRootPath(const QString& path, bool set_data, bool hide_element)
{
QDir dir(path);
if (dir.exists()) {
@@ -278,7 +278,7 @@ void FileElementCollectionItem::setUpIcon()
* For create a new file collection see setRootPath.
* @param path_name
*/
void FileElementCollectionItem::setPathName(QString path_name, bool set_data, bool hide_element)
void FileElementCollectionItem::setPathName(const QString& path_name, bool set_data, bool hide_element)
{
m_path = path_name;

View File

@@ -33,7 +33,7 @@ class FileElementCollectionItem : public ElementCollectionItem
enum { Type = UserType+2 };
int type() const override { return Type;}
bool setRootPath(QString path, bool set_data = true, bool hide_element = false);
bool setRootPath(const QString& path, bool set_data = true, bool hide_element = false);
QString fileSystemPath() const;
QString dirPath() const;
@@ -54,7 +54,7 @@ class FileElementCollectionItem : public ElementCollectionItem
private:
void setPathName(QString path_name, bool set_data = true, bool hide_element = false);
void setPathName(const QString& path_name, bool set_data = true, bool hide_element = false);
void populate(bool set_data = true, bool hide_element = false);
private:

View File

@@ -16,12 +16,14 @@
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include "renamedialog.h"
#include <utility>
#include "ui_renamedialog.h"
RenameDialog::RenameDialog(QString path, QWidget *parent) :
QDialog(parent),
ui(new Ui::RenameDialog),
m_path(path)
m_path(std::move(path))
{
ui->setupUi(this);
m_name = m_path.split("/").last();

View File

@@ -462,7 +462,7 @@ bool XmlElementCollection::addElementDefinition(const QString &dir_path, const Q
* @return True if element is removed and emit the signal elementRemoved.
* else false.
*/
bool XmlElementCollection::removeElement(QString path)
bool XmlElementCollection::removeElement(const QString& path)
{
QDomElement elmt = element(path);
@@ -486,7 +486,7 @@ bool XmlElementCollection::removeElement(QString path)
* @param deep_copy : if true copy all childs of source (only if source is directory)
* @return the ElementLocation that represent the copy, if copy failed return a null ElementLocation
*/
ElementsLocation XmlElementCollection::copy(ElementsLocation &source, ElementsLocation &destination, QString rename, bool deep_copy)
ElementsLocation XmlElementCollection::copy(ElementsLocation &source, ElementsLocation &destination, const QString& rename, bool deep_copy)
{
if (!(source.exist() && destination.isDirectory() && destination.isProject() && destination.projectCollection() == this))
return ElementsLocation();
@@ -520,7 +520,7 @@ bool XmlElementCollection::exist(const QString &path) const
* @param name_list : translation of the directorie name.
* @return true if creation success, if directorie already exist return true.
*/
bool XmlElementCollection::createDir(QString path, QString name, const NamesList &name_list)
bool XmlElementCollection::createDir(const QString& path, const QString& name, const NamesList &name_list)
{
QString new_dir_path = path + "/" + name;
@@ -552,7 +552,7 @@ bool XmlElementCollection::createDir(QString path, QString name, const NamesList
* @return true if successfuly removed and emit directoryRemoved(QString),
* else false.
*/
bool XmlElementCollection::removeDir(QString path)
bool XmlElementCollection::removeDir(const QString& path)
{
QDomElement dir = directory(path);
if (!dir.isNull()) {
@@ -670,7 +670,7 @@ void XmlElementCollection::cleanUnusedDirectory()
* @param deep_copy :if true copy all childs of source
* @return the ElementLocation that represent the copy, if copy failed return a null ElementLocation
*/
ElementsLocation XmlElementCollection::copyDirectory(ElementsLocation &source, ElementsLocation &destination, QString rename, bool deep_copy)
ElementsLocation XmlElementCollection::copyDirectory(ElementsLocation &source, ElementsLocation &destination, const QString& rename, bool deep_copy)
{
QString new_dir_name = rename.isEmpty() ? source.fileName() : rename;
@@ -757,7 +757,7 @@ ElementsLocation XmlElementCollection::copyDirectory(ElementsLocation &source, E
* @param rename : rename the copy with @rename else use the name of source
* @return The ElementsLocation of the copy
*/
ElementsLocation XmlElementCollection::copyElement(ElementsLocation &source, ElementsLocation &destination, QString rename)
ElementsLocation XmlElementCollection::copyElement(ElementsLocation &source, ElementsLocation &destination, const QString& rename)
{
QString new_elmt_name = rename.isEmpty() ? source.fileName() : rename;

View File

@@ -50,11 +50,11 @@ class XmlElementCollection : public QObject
QDomElement directory(const QString &path) const;
QString addElement (ElementsLocation &location);
bool addElementDefinition (const QString &dir_path, const QString &elmt_name, const QDomElement &xml_definition);
bool removeElement(QString path);
ElementsLocation copy (ElementsLocation &source, ElementsLocation &destination, QString rename = QString(), bool deep_copy = true);
bool removeElement(const QString& path);
ElementsLocation copy (ElementsLocation &source, ElementsLocation &destination, const QString& rename = QString(), bool deep_copy = true);
bool exist (const QString &path) const;
bool createDir (QString path, QString name, const NamesList &name_list);
bool removeDir (QString path);
bool createDir (const QString& path, const QString& name, const NamesList &name_list);
bool removeDir (const QString& path);
QList <ElementsLocation> elementsLocation (QDomElement dom_element = QDomElement(), bool childs = true) const;
ElementsLocation domToLocation(QDomElement dom_element) const;
@@ -63,8 +63,8 @@ class XmlElementCollection : public QObject
void cleanUnusedDirectory();
private:
ElementsLocation copyDirectory(ElementsLocation &source, ElementsLocation &destination, QString rename = QString(), bool deep_copy = true);
ElementsLocation copyElement(ElementsLocation &source, ElementsLocation &destination, QString rename = QString());
ElementsLocation copyDirectory(ElementsLocation &source, ElementsLocation &destination, const QString& rename = QString(), bool deep_copy = true);
ElementsLocation copyElement(ElementsLocation &source, ElementsLocation &destination, const QString& rename = QString());
signals:
/**

View File

@@ -259,7 +259,7 @@ void XmlProjectElementCollectionItem::populate(bool set_data, bool hide_element)
* @param project : the parent project of managed collection
* @param set_data : if true, call setUpData for every child of this item
*/
void XmlProjectElementCollectionItem::setXmlElement(QDomElement element, QETProject *project, bool set_data, bool hide_element)
void XmlProjectElementCollectionItem::setXmlElement(const QDomElement& element, QETProject *project, bool set_data, bool hide_element)
{
m_dom_element = element;
m_project = project;

View File

@@ -51,7 +51,7 @@ class XmlProjectElementCollectionItem : public ElementCollectionItem
private:
void populate(bool set_data = true, bool hide_element = false);
void setXmlElement(QDomElement element, QETProject *project, bool set_data = true, bool hide_element = false);
void setXmlElement(const QDomElement& element, QETProject *project, bool set_data = true, bool hide_element = false);
private:
QETProject *m_project = nullptr;