+void KdenliveDoc::setProjectFolder(KUrl url) {
+ if (url == m_projectFolder) return;
+ setModified(true);
+ KStandardDirs::makeDir(url.path());
+ KStandardDirs::makeDir(url.path() + "/titles/");
+ KStandardDirs::makeDir(url.path() + "/thumbs/");
+ if (KMessageBox::questionYesNo(kapp->activeWindow(), i18n("You have changed the project folder. Do you want to copy the cached data from %1 to the new folder %2 ?").arg(m_projectFolder.path(), url.path())) == KMessageBox::Yes) moveProjectData(url);
+ m_projectFolder = url;
+}
+
+void KdenliveDoc::moveProjectData(KUrl url) {
+ QList <DocClipBase*> list = m_clipManager->documentClipList();
+ for (int i = 0; i < list.count(); i++) {
+ DocClipBase *clip = list.at(i);
+ if (clip->clipType() == TEXT) {
+ // the image for title clip must be moved
+ KUrl oldUrl = clip->fileURL();
+ KUrl newUrl = KUrl(url.path() + "/titles/" + oldUrl.fileName());
+ KIO::Job *job = KIO::copy(oldUrl, newUrl);
+ if (KIO::NetAccess::synchronousRun(job, 0)) clip->setProperty("resource", newUrl.path());
+ }
+ QString hash = clip->getClipHash();
+ KUrl oldVideoThumbUrl = KUrl(m_projectFolder.path() + "/thumbs/" + hash + ".png");
+ KUrl oldAudioThumbUrl = KUrl(m_projectFolder.path() + "/thumbs/" + hash + ".thumb");
+ if (KIO::NetAccess::exists(oldVideoThumbUrl, KIO::NetAccess::SourceSide, 0)) {
+ KUrl newUrl = KUrl(url.path() + "/thumbs/" + hash + ".png");
+ KIO::Job *job = KIO::copy(oldVideoThumbUrl, newUrl);
+ KIO::NetAccess::synchronousRun(job, 0);
+ }
+ if (KIO::NetAccess::exists(oldAudioThumbUrl, KIO::NetAccess::SourceSide, 0)) {
+ KUrl newUrl = KUrl(url.path() + "/thumbs/" + hash + ".thumb");
+ KIO::Job *job = KIO::copy(oldAudioThumbUrl, newUrl);
+ if (KIO::NetAccess::synchronousRun(job, 0)) clip->refreshThumbUrl();
+ }
+ }
+}
+