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()));
46 } else return QItemDelegate::createEditor(parent, option, index);
50 void setEditorData(QWidget *editor, const QModelIndex &index) const {
51 if (index.column() == 1) {
52 QSpinBox *spin = qobject_cast< QSpinBox* >(editor);
53 spin->setRange(m_min, m_max);
54 spin->setValue(index.model()->data(index).toInt());
55 } else QItemDelegate::setEditorData(editor, index);
59 void commitAndCloseEditor() {
60 QSpinBox *spin = qobject_cast< QSpinBox* >(sender());
61 emit closeEditor(spin);
64 void commitEditorData() {
65 QSpinBox *spin = qobject_cast< QSpinBox* >(sender());
66 emit commitData(spin);
74 class KeyframeEdit : public QWidget, public Ui::KeyframeEditor_UI
78 explicit KeyframeEdit(QDomElement e, int minFrame, int maxFrame, int minVal, int maxVal, Timecode tc, const QString paramName = QString(), QWidget* parent = 0);
79 virtual ~KeyframeEdit();
81 void addParameter(QDomElement e);
84 QList <QDomElement> m_params;
91 KeyItemDelegate *m_delegate;
92 void generateAllParams();
98 void slotDeleteKeyframe();
99 void slotAddKeyframe();
100 void slotGenerateParams(int row, int column);
101 void slotAdjustKeyframeInfo();
102 void slotAdjustKeyframePos(int value);
103 void slotAdjustKeyframeValue(int value);
104 //void slotSaveCurrentParam(QTreeWidgetItem *item, int column);
107 void parameterChanged();