moving code around for a better file structure

This commit is contained in:
Chris Cochrun 2022-12-09 10:55:50 -06:00
parent 8f3e898385
commit 7eba697dc2
27 changed files with 20 additions and 24 deletions

67
src/cpp/videosqlmodel.h Normal file
View file

@ -0,0 +1,67 @@
#ifndef VIDEOSQLMODEL_H
#define VIDEOSQLMODEL_H
#include <QSqlTableModel>
#include <qobject.h>
#include <qobjectdefs.h>
#include <qqml.h>
#include <qurl.h>
#include <qvariant.h>
class VideoSqlModel : public QSqlTableModel
{
Q_OBJECT
Q_PROPERTY(int id READ id)
Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged)
Q_PROPERTY(QUrl filePath READ filePath WRITE setFilePath NOTIFY filePathChanged)
Q_PROPERTY(int startTime READ startTime WRITE setStartTime NOTIFY startTimeChanged)
Q_PROPERTY(int endTime READ endTime WRITE setEndTime NOTIFY endTimeChanged)
Q_PROPERTY(bool loop READ loop WRITE setLoop NOTIFY loopChanged)
QML_ELEMENT
public:
VideoSqlModel(QObject *parent = 0);
int id() const;
QString title() const;
QUrl filePath() const;
int startTime() const;
int endTime() const;
bool loop() const;
void setTitle(const QString &title);
void setFilePath(const QUrl &filePath);
void setStartTime(const int &startTime);
void setEndTime(const int &endTime);
void setLoop(const bool &loop);
Q_INVOKABLE void updateTitle(const int &row, const QString &title);
Q_INVOKABLE void updateFilePath(const int &row, const QUrl &filePath);
Q_INVOKABLE void updateStartTime(const int &row, const int &startTime);
Q_INVOKABLE void updateEndTime(const int &row, const int &endTime);
Q_INVOKABLE void updateLoop(const int &row, const bool &loop);
Q_INVOKABLE void newVideo(const QUrl &filePath);
Q_INVOKABLE void deleteVideo(const int &row);
Q_INVOKABLE QVariantMap getVideo(const int &row);
QVariant data(const QModelIndex &index, int role) const override;
QHash<int, QByteArray> roleNames() const override;
signals:
void titleChanged();
void filePathChanged();
void loopChanged();
void startTimeChanged();
void endTimeChanged();
private:
int m_id;
QString m_title;
QUrl m_filePath;
int m_startTime;
int m_endTime;
bool m_loop;
};
#endif //VIDEOSQLMODEL_H