]> git.sesse.net Git - kdenlive/blobdiff - src/archivewidget.cpp
const'ref
[kdenlive] / src / archivewidget.cpp
index 569d336ac7dd6a02dc33d1e93ef89c45db291252..e942b1524e66309e1ca066a2a414c70700a067c5 100644 (file)
 #include "projectsettings.h"
 
 
-ArchiveWidget::ArchiveWidget(QString projectName, QDomDocument doc, QList <DocClipBase*> list, QStringList luma_list, QWidget * parent) :
-        QDialog(parent),
-        m_requestedSize(0),
-        m_copyJob(NULL),
-        m_name(projectName.section('.', 0, -2)),
-        m_doc(doc),
-        m_abortArchive(false),
-        m_extractMode(false),
-        m_extractArchive(NULL),
-        m_missingClips(0)
+ArchiveWidget::ArchiveWidget(const QString &projectName, const QDomDocument &doc, const QList <DocClipBase*> &list, const QStringList &luma_list, QWidget * parent) :
+        QDialog(parent)
+        , m_requestedSize(0)
+        , m_copyJob(NULL)
+        , m_name(projectName.section('.', 0, -2))
+        , m_doc(doc)
+       , m_temp(NULL)
+        , m_abortArchive(false)
+        , m_extractMode(false)
+       , m_progressTimer(NULL)
+        , m_extractArchive(NULL)
+        , m_missingClips(0)
 {
     setAttribute(Qt::WA_DeleteOnClose);
     setupUi(this);
     setWindowTitle(i18n("Archive Project"));
     archive_url->setUrl(KUrl(QDir::homePath()));
-    connect(archive_url, SIGNAL(textChanged (const QString &)), this, SLOT(slotCheckSpace()));
+    connect(archive_url, SIGNAL(textChanged(QString)), this, SLOT(slotCheckSpace()));
     connect(this, SIGNAL(archivingFinished(bool)), this, SLOT(slotArchivingFinished(bool)));
     connect(this, SIGNAL(archiveProgress(int)), this, SLOT(slotArchivingProgress(int)));
     connect(proxy_only, SIGNAL(stateChanged(int)), this, SLOT(slotProxyOnly(int)));
@@ -115,7 +117,7 @@ ArchiveWidget::ArchiveWidget(QString projectName, QDomDocument doc, QList <DocCl
     QMap <QString, QString>playlistUrls;
     QMap <QString, QString>proxyUrls;
 
-    for (int i = 0; i < list.count(); i++) {
+    for (int i = 0; i < list.count(); ++i) {
         DocClipBase *clip = list.at(i);
         CLIPTYPE t = clip->clipType();
         QString id = clip->getId();
@@ -182,7 +184,7 @@ ArchiveWidget::ArchiveWidget(QString projectName, QDomDocument doc, QList <DocCl
 
     // Hide unused categories, add item count
     int total = 0;
-    for (int i = 0; i < files_list->topLevelItemCount(); i++) {
+    for (int i = 0; i < files_list->topLevelItemCount(); ++i) {
         QTreeWidgetItem *parentItem = files_list->topLevelItem(i);
         int items = parentItem->childCount();
         if (items == 0) {
@@ -206,7 +208,7 @@ ArchiveWidget::ArchiveWidget(QString projectName, QDomDocument doc, QList <DocCl
     buttonBox->button(QDialogButtonBox::Apply)->setText(i18n("Archive"));
     connect(buttonBox->button(QDialogButtonBox::Apply), SIGNAL(clicked()), this, SLOT(slotStartArchiving()));
     buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false);
-
+    
     slotCheckSpace();
 }
 
@@ -219,8 +221,12 @@ ArchiveWidget::ArchiveWidget(const KUrl &url, QWidget * parent):
     //setAttribute(Qt::WA_DeleteOnClose);
 
     setupUi(this);
+    m_progressTimer = new QTimer;
+    m_progressTimer->setInterval(800);
+    m_progressTimer->setSingleShot(false);
+    connect(m_progressTimer, SIGNAL(timeout()), this, SLOT(slotExtractProgress()));
     connect(this, SIGNAL(extractingFinished()), this, SLOT(slotExtractingFinished()));
-    connect(this, SIGNAL(showMessage(const QString &, const QString &)), this, SLOT(slotDisplayMessage(const QString &, const QString &)));
+    connect(this, SIGNAL(showMessage(QString,QString)), this, SLOT(slotDisplayMessage(QString,QString)));
     
     compressed_archive->setHidden(true);
     proxy_only->setHidden(true);
@@ -239,7 +245,8 @@ ArchiveWidget::ArchiveWidget(const KUrl &url, QWidget * parent):
 
 ArchiveWidget::~ArchiveWidget()
 {
-    if (m_extractArchive) delete m_extractArchive;
+    delete m_extractArchive;
+    delete m_progressTimer;
 }
 
 void ArchiveWidget::slotDisplayMessage(const QString &icon, const QString &text)
@@ -318,7 +325,7 @@ bool ArchiveWidget::closeAccepted()
 }
 
 
-void ArchiveWidget::generateItems(QTreeWidgetItem *parentItem, QStringList items)
+void ArchiveWidget::generateItems(QTreeWidgetItem *parentItem, const QStringList& items)
 {
     QStringList filesList;
     QString fileName;
@@ -336,7 +343,6 @@ void ArchiveWidget::generateItems(QTreeWidgetItem *parentItem, QStringList items
             if (slideUrl.fileName().startsWith(".all.")) {
                 // mimetype slideshow (for example *.png)
                     QStringList filters;
-                    QString extension;
                     // TODO: improve jpeg image detection with extension like jpeg, requires change in MLT image producers
                     filters << "*." + slideUrl.fileName().section('.', -1);
                     dir.setNameFilters(filters);
@@ -400,7 +406,7 @@ void ArchiveWidget::generateItems(QTreeWidgetItem *parentItem, QStringList items
     }
 }
 
-void ArchiveWidget::generateItems(QTreeWidgetItem *parentItem, QMap <QString, QString> items)
+void ArchiveWidget::generateItems(QTreeWidgetItem *parentItem, const QMap <QString, QString>& items)
 {
     QStringList filesList;
     QString fileName;
@@ -422,7 +428,6 @@ void ArchiveWidget::generateItems(QTreeWidgetItem *parentItem, QMap <QString, QS
             if (slideUrl.fileName().startsWith(".all.")) {
                 // mimetype slideshow (for example *.png)
                     QStringList filters;
-                    QString extension;
                     // TODO: improve jpeg image detection with extension like jpeg, requires change in MLT image producers
                     filters << "*." + slideUrl.fileName().section('.', -1);
                     dir.setNameFilters(filters);
@@ -603,8 +608,8 @@ bool ArchiveWidget::slotStartArchiving(bool firstPass)
             KUrl startJobDst = i.value();
             m_duplicateFiles.remove(startJobSrc);
             KIO::CopyJob *job = KIO::copyAs(startJobSrc, startJobDst, KIO::HideProgressInfo);
-            connect(job, SIGNAL(result(KJob *)), this, SLOT(slotArchivingFinished(KJob *)));
-            connect(job, SIGNAL(processedSize(KJob *, qulonglong)), this, SLOT(slotArchivingProgress(KJob *, qulonglong)));
+            connect(job, SIGNAL(result(KJob*)), this, SLOT(slotArchivingFinished(KJob*)));
+            connect(job, SIGNAL(processedSize(KJob*,qulonglong)), this, SLOT(slotArchivingProgress(KJob*,qulonglong)));
         }
         return true;
     }
@@ -622,8 +627,8 @@ bool ArchiveWidget::slotStartArchiving(bool firstPass)
     else {
         KIO::NetAccess::mkdir(destUrl, this);
         m_copyJob = KIO::copy (files, destUrl, KIO::HideProgressInfo);
-        connect(m_copyJob, SIGNAL(result(KJob *)), this, SLOT(slotArchivingFinished(KJob *)));
-        connect(m_copyJob, SIGNAL(processedSize(KJob *, qulonglong)), this, SLOT(slotArchivingProgress(KJob *, qulonglong)));
+        connect(m_copyJob, SIGNAL(result(KJob*)), this, SLOT(slotArchivingFinished(KJob*)));
+        connect(m_copyJob, SIGNAL(processedSize(KJob*,qulonglong)), this, SLOT(slotArchivingProgress(KJob*,qulonglong)));
     }
     if (firstPass) {
         progressBar->setValue(0);
@@ -825,9 +830,12 @@ void ArchiveWidget::createArchive()
     }
 
     // Add project file
-    archive.addLocalFile(m_temp->fileName(), m_name + ".kdenlive");
-    bool result = archive.close();
-    delete m_temp;
+    bool result = false;
+    if (m_temp) {
+       archive.addLocalFile(m_temp->fileName(), m_name + ".kdenlive");
+       result = archive.close();
+       delete m_temp;
+    }
     emit archivingFinished(result);
 }
 
@@ -868,10 +876,6 @@ void ArchiveWidget::slotStartExtracting()
     KIO::NetAccess::mkdir(archive_url->url().path(KUrl::RemoveTrailingSlash), this);
     slotDisplayMessage("system-run", i18n("Extracting..."));
     buttonBox->button(QDialogButtonBox::Apply)->setText(i18n("Abort"));
-    m_progressTimer = new QTimer;
-    m_progressTimer->setInterval(800);
-    m_progressTimer->setSingleShot(false);
-    connect(m_progressTimer, SIGNAL(timeout()), this, SLOT(slotExtractProgress()));
     m_archiveThread = QtConcurrent::run(this, &ArchiveWidget::doExtracting);
     m_progressTimer->start();
 }
@@ -906,7 +910,6 @@ QString ArchiveWidget::extractedProjectFile()
 void ArchiveWidget::slotExtractingFinished()
 {
     m_progressTimer->stop();
-    delete m_progressTimer;
     // Process project file
     QFile file(extractedProjectFile());
     bool error = false;