Allow dropping a bin folder in timeline

parent cf859f3b
......@@ -1065,6 +1065,21 @@ void Bin::slotThumbnailReady(const QString &id, const QImage &img)
if (clip) clip->setThumbnail(img);
}
QStringList Bin::getBinFolderClipIds(const QString &id) const
{
QStringList ids;
ProjectFolder *folder = m_rootFolder->folder(id);
if (folder) {
for (int i = 0; i < folder->count(); i++) {
AbstractProjectItem *child = folder->at(i);
if (child->itemType() == AbstractProjectItem::ClipItem) {
ids << child->clipId();
}
}
}
return ids;
}
ProjectClip *Bin::getBinClip(const QString &id)
{
ProjectClip *clip = NULL;
......
......@@ -379,6 +379,8 @@ public:
void selectClipById(const QString &id);
/** @brief Set focus to the Bin view. */
void focusBinView() const;
/** @brief Get a string list of all clip ids that are inside a folder defined by id. */
QStringList getBinFolderClipIds(const QString &id) const;
private slots:
void slotAddClip();
......
......@@ -1303,6 +1303,11 @@ ProjectClip *KdenliveDoc::getBinClip(const QString &clipId)
return pCore->bin()->getBinClip(clipId);
}
QStringList KdenliveDoc::getBinFolderClipIds(const QString &folderId) const
{
return pCore->bin()->getBinFolderClipIds(folderId);
}
ClipController *KdenliveDoc::getClipController(const QString &clipId)
{
return pCore->binController()->getController(clipId);
......
......@@ -92,7 +92,10 @@ public:
bool addClipInfo(QDomElement elem, QDomElement orig, const QString &clipId);
void deleteClip(const QString &clipId);
int getFramePos(const QString &duration);
/** @brief Get a bin's clip from its id. */
ProjectClip *getBinClip(const QString &clipId);
/** @brief Get a list of all clip ids that are inside a folder. */
QStringList getBinFolderClipIds(const QString &folderId) const;
ClipController *getClipController(const QString &clipId);
void updateClip(const QString &id);
......
......@@ -1702,6 +1702,19 @@ bool CustomTrackView::insertDropClips(const QMimeData *data, const QPoint &pos)
int track = (int)(framePos.y() / m_tracksHeight);
framePos.setX((int)(framePos.x() + 0.5));
framePos.setY(track * m_tracksHeight);
// Check if user dragged a folder
for (int i = 0; i < ids.size(); ++i) {
if (ids.at(i).startsWith("#")) {
QString folderId = ids.at(i);
folderId.remove(0, 1);
QStringList clipsInFolder = m_document->getBinFolderClipIds(folderId);
ids.removeAt(i);
for (int j = 0; j < clipsInFolder.count(); j++) {
ids.insert(i + j, clipsInFolder.at(j));
}
}
}
// Check if clips can be inserted at that position
for (int i = 0; i < ids.size(); ++i) {
......
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