1 /***************************************************************************
2 keyframeedit.h - description
5 copyright : (C) 2008 by Jean-Baptiste Mardelle
6 email : jb@kdenlive.org
7 ***************************************************************************/
9 /***************************************************************************
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
16 ***************************************************************************/
18 #ifndef KEYFRAMEEDIT_H
19 #define KEYFRAMEEDIT_H
23 #include <QDomElement>
24 #include <QItemDelegate>
25 #include <QAbstractItemView>
29 #include "ui_keyframeeditor_ui.h"
30 #include "definitions.h"
31 #include "keyframehelper.h"
33 class KeyItemDelegate: public QItemDelegate
37 KeyItemDelegate(int min, int max, QAbstractItemView* parent = 0): QItemDelegate(parent), m_min(min), m_max(max) {
40 QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const {
41 if (index.column() == 1) {
42 QSpinBox *spin = new QSpinBox(parent);
43 connect(spin, SIGNAL(valueChanged(int)), this, SLOT(commitEditorData()));
44 connect(spin, SIGNAL(editingFinished()), this, SLOT(commitAndCloseEditor()));
47 return QItemDelegate::createEditor(parent, option, index);
52 void setEditorData(QWidget *editor, const QModelIndex &index) const {
53 if (index.column() == 1) {
54 QSpinBox *spin = qobject_cast< QSpinBox* >(editor);
55 spin->setRange(m_min, m_max);
56 spin->setValue(index.model()->data(index).toInt());
58 QItemDelegate::setEditorData(editor, index);
63 void commitAndCloseEditor() {
64 QSpinBox *spin = qobject_cast< QSpinBox* >(sender());
65 emit closeEditor(spin);
68 void commitEditorData() {
69 QSpinBox *spin = qobject_cast< QSpinBox* >(sender());
70 emit commitData(spin);
78 class KeyframeEdit : public QWidget, public Ui::KeyframeEditor_UI
82 explicit KeyframeEdit(QDomElement e, int minFrame, int maxFrame, int minVal, int maxVal, Timecode tc, int active_keyframe, QWidget* parent = 0);
83 virtual ~KeyframeEdit();
85 void addParameter(QDomElement e);
86 const QString getValue(const QString &name);
87 /** @brief Updates the timecode display according to settings (frame number or hh:mm:ss:ff) */
88 void updateTimecodeFormat();
91 QList <QDomElement> m_params;
98 //KeyItemDelegate *m_delegate;
99 void generateAllParams();
100 QGridLayout *m_slidersLayout;
101 int m_active_keyframe;
103 /** @brief Gets the position of a keyframe from the table.
104 * @param row Row of the keyframe in the table */
106 /** @brief Converts a frame value to timecode considering the frames vs. HH:MM:SS:FF setting.
107 * @return timecode */
108 QString getPosString(int pos);
111 void slotDeleteKeyframe();
112 void slotAddKeyframe();
113 void slotGenerateParams(int row, int column);
114 void slotAdjustKeyframeInfo(bool seek = true);
115 void slotAdjustKeyframePos(int value);
116 void slotAdjustKeyframeValue(int value);
117 /** @brief Turns the seek to keyframe position setting on/off.
118 * @param state State of the associated checkbox */
119 void slotSetSeeking(int state);
120 //void slotSaveCurrentParam(QTreeWidgetItem *item, int column);
123 void parameterChanged();