1 /***************************************************************************
2 * Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
22 * @brief Manages the timline
23 * @author Jean-Baptiste Mardelle
29 #include <QScrollArea>
31 #include <QGraphicsScene>
32 #include <QGraphicsLineItem>
33 #include <QDomElement>
37 #include "customtrackscene.h"
38 #include "effectslist.h"
39 #include "ui_timeline_ui.h"
40 #include "definitions.h"
44 class CustomTrackView;
49 class TrackView : public QWidget, public Ui::TimeLine_UI
54 explicit TrackView(KdenliveDoc *doc, bool *ok, QWidget *parent = 0);
55 virtual ~ TrackView();
56 void setEditMode(const QString & editMode);
57 const QString & editMode() const;
58 QGraphicsScene *projectScene();
59 CustomTrackView *projectView();
61 int tracksNumber() const;
62 KdenliveDoc *document();
64 void updateProjectFps();
69 /** @brief Updates (redraws) the ruler.
71 * Used to change from displaying frames to timecode or vice versa. */
74 /** @brief Parse tracks to see if project has audio in it.
76 * Parses all tracks to check if there is audio data. */
77 bool checkProjectAudio() const;
80 virtual void keyPressEvent(QKeyEvent * event);
83 void slotDeleteClip(const QString &clipId);
84 void slotChangeZoom(int horizontal, int vertical = -1);
85 void setDuration(int dur);
86 void slotSetZone(QPoint p, bool updateDocumentProperties = true);
87 /** @brief Save a snapshot image of current timeline view */
88 void slotSaveTimelinePreview(const QString path);
91 CustomTrackView *m_trackview;
92 QList <QString> m_invalidProducers;
96 CustomTrackScene *m_scene;
97 /** @brief A list of producer ids to be replaced when opening a corrupted document*/
98 QMap <QString, QString> m_replacementProducerIds;
102 QString m_documentErrors;
103 void parseDocument(QDomDocument doc);
104 int slotAddProjectTrack(int ix, QDomElement xml, bool locked, QDomNodeList producers);
105 DocClipBase *getMissingProducer(const QString id) const;
106 void adjustTrackHeaders();
107 /** @brief Add effects from the xml. Returns true if some effect was upgraded, false if everything went fine.*/
108 void slotAddProjectEffects(QDomNodeList effects, QDomElement parentNode, ClipItem *clip, int trackIndex);
111 void setCursorPos(int pos);
112 void moveCursorPos(int pos);
113 /** @brief Rebuilds the track headers */
114 void slotRebuildTrackHeaders();
115 /** @brief The tracks count or a track name changed, rebuild and notify */
116 void slotReloadTracks();
117 void slotChangeTrackLock(int ix, bool lock);
118 void slotVerticalZoomDown();
119 void slotVerticalZoomUp();
121 /** @brief Changes the name of a track.
122 * @param ix Number of the track
123 * @param name New name */
124 void slotRenameTrack(int ix, QString name);
125 void slotRepaintTracks();
127 /** @brief Adjusts the margins of the header area.
129 * Avoid a shift between header area and trackview if
130 * the horizontal scrollbar is visible and the position
131 * of the vertical scrollbar is maximal */
132 void slotUpdateVerticalScroll(int min, int max);
133 void slotShowTrackEffects(int);
134 /** @brief Update the track label showing applied effects.*/
135 void slotUpdateTrackEffectState(int);
138 void mousePosition(int);
140 void zoneMoved(int, int);
141 void insertTrack(int);
142 void deleteTrack(int);
143 void configTrack(int);
144 void updateTracksInfo();
146 void showTrackEffects(int, TrackInfo);