jogshuttle.cpp
addtransitioncommand.cpp
edittransitioncommand.cpp
+ addfoldercommand.cpp
+ editfoldercommand.cpp
)
kde4_add_kcfg_files(kdenlive_SRCS GENERATE_MOC kdenlivesettings.kcfgc )
--- /dev/null
+/***************************************************************************
+ * Copyright (C) 2007 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 <KLocale>
+
+#include "addfoldercommand.h"
+#include "kdenlivedoc.h"
+
+AddFolderCommand::AddFolderCommand(KdenliveDoc *doc, const QString folderName, int clipId, bool doIt)
+ : m_doc(doc), m_name(folderName), m_id(clipId), m_doIt(doIt) {
+ if (doIt) setText(i18n("Add folder"));
+ else setText(i18n("Delete folder"));
+}
+
+// virtual
+void AddFolderCommand::undo() {
+ if (m_doIt) m_doc->deleteFolder(m_name, m_id);
+ else m_doc->addFolder(m_name, m_id, false);
+}
+// virtual
+void AddFolderCommand::redo() {
+ if (m_doIt) m_doc->addFolder(m_name, m_id, false);
+ else m_doc->deleteFolder(m_name, m_id);
+}
+
+#include "addfoldercommand.moc"
--- /dev/null
+/***************************************************************************
+ * Copyright (C) 2007 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 ADDFOLDERCOMMAND_H
+#define ADDFOLDERCOMMAND_H
+
+#include <QUndoCommand>
+
+class KdenliveDoc;
+
+class AddFolderCommand : public QUndoCommand {
+public:
+ AddFolderCommand(KdenliveDoc *doc, const QString folderName, int clipId, bool doIt);
+
+ virtual void undo();
+ virtual void redo();
+
+private:
+ KdenliveDoc *m_doc;
+ QString m_name;
+ int m_id;
+ bool m_doIt;
+};
+
+#endif
+
void ClipManager::slotDeleteClip(uint clipId) {
for (int i = 0; i < m_clipList.count(); i++) {
if (m_clipList.at(i)->getId() == clipId) {
- //m_clipList.removeAt(i);
AddClipCommand *command = new AddClipCommand(m_doc, m_clipList.at(i)->toXML(), clipId, false);
m_doc->commandStack()->push(command);
break;
return NULL;
}
-void ClipManager::slotAddClipFile(const KUrl url, const QString group) {
+void ClipManager::slotAddClipFile(const KUrl url, const QString group, const int groupId) {
kDebug() << "///// CLIP MANAGER, ADDING CLIP: " << url;
QDomDocument doc;
QDomElement prod = doc.createElement("producer");
prod.setAttribute("resource", url.path());
uint id = m_clipIdCounter++;
prod.setAttribute("id", QString::number(id));
- if (!group.isEmpty()) prod.setAttribute("group", group);
+ if (!group.isEmpty()) {
+ prod.setAttribute("groupname", group);
+ prod.setAttribute("groupid", groupId);
+ }
KMimeType::Ptr type = KMimeType::findByUrl(url);
if (type->name().startsWith("image/")) {
prod.setAttribute("type", (int) IMAGE);
m_doc->commandStack()->push(command);
}
-void ClipManager::slotAddColorClipFile(const QString name, const QString color, QString duration, const QString group) {
+void ClipManager::slotAddColorClipFile(const QString name, const QString color, QString duration, const QString group, const int groupId) {
QDomDocument doc;
QDomElement prod = doc.createElement("producer");
prod.setAttribute("mlt_service", "colour");
prod.setAttribute("in", "0");
prod.setAttribute("out", m_doc->getFramePos(duration));
prod.setAttribute("name", name);
+ if (!group.isEmpty()) {
+ prod.setAttribute("groupname", group);
+ prod.setAttribute("groupid", groupId);
+ }
AddClipCommand *command = new AddClipCommand(m_doc, prod, id, true);
m_doc->commandStack()->push(command);
}
+int ClipManager::getFreeClipId() {
+ return m_clipIdCounter++;
+}
+
+
void addClip(DocClipBase *clip);
DocClipBase *getClipAt(int pos);
void deleteClip(uint clipId);
- void slotAddClipFile(const KUrl url, const QString group);
- void slotAddColorClipFile(const QString name, const QString color, QString duration, const QString group);
+ void slotAddClipFile(const KUrl url, const QString group, const int groupId);
+ void slotAddColorClipFile(const QString name, const QString color, QString duration, const QString group, const int groupId);
DocClipBase *getClipById(int clipId);
void slotDeleteClip(uint clipId);
void setThumbsProgress(KUrl url, int progress);
void checkAudioThumbs();
QList <DocClipBase*> documentClipList();
+ int getFreeClipId();
private: // Private attributes
/** the list of clips in the document */
#define MAXCLIPDURATION 15000
enum OPERATIONTYPE { NONE = 0, MOVE = 1, RESIZESTART = 2, RESIZEEND = 3, FADEIN = 4, FADEOUT = 5, TRANSITIONSTART = 6, TRANSITIONEND = 7};
-enum CLIPTYPE { UNKNOWN = 0, AUDIO = 1, VIDEO = 2, AV = 3, COLOR = 4, IMAGE = 5, TEXT = 6, SLIDESHOW = 7, VIRTUAL = 8, PLAYLIST = 9};
+enum CLIPTYPE { UNKNOWN = 0, AUDIO = 1, VIDEO = 2, AV = 3, COLOR = 4, IMAGE = 5, TEXT = 6, SLIDESHOW = 7, VIRTUAL = 8, PLAYLIST = 9, FOLDER = 10};
enum GRAPHICSRECTITEM { AVWIDGET = 70000 , LABELWIDGET , TRANSITIONWIDGET };
enum TRANSITIONTYPE {
m_audioThumbCreated = false;
}
+void DocClipBase::setGroup(const QString name, const QString id) {
+ m_xml.setAttribute("groupname", name);
+ m_xml.setAttribute("groupid", id);
+}
+
KThumb *DocClipBase::thumbProducer() {
return m_thumbProd;
}
void slotRequestAudioThumbs();
/** Free cache data */
void slotClearAudioCache();
+ /** puts the clip in a group (used for folder grouping) */
+ void setGroup(const QString name, const QString id);
private: // Private attributes
--- /dev/null
+/***************************************************************************
+ * Copyright (C) 2007 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 <KLocale>
+
+#include "editfoldercommand.h"
+#include "kdenlivedoc.h"
+
+EditFolderCommand::EditFolderCommand(KdenliveDoc *doc, const QString newfolderName, const QString oldfolderName, int clipId, bool doIt)
+ : m_doc(doc), m_name(newfolderName), m_oldname(oldfolderName), m_id(clipId), m_doIt(doIt) {
+ setText(i18n("Rename folder"));
+}
+
+// virtual
+void EditFolderCommand::undo() {
+ m_doc->addFolder(m_oldname, m_id, true);
+}
+// virtual
+void EditFolderCommand::redo() {
+ if (m_doIt) m_doc->addFolder(m_name, m_id, true);
+ m_doIt = true;
+}
+
+#include "editfoldercommand.moc"
--- /dev/null
+/***************************************************************************
+ * Copyright (C) 2007 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 EDITFOLDERCOMMAND_H
+#define EDITFOLDERCOMMAND_H
+
+#include <QUndoCommand>
+
+class KdenliveDoc;
+
+class EditFolderCommand : public QUndoCommand {
+public:
+ EditFolderCommand(KdenliveDoc *doc, const QString newfolderName, const QString oldfolderName, int clipId, bool doIt);
+
+ virtual void undo();
+ virtual void redo();
+
+private:
+ KdenliveDoc *m_doc;
+ QString m_name;
+ QString m_oldname;
+ int m_id;
+ bool m_doIt;
+};
+
+#endif
+
#include "kdenlivesettings.h"
#include "renderer.h"
#include "clipmanager.h"
+#include "addfoldercommand.h"
+#include "editfoldercommand.h"
KdenliveDoc::KdenliveDoc(const KUrl &url, MltVideoProfile profile, QUndoGroup *undoGroup, QWidget *parent): QObject(parent), m_render(NULL), m_url(url), m_profile(profile), m_fps((double)profile.frame_rate_num / profile.frame_rate_den), m_width(profile.width), m_height(profile.height), m_commandStack(new KUndoStack(undoGroup)), m_modified(false) {
m_clipManager = new ClipManager(this);
}
void KdenliveDoc::addClip(const QDomElement &elem, const int clipId) {
- kDebug() << "///////// DOCUM, CREATING NEW CLIP, ID:" << clipId;
DocClipBase *clip = new DocClipBase(m_clipManager, elem, clipId);
+ kDebug() << "///////// DOCUM, CREATING NEW CLIP, ID:" << clipId << ", PAR ID:" << elem.attribute("groupid");
m_clipManager->addClip(clip);
emit addProjectClip(clip);
}
-void KdenliveDoc::deleteProjectClip(const uint clipId) {
- emit deletTimelineClip(clipId);
- m_clipManager->slotDeleteClip(clipId);
+void KdenliveDoc::addFolder(const QString foldername, int clipId, bool edit) {
+ emit addProjectFolder(foldername, clipId, false, edit);
+}
+
+void KdenliveDoc::deleteFolder(const QString foldername, int clipId) {
+ emit addProjectFolder(foldername, clipId, true);
+}
+
+void KdenliveDoc::deleteProjectClip(QList <int> ids) {
+ for (int i = 0; i < ids.size(); ++i) {
+ emit deletTimelineClip(ids.at(i));
+ m_clipManager->slotDeleteClip(ids.at(i));
+ }
+ setModified(true);
+}
+
+void KdenliveDoc::deleteProjectFolder(QMap <QString, int> map) {
+ QMapIterator<QString, int> i(map);
+ while (i.hasNext()) {
+ i.next();
+ slotDeleteFolder(i.key(), i.value());
+ }
setModified(true);
}
m_clipManager->deleteClip(clipId);
}
-void KdenliveDoc::slotAddClipFile(const KUrl url, const QString group) {
+void KdenliveDoc::slotAddClipFile(const KUrl url, const QString group, const int groupId) {
kDebug() << "///////// DOCUM, ADD CLP: " << url;
- m_clipManager->slotAddClipFile(url, group);
+ m_clipManager->slotAddClipFile(url, group, groupId);
+ setModified(true);
+}
+
+void KdenliveDoc::slotAddFolder(const QString folderName) {
+ AddFolderCommand *command = new AddFolderCommand(this, folderName, m_clipManager->getFreeClipId(), true);
+ commandStack()->push(command);
+ setModified(true);
+}
+
+void KdenliveDoc::slotDeleteFolder(const QString folderName, const int id) {
+ AddFolderCommand *command = new AddFolderCommand(this, folderName, id, false);
+ commandStack()->push(command);
setModified(true);
}
+void KdenliveDoc::slotEditFolder(const QString newfolderName, const QString oldfolderName, int clipId) {
+ EditFolderCommand *command = new EditFolderCommand(this, newfolderName, oldfolderName, clipId, false);
+ commandStack()->push(command);
+ setModified(true);
+}
+
+int KdenliveDoc::getFreeClipId() {
+ return m_clipManager->getFreeClipId();
+}
+
DocClipBase *KdenliveDoc::getBaseClip(int clipId) {
return m_clipManager->getClipById(clipId);
}
-void KdenliveDoc::slotAddColorClipFile(const QString name, const QString color, QString duration, const QString group) {
- m_clipManager->slotAddColorClipFile(name, color, duration, group);
+void KdenliveDoc::slotAddColorClipFile(const QString name, const QString color, QString duration, const QString group, const int groupId) {
+ m_clipManager->slotAddColorClipFile(name, color, duration, group, groupId);
setModified(true);
}
Render *renderer();
ClipManager *clipManager();
void addClip(const QDomElement &elem, const int clipId);
- void slotAddClipFile(const KUrl url, const QString group);
- void slotAddColorClipFile(const QString name, const QString color, QString duration, const QString group);
+ void addFolder(const QString foldername, int clipId, bool edit);
+ void deleteFolder(const QString foldername, int clipId);
+ void slotAddClipFile(const KUrl url, const QString group, const int groupId = -1);
+ void slotAddFolder(const QString folderName);
+ void slotDeleteFolder(const QString folderName, const int id);
+ void slotEditFolder(const QString folderName, const QString oldfolderName, int clipId);
+ void slotAddColorClipFile(const QString name, const QString color, QString duration, const QString group, const int groupId = -1);
void deleteClip(const uint clipId);
int getFramePos(QString duration);
DocClipBase *getBaseClip(int clipId);
void updateClip(int id);
- void deleteProjectClip(const uint clipId);
+ void deleteProjectClip(QList <int> ids);
+ void deleteProjectFolder(QMap <QString, int> map);
/** Inform application of the audio thumbnails generation progress */
void setThumbsProgress(KUrl url, int progress);
QString profilePath() const;
void setProfilePath(QString path);
/** Set to true if document needs saving, false otherwise */
void setModified(bool mod);
+ int getFreeClipId();
private:
KUrl m_url;
signals:
void addProjectClip(DocClipBase *);
+ void addProjectFolder(const QString, int, bool, bool edit = false);
void signalDeleteProjectClip(int);
void updateClipDisplay(int);
void deletTimelineClip(int);
disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *)), m_projectList, SLOT(slotAddClip(DocClipBase *)));
+ disconnect(m_activeDocument, SIGNAL(addProjectFolder(const QString, int, bool, bool)), m_projectList, SLOT(slotAddFolder(const QString, int, bool, bool)));
disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(int)), m_projectList, SLOT(slotDeleteClip(int)));
disconnect(m_activeDocument, SIGNAL(updateClipDisplay(int)), m_projectList, SLOT(slotUpdateClip(int)));
disconnect(m_activeDocument, SIGNAL(deletTimelineClip(int)), m_activeTimeline, SLOT(slotDeleteClip(int)));
connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
connect(doc, SIGNAL(addProjectClip(DocClipBase *)), m_projectList, SLOT(slotAddClip(DocClipBase *)));
+ connect(doc, SIGNAL(addProjectFolder(const QString, int, bool, bool)), m_projectList, SLOT(slotAddFolder(const QString, int, bool, bool)));
connect(doc, SIGNAL(signalDeleteProjectClip(int)), m_projectList, SLOT(slotDeleteClip(int)));
connect(doc, SIGNAL(updateClipDisplay(int)), m_projectList, SLOT(slotUpdateClip(int)));
connect(doc, SIGNAL(deletTimelineClip(int)), trackView, SLOT(slotDeleteClip(int)));
ProjectItem::ProjectItem(QTreeWidget * parent, const QStringList & strings, QDomElement xml, int clipId)
- : QTreeWidgetItem(parent, strings, QTreeWidgetItem::UserType), m_clipType(UNKNOWN), m_clipId(clipId), m_isGroup(false), m_groupName(QString::null) {
+ : QTreeWidgetItem(parent, strings, QTreeWidgetItem::UserType), m_clipType(UNKNOWN), m_clipId(clipId) {
m_element = xml.cloneNode().toElement();
setSizeHint(0, QSize(65, 45));
setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsEditable);
}
ProjectItem::ProjectItem(QTreeWidgetItem * parent, const QStringList & strings, QDomElement xml, int clipId)
- : QTreeWidgetItem(parent, strings, QTreeWidgetItem::UserType), m_clipType(UNKNOWN), m_clipId(clipId), m_isGroup(false), m_groupName(QString::null) {
+ : QTreeWidgetItem(parent, strings, QTreeWidgetItem::UserType), m_clipType(UNKNOWN), m_clipId(clipId) {
m_element = xml.cloneNode().toElement();
setSizeHint(0, QSize(65, 45));
setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsEditable);
}
}
+// folder
ProjectItem::ProjectItem(QTreeWidget * parent, const QStringList & strings, int clipId)
- : QTreeWidgetItem(parent, strings, QTreeWidgetItem::UserType), m_element(QDomElement()), m_clipType(UNKNOWN), m_clipId(clipId), m_isGroup(true), m_groupName(strings.at(1)) {
+ : QTreeWidgetItem(parent, strings, QTreeWidgetItem::UserType), m_element(QDomElement()), m_clipType(FOLDER), m_groupName(strings.at(1)), m_clipId(clipId), m_clip(NULL) {
setSizeHint(0, QSize(65, 45));
setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsEditable);
setIcon(0, KIcon("folder"));
}
ProjectItem::ProjectItem(QTreeWidget * parent, DocClipBase *clip)
- : QTreeWidgetItem(parent, QStringList(), QTreeWidgetItem::UserType), m_isGroup(false) {
+ : QTreeWidgetItem(parent, QStringList(), QTreeWidgetItem::UserType) {
+ setSizeHint(0, QSize(65, 45));
+ setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsEditable);
+ m_clip = clip;
+ m_element = clip->toXML();
+ m_clipId = clip->getId();
+ QString name = m_element.attribute("name");
+ if (name.isEmpty()) name = KUrl(m_element.attribute("resource")).fileName();
+ m_clipType = (CLIPTYPE) m_element.attribute("type").toInt();
+ setText(1, name);
+ kDebug() << "PROJECT ITE;. ADDING LCIP: " << m_clipId;
+}
+
+ProjectItem::ProjectItem(QTreeWidgetItem * parent, DocClipBase *clip)
+ : QTreeWidgetItem(parent, QStringList(), QTreeWidgetItem::UserType) {
setSizeHint(0, QSize(65, 45));
setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsEditable);
m_clip = clip;
QString name = m_element.attribute("name");
if (name.isEmpty()) name = KUrl(m_element.attribute("resource")).fileName();
m_clipType = (CLIPTYPE) m_element.attribute("type").toInt();
- m_groupName = m_element.attribute("group");
setText(1, name);
kDebug() << "PROJECT ITE;. ADDING LCIP: " << m_clipId;
}
}
bool ProjectItem::isGroup() const {
- return m_isGroup;
+ return m_clipType == FOLDER;
}
const QString ProjectItem::groupName() const {
return m_groupName;
}
+void ProjectItem::setGroupName(const QString name) {
+ m_groupName = name;
+}
+
+void ProjectItem::setGroup(const QString name, const QString id) {
+ if (m_clip) m_clip->setGroup(name, id);
+}
+
QStringList ProjectItem::names() const {
QStringList result;
result.append(text(0));
public:
ProjectItem(QTreeWidget * parent, const QStringList & strings, QDomElement xml, int clipId);
ProjectItem(QTreeWidgetItem * parent, const QStringList & strings, QDomElement xml, int clipId);
+ /** Create folder item */
ProjectItem(QTreeWidget * parent, const QStringList & strings, int clipId);
ProjectItem(QTreeWidget * parent, DocClipBase *clip);
+ ProjectItem(QTreeWidgetItem * parent, DocClipBase *clip);
virtual ~ProjectItem();
QDomElement toXml() const;
int numReferences() const;
QStringList names() const;
bool isGroup() const;
const QString groupName() const;
+ void setGroupName(const QString name);
const KUrl clipUrl() const;
int clipMaxDuration() const;
CLIPTYPE clipType() const;
+ void setGroup(const QString name, const QString id);
private:
QDomElement m_element;
GenTime m_duration;
+ QString m_groupName;
bool m_durationKnown;
CLIPTYPE m_clipType;
int m_clipId;
void slotSetToolTip();
- bool m_isGroup;
- QString m_groupName;
DocClipBase *m_clip;
};
}
void ProjectList::slotClipSelected() {
- ProjectItem *item = (ProjectItem*) listView->currentItem();
+ ProjectItem *item = static_cast <ProjectItem*>(listView->currentItem());
if (item && !item->isGroup()) emit clipSelected(item->toXml());
}
void ProjectList::slotUpdateItemDescription(QTreeWidgetItem *item, int column) {
- if (column != 2) return;
- ProjectItem *clip = (ProjectItem*) item;
+ ProjectItem *clip = static_cast <ProjectItem*>(item);
CLIPTYPE type = clip->clipType();
- if (type == AUDIO || type == VIDEO || type == AV || type == IMAGE || type == PLAYLIST) {
- // Use Nepomuk system to store clip description
- Nepomuk::Resource f(clip->clipUrl().path());
- f.setDescription(item->text(2));
- kDebug() << "NEPOMUK, SETTING CLIP: " << clip->clipUrl().path() << ", TO TEXT: " << item->text(2);
+ if (column == 2) {
+ if (type == AUDIO || type == VIDEO || type == AV || type == IMAGE || type == PLAYLIST) {
+ // Use Nepomuk system to store clip description
+ Nepomuk::Resource f(clip->clipUrl().path());
+ f.setDescription(item->text(2));
+ kDebug() << "NEPOMUK, SETTING CLIP: " << clip->clipUrl().path() << ", TO TEXT: " << item->text(2);
+ }
+ } else if (column == 1 && type == FOLDER) {
+ m_doc->slotEditFolder(item->text(1), clip->groupName(), clip->clipId());
}
}
}
void ProjectList::slotRemoveClip() {
-
- if (!m_commandStack) kDebug() << "!!!!!!!!!!!!!!!! NO CMD STK";
if (!listView->currentItem()) return;
- ProjectItem *item = ((ProjectItem *)listView->currentItem());
+ ProjectItem *item = static_cast <ProjectItem *>(listView->currentItem());
+ QList <int> ids;
+ QMap <QString, int> folderids;
+ if (item->clipType() == FOLDER) folderids[item->groupName()] = item->clipId();
+ else ids << item->clipId();
if (item->numReferences() > 0) {
if (KMessageBox::questionYesNo(this, i18np("Delete clip <b>%2</b> ?<br>This will also remove the clip in timeline", "Delete clip <b>%2</b> ?<br>This will also remove its %1 clips in timeline", item->numReferences(), item->names().at(1)), i18n("Delete Clip")) != KMessageBox::Yes) return;
+ } else if (item->clipType() == FOLDER && item->childCount() > 0) {
+ int children = item->childCount();
+ if (KMessageBox::questionYesNo(this, i18n("Delete folder <b>%2</b> ?<br>This will also remove the %1 clips in that folder", children, item->names().at(1)), i18n("Delete Folder")) != KMessageBox::Yes) return;
+ for (int i = 0; i < children; ++i) {
+ ProjectItem *child = static_cast <ProjectItem *>(item->child(i));
+ ids << child->clipId();
+ }
}
- m_doc->deleteProjectClip(item->clipId());
+ if (!ids.isEmpty()) m_doc->deleteProjectClip(ids);
+ if (!folderids.isEmpty()) m_doc->deleteProjectFolder(folderids);
}
void ProjectList::selectItemById(const int clipId) {
ProjectItem *item;
ProjectItem *groupItem = NULL;
QString groupName;
- if (group.isEmpty()) groupName = elem.attribute("group", QString::null);
+ if (group.isEmpty()) groupName = elem.attribute("groupname", QString::null);
else groupName = group;
if (elem.isNull() && url.isEmpty()) {
// this is a folder
groupName = name.at(1);
QList<QTreeWidgetItem *> groupList = listView->findItems(groupName, Qt::MatchExactly, 1);
if (groupList.isEmpty()) {
- (void) new ProjectItem(listView, name, clipId);
+ (void) new ProjectItem(listView, name, m_doc->getFreeClipId());
}
return;
}
QStringList itemName;
itemName << QString::null << groupName;
kDebug() << "------- CREATING NEW GRP: " << itemName;
- groupItem = new ProjectItem(listView, itemName, m_clipIdCounter++);
+ groupItem = new ProjectItem(listView, itemName, m_doc->getFreeClipId());
} else groupItem = (ProjectItem *) groupList.first();
}
if (groupItem) item = new ProjectItem(groupItem, name, elem, clipId);
}
void ProjectList::slotDeleteClip(int clipId) {
+ kDebug() << "/////// DELETE CLIP: " << clipId;
ProjectItem *item = getItemById(clipId);
if (item) delete item;
}
void ProjectList::slotAddFolder() {
- /*
- QString folderName = KInputDialog::getText(i18n("New Folder"), i18n("Enter new folder name: "));
- if (folderName.isEmpty()) return;
- QStringList itemEntry;
- itemEntry.append(QString::null);
- itemEntry.append(folderName);
- AddClipCommand *command = new AddClipCommand(this, itemEntry, QDomElement(), m_clipIdCounter++, KUrl(), folderName, true);
- m_commandStack->push(command);*/
+
+ // QString folderName = KInputDialog::getText(i18n("New Folder"), i18n("Enter new folder name: "));
+ // if (folderName.isEmpty()) return;
+ m_doc->slotAddFolder(i18n("Folder")); //folderName);
+}
+
+void ProjectList::slotAddFolder(const QString foldername, int clipId, bool remove, bool edit) {
+ if (remove) {
+ ProjectItem *item;
+ QTreeWidgetItemIterator it(listView);
+ while (*it) {
+ item = static_cast <ProjectItem *>(*it);
+ if (item->clipType() == FOLDER && item->clipId() == clipId) {
+ delete item;
+ break;
+ }
+ ++it;
+ }
+ } else {
+ if (edit) {
+ disconnect(listView, SIGNAL(itemChanged(QTreeWidgetItem *, int)), this, SLOT(slotUpdateItemDescription(QTreeWidgetItem *, int)));
+ ProjectItem *item;
+ QTreeWidgetItemIterator it(listView);
+ while (*it) {
+ item = static_cast <ProjectItem *>(*it);
+ if (item->clipType() == FOLDER && item->clipId() == clipId) {
+ item->setText(1, foldername);
+ break;
+ }
+ ++it;
+ }
+ connect(listView, SIGNAL(itemChanged(QTreeWidgetItem *, int)), this, SLOT(slotUpdateItemDescription(QTreeWidgetItem *, int)));
+ } else {
+ QStringList text;
+ text << QString() << foldername;
+ (void) new ProjectItem(listView, text, clipId);
+ }
+ }
}
void ProjectList::slotAddClip(DocClipBase *clip) {
- ProjectItem *item = new ProjectItem(listView, clip);
+ const int parent = clip->toXML().attribute("groupid").toInt();
+ if (parent != 0) {
+ ProjectItem *parentitem = getItemById(parent);
+ if (parentitem)(void) new ProjectItem(parentitem, clip);
+ else (void) new ProjectItem(listView, clip);
+ } else (void) new ProjectItem(listView, clip);
emit getFileProperties(clip->toXML(), clip->getId());
}
item->setData(1, UsageRole, QString::number(item->numReferences()));
}
-void ProjectList::slotAddClip(QUrl givenUrl, const QString &group) {
+void ProjectList::slotAddClip(QUrl givenUrl, QString group) {
if (!m_commandStack) kDebug() << "!!!!!!!!!!!!!!!! NO CMD STK";
KUrl::List list;
if (givenUrl.isEmpty())
else list.append(givenUrl);
if (list.isEmpty()) return;
KUrl::List::Iterator it;
-
+ int groupId = -1;
+ if (group.isEmpty()) {
+ ProjectItem *item = static_cast <ProjectItem*>(listView->currentItem());
+ if (item && item->clipType() != FOLDER) {
+ while (item->parent()) {
+ item = static_cast <ProjectItem*>(item->parent());
+ if (item->clipType() == FOLDER) break;
+ }
+ }
+ if (item && item->clipType() == FOLDER) {
+ group = item->groupName();
+ groupId = item->clipId();
+ }
+ }
for (it = list.begin(); it != list.end(); it++) {
- m_doc->slotAddClipFile(*it, group);
+ m_doc->slotAddClipFile(*it, group, groupId);
}
}
if (dia->exec() == QDialog::Accepted) {
QString color = dia_ui->clip_color->color().name();
color = color.replace(0, 1, "0x") + "ff";
- m_doc->slotAddColorClipFile(dia_ui->clip_name->text(), color, dia_ui->clip_duration->text(), QString::null);
+
+ QString group = QString();
+ int groupId = -1;
+ ProjectItem *item = static_cast <ProjectItem*>(listView->currentItem());
+ if (item && item->clipType() != FOLDER) {
+ while (item->parent()) {
+ item = static_cast <ProjectItem*>(item->parent());
+ if (item->clipType() == FOLDER) break;
+ }
+ }
+ if (item && item->clipType() == FOLDER) {
+ group = item->groupName();
+ groupId = item->clipId();
+ }
+
+ m_doc->slotAddColorClipFile(dia_ui->clip_name->text(), color, dia_ui->clip_duration->text(), group, groupId);
}
delete dia_ui;
delete dia;
break;
++it;
}
- return ((ProjectItem *)(*it));
+ if (*it) return ((ProjectItem *)(*it));
+ return NULL;
}
//kDebug()<<"////// ADDING PRODUCER:\n "<<doc.toString()<<"\n+++++++++++++++++";
int id = producer.attribute("id").toInt();
- QString groupName = producer.attribute("group");
+ QString groupName = producer.attribute("groupname");
if (id >= m_clipIdCounter) m_clipIdCounter = id + 1;
else if (id == 0) id = m_clipIdCounter++;
void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const {
if (index.column() == 1) {
- const bool hover = option.state & (QStyle::State_Selected | QStyle::State_MouseOver | QStyle::State_HasFocus);
+ const bool hover = option.state & (QStyle::State_Selected);
QRect r1 = option.rect;
painter->save();
if (hover) {
KdenliveDoc *m_doc;
private slots:
- void slotAddClip(QUrl givenUrl = QUrl(), const QString &group = QString());
+ void slotAddClip(QUrl givenUrl = QUrl(), QString group = QString());
void slotRemoveClip();
void slotEditClip();
void slotClipSelected();
void slotEditClip(QTreeWidgetItem *, int);
void slotContextMenu(const QPoint &pos, QTreeWidgetItem *);
void slotAddFolder();
+ void slotAddFolder(const QString foldername, int clipId, bool remove, bool edit);
/** This is triggered when a clip description has been modified */
void slotUpdateItemDescription(QTreeWidgetItem *item, int column);
//void slotShowMenu(const QPoint &pos);
// virtual
void ProjectListView::mouseDoubleClickEvent(QMouseEvent * event) {
- if (!itemAt(event->pos())) emit addClip();
- else if (columnAt(event->pos().x()) == 2) QTreeWidget::mouseDoubleClickEvent(event);
+ ProjectItem *item = static_cast <ProjectItem *>(itemAt(event->pos()));
+ if (!item) emit addClip();
+ else if ((item->clipType() == FOLDER && columnAt(event->pos().x()) == 1) || columnAt(event->pos().x()) == 2) QTreeWidget::mouseDoubleClickEvent(event);
}
// virtual
emit addClip(url, groupName);
}
- } else if (event->mimeData()->hasText()) {
- QTreeWidgetItem *item = itemAt(event->pos());
+ } else if (event->mimeData()->hasFormat("kdenlive/producerslist")) {
+ ProjectItem *item = static_cast <ProjectItem *>(itemAt(event->pos()));
if (item) {
- if (item->parent()) item = item->parent();
- if (((ProjectItem *) item)->isGroup()) {
+ if (item->parent()) item = static_cast <ProjectItem *>(item->parent());
+ if (item->isGroup()) {
//emit addClip(event->mimeData->text());
kDebug() << "//////////////// DROPPED RIGHT 1 ";
QList <QTreeWidgetItem *> list;
list = selectedItems();
ProjectItem *clone;
+ int parentId = item->clipId();
foreach(QTreeWidgetItem *it, list) {
// TODO allow dragging of folders ?
if (!((ProjectItem *) it)->isGroup() && ((ProjectItem *) it)->clipId() < 10000) {
if (it->parent()) clone = (ProjectItem*) it->parent()->takeChild(it->parent()->indexOfChild(it));
else clone = (ProjectItem*) takeTopLevelItem(indexOfTopLevelItem(it));
- if (clone) item->addChild(clone);
+ if (clone) {
+ item->addChild(clone);
+ clone->setGroup(item->groupName(), QString::number(parentId));
+ }
}
}
} else item = NULL;
QStringList ids;
foreach(QTreeWidgetItem *item, list) {
// TODO allow dragging of folders
- if (!((ProjectItem *) item)->isGroup())
- ids.append(QString::number(((ProjectItem *) item)->clipId()));
+ ids.append(QString::number(((ProjectItem *) item)->clipId()));
}
QByteArray data;
data.append(ids.join(";").toUtf8()); //doc.toString().toUtf8());
QStringList ProjectListView::mimeTypes() const {
QStringList qstrList;
+ qstrList << QTreeWidget::mimeTypes();
// list of accepted mime types for drop
qstrList.append("text/uri-list");
qstrList.append("text/plain");
+ qstrList.append("kdenlive/producerslist");
return qstrList;
}