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
31 enum Columns {
32 COLUMN_ERROR = 0,
33 COLUMN_NAME,
34 COLUMN_OFFSET,
35 COLUMN_SPEED,
36 COLUMN_COUNT,
37 };
38 static const int INVALID_OFFSET = std::numeric_limits<int>::max();
39
40 explicit AlignClipsModel(QObject *parent = 0);
41 virtual ~AlignClipsModel();
42 void clear();
43 void addClip(const QString &name, int offset, int speed, const QString &error);
44 void updateProgress(int row, int percent);
45 int getProgress(int row) const;
46 void updateOffsetAndSpeed(int row, int offset, double speed, const QString &error);
47 int getOffset(int row);
48 double getSpeed(int row);
49
50protected:
51 // Implement QAbstractItemModel
52 int rowCount(const QModelIndex &parent) const;
53 int columnCount(const QModelIndex &parent) const;
54 QVariant data(const QModelIndex &index, int role) const;
55 QVariant headerData(int section, Qt::Orientation orientation, int role) const;
56 QModelIndex index(int row, int column = 0, const QModelIndex &parent = QModelIndex()) const;
57 QModelIndex parent(const QModelIndex &index) const;
58
59private:
60 typedef struct {
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