making presentation library work
This commit is contained in:
parent
96de8e3b00
commit
5713f40208
6 changed files with 78 additions and 46 deletions
|
@ -9,6 +9,7 @@ target_sources(presenter
|
||||||
slide.cpp slide.h
|
slide.cpp slide.h
|
||||||
videosqlmodel.cpp videosqlmodel.h
|
videosqlmodel.cpp videosqlmodel.h
|
||||||
imagesqlmodel.cpp imagesqlmodel.h
|
imagesqlmodel.cpp imagesqlmodel.h
|
||||||
|
presentationsqlmodel.cpp presentationsqlmodel.h
|
||||||
mpv/mpvobject.h mpv/mpvobject.cpp
|
mpv/mpvobject.h mpv/mpvobject.cpp
|
||||||
mpv/qthelper.hpp mpv/mpvhelpers.h
|
mpv/qthelper.hpp mpv/mpvhelpers.h
|
||||||
)
|
)
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
#include "songsqlmodel.h"
|
#include "songsqlmodel.h"
|
||||||
#include "videosqlmodel.h"
|
#include "videosqlmodel.h"
|
||||||
#include "imagesqlmodel.h"
|
#include "imagesqlmodel.h"
|
||||||
#include "pressqlmodel.h"
|
#include "presentationsqlmodel.h"
|
||||||
#include "slide.h"
|
#include "slide.h"
|
||||||
|
|
||||||
static void connectToDatabase() {
|
static void connectToDatabase() {
|
||||||
|
@ -106,7 +106,7 @@ int main(int argc, char *argv[])
|
||||||
qmlRegisterType<SongSqlModel>("org.presenter", 1, 0, "SongSqlModel");
|
qmlRegisterType<SongSqlModel>("org.presenter", 1, 0, "SongSqlModel");
|
||||||
qmlRegisterType<VideoSqlModel>("org.presenter", 1, 0, "VideoSqlModel");
|
qmlRegisterType<VideoSqlModel>("org.presenter", 1, 0, "VideoSqlModel");
|
||||||
qmlRegisterType<ImageSqlModel>("org.presenter", 1, 0, "ImageSqlModel");
|
qmlRegisterType<ImageSqlModel>("org.presenter", 1, 0, "ImageSqlModel");
|
||||||
qmlRegisterType<PresSqlModel>("org.presenter", 1, 0, "PresSqlModel");
|
qmlRegisterType<PresentationSqlModel>("org.presenter", 1, 0, "PresentationSqlModel");
|
||||||
qmlRegisterType<ServiceItemModel>("org.presenter", 1, 0, "ServiceItemModel");
|
qmlRegisterType<ServiceItemModel>("org.presenter", 1, 0, "ServiceItemModel");
|
||||||
qmlRegisterSingletonInstance("org.presenter", 1, 0, "SlideObject", slide.get());
|
qmlRegisterSingletonInstance("org.presenter", 1, 0, "SlideObject", slide.get());
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#include "pressqlmodel.h"
|
#include "presentationsqlmodel.h"
|
||||||
|
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
@ -17,15 +17,17 @@
|
||||||
#include <qurl.h>
|
#include <qurl.h>
|
||||||
#include <qvariant.h>
|
#include <qvariant.h>
|
||||||
|
|
||||||
static const char *presTableName = "presentation";
|
static const char *presentationsTableName = "presentations";
|
||||||
|
|
||||||
static void createPresTable()
|
static void createPresentationTable()
|
||||||
{
|
{
|
||||||
if(QSqlDatabase::database().tables().contains(presTableName)) {
|
QSqlQuery query;
|
||||||
|
if(QSqlDatabase::database().tables().contains(presentationsTableName)) {
|
||||||
|
// query.exec("DROP TABLE 'presentations'");
|
||||||
|
// qDebug() << query.lastQuery();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSqlQuery query;
|
|
||||||
if (!query.exec("CREATE TABLE IF NOT EXISTS 'presentations' ("
|
if (!query.exec("CREATE TABLE IF NOT EXISTS 'presentations' ("
|
||||||
" 'id' INTEGER NOT NULL,"
|
" 'id' INTEGER NOT NULL,"
|
||||||
" 'title' TEXT NOT NULL,"
|
" 'title' TEXT NOT NULL,"
|
||||||
|
@ -37,25 +39,25 @@ static void createPresTable()
|
||||||
qDebug() << query.lastQuery();
|
qDebug() << query.lastQuery();
|
||||||
qDebug() << "inserting into presentations";
|
qDebug() << "inserting into presentations";
|
||||||
|
|
||||||
query.exec("INSERT INTO presentations (title, filePath) VALUES ('Dec 180', 'file:///home/chris/nextcloud/tfc/openlp/5 slides-2.pdf')");
|
query.exec("INSERT INTO presentations (title, filePath) VALUES ('Dec 180', 'file:///home/chris/nextcloud/tfc/openlp/5 slides-1.pdf')");
|
||||||
qDebug() << query.lastQuery();
|
qDebug() << query.lastQuery();
|
||||||
query.exec("INSERT INTO presentations (title, filePath) VALUES ('No TFC', "
|
query.exec("INSERT INTO presentations (title, filePath) VALUES ('No TFC', "
|
||||||
"'file:///home/chris/nextcloud/tfc/openlp/5 slides-1.pdf')");
|
"'file:///home/chris/nextcloud/tfc/openlp/5 slides-2.pdf')");
|
||||||
|
|
||||||
query.exec("select * from presentations");
|
query.exec("select * from presentations");
|
||||||
qDebug() << query.lastQuery();
|
qDebug() << query.lastQuery();
|
||||||
}
|
}
|
||||||
|
|
||||||
PresSqlModel::PresSqlModel(QObject *parent) : QSqlTableModel(parent) {
|
PresentationSqlModel::PresentationSqlModel(QObject *parent) : QSqlTableModel(parent) {
|
||||||
qDebug() << "creating pres table";
|
qDebug() << "creating presentation table";
|
||||||
createPresTable();
|
createPresentationTable();
|
||||||
setTable(pressTableName);
|
setTable(presentationsTableName);
|
||||||
setEditStrategy(QSqlTableModel::OnManualSubmit);
|
setEditStrategy(QSqlTableModel::OnManualSubmit);
|
||||||
// make sure to call select else the model won't fill
|
// make sure to call select else the model won't fill
|
||||||
select();
|
select();
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant PresSqlModel::data(const QModelIndex &index, int role) const {
|
QVariant PresentationSqlModel::data(const QModelIndex &index, int role) const {
|
||||||
if (role < Qt::UserRole) {
|
if (role < Qt::UserRole) {
|
||||||
return QSqlTableModel::data(index, role);
|
return QSqlTableModel::data(index, role);
|
||||||
}
|
}
|
||||||
|
@ -65,7 +67,7 @@ QVariant PresSqlModel::data(const QModelIndex &index, int role) const {
|
||||||
return sqlRecord.value(role - Qt::UserRole);
|
return sqlRecord.value(role - Qt::UserRole);
|
||||||
}
|
}
|
||||||
|
|
||||||
QHash<int, QByteArray> PresSqlModel::roleNames() const
|
QHash<int, QByteArray> PresentationSqlModel::roleNames() const
|
||||||
{
|
{
|
||||||
QHash<int, QByteArray> names;
|
QHash<int, QByteArray> names;
|
||||||
names[Qt::UserRole] = "id";
|
names[Qt::UserRole] = "id";
|
||||||
|
@ -74,8 +76,8 @@ QHash<int, QByteArray> PresSqlModel::roleNames() const
|
||||||
return names;
|
return names;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PresSqlModel::newPres(const QUrl &filePath) {
|
void PresentationSqlModel::newPresentation(const QUrl &filePath) {
|
||||||
qDebug() << "adding new pres";
|
qDebug() << "adding new presentation";
|
||||||
int rows = rowCount();
|
int rows = rowCount();
|
||||||
|
|
||||||
qDebug() << rows;
|
qDebug() << rows;
|
||||||
|
@ -92,7 +94,7 @@ void PresSqlModel::newPres(const QUrl &filePath) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
void PresSqlModel::deletePres(const int &row) {
|
void PresentationSqlModel::deletePresentation(const int &row) {
|
||||||
QSqlRecord recordData = record(row);
|
QSqlRecord recordData = record(row);
|
||||||
if (recordData.isEmpty())
|
if (recordData.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
@ -101,15 +103,15 @@ void PresSqlModel::deletePres(const int &row) {
|
||||||
submitAll();
|
submitAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
int PresSqlModel::id() const {
|
int PresentationSqlModel::id() const {
|
||||||
return m_id;
|
return m_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString PresSqlModel::title() const {
|
QString PresentationSqlModel::title() const {
|
||||||
return m_title;
|
return m_title;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PresSqlModel::setTitle(const QString &title) {
|
void PresentationSqlModel::setTitle(const QString &title) {
|
||||||
if (title == m_title)
|
if (title == m_title)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -120,7 +122,7 @@ void PresSqlModel::setTitle(const QString &title) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// This function is for updating the title from outside the delegate
|
// This function is for updating the title from outside the delegate
|
||||||
void PresSqlModel::updateTitle(const int &row, const QString &title) {
|
void PresentationSqlModel::updateTitle(const int &row, const QString &title) {
|
||||||
qDebug() << "Row is " << row;
|
qDebug() << "Row is " << row;
|
||||||
QSqlRecord rowdata = record(row);
|
QSqlRecord rowdata = record(row);
|
||||||
qDebug() << rowdata;
|
qDebug() << rowdata;
|
||||||
|
@ -131,11 +133,11 @@ void PresSqlModel::updateTitle(const int &row, const QString &title) {
|
||||||
emit titleChanged();
|
emit titleChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
QUrl PresSqlModel::filePath() const {
|
QUrl PresentationSqlModel::filePath() const {
|
||||||
return m_filePath;
|
return m_filePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PresSqlModel::setFilePath(const QUrl &filePath) {
|
void PresentationSqlModel::setFilePath(const QUrl &filePath) {
|
||||||
if (filePath == m_filePath)
|
if (filePath == m_filePath)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -146,7 +148,7 @@ void PresSqlModel::setFilePath(const QUrl &filePath) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// This function is for updating the filepath from outside the delegate
|
// This function is for updating the filepath from outside the delegate
|
||||||
void PresSqlModel::updateFilePath(const int &row, const QUrl &filePath) {
|
void PresentationSqlModel::updateFilePath(const int &row, const QUrl &filePath) {
|
||||||
qDebug() << "Row is " << row;
|
qDebug() << "Row is " << row;
|
||||||
QSqlRecord rowdata = record(row);
|
QSqlRecord rowdata = record(row);
|
||||||
qDebug() << rowdata;
|
qDebug() << rowdata;
|
||||||
|
@ -157,16 +159,15 @@ void PresSqlModel::updateFilePath(const int &row, const QUrl &filePath) {
|
||||||
emit filePathChanged();
|
emit filePathChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Here we grab the presentation from it's row id
|
QVariantMap PresentationSqlModel::getPresentation(const int &row) {
|
||||||
QVariantMap PresSqlModel::getPres(const int &row) {
|
|
||||||
// qDebug() << "Row we are getting is " << row;
|
// qDebug() << "Row we are getting is " << row;
|
||||||
// QUrl pres;
|
// QUrl presentation;
|
||||||
// QSqlRecord rec = record(row);
|
// QSqlRecord rec = record(row);
|
||||||
// qDebug() << rec.value("filePath").toUrl();
|
// qDebug() << rec.value("filePath").toUrl();
|
||||||
// // pres.append(rec.value("title"));
|
// // presentation.append(rec.value("title"));
|
||||||
// // pres.append(rec.value("filePath"));
|
// // presentation.append(rec.value("filePath"));
|
||||||
// pres = rec.value("filePath").toUrl();
|
// presentation = rec.value("filePath").toUrl();
|
||||||
// return pres;
|
// return presentation;
|
||||||
|
|
||||||
QVariantMap data;
|
QVariantMap data;
|
||||||
const QModelIndex idx = this->index(row,0);
|
const QModelIndex idx = this->index(row,0);
|
|
@ -1,5 +1,5 @@
|
||||||
#ifndef PRESSQLMODEL_H
|
#ifndef PRESENTATIONSQLMODEL_H
|
||||||
#define PRESSQLMODEL_H
|
#define PRESENTATIONSQLMODEL_H
|
||||||
|
|
||||||
#include <QSqlTableModel>
|
#include <QSqlTableModel>
|
||||||
#include <qobject.h>
|
#include <qobject.h>
|
||||||
|
@ -8,7 +8,7 @@
|
||||||
#include <qurl.h>
|
#include <qurl.h>
|
||||||
#include <qvariant.h>
|
#include <qvariant.h>
|
||||||
|
|
||||||
class PresSqlModel : public QSqlTableModel
|
class PresentationSqlModel : public QSqlTableModel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(int id READ id)
|
Q_PROPERTY(int id READ id)
|
||||||
|
@ -17,7 +17,7 @@ class PresSqlModel : public QSqlTableModel
|
||||||
QML_ELEMENT
|
QML_ELEMENT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PresSqlModel(QObject *parent = 0);
|
PresentationSqlModel(QObject *parent = 0);
|
||||||
|
|
||||||
int id() const;
|
int id() const;
|
||||||
QString title() const;
|
QString title() const;
|
||||||
|
@ -29,9 +29,9 @@ public:
|
||||||
Q_INVOKABLE void updateTitle(const int &row, const QString &title);
|
Q_INVOKABLE void updateTitle(const int &row, const QString &title);
|
||||||
Q_INVOKABLE void updateFilePath(const int &row, const QUrl &filePath);
|
Q_INVOKABLE void updateFilePath(const int &row, const QUrl &filePath);
|
||||||
|
|
||||||
Q_INVOKABLE void newPres(const QUrl &filePath);
|
Q_INVOKABLE void newPresentation(const QUrl &filePath);
|
||||||
Q_INVOKABLE void deletePres(const int &row);
|
Q_INVOKABLE void deletePresentation(const int &row);
|
||||||
Q_INVOKABLE QVariantMap getPres(const int &row);
|
Q_INVOKABLE QVariantMap getPresentation(const int &row);
|
||||||
|
|
||||||
QVariant data(const QModelIndex &index, int role) const override;
|
QVariant data(const QModelIndex &index, int role) const override;
|
||||||
QHash<int, QByteArray> roleNames() const override;
|
QHash<int, QByteArray> roleNames() const override;
|
||||||
|
@ -46,4 +46,4 @@ private:
|
||||||
QUrl m_filePath;
|
QUrl m_filePath;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //PRESSQLMODEL_H
|
#endif //PRESENTATIONSQLMODEL_H
|
|
@ -692,8 +692,38 @@ Item {
|
||||||
color: Kirigami.Theme.backgroundColor
|
color: Kirigami.Theme.backgroundColor
|
||||||
|
|
||||||
Controls.Label {
|
Controls.Label {
|
||||||
anchors.centerIn: parent
|
id: presentationLabel
|
||||||
|
anchors.right: presentationCount.left
|
||||||
|
anchors.rightMargin: 15
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
text: "Presentations"
|
text: "Presentations"
|
||||||
|
elide: Text.ElideRight
|
||||||
|
}
|
||||||
|
|
||||||
|
Controls.Label {
|
||||||
|
id: presentationCount
|
||||||
|
anchors {right: presentationDrawerArrow.left
|
||||||
|
verticalCenter: presentationLabel.verticalCenter
|
||||||
|
rightMargin: 10}
|
||||||
|
text: pressqlmodel.rowCount()
|
||||||
|
font.pixelSize: 15
|
||||||
|
color: Kirigami.Theme.disabledTextColor
|
||||||
|
}
|
||||||
|
|
||||||
|
Kirigami.Icon {
|
||||||
|
id: presentationDrawerArrow
|
||||||
|
anchors {right: parent.right
|
||||||
|
verticalCenter: presentationCount.verticalCenter
|
||||||
|
rightMargin: 10}
|
||||||
|
source: "arrow-down"
|
||||||
|
rotation: selectedLibrary == "presentations" ? 0 : 180
|
||||||
|
|
||||||
|
Behavior on rotation {
|
||||||
|
NumberAnimation {
|
||||||
|
easing.type: Easing.OutCubic
|
||||||
|
duration: 300
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
|
@ -747,14 +777,14 @@ Item {
|
||||||
id: presDelegate
|
id: presDelegate
|
||||||
Item{
|
Item{
|
||||||
implicitWidth: ListView.view.width
|
implicitWidth: ListView.view.width
|
||||||
height: selectedLibrary == "press" ? 50 : 0
|
height: selectedLibrary == "presentations" ? 50 : 0
|
||||||
Kirigami.BasicListItem {
|
Kirigami.BasicListItem {
|
||||||
id: presListItem
|
id: presListItem
|
||||||
|
|
||||||
property bool rightMenu: false
|
property bool rightMenu: false
|
||||||
|
|
||||||
implicitWidth: presentationLibraryList.width
|
implicitWidth: presentationLibraryList.width
|
||||||
height: selectedLibrary == "press" ? 50 : 0
|
height: selectedLibrary == "presentations" ? 50 : 0
|
||||||
clip: true
|
clip: true
|
||||||
label: title
|
label: title
|
||||||
/* subtitle: author */
|
/* subtitle: author */
|
||||||
|
@ -833,7 +863,7 @@ Item {
|
||||||
rightClickPresMenu.popup()
|
rightClickPresMenu.popup()
|
||||||
else{
|
else{
|
||||||
presentationLibraryList.currentIndex = index
|
presentationLibraryList.currentIndex = index
|
||||||
const pres = pressqlmodel.getPres(presentationLibraryList.currentIndex);
|
const pres = pressqlmodel.getPresentation(presentationLibraryList.currentIndex);
|
||||||
if (!editMode)
|
if (!editMode)
|
||||||
editMode = true;
|
editMode = true;
|
||||||
editType = "pres";
|
editType = "pres";
|
||||||
|
@ -849,7 +879,7 @@ Item {
|
||||||
y: presClickHandler.mouseY + 10
|
y: presClickHandler.mouseY + 10
|
||||||
Kirigami.Action {
|
Kirigami.Action {
|
||||||
text: "delete"
|
text: "delete"
|
||||||
onTriggered: pressqlmodel.deletePres(index)
|
onTriggered: pressqlmodel.deletePresentation(index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,7 +115,7 @@ Controls.Page {
|
||||||
id: imagesqlmodel
|
id: imagesqlmodel
|
||||||
}
|
}
|
||||||
|
|
||||||
PresSqlModel {
|
PresentationSqlModel {
|
||||||
id: pressqlmodel
|
id: pressqlmodel
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue