aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Baptiste Mardelle <[email protected]>2015-01-11 01:10:58 +0100
committerJean-Baptiste Mardelle <[email protected]>2015-01-11 01:10:58 +0100
commit3298d2dba480ace46692f6e7ff688935b964229b (patch)
tree6c8260518f36b0e081e628205cdf546dd9600782
parent0bed18d5600bb51f41bd1c3044862d06307ebfb8 (diff)
Cleanup unused functions
-rw-r--r--src/bin/bin.cpp6
-rw-r--r--src/bin/bin.h1
-rw-r--r--src/dialogs/clipcreationdialog.cpp38
-rw-r--r--src/doc/kdenlivedoc.cpp6
-rw-r--r--src/doc/kdenlivedoc.h1
-rw-r--r--src/mainwindow.cpp8
-rw-r--r--src/project/clipmanager.cpp270
-rw-r--r--src/project/clipmanager.h17
-rw-r--r--src/project/projectlist.cpp215
-rw-r--r--src/project/projectlist.h3
-rw-r--r--src/project/projectmanager.cpp2
11 files changed, 51 insertions, 516 deletions
diff --git a/src/bin/bin.cpp b/src/bin/bin.cpp
index 07d00e6..701aea4 100644
--- a/src/bin/bin.cpp
+++ b/src/bin/bin.cpp
@@ -1046,6 +1046,12 @@ void Bin::doMoveClip(const QString &id, const QString &newParentId)
currentItem->updateParentInfo(newParentId, newParent->name());
}
+void Bin::droppedUrls(QList <QUrl> urls, const QMap<QString,QString> properties)
+{
+ QModelIndex current = m_proxyModel->mapToSource(m_proxyModel->selectionModel()->currentIndex());
+ slotItemDropped(urls, current);
+}
+
void Bin::slotItemDropped(const QList<QUrl>&urls, const QModelIndex &parent)
{
QStringList folderInfo;
diff --git a/src/bin/bin.h b/src/bin/bin.h
index 7447382..48cc0c8 100644
--- a/src/bin/bin.h
+++ b/src/bin/bin.h
@@ -304,6 +304,7 @@ public:
void doMoveClip(const QString &id, const QString &newParentId);
void setupGeneratorMenu(const QHash<QString,QMenu*>& menus);
void startClipJob(const QStringList &params);
+ void droppedUrls(QList <QUrl> urls, const QMap<QString,QString> properties = QMap<QString,QString>());
private slots:
void slotAddClip();
diff --git a/src/dialogs/clipcreationdialog.cpp b/src/dialogs/clipcreationdialog.cpp
index 2ec6cb0..46bd6d4 100644
--- a/src/dialogs/clipcreationdialog.cpp
+++ b/src/dialogs/clipcreationdialog.cpp
@@ -169,6 +169,43 @@ void ClipCreationDialogDialog::createClipsCommand(KdenliveDoc *doc, const QList<
{
QUndoCommand *addClips = new QUndoCommand();
+ //TODO: check files on removable volume
+ /*listRemovableVolumes();
+ foreach(const QUrl &file, urls) {
+ if (QFile::exists(file.path())) {
+ //TODO check for duplicates
+ if (!data.contains("bypassDuplicate") && !getClipByResource(file.path()).empty()) {
+ if (KMessageBox::warningContinueCancel(QApplication::activeWindow(), i18n("Clip <b>%1</b><br />already exists in project, what do you want to do?", file.path()), i18n("Clip already exists")) == KMessageBox::Cancel)
+ continue;
+ }
+ if (isOnRemovableDevice(file) && !isOnRemovableDevice(m_doc->projectFolder())) {
+ int answer = KMessageBox::warningYesNoCancel(QApplication::activeWindow(), i18n("Clip <b>%1</b><br /> is on a removable device, will not be available when device is unplugged", file.path()), i18n("File on a Removable Device"), KGuiItem(i18n("Copy file to project folder")), KGuiItem(i18n("Continue")), KStandardGuiItem::cancel(), QString("copyFilesToProjectFolder"));
+
+ if (answer == KMessageBox::Cancel) continue;
+ else if (answer == KMessageBox::Yes) {
+ // Copy files to project folder
+ QDir sourcesFolder(m_doc->projectFolder().toLocalFile());
+ sourcesFolder.cd("clips");
+ KIO::MkdirJob *mkdirJob = KIO::mkdir(QUrl::fromLocalFile(sourcesFolder.absolutePath()));
+ KJobWidgets::setWindow(mkdirJob, QApplication::activeWindow());
+ if (!mkdirJob->exec()) {
+ KMessageBox::sorry(QApplication::activeWindow(), i18n("Cannot create directory %1", sourcesFolder.absolutePath()));
+ continue;
+ }
+ //KIO::filesize_t m_requestedSize;
+ KIO::CopyJob *copyjob = KIO::copy(file, QUrl::fromLocalFile(sourcesFolder.absolutePath()));
+ //TODO: for some reason, passing metadata does not work...
+ copyjob->addMetaData("group", data.value("group"));
+ copyjob->addMetaData("groupId", data.value("groupId"));
+ copyjob->addMetaData("comment", data.value("comment"));
+ KJobWidgets::setWindow(copyjob, QApplication::activeWindow());
+ connect(copyjob, &KIO::CopyJob::copyingDone, this, &ClipManager::slotAddCopiedClip);
+ continue;
+ }
+ }*/
+
+
+
//TODO check folders
/*QList < QList<QUrl> > foldersList;
QMimeDatabase db;
@@ -183,6 +220,7 @@ void ClipCreationDialogDialog::createClipsCommand(KdenliveDoc *doc, const QList<
QList <QUrl> folderFiles;
folderFiles << file;
foreach(const QString & path, result) {
+ // TODO: create folder command
folderFiles.append(QUrl::fromLocalFile(dir.absoluteFilePath(path)));
}
if (folderFiles.count() > 1) foldersList.append(folderFiles);
diff --git a/src/doc/kdenlivedoc.cpp b/src/doc/kdenlivedoc.cpp
index bdd9629..8c4b6f5 100644
--- a/src/doc/kdenlivedoc.cpp
+++ b/src/doc/kdenlivedoc.cpp
@@ -1292,12 +1292,6 @@ void KdenliveDoc::deleteClip(const QString &clipId)
pCore->binController()->removeBinClip(clipId);
}
-void KdenliveDoc::addClipList(const QList<QUrl> &urls, const QMap<QString, QString> &data)
-{
- m_clipManager->doAddClipList(urls, data);
- emit selectLastAddedClip(QString::number(m_clipManager->lastClipId()));
-}
-
ProjectClip *KdenliveDoc::getBinClip(const QString &clipId)
{
return pCore->bin()->getBinClip(clipId);
diff --git a/src/doc/kdenlivedoc.h b/src/doc/kdenlivedoc.h
index 91ea1e4..6a6f78c 100644
--- a/src/doc/kdenlivedoc.h
+++ b/src/doc/kdenlivedoc.h
@@ -152,7 +152,6 @@ public:
int setSceneList();
void setDocumentProperty(const QString &name, const QString &value);
const QString getDocumentProperty(const QString &name) const;
- void addClipList(const QList<QUrl> &urls, const QMap<QString, QString> &data = QMap<QString, QString>());
/** @brief Gets the list of renderer properties saved into the document. */
QMap <QString, QString> getRenderProperties() const;
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 618bcae..5200029 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -564,7 +564,7 @@ void MainWindow::generateClip()
QUrl clipUrl = iGenerator->generatedClip(KdenliveSettings::rendererpath(), action->data().toString(), project->projectFolder(),
QStringList(), QStringList(), project->fps(), project->width(), project->height());
if (clipUrl.isValid()) {
- m_projectList->slotAddClip(QList <QUrl> () << clipUrl);
+ pCore->bin()->droppedUrls(QList <QUrl> () << clipUrl);
}
}
@@ -2119,14 +2119,14 @@ void MainWindow::slotEditItemDuration()
pCore->projectManager()->currentTrackView()->projectView()->editItemDuration();
}
-void MainWindow::slotAddProjectClip(const QUrl &url, const stringMap &data)
+void MainWindow::slotAddProjectClip(const QUrl &url, const QMap<QString,QString> &data)
{
- pCore->projectManager()->current()->addClipList(QList<QUrl>() << url, data);
+ pCore->bin()->droppedUrls(QList<QUrl>() << url, data);
}
void MainWindow::slotAddProjectClipList(const QList<QUrl> &urls)
{
- pCore->projectManager()->current()->addClipList(urls);
+ pCore->bin()->droppedUrls(urls);
}
void MainWindow::slotAddTransition(QAction *result)
diff --git a/src/project/clipmanager.cpp b/src/project/clipmanager.cpp
index ac46078..f2c3fac 100644
--- a/src/project/clipmanager.cpp
+++ b/src/project/clipmanager.cpp
@@ -394,141 +394,6 @@ QMap <QString, QString> ClipManager::documentFolderList() const
return m_folderList;
}
-void ClipManager::slotAddClip(const QString &url, const QStringList &groupInfo)
-{
- //qDebug()<<"// Adding clip: "<<url;
- QList <QUrl> list = QList <QUrl>();
- if (!url.isEmpty()) list.append(QUrl::fromLocalFile(url));
- slotAddClipList(list, groupInfo);
-}
-
-void ClipManager::slotAddClipList(const QList <QUrl> &givenList, const QStringList &groupInfo)
-{
- if (!m_doc->commandStack())
- qDebug() << "!!!!!!!!!!!!!!!! NO CMD STK";
-
- QList <QUrl> list;
- if (givenList.isEmpty()) {
- QString allExtensions = "*"; //getExtensions().join(" ");
- const QString dialogFilter = i18n("All Supported Files") + "(" + allExtensions + ");;" + i18n("All Files") + "(*)";
- QCheckBox *b = new QCheckBox(i18n("Import image sequence"));
- b->setChecked(KdenliveSettings::autoimagesequence());
- QCheckBox *c = new QCheckBox(i18n("Transparent background for images"));
- c->setChecked(KdenliveSettings::autoimagetransparency());
- QFrame *f = new QFrame();
- f->setFrameShape(QFrame::NoFrame);
- QHBoxLayout *l = new QHBoxLayout;
- l->addWidget(b);
- l->addWidget(c);
- l->addStretch(5);
- f->setLayout(l);
- QString clipFolder = KRecentDirs::dir(":KdenliveClipFolder");
- if (clipFolder.isEmpty()) clipFolder = QDir::homePath();
- QPointer<QFileDialog> d = new QFileDialog(QApplication::activeWindow(), i18n("Open Clips"), clipFolder, dialogFilter);
- //TODO: KF5, how to add a custom widget to file dialog
- /*QGridLayout *layout = (QGridLayout*)d->layout();
- layout->addWidget(f, 0, 0);*/
- d->setFileMode(QFileDialog::ExistingFiles);
- if (d->exec() == QDialog::Accepted) {
- KdenliveSettings::setAutoimagetransparency(c->isChecked());
- list = d->selectedUrls();
- if (!list.isEmpty()) {
- KRecentDirs::add(":KdenliveClipFolder", list.first().adjusted(QUrl::RemoveFilename).path());
- }
- if (b->isChecked() && list.count() == 1) {
- // Check for image sequence
- QUrl url = list.at(0);
- QString fileName = url.fileName().section('.', 0, -2);
- if (fileName.at(fileName.size() - 1).isDigit()) {
- KFileItem item(url);
- if (item.mimetype().startsWith(QLatin1String("image"))) {
- // import as sequence if we found more than one image in the sequence
- QStringList list;
- QString pattern = SlideshowClip::selectedPath(url, false, QString(), &list);
- int count = list.count();
- if (count > 1) {
- delete d;
- /*QStringList groupInfo = getGroup(); */
- // get image sequence base name
- while (fileName.at(fileName.size() - 1).isDigit()) {
- fileName.chop(1);
- }
- QMap <QString, QString> properties;
- properties.insert("name", fileName);
- properties.insert("resource", pattern);
- properties.insert("in", "0");
- QString duration = m_doc->timecode().reformatSeparators(KdenliveSettings::sequence_duration());
- properties.insert("out", QString::number(m_doc->getFramePos(duration) * count));
- properties.insert("ttl", QString::number(m_doc->getFramePos(duration)));
- properties.insert("loop", QString::number(false));
- properties.insert("crop", QString::number(false));
- properties.insert("fade", QString::number(false));
- properties.insert("luma_duration", QString::number(m_doc->getFramePos(m_doc->timecode().getTimecodeFromFrames(int(ceil(m_doc->timecode().fps()))))));
- //TODO
- //m_doc->slotCreateSlideshowClipFile(properties, groupInfo.at(0), groupInfo.at(1));
- return;
- }
- }
- }
- }
- }
- delete d;
- } else {
- for (int i = 0; i < givenList.count(); ++i)
- list << givenList.at(i);
- }
- QList < QList<QUrl> > foldersList;
- QMimeDatabase db;
- foreach(const QUrl & file, list) {
- // Check there is no folder here
- QMimeType type = db.mimeTypeForUrl(file);
- if (type.inherits("inode/directory")) {
- // user dropped a folder, import its files
- list.removeAll(file);
- QDir dir(file.path());
- QStringList result = dir.entryList(QDir::Files);
- QList <QUrl> folderFiles;
- folderFiles << file;
- foreach(const QString & path, result) {
- folderFiles.append(QUrl::fromLocalFile(dir.absoluteFilePath(path)));
- }
- if (folderFiles.count() > 1) foldersList.append(folderFiles);
- }
- }
- if (givenList.isEmpty() && !list.isEmpty()) {
- QMap <QString, QString> data;
- if (!groupInfo.isEmpty()) {
- data.insert("group", groupInfo.at(0));
- data.insert("groupId", groupInfo.at(1));
- }
- doAddClipList(list, data);
- }
-
- if (!foldersList.isEmpty()) {
- // create folders
- for (int i = 0; i < foldersList.count(); ++i) {
- QList <QUrl> urls = foldersList.at(i);
- QUrl folderUrl = urls.takeFirst();
- QString folderName = folderUrl.fileName();
- /*FolderProjectItem *folder = NULL;
- if (!folderName.isEmpty()) {
- folder = getFolderItemByName(folderName);
- if (folder == NULL) {
- slotAddFolder(folderName);
- folder = getFolderItemByName(folderName);
- }
- }
- if (folder) {
- QMap <QString, QString> data;
- data.insert("group", folder->groupName());
- data.insert("groupId", folder->clipId());
- doAddClipList(urls, data);
- }
- else*/ doAddClipList(urls);
- }
- }
-}
-
void ClipManager::deleteProjectClip(const QString &clipId)
{
pCore->bin()->deleteClip(clipId);
@@ -603,142 +468,9 @@ void ClipManager::slotAddCopiedClip(KIO::Job *job, const QUrl &, const QUrl &dst
data.insert("groupid", meta.value("groupid"));
data.insert("comment", meta.value("comment"));
//qDebug()<<"Finished copying: "<<dst<<" / "<<meta.value("group")<<" / "<<meta.value("groupid");
- doAddClipList(QList<QUrl> () << dst, data);
+ pCore->bin()->droppedUrls(QList<QUrl> () << dst, data);
}
-void ClipManager::doAddClipList(const QList<QUrl> &urls, const QMap <QString, QString> &data)
-{
- QUndoCommand *addClips = new QUndoCommand();
- // Update list of removable volumes
- //TODO: update only when new volume is plugged / unplugged
- listRemovableVolumes();
- foreach(const QUrl &file, urls) {
- if (QFile::exists(file.path())) {
- //TODO check for duplicates
- if (!data.contains("bypassDuplicate") && false /*!getClipByResource(file.path()).empty()*/) {
- if (KMessageBox::warningContinueCancel(QApplication::activeWindow(), i18n("Clip <b>%1</b><br />already exists in project, what do you want to do?", file.path()), i18n("Clip already exists")) == KMessageBox::Cancel)
- continue;
- }
- if (isOnRemovableDevice(file) && !isOnRemovableDevice(m_doc->projectFolder())) {
- int answer = KMessageBox::warningYesNoCancel(QApplication::activeWindow(), i18n("Clip <b>%1</b><br /> is on a removable device, will not be available when device is unplugged", file.path()), i18n("File on a Removable Device"), KGuiItem(i18n("Copy file to project folder")), KGuiItem(i18n("Continue")), KStandardGuiItem::cancel(), QString("copyFilesToProjectFolder"));
-
- if (answer == KMessageBox::Cancel) continue;
- else if (answer == KMessageBox::Yes) {
- // Copy files to project folder
- QDir sourcesFolder(m_doc->projectFolder().toLocalFile());
- sourcesFolder.cd("clips");
- KIO::MkdirJob *mkdirJob = KIO::mkdir(QUrl::fromLocalFile(sourcesFolder.absolutePath()));
- KJobWidgets::setWindow(mkdirJob, QApplication::activeWindow());
- if (!mkdirJob->exec()) {
- KMessageBox::sorry(QApplication::activeWindow(), i18n("Cannot create directory %1", sourcesFolder.absolutePath()));
- continue;
- }
- //KIO::filesize_t m_requestedSize;
- KIO::CopyJob *copyjob = KIO::copy(file, QUrl::fromLocalFile(sourcesFolder.absolutePath()));
- //TODO: for some reason, passing metadata does not work...
- copyjob->addMetaData("group", data.value("group"));
- copyjob->addMetaData("groupId", data.value("groupId"));
- copyjob->addMetaData("comment", data.value("comment"));
- KJobWidgets::setWindow(copyjob, QApplication::activeWindow());
- connect(copyjob, &KIO::CopyJob::copyingDone, this, &ClipManager::slotAddCopiedClip);
- continue;
- }
- }
- //qDebug() << "Adding clip: " << file.path();
- QDomDocument doc;
- QDomElement prod = doc.createElement("producer");
- doc.appendChild(prod);
- QDomElement prop = doc.createElement("property");
- prop.setAttribute("name", "resource");
- QDomText value = doc.createTextNode(file.path());
- prop.appendChild(value);
- prod.appendChild(prop);
- //prod.setAttribute("resource", file.path());
- uint id = pCore->bin()->getFreeClipId();
- prod.setAttribute("id", QString::number(id));
- if (data.contains("comment")) prod.setAttribute("description", data.value("comment"));
- if (data.contains("group")) {
- prod.setAttribute("groupname", data.value("group"));
- prod.setAttribute("groupid", data.value("groupId"));
- }
- if (data.contains("video_index")) prod.setAttribute("video_index", data.value("video_index"));
- if (data.contains("audio_index")) prod.setAttribute("audio_index", data.value("audio_index"));
-
- QMimeDatabase db;
- QMimeType type = db.mimeTypeForUrl(file);
- if (type.name().startsWith(QLatin1String("image/"))) {
- prod.setAttribute("type", (int) Image);
- prod.setAttribute("in", 0);
- prod.setAttribute("out", m_doc->getFramePos(KdenliveSettings::image_duration()) - 1);
- if (KdenliveSettings::autoimagetransparency()) prod.setAttribute("transparency", 1);
- // Read EXIF metadata for JPEG
- if (type.inherits("image/jpeg")) {
- //TODO KF5 how to read metadata?
- /*
- KFileMetaInfo metaInfo(file.path(), QString("image/jpeg"), KFileMetaInfo::TechnicalInfo);
- const QHash<QString, KFileMetaInfoItem> metaInfoItems = metaInfo.items();
- foreach(const KFileMetaInfoItem & metaInfoItem, metaInfoItems) {
- QDomElement meta = doc.createElement("metaproperty");
- meta.setAttribute("name", "meta.attr." + metaInfoItem.name().section('#', 1));
- QDomText value = doc.createTextNode(metaInfoItem.value().toString());
- meta.setAttribute("tool", "KDE Metadata");
- meta.appendChild(value);
- prod.appendChild(meta);
- }*/
- }
- } else if (type.inherits("application/x-kdenlivetitle")) {
- // opening a title file
- QDomDocument txtdoc("titledocument");
- QFile txtfile(file.path());
- if (txtfile.open(QIODevice::ReadOnly) && txtdoc.setContent(&txtfile)) {
- txtfile.close();
- prod.setAttribute("type", (int) Text);
- // extract embeded images
- QDomNodeList items = txtdoc.elementsByTagName("content");
- for (int i = 0; i < items.count() ; ++i) {
- QDomElement content = items.item(i).toElement();
- if (content.hasAttribute("base64")) {
- QString titlesFolder = m_doc->projectFolder().path() + QDir::separator() + "titles/";
- QString path = TitleDocument::extractBase64Image(titlesFolder, content.attribute("base64"));
- if (!path.isEmpty()) {
- content.setAttribute("url", path);
- content.removeAttribute("base64");
- }
- }
- }
- prod.setAttribute("transparency", 1);
- prod.setAttribute("in", 0);
- int duration = 0;
- if (txtdoc.documentElement().hasAttribute("duration")) {
- duration = txtdoc.documentElement().attribute("duration").toInt();
- } else if (txtdoc.documentElement().hasAttribute("out")) {
- duration = txtdoc.documentElement().attribute("out").toInt();
- }
- if (duration <= 0)
- duration = m_doc->getFramePos(KdenliveSettings::title_duration()) - 1;
- prod.setAttribute("duration", duration);
- prod.setAttribute("out", duration);
- txtdoc.documentElement().setAttribute("duration", duration);
- txtdoc.documentElement().setAttribute("out", duration);
- QString titleData = txtdoc.toString();
- prod.setAttribute("xmldata", titleData);
- } else
- txtfile.close();
- }
- new AddClipCommand(m_doc, doc.documentElement(), QString::number(id), true, addClips);
- }
- else qDebug()<<"// CANNOT READ FILE: "<<file;
- }
- if (addClips->childCount() > 0) {
- addClips->setText(i18np("Add clip", "Add clips", addClips->childCount()));
- m_doc->commandStack()->push(addClips);
- }
-}
-
-void ClipManager::slotAddClipFile(const QUrl &url, const QMap <QString, QString> &data)
-{
- doAddClipList(QList<QUrl>() << url, data);
-}
void ClipManager::slotAddXmlClipFile(const QString &name, const QDomElement &xml, const QString &group, const QString &groupId)
{
diff --git a/src/project/clipmanager.h b/src/project/clipmanager.h
index 97912df..df7bf31 100644
--- a/src/project/clipmanager.h
+++ b/src/project/clipmanager.h
@@ -71,18 +71,8 @@ Q_OBJECT public:
ClipManager(KdenliveDoc *doc);
virtual ~ ClipManager();
void deleteClip(const QString &clipId);
-
- /** @brief Adds a list of files to the project.
- * @param urls files to add
- * @param group name of the group to insert the files in (can be empty)
- * @param groupId id of the group (if any)
- * It checks for duplicated items and asks to the user for instructions. */
- void doAddClipList(const QList<QUrl> &urls, const QMap<QString, QString> &data = QMap<QString, QString>());
void deleteProjectClip(const QString &clipId);
- void slotAddClip(const QString &url, const QStringList &groupInfo);
- void slotAddClipList(const QList <QUrl> &givenList, const QStringList &groupInfo);
-
void slotAddTextClipFile(const QString &titleName, int out, const QString &xml, const QString &group, const QString &groupId);
void slotAddTextTemplateClip(QString titleName, const QUrl &path, const QString &group, const QString &groupId);
void slotAddXmlClipFile(const QString &name, const QDomElement &xml, const QString &group, const QString &groupId);
@@ -111,13 +101,6 @@ Q_OBJECT public:
public slots:
/** @brief Request creation of a clip thumbnail for specified frames. */
void slotRequestThumbs(const QString &id, const QList<int> &frames);
-
- /** @brief Add a file to the project.
- * @ref slotAddClipList
- * @param url file to add
- * @param group name of the group to insert the file in (can be empty)
- * @param groupId id of the group (if any) */
- void slotAddClipFile(const QUrl &url, const QMap<QString, QString> &data);
private slots:
/** A clip was externally modified, monitor for more changes and prepare for reload */
diff --git a/src/project/projectlist.cpp b/src/project/projectlist.cpp
index c798ef7..2b33f59 100644
--- a/src/project/projectlist.cpp
+++ b/src/project/projectlist.cpp
@@ -1161,8 +1161,6 @@ void ProjectList::slotAddFolder(const QString &foldername, const QString &clipId
m_doc->setModified(true);
}
-
-
void ProjectList::deleteProjectFolder(QMap <QString, QString> map)
{
QMapIterator<QString, QString> i(map);
@@ -1176,78 +1174,6 @@ void ProjectList::deleteProjectFolder(QMap <QString, QString> map)
else delete delCommand;
}
-void ProjectList::slotAddClip(DocClipBase *clip, bool getProperties)
-{
- //m_listView->setEnabled(false);
- const QString parent = clip->getProperty("groupid");
- QString groupName = clip->getProperty("groupname");
- QSize pixelSize((int)(m_listView->iconSize().height() * m_render->dar()), m_listView->iconSize().height());
- ProjectItem *item = NULL;
- monitorItemEditing(false);
- if (!parent.isEmpty()) {
- FolderProjectItem *parentitem = getFolderItemById(parent);
- if (!parentitem) {
- QStringList text;
- ////qDebug() << "Adding clip to new group: " << groupName;
- if (groupName.isEmpty()) groupName = i18n("Folder");
- text << groupName;
- parentitem = new FolderProjectItem(m_listView, text, parent);
- }
-
- if (parentitem)
- item = new ProjectItem(parentitem, clip, pixelSize);
- }
- if (item == NULL) {
- item = new ProjectItem(m_listView, clip, pixelSize);
- }
- if (item->data(0, ItemDelegate::DurationRole).isNull()) item->setData(0, ItemDelegate::DurationRole, i18n("Loading"));
- connect(clip, SIGNAL(createProxy(QString)), this, SLOT(slotCreateProxy(QString)));
- connect(clip, SIGNAL(abortProxy(QString,QString)), this, SLOT(slotAbortProxy(QString,QString)));
-
- if (getProperties) {
- //item->setFlags(Qt::ItemIsSelectable);
- //m_listView->processLayout();
- QDomElement e = clip->toXML().cloneNode().toElement();
- if (!groupName.isEmpty()) {
- e.setAttribute("groupId", parent);
- e.setAttribute("group", groupName);
- }
- e.removeAttribute("file_hash");
- resetThumbsProducer(clip);
- m_render->getFileProperties(e, clip->getId(), 200, true);
- }
- // WARNING: code below triggers unnecessary reload of all proxy clips on document loading... is it useful in some cases?
- /*else if (item->hasProxy() && !item->isJobRunning()) {
- slotCreateProxy(clip->getId());
- }*/
-
- QUrl url = clip->fileURL();
-
- // Add info to date column
- QFileInfo fileInfo(url.path());
- if (fileInfo.exists()) {
- item->setText(3, fileInfo.lastModified().toString(QString("yyyy/MM/dd hh:mm:ss")));
- }
-
- // Add cut zones
- QList <CutZoneInfo> cuts = clip->cutZones();
- if (!cuts.isEmpty()) {
- for (int i = 0; i < cuts.count(); ++i) {
- SubProjectItem *sub = new SubProjectItem(m_render->dar(), item, cuts.at(i).zone.x(), cuts.at(i).zone.y(), cuts.at(i).description);
- if (!clip->getClipHash().isEmpty()) {
- QString cachedPixmap = m_doc->projectFolder().path() + QDir::separator() + "thumbs/" + clip->getClipHash() + '#' + QString::number(cuts.at(i).zone.x()) + ".png";
- if (QFile::exists(cachedPixmap)) {
- QPixmap pix(cachedPixmap);
- if (pix.isNull())
- QFile::remove(cachedPixmap);
- sub->setData(0, Qt::DecorationRole, pix);
- }
- }
- }
- }
- monitorItemEditing(true);
- if (!getProperties) updateButtons();
-}
void ProjectList::slotGotProxy(const QString &proxyPath)
{
@@ -1556,147 +1482,6 @@ QStringList ProjectList::getExtensions()
return allExtensions;
}
-void ProjectList::slotAddClip(const QString &url, const QString &groupName, const QString &groupId)
-{
- //qDebug()<<"// Adding clip: "<<url;
- QList <QUrl> list;
- list.append(QUrl::fromLocalFile(url));
- slotAddClip(list, groupName, groupId);
-}
-
-void ProjectList::slotAddClip(const QList <QUrl> &givenList, const QString &groupName, const QString &groupId)
-{
- if (!m_commandStack)
- qDebug() << "!!!!!!!!!!!!!!!! NO CMD STK";
-
- QList <QUrl> list;
- if (givenList.isEmpty()) {
- QString allExtensions = getExtensions().join(" ");
- const QString dialogFilter = i18n("All Supported Files") + "(" + allExtensions + ");;" + i18n("All Files") + "(*)";
- QCheckBox *b = new QCheckBox(i18n("Import image sequence"));
- b->setChecked(KdenliveSettings::autoimagesequence());
- QCheckBox *c = new QCheckBox(i18n("Transparent background for images"));
- c->setChecked(KdenliveSettings::autoimagetransparency());
- QFrame *f = new QFrame();
- f->setFrameShape(QFrame::NoFrame);
- QHBoxLayout *l = new QHBoxLayout;
- l->addWidget(b);
- l->addWidget(c);
- l->addStretch(5);
- f->setLayout(l);
- QString clipFolder = KRecentDirs::dir(":KdenliveClipFolder");
- if (clipFolder.isEmpty()) clipFolder = QDir::homePath();
- QPointer<QFileDialog> d = new QFileDialog(QApplication::activeWindow(), i18n("Open Clips"), clipFolder, dialogFilter);
- //TODO: KF5, how to add a custom widget to file dialog
- /*QGridLayout *layout = (QGridLayout*)d->layout();
- layout->addWidget(f, 0, 0);*/
- d->setFileMode(QFileDialog::ExistingFiles);
- if (d->exec() == QDialog::Accepted) {
- KdenliveSettings::setAutoimagetransparency(c->isChecked());
- list = d->selectedUrls();
- if (!list.isEmpty()) {
- KRecentDirs::add(":KdenliveClipFolder", list.first().adjusted(QUrl::RemoveFilename).path());
- }
- if (b->isChecked() && list.count() == 1) {
- // Check for image sequence
- QUrl url = list.at(0);
- QString fileName = url.fileName().section('.', 0, -2);
- if (fileName.at(fileName.size() - 1).isDigit()) {
- KFileItem item(url);
- if (item.mimetype().startsWith(QLatin1String("image"))) {
- // import as sequence if we found more than one image in the sequence
- QStringList list;
- QString pattern = SlideshowClip::selectedPath(url, false, QString(), &list);
- int count = list.count();
- if (count > 1) {
- delete d;
- QStringList groupInfo = getGroup();
-
- // get image sequence base name
- while (fileName.at(fileName.size() - 1).isDigit()) {
- fileName.chop(1);
- }
- QMap <QString, QString> properties;
- properties.insert("name", fileName);
- properties.insert("resource", pattern);
- properties.insert("in", "0");
- QString duration = m_timecode.reformatSeparators(KdenliveSettings::sequence_duration());
- properties.insert("out", QString::number(m_doc->getFramePos(duration) * count));
- properties.insert("ttl", QString::number(m_doc->getFramePos(duration)));
- properties.insert("loop", QString::number(false));
- properties.insert("crop", QString::number(false));
- properties.insert("fade", QString::number(false));
- properties.insert("luma_duration", QString::number(m_doc->getFramePos(m_timecode.getTimecodeFromFrames(int(ceil(m_timecode.fps()))))));
- //TODO
- //m_doc->slotCreateSlideshowClipFile(properties, groupInfo.at(0), groupInfo.at(1));
- return;
- }
- }
- }
- }
- }
- delete d;
- } else {
- for (int i = 0; i < givenList.count(); ++i)
- list << givenList.at(i);
- }
- QList < QList<QUrl> > foldersList;
- QMimeDatabase db;
- foreach(const QUrl & file, list) {
- // Check there is no folder here
- QMimeType type = db.mimeTypeForUrl(file);
- if (type.inherits("inode/directory")) {
- // user dropped a folder, import its files
- list.removeAll(file);
- QDir dir(file.path());
- QStringList result = dir.entryList(QDir::Files);
- QList <QUrl> folderFiles;
- folderFiles << file;
- foreach(const QString & path, result) {
- folderFiles.append(QUrl::fromLocalFile(dir.absoluteFilePath(path)));
- }
- if (folderFiles.count() > 1) foldersList.append(folderFiles);
- }
- }
-
- if (givenList.isEmpty() && !list.isEmpty()) {
- QStringList groupInfo = getGroup();
- QMap <QString, QString> data;
- data.insert("group", groupInfo.at(0));
- data.insert("groupId", groupInfo.at(1));
- m_doc->clipManager()->doAddClipList(list, data);
- } else if (!list.isEmpty()) {
- QMap <QString, QString> data;
- data.insert("group", groupName);
- data.insert("groupId", groupId);
- m_doc->clipManager()->doAddClipList(list, data);
- }
-
- if (!foldersList.isEmpty()) {
- // create folders
- for (int i = 0; i < foldersList.count(); ++i) {
- QList <QUrl> urls = foldersList.at(i);
- QUrl folderUrl = urls.takeFirst();
- QString folderName = folderUrl.fileName();
- FolderProjectItem *folder = NULL;
- if (!folderName.isEmpty()) {
- folder = getFolderItemByName(folderName);
- if (folder == NULL) {
- slotAddFolder(folderName);
- folder = getFolderItemByName(folderName);
- }
- }
- if (folder) {
- QMap <QString, QString> data;
- data.insert("group", folder->groupName());
- data.insert("groupId", folder->clipId());
- m_doc->addClipList(urls, data);
- }
- else m_doc->addClipList(urls);
- }
- }
-}
-
void ProjectList::slotRemoveInvalidClip(const QString &id, bool replace)
{
ProjectItem *item = getItemById(id);
diff --git a/src/project/projectlist.h b/src/project/projectlist.h
index ff1caba..bd7c9b1 100644
--- a/src/project/projectlist.h
+++ b/src/project/projectlist.h
@@ -165,7 +165,6 @@ public slots:
void slotReplyGetImage(const QString &clipId, const QImage &img);
void slotReplyGetImage(const QString &clipId, const QString &name, int width, int height);
void slotReplyGetFileProperties(requestClipInfo &clipInfo, Mlt::Producer &producer, const stringMap &properties, const stringMap &metadata);
- void slotAddClip(DocClipBase *clip, bool getProperties);
void slotDeleteClip(const QString &clipId);
void slotUpdateClip(const QString &id);
void slotRefreshClipThumbnail(const QString &clipId, bool update = true);
@@ -176,8 +175,6 @@ public slots:
/** @brief Prepares removing the selected items. */
void slotRemoveClip();
- void slotAddClip(const QString &url, const QString &groupName, const QString &groupId);
- void slotAddClip(const QList <QUrl> &givenList = QList <QUrl> (), const QString &groupName = QString(), const QString &groupId = QString());
/** @brief Adds, edits or deletes a folder item.
*
diff --git a/src/project/projectmanager.cpp b/src/project/projectmanager.cpp
index d4289dd..742d7b9 100644
--- a/src/project/projectmanager.cpp
+++ b/src/project/projectmanager.cpp
@@ -79,7 +79,7 @@ void ProjectManager::slotLoadOnOpen()
//qDebug() << QDir::current().absoluteFilePath(path);
urls << QUrl::fromLocalFile(QDir::current().absoluteFilePath(path));
}
- pCore->window()->m_projectList->slotAddClip(urls);
+ pCore->bin()->droppedUrls(urls);
}
m_loadClipsOnOpen.clear();
}