Commit 8ff45d90 authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Check for duplicates on add clip

Fixes #1114
parent b3a97400
......@@ -229,11 +229,28 @@ const QString ClipCreator::createClipsFromList(const QList<QUrl> &list, bool che
progressDialog->repaint();
qApp->processEvents();
}*/
qDebug() << "/////////// creatclipsfromlist" << list << checkRemovable << parentFolder;
// Check for duplicates
QList<QUrl> cleanList;
QStringList duplicates;
for (const QUrl &url : list) {
if (!pCore->projectItemModel()->urlExists(url.toLocalFile())) {
cleanList << url;
} else {
duplicates << url.toLocalFile();
}
}
if (!duplicates.isEmpty()) {
if (KMessageBox::warningYesNoList(QApplication::activeWindow(), i18n("The following clips are already inserted in the project. Do you want to duplicate them?"), duplicates) ==
KMessageBox::Yes) {
cleanList = list;
}
}
qDebug() << "/////////// creatclipsfromlist" << cleanList << checkRemovable << parentFolder;
bool created = false;
QMimeDatabase db;
bool removableProject = checkRemovable ? isOnRemovableDevice(pCore->currentDoc()->projectDataFolder()) : false;
for (const QUrl &file : list) {
for (const QUrl &file : cleanList) {
if (!QFile::exists(file.toLocalFile())) {
continue;
}
......
......@@ -115,3 +115,8 @@ void FileWatcher::clear()
m_binClipPaths.clear();
m_fileWatcher->startScan();
}
bool FileWatcher::contains(const QString &path) const
{
return m_fileWatcher->contains(path);
}
......@@ -43,6 +43,8 @@ public:
void addFile(const QString &binId, const QString &url);
// Remove a binId from the list of watched items
void removeFile(const QString &binId);
// True if this url is already watched
bool contains(const QString &path) const;
// Reset all watched files
void clear();
......
......@@ -1169,3 +1169,8 @@ QString ProjectItemModel::validateClipInFolder(const QString &folderId, const QS
}
return QString();
}
bool ProjectItemModel::urlExists(const QString &path) const
{
return m_fileWatcher->contains(path);
}
......@@ -218,6 +218,8 @@ public:
/** @brief Number of clips in the bin playlist */
int clipsCount() const;
/** @brief Check if a file is already in Bin */
bool urlExists(const QString &path) const;
protected:
/** @brief Register the existence of a new element
......
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