#include "projectlistview.h"
ProjectList::ProjectList(QWidget *parent)
- : QWidget(parent), m_render(NULL), m_fps(-1), m_commandStack(NULL), m_selectedItem(NULL), m_infoQueue(QMap <QString, QDomElement> ()), m_thumbnailQueue(QList <QString> ()) {
+ : QWidget(parent), m_render(NULL), m_fps(-1), m_commandStack(NULL), m_selectedItem(NULL), m_infoQueue(QMap <QString, QDomElement> ()), m_thumbnailQueue(QList <QString> ()), m_refreshed(false) {
QWidget *vbox = new QWidget;
listView = new ProjectListView(this);;
QVBoxLayout *layout = new QVBoxLayout;
+ layout->setContentsMargins(0, 0, 0, 0);
m_clipIdCounter = 0;
// setup toolbar
searchView = new KTreeWidgetSearchLine(this);
connect(listView, SIGNAL(itemSelectionChanged()), this, SLOT(slotClipSelected()));
connect(listView, SIGNAL(focusMonitor()), this, SLOT(slotClipSelected()));
+ connect(listView, SIGNAL(pauseMonitor()), this, SLOT(slotPauseMonitor()));
connect(listView, SIGNAL(requestMenu(const QPoint &, QTreeWidgetItem *)), this, SLOT(slotContextMenu(const QPoint &, QTreeWidgetItem *)));
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(slotItemEdited(QTreeWidgetItem *, int)));
connect(listView, SIGNAL(showProperties(DocClipBase *)), this, SIGNAL(showClipProperties(DocClipBase *)));
- m_listViewDelegate = new ItemDelegate(listView);
- listView->setItemDelegate(m_listViewDelegate);
+ ItemDelegate *listViewDelegate = new ItemDelegate(listView);
+ listView->setItemDelegate(listViewDelegate);
}
ProjectList::~ProjectList() {
delete m_toolbar;
}
+QByteArray ProjectList::headerInfo() {
+ return listView->header()->saveState();
+}
+
+void ProjectList::setHeaderInfo(const QByteArray &state) {
+ listView->header()->restoreState(state);
+}
+
void ProjectList::slotEditClip() {
ProjectItem *item = static_cast <ProjectItem*>(listView->currentItem());
if (item && !item->isGroup()) {
}
}
+void ProjectList::slotPauseMonitor() {
+ if (m_render) m_render->pause();
+}
+
void ProjectList::slotUpdateClipProperties(const QString &id, QMap <QString, QString> properties) {
ProjectItem *item = getItemById(id);
if (item) {
ProjectItem *item = getItemById(clipId);
QTreeWidgetItem *p = item->parent();
if (p) {
- kDebug() << "/////// DELETEED CLIP HAS A PARENT... " << p->indexOfChild(item);
+ kDebug() << "/////// DELETED CLIP HAS A PARENT... " << p->indexOfChild(item);
QTreeWidgetItem *clone = p->takeChild(p->indexOfChild(item));
} else if (item) {
delete item;
}
void ProjectList::slotAddClip(DocClipBase *clip, bool getProperties) {
+ if (getProperties) listView->setEnabled(false);
const QString parent = clip->getProperty("groupid");
+ //kDebug() << "Adding clip with groupid: " << parent;
ProjectItem *item = NULL;
if (!parent.isEmpty()) {
ProjectItem *parentitem = getItemById(parent);
if (!parentitem) {
QStringList text;
QString groupName = clip->getProperty("groupname");
+ //kDebug() << "Adding clip to new group: " << groupName;
if (groupName.isEmpty()) groupName = i18n("Folder");
text << QString() << groupName;
listView->blockSignals(true);
parentitem = new ProjectItem(listView, text, parent);
listView->blockSignals(false);
+ } else {
+ //kDebug() << "Adding clip to existing group: " << parentitem->groupName();
}
if (parentitem) item = new ProjectItem(parentitem, clip);
}
}
if (!annotation.isEmpty()) item->setText(2, annotation);
}
- if (getProperties) requestClipInfo(clip->toXML(), clip->getId());
}
void ProjectList::requestClipInfo(const QDomElement xml, const QString id) {
+ kDebug() << " PRG LIST REQUEST CLP INFO: " << id;
m_infoQueue.insert(id, xml);
listView->setEnabled(false);
if (m_infoQueue.count() == 1) QTimer::singleShot(300, this, SLOT(slotProcessNextClipInQueue()));
}
requestClipInfo(clip->toXML(), clip->getId());
} else {
- requestClipThumbnail(item->clipId());
- //slotRefreshClipThumbnail(item, false);
+ QString cachedPixmap = m_doc->projectFolder().path() + "/thumbs/" + item->getClipHash() + ".png";
+ if (QFile::exists(cachedPixmap)) {
+ //kDebug()<<"// USING CACHED PIX: "<<cachedPixmap;
+ item->setIcon(0, QPixmap(cachedPixmap));
+ } else requestClipThumbnail(item->clipId());
item->changeDuration(item->referencedClip()->producer()->get_playtime());
}
item->setData(1, UsageRole, QString::number(item->numReferences()));
}
++it;
}
+ QTimer::singleShot(500, this, SLOT(slotCheckForEmptyQueue()));
}
void ProjectList::slotAddClip(QUrl givenUrl, QString group) {
- if (!m_commandStack) kDebug() << "!!!!!!!!!!!!!!!! NO CMD STK";
+ if (!m_commandStack) kDebug() << "!!!!!!!!!!!!!!!! NO CMD STK";
KUrl::List list;
if (givenUrl.isEmpty()) {
- list = KFileDialog::getOpenUrls(KUrl("kfiledialog:///clipfolder"), "application/x-kdenlive application/x-flash-video application/vnd.rn-realmedia video/x-dv video/dv video/x-msvideo video/mpeg video/x-ms-wmv audio/mpeg audio/x-mp3 audio/x-wav application/ogg video/mp4 video/quicktime image/gif image/jpeg image/png image/x-bmp image/svg+xml image/tiff image/x-xcf-gimp image/x-vnd.adobe.photoshop image/x-pcx image/x-exr video/mlt-playlist audio/x-flac audio/mp4", this);
+ list = KFileDialog::getOpenUrls(KUrl("kfiledialog:///clipfolder"), "application/x-kdenlive video/x-flv application/vnd.rn-realmedia video/x-dv video/dv video/x-msvideo video/mpeg video/x-ms-wmv audio/mpeg audio/x-mp3 audio/x-wav application/ogg video/mp4 video/quicktime image/gif image/jpeg image/png image/x-bmp image/svg+xml image/tiff image/x-xcf-gimp image/x-vnd.adobe.photoshop image/x-pcx image/x-exr video/mlt-playlist audio/x-flac audio/mp4", this);
} else list.append(givenUrl);
if (list.isEmpty()) return;
void ProjectList::slotRemoveInvalidClip(const QString &id) {
ProjectItem *item = getItemById(id);
if (item) {
- QString path = item->referencedClip()->fileURL().path();
- if (!path.isEmpty()) KMessageBox::sorry(this, i18n("<qt>Clip <b>%1</b><br>is invalid, will be removed from project.", path));
-
+ const QString path = item->referencedClip()->fileURL().path();
+ if (!path.isEmpty()) KMessageBox::sorry(this, i18n("Clip <b>%1</b><br>is invalid, will be removed from project.", path));
+ QList <QString> ids;
+ ids << id;
+ m_doc->deleteProjectClip(ids);
}
- QList <QString> ids;
- ids << id;
- m_doc->deleteProjectClip(ids);
if (!m_infoQueue.isEmpty()) QTimer::singleShot(300, this, SLOT(slotProcessNextClipInQueue()));
}
void ProjectList::slotAddColorClip() {
- if (!m_commandStack) kDebug() << "!!!!!!!!!!!!!!!! NO CMD STK";
+ if (!m_commandStack) kDebug() << "!!!!!!!!!!!!!!!! NO CMD STK";
QDialog *dia = new QDialog(this);
Ui::ColorClip_UI *dia_ui = new Ui::ColorClip_UI();
dia_ui->setupUi(dia);
void ProjectList::slotAddSlideshowClip() {
- if (!m_commandStack) kDebug() << "!!!!!!!!!!!!!!!! NO CMD STK";
+ if (!m_commandStack) kDebug() << "!!!!!!!!!!!!!!!! NO CMD STK";
SlideshowClip *dia = new SlideshowClip(this);
if (dia->exec() == QDialog::Accepted) {
}
void ProjectList::setDocument(KdenliveDoc *doc) {
+ listView->blockSignals(true);
listView->clear();
+ m_thumbnailQueue.clear();
+ m_infoQueue.clear();
+ m_refreshed = false;
QList <DocClipBase*> list = doc->clipManager()->documentClipList();
for (int i = 0; i < list.count(); i++) {
slotAddClip(list.at(i), false);
m_doc = doc;
QTreeWidgetItem *first = listView->topLevelItem(0);
if (first) listView->setCurrentItem(first);
+ listView->blockSignals(false);
m_toolbar->setEnabled(true);
}
return prods;
}
+void ProjectList::slotCheckForEmptyQueue() {
+ if (!m_refreshed && m_thumbnailQueue.isEmpty() && m_infoQueue.isEmpty()) {
+ m_refreshed = true;
+ emit loadingIsOver();
+ } else QTimer::singleShot(500, this, SLOT(slotCheckForEmptyQueue()));
+}
void ProjectList::requestClipThumbnail(const QString &id) {
m_thumbnailQueue.append(id);
}
void ProjectList::slotProcessNextThumbnail() {
- if (m_thumbnailQueue.isEmpty()) return;
+ if (m_thumbnailQueue.isEmpty()) {
+ return;
+ }
slotRefreshClipThumbnail(m_thumbnailQueue.takeFirst(), false);
}
void ProjectList::slotRefreshClipThumbnail(ProjectItem *item, bool update) {
if (item) {
+ if (!item->referencedClip()) return;
int height = 50;
int width = (int)(height * m_render->dar());
- QPixmap pix = item->referencedClip()->thumbProducer()->extractImage(item->referencedClip()->getClipThumbFrame(), width, height);
+ DocClipBase *clip = item->referencedClip();
+ if (!clip) slotProcessNextThumbnail();
+ QPixmap pix;
+ if (clip->clipType() == AUDIO) pix = KIcon("audio-x-generic").pixmap(QSize(width, height));
+ else pix = item->referencedClip()->thumbProducer()->extractImage(item->referencedClip()->getClipThumbFrame(), width, height);
item->setIcon(0, pix);
+ m_doc->cachePixmap(item->getClipHash(), pix);
if (update) emit projectModified();
if (!m_thumbnailQueue.isEmpty()) QTimer::singleShot(300, this, SLOT(slotProcessNextThumbnail()));
}
emit receivedClipDuration(clipId, item->clipMaxDuration());
} else kDebug() << "//////// COULD NOT FIND CLIP TO UPDATE PRPS...";
if (!m_infoQueue.isEmpty()) QTimer::singleShot(300, this, SLOT(slotProcessNextClipInQueue()));
+ else listView->setEnabled(true);
}
void ProjectList::slotReplyGetImage(const QString &clipId, int pos, const QPixmap &pix, int w, int h) {
ProjectItem *item = getItemById(clipId);
- if (item) item->setIcon(0, pix);
+ if (item) {
+ item->setIcon(0, pix);
+ m_doc->cachePixmap(item->getClipHash(), pix);
+ }
}
ProjectItem *ProjectList::getItemById(const QString &id) {
QTreeWidgetItemIterator it(listView);
+ while (*it) {
+ if (((ProjectItem *)(*it))->clipId() == id)
+ return static_cast<ProjectItem *>(*it);
+ ++it;
+ }
+ return NULL;
+#ifdef USED_TO_BE_THIS
while (*it) {
if (((ProjectItem *)(*it))->clipId() == id)
break;
}
if (*it) return ((ProjectItem *)(*it));
return NULL;
+#endif
}
void ProjectList::slotSelectClip(const QString &ix) {