ok I added some proxy models to all sql models, but they aint done..
This commit is contained in:
parent
cc501873c1
commit
c9f6fc4d1b
8 changed files with 117 additions and 71 deletions
|
@ -208,9 +208,22 @@ QVariantMap ImageSqlModel::getImage(const int &row) {
|
|||
ImageProxyModel::ImageProxyModel(QObject *parent)
|
||||
:QSortFilterProxyModel(parent)
|
||||
{
|
||||
ImageSqlModel *imageModel = new ImageSqlModel;
|
||||
setSourceModel(imageModel);
|
||||
m_imageModel = new ImageSqlModel;
|
||||
setSourceModel(m_imageModel);
|
||||
setDynamicSortFilter(true);
|
||||
setFilterRole(Qt::UserRole + 1);
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -50,11 +50,20 @@ private:
|
|||
class ImageProxyModel : public QSortFilterProxyModel
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(ImageSqlModel *imageModel READ imageModel)
|
||||
|
||||
public:
|
||||
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;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -243,9 +243,22 @@ QVariantMap PresentationSqlModel::getPresentation(const int &row) {
|
|||
PresentationProxyModel::PresentationProxyModel(QObject *parent)
|
||||
:QSortFilterProxyModel(parent)
|
||||
{
|
||||
PresentationSqlModel *presentationModel = new PresentationSqlModel;
|
||||
setSourceModel(presentationModel);
|
||||
m_presentationModel = new PresentationSqlModel;
|
||||
setSourceModel(m_presentationModel);
|
||||
setDynamicSortFilter(true);
|
||||
setFilterRole(Qt::UserRole + 1);
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -53,14 +53,24 @@ private:
|
|||
int m_pageCount;
|
||||
};
|
||||
|
||||
|
||||
class PresentationProxyModel : public QSortFilterProxyModel
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(PresentationSqlModel *presentationModel READ presentationModel)
|
||||
|
||||
public:
|
||||
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
|
||||
|
|
|
@ -714,9 +714,22 @@ void SongSqlModel::updateFontSize(const int &row, const int &fontSize) {
|
|||
SongProxyModel::SongProxyModel(QObject *parent)
|
||||
:QSortFilterProxyModel(parent)
|
||||
{
|
||||
SongSqlModel *songModel = new SongSqlModel;
|
||||
setSourceModel(songModel);
|
||||
m_songModel = new SongSqlModel;
|
||||
setSourceModel(m_songModel);
|
||||
setDynamicSortFilter(true);
|
||||
setFilterRole(Qt::UserRole + 1);
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -111,11 +111,20 @@ private:
|
|||
class SongProxyModel : public QSortFilterProxyModel
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(SongSqlModel *songModel READ songModel)
|
||||
|
||||
public:
|
||||
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;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ Item {
|
|||
anchors {left: songLabel.right
|
||||
verticalCenter: songLabel.verticalCenter
|
||||
leftMargin: 15}
|
||||
text: songSqlModel.rowCount()
|
||||
text: songProxyModel.songModel.rowCount()
|
||||
color: Kirigami.Theme.disabledTextColor
|
||||
}
|
||||
|
||||
|
@ -288,7 +288,7 @@ Item {
|
|||
y: songClickHandler.mouseY + 10
|
||||
Kirigami.Action {
|
||||
text: "delete"
|
||||
onTriggered: songSqlModel.deleteSong(index)
|
||||
onTriggered: songProxyModel.deleteSong(index)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -312,8 +312,8 @@ Item {
|
|||
}
|
||||
|
||||
function newSong() {
|
||||
songSqlModel.newSong();
|
||||
songLibraryList.currentIndex = songSqlModel.rowCount() - 1;
|
||||
songProxyModel.songModel.newSong();
|
||||
songLibraryList.currentIndex = songProxyModel.songModel.rowCount() - 1;
|
||||
if (!editMode)
|
||||
editMode = true;
|
||||
editType = "song";
|
||||
|
@ -343,7 +343,7 @@ Item {
|
|||
anchors {left: videoLabel.right
|
||||
verticalCenter: videoLabel.verticalCenter
|
||||
leftMargin: 15}
|
||||
text: videoSqlModel.rowCount()
|
||||
text: videoProxyModel.videoModel.rowCount()
|
||||
font.pixelSize: 15
|
||||
color: Kirigami.Theme.disabledTextColor
|
||||
}
|
||||
|
@ -586,7 +586,7 @@ Item {
|
|||
rightClickVideoMenu.popup()
|
||||
else{
|
||||
videoLibraryList.currentIndex = index
|
||||
const video = videoSqlModel.getVideo(videoLibraryList.currentIndex);
|
||||
const video = videoProxyModel.videoModel.getVideo(videoLibraryList.currentIndex);
|
||||
if (!editMode)
|
||||
editMode = true;
|
||||
editType = "video";
|
||||
|
@ -602,7 +602,7 @@ Item {
|
|||
y: videoClickHandler.mouseY + 10
|
||||
Kirigami.Action {
|
||||
text: "delete"
|
||||
onTriggered: videoSqlModel.deleteVideo(index)
|
||||
onTriggered: videoProxyModel.deleteVideo(index)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -614,7 +614,6 @@ Item {
|
|||
/* anchors.left: videoLibraryList.right */
|
||||
active: hovered || pressed
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
|
@ -639,7 +638,7 @@ Item {
|
|||
anchors {left: imageLabel.right
|
||||
verticalCenter: imageLabel.verticalCenter
|
||||
leftMargin: 15}
|
||||
text: imageSqlModel.rowCount()
|
||||
text: imageProxyModel.imageModel.rowCount()
|
||||
font.pixelSize: 15
|
||||
color: Kirigami.Theme.disabledTextColor
|
||||
}
|
||||
|
@ -881,7 +880,7 @@ Item {
|
|||
rightClickImageMenu.popup()
|
||||
else{
|
||||
imageLibraryList.currentIndex = index
|
||||
const image = imageSqlModel.getImage(imageLibraryList.currentIndex);
|
||||
const image = imageProxyModel.imageModel.getImage(imageLibraryList.currentIndex);
|
||||
if (!editMode)
|
||||
editMode = true;
|
||||
editType = "image";
|
||||
|
@ -897,7 +896,7 @@ Item {
|
|||
y: imageClickHandler.mouseY + 10
|
||||
Kirigami.Action {
|
||||
text: "delete"
|
||||
onTriggered: imageSqlModel.deleteImage(index)
|
||||
onTriggered: imageProxyModel.deleteImage(index)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -933,7 +932,7 @@ Item {
|
|||
anchors {left: presentationLabel.right
|
||||
verticalCenter: presentationLabel.verticalCenter
|
||||
leftMargin: 10}
|
||||
text: presSqlModel.rowCount()
|
||||
text: presProxyModel.presentationModel.rowCount()
|
||||
font.pixelSize: 15
|
||||
color: Kirigami.Theme.disabledTextColor
|
||||
}
|
||||
|
@ -1166,7 +1165,7 @@ Item {
|
|||
rightClickPresMenu.popup()
|
||||
else{
|
||||
presentationLibraryList.currentIndex = index
|
||||
const pres = presSqlModel.getPresentation(presentationLibraryList.currentIndex);
|
||||
const pres = presProxyModel.presentationModel.getPresentation(presentationLibraryList.currentIndex);
|
||||
if (!editMode)
|
||||
editMode = true;
|
||||
editType = "presentation";
|
||||
|
@ -1182,7 +1181,7 @@ Item {
|
|||
y: presClickHandler.mouseY + 10
|
||||
Kirigami.Action {
|
||||
text: "delete"
|
||||
onTriggered: presSqlModel.deletePresentation(index)
|
||||
onTriggered: presProxyModel.deletePresentation(index)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1355,11 +1354,11 @@ Item {
|
|||
onExited: overlay = false
|
||||
|
||||
function addVideo(url) {
|
||||
videoSqlModel.newVideo(url);
|
||||
videoProxyModel.videoModel.newVideo(url);
|
||||
selectedLibrary = "videos";
|
||||
videoLibraryList.currentIndex = videoSqlModel.rowCount();
|
||||
console.log(videoSqlModel.getVideo(videoLibraryList.currentIndex));
|
||||
const video = videoSqlModel.getVideo(videoLibraryList.currentIndex);
|
||||
videoLibraryList.currentIndex = videoProxyModel.videoModel.rowCount();
|
||||
console.log(videoProxyModel.videoModel.getVideo(videoLibraryList.currentIndex));
|
||||
const video = videoProxyModel.videoModel.getVideo(videoLibraryList.currentIndex);
|
||||
showPassiveNotification("newest video: " + video.title);
|
||||
if (!editMode)
|
||||
editMode = true;
|
||||
|
@ -1367,11 +1366,11 @@ Item {
|
|||
}
|
||||
|
||||
function addImg(url) {
|
||||
imageSqlModel.newImage(url);
|
||||
imageProxyModel.imageModel.newImage(url);
|
||||
selectedLibrary = "images";
|
||||
imageLibraryList.currentIndex = imageSqlModel.rowCount();
|
||||
console.log(imageSqlModel.getImage(imageLibraryList.currentIndex));
|
||||
const image = imageSqlModel.getImage(imageLibraryList.currentIndex);
|
||||
imageLibraryList.currentIndex = imageProxyModel.imageModel.rowCount();
|
||||
console.log(imageProxyModel.imageModel.getImage(imageLibraryList.currentIndex));
|
||||
const image = imageProxyModel.imageModel.getImage(imageLibraryList.currentIndex);
|
||||
showPassiveNotification("newest image: " + image.title);
|
||||
if (!editMode)
|
||||
editMode = true;
|
||||
|
@ -1385,11 +1384,11 @@ Item {
|
|||
console.log(pdf.status);
|
||||
console.log("PAGECOUNT: " + pdf.pageCount);
|
||||
}
|
||||
presSqlModel.newPresentation(url, pdf.pageCount);
|
||||
presProxyModel.presentationModel.newPresentation(url, pdf.pageCount);
|
||||
selectedLibrary = "presentations";
|
||||
presentationLibraryList.currentIndex = presSqlModel.rowCount();
|
||||
console.log(presSqlModel.getPresentation(presentationLibraryList.currentIndex));
|
||||
const presentation = presSqlModel.getImage(presentationLibraryList.currentIndex);
|
||||
presentationLibraryList.currentIndex = presProxyModel.presentationModel.rowCount();
|
||||
console.log(presProxyModel.presentationModel.getPresentation(presentationLibraryList.currentIndex));
|
||||
const presentation = presProxyModel.presentationModel.getImage(presentationLibraryList.currentIndex);
|
||||
showPassiveNotification("newest image: " + presentation.title);
|
||||
if (!editMode)
|
||||
editMode = true;
|
||||
|
@ -1459,29 +1458,9 @@ Item {
|
|||
border.color: overlay ? Kirigami.Theme.hoverColor : "#00000000"
|
||||
}
|
||||
|
||||
// used for detecting number of pages without the need for PoDoFo
|
||||
PdfDocument {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -321,7 +321,7 @@ Item {
|
|||
function changeSong(index) {
|
||||
clearSlides();
|
||||
console.log(index);
|
||||
const s = songsqlmodel.getSong(index);
|
||||
const s = songProxyModel.songModel.getSong(index);
|
||||
song = s;
|
||||
songLyrics = s.lyrics;
|
||||
songIndex = index;
|
||||
|
@ -344,41 +344,41 @@ Item {
|
|||
}
|
||||
|
||||
function updateLyrics(lyrics) {
|
||||
songsqlmodel.updateLyrics(songIndex, lyrics);
|
||||
songProxyModel.songModel.updateLyrics(songIndex, lyrics);
|
||||
songLyrics = lyrics;
|
||||
clearSlides();
|
||||
changeSlideText(songIndex);
|
||||
}
|
||||
|
||||
function updateTitle(title) {
|
||||
songsqlmodel.updateTitle(songIndex, title)
|
||||
songProxyModel.songModel.updateTitle(songIndex, title)
|
||||
}
|
||||
|
||||
function updateAuthor(author) {
|
||||
songsqlmodel.updateAuthor(songIndex, author)
|
||||
songProxyModel.songModel.updateAuthor(songIndex, author)
|
||||
}
|
||||
|
||||
function updateAudio(audio) {
|
||||
songsqlmodel.updateAudio(songIndex, audio)
|
||||
songProxyModel.songModel.updateAudio(songIndex, audio)
|
||||
}
|
||||
|
||||
function updateCcli(ccli) {
|
||||
songsqlmodel.updateCcli(songIndex, ccli)
|
||||
songProxyModel.songModel.updateCcli(songIndex, ccli)
|
||||
}
|
||||
|
||||
function updateVerseOrder(vorder) {
|
||||
songsqlmodel.updateVerseOrder(songIndex, vorder)
|
||||
songProxyModel.songModel.updateVerseOrder(songIndex, vorder)
|
||||
}
|
||||
|
||||
function updateAudioFile(file) {
|
||||
songsqlmodel.updateAudio(songIndex, file);
|
||||
songProxyModel.songModel.updateAudio(songIndex, file);
|
||||
}
|
||||
|
||||
function updateBackground(background, backgroundType) {
|
||||
song.backgroundType = backgroundType;
|
||||
song.background = background;
|
||||
songsqlmodel.updateBackground(songIndex, background);
|
||||
songsqlmodel.updateBackgroundType(songIndex, backgroundType);
|
||||
songProxyModel.songModel.updateBackground(songIndex, background);
|
||||
songProxyModel.songModel.updateBackgroundType(songIndex, backgroundType);
|
||||
console.log("changed background");
|
||||
if (backgroundType === "image") {
|
||||
//todo
|
||||
|
@ -395,23 +395,23 @@ Item {
|
|||
|
||||
function updateHorizontalTextAlignment(textAlignment) {
|
||||
changeSlideHAlignment(textAlignment);
|
||||
songsqlmodel.updateHorizontalTextAlignment(songIndex, textAlignment);
|
||||
songProxyModel.songModel.updateHorizontalTextAlignment(songIndex, textAlignment);
|
||||
}
|
||||
|
||||
function updateVerticalTextAlignment(textAlignment) {
|
||||
changeSlideVAlignment(textAlignment);
|
||||
songsqlmodel.updateVerticalTextAlignment(songIndex, textAlignment)
|
||||
songProxyModel.songModel.updateVerticalTextAlignment(songIndex, textAlignment)
|
||||
}
|
||||
|
||||
function updateFont(font) {
|
||||
changeSlideFont(font, false);
|
||||
songsqlmodel.updateFont(songIndex, font);
|
||||
songProxyModel.songModel.updateFont(songIndex, font);
|
||||
song.font = font;
|
||||
}
|
||||
|
||||
function updateFontSize(fontSize) {
|
||||
changeSlideFontSize(fontSize, false);
|
||||
songsqlmodel.updateFontSize(songIndex, fontSize);
|
||||
songProxyModel.songModel.updateFontSize(songIndex, fontSize);
|
||||
song.fontSize = fontSize;
|
||||
}
|
||||
|
||||
|
@ -468,7 +468,7 @@ Item {
|
|||
|
||||
function changeSlideText(id) {
|
||||
/* console.log("Here are the verses: " + verses); */
|
||||
const verses = songsqlmodel.getLyricList(id);
|
||||
const verses = songProxyModel.songModel.getLyricList(id);
|
||||
verses.forEach(slideEditor.appendVerse);
|
||||
/* slideEditor.loadVideo(); */
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue