#include <QWidget>
#include <QDomElement>
+#include <QItemDelegate>
+#include <QAbstractItemView>
+#include <QSpinBox>
#include "ui_keyframeeditor_ui.h"
#include "definitions.h"
#include "keyframehelper.h"
-//class QGraphicsScene;
+class KeyItemDelegate: public QItemDelegate
+{
+ Q_OBJECT
+public:
+ KeyItemDelegate(int min, int max, QAbstractItemView* parent = 0): QItemDelegate(parent), m_min(min), m_max(max) {
+ }
+
+ QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const {
+ if (index.column() == 1) {
+ QSpinBox *spin = new QSpinBox(parent);
+ connect(spin, SIGNAL(valueChanged(int)), this, SLOT(commitEditorData()));
+ connect(spin, SIGNAL(editingFinished()), this, SLOT(commitAndCloseEditor()));
+ return spin;
+ } else return QItemDelegate::createEditor(parent, option, index);
+ }
+
+
+ void setEditorData(QWidget *editor, const QModelIndex &index) const {
+ if (index.column() == 1) {
+ QSpinBox *spin = qobject_cast< QSpinBox* >(editor);
+ spin->setRange(m_min, m_max);
+ spin->setValue(index.model()->data(index).toInt());
+ } else QItemDelegate::setEditorData(editor, index);
+ }
+
+private slots:
+ void commitAndCloseEditor() {
+ QSpinBox *spin = qobject_cast< QSpinBox* >(sender());
+ emit closeEditor(spin);
+ }
+
+ void commitEditorData() {
+ QSpinBox *spin = qobject_cast< QSpinBox* >(sender());
+ emit commitData(spin);
+ }
+
+private:
+ int m_min;
+ int m_max;
+};
-class KeyframeEdit : public QWidget
+class KeyframeEdit : public QWidget, public Ui::KeyframeEditor_UI
{
Q_OBJECT
public:
- explicit KeyframeEdit(int maxFrame, double fps, int minValue, int maxValue, QWidget* parent = 0);
+ explicit KeyframeEdit(QDomElement e, int minFrame, int maxFrame, int minVal, int maxVal, Timecode tc, int active_keyframe, QWidget* parent = 0);
+ virtual ~KeyframeEdit();
+ void setupParam();
+ void addParameter(QDomElement e);
+ const QString getValue(const QString &name);
private:
- Ui::KeyframeEditor_UI m_ui;
- double m_fps;
+ QList <QDomElement> m_params;
+ int m_min;
+ int m_max;
+ int m_minVal;
+ int m_maxVal;
+ Timecode m_timecode;
+ int m_previousPos;
+ //KeyItemDelegate *m_delegate;
+ void generateAllParams();
+ QGridLayout *m_slidersLayout;
+ int m_active_keyframe;
public slots:
private slots:
+ void slotDeleteKeyframe();
+ void slotAddKeyframe();
+ void slotGenerateParams(int row, int column);
+ void slotAdjustKeyframeInfo(bool seek = true);
+ void slotAdjustKeyframePos(int value);
+ void slotAdjustKeyframeValue(int value);
+ void slotSetSeeking(int state);
+ //void slotSaveCurrentParam(QTreeWidgetItem *item, int column);
signals:
void parameterChanged();