Skip to content
Extraits de code Groupes Projets

Implement the VivyDocument specification

Fusionnées Kubat a demandé de fusionner vivy-doc vers master
5 files
+ 57
13
Comparer les modifications
  • Côte à côte
  • En ligne

Fichiers

+ 41
11
@@ -233,19 +233,11 @@ VivyDocument::detectDocumentType(const QFileInfo &file, Capabilities *ableType)
void
VivyDocument::copy(const QString &newName)
{
const QString newNameWithExtension =
(newName.right(fileSuffix.size()) == fileSuffix) ? newName : newName + "." + fileSuffix;
const QFileInfo newPath(documentLocation, newNameWithExtension);
const QFileInfo newPath = computeFileInfo(newName);
// Rename + create the disk on disk as it's a memory document
if (documentOptions & MemoryDocumentCreation) {
documentName = newPath.baseName();
documentLocation = newPath.absoluteDir();
documentOptions = static_cast<Options>(documentOptions & (~MemoryDocumentCreation));
qDebug().nospace() << "Renaming a memory file => create it on disk with { "
<< documentLocation << ", " << documentName << " }";
save();
}
if (documentOptions & MemoryDocumentCreation)
return saveMemoryFile(newPath);
// Compute new paths, the document is really on disk initially
else {
@@ -257,6 +249,44 @@ VivyDocument::copy(const QString &newName)
}
}
void
VivyDocument::rename(const QString &newName)
{
const QFileInfo newPath = computeFileInfo(newName);
// Rename + create the disk on disk as it's a memory document
if (documentOptions & MemoryDocumentCreation)
return saveMemoryFile(newPath);
// Compute new paths, the document is really on disk initially
else {
qDebug() << "Renaming a real file";
renameWith(newPath, [=, this]() noexcept -> void {
documentLocation = newPath.dir();
documentName = newPath.baseName();
});
}
}
QFileInfo
VivyDocument::computeFileInfo(const QString &newName) const noexcept
{
const QString newNameWithExtension =
(newName.right(fileSuffix.size()) == fileSuffix) ? newName : newName + "." + fileSuffix;
return QFileInfo(documentLocation, newNameWithExtension);
}
void
VivyDocument::saveMemoryFile(const QFileInfo &newPath)
{
documentName = newPath.baseName();
documentLocation = newPath.absoluteDir();
documentOptions = static_cast<Options>(documentOptions & (~MemoryDocumentCreation));
qDebug().nospace() << "Renaming a memory file => create it on disk with { " << documentLocation
<< ", " << documentName << " }";
save();
}
std::shared_ptr<AudioSubDocument>
VivyDocument::getAudioSubDocument() const noexcept
{
Chargement en cours