From f1ae6c23075461d2cffd367000156e515b0c0be9 Mon Sep 17 00:00:00 2001 From: blacksun Date: Sat, 9 Apr 2016 10:45:15 +0000 Subject: [PATCH] ElementLocation : Fix addToPath. git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4435 bfdf4180-ca20-0410-9c96-a3a8aa849046 --- .../ElementsCollection/elementslocation.cpp | 32 +++++++++++++------ 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/sources/ElementsCollection/elementslocation.cpp b/sources/ElementsCollection/elementslocation.cpp index 7b238da07..74a49436f 100644 --- a/sources/ElementsCollection/elementslocation.cpp +++ b/sources/ElementsCollection/elementslocation.cpp @@ -299,16 +299,28 @@ void ElementsLocation::setPath(const QString &path) } /** - Ajoute une chaine au chemin - @param string Chaine a ajouter - @return true si l'operation a reussi, false si l'operation n'a pas de sens. - Par exemple, il n'y a pas de sens a vouloir ajouter quelque chose apres le - chemin d'un element. -*/ -bool ElementsLocation::addToPath(const QString &string) { - if (m_collection_path.endsWith(".elmt", Qt::CaseInsensitive)) return(false); - if (!m_collection_path.endsWith("/") && !string.startsWith("/")) m_collection_path += "/"; - m_collection_path += string; + * @brief ElementsLocation::addToPath + * Add a string to the actual path of this location + * @param string + * @return True if the operation success + */ +bool ElementsLocation::addToPath(const QString &string) +{ + if (m_collection_path.endsWith(".elmt", Qt::CaseInsensitive)) + { + qDebug() << "ElementsLocation::addToPath : Can't add string to the path of an element"; + return(false); + } + + QString added_path = string; + + if (!m_collection_path.endsWith("/") && !added_path.startsWith("/")) + added_path.prepend("/"); + + if (isFileSystem()) + m_file_system_path += added_path; + + m_collection_path += added_path; return(true); }