Skip to content
Extraits de code Groupes Projets
Vérifiée Valider 47ba3c78 rédigé par Kubat's avatar Kubat
Parcourir les fichiers

DOCUMENT: Create the folder if needed on rename of document

parent 5389a3bb
Aucune branche associée trouvée
Aucune étiquette associée trouvée
1 requête de fusion!3Add documents
Ce commit fait partie de la requête de fusion !3. Les commentaires créés ici seront créés dans le contexte de cette requête de fusion.
...@@ -63,11 +63,18 @@ VivyDocument::detectDocumentType(const QFileInfo &file, VivyDocument::SubDocumen ...@@ -63,11 +63,18 @@ VivyDocument::detectDocumentType(const QFileInfo &file, VivyDocument::SubDocumen
bool bool
VivyDocument::rename(const QString &name) noexcept VivyDocument::rename(const QString &name) noexcept
{ {
/* Compute new paths */
const QString newNameWithExtension = name.right(filePrefix.size()) == filePrefix ? name : name + "." + filePrefix; const QString newNameWithExtension = name.right(filePrefix.size()) == filePrefix ? name : name + "." + filePrefix;
QFileInfo oldPath(documentLocation, documentName + "." + filePrefix); QFileInfo oldPath(documentLocation, documentName + "." + filePrefix);
QFileInfo newPath(documentLocation, newNameWithExtension); QFileInfo newPath(documentLocation, newNameWithExtension);
QDir renamer;
if (renamer.rename(oldPath.absoluteFilePath(), newPath.absoluteFilePath())) { /* Create folder if needed */
QDir dirOp;
const QString newAbsDirPath = newPath.dir().absolutePath();
if (!dirOp.exists(newAbsDirPath))
dirOp.mkpath(newAbsDirPath);
if (dirOp.rename(oldPath.absoluteFilePath(), newPath.absoluteFilePath())) {
documentLocation = newPath.dir(); documentLocation = newPath.dir();
documentName = newPath.baseName(); documentName = newPath.baseName();
return true; return true;
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter