ok I added some proxy models to all sql models, but they aint done..

This commit is contained in:
Chris Cochrun 2023-02-17 16:14:50 -06:00
parent cc501873c1
commit c9f6fc4d1b
8 changed files with 117 additions and 71 deletions

View file

@ -208,9 +208,22 @@ QVariantMap ImageSqlModel::getImage(const int &row) {
ImageProxyModel::ImageProxyModel(QObject *parent) ImageProxyModel::ImageProxyModel(QObject *parent)
:QSortFilterProxyModel(parent) :QSortFilterProxyModel(parent)
{ {
ImageSqlModel *imageModel = new ImageSqlModel; m_imageModel = new ImageSqlModel;
setSourceModel(imageModel); setSourceModel(m_imageModel);
setDynamicSortFilter(true); setDynamicSortFilter(true);
setFilterRole(Qt::UserRole + 1); setFilterRole(Qt::UserRole + 1);
setFilterCaseSensitivity(Qt::CaseInsensitive); setFilterCaseSensitivity(Qt::CaseInsensitive);
} }
ImageSqlModel *ImageProxyModel::imageModel() {
return m_imageModel;
}
QVariantMap ImageProxyModel::getImage(const int &row) {
return QVariantMap();
}
void ImageProxyModel::deleteImage(const int &row) {
auto model = qobject_cast<ImageSqlModel *>(sourceModel());
model->deleteImage(row);
}

View file

@ -50,11 +50,20 @@ private:
class ImageProxyModel : public QSortFilterProxyModel class ImageProxyModel : public QSortFilterProxyModel
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY(ImageSqlModel *imageModel READ imageModel)
public: public:
explicit ImageProxyModel(QObject *parent = nullptr); explicit ImageProxyModel(QObject *parent = nullptr);
~ImageProxyModel() = default;
ImageSqlModel *imageModel();
public slots:
Q_INVOKABLE QVariantMap getImage(const int &row);
Q_INVOKABLE void deleteImage(const int &row);
private:
ImageSqlModel *m_imageModel;
}; };

View file

@ -243,9 +243,22 @@ QVariantMap PresentationSqlModel::getPresentation(const int &row) {
PresentationProxyModel::PresentationProxyModel(QObject *parent) PresentationProxyModel::PresentationProxyModel(QObject *parent)
:QSortFilterProxyModel(parent) :QSortFilterProxyModel(parent)
{ {
PresentationSqlModel *presentationModel = new PresentationSqlModel; m_presentationModel = new PresentationSqlModel;
setSourceModel(presentationModel); setSourceModel(m_presentationModel);
setDynamicSortFilter(true); setDynamicSortFilter(true);
setFilterRole(Qt::UserRole + 1); setFilterRole(Qt::UserRole + 1);
setFilterCaseSensitivity(Qt::CaseInsensitive); setFilterCaseSensitivity(Qt::CaseInsensitive);
} }
PresentationSqlModel *PresentationProxyModel::presentationModel() {
return m_presentationModel;
}
QVariantMap PresentationProxyModel::getPresentation(const int &row) {
return QVariantMap();
}
void PresentationProxyModel::deletePresentation(const int &row) {
auto model = qobject_cast<PresentationSqlModel *>(sourceModel());
model->deletePresentation(row);
}

View file

@ -53,14 +53,24 @@ private:
int m_pageCount; int m_pageCount;
}; };
class PresentationProxyModel : public QSortFilterProxyModel class PresentationProxyModel : public QSortFilterProxyModel
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY(PresentationSqlModel *presentationModel READ presentationModel)
public: public:
explicit PresentationProxyModel(QObject *parent = nullptr); explicit PresentationProxyModel(QObject *parent = nullptr);
~PresentationProxyModel() = default;
PresentationSqlModel *presentationModel();
public slots:
Q_INVOKABLE QVariantMap getPresentation(const int &row);
Q_INVOKABLE void deletePresentation(const int &row);
private:
PresentationSqlModel *m_presentationModel;
}; };
#endif //PRESENTATIONSQLMODEL_H #endif //PRESENTATIONSQLMODEL_H

View file

@ -714,9 +714,22 @@ void SongSqlModel::updateFontSize(const int &row, const int &fontSize) {
SongProxyModel::SongProxyModel(QObject *parent) SongProxyModel::SongProxyModel(QObject *parent)
:QSortFilterProxyModel(parent) :QSortFilterProxyModel(parent)
{ {
SongSqlModel *songModel = new SongSqlModel; m_songModel = new SongSqlModel;
setSourceModel(songModel); setSourceModel(m_songModel);
setDynamicSortFilter(true); setDynamicSortFilter(true);
setFilterRole(Qt::UserRole + 1); setFilterRole(Qt::UserRole + 1);
setFilterCaseSensitivity(Qt::CaseInsensitive); setFilterCaseSensitivity(Qt::CaseInsensitive);
} }
SongSqlModel *SongProxyModel::songModel() {
return m_songModel;
}
QVariantMap SongProxyModel::getSong(const int &row) {
return QVariantMap();
}
void SongProxyModel::deleteSong(const int &row) {
auto model = qobject_cast<SongSqlModel *>(sourceModel());
model->deleteSong(row);
}

View file

@ -111,11 +111,20 @@ private:
class SongProxyModel : public QSortFilterProxyModel class SongProxyModel : public QSortFilterProxyModel
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY(SongSqlModel *songModel READ songModel)
public: public:
explicit SongProxyModel(QObject *parent = nullptr); explicit SongProxyModel(QObject *parent = nullptr);
~SongProxyModel() = default;
SongSqlModel *songModel();
public slots:
Q_INVOKABLE QVariantMap getSong(const int &row);
Q_INVOKABLE void deleteSong(const int &row);
private:
SongSqlModel *m_songModel;
}; };

View file

@ -48,7 +48,7 @@ Item {
anchors {left: songLabel.right anchors {left: songLabel.right
verticalCenter: songLabel.verticalCenter verticalCenter: songLabel.verticalCenter
leftMargin: 15} leftMargin: 15}
text: songSqlModel.rowCount() text: songProxyModel.songModel.rowCount()
color: Kirigami.Theme.disabledTextColor color: Kirigami.Theme.disabledTextColor
} }
@ -288,7 +288,7 @@ Item {
y: songClickHandler.mouseY + 10 y: songClickHandler.mouseY + 10
Kirigami.Action { Kirigami.Action {
text: "delete" text: "delete"
onTriggered: songSqlModel.deleteSong(index) onTriggered: songProxyModel.deleteSong(index)
} }
} }
} }
@ -312,8 +312,8 @@ Item {
} }
function newSong() { function newSong() {
songSqlModel.newSong(); songProxyModel.songModel.newSong();
songLibraryList.currentIndex = songSqlModel.rowCount() - 1; songLibraryList.currentIndex = songProxyModel.songModel.rowCount() - 1;
if (!editMode) if (!editMode)
editMode = true; editMode = true;
editType = "song"; editType = "song";
@ -343,7 +343,7 @@ Item {
anchors {left: videoLabel.right anchors {left: videoLabel.right
verticalCenter: videoLabel.verticalCenter verticalCenter: videoLabel.verticalCenter
leftMargin: 15} leftMargin: 15}
text: videoSqlModel.rowCount() text: videoProxyModel.videoModel.rowCount()
font.pixelSize: 15 font.pixelSize: 15
color: Kirigami.Theme.disabledTextColor color: Kirigami.Theme.disabledTextColor
} }
@ -586,7 +586,7 @@ Item {
rightClickVideoMenu.popup() rightClickVideoMenu.popup()
else{ else{
videoLibraryList.currentIndex = index videoLibraryList.currentIndex = index
const video = videoSqlModel.getVideo(videoLibraryList.currentIndex); const video = videoProxyModel.videoModel.getVideo(videoLibraryList.currentIndex);
if (!editMode) if (!editMode)
editMode = true; editMode = true;
editType = "video"; editType = "video";
@ -602,7 +602,7 @@ Item {
y: videoClickHandler.mouseY + 10 y: videoClickHandler.mouseY + 10
Kirigami.Action { Kirigami.Action {
text: "delete" text: "delete"
onTriggered: videoSqlModel.deleteVideo(index) onTriggered: videoProxyModel.deleteVideo(index)
} }
} }
} }
@ -614,7 +614,6 @@ Item {
/* anchors.left: videoLibraryList.right */ /* anchors.left: videoLibraryList.right */
active: hovered || pressed active: hovered || pressed
} }
} }
Rectangle { Rectangle {
@ -639,7 +638,7 @@ Item {
anchors {left: imageLabel.right anchors {left: imageLabel.right
verticalCenter: imageLabel.verticalCenter verticalCenter: imageLabel.verticalCenter
leftMargin: 15} leftMargin: 15}
text: imageSqlModel.rowCount() text: imageProxyModel.imageModel.rowCount()
font.pixelSize: 15 font.pixelSize: 15
color: Kirigami.Theme.disabledTextColor color: Kirigami.Theme.disabledTextColor
} }
@ -881,7 +880,7 @@ Item {
rightClickImageMenu.popup() rightClickImageMenu.popup()
else{ else{
imageLibraryList.currentIndex = index imageLibraryList.currentIndex = index
const image = imageSqlModel.getImage(imageLibraryList.currentIndex); const image = imageProxyModel.imageModel.getImage(imageLibraryList.currentIndex);
if (!editMode) if (!editMode)
editMode = true; editMode = true;
editType = "image"; editType = "image";
@ -897,7 +896,7 @@ Item {
y: imageClickHandler.mouseY + 10 y: imageClickHandler.mouseY + 10
Kirigami.Action { Kirigami.Action {
text: "delete" text: "delete"
onTriggered: imageSqlModel.deleteImage(index) onTriggered: imageProxyModel.deleteImage(index)
} }
} }
} }
@ -933,7 +932,7 @@ Item {
anchors {left: presentationLabel.right anchors {left: presentationLabel.right
verticalCenter: presentationLabel.verticalCenter verticalCenter: presentationLabel.verticalCenter
leftMargin: 10} leftMargin: 10}
text: presSqlModel.rowCount() text: presProxyModel.presentationModel.rowCount()
font.pixelSize: 15 font.pixelSize: 15
color: Kirigami.Theme.disabledTextColor color: Kirigami.Theme.disabledTextColor
} }
@ -1166,7 +1165,7 @@ Item {
rightClickPresMenu.popup() rightClickPresMenu.popup()
else{ else{
presentationLibraryList.currentIndex = index presentationLibraryList.currentIndex = index
const pres = presSqlModel.getPresentation(presentationLibraryList.currentIndex); const pres = presProxyModel.presentationModel.getPresentation(presentationLibraryList.currentIndex);
if (!editMode) if (!editMode)
editMode = true; editMode = true;
editType = "presentation"; editType = "presentation";
@ -1182,7 +1181,7 @@ Item {
y: presClickHandler.mouseY + 10 y: presClickHandler.mouseY + 10
Kirigami.Action { Kirigami.Action {
text: "delete" text: "delete"
onTriggered: presSqlModel.deletePresentation(index) onTriggered: presProxyModel.deletePresentation(index)
} }
} }
} }
@ -1355,11 +1354,11 @@ Item {
onExited: overlay = false onExited: overlay = false
function addVideo(url) { function addVideo(url) {
videoSqlModel.newVideo(url); videoProxyModel.videoModel.newVideo(url);
selectedLibrary = "videos"; selectedLibrary = "videos";
videoLibraryList.currentIndex = videoSqlModel.rowCount(); videoLibraryList.currentIndex = videoProxyModel.videoModel.rowCount();
console.log(videoSqlModel.getVideo(videoLibraryList.currentIndex)); console.log(videoProxyModel.videoModel.getVideo(videoLibraryList.currentIndex));
const video = videoSqlModel.getVideo(videoLibraryList.currentIndex); const video = videoProxyModel.videoModel.getVideo(videoLibraryList.currentIndex);
showPassiveNotification("newest video: " + video.title); showPassiveNotification("newest video: " + video.title);
if (!editMode) if (!editMode)
editMode = true; editMode = true;
@ -1367,11 +1366,11 @@ Item {
} }
function addImg(url) { function addImg(url) {
imageSqlModel.newImage(url); imageProxyModel.imageModel.newImage(url);
selectedLibrary = "images"; selectedLibrary = "images";
imageLibraryList.currentIndex = imageSqlModel.rowCount(); imageLibraryList.currentIndex = imageProxyModel.imageModel.rowCount();
console.log(imageSqlModel.getImage(imageLibraryList.currentIndex)); console.log(imageProxyModel.imageModel.getImage(imageLibraryList.currentIndex));
const image = imageSqlModel.getImage(imageLibraryList.currentIndex); const image = imageProxyModel.imageModel.getImage(imageLibraryList.currentIndex);
showPassiveNotification("newest image: " + image.title); showPassiveNotification("newest image: " + image.title);
if (!editMode) if (!editMode)
editMode = true; editMode = true;
@ -1385,11 +1384,11 @@ Item {
console.log(pdf.status); console.log(pdf.status);
console.log("PAGECOUNT: " + pdf.pageCount); console.log("PAGECOUNT: " + pdf.pageCount);
} }
presSqlModel.newPresentation(url, pdf.pageCount); presProxyModel.presentationModel.newPresentation(url, pdf.pageCount);
selectedLibrary = "presentations"; selectedLibrary = "presentations";
presentationLibraryList.currentIndex = presSqlModel.rowCount(); presentationLibraryList.currentIndex = presProxyModel.presentationModel.rowCount();
console.log(presSqlModel.getPresentation(presentationLibraryList.currentIndex)); console.log(presProxyModel.presentationModel.getPresentation(presentationLibraryList.currentIndex));
const presentation = presSqlModel.getImage(presentationLibraryList.currentIndex); const presentation = presProxyModel.presentationModel.getImage(presentationLibraryList.currentIndex);
showPassiveNotification("newest image: " + presentation.title); showPassiveNotification("newest image: " + presentation.title);
if (!editMode) if (!editMode)
editMode = true; editMode = true;
@ -1459,29 +1458,9 @@ Item {
border.color: overlay ? Kirigami.Theme.hoverColor : "#00000000" border.color: overlay ? Kirigami.Theme.hoverColor : "#00000000"
} }
// used for detecting number of pages without the need for PoDoFo
PdfDocument { PdfDocument {
id: pdf id: pdf
} }
MpvObject {
id: thumbnailer
useHwdec: true
enableAudio: false
width: 0
height: 0
Component.onCompleted: console.log("ready")
onFileLoaded: {
thumbnailer.pause();
console.log("FILE: " + thumbnailer.mediaTitle);
thumbnailer.screenshotToFile(thumbnailFile(thumbnailer.mediaTitle));
showPassiveNotification("Screenshot Taken to: " + thumbnailFile(thumbnailer.mediaTitle));
thumbnailer.stop();
}
function thumbnailFile(title) {
const thumbnailFolder = Labs.StandardPaths.writableLocation(Labs.StandardPaths.AppDataLocation) + "/thumbnails/";
return Qt.resolvedUrl(thumbnailFolder + title);
}
}
} }
} }

