]> git.sesse.net Git - kdenlive/blob - src/documenttrack.cpp
Start porting timeline to QGraphicsView
[kdenlive] / src / documenttrack.cpp
1
2 #include <QMouseEvent>
3 #include <QStylePainter>
4
5 #include <KDebug>
6 #include <QFrame>
7 #include <QWidget>
8 #include <QPainter>
9
10
11 #include "documenttrack.h"
12
13 DocumentTrack::DocumentTrack(QDomElement xml, TrackView * view, QWidget *parent)
14     : QWidget(parent), m_xml(xml), m_trackDuration(0)
15 {
16   setFixedHeight(50);
17   addFunctionDecorator("move", "move");
18   parseXml();
19 }
20
21 int DocumentTrack::documentTrackIndex()
22 {
23   return 0;
24 }
25
26 TrackViewClip *DocumentTrack::getClipAt(GenTime pos)
27 {
28   return 0;
29 }
30
31 void DocumentTrack::addFunctionDecorator(const QString & mode, const QString & function) 
32 {
33   m_trackPanelFunctions[mode].append(function);
34 }
35
36 QStringList DocumentTrack::applicableFunctions(const QString & mode) 
37 {
38   return m_trackPanelFunctions[mode];
39 }
40
41 void DocumentTrack::parseXml()
42 {
43   m_clipList.clear();
44   int position = 0;
45   for(QDomNode n = m_xml.firstChild(); !n.isNull(); n = n.nextSibling())
46   {
47     QDomElement elem = n.toElement();
48    if (elem.tagName() == "blank") {
49     position += elem.attribute("length", 0).toInt();
50    }
51    else if (elem.tagName() == "entry") {
52     TrackViewClip clip;
53     clip.startTime = position;
54     int in = elem.attribute("in", 0).toInt();
55     int out = elem.attribute("out", 0).toInt() - in;
56     clip.cropTime = in;
57     clip.duration = out;
58     position += out;
59     clip.producer = elem.attribute("producer", QString::null);
60     kDebug()<<"++++++++++++++\n\n / / /ADDING CLIP: "<<clip.cropTime<<", out: "<<clip.duration<<", Producer: "<<clip.producer<<"\n\n++++++++++++++++++++";
61     m_clipList.append(clip);
62    }
63   }
64   m_trackDuration = position;
65 }
66
67 int DocumentTrack::duration()
68 {
69   return m_trackDuration;
70 }
71
72 QList <TrackViewClip> DocumentTrack::clipList()
73 {
74   return m_clipList;
75 }
76
77 // virtual
78 /*
79 void DocumentTrack::paintEvent(QPaintEvent *e )
80 {
81     QRect region = e->rect();
82     region.setBottomRight(QPoint(region.right() - 1, region.bottom() - 1));
83     QPainter painter(this);
84     painter.fillRect(region, QBrush(Qt::red));
85     painter.drawLine(region.bottomLeft (), region.bottomRight ());
86 }
87 */
88
89 #include "documenttrack.moc"