diff --git a/src/qml/presenter/MainWindow.qml b/src/qml/presenter/MainWindow.qml index 0d2f95b..7d14dab 100644 --- a/src/qml/presenter/MainWindow.qml +++ b/src/qml/presenter/MainWindow.qml @@ -136,7 +136,7 @@ Controls.Page { presentation.textIndex = 0; presentation.changeSlide(); - print("Slide changed to: " + item.name); + print("Slide Cchanged to: " + item.name); } function editSwitch(item) { diff --git a/src/qml/presenter/VideoEditor.qml b/src/qml/presenter/VideoEditor.qml index a3623ba..04cfbae 100644 --- a/src/qml/presenter/VideoEditor.qml +++ b/src/qml/presenter/VideoEditor.qml @@ -143,6 +143,46 @@ Item { /* onEditingFinished: updateTitle(text); */ } + RowLayout { + Layout.preferredWidth: 300 + Layout.fillWidth: true + Layout.leftMargin: 20 + Layout.rightMargin: 20 + + + Controls.Label { + Layout.fillHeight: true + Layout.leftMargin: 20 + Layout.rightMargin: 20 + + text: videoLengthSlider.first.value + } + + Controls.Label { + Layout.fillHeight: true + Layout.leftMargin: 20 + Layout.rightMargin: 20 + + text: videoLengthSlider.second.value + } + } + + Controls.RangeSlider { + id: videoLengthSlider + + Layout.preferredWidth: 300 + Layout.fillWidth: true + Layout.leftMargin: 20 + Layout.rightMargin: 20 + + to: videoPreview.duration + from: 0 + + first.value: 0 + second.value: to + + } + Item { id: empty Layout.fillHeight: true diff --git a/src/videosqlmodel.cpp b/src/videosqlmodel.cpp index 7d4a99f..c44098d 100644 --- a/src/videosqlmodel.cpp +++ b/src/videosqlmodel.cpp @@ -30,6 +30,8 @@ static void createVideoTable() " 'id' INTEGER NOT NULL," " 'title' TEXT NOT NULL," " 'filePath' TEXT NOT NULL," + " 'startTime' REAL NOT NULL," + " 'endTime' REAL NOT NULL," " PRIMARY KEY(id))")) { qFatal("Failed to query database: %s", qPrintable(query.lastError().text())); @@ -70,6 +72,8 @@ QHash VideoSqlModel::roleNames() const names[Qt::UserRole] = "id"; names[Qt::UserRole + 1] = "title"; names[Qt::UserRole + 2] = "filePath"; + names[Qt::UserRole + 3] = "startTime"; + names[Qt::UserRole + 4] = "endTime"; return names; } @@ -156,6 +160,59 @@ void VideoSqlModel::updateFilePath(const int &row, const QUrl &filePath) { emit filePathChanged(); } + +int VideoSqlModel::startTime() const { + return m_startTime; +} + +void VideoSqlModel::setStartTime(const int &startTime) { + if (startTime == m_startTime) + return; + + m_startTime = startTime; + + select(); + emit startTimeChanged(); +} + +// This function is for updating the title from outside the delegate +void VideoSqlModel::updateStartTime(const int &row, const int &startTime) { + qDebug() << "Row is " << row; + QSqlRecord rowdata = record(row); + qDebug() << rowdata; + rowdata.setValue("startTime", startTime); + setRecord(row, rowdata); + qDebug() << rowdata; + submitAll(); + emit startTimeChanged(); +} + +int VideoSqlModel::endTime() const { + return m_endTime; +} + +void VideoSqlModel::setEndTime(const int &endTime) { + if (endTime == m_endTime) + return; + + m_endTime = endTime; + + select(); + emit endTimeChanged(); +} + +// This function is for updating the title from outside the delegate +void VideoSqlModel::updateEndTime(const int &row, const int &endTime) { + qDebug() << "Row is " << row; + QSqlRecord rowdata = record(row); + qDebug() << rowdata; + rowdata.setValue("endTime", endTime); + setRecord(row, rowdata); + qDebug() << rowdata; + submitAll(); + emit endTimeChanged(); +} + QVariantMap VideoSqlModel::getVideo(const int &row) { // qDebug() << "Row we are getting is " << row; // QVariantList video; diff --git a/src/videosqlmodel.h b/src/videosqlmodel.h index 07430d4..c592879 100644 --- a/src/videosqlmodel.h +++ b/src/videosqlmodel.h @@ -14,6 +14,8 @@ class VideoSqlModel : public QSqlTableModel 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) QML_ELEMENT public: @@ -22,12 +24,18 @@ public: int id() const; QString title() const; QUrl filePath() const; + int startTime() const; + int endTime() const; void setTitle(const QString &title); void setFilePath(const QUrl &filePath); + void setStartTime(const int &startTime); + void setEndTime(const int &endTime); 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 newVideo(const QUrl &filePath); Q_INVOKABLE void deleteVideo(const int &row); @@ -39,11 +47,15 @@ public: signals: void titleChanged(); void filePathChanged(); + void startTimeChanged(); + void endTimeChanged(); private: int m_id; QString m_title; QUrl m_filePath; + int m_startTime; + int m_endTime; }; #endif //VIDEOSQLMODEL_H