//m_toolbar->setEnabled(false);
searchView->setTreeWidget(listView);
- listView->setColumnCount(3);
- QStringList headers;
- headers << i18n("Thumbnail") << i18n("Filename") << i18n("Description");
- listView->setHeaderLabels(headers);
- listView->sortByColumn(1, Qt::AscendingOrder);
m_menu = new QMenu();
m_menu->addAction(addClipButton);
connect(listView, SIGNAL(addClip()), this, SLOT(slotAddClip()));
connect(listView, SIGNAL(addClip(QUrl, const QString &)), this, SLOT(slotAddClip(QUrl, const QString &)));
connect(listView, SIGNAL(itemChanged(QTreeWidgetItem *, int)), this, SLOT(slotUpdateItemDescription(QTreeWidgetItem *, int)));
+ connect(listView, SIGNAL(showProperties(DocClipBase *)), this, SIGNAL(showClipProperties(DocClipBase *)));
m_listViewDelegate = new ItemDelegate(listView);
listView->setItemDelegate(m_listViewDelegate);
- listView->setIconSize(QSize(60, 40));
- listView->setSortingEnabled(true);
}
ProjectList::~ProjectList() {
delete m_toolbar;
}
+
+
void ProjectList::setRenderer(Render *projectRender) {
m_render = projectRender;
}
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());
+ if (f.isValid()) f.setDescription(item->text(2));
+ clip->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::slotEditClip() {
- kDebug() << "//////////////////////////////////////// DBL CLK";
-}
-
-
-void ProjectList::slotEditClip(QTreeWidgetItem *item, int column) {
- kDebug() << "//////////////////////////////////////// DBL CLK";
-}
-
void ProjectList::slotContextMenu(const QPoint &pos, QTreeWidgetItem *item) {
bool enable = false;
if (item) {
- QFrame *w = new QFrame;
- w->setFrameShape(QFrame::StyledPanel);
- w->setLineWidth(2);
- w->setAutoFillBackground(true);
- QHBoxLayout *layout = new QHBoxLayout;
- layout->addWidget(new QLabel(i18n("Color:")));
- layout->addWidget(new KColorButton());
- layout->addWidget(new QLabel(i18n("Duration:")));
- layout->addWidget(new KRestrictedLine());
- w->setLayout(layout);
- m_listViewDelegate->extendItem(w, listView->currentIndex());
enable = true;
}
m_editAction->setEnabled(enable);
}
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);
if (!url.isEmpty()) {
// if file has Nepomuk comment, use it
Nepomuk::Resource f(url.path());
- QString annotation = f.description();
+ QString annotation;
+ if (f.isValid()) annotation = f.description();
+
if (!annotation.isEmpty()) item->setText(2, annotation);
QString resource = url.path();
if (resource.endsWith("westley") || resource.endsWith("kdenlive")) {
void ProjectList::slotDeleteClip(int clipId) {
ProjectItem *item = getItemById(clipId);
- if (item) delete item;
+ QTreeWidgetItem *p = item->parent();
+ if (p) {
+ kDebug() << "/////// DELETEED CLIP HAS A PARENT... " << p->indexOfChild(item);
+ QTreeWidgetItem *clone = p->takeChild(p->indexOfChild(item));
+ } else 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();
+ ProjectItem *item = NULL;
+ if (parent != 0) {
+ ProjectItem *parentitem = getItemById(parent);
+ if (parentitem) item = new ProjectItem(parentitem, clip);
+ }
+ if (item == NULL) item = new ProjectItem(listView, clip);
+
+ KUrl url = clip->fileURL();
+ if (!url.isEmpty()) {
+ // if file has Nepomuk comment, use it
+ Nepomuk::Resource f(url.path());
+ QString annotation;
+ if (f.isValid()) {
+ annotation = f.description();
+ /*
+ Nepomuk::Tag tag("test");
+ f.addTag(tag);*/
+ } else kDebug() << "--- CANNOT CONTACT NEPOMUK";
+ if (!annotation.isEmpty()) item->setText(2, annotation);
+ }
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++;