CuteLogger
Fast and simple logging solution for Qt based applications
keyframesmodel.h
1/*
2 * Copyright (c) 2018-2023 Meltytech, LLC
3 *
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 3 of the License, or
7 * (at your option) any later version.
8 *
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.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef KEYFRAMESMODEL_H
19#define KEYFRAMESMODEL_H
20
21#include <MltAnimation.h>
22#include <MltProperties.h>
23#include <QAbstractItemModel>
24#include <QString>
25
26class QmlMetadata;
27class QmlFilter;
28
29class KeyframesModel : public QAbstractItemModel
30{
31 Q_OBJECT
32
33public:
34 enum InterpolationType {
35 DiscreteInterpolation,
36 LinearInterpolation,
37 SmoothLooseInterpolation,
38 SmoothNaturalInterpolation,
39 SmoothTightInterpolation,
40 EaseInSinusoidal,
41 EaseOutSinusoidal,
42 EaseInOutSinusoidal,
43 EaseInQuadratic,
44 EaseOutQuadratic,
45 EaseInOutQuadratic,
46 EaseInCubic,
47 EaseOutCubic,
48 EaseInOutCubic,
49 EaseInQuartic,
50 EaseOutQuartic,
51 EaseInOutQuartic,
52 EaseInQuintic,
53 EaseOutQuintic,
54 EaseInOutQuintic,
55 EaseInExponential,
56 EaseOutExponential,
57 EaseInOutExponential,
58 EaseInCircular,
59 EaseOutCircular,
60 EaseInOutCircular,
61 EaseInBack,
62 EaseOutBack,
63 EaseInOutBack,
64 EaseInElastic,
65 EaseOutElastic,
66 EaseInOutElastic,
67 EaseInBounce,
68 EaseOutBounce,
69 EaseInOutBounce,
70 };
71 Q_ENUM(InterpolationType)
72
73
74 enum Roles {
75 NameRole = Qt::UserRole + 1,
76 PropertyNameRole,
77 IsCurveRole,
78 MinimumValueRole,
79 MaximumValueRole,
80 LowestValueRole,
81 HighestValueRole,
82 FrameNumberRole,
83 KeyframeTypeRole,
84 PrevKeyframeTypeRole,
85 NumericValueRole,
86 MinimumFrameRole,
87 MaximumFrameRole
88 };
89
90 explicit KeyframesModel(QObject *parent = 0);
91 virtual ~KeyframesModel();
92
93 int rowCount(const QModelIndex &parent) const;
94 int columnCount(const QModelIndex &parent) const;
95 QVariant data(const QModelIndex &index, int role) const;
96 QModelIndex index(int row, int column = 0, const QModelIndex &parent = QModelIndex()) const;
97 QModelIndex parent(const QModelIndex &index) const;
98 QHash<int, QByteArray> roleNames() const;
99 void load(QmlFilter *, QmlMetadata *);
100 Q_INVOKABLE bool remove(int parameterIndex, int keyframeIndex);
101 int previousKeyframePosition(int parameterIndex, int currentPosition);
102 int nextKeyframePosition(int parameterIndex, int currentPosition);
103 Q_INVOKABLE int keyframeIndex(int parameterIndex, int currentPosition);
104 Q_INVOKABLE int parameterIndex(const QString &propertyName) const;
105 Q_INVOKABLE bool setInterpolation(int parameterIndex, int keyframeIndex, InterpolationType type);
106 Q_INVOKABLE void setKeyframePosition(int parameterIndex, int keyframeIndex, int position);
107 Q_INVOKABLE void addKeyframe(int parameterIndex,
108 double value,
109 int position,
110 InterpolationType type);
111 Q_INVOKABLE void addKeyframe(int parameterIndex, int position);
112 Q_INVOKABLE void setKeyframeValue(int parameterIndex, int keyframeIndex, double value);
113 Q_INVOKABLE void setKeyframeValuePosition(int parameterIndex,
114 int keyframeIndex,
115 double value,
116 int position);
117 Q_INVOKABLE bool isKeyframe(int parameterIndex, int position);
118 Q_INVOKABLE bool advancedKeyframesInUse();
119 Q_INVOKABLE void removeAdvancedKeyframes();
120 Q_INVOKABLE bool simpleKeyframesInUse();
121 Q_INVOKABLE void removeSimpleKeyframes();
122 int keyframeCount(int index) const;
123
124signals:
125 void loaded();
126 void keyframeAdded(QString parameter, int position);
127
128public slots:
129 void reload();
130 void onFilterChanged(const QString &property);
131 void onFilterInChanged(int delta);
132 void trimFilterIn(int in);
133 void trimFilterOut(int out);
134
135private:
136 QList<QString> m_propertyNames;
137 QmlMetadata *m_metadata;
138 QmlFilter *m_filter;
139 QList<int> m_keyframeCounts;
140 QList<int> m_metadataIndex;
141
142 void updateNeighborsMinMax(int parameterIndex, int keyframeIndex);
143 QStringList gangedProperties(int parameterIndex) const;
144};
145
146#endif // KEYFRAMESMODEL_H