return true;
}
+qulonglong DocClipBase::fileSize() const
+{
+ return m_properties.value("file_size").toULongLong();
+}
// virtual
QDomElement DocClipBase::toXML() const
bool hasFileSize() const;
/** Returns the filesize, or 0 if there is no appropriate filesize. */
- uint fileSize() const;
+ qulonglong fileSize() const;
/** Returns true if this clip refers to the clip passed in. A clip refers to another clip if
* it uses it as part of it's own composition. */
#include "kdenlive-config.h"
#include "cliptranscode.h"
#include "ui_templateclip_ui.h"
+#include "ui_projectfiles_ui.h"
#include <KApplication>
#include <KAction>
profileName = KdenliveSettings::default_profile();
projectFolder = KdenliveSettings::defaultprojectfolder();
} else {
- ProjectSettings *w = new ProjectSettings(projectTracks.x(), projectTracks.y(), KdenliveSettings::defaultprojectfolder(), false, true, this);
+ ProjectSettings *w = new ProjectSettings(NULL, projectTracks.x(), projectTracks.y(), KdenliveSettings::defaultprojectfolder(), false, true, this);
if (w->exec() != QDialog::Accepted) return;
if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
KdenliveSettings::setVideothumbnails(w->enableVideoThumbs());
void MainWindow::slotEditProjectSettings()
{
QPoint p = m_activeDocument->getTracksCount();
- ProjectSettings *w = new ProjectSettings(p.x(), p.y(), m_activeDocument->projectFolder().path(), true, !m_activeDocument->isModified(), this);
+ ProjectSettings *w = new ProjectSettings(m_activeDocument->clipManager(), p.x(), p.y(), m_activeDocument->projectFolder().path(), true, !m_activeDocument->isModified(), this);
if (w->exec() == QDialog::Accepted) {
+ if (w->deleteUnused()) {
+ // we are going to trash the unused clips
+ m_projectList->trashUnusedClips();
+ }
QString profile = w->selectedProfile();
m_activeDocument->setProjectFolder(w->selectedFolder());
if (m_renderWidget) m_renderWidget->setDocumentPath(w->selectedFolder().path(KUrl::AddTrailingSlash));
delete w;
}
+
void MainWindow::slotRenderProject()
{
if (!m_renderWidget) {
#include <KFileDialog>
#include <KInputDialog>
#include <KMessageBox>
+#include <KIO/NetAccess>
+#include <KFileItem>
#include <nepomuk/global.h>
#include <nepomuk/resourcemanager.h>
slotRemoveClip();
}
+void ProjectList::trashUnusedClips()
+{
+ QTreeWidgetItemIterator it(m_listView);
+ ProjectItem *item;
+ QStringList ids;
+ KUrl::List urls;
+ while (*it) {
+ item = static_cast <ProjectItem *>(*it);
+ if (item->numReferences() == 0) {
+ ids << item->clipId();
+ KUrl url = item->clipUrl();
+ if (!url.isEmpty()) urls << url;
+ }
+ it++;
+ }
+ m_doc->deleteProjectClip(ids);
+ for (int i = 0; i < urls.count(); i++) {
+ KIO::NetAccess::del(urls.at(i), this);
+ }
+}
+
void ProjectList::slotReloadClip(const QString &id)
{
QList<QTreeWidgetItem *> selected;
void reloadClipThumbnails();
QDomDocument generateTemplateXml(QString data, const QString &replaceString);
void cleanup();
+ void trashUnusedClips();
public slots:
void setDocument(KdenliveDoc *doc);
#include "projectsettings.h"
#include "kdenlivesettings.h"
#include "profilesdialog.h"
+#include "docclipbase.h"
#include <KStandardDirs>
#include <KMessageBox>
#include <KDebug>
+#include <kio/directorysizejob.h>
+#include <KIO/NetAccess>
#include <QDir>
#include <kmessagebox.h>
-ProjectSettings::ProjectSettings(int videotracks, int audiotracks, const QString projectPath, bool readOnlyTracks, bool savedProject, QWidget * parent) :
- QDialog(parent), m_savedProject(savedProject)
+ProjectSettings::ProjectSettings(ClipManager *manager, int videotracks, int audiotracks, const QString projectPath, bool readOnlyTracks, bool savedProject, QWidget * parent) :
+ QDialog(parent), m_savedProject(savedProject), m_clipManager(manager), m_deleteUnused(false)
{
setupUi(this);
audio_tracks->setEnabled(false);
}
slotUpdateDisplay();
+ if (manager != NULL) {
+ slotUpdateFiles();
+ connect(clear_cache, SIGNAL(clicked()), this, SLOT(slotClearCache()));
+ connect(delete_unused, SIGNAL(clicked()), this, SLOT(slotDeleteUnused()));
+ }
+ else tabWidget->widget(1)->setEnabled(false);
connect(profiles_list, SIGNAL(currentIndexChanged(int)), this, SLOT(slotUpdateDisplay()));
connect(project_folder, SIGNAL(textChanged(const QString &)), this, SLOT(slotUpdateButton(const QString &)));
}
+void ProjectSettings::slotDeleteUnused()
+{
+ QStringList toDelete;
+ QList <DocClipBase*> list = m_clipManager->documentClipList();
+ for (int i = 0; i < list.count(); i++) {
+ DocClipBase *clip = list.at(i);
+ if (clip->numReferences() == 0) {
+ KUrl url = clip->fileURL();
+ if (!url.isEmpty()) toDelete << url.path();
+ }
+ }
+ if (toDelete.count() == 0) {
+ KMessageBox::sorry(this, i18n("No clip to delete"));
+ return;
+ }
+ if (KMessageBox::warningYesNoList(this, i18n("This will remove the following files from your hard drive.\nThis action cannot be undone, only use if you know what you are doing.\nAre you sure you want to continue?"), toDelete, i18n("Delete unused clips")) != KMessageBox::Yes) return;
+ m_deleteUnused = true;
+ delete_unused->setEnabled(false);
+}
+
+bool ProjectSettings::deleteUnused() const
+{
+ return m_deleteUnused;
+}
+
+void ProjectSettings::slotClearCache()
+{
+ buttonBox->setEnabled(false);
+ KIO::NetAccess::del(KUrl(project_folder->url().path(KUrl::AddTrailingSlash) + "thumbs/"), this);
+ KStandardDirs::makeDir(project_folder->url().path(KUrl::AddTrailingSlash) + "thumbs/");
+ buttonBox->setEnabled(true);
+ slotUpdateFiles(true);
+}
+
+void ProjectSettings::slotUpdateFiles(bool cacheOnly)
+{
+ KIO::DirectorySizeJob * job = KIO::directorySize( project_folder->url().path(KUrl::AddTrailingSlash) + "thumbs/" );
+ job->exec();
+ thumbs_count->setText(QString::number(job->totalFiles()));
+ thumbs_size->setText(KIO::convertSize(job->totalSize()));
+ delete job;
+ if (cacheOnly) return;
+ int unused = 0;
+ int used = 0;
+ KIO::filesize_t usedSize = 0;
+ KIO::filesize_t unUsedSize = 0;
+ QList <DocClipBase*> list = m_clipManager->documentClipList();
+
+ for (int i = 0; i < list.count(); i++) {
+ DocClipBase *clip = list.at(i);
+ if (clip->numReferences() == 0) {
+ unused++;
+ unUsedSize += clip->fileSize();
+ }
+ else {
+ used++;
+ usedSize += clip->fileSize();
+ }
+ }
+ used_count->setText(QString::number(used));
+ used_size->setText(KIO::convertSize(usedSize));
+ unused_count->setText(QString::number(unused));
+ unused_size->setText(KIO::convertSize(unUsedSize));
+ if (!m_deleteUnused) delete_unused->setEnabled(unused > 0);
+}
+
void ProjectSettings::accept()
{
if (!m_savedProject && selectedProfile() != KdenliveSettings::current_profile())
void ProjectSettings::slotUpdateButton(const QString &path)
{
if (path.isEmpty()) m_buttonOk->setEnabled(false);
- else m_buttonOk->setEnabled(true);
+ else {
+ m_buttonOk->setEnabled(true);
+ slotUpdateFiles(true);
+ }
}
QString ProjectSettings::selectedProfile() const
#include <QDialog>
#include <QPushButton>
+#include "clipmanager.h"
#include "ui_projectsettings_ui.h"
class ProjectSettings : public QDialog, public Ui::ProjectSettings_UI
Q_OBJECT
public:
- ProjectSettings(int videotracks, int audiotracks, const QString projectPath, bool readOnlyTracks, bool unsavedProject, QWidget * parent = 0);
+ ProjectSettings(ClipManager *manager, int videotracks, int audiotracks, const QString projectPath, bool readOnlyTracks, bool unsavedProject, QWidget * parent = 0);
QString selectedProfile() const;
KUrl selectedFolder() const;
QPoint tracks();
bool enableVideoThumbs() const;
bool enableAudioThumbs() const;
+ bool deleteUnused() const;
public slots:
virtual void accept();
private slots:
void slotUpdateDisplay();
void slotUpdateButton(const QString &path);
+ void slotUpdateFiles(bool cacheOnly = false);
+ void slotClearCache();
+ void slotDeleteUnused();
private:
QPushButton *m_buttonOk;
bool m_savedProject;
+ ClipManager *m_clipManager;
+ bool m_deleteUnused;
};