View file

@ -321,7 +321,7 @@ Item {
function changeSong(index) { function changeSong(index) {
clearSlides(); clearSlides();
console.log(index); console.log(index);
const s = songsqlmodel.getSong(index); const s = songProxyModel.songModel.getSong(index);
song = s; song = s;
songLyrics = s.lyrics; songLyrics = s.lyrics;
songIndex = index; songIndex = index;
@ -344,41 +344,41 @@ Item {
} }
function updateLyrics(lyrics) { function updateLyrics(lyrics) {
songsqlmodel.updateLyrics(songIndex, lyrics); songProxyModel.songModel.updateLyrics(songIndex, lyrics);
songLyrics = lyrics; songLyrics = lyrics;
clearSlides(); clearSlides();
changeSlideText(songIndex); changeSlideText(songIndex);
} }
function updateTitle(title) { function updateTitle(title) {
songsqlmodel.updateTitle(songIndex, title) songProxyModel.songModel.updateTitle(songIndex, title)
} }
function updateAuthor(author) { function updateAuthor(author) {
songsqlmodel.updateAuthor(songIndex, author) songProxyModel.songModel.updateAuthor(songIndex, author)
} }
function updateAudio(audio) { function updateAudio(audio) {
songsqlmodel.updateAudio(songIndex, audio) songProxyModel.songModel.updateAudio(songIndex, audio)
} }
function updateCcli(ccli) { function updateCcli(ccli) {
songsqlmodel.updateCcli(songIndex, ccli) songProxyModel.songModel.updateCcli(songIndex, ccli)
} }
function updateVerseOrder(vorder) { function updateVerseOrder(vorder) {
songsqlmodel.updateVerseOrder(songIndex, vorder) songProxyModel.songModel.updateVerseOrder(songIndex, vorder)
} }
function updateAudioFile(file) { function updateAudioFile(file) {
songsqlmodel.updateAudio(songIndex, file); songProxyModel.songModel.updateAudio(songIndex, file);
} }
function updateBackground(background, backgroundType) { function updateBackground(background, backgroundType) {
song.backgroundType = backgroundType; song.backgroundType = backgroundType;
song.background = background; song.background = background;
songsqlmodel.updateBackground(songIndex, background); songProxyModel.songModel.updateBackground(songIndex, background);
songsqlmodel.updateBackgroundType(songIndex, backgroundType); songProxyModel.songModel.updateBackgroundType(songIndex, backgroundType);
console.log("changed background"); console.log("changed background");
if (backgroundType === "image") { if (backgroundType === "image") {
//todo //todo
@ -395,23 +395,23 @@ Item {
function updateHorizontalTextAlignment(textAlignment) { function updateHorizontalTextAlignment(textAlignment) {
changeSlideHAlignment(textAlignment); changeSlideHAlignment(textAlignment);
songsqlmodel.updateHorizontalTextAlignment(songIndex, textAlignment); songProxyModel.songModel.updateHorizontalTextAlignment(songIndex, textAlignment);
} }
function updateVerticalTextAlignment(textAlignment) { function updateVerticalTextAlignment(textAlignment) {
changeSlideVAlignment(textAlignment); changeSlideVAlignment(textAlignment);
songsqlmodel.updateVerticalTextAlignment(songIndex, textAlignment) songProxyModel.songModel.updateVerticalTextAlignment(songIndex, textAlignment)
} }
function updateFont(font) { function updateFont(font) {
changeSlideFont(font, false); changeSlideFont(font, false);
songsqlmodel.updateFont(songIndex, font); songProxyModel.songModel.updateFont(songIndex, font);
song.font = font; song.font = font;
} }
function updateFontSize(fontSize) { function updateFontSize(fontSize) {
changeSlideFontSize(fontSize, false); changeSlideFontSize(fontSize, false);
songsqlmodel.updateFontSize(songIndex, fontSize); songProxyModel.songModel.updateFontSize(songIndex, fontSize);
song.fontSize = fontSize; song.fontSize = fontSize;
} }
@ -468,7 +468,7 @@ Item {
function changeSlideText(id) { function changeSlideText(id) {
/* console.log("Here are the verses: " + verses); */ /* console.log("Here are the verses: " + verses); */
const verses = songsqlmodel.getLyricList(id); const verses = songProxyModel.songModel.getLyricList(id);
verses.forEach(slideEditor.appendVerse); verses.forEach(slideEditor.appendVerse);
/* slideEditor.loadVideo(); */ /* slideEditor.loadVideo(); */
} }