Delete unused clipmanager

parent e8642c24
......@@ -38,7 +38,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "mltcontroller/clipcontroller.h"
#include "mltcontroller/clippropertiescontroller.h"
#include "monitor/monitor.h"
#include "project/clipmanager.h"
#include "project/dialogs/slideshowclip.h"
#include "project/invaliddialog.h"
#include "project/projectcommands.h"
......
......@@ -37,7 +37,6 @@
#include "mltcontroller/effectscontroller.h"
#include "profiles/profilemodel.hpp"
#include "profiles/profilerepository.hpp"
#include "project/clipmanager.h"
#include "project/projectcommands.h"
#include "renderer.h"
#include "titler/titlewidget.h"
......@@ -86,9 +85,6 @@ KdenliveDoc::KdenliveDoc(const QUrl &url, const QString &projectFolder, QUndoGro
m_commandStack = std::make_shared<DocUndoStack>(undoGroup);
m_guideModel.reset(new MarkerListModel(m_commandStack, this));
connect(m_guideModel.get(), &MarkerListModel::modelChanged, this, &KdenliveDoc::guidesChanged);
m_clipManager = new ClipManager(this);
connect(m_clipManager, SIGNAL(displayMessage(QString, int)), parent, SLOT(slotGotProgressInfo(QString, int)));
connect(this, SIGNAL(updateCompositionMode(int)), parent, SLOT(slotUpdateCompositeAction(int)));
bool success = false;
connect(m_commandStack.get(), &QUndoStack::indexChanged, this, &KdenliveDoc::slotModified);
......@@ -287,7 +283,6 @@ KdenliveDoc::~KdenliveDoc()
// qCDebug(KDENLIVE_LOG) << "// DEL CLP MAN";
// Clean up guide model
m_guideModel.reset();
delete m_clipManager;
// qCDebug(KDENLIVE_LOG) << "// DEL CLP MAN done";
if (m_autosave) {
if (!m_autosave->fileName().isEmpty()) {
......@@ -596,11 +591,6 @@ bool KdenliveDoc::saveSceneList(const QString &path, const QString &scene)
return true;
}
ClipManager *KdenliveDoc::clipManager()
{
return m_clipManager;
}
QString KdenliveDoc::projectTempFolder() const
{
if (m_projectFolder.isEmpty()) {
......
......@@ -39,7 +39,6 @@
#include "mltcontroller/effectscontroller.h"
#include "timecode.h"
class ClipManager;
class MainWindow;
class TrackInfo;
class ProjectClip;
......@@ -76,7 +75,6 @@ public:
Timecode timecode() const;
QDomDocument toXml();
std::shared_ptr<DocUndoStack> commandStack();
ClipManager *clipManager();
int getFramePos(const QString &duration);
/** @brief Get a bin's clip from its id. */
......@@ -165,7 +163,6 @@ private:
QString m_documentRoot;
Timecode m_timecode;
std::shared_ptr<DocUndoStack> m_commandStack;
ClipManager *m_clipManager;
QString m_searchFolder;
/** @brief Tells whether the current document has been changed after being saved. */
......
......@@ -52,7 +52,6 @@
#include "monitor/monitormanager.h"
#include "monitor/scopes/audiographspectrum.h"
#include "profiles/profilemodel.hpp"
#include "project/clipmanager.h"
#include "project/cliptranscode.h"
#include "project/dialogs/archivewidget.h"
#include "project/dialogs/projectsettings.h"
......
add_subdirectory(dialogs)
set(kdenlive_SRCS
${kdenlive_SRCS}
project/clipmanager.cpp
project/clipstabilize.cpp
project/cliptranscode.cpp
project/invaliddialog.cpp
......
/***************************************************************************
* Copyright (C) 2008 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
#include "clipmanager.h"
#include "bin/bin.h"
#include "bin/bincommands.h"
#include "core.h"
#include "dialogs/slideshowclip.h"
#include "doc/docundostack.hpp"
#include "doc/kdenlivedoc.h"
#include "doc/kthumb.h"
#include "kdenlivesettings.h"
#include "mltcontroller/bincontroller.h"
#include "mltcontroller/clipcontroller.h"
#include "project/projectmanager.h"
#include "renderer.h"
#include "titler/titledocument.h"
#include <mlt++/Mlt.h>
#include <KIO/JobUiDelegate>
#include <KIO/MkdirJob>
#include <KJobWidgets/KJobWidgets>
#include <klocalizedstring.h>
#include <QApplication>
#include <QCheckBox>
#include <QGraphicsItemGroup>
#include <QtConcurrent>
ClipManager::ClipManager(KdenliveDoc *doc)
: QObject()
, m_audioThumbsQueue()
, m_doc(doc)
, m_abortThumb(false)
, m_closing(false)
, m_abortAudioThumb(false)
{
}
ClipManager::~ClipManager()
{
m_closing = true;
m_abortThumb = true;
m_abortAudioThumb = true;
m_thumbsThread.waitForFinished();
m_audioThumbsThread.waitForFinished();
m_thumbsMutex.lock();
m_requestedThumbs.clear();
m_audioThumbsQueue.clear();
m_thumbsMutex.unlock();
}
void ClipManager::clear()
{
m_abortThumb = true;
m_abortAudioThumb = true;
m_thumbsThread.waitForFinished();
m_audioThumbsThread.waitForFinished();
m_thumbsMutex.lock();
m_requestedThumbs.clear();
m_audioThumbsQueue.clear();
m_thumbsMutex.unlock();
m_abortThumb = false;
m_abortAudioThumb = false;
m_folderList.clear();
m_modifiedClips.clear();
}
void ClipManager::slotRequestThumbs(const QString &id, const QList<int> &frames)
{
m_thumbsMutex.lock();
for (int frame : frames) {
m_requestedThumbs.insertMulti(id, frame);
}
m_thumbsMutex.unlock();
if (!m_thumbsThread.isRunning() && !m_abortThumb) {
m_thumbsThread = QtConcurrent::run(this, &ClipManager::slotGetThumbs);
}
}
void ClipManager::stopThumbs(const QString &id)
{
if (m_closing || (m_requestedThumbs.isEmpty() && m_processingThumbId != id && m_audioThumbsQueue.isEmpty() && m_processingAudioThumbId != id)) {
return;
}
// Abort video thumbs for this clip
m_abortThumb = true;
m_thumbsThread.waitForFinished();
m_thumbsMutex.lock();
m_requestedThumbs.remove(id);
m_audioThumbsQueue.removeAll(id);
m_thumbsMutex.unlock();
m_abortThumb = false;
// Abort audio thumbs for this clip
if (m_processingAudioThumbId == id) {
m_abortAudioThumb = true;
m_audioThumbsThread.waitForFinished();
m_abortAudioThumb = false;
}
if (!m_thumbsThread.isRunning() && !m_requestedThumbs.isEmpty()) {
m_thumbsThread = QtConcurrent::run(this, &ClipManager::slotGetThumbs);
}
}
void ClipManager::slotGetThumbs()
{
QMap<QString, int>::const_iterator i;
while (!m_requestedThumbs.isEmpty() && !m_abortThumb) {
m_thumbsMutex.lock();
i = m_requestedThumbs.constBegin();
m_processingThumbId = i.key();
QList<int> values = m_requestedThumbs.values(m_processingThumbId);
m_requestedThumbs.remove(m_processingThumbId);
// TODO int thumbType = 0; // 0 = timeline thumb, 1 = project clip zone thumb, 2 = clip properties thumb
if (m_processingThumbId.startsWith(QLatin1String("?"))) {
// if id starts with ?, it means the request comes from a clip property widget
// TODO thumbType = 2;
m_processingThumbId.remove(0, 1);
}
if (m_processingThumbId.startsWith(QLatin1String("#"))) {
// if id starts with #, it means the request comes from project tree
// TODO thumbType = 1;
m_processingThumbId.remove(0, 1);
}
m_thumbsMutex.unlock();
qSort(values);
// TODO
/*
DocClipBase *clip = getClipById(m_processingThumbId);
if (!clip) continue;
max = m_requestedThumbs.size() + values.count();
// keep in sync with declaration un projectitem.cpp and subprojectitem.cpp
int minHeight = qMax(38, QFontMetrics(QApplication::font()).lineSpacing() * 2);
while (!values.isEmpty() && clip->thumbProducer() && !m_abortThumb) {
int pos = values.takeFirst();
switch (thumbType) {
case 1:
clip->thumbProducer()->getGenericThumb(pos, minHeight, thumbType);
break;
case 2:
clip->thumbProducer()->getGenericThumb(pos, 180, thumbType);
break;
default:
clip->thumbProducer()->getThumb(pos);
}
done++;
if (max > 3) emit displayMessage(i18n("Loading thumbnails"), 100 * done / max);
}
*/
}
m_processingThumbId.clear();
emit displayMessage(QString(), -1);
}
void ClipManager::slotAddCopiedClip(KIO::Job *, const QUrl &, const QUrl &dst)
{
pCore->bin()->droppedUrls(QList<QUrl>() << dst);
}
int ClipManager::lastClipId() const
{
return pCore->bin()->lastClipId();
}
/*
void ClipManager::slotClipMissing(const QString &path)
{
qCDebug(KDENLIVE_LOG) << "// CLIP: " << path << " WAS MISSING";
//TODO
const QList<DocClipBase *> list = getClipByResource(path);
for (int i = 0; i < list.count(); ++i) {
DocClipBase *clip = list.at(i);
if (clip != nullptr) emit missingClip(clip->getId());
}
}
void ClipManager::slotClipAvailable(const QString &path)
{
qCDebug(KDENLIVE_LOG) << "// CLIP: " << path << " WAS ADDED";
//TODO
const QList<DocClipBase *> list = getClipByResource(path);
for (int i = 0; i < list.count(); ++i) {
DocClipBase *clip = list.at(i);
if (clip != nullptr) emit availableClip(clip->getId());
}
}
*/
void ClipManager::projectTreeThumbReady(const QString &id, int frame, const QImage &img, int type)
{
switch (type) {
case 2:
emit gotClipPropertyThumbnail(id, img);
break;
default:
emit thumbReady(id, frame, img);
}
}
/***************************************************************************
* Copyright (C) 2008 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
#ifndef CLIPMANAGER_H
#define CLIPMANAGER_H
#include <QFuture>
#include <QMutex>
#include <QObject>
#include <qdom.h>
#include <KIO/CopyJob>
#include <QUrl>
#include "definitions.h"
#include "gentime.h"
class KdenliveDoc;
class AbstractGroupItem;
class QUndoCommand;
class SolidVolumeInfo
{
public:
QString path; // mount path of volume, with trailing slash
QString uuid; // UUID as from Solid
QString label; // volume label (think of CDs)
bool isRemovable; // may be removed
bool isMounted;
bool isNull() const { return path.isNull(); }
};
namespace Mlt {
}
/**
* @class ClipManager
* @brief Takes care of clip operations that might affect timeline and bin
*/
class ClipManager : public QObject
{
Q_OBJECT public :
explicit ClipManager(KdenliveDoc *doc);
virtual ~ClipManager();
int lastClipId() const;
/** @brief Prepare deletion of clips and folders from the Bin. */
void clear();
/** @brief remove a clip id from the queue list. */
void stopThumbs(const QString &id);
void projectTreeThumbReady(const QString &id, int frame, const QImage &img, int type);
public slots:
/** @brief Request creation of a clip thumbnail for specified frames. */
void slotRequestThumbs(const QString &id, const QList<int> &frames);
private slots:
void slotGetThumbs();
/** @brief Clip has been copied, add it now. */
void slotAddCopiedClip(KIO::Job *, const QUrl &, const QUrl &dst);
private: // Private attributes
/** @brief the list of groups in the document */
QList<AbstractGroupItem *> m_groupsList;
QMap<QString, QString> m_folderList;
QList<QString> m_audioThumbsQueue;
/** the document undo stack*/
KdenliveDoc *m_doc;
/** List of the clip IDs that need to be reloaded after being externally modified */
QMap<QString, QTime> m_modifiedClips;
/** Struct containing the list of clip thumbnails to request (clip id and frames) */
QMap<QString, int> m_requestedThumbs;
QMutex m_thumbsMutex;
QFuture<void> m_thumbsThread;
/** @brief The id of currently processed clip for thumbs creation. */
QString m_processingThumbId;
/** @brief If true, abort processing of clip thumbs before removing a clip. */
bool m_abortThumb;
/** @brief We are about to delete the clip producer, stop processing thumbs. */
bool m_closing;
QFuture<void> m_audioThumbsThread;
/** @brief If true, abort processing of audio thumbs. */
bool m_abortAudioThumb;
/** @brief The id of currently processed clip for audio thumbs creation. */
QString m_processingAudioThumbId;
QMutex m_groupsMutex;
QPoint m_projectTreeThumbSize;
signals:
void reloadClip(const QString &);
void modifiedClip(const QString &);
void missingClip(const QString &);
void availableClip(const QString &);
void checkAllClips(bool displayRatioChanged, bool fpsChanged, const QStringList &brokenClips);
void displayMessage(const QString &, int);
void thumbReady(const QString &id, int, const QImage &);
void gotClipPropertyThumbnail(const QString &id, const QImage &);
};
#endif
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