CuteLogger
Fast and simple logging solution for Qt based applications
alignclipsmodel.h
1/*
2 * Copyright (c) 2022 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 ALIGNCLIPSMODEL_H
19#define ALIGNCLIPSMODEL_H
20
21#include <QAbstractItemModel>
22
23#include <limits>
24
25class AlignClipsModel : public QAbstractItemModel
26{
27 Q_OBJECT
28
29public:
30 enum Columns {
31 COLUMN_ERROR = 0,
32 COLUMN_NAME,
33 COLUMN_OFFSET,
34 COLUMN_SPEED,
35 COLUMN_COUNT,
36 };
37 static const int INVALID_OFFSET = std::numeric_limits<int>::max();
38
39 explicit AlignClipsModel(QObject *parent = 0);
40 virtual ~AlignClipsModel();
41 void clear();
42 void addClip(const QString &name, int offset, int speed, const QString &error);
43 void updateProgress(int row, int percent);
44 int getProgress(int row) const;
45 void updateOffsetAndSpeed(int row, int offset, double speed, const QString &error);
46 int getOffset(int row);
47 double getSpeed(int row);
48
49protected:
50 // Implement QAbstractItemModel
51 int rowCount(const QModelIndex &parent) const;
52 int columnCount(const QModelIndex &parent) const;
53 QVariant data(const QModelIndex &index, int role) const;
54 QVariant headerData(int section, Qt::Orientation orientation, int role) const;
55 QModelIndex index(int row, int column = 0, const QModelIndex &parent = QModelIndex()) const;
56 QModelIndex parent(const QModelIndex &index) const;
57
58private:
59 typedef struct
60 {
61 QString name;
62 int offset;
63 double speed;
64 QString error;
65 int progress;
66 } ClipAlignment;
67 QList<ClipAlignment> m_clips;
68};
69
70#endif // ALIGNCLIPSMODEL_H