Commit 240d4321 authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Clean Project works again (remove unused clips from bin)

parent a1c63f98
......@@ -83,6 +83,11 @@ void AbstractProjectItem::setRefCount(uint count)
bin()->emitItemUpdated(this);
}
uint AbstractProjectItem::refCount() const
{
return m_usage;
}
void AbstractProjectItem::addRef()
{
m_usage++;
......
......@@ -118,6 +118,8 @@ public:
virtual QPoint zone() const;
/** @brief Set current usage count. */
void setRefCount(uint count);
/** @brief Returns clip's current usage count in timeline. */
uint refCount() const;
/** @brief Increase usage count. */
void addRef();
/** @brief Decrease usage count. */
......
......@@ -3105,3 +3105,18 @@ void Bin::resetUsageCount()
}
}
void Bin::cleanup()
{
QList <ProjectClip*> clipList = m_rootFolder->childClips();
QStringList ids;
QStringList subIds;
foreach(ProjectClip *clip, clipList) {
if (clip->refCount() == 0) {
ids << clip->clipId();
subIds << clip->subClipIds();
}
}
QUndoCommand *command = new QUndoCommand();
command->setText(i18n("Clean Project"));
m_doc->clipManager()->slotDeleteClips(ids, QStringList(), subIds, command, true);
}
......@@ -503,6 +503,8 @@ public:
bool isEmpty() const;
/** @brief Trigger reload of all clips. */
void reloadAllProducers();
/** @brief Remove all unused clip from project bin. */
void cleanup();
private slots:
void slotAddClip();
......
......@@ -195,6 +195,18 @@ ProjectSubClip* ProjectClip::getSubClip(int in, int out)
return NULL;
}
QStringList ProjectClip::subClipIds() const
{
QStringList subIds;
for (int i = 0; i < count(); ++i) {
AbstractProjectItem *clip = at(i);
if (clip) {
subIds << clip->clipId();
}
}
return subIds;
}
ProjectClip* ProjectClip::clipAt(int ix)
{
if (ix == index()) {
......
......@@ -199,6 +199,8 @@ public:
QMap <QString, QString> analysisData(bool withPrefix = false);
/** @brief Abort running audio thumb process if any. */
void abortAudioThumbs();
/** @brief Returns the list of this clip's subclip's ids. */
QStringList subClipIds() const;
public slots:
void updateAudioThumbnail(QVariantList audioLevels);
......
......@@ -1581,8 +1581,7 @@ void MainWindow::setRenderingFinished(const QString &url, int status, const QStr
void MainWindow::slotCleanProject()
{
if (KMessageBox::warningContinueCancel(this, i18n("This will remove all unused clips from your project."), i18n("Clean up project")) == KMessageBox::Cancel) return;
//TODO
//m_projectList->cleanup();
pCore->bin()->cleanup();
}
void MainWindow::slotUpdateMousePosition(int pos)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment