Fix display of clip duration in project tree + some cleanup + indent fixes

svn path=/trunk/kdenlive/; revision=3119
parent 9bc75be5
......@@ -38,13 +38,15 @@ DocClipBase::DocClipBase(ClipManager *clipManager, QDomElement xml, const QStrin
KUrl url = KUrl(xml.attribute("resource"));
if (!m_properties.contains("file_hash") && !url.isEmpty()) getFileHash(url.path());
int out = xml.attribute("out").toInt();
if (out != 0) {
setDuration(GenTime(out, KdenliveSettings::project_fps()));
if (xml.hasAttribute("duration")) {
setDuration(GenTime(xml.attribute("duration").toInt(), KdenliveSettings::project_fps()));
} else {
out = xml.attribute("duration").toInt();
if (out != 0) setDuration(GenTime(out, KdenliveSettings::project_fps()));
int out = xml.attribute("out").toInt();
int in = xml.attribute("in").toInt();
setDuration(GenTime(out - in, KdenliveSettings::project_fps()));
}
if (!m_properties.contains("name")) m_properties.insert("name", url.fileName());
//if (!url.isEmpty() && QFile::exists(url.path()))
......
......@@ -85,10 +85,6 @@ KdenliveDoc::KdenliveDoc(const KUrl &url, const KUrl &projectFolder, QUndoGroup
}
m_startPos = infoXml.attribute("position").toInt();
m_zoom = infoXml.attribute("zoom", "7").toInt();
m_zoneEnd = infoXml.attribute("zoneout", "100").toInt();
setProfilePath(profilePath);
......@@ -113,7 +109,6 @@ KdenliveDoc::KdenliveDoc(const KUrl &url, const KUrl &projectFolder, QUndoGroup
westley.removeChild(tracksinfo);
}
QDomElement orig;
QDomNodeList producers = m_document.elementsByTagName("producer");
QDomNodeList infoproducers = m_document.elementsByTagName("kdenlive_producer");
const int max = producers.count();
......@@ -142,7 +137,7 @@ KdenliveDoc::KdenliveDoc(const KUrl &url, const KUrl &projectFolder, QUndoGroup
if (!e.isNull() && prodId != "black" && !prodId.startsWith("slowmotion") && !m_abortLoading) {
e.setTagName("producer");
// Get MLT's original producer properties
QDomElement orig;
for (int j = 0; j < max; j++) {
QDomElement o = producers.item(j).cloneNode().toElement();
QString origId = o.attribute("id").section('_', 0, 0);
......@@ -1262,10 +1257,6 @@ void KdenliveDoc::addClip(QDomElement elem, QString clipId, bool createClipItem)
const QString producerId = clipId.section('_', 0, 0);
DocClipBase *clip = m_clipManager->getClipById(producerId);
if (clip == NULL) {
/*kDebug()<<"// CLIP "<<clipId<<" NOT OFUND in LIST, CREATING";
QDomDocument doc;
doc.appendChild(doc.importNode(elem, true));
kDebug() << "IMPORTED CLIP: \n" << doc.toString()<<"\n";*/
elem.setAttribute("id", producerId);
QString path = elem.attribute("resource");
QString extension;
......@@ -1273,7 +1264,7 @@ void KdenliveDoc::addClip(QDomElement elem, QString clipId, bool createClipItem)
extension = KUrl(path).fileName();
path = KUrl(path).directory();
}
if (!QFile::exists(path) && elem.attribute("type").toInt() == TEXT) {
if (elem.attribute("type").toInt() == TEXT && !QFile::exists(path)) {
kDebug() << "// TITLE: " << elem.attribute("titlename") << " Preview file: " << elem.attribute("resource") << " DOES NOT EXIST";
QString titlename = elem.attribute("titlename");
QString titleresource;
......@@ -1343,6 +1334,7 @@ void KdenliveDoc::addClip(QDomElement elem, QString clipId, bool createClipItem)
clip = new DocClipBase(m_clipManager, elem, producerId);
m_clipManager->addClip(clip);
}
if (createClipItem) {
emit addProjectClip(clip);
qApp->processEvents();
......@@ -1434,7 +1426,7 @@ void KdenliveDoc::addClipInfo(QDomElement elem, QDomElement orig, QString clipId
m = m.nextSibling();
}
if (!meta.isEmpty()) {
clip = m_clipManager->getClipById(clipId);
if (clip == NULL) clip = m_clipManager->getClipById(clipId);
if (clip) clip->setMetadata(meta);
}
}
......
......@@ -56,6 +56,8 @@ ProjectItem::ProjectItem(QTreeWidget * parent, DocClipBase *clip)
setText(1, name);
setText(2, m_clip->description());
if ((m_clip->clipType() == AV || m_clip->clipType() == AUDIO) && KdenliveSettings::audiothumbnails()) m_clip->askForAudioThumbs();
GenTime duration = m_clip->duration();
if (duration != GenTime()) setData(1, DurationRole, Timecode::getEasyTimecode(duration, KdenliveSettings::project_fps()));
//setFlags(Qt::NoItemFlags);
//kDebug() << "Constructed with clipId: " << m_clipId;
}
......@@ -72,6 +74,8 @@ ProjectItem::ProjectItem(QTreeWidgetItem * parent, DocClipBase *clip)
setText(1, name);
setText(2, m_clip->description());
if ((m_clip->clipType() == AV || m_clip->clipType() == AUDIO) && KdenliveSettings::audiothumbnails()) m_clip->askForAudioThumbs();
GenTime duration = m_clip->duration();
if (duration != GenTime()) setData(1, DurationRole, Timecode::getEasyTimecode(duration, KdenliveSettings::project_fps()));
//setFlags(Qt::NoItemFlags);
//kDebug() << "Constructed with clipId: " << m_clipId;
}
......@@ -199,9 +203,7 @@ void ProjectItem::setProperties(const QMap < QString, QString > &attributes, con
if (m_clip == NULL) return;
//setFlags(Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled);
if (attributes.contains("duration")) {
//if (m_clipType == AUDIO || m_clipType == VIDEO || m_clipType == AV)
//m_clip->setProperty("duration", attributes["duration"]);
GenTime duration = GenTime(attributes["duration"].toInt(), KdenliveSettings::project_fps());
GenTime duration = GenTime(attributes.value("duration").toInt(), KdenliveSettings::project_fps());
setData(1, DurationRole, Timecode::getEasyTimecode(duration, KdenliveSettings::project_fps()));
m_clip->setDuration(duration);
//kDebug() << "//// LOADED CLIP, DURATION SET TO: " << duration.frames(KdenliveSettings::project_fps());
......@@ -213,18 +215,13 @@ void ProjectItem::setProperties(const QMap < QString, QString > &attributes, con
//extend attributes -reh
if (m_clipType == UNKNOWN) {
if (attributes.contains("type")) {
if (attributes["type"] == "audio")
m_clipType = AUDIO;
else if (attributes["type"] == "video")
m_clipType = VIDEO;
else if (attributes["type"] == "av")
m_clipType = AV;
else if (attributes["type"] == "playlist")
m_clipType = PLAYLIST;
} else {
m_clipType = AV;
}
QString cliptype = attributes.value("type");
if (cliptype == "audio") m_clipType = AUDIO;
else if (cliptype == "video") m_clipType = VIDEO;
else if (cliptype == "av") m_clipType = AV;
else if (cliptype == "playlist") m_clipType = PLAYLIST;
else m_clipType = AV;
m_clip->setClipType(m_clipType);
slotSetToolTip();
}
......@@ -234,10 +231,10 @@ void ProjectItem::setProperties(const QMap < QString, QString > &attributes, con
if (m_clip->description().isEmpty()) {
if (metadata.contains("description")) {
m_clip->setProperty("description", metadata["description"]);
m_clip->setProperty("description", metadata.value("description"));
setText(2, m_clip->description());
} else if (metadata.contains("comment")) {
m_clip->setProperty("description", metadata["comment"]);
m_clip->setProperty("description", metadata.value("comment"));
setText(2, m_clip->description());
}
}
......
......@@ -356,8 +356,8 @@ void ProjectList::selectItemById(const QString &clipId) {
void ProjectList::slotDeleteClip(const QString &clipId) {
ProjectItem *item = getItemById(clipId);
if (!item) {
kDebug()<<"/// Cannot find clip to delete";
return;
kDebug() << "/// Cannot find clip to delete";
return;
}
delete item;
}
......@@ -517,9 +517,12 @@ void ProjectList::updateAllClips() {
item->setIcon(0, QPixmap(cachedPixmap));
listView->blockSignals(false);
} else requestClipThumbnail(item->clipId());
listView->blockSignals(true);
item->changeDuration(item->referencedClip()->producer()->get_playtime());
listView->blockSignals(false);
if (item->data(1, DurationRole).toString().isEmpty()) {
listView->blockSignals(true);
item->changeDuration(item->referencedClip()->producer()->get_playtime());
listView->blockSignals(false);
}
}
listView->blockSignals(true);
item->setData(1, UsageRole, QString::number(item->numReferences()));
......@@ -595,7 +598,7 @@ void ProjectList::slotAddColorClip() {
}
m_doc->clipManager()->slotAddColorClipFile(dia_ui->clip_name->text(), color, dia_ui->clip_duration->text(), group, groupId);
m_doc->setModified(true);
m_doc->setModified(true);
}
delete dia_ui;
delete dia;
......@@ -622,8 +625,8 @@ void ProjectList::slotAddSlideshowClip() {
groupId = item->clipId();
}
m_doc->clipManager()->slotAddSlideshowClipFile(dia->clipName(), dia->selectedPath(), dia->imageCount(), dia->clipDuration(), dia->loop(), dia->fade(), dia->lumaDuration(), dia->lumaFile(), dia->softness(), group, groupId);
m_doc->setModified(true);
m_doc->clipManager()->slotAddSlideshowClipFile(dia->clipName(), dia->selectedPath(), dia->imageCount(), dia->clipDuration(), dia->loop(), dia->fade(), dia->lumaDuration(), dia->lumaFile(), dia->softness(), group, groupId);
m_doc->setModified(true);
}
delete dia;
}
......
......@@ -463,15 +463,10 @@ void Render::slotSplitView(bool doit) {
}
void Render::getFileProperties(const QDomElement &xml, const QString &clipId, bool replaceProducer) {
int height = 50;
int width = (int)(height * m_mltProfile->dar());
QMap < QString, QString > filePropertyMap;
QMap < QString, QString > metadataPropertyMap;
KUrl url = KUrl(xml.attribute("resource", QString()));
Mlt::Producer *producer = NULL;
if (xml.attribute("type").toInt() == TEXT && !QFile::exists(url.path())) {
emit replyGetFileProperties(clipId, producer, filePropertyMap, metadataPropertyMap, replaceProducer);
emit replyGetFileProperties(clipId, producer, QMap < QString, QString >(), QMap < QString, QString >(), replaceProducer);
return;
}
if (xml.attribute("type").toInt() == COLOR) {
......@@ -489,35 +484,9 @@ void Render::getFileProperties(const QDomElement &xml, const QString &clipId, bo
producer = new Mlt::Producer(*m_mltProfile, "westley-xml", tmp);
delete[] tmp;
} else {
QString urlpath = url.path();
/*if (urlpath.contains(':')) {
if (!urlpath.startsWith("file:")) urlpath.prepend("file:");
char *tmp = decodedString(urlpath);
producer = new Mlt::Producer(*m_mltProfile, "avformat", tmp);
delete[] tmp;
}
else {*/
char *tmp = decodedString(urlpath);
char *tmp = decodedString(url.path());
producer = new Mlt::Producer(*m_mltProfile, tmp);
delete[] tmp;
if (xml.hasAttribute("force_aspect_ratio")) {
double aspect = xml.attribute("force_aspect_ratio").toDouble();
if (aspect > 0) producer->set("force_aspect_ratio", aspect);
}
if (xml.hasAttribute("threads")) {
int threads = xml.attribute("threads").toInt();
if (threads != 1) producer->set("threads", threads);
}
if (xml.hasAttribute("video_index")) {
int vindex = xml.attribute("video_index").toInt();
if (vindex != 0) producer->set("video_index", vindex);
}
if (xml.hasAttribute("audio_index")) {
int aindex = xml.attribute("audio_index").toInt();
if (aindex != 0) producer->set("audio_index", aindex);
}
//}
}
if (producer == NULL || producer->is_blank() || !producer->is_valid()) {
......@@ -526,11 +495,34 @@ void Render::getFileProperties(const QDomElement &xml, const QString &clipId, bo
return;
}
if (xml.hasAttribute("force_aspect_ratio")) {
double aspect = xml.attribute("force_aspect_ratio").toDouble();
if (aspect > 0) producer->set("force_aspect_ratio", aspect);
}
if (xml.hasAttribute("threads")) {
int threads = xml.attribute("threads").toInt();
if (threads != 1) producer->set("threads", threads);
}
if (xml.hasAttribute("video_index")) {
int vindex = xml.attribute("video_index").toInt();
if (vindex != 0) producer->set("video_index", vindex);
}
if (xml.hasAttribute("audio_index")) {
int aindex = xml.attribute("audio_index").toInt();
if (aindex != 0) producer->set("audio_index", aindex);
}
if (xml.hasAttribute("out")) producer->set_in_and_out(xml.attribute("in").toInt(), xml.attribute("out").toInt());
char *tmp = decodedString(clipId);
producer->set("id", tmp);
delete[] tmp;
int height = 50;
int width = (int)(height * m_mltProfile->dar());
QMap < QString, QString > filePropertyMap;
QMap < QString, QString > metadataPropertyMap;
int frameNumber = xml.attribute("thumbnail", "0").toInt();
if (frameNumber != 0) producer->seek(frameNumber);
......@@ -2786,7 +2778,7 @@ void Render::fillSlowMotionProducers() {
QString id = nprod->get("id");
if (id.startsWith("slowmotion:")) {
// this is a slowmotion producer, add it to the list
QString url = QString::fromUtf8(nprod->get("resource"));
QString url = QString::fromUtf8(nprod->get("resource"));
if (!m_slowmotionProducers.contains(url)) {
m_slowmotionProducers.insert(url, nprod);
}
......
......@@ -859,7 +859,7 @@ void RenderWidget::parseProfiles(QString meta, QString group, QString profile) {
// can also override profiles installed by KNewStuff
fileList.removeAll("customprofiles.xml");
foreach(const QString &filename, fileList)
parseFile(exportFolder + '/' + filename, true);
parseFile(exportFolder + '/' + filename, true);
if (QFile::exists(exportFolder + "/customprofiles.xml")) parseFile(exportFolder + "/customprofiles.xml", true);
if (!meta.isEmpty()) {
......
......@@ -104,8 +104,8 @@ void SlideshowClip::parseFolder() {
QStringList filters;
QString filter = m_view.image_type->itemData(m_view.image_type->currentIndex()).toString();
filters << "*." + filter;
// TODO: improve jpeg image detection with extension like jpeg, requires change in MLT image producers
// << "*.jpeg";
// TODO: improve jpeg image detection with extension like jpeg, requires change in MLT image producers
// << "*.jpeg";
dir.setNameFilters(filters);
const QStringList result = dir.entryList(QDir::Files);
......
......@@ -31,7 +31,7 @@ public:
enum Formats { HH_MM_SS_FF, HH_MM_SS_HH, Frames, Seconds };
explicit Timecode(Formats format = HH_MM_SS_FF, int framesPerSecond =
25, bool dropFrame = false);
25, bool dropFrame = false);
/** Set the current timecode format; this is the output format for this timecode. */
void setFormat(int framesPerSecond, bool dropFrame = false, Formats format = HH_MM_SS_FF) {
......
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