QList < CommentedTime >::Iterator it = markers.begin();
GenTime pos;
double framepos;
- QBrush markerBrush(QColor(120, 120, 0, 140));
+ QBrush markerBrush(QColor(120, 120, 0, 140));
QPen pen = painter->pen();
- pen.setColor(QColor(255, 255, 255, 200));
- pen.setStyle(Qt::DotLine);
for (; it != markers.end(); ++it) {
pos = GenTime((int)((*it).time().frames(m_fps) / qAbs(m_speed) + 0.5), m_fps) - cropStart();
if (pos > cropDuration()) break;
QLineF l(rect().x() + pos.frames(m_fps), rect().y(), rect().x() + pos.frames(m_fps), rect().bottom());
QLineF l2 = painter->worldTransform().map(l);
+ pen.setColor(CommentedTime::markerColor((*it).markerType()));
+ pen.setStyle(Qt::DotLine);
painter->setPen(pen);
painter->drawLine(l2);
if (KdenliveSettings::showmarkers()) {
const QRectF r2 = painter->worldTransform().mapRect(r1);
const QRectF txtBounding3 = painter->boundingRect(r2, Qt::AlignLeft | Qt::AlignTop, ' ' + (*it).comment() + ' ');
painter->setBrush(markerBrush);
- painter->setPen(Qt::NoPen);
- painter->drawRoundedRect(txtBounding3, 3, 3);
- painter->setBrush(QBrush(Qt::NoBrush));
+ pen.setStyle(Qt::SolidLine);
+ painter->setPen(pen);
+ painter->drawRect(txtBounding3);
+ painter->setBrush(Qt::NoBrush);
painter->setPen(Qt::white);
painter->drawText(txtBounding3, Qt::AlignCenter, (*it).comment());
}
pos = GenTime((int)(markers.at(i).time().frames(m_fps) / qAbs(m_speed) + 0.5), m_fps) - cropStart();
if (pos > GenTime()) {
if (pos > cropDuration()) break;
- else snaps.append(CommentedTime(pos + startPos(), markers.at(i).comment()));
+ else snaps.append(CommentedTime(pos + startPos(), markers.at(i).comment(), markers.at(i).markerType()));
}
}
return snaps;
for (int count = 0; count < marks.count(); ++count) {
QString time = m_tc.getTimecode(marks[count].time());
QStringList itemtext;
- itemtext << time << marks[count].comment();
- (void) new QTreeWidgetItem(m_view.markers_list, itemtext);
+ itemtext << time << marks.at(count).comment();
+ QTreeWidgetItem *item = new QTreeWidgetItem(m_view.markers_list, itemtext);
+ item->setData(0, Qt::DecorationRole, CommentedTime::markerColor(marks.at(count).markerType()));
}
}
QPointer<MarkerDialog> d = new MarkerDialog(m_clip, marker,
m_tc, i18n("Add Marker"), this);
if (d->exec() == QDialog::Accepted) {
- emit addMarker(m_clip->getId(), d->newMarker().time(), d->newMarker().comment());
+ emit addMarker(m_clip->getId(), d->newMarker());
}
delete d;
}
if (pos < 0 || pos > marks.count() - 1) return;
MarkerDialog d(m_clip, marks.at(pos), m_tc, i18n("Edit Marker"), this);
if (d.exec() == QDialog::Accepted) {
- emit addMarker(m_clip->getId(), d.newMarker().time(), d.newMarker().comment());
+ emit addMarker(m_clip->getId(), d.newMarker());
}
}
QList < CommentedTime > marks = m_clip->commentedSnapMarkers();
int pos = m_view.markers_list->currentIndex().row();
if (pos < 0 || pos > marks.count() - 1) return;
- emit addMarker(m_clip->getId(), marks.at(pos).time(), QString());
+ CommentedTime marker = marks.at(pos);
+ marker.setMarkerType(-1);
+ emit addMarker(m_clip->getId(), marker);
}
const QString &ClipProperties::clipId() const
QFrame* m_proxyContainer;
signals:
- void addMarker(const QString &, GenTime, QString);
+ void addMarker(const QString &, CommentedTime);
void deleteProxy(const QString);
void applyNewClipProperties(const QString, QMap <QString, QString> , QMap <QString, QString> , bool, bool);
void saveMarkers(const QString &);
#include <KLocale>
-AddMarkerCommand::AddMarkerCommand(CustomTrackView *view, const QString &oldcomment, const QString &comment, const QString &id, const GenTime &pos, QUndoCommand * parent) :
+AddMarkerCommand::AddMarkerCommand(CustomTrackView *view, const CommentedTime oldMarker, const CommentedTime newMarker, const QString &id, QUndoCommand * parent) :
QUndoCommand(parent),
m_view(view),
- m_oldcomment(oldcomment),
- m_comment(comment),
- m_id(id),
- m_pos(pos)
+ m_oldMarker(oldMarker),
+ m_newMarker(newMarker),
+ m_id(id)
{
- if (m_comment.isEmpty()) setText(i18n("Delete marker"));
- else if (m_oldcomment.isEmpty()) setText(i18n("Add marker"));
+ if (m_newMarker.markerType() < 0) setText(i18n("Delete marker"));
+ else if (m_oldMarker.comment().isEmpty()) setText(i18n("Add marker"));
else setText(i18n("Edit marker"));
}
// virtual
void AddMarkerCommand::undo()
{
- m_view->addMarker(m_id, m_pos, m_oldcomment);
+ m_view->addMarker(m_id, m_oldMarker);
}
// virtual
void AddMarkerCommand::redo()
{
- m_view->addMarker(m_id, m_pos, m_comment);
+ m_view->addMarker(m_id, m_newMarker);
}
class AddMarkerCommand : public QUndoCommand
{
public:
- AddMarkerCommand(CustomTrackView *view, const QString &oldcomment, const QString &comment, const QString &id, const GenTime &pos, QUndoCommand * parent = 0);
+ AddMarkerCommand(CustomTrackView *view, const CommentedTime oldMarker, const CommentedTime newMarker, const QString &id, QUndoCommand * parent = 0);
virtual void undo();
virtual void redo();
private:
CustomTrackView *m_view;
- QString m_oldcomment;
- QString m_comment;
+ CommentedTime m_oldMarker;
+ CommentedTime m_newMarker;
QString m_id;
- GenTime m_pos;
};
#endif
}
}
-void CustomTrackView::slotAddClipMarker(const QString &id, GenTime t, QString c, QUndoCommand *groupCommand)
+void CustomTrackView::slotAddClipMarker(const QString &id, CommentedTime newMarker, QUndoCommand *groupCommand)
{
- QString oldcomment = m_document->clipManager()->getClipById(id)->markerComment(t);
- AddMarkerCommand *command = new AddMarkerCommand(this, oldcomment, c, id, t, groupCommand);
+ CommentedTime oldMarker = m_document->clipManager()->getClipById(id)->markerAt(newMarker.time());
+ if (oldMarker == CommentedTime()) {
+ oldMarker = newMarker;
+ oldMarker.setMarkerType(-1);
+ }
+ AddMarkerCommand *command = new AddMarkerCommand(this, oldMarker, newMarker, id, groupCommand);
if (!groupCommand) m_commandStack->push(command);
}
void CustomTrackView::slotDeleteClipMarker(const QString &comment, const QString &id, const GenTime &position)
{
- AddMarkerCommand *command = new AddMarkerCommand(this, comment, QString(), id, position);
+ CommentedTime oldmarker(position, comment);
+ CommentedTime marker = oldmarker;
+ marker.setMarkerType(-1);
+ AddMarkerCommand *command = new AddMarkerCommand(this, oldmarker, marker, id);
m_commandStack->push(command);
}
deleteMarkers->setText("Delete clip markers");
for (int i = 0; i < markers.size(); i++) {
- new AddMarkerCommand(this, markers.at(i).comment(), QString(), id, markers.at(i).time(), deleteMarkers);
+ CommentedTime oldMarker = markers.at(i);
+ CommentedTime marker = oldMarker;
+ marker.setMarkerType(-1);
+ new AddMarkerCommand(this, oldMarker, marker, id, deleteMarkers);
}
m_commandStack->push(deleteMarkers);
}
}
if (!markerText.isEmpty()) {
// Marker found, add it
- slotAddClipMarker(id, GenTime(time1), markerText, command);
- if (time2 > 0 && time2 != time1) slotAddClipMarker(id, GenTime(time2), markerText, command);
+ //TODO: allow user to set a marker category
+ CommentedTime marker1(GenTime(time1), markerText);
+ slotAddClipMarker(id, marker1, command);
+ if (time2 > 0 && time2 != time1) {
+ CommentedTime marker2(GenTime(time2), markerText);
+ slotAddClipMarker(id, marker2, command);
+ }
}
}
if (command->childCount() > 0) m_commandStack->push(command);
else delete command;
}
-void CustomTrackView::addMarker(const QString &id, const GenTime &pos, const QString &comment)
+void CustomTrackView::addMarker(const QString &id, const CommentedTime marker)
{
DocClipBase *base = m_document->clipManager()->getClipById(id);
- if (!comment.isEmpty()) base->addSnapMarker(pos, comment);
- else base->deleteSnapMarker(pos);
+ if (marker.markerType() < 0) base->deleteSnapMarker(marker.time());
+ else base->addSnapMarker(marker);
emit updateClipMarkers(base);
setDocumentModified();
viewport()->update();
void deleteClip(ItemInfo info, bool refresh = true);
void slotDeleteClipMarker(const QString &comment, const QString &id, const GenTime &position);
void slotDeleteAllClipMarkers(const QString &id);
- void addMarker(const QString &id, const GenTime &pos, const QString &comment);
+ void addMarker(const QString &id, const CommentedTime marker);
void setScale(double scaleFactor, double verticalScale);
void deleteClip(const QString &clipId);
/** @brief Add effect to current clip */
* @param id Id of the marker's clip
* @param t Position of the marker
* @param c Comment of the marker */
- void slotAddClipMarker(const QString &id, GenTime t, QString c, QUndoCommand *groupCommand = 0);
+ void slotAddClipMarker(const QString &id, CommentedTime newMarker, QUndoCommand *groupCommand = 0);
void slotLoadClipMarkers(const QString &id);
void slotSaveClipMarkers(const QString &id);
bool addGuide(const GenTime &pos, const QString &comment);
class CommentedTime
{
public:
- CommentedTime(): t(GenTime(0)) {}
- CommentedTime(const GenTime &time, QString comment)
- : t(time), c(comment) { }
+ CommentedTime(): t(GenTime(0)), type(0) {}
+ CommentedTime(const GenTime &time, QString comment, int markerType = 0)
+ : t(time), c(comment), type(markerType) { }
QString comment() const {
return (c.isEmpty() ? i18n("Marker") : c);
void setComment(QString comm) {
c = comm;
}
+ void setMarkerType(int t) {
+ type = t;
+ }
+ int markerType() const {
+ return type;
+ }
+ static QColor markerColor(int type) {
+ switch (type) {
+ case 0:
+ return Qt::red;
+ break;
+ case 1:
+ return Qt::blue;
+ break;
+ case 2:
+ return Qt::green;
+ break;
+ case 3:
+ return Qt::yellow;
+ break;
+ default:
+ return Qt::cyan;
+ break;
+ }
+ };
/* Implementation of > operator; Works identically as with basic types. */
bool operator>(CommentedTime op) const {
private:
GenTime t;
QString c;
+ int type;
+
};
}
-void DocClipBase::addSnapMarker(const GenTime & time, QString comment)
+void DocClipBase::addSnapMarker(const CommentedTime marker)
{
QList < CommentedTime >::Iterator it = m_snapMarkers.begin();
for (it = m_snapMarkers.begin(); it != m_snapMarkers.end(); ++it) {
- if ((*it).time() >= time)
+ if ((*it).time() >= marker.time())
break;
}
- if ((it != m_snapMarkers.end()) && ((*it).time() == time)) {
- (*it).setComment(comment);
+ if ((it != m_snapMarkers.end()) && ((*it).time() == marker.time())) {
+ (*it).setComment(marker.comment());
+ (*it).setMarkerType(marker.markerType());
//kError() << "trying to add Snap Marker that already exists, this will cause inconsistancies with undo/redo";
} else {
- CommentedTime t(time, comment);
- m_snapMarkers.insert(it, t);
+ m_snapMarkers.insert(it, marker);
}
-
}
void DocClipBase::editSnapMarker(const GenTime & time, QString comment)
return duration();
}
-QString DocClipBase::markerComment(GenTime t)
+QString DocClipBase::markerComment(GenTime t) const
{
- QList < CommentedTime >::Iterator itt = m_snapMarkers.begin();
-
+ QList < CommentedTime >::ConstIterator itt = m_snapMarkers.begin();
while (itt != m_snapMarkers.end()) {
if ((*itt).time() == t)
return (*itt).comment();
return QString();
}
+CommentedTime DocClipBase::markerAt(GenTime t) const
+{
+ QList < CommentedTime >::ConstIterator itt = m_snapMarkers.begin();
+ while (itt != m_snapMarkers.end()) {
+ if ((*itt).time() == t)
+ return (*itt);
+ ++itt;
+ }
+ return CommentedTime();
+}
+
void DocClipBase::clearThumbProducer()
{
if (m_thumbProd) m_thumbProd->clearProducer();
GenTime hasSnapMarkers(const GenTime & time);
QString deleteSnapMarker(const GenTime & time);
void editSnapMarker(const GenTime & time, QString comment);
- void addSnapMarker(const GenTime & time, QString comment);
+ void addSnapMarker(const CommentedTime marker);
QList < GenTime > snapMarkers() const;
- QString markerComment(GenTime t);
+ QString markerComment(GenTime t) const;
+ CommentedTime markerAt(GenTime t) const;
void setClipThumbFrame(const uint &ix);
uint getClipThumbFrame() const;
void setProperties(QMap <QString, QString> properties);
int maxchild = markerslist.count();
for (int k = 0; k < maxchild; k++) {
e = markerslist.at(k).toElement();
- if (e.tagName() == "marker")
- m_clipManager->getClipById(e.attribute("id"))->addSnapMarker(GenTime(e.attribute("time").toDouble()), e.attribute("comment"));
+ if (e.tagName() == "marker") {
+ CommentedTime marker(GenTime(e.attribute("time").toDouble()), e.attribute("comment"), e.attribute("type").toInt());
+ m_clipManager->getClipById(e.attribute("id"))->addSnapMarker(marker);
+ }
}
infoXml.removeChild(markers);
}
marker.setAttribute("time", marks.at(j).time().ms() / 1000);
marker.setAttribute("comment", marks.at(j).comment());
marker.setAttribute("id", e.attribute("id"));
+ marker.setAttribute("type", marks.at(j).markerType());
markers.appendChild(marker);
}
}
QPointer<MarkerDialog> d = new MarkerDialog(clip, marker,
m_activeDocument->timecode(), i18n("Add Marker"), this);
if (d->exec() == QDialog::Accepted)
- m_activeTimeline->projectView()->slotAddClipMarker(id, d->newMarker().time(), d->newMarker().comment());
+ m_activeTimeline->projectView()->slotAddClipMarker(id, d->newMarker());
delete d;
}
}
QString id = clip->getId();
- QString oldcomment = clip->markerComment(pos);
- if (oldcomment.isEmpty()) {
+ CommentedTime oldMarker = clip->markerAt(pos);
+ if (oldMarker == CommentedTime()) {
m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
return;
}
- CommentedTime marker(pos, oldcomment);
- QPointer<MarkerDialog> d = new MarkerDialog(clip, marker,
+ QPointer<MarkerDialog> d = new MarkerDialog(clip, oldMarker,
m_activeDocument->timecode(), i18n("Edit Marker"), this);
if (d->exec() == QDialog::Accepted) {
- m_activeTimeline->projectView()->slotAddClipMarker(id, d->newMarker().time(), d->newMarker().comment());
+ m_activeTimeline->projectView()->slotAddClipMarker(id, d->newMarker());
if (d->newMarker().time() != pos) {
// remove old marker
- m_activeTimeline->projectView()->slotAddClipMarker(id, pos, QString());
+ oldMarker.setMarkerType(-1);
+ m_activeTimeline->projectView()->slotAddClipMarker(id, oldMarker);
}
}
delete d;
m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
return;
}
-
- m_activeTimeline->projectView()->slotAddClipMarker(clip->getId(), pos, m_activeDocument->timecode().getDisplayTimecode(pos, false));
+ //TODO: allow user to set default marker category
+ CommentedTime marker(pos, m_activeDocument->timecode().getDisplayTimecode(pos, false));
+ m_activeTimeline->projectView()->slotAddClipMarker(clip->getId(), marker);
} else {
m_activeTimeline->projectView()->slotAddGuide(false);
}
// any type of clip but a title
ClipProperties *dia = new ClipProperties(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
- connect(dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
+ connect(dia, SIGNAL(addMarker(const QString &, CommentedTime)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, CommentedTime)));
connect(m_activeTimeline->projectView(), SIGNAL(updateClipMarkers(DocClipBase *)), dia, SLOT(slotFillMarkersList(DocClipBase *)));
connect(dia, SIGNAL(loadMarkers(const QString &)), m_activeTimeline->projectView(), SLOT(slotLoadClipMarkers(const QString &)));
connect(dia, SIGNAL(saveMarkers(const QString &)), m_activeTimeline->projectView(), SLOT(slotSaveClipMarkers(const QString &)));
setupUi(this);
setWindowTitle(caption);
+ // Set up categories
+ for (int i = 0; i < 5; ++i) {
+ marker_type->insertItem(i, i18n("Category %1", i));
+ marker_type->setItemData(i, CommentedTime::markerColor(i), Qt::DecorationRole);
+ }
+ marker_type->setCurrentIndex(t.markerType());
+
m_in = new TimecodeDisplay(tc, this);
inputLayout->addWidget(m_in);
m_in->setValue(t.time());
CommentedTime MarkerDialog::newMarker()
{
- return CommentedTime(m_in->gentime(), marker_comment->text());
+ return CommentedTime(m_in->gentime(), marker_comment->text(), marker_type->currentIndex());
}
#include "markerdialog.moc"
bool Monitor::createOpenGlWidget(QWidget *parent, const QString profile)
{
render = new Render(id(), 0, profile, this);
+ kDebug()<<"+++++++++++++\nCREATED OPENGL WIDG\n++++++++++++++";
m_glWidget = new VideoGLWidget(parent);
if (m_glWidget == NULL) {
// Creation failed, we are in trouble...
QAction *go = m_markerMenu->addAction(position);
go->setData(pos);
}
- m_ruler->setMarkers(marks);
- } else m_ruler->setMarkers(QList <int>());
+ }
+ m_ruler->setMarkers(markers);
m_markerMenu->setEnabled(!m_markerMenu->isEmpty());
}
}
// Producer params
jobParams << QString();
// Filter params, use a smaller region of the image to speed up operation
- jobParams << filterName << "bounding=\"25%x25%:25%x25\" _scene_cuts=0";
+ jobParams << filterName << "bounding=\"25%x25%:25%x25\" shot_change_list=0";
// Consumer
jobParams << "null" << "all=1 terminate_on_pause=1 real_time=-1";
// Keys
- jobParams << "_scene_cuts";
+ jobParams << "shot_change_list";
QStringList extraParams;
extraParams << "projecttreefilter" << "project_profile";
processClipJob(ids, QString(), false, jobParams, i18n("Auto split"), extraParams);
{
if (filter == "motion_est") {
// Autosplit filter, add sub zones
- QStringList cuts = results.value("_scene_cuts").split(':', QString::SkipEmptyParts);
+ QStringList cuts = results.value("shot_change_list").split(';', QString::SkipEmptyParts);
int cutPos = 0;
QUndoCommand *command = new QUndoCommand();
command->setText(i18n("Auto Split Clip"));
- foreach (const QString &pos, cuts) {
- int newPos = pos.toInt();
+ foreach (QString pos, cuts) {
+ if (!pos.contains("=")) continue;
+ int newPos = pos.section("=", 0, 0).toInt();
// Don't use scenes shorter than 1 second
if (newPos - cutPos < 24) continue;
(void) new AddClipCutCommand(this, id, cutPos, newPos, QString(), true, false, command);
updatePixmap();
}
-void SmallRuler::setMarkers(QList < int > list)
+void SmallRuler::setMarkers(QList < CommentedTime > list)
{
m_markers = list;
updatePixmap();
}
// draw markers
if (!m_markers.isEmpty()) {
- p.setPen(Qt::red);
for (int i = 0; i < m_markers.count(); i++) {
- p.drawLine(m_markers.at(i) * m_scale, 0, m_markers.at(i) * m_scale, 9);
+ int pos = m_markers.at(i).time().frames(m_manager->timecode().fps()) * m_scale;
+ p.setPen(CommentedTime::markerColor(m_markers.at(i).markerType()));
+ p.drawLine(pos, 0, pos, 9);
}
}
p.end();
void setZoneStart();
void setZoneEnd();
QPoint zone();
- void setMarkers(QList < int > list);
+ void setMarkers(QList < CommentedTime > list);
void updatePalette();
void refreshRuler();
int m_zoneStart;
int m_zoneEnd;
KStatefulBrush m_zoneBrush;
- QList <int> m_markers;
+ QList <CommentedTime> m_markers;
QPixmap m_pixmap;
MonitorManager *m_manager;
Render *m_render;
<rect>
<x>0</x>
<y>0</y>
- <width>312</width>
- <height>88</height>
+ <width>376</width>
+ <height>124</height>
</rect>
</property>
<property name="windowTitle">
<string>Marker</string>
</property>
<layout class="QGridLayout" name="gridLayout">
- <item row="2" column="1" colspan="3">
- <spacer name="verticalSpacer">
+ <item row="0" column="1">
+ <widget class="QLabel" name="clip_filesize_2">
+ <property name="text">
+ <string>Position</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="3">
+ <spacer name="horizontalSpacer">
<property name="orientation">
- <enum>Qt::Vertical</enum>
+ <enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
- <width>218</width>
- <height>2</height>
+ <width>40</width>
+ <height>20</height>
</size>
</property>
</spacer>
</item>
- <item row="0" column="2">
- <layout class="QHBoxLayout" name="inputLayout"/>
- </item>
- <item row="3" column="0" colspan="4">
+ <item row="6" column="0" colspan="4">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
+ <item row="0" column="2">
+ <layout class="QHBoxLayout" name="inputLayout"/>
+ </item>
+ <item row="1" column="2" colspan="2">
+ <widget class="KLineEdit" name="marker_comment"/>
+ </item>
<item row="1" column="1">
<widget class="QLabel" name="clip_filesize_3">
<property name="text">
</property>
</widget>
</item>
- <item row="0" column="0" rowspan="3">
+ <item row="5" column="2">
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>218</width>
+ <height>2</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="4" column="1">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Category</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0" rowspan="5">
<widget class="QLabel" name="clip_thumb">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
</widget>
</item>
- <item row="1" column="2" colspan="2">
- <widget class="KLineEdit" name="marker_comment"/>
- </item>
- <item row="0" column="1">
- <widget class="QLabel" name="clip_filesize_2">
- <property name="text">
- <string>Position</string>
- </property>
- </widget>
- </item>
- <item row="0" column="3">
- <spacer name="horizontalSpacer">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
+ <item row="4" column="2">
+ <widget class="QComboBox" name="marker_type"/>
</item>
</layout>
</widget>