Commit 845a9839 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Reindent. It helps to read code

parent 254095f4
...@@ -176,34 +176,34 @@ void ClipManager::slotGetThumbs() ...@@ -176,34 +176,34 @@ void ClipManager::slotGetThumbs()
m_processingThumbId = i.key(); m_processingThumbId = i.key();
QList<int> values = m_requestedThumbs.values(m_processingThumbId); QList<int> values = m_requestedThumbs.values(m_processingThumbId);
m_requestedThumbs.remove(m_processingThumbId); m_requestedThumbs.remove(m_processingThumbId);
if (m_processingThumbId.startsWith("?")) { if (m_processingThumbId.startsWith("?")) {
// if id starts with ?, it means the request comes from a clip property widget // if id starts with ?, it means the request comes from a clip property widget
thumbType = 2; thumbType = 2;
m_processingThumbId.remove(0, 1); m_processingThumbId.remove(0, 1);
} }
if (m_processingThumbId.startsWith("#")) { if (m_processingThumbId.startsWith("#")) {
// if id starts with #, it means the request comes from project tree // if id starts with #, it means the request comes from project tree
thumbType = 1; thumbType = 1;
m_processingThumbId.remove(0, 1); m_processingThumbId.remove(0, 1);
} }
m_thumbsMutex.unlock(); m_thumbsMutex.unlock();
qSort(values); qSort(values);
DocClipBase *clip = getClipById(m_processingThumbId); DocClipBase *clip = getClipById(m_processingThumbId);
if (!clip) continue; if (!clip) continue;
max = m_requestedThumbs.size() + values.count(); max = m_requestedThumbs.size() + values.count();
int pos; int pos;
while (!values.isEmpty() && clip->thumbProducer() && !m_abortThumb) { while (!values.isEmpty() && clip->thumbProducer() && !m_abortThumb) {
pos = values.takeFirst(); pos = values.takeFirst();
switch (thumbType) { switch (thumbType) {
case 1: case 1:
clip->thumbProducer()->getGenericThumb(pos, SubProjectItem::itemDefaultHeight(), thumbType); clip->thumbProducer()->getGenericThumb(pos, SubProjectItem::itemDefaultHeight(), thumbType);
break; break;
case 2: case 2:
clip->thumbProducer()->getGenericThumb(pos, 180, thumbType); clip->thumbProducer()->getGenericThumb(pos, 180, thumbType);
break; break;
default: default:
clip->thumbProducer()->getThumb(pos); clip->thumbProducer()->getThumb(pos);
} }
done++; done++;
if (max > 3) emit displayMessage(i18n("Loading thumbnails"), 100 * done / max); if (max > 3) emit displayMessage(i18n("Loading thumbnails"), 100 * done / max);
} }
...@@ -264,17 +264,17 @@ void ClipManager::slotGetAudioThumbs() ...@@ -264,17 +264,17 @@ void ClipManager::slotGetAudioThumbs()
if (hash.isEmpty()) continue; if (hash.isEmpty()) continue;
QString audioPath = projectFolder() + "/thumbs/" + hash + ".thumb"; QString audioPath = projectFolder() + "/thumbs/" + hash + ".thumb";
double lengthInFrames = clip->duration().frames(m_doc->fps()); double lengthInFrames = clip->duration().frames(m_doc->fps());
int frequency = 0; int frequency = 0;
int channels = 0; int channels = 0;
QString data = clip->getProperty("frequency"); QString data = clip->getProperty("frequency");
if (!data.isEmpty()) frequency = data.toInt(); if (!data.isEmpty()) frequency = data.toInt();
if (frequency <= 0) frequency = 48000; if (frequency <= 0) frequency = 48000;
data = clip->getProperty("channels"); data = clip->getProperty("channels");
if (!data.isEmpty()) channels = data.toInt(); if (!data.isEmpty()) channels = data.toInt();
if (channels <= 0) channels = 2; if (channels <= 0) channels = 2;
int arrayWidth = 20; int arrayWidth = 20;
double frame = 0.0; double frame = 0.0;
int maxVolume = 0; int maxVolume = 0;
audioByteArray storeIn; audioByteArray storeIn;
QFile f(audioPath); QFile f(audioPath);
if (QFileInfo(audioPath).size() > 0 && f.open(QIODevice::ReadOnly)) { if (QFileInfo(audioPath).size() > 0 && f.open(QIODevice::ReadOnly)) {
...@@ -296,7 +296,7 @@ void ClipManager::slotGetAudioThumbs() ...@@ -296,7 +296,7 @@ void ClipManager::slotGetAudioThumbs()
QByteArray audioArray(arrayWidth, '\x00'); QByteArray audioArray(arrayWidth, '\x00');
for (int i = 0; i < arrayWidth; ++i) { for (int i = 0; i < arrayWidth; ++i) {
audioArray[i] = channelarray.at(h2 + h3 + i); audioArray[i] = channelarray.at(h2 + h3 + i);
if (audioArray.at(i) > maxVolume) maxVolume = audioArray.at(i); if (audioArray.at(i) > maxVolume) maxVolume = audioArray.at(i);
} }
h3 += arrayWidth; h3 += arrayWidth;
storeIn[z][c] = audioArray; storeIn[z][c] = audioArray;
...@@ -304,11 +304,11 @@ void ClipManager::slotGetAudioThumbs() ...@@ -304,11 +304,11 @@ void ClipManager::slotGetAudioThumbs()
h2 += h1; h2 += h1;
} }
if (!m_abortAudioThumb) { if (!m_abortAudioThumb) {
clip->setProperty("audio_max", QString::number(maxVolume - 64)); clip->setProperty("audio_max", QString::number(maxVolume - 64));
clip->updateAudioThumbnail(storeIn); clip->updateAudioThumbnail(storeIn);
} }
continue; continue;
} }
if (!f.open(QIODevice::WriteOnly)) { if (!f.open(QIODevice::WriteOnly)) {
kDebug() << "++++++++ ERROR WRITING TO FILE: " << audioPath; kDebug() << "++++++++ ERROR WRITING TO FILE: " << audioPath;
...@@ -354,17 +354,17 @@ void ClipManager::slotGetAudioThumbs() ...@@ -354,17 +354,17 @@ void ClipManager::slotGetAudioThumbs()
QByteArray audioArray; QByteArray audioArray;
audioArray.resize(arrayWidth); audioArray.resize(arrayWidth);
for (int i = 0; i < audioArray.size(); ++i) { for (int i = 0; i < audioArray.size(); ++i) {
double pcmval = *(pcm + c + i * samples / audioArray.size()); double pcmval = *(pcm + c + i * samples / audioArray.size());
if (pcmval >= 0) { if (pcmval >= 0) {
pcmval = sqrt(pcmval) / 2.83 + 64; pcmval = sqrt(pcmval) / 2.83 + 64;
audioArray[i] = pcmval; audioArray[i] = pcmval;
if (pcmval > maxVolume) maxVolume = pcmval; if (pcmval > maxVolume) maxVolume = pcmval;
} }
else { else {
pcmval = -sqrt(-pcmval) / 2.83 + 64; pcmval = -sqrt(-pcmval) / 2.83 + 64;
audioArray[i] = pcmval; audioArray[i] = pcmval;
if (-pcmval > maxVolume) maxVolume = -pcmval; if (-pcmval > maxVolume) maxVolume = -pcmval;
} }
} }
f.write(audioArray); f.write(audioArray);
storeIn[z][c] = audioArray; storeIn[z][c] = audioArray;
...@@ -380,7 +380,7 @@ void ClipManager::slotGetAudioThumbs() ...@@ -380,7 +380,7 @@ void ClipManager::slotGetAudioThumbs()
f.remove(); f.remove();
} else { } else {
clip->updateAudioThumbnail(storeIn); clip->updateAudioThumbnail(storeIn);
clip->setProperty("audio_max", QString::number(maxVolume - 64)); clip->setProperty("audio_max", QString::number(maxVolume - 64));
} }
} }
m_processingAudioThumbId.clear(); m_processingAudioThumbId.clear();
...@@ -433,7 +433,7 @@ void ClipManager::deleteClip(const QString &clipId) ...@@ -433,7 +433,7 @@ void ClipManager::deleteClip(const QString &clipId)
{ {
for (int i = 0; i < m_clipList.count(); ++i) { for (int i = 0; i < m_clipList.count(); ++i) {
if (m_clipList.at(i)->getId() == clipId) { if (m_clipList.at(i)->getId() == clipId) {
DocClipBase *clip = m_clipList.takeAt(i); DocClipBase *clip = m_clipList.takeAt(i);
if (clip->clipType() != COLOR && clip->clipType() != SLIDESHOW && !clip->fileURL().isEmpty()) { if (clip->clipType() != COLOR && clip->clipType() != SLIDESHOW && !clip->fileURL().isEmpty()) {
//if (m_clipList.at(i)->clipType() == IMAGE || m_clipList.at(i)->clipType() == AUDIO || (m_clipList.at(i)->clipType() == TEXT && !m_clipList.at(i)->fileURL().isEmpty())) { //if (m_clipList.at(i)->clipType() == IMAGE || m_clipList.at(i)->clipType() == AUDIO || (m_clipList.at(i)->clipType() == TEXT && !m_clipList.at(i)->fileURL().isEmpty())) {
// listen for file change // listen for file change
...@@ -540,23 +540,23 @@ void ClipManager::slotAddClipList(const KUrl::List &urls, const QMap <QString, Q ...@@ -540,23 +540,23 @@ void ClipManager::slotAddClipList(const KUrl::List &urls, const QMap <QString, Q
continue; continue;
} }
if (isOnRemovableDevice(file)) { if (isOnRemovableDevice(file)) {
int answer = KMessageBox::warningYesNoCancel(kapp->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")); int answer = KMessageBox::warningYesNoCancel(kapp->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; if (answer == KMessageBox::Cancel) continue;
else if (answer == KMessageBox::Yes) { else if (answer == KMessageBox::Yes) {
// Copy files to project folder // Copy files to project folder
QString sourcesFolder = m_doc->projectFolder().path(KUrl::AddTrailingSlash) + "clips/"; QString sourcesFolder = m_doc->projectFolder().path(KUrl::AddTrailingSlash) + "clips/";
KIO::NetAccess::mkdir(sourcesFolder, kapp->activeWindow()); KIO::NetAccess::mkdir(sourcesFolder, kapp->activeWindow());
//KIO::filesize_t m_requestedSize; //KIO::filesize_t m_requestedSize;
KIO::CopyJob *copyjob = KIO::copy (file, KUrl(sourcesFolder)); KIO::CopyJob *copyjob = KIO::copy (file, KUrl(sourcesFolder));
//TODO: for some reason, passing metadata does not work... //TODO: for some reason, passing metadata does not work...
copyjob->addMetaData("group", data.value("group")); copyjob->addMetaData("group", data.value("group"));
copyjob->addMetaData("groupId", data.value("groupId")); copyjob->addMetaData("groupId", data.value("groupId"));
copyjob->addMetaData("comment", data.value("comment")); copyjob->addMetaData("comment", data.value("comment"));
copyjob->ui()->setWindow(kapp->activeWindow()); copyjob->ui()->setWindow(kapp->activeWindow());
connect(copyjob, SIGNAL(copyingDone(KIO::Job*,KUrl,KUrl,time_t,bool,bool)), this, SLOT(slotAddClip(KIO::Job*,KUrl,KUrl))); connect(copyjob, SIGNAL(copyingDone(KIO::Job*,KUrl,KUrl,time_t,bool,bool)), this, SLOT(slotAddClip(KIO::Job*,KUrl,KUrl)));
continue; continue;
} }
} }
kDebug() << "Adding clip: " << file.path(); kDebug() << "Adding clip: " << file.path();
QDomDocument doc; QDomDocument doc;
QDomElement prod = doc.createElement("producer"); QDomElement prod = doc.createElement("producer");
...@@ -570,8 +570,8 @@ void ClipManager::slotAddClipList(const KUrl::List &urls, const QMap <QString, Q ...@@ -570,8 +570,8 @@ void ClipManager::slotAddClipList(const KUrl::List &urls, const QMap <QString, Q
prod.setAttribute("groupid", data.value("groupId")); prod.setAttribute("groupid", data.value("groupId"));
} }
if (data.contains("video_index")) prod.setAttribute("video_index", data.value("video_index")); 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")); if (data.contains("audio_index")) prod.setAttribute("audio_index", data.value("audio_index"));
KMimeType::Ptr type = KMimeType::findByUrl(file); KMimeType::Ptr type = KMimeType::findByUrl(file);
if (type->name().startsWith("image/")) { if (type->name().startsWith("image/")) {
prod.setAttribute("type", (int) IMAGE); prod.setAttribute("type", (int) IMAGE);
...@@ -583,12 +583,12 @@ void ClipManager::slotAddClipList(const KUrl::List &urls, const QMap <QString, Q ...@@ -583,12 +583,12 @@ void ClipManager::slotAddClipList(const KUrl::List &urls, const QMap <QString, Q
KFileMetaInfo metaInfo(file.path(), QString("image/jpeg"), KFileMetaInfo::TechnicalInfo); KFileMetaInfo metaInfo(file.path(), QString("image/jpeg"), KFileMetaInfo::TechnicalInfo);
const QHash<QString, KFileMetaInfoItem> metaInfoItems = metaInfo.items(); const QHash<QString, KFileMetaInfoItem> metaInfoItems = metaInfo.items();
foreach(const KFileMetaInfoItem & metaInfoItem, metaInfoItems) { foreach(const KFileMetaInfoItem & metaInfoItem, metaInfoItems) {
QDomElement meta = doc.createElement("metaproperty"); QDomElement meta = doc.createElement("metaproperty");
meta.setAttribute("name", "meta.attr." + metaInfoItem.name().section('#', 1)); meta.setAttribute("name", "meta.attr." + metaInfoItem.name().section('#', 1));
QDomText value = doc.createTextNode(metaInfoItem.value().toString()); QDomText value = doc.createTextNode(metaInfoItem.value().toString());
meta.setAttribute("tool", "KDE Metadata"); meta.setAttribute("tool", "KDE Metadata");
meta.appendChild(value); meta.appendChild(value);
prod.appendChild(meta); prod.appendChild(meta);
} }
} }
} else if (type->is("application/x-kdenlivetitle")) { } else if (type->is("application/x-kdenlivetitle")) {
...@@ -613,20 +613,20 @@ void ClipManager::slotAddClipList(const KUrl::List &urls, const QMap <QString, Q ...@@ -613,20 +613,20 @@ void ClipManager::slotAddClipList(const KUrl::List &urls, const QMap <QString, Q
} }
prod.setAttribute("transparency", 1); prod.setAttribute("transparency", 1);
prod.setAttribute("in", 0); prod.setAttribute("in", 0);
if (!txtdoc.documentElement().hasAttribute("out")) { if (!txtdoc.documentElement().hasAttribute("out")) {
prod.setAttribute("out", m_doc->getFramePos(KdenliveSettings::title_duration()) - 1); prod.setAttribute("out", m_doc->getFramePos(KdenliveSettings::title_duration()) - 1);
txtdoc.documentElement().setAttribute("out", m_doc->getFramePos(KdenliveSettings::title_duration()) - 1); txtdoc.documentElement().setAttribute("out", m_doc->getFramePos(KdenliveSettings::title_duration()) - 1);
} }
else { else {
int out = txtdoc.documentElement().attribute("out").toInt(); int out = txtdoc.documentElement().attribute("out").toInt();
if (out >= 0) if (out >= 0)
prod.setAttribute("out", out); prod.setAttribute("out", out);
else { else {
prod.setAttribute("out", m_doc->getFramePos(KdenliveSettings::title_duration()) - 1); prod.setAttribute("out", m_doc->getFramePos(KdenliveSettings::title_duration()) - 1);
txtdoc.documentElement().setAttribute("out", m_doc->getFramePos(KdenliveSettings::title_duration()) - 1); txtdoc.documentElement().setAttribute("out", m_doc->getFramePos(KdenliveSettings::title_duration()) - 1);
} }
} }
QString titleData = txtdoc.toString(); QString titleData = txtdoc.toString();
prod.setAttribute("xmldata", titleData); prod.setAttribute("xmldata", titleData);
} else } else
txtfile.close(); txtfile.close();
...@@ -750,13 +750,13 @@ void ClipManager::slotAddTextTemplateClip(QString titleName, const KUrl &path, c ...@@ -750,13 +750,13 @@ void ClipManager::slotAddTextTemplateClip(QString titleName, const KUrl &path, c
QFile txtfile(path.path()); QFile txtfile(path.path());
if (txtfile.open(QIODevice::ReadOnly) && titledoc.setContent(&txtfile)) { if (txtfile.open(QIODevice::ReadOnly) && titledoc.setContent(&txtfile)) {
txtfile.close(); txtfile.close();
if (titledoc.documentElement().hasAttribute("duration")) { if (titledoc.documentElement().hasAttribute("duration")) {
duration = titledoc.documentElement().attribute("duration").toInt(); duration = titledoc.documentElement().attribute("duration").toInt();
} }
else { else {
// keep some time for backwards compatibility - 26/12/12 // keep some time for backwards compatibility - 26/12/12
duration = titledoc.documentElement().attribute("out").toInt(); duration = titledoc.documentElement().attribute("out").toInt();
} }
} else txtfile.close(); } else txtfile.close();
if (duration == 0) duration = m_doc->getFramePos(KdenliveSettings::title_duration()); if (duration == 0) duration = m_doc->getFramePos(KdenliveSettings::title_duration());
...@@ -929,7 +929,7 @@ void ClipManager::listRemovableVolumes() ...@@ -929,7 +929,7 @@ void ClipManager::listRemovableVolumes()
continue; continue;
Solid::StorageDrive *drive = driveDevice.as<Solid::StorageDrive>(); Solid::StorageDrive *drive = driveDevice.as<Solid::StorageDrive>();
if (!drive->isRemovable()) continue; if (!drive->isRemovable()) continue;
// check for StorageVolume // check for StorageVolume
Solid::Device volumeDevice; Solid::Device volumeDevice;
...@@ -985,11 +985,11 @@ bool ClipManager::isOnRemovableDevice(const KUrl &url) ...@@ -985,11 +985,11 @@ bool ClipManager::isOnRemovableDevice(const KUrl &url)
void ClipManager::projectTreeThumbReady(const QString &id, int frame, const QImage &img, int type) void ClipManager::projectTreeThumbReady(const QString &id, int frame, const QImage &img, int type)
{ {
switch (type) { switch (type) {
case 2: case 2:
emit gotClipPropertyThumbnail(id, img); emit gotClipPropertyThumbnail(id, img);
break; break;
default: default:
emit thumbReady(id, frame, img); emit thumbReady(id, frame, img);
} }
} }
......
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