Fix clip count & duration on document opening

svn path=/branches/KDE4/; revision=2287
parent 2f6cac53
......@@ -776,7 +776,7 @@ void ClipItem::checkEffectsKeyframesPos(const int previous, const int current, b
}
}
}
setSelectedEffect(m_selectedEffect);
if (m_selectedEffect >= 0) setSelectedEffect(m_selectedEffect);
}
......
......@@ -735,21 +735,32 @@ void CustomTrackView::cutClip(ItemInfo info, GenTime cutTime, bool cut) {
if (cut) {
// cut clip
ClipItem *item = getClipItemAt((int) info.startPos.frames(m_document->fps()), info.track);
if (!item) {
emit displayMessage(i18n("Cannot find clip to cut"), ErrorMessage);
return;
}
int cutPos = (int) cutTime.frames(m_document->fps());
ItemInfo newPos;
newPos.startPos = cutTime;
newPos.endPos = info.endPos;
newPos.track = info.track;
ClipItem *dup = new ClipItem(item->baseClip(), newPos, item->cropStart(), m_scale, m_document->fps());
dup->setCropStart(dup->cropStart() + (cutTime - info.startPos));
item->resizeEnd(cutPos, m_scale);
ClipItem *dup = new ClipItem(item->baseClip(), newPos, item->cropStart() + (cutTime - info.startPos), m_scale, m_document->fps());
scene()->addItem(dup);
m_document->renderer()->mltCutClip(m_tracksList.count() - info.track, cutTime);
item->baseClip()->addReference();
m_document->updateClip(item->baseClip()->getId());
} else {
// uncut clip
ClipItem *item = getClipItemAt((int) info.startPos.frames(m_document->fps()), info.track);
ClipItem *dup = getClipItemAt((int) cutTime.frames(m_document->fps()), info.track);
if (!item || !dup) {
emit displayMessage(i18n("Cannot find clip to uncut"), ErrorMessage);
return;
}
delete dup;
item->baseClip()->removeReference();
m_document->updateClip(item->baseClip()->getId());
item->resizeEnd((int) info.endPos.frames(m_document->fps()), m_scale);
m_document->renderer()->mltRemoveClip(m_tracksList.count() - info.track, cutTime);
m_document->renderer()->mltResizeClipEnd(m_tracksList.count() - info.track, info.startPos, item->cropStart(), item->cropStart() + info.endPos - info.startPos);
......
......@@ -38,7 +38,9 @@ DocClipBase::DocClipBase(ClipManager *clipManager, QDomElement xml, uint id):
int out = xml.attribute("out").toInt();
if (out != 0) {
setDuration(GenTime(out, KdenliveSettings::project_fps()));
//m_properties.insert("out", QString::number(out));
} else {
out = xml.attribute("duration").toInt();
if (out != 0) setDuration(GenTime(out, KdenliveSettings::project_fps()));
}
if (m_name.isEmpty()) m_name = url.fileName();
......
......@@ -401,6 +401,12 @@ void KdenliveDoc::updateClip(int id) {
emit updateClipDisplay(id);
}
void KdenliveDoc::updateAllProjectClips() {
QList <DocClipBase*> list = m_clipManager->documentClipList();
for (int i = 0; i < list.count(); i++)
emit updateClipDisplay(list.at(i)->getId());
}
int KdenliveDoc::getFramePos(QString duration) {
return m_timecode.getFrameCount(duration, m_fps);
}
......
......@@ -95,6 +95,8 @@ Q_OBJECT public:
KUrl projectFolder() const;
/** Used to inform main app of the current document loading progress */
void loadingProgressed();
void updateAllProjectClips();
private:
KUrl m_url;
QDomDocument m_document;
......
......@@ -943,6 +943,9 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) { //cha
m_monitorManager->setTimecode(doc->timecode());
doc->setRenderer(m_projectMonitor->render);
m_commandStack->setActiveStack(doc->commandStack());
doc->updateAllProjectClips();
if (m_commandStack->isClean()) kDebug() << "//////////// UNDO STACK IS CLEAN";
else kDebug() << "//////////// UNDO STACK IS NOT CLEAN*******************";
......
......@@ -60,7 +60,6 @@ public:
extendItem(w,
}
*/
void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const {
if (index.column() == 1) {
const bool hover = option.state & (QStyle::State_Selected);
......@@ -73,7 +72,6 @@ public:
painter->fillRect(r1, QBrush(backgroundColor));
}
QFont font = painter->font();
font.setPointSize(font.pointSize());
font.setBold(true);
painter->setFont(font);
int mid = (int)((r1.height() / 2));
......@@ -87,6 +85,7 @@ public:
QString subText = index.data(DurationRole).toString();
int usage = index.data(UsageRole).toInt();
if (usage != 0) subText.append(QString(" (%1)").arg(usage));
painter->setPen(option.palette.color(QPalette::Mid));
painter->drawText(r2, Qt::AlignLeft | Qt::AlignVCenter , subText);
painter->restore();
} else {
......
......@@ -347,6 +347,7 @@ int TrackView::slotAddProjectTrack(int ix, QDomElement xml, bool videotrack) {
//kDebug() << "// INSERTING CLIP: " << in << "x" << out << ", track: " << ix << ", ID: " << id << ", SCALE: " << m_scale << ", FPS: " << m_doc->fps();
ClipItem *item = new ClipItem(clip, clipinfo, GenTime(in, m_doc->fps()), m_scale, m_doc->fps());
m_scene->addItem(item);
clip->addReference();
position += (out - in);
// parse clip effects
......
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