adding looping into basic model of videos
This commit is contained in:
parent
a3be06639b
commit
0ccb725c55
2 changed files with 44 additions and 2 deletions
|
@ -30,8 +30,9 @@ static void createVideoTable()
|
|||
" 'id' INTEGER NOT NULL,"
|
||||
" 'title' TEXT NOT NULL,"
|
||||
" 'filePath' TEXT NOT NULL,"
|
||||
" 'startTime' REAL NOT NULL,"
|
||||
" 'endTime' REAL NOT NULL,"
|
||||
" 'startTime' REAL,"
|
||||
" 'endTime' REAL,"
|
||||
" 'loop' BOOLEAN NOT NULL DEFAULT 0,"
|
||||
" PRIMARY KEY(id))")) {
|
||||
qFatal("Failed to query database: %s",
|
||||
qPrintable(query.lastError().text()));
|
||||
|
@ -74,6 +75,7 @@ QHash<int, QByteArray> VideoSqlModel::roleNames() const
|
|||
names[Qt::UserRole + 2] = "filePath";
|
||||
names[Qt::UserRole + 3] = "startTime";
|
||||
names[Qt::UserRole + 4] = "endTime";
|
||||
names[Qt::UserRole + 5] = "loop";
|
||||
return names;
|
||||
}
|
||||
|
||||
|
@ -245,6 +247,40 @@ void VideoSqlModel::updateEndTime(const int &row, const int &endTime) {
|
|||
emit endTimeChanged();
|
||||
}
|
||||
|
||||
// bool VideoSqlModel::loop() const {
|
||||
// return m_loop;
|
||||
// }
|
||||
|
||||
// void VideoSqlModel::setloop(const bool &loop) {
|
||||
// if (loop == m_loop)
|
||||
// return;
|
||||
|
||||
// m_loop = loop;
|
||||
|
||||
// select();
|
||||
// emit loopChanged();
|
||||
// }
|
||||
|
||||
// // This function is for updating looping from outside the delegate
|
||||
// void VideoSqlModel::updateloop(const int &row, const bool &loop) {
|
||||
// qDebug() << "Row is " << row;
|
||||
// QSqlQuery query("select id from videos");
|
||||
// QList<int> ids;
|
||||
// while (query.next()) {
|
||||
// ids.append(query.value(0).toInt());
|
||||
// // qDebug() << ids;
|
||||
// }
|
||||
// int id = ids.indexOf(row,0);
|
||||
|
||||
// QSqlRecord rowdata = record(id);
|
||||
// qDebug() << rowdata;
|
||||
// rowdata.setValue("loop", loop);
|
||||
// setRecord(id, rowdata);
|
||||
// qDebug() << rowdata;
|
||||
// submitAll();
|
||||
// emit loopChanged();
|
||||
// }
|
||||
|
||||
QVariantMap VideoSqlModel::getVideo(const int &row) {
|
||||
// qDebug() << "Row we are getting is " << row;
|
||||
// QVariantList video;
|
||||
|
|
|
@ -16,6 +16,7 @@ class VideoSqlModel : public QSqlTableModel
|
|||
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:
|
||||
|
@ -26,16 +27,19 @@ public:
|
|||
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);
|
||||
|
@ -47,6 +51,7 @@ public:
|
|||
signals:
|
||||
void titleChanged();
|
||||
void filePathChanged();
|
||||
// void loopChanged();
|
||||
void startTimeChanged();
|
||||
void endTimeChanged();
|
||||
|
||||
|
@ -56,6 +61,7 @@ private:
|
|||
QUrl m_filePath;
|
||||
int m_startTime;
|
||||
int m_endTime;
|
||||
// bool m_loop;
|
||||
};
|
||||
|
||||
#endif //VIDEOSQLMODEL_H
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue