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 <QAbstractItemModel>
22#include <QString>
23#include <MltProperties.h>
24#include <MltAnimation.h>
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,
97 const QModelIndex &parent = QModelIndex()) const;
98 QModelIndex parent(const QModelIndex &index) const;
99 QHash<int, QByteArray> roleNames() const;
100 void load(QmlFilter *, QmlMetadata *);
101 Q_INVOKABLE bool remove(int parameterIndex, int keyframeIndex);
102 int previousKeyframePosition(int parameterIndex, int currentPosition);
103 int nextKeyframePosition(int parameterIndex, int currentPosition);
104 Q_INVOKABLE int keyframeIndex(int parameterIndex, int currentPosition);
105 Q_INVOKABLE int parameterIndex(const QString &propertyName) const;
106 Q_INVOKABLE bool setInterpolation(int parameterIndex, int keyframeIndex, InterpolationType type);
107 Q_INVOKABLE void setKeyframePosition(int parameterIndex, int keyframeIndex, int position);
108 Q_INVOKABLE void addKeyframe(int parameterIndex, double value, int position,
109 InterpolationType type);
110 Q_INVOKABLE void addKeyframe(int parameterIndex, int position);
111 Q_INVOKABLE void setKeyframeValue(int parameterIndex, int keyframeIndex, double value);
112 Q_INVOKABLE void setKeyframeValuePosition(int parameterIndex, int keyframeIndex, double value,
113 int position);
114 Q_INVOKABLE bool isKeyframe(int parameterIndex, int position);
115 Q_INVOKABLE bool advancedKeyframesInUse();
116 Q_INVOKABLE void removeAdvancedKeyframes();
117 Q_INVOKABLE bool simpleKeyframesInUse();
118 Q_INVOKABLE void removeSimpleKeyframes();
119 int keyframeCount(int index) const;
120
121signals:
122 void loaded();
123 void keyframeAdded(QString parameter, int position);
124
125public slots:
126 void reload();
127 void onFilterChanged(const QString &property);
128 void onFilterInChanged(int delta);
129 void trimFilterIn(int in);
130 void trimFilterOut(int out);
131
132private:
133 QList<QString> m_propertyNames;
134 QmlMetadata *m_metadata;
135 QmlFilter *m_filter;
136 QList<int> m_keyframeCounts;
137 QList<int> m_metadataIndex;
138
139 void updateNeighborsMinMax(int parameterIndex, int keyframeIndex);
140 QStringList gangedProperties(int parameterIndex) const;
141};
142
143#endif // KEYFRAMESMODEL_H