mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-18 05:00:33 +01:00
use "%" for string-concatenation
Qt-Docs says it's less memory-usage...
This commit is contained in:
@@ -44,7 +44,7 @@ ECHSFileToFile::ECHSFileToFile(ElementsLocation &source, ElementsLocation &desti
|
||||
ElementsLocation ECHSFileToFile::copy()
|
||||
{
|
||||
//Check if the destination already have an item with the same name of the item to copy
|
||||
ElementsLocation location(m_destination.fileSystemPath() + "/" + m_source.fileName());
|
||||
ElementsLocation location(m_destination.fileSystemPath() % "/" % m_source.fileName());
|
||||
QString rename;
|
||||
if (location.exist())
|
||||
{
|
||||
@@ -92,10 +92,10 @@ ElementsLocation ECHSFileToFile::copyDirectory(ElementsLocation &source, Element
|
||||
if (destination_dir.mkdir(new_dir_name))
|
||||
{
|
||||
//The new created directory
|
||||
QDir created_dir(destination_dir.canonicalPath() + "/" + new_dir_name);
|
||||
QDir created_dir(destination_dir.canonicalPath() % "/" % new_dir_name);
|
||||
|
||||
//Copy the qet_directory file
|
||||
QFile::copy(source_dir.canonicalPath() + "/qet_directory", created_dir.canonicalPath() + "/qet_directory");
|
||||
QFile::copy(source_dir.canonicalPath() % "/qet_directory", created_dir.canonicalPath() % "/qet_directory");
|
||||
|
||||
//Copy all dirs found in source_dir to destination_dir
|
||||
ElementsLocation created_location(created_dir.canonicalPath());
|
||||
@@ -115,7 +115,7 @@ ElementsLocation ECHSFileToFile::copyDirectory(ElementsLocation &source, Element
|
||||
}
|
||||
}
|
||||
|
||||
ElementsLocation sub_source(source.fileSystemPath() + "/" + str);
|
||||
ElementsLocation sub_source(source.fileSystemPath() % "/" % str);
|
||||
copyDirectory(sub_source, created_location);
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ ElementsLocation ECHSFileToFile::copyDirectory(ElementsLocation &source, Element
|
||||
source_dir.setNameFilters(QStringList() << "*.elmt");
|
||||
foreach(QString str, source_dir.entryList(QDir::Files | QDir::NoDotAndDotDot, QDir::Name))
|
||||
{
|
||||
ElementsLocation sub_source(source.fileSystemPath() + "/" + str);
|
||||
ElementsLocation sub_source(source.fileSystemPath() % "/" % str);
|
||||
copyElement(sub_source, created_location);
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ ElementsLocation ECHSFileToFile::copyDirectory(ElementsLocation &source, Element
|
||||
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);
|
||||
bool rb = QFile::copy(source.fileSystemPath(), destination.fileSystemPath() % "/" % new_elmt_name);
|
||||
if (rb)
|
||||
{
|
||||
#ifdef Q_OS_WIN
|
||||
@@ -145,7 +145,7 @@ ElementsLocation ECHSFileToFile::copyElement(ElementsLocation &source, ElementsL
|
||||
//user can't save the element
|
||||
extern Q_CORE_EXPORT int qt_ntfs_permission_lookup;
|
||||
qt_ntfs_permission_lookup++;
|
||||
QFile file(destination.fileSystemPath() + "/" + new_elmt_name);
|
||||
QFile file(destination.fileSystemPath() % "/" % new_elmt_name);
|
||||
if (!file.isWritable()) {
|
||||
if (!file.setPermissions(file.permissions() | QFileDevice::WriteUser)) {
|
||||
qDebug() << "Failed to change file permission of : " << QFileInfo(file).canonicalFilePath() \
|
||||
@@ -154,7 +154,7 @@ ElementsLocation ECHSFileToFile::copyElement(ElementsLocation &source, ElementsL
|
||||
}
|
||||
qt_ntfs_permission_lookup--;
|
||||
#endif
|
||||
return ElementsLocation (destination.fileSystemPath() + "/" + new_elmt_name);
|
||||
return ElementsLocation (destination.fileSystemPath() % "/" % new_elmt_name);
|
||||
}
|
||||
else
|
||||
return ElementsLocation();
|
||||
@@ -169,7 +169,7 @@ ECHSXmlToFile::ECHSXmlToFile(ElementsLocation &source, ElementsLocation &destina
|
||||
ElementsLocation ECHSXmlToFile::copy()
|
||||
{
|
||||
//Check if the destination already have an item with the same name of the item to copy
|
||||
ElementsLocation location(m_destination.fileSystemPath() + "/" + m_source.fileName());
|
||||
ElementsLocation location(m_destination.fileSystemPath() % "/" % m_source.fileName());
|
||||
QString rename;
|
||||
if (location.exist())
|
||||
{
|
||||
@@ -215,7 +215,7 @@ ElementsLocation ECHSXmlToFile::copyDirectory(ElementsLocation &source, Elements
|
||||
//Create new dir
|
||||
if (destination_dir.mkdir(new_dir_name))
|
||||
{
|
||||
QDir created_dir(destination_dir.canonicalPath() + "/" + new_dir_name);
|
||||
QDir created_dir(destination_dir.canonicalPath() % "/" % new_dir_name);
|
||||
ElementsLocation created_location(created_dir.canonicalPath());
|
||||
|
||||
//Create the qet-directory file
|
||||
@@ -224,7 +224,7 @@ ElementsLocation ECHSXmlToFile::copyDirectory(ElementsLocation &source, Elements
|
||||
document.appendChild(root);
|
||||
root.appendChild(source.nameList().toXml(document));
|
||||
|
||||
QString filepath = created_dir.canonicalPath() + "/qet_directory";
|
||||
QString filepath = created_dir.canonicalPath() % "/qet_directory";
|
||||
QET::writeXmlFile(document, filepath);
|
||||
|
||||
//Create all directory found in source to created_dir
|
||||
@@ -233,7 +233,7 @@ ElementsLocation ECHSXmlToFile::copyDirectory(ElementsLocation &source, Elements
|
||||
QStringList directories_names = project_collection->directoriesNames( project_collection->directory(source.collectionPath(false)) );
|
||||
foreach(QString name, directories_names)
|
||||
{
|
||||
ElementsLocation sub_source_dir(source.projectCollectionPath() + "/" + name);
|
||||
ElementsLocation sub_source_dir(source.projectCollectionPath() % "/" % name);
|
||||
copyDirectory(sub_source_dir, created_location);
|
||||
}
|
||||
|
||||
@@ -241,7 +241,7 @@ ElementsLocation ECHSXmlToFile::copyDirectory(ElementsLocation &source, Elements
|
||||
QStringList elements_names = project_collection->elementsNames( project_collection->directory(source.collectionPath(false))) ;
|
||||
foreach (QString name, elements_names)
|
||||
{
|
||||
ElementsLocation source_element(source.projectCollectionPath() + "/" + name);
|
||||
ElementsLocation source_element(source.projectCollectionPath() % "/" % name);
|
||||
copyElement(source_element, created_location);
|
||||
}
|
||||
|
||||
@@ -262,7 +262,7 @@ ElementsLocation ECHSXmlToFile::copyElement(ElementsLocation &source, ElementsLo
|
||||
document.appendChild(document.importNode(source.xml(), true));
|
||||
|
||||
//Create the .elmt file
|
||||
QString filepath = destination.fileSystemPath() + "/" + new_element_name;
|
||||
QString filepath = destination.fileSystemPath() % "/" % new_element_name;
|
||||
if (QET::writeXmlFile(document, filepath))
|
||||
return ElementsLocation(filepath);
|
||||
else
|
||||
@@ -280,7 +280,7 @@ ElementsLocation ECHSToXml::copy()
|
||||
if (!(m_source.exist() && m_destination.isDirectory() && m_destination.isProject())) return ElementsLocation();
|
||||
|
||||
//Check if the destination already have an item with the same name of the item to copy
|
||||
ElementsLocation location(m_destination.projectCollectionPath() + "/" + m_source.fileName());
|
||||
ElementsLocation location(m_destination.projectCollectionPath() % "/" % m_source.fileName());
|
||||
|
||||
QString rename;
|
||||
if (location.exist())
|
||||
@@ -370,7 +370,7 @@ ElementsLocation ElementCollectionHandler::createDir(ElementsLocation &parent, c
|
||||
document.appendChild(root);
|
||||
root.appendChild(name_list.toXml(document));
|
||||
|
||||
QString filepath = created_dir.fileSystemPath() + "/qet_directory";
|
||||
QString filepath = created_dir.fileSystemPath() % "/qet_directory";
|
||||
if (!QET::writeXmlFile(document, filepath)) {
|
||||
qDebug() << "ElementCollectionHandler::createDir : write qet-directory file failed";
|
||||
}
|
||||
|
||||
@@ -620,7 +620,7 @@ void ElementsCollectionWidget::dirProperties()
|
||||
QMessageBox::information(
|
||||
this,
|
||||
tr("Propriété du dossier %1").arg(eci->localName()),
|
||||
txt1 + " " + txt2 + " " + txt3 + "\n\n" + txt4 + "\n" + txt5);
|
||||
txt1 % " " % txt2 % " " % txt3 % "\n\n" % txt4 % "\n" % txt5);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -196,9 +196,9 @@ QString ElementsLocation::projectCollectionPath() const
|
||||
return QString();
|
||||
else
|
||||
return QString("project"
|
||||
+ QString::number(QETApp::projectId(m_project))
|
||||
+ "+"
|
||||
+ collectionPath());
|
||||
% QString::number(QETApp::projectId(m_project))
|
||||
% "+"
|
||||
% collectionPath());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -296,17 +296,17 @@ void ElementsLocation::setPath(const QString &path)
|
||||
if (path.startsWith("common://"))
|
||||
{
|
||||
tmp_path.remove("common://");
|
||||
p = QETApp::commonElementsDirN() + "/" + tmp_path;
|
||||
p = QETApp::commonElementsDirN() % "/" % tmp_path;
|
||||
}
|
||||
else if (path.startsWith("company://"))
|
||||
{
|
||||
tmp_path.remove("company://");
|
||||
p = QETApp::companyElementsDirN() + "/" + tmp_path;
|
||||
p = QETApp::companyElementsDirN() % "/" % tmp_path;
|
||||
}
|
||||
else
|
||||
{
|
||||
tmp_path.remove("custom://");
|
||||
p = QETApp::customElementsDirN() + "/" + tmp_path;
|
||||
p = QETApp::customElementsDirN() % "/" % tmp_path;
|
||||
}
|
||||
|
||||
m_file_system_path = p;
|
||||
@@ -464,7 +464,7 @@ QString ElementsLocation::toString() const
|
||||
if (m_project) {
|
||||
int project_id = QETApp::projectId(m_project);
|
||||
if (project_id != -1) {
|
||||
result += "project" + QString().setNum(project_id) + "+";
|
||||
result += "project" % QString().setNum(project_id) % "+";
|
||||
}
|
||||
}
|
||||
result += m_collection_path;
|
||||
@@ -624,7 +624,7 @@ NamesList ElementsLocation::nameList()
|
||||
{
|
||||
//Open the qet_directory file,
|
||||
// to get the traductions name of this dir
|
||||
QFile dir_conf(fileSystemPath() + "/qet_directory");
|
||||
QFile dir_conf(fileSystemPath() % "/qet_directory");
|
||||
if (dir_conf.exists() && dir_conf.open(
|
||||
QIODevice::ReadOnly
|
||||
| QIODevice::Text))
|
||||
|
||||
@@ -67,7 +67,7 @@ QString FileElementCollectionItem::fileSystemPath() const
|
||||
FileElementCollectionItem *feci =
|
||||
static_cast<FileElementCollectionItem *> (parent());
|
||||
if (feci)
|
||||
return feci->fileSystemPath() + "/" + m_path;
|
||||
return feci->fileSystemPath() % "/" % m_path;
|
||||
else
|
||||
return QString();//Null string
|
||||
}
|
||||
@@ -131,7 +131,7 @@ QString FileElementCollectionItem::localName()
|
||||
}
|
||||
else
|
||||
{
|
||||
QString str(fileSystemPath() + "/qet_directory");
|
||||
QString str(fileSystemPath() % "/qet_directory");
|
||||
pugi::xml_document docu;
|
||||
if(docu.load_file(str.toStdString().c_str()))
|
||||
{
|
||||
@@ -208,7 +208,7 @@ QString FileElementCollectionItem::collectionPath() const
|
||||
if (eci->isCollectionRoot())
|
||||
return eci->collectionPath() + m_path;
|
||||
else
|
||||
return eci->collectionPath() + "/" + m_path;
|
||||
return eci->collectionPath() % "/" % m_path;
|
||||
}
|
||||
else
|
||||
return QString();
|
||||
|
||||
@@ -446,7 +446,7 @@ QString XmlElementCollection::addElement(ElementsLocation &location)
|
||||
if (path.isEmpty())
|
||||
path = str;
|
||||
else
|
||||
path = path + "/" + str;
|
||||
path = path % "/" % str;
|
||||
|
||||
QDomElement child_element = child(parent_element, str);
|
||||
|
||||
@@ -530,7 +530,7 @@ bool XmlElementCollection::addElementDefinition(
|
||||
dom_elmt.appendChild(xml_definition.cloneNode(true));
|
||||
dom_dir.appendChild(dom_elmt);
|
||||
|
||||
emit elementAdded(dir_path + "/" + name);
|
||||
emit elementAdded(dir_path % "/" % name);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -617,7 +617,7 @@ bool XmlElementCollection::createDir(const QString& path,
|
||||
const QString& name,
|
||||
const NamesList &name_list)
|
||||
{
|
||||
QString new_dir_path = path + "/" + name;
|
||||
QString new_dir_path = path % "/" % name;
|
||||
|
||||
if (!directory(new_dir_path).isNull()) {
|
||||
return true;
|
||||
@@ -724,7 +724,7 @@ ElementsLocation XmlElementCollection::domToLocation(
|
||||
dom_element = dom_element.parentNode().toElement();
|
||||
|
||||
if (dom_element.tagName() == "category")
|
||||
path.prepend(dom_element.attribute("name") + "/");
|
||||
path.prepend(dom_element.attribute("name") % "/");
|
||||
}
|
||||
|
||||
return ElementsLocation(path, m_project);
|
||||
@@ -789,11 +789,11 @@ ElementsLocation XmlElementCollection::copyDirectory(
|
||||
|
||||
//Remove the previous directory with the same path
|
||||
QDomElement element = child(destination.collectionPath(false)
|
||||
+ "/" + new_dir_name);
|
||||
% "/" % new_dir_name);
|
||||
if (!element.isNull()) {
|
||||
element.parentNode().removeChild(element);
|
||||
emit directoryRemoved(destination.collectionPath(false)
|
||||
+ "/" + new_dir_name);
|
||||
% "/" % new_dir_name);
|
||||
}
|
||||
|
||||
ElementsLocation created_location;
|
||||
@@ -813,7 +813,7 @@ ElementsLocation XmlElementCollection::copyDirectory(
|
||||
parent_dir_dom.appendChild(elmt_dom);
|
||||
|
||||
created_location.setPath(destination.projectCollectionPath()
|
||||
+ "/" + new_dir_name);
|
||||
% "/" % new_dir_name);
|
||||
|
||||
if (deep_copy)
|
||||
{
|
||||
@@ -823,7 +823,7 @@ ElementsLocation XmlElementCollection::copyDirectory(
|
||||
QDir::Name))
|
||||
{
|
||||
ElementsLocation sub_source(source.fileSystemPath()
|
||||
+ "/" + str);
|
||||
% "/" % str);
|
||||
copyDirectory(sub_source, created_location);
|
||||
}
|
||||
|
||||
@@ -834,7 +834,7 @@ ElementsLocation XmlElementCollection::copyDirectory(
|
||||
QDir::Name))
|
||||
{
|
||||
ElementsLocation sub_source(source.fileSystemPath()
|
||||
+ "/" + str);
|
||||
% "/" % str);
|
||||
copyElement(sub_source, created_location);
|
||||
}
|
||||
}
|
||||
@@ -861,7 +861,7 @@ ElementsLocation XmlElementCollection::copyDirectory(
|
||||
other_collection_dom_dir.setAttribute("name", new_dir_name);
|
||||
parent_dir_dom.appendChild(other_collection_dom_dir);
|
||||
|
||||
created_location.setPath(destination.projectCollectionPath() + "/" + new_dir_name);
|
||||
created_location.setPath(destination.projectCollectionPath() % "/" % new_dir_name);
|
||||
}
|
||||
|
||||
emit directorieAdded(created_location.collectionPath(false));
|
||||
@@ -906,7 +906,7 @@ ElementsLocation XmlElementCollection::copyElement(
|
||||
|
||||
//Remove the previous element with the same path
|
||||
QDomElement element = child(destination.collectionPath(false)
|
||||
+ "/" + new_elmt_name);
|
||||
% "/" % new_elmt_name);
|
||||
bool removed = false;
|
||||
if (!element.isNull()) {
|
||||
element.parentNode().removeChild(element);
|
||||
@@ -919,7 +919,7 @@ ElementsLocation XmlElementCollection::copyElement(
|
||||
dir_dom.appendChild(elmt_dom);
|
||||
|
||||
ElementsLocation copy_loc(destination.projectCollectionPath()
|
||||
+ "/" + new_elmt_name);
|
||||
% "/" % new_elmt_name);
|
||||
|
||||
if (removed) {
|
||||
emit elementChanged(copy_loc.collectionPath(false));
|
||||
|
||||
@@ -108,7 +108,7 @@ QString XmlProjectElementCollectionItem::embeddedPath() const
|
||||
if (xpeci->isCollectionRoot())
|
||||
return xpeci->embeddedPath() + name();
|
||||
else
|
||||
return xpeci->embeddedPath() + "/" + name();
|
||||
return xpeci->embeddedPath() % "/" % name();
|
||||
}
|
||||
else
|
||||
return QString();
|
||||
|
||||
Reference in New Issue
Block a user