]> git.sesse.net Git - kdenlive/commitdiff
Add a timestamp as "documentid" property to the kdenlive project file to identify...
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Mon, 6 Jun 2011 14:36:06 +0000 (14:36 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Mon, 6 Jun 2011 14:36:06 +0000 (14:36 +0000)
svn path=/trunk/kdenlive/; revision=5669

src/databackup/backupwidget.cpp
src/databackup/backupwidget.h
src/kdenlivedoc.cpp
src/mainwindow.cpp

index cf862656fe39cb0e77d7cac8aa78b62da89dfbf0..31c07ad719edc8fa4d9f5ab24b1a4661782484be 100644 (file)
@@ -24,7 +24,7 @@
 #include <KUrl>
 
 
-BackupWidget::BackupWidget(KUrl projectUrl, KUrl projectFolder, QWidget * parent) :
+BackupWidget::BackupWidget(KUrl projectUrl, KUrl projectFolder, const QString projectId, QWidget * parent) :
         QDialog(parent),
         m_url(projectUrl)
 {
@@ -34,7 +34,11 @@ BackupWidget::BackupWidget(KUrl projectUrl, KUrl projectFolder, QWidget * parent
     KUrl backupFile;
     m_projectWildcard = projectUrl.fileName().section('.', 0, -2);
     project_url->setUrl(projectFolder);
-    
+    if (!projectId.isEmpty()) m_projectWildcard.append("-" + projectId);
+    else {
+        // No project id, it was lost, add wildcard
+        m_projectWildcard.append("*");
+    }
     m_projectWildcard.append("-??");
     m_projectWildcard.append("??");
     m_projectWildcard.append("-??");
index 566dbd53e9cb753f07db8bcabbe712fd903d899d..9c2fa0c9188a55560a21848e0807c8c737d5e82b 100644 (file)
@@ -37,7 +37,7 @@ class BackupWidget : public QDialog, public Ui::BackupDialog_UI
     Q_OBJECT
 
 public:
-    BackupWidget(KUrl projectUrl, KUrl projectFolder, QWidget * parent = 0);
+    BackupWidget(KUrl projectUrl, KUrl projectFolder, const QString projectId, QWidget * parent = 0);
     // Constructor for extracting widget
     ~BackupWidget();
     /** @brief Return the path for selected backup file. */
index 35355db0e74b989442973f1d21e2085d218b3198..76d4e5d685b0a989d3664ce9f1f9561effab8f8b 100644 (file)
@@ -81,7 +81,13 @@ KdenliveDoc::KdenliveDoc(const KUrl &url, const KUrl &projectFolder, QUndoGroup
     m_documentProperties["proxyminsize"] = QString::number(KdenliveSettings::proxyminsize());
     m_documentProperties["generateimageproxy"] = QString::number((int) KdenliveSettings::generateimageproxy());
     m_documentProperties["proxyimageminsize"] = QString::number(KdenliveSettings::proxyimageminsize());
-    
+#if QT_VERSION >= 0x040700
+    m_documentProperties["documentid"] = QString::number(QDateTime::currentMSecsSinceEpoch());
+#else
+    QDateTime date = QDateTime::currentDateTime();
+    m_documentProperties["documentid"] = QString::number(date.toTime_t());
+#endif
+
     // Load properties
     QMapIterator<QString, QString> i(properties);
     while (i.hasNext()) {
@@ -1606,6 +1612,7 @@ void KdenliveDoc::backupLastSavedVersion(const QString &path)
     KIO::NetAccess::mkdir(backupFile, kapp->activeWindow());
     QString fileName = KUrl(path).fileName().section('.', 0, -2);
     QFileInfo info(file);
+    fileName.append("-" + m_documentProperties.value("documentid"));
     fileName.append(info.lastModified().toString("-yyyy-MM-dd-hh-mm"));
     fileName.append(".kdenlive");
     backupFile.addPath(fileName);
@@ -1627,6 +1634,7 @@ void KdenliveDoc::cleanupBackupFiles()
     backupFile.addPath(".backup/");
     QDir dir(backupFile.path());
     QString projectFile = url().fileName().section('.', 0, -2);
+    projectFile.append("-" + m_documentProperties.value("documentid"));
     projectFile.append("-??");
     projectFile.append("??");
     projectFile.append("-??");
index 902e8519872dc85c66aa4bc9feff547554afdc3e..1674d785a2a4868c7f8133e7a2abf120a31b746c 100644 (file)
@@ -4277,6 +4277,7 @@ void MainWindow::slotOpenBackupDialog(const KUrl url)
 {
     KUrl projectFile;
     KUrl projectFolder;
+    QString projectId;
     kDebug()<<"// BACKUP URL: "<<url.path();
     if (!url.isEmpty()) {
         // we could not open the project file, guess where the backups are
@@ -4286,15 +4287,17 @@ void MainWindow::slotOpenBackupDialog(const KUrl url)
     else {
         projectFolder = m_activeDocument->projectFolder();
         projectFile = m_activeDocument->url();
+        projectId = m_activeDocument->getDocumentProperty("documentid");
     }
 
-    BackupWidget *dia = new BackupWidget(projectFile, projectFolder, this);
+    BackupWidget *dia = new BackupWidget(projectFile, projectFolder, projectId, this);
     if (dia->exec() == QDialog::Accepted) {
         QString requestedBackup = dia->selectedFile();
         m_activeDocument->backupLastSavedVersion(projectFile.path());
         closeCurrentDocument(false);
         doOpenFile(KUrl(requestedBackup), NULL);
         m_activeDocument->setUrl(projectFile);
+        m_activeDocument->setModified(true);
         setCaption(m_activeDocument->description());
     }
     delete dia;