refactoring for proxy models
This commit is contained in:
parent
3b35424a0c
commit
85318706fc
6 changed files with 68 additions and 57 deletions
|
@ -326,3 +326,7 @@ VideoProxyModel::VideoProxyModel(QObject *parent)
|
||||||
setFilterRole(Qt::UserRole + 1);
|
setFilterRole(Qt::UserRole + 1);
|
||||||
setFilterCaseSensitivity(Qt::CaseInsensitive);
|
setFilterCaseSensitivity(Qt::CaseInsensitive);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QVariantMap VideoProxyModel::getVideo(const int &row) {
|
||||||
|
return QVariantMap();
|
||||||
|
}
|
||||||
|
|
|
@ -72,7 +72,8 @@ class VideoProxyModel : public QSortFilterProxyModel
|
||||||
public:
|
public:
|
||||||
explicit VideoProxyModel(QObject *parent = nullptr);
|
explicit VideoProxyModel(QObject *parent = nullptr);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
Q_INVOKABLE QVariantMap getVideo(const int &row);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //VIDEOSQLMODEL_H
|
#endif //VIDEOSQLMODEL_H
|
||||||
|
|
12
src/main.cpp
12
src/main.cpp
|
@ -172,10 +172,14 @@ int main(int argc, char *argv[])
|
||||||
qmlRegisterType<MpvObject>("mpv", 1, 0, "MpvObject");
|
qmlRegisterType<MpvObject>("mpv", 1, 0, "MpvObject");
|
||||||
|
|
||||||
//register our models
|
//register our models
|
||||||
qmlRegisterType<SongProxyModel>("org.presenter", 1, 0, "SongSqlModel");
|
qmlRegisterType<SongProxyModel>("org.presenter", 1, 0, "SongProxyModel");
|
||||||
qmlRegisterType<VideoProxyModel>("org.presenter", 1, 0, "VideoSqlModel");
|
qmlRegisterType<VideoProxyModel>("org.presenter", 1, 0, "VideoProxyModel");
|
||||||
qmlRegisterType<ImageProxyModel>("org.presenter", 1, 0, "ImageSqlModel");
|
qmlRegisterType<ImageProxyModel>("org.presenter", 1, 0, "ImageProxyModel");
|
||||||
qmlRegisterType<PresentationProxyModel>("org.presenter", 1, 0, "PresentationSqlModel");
|
qmlRegisterType<PresentationProxyModel>("org.presenter", 1, 0, "PresentationProxyModel");
|
||||||
|
qmlRegisterType<SongSqlModel>("org.presenter", 1, 0, "SongSqlModel");
|
||||||
|
qmlRegisterType<VideoSqlModel>("org.presenter", 1, 0, "VideoSqlModel");
|
||||||
|
qmlRegisterType<ImageSqlModel>("org.presenter", 1, 0, "ImageSqlModel");
|
||||||
|
qmlRegisterType<PresentationSqlModel>("org.presenter", 1, 0, "PresentationSqlModel");
|
||||||
qmlRegisterType<FileHelper>("org.presenter", 1, 0, "FileHelper");
|
qmlRegisterType<FileHelper>("org.presenter", 1, 0, "FileHelper");
|
||||||
qmlRegisterType<ServiceThing>("org.presenter", 1, 0, "ServiceThing");
|
qmlRegisterType<ServiceThing>("org.presenter", 1, 0, "ServiceThing");
|
||||||
qmlRegisterSingletonInstance("org.presenter", 1, 0,
|
qmlRegisterSingletonInstance("org.presenter", 1, 0,
|
||||||
|
|
|
@ -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: songSqlModel.rowCount()
|
||||||
color: Kirigami.Theme.disabledTextColor
|
color: Kirigami.Theme.disabledTextColor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ Item {
|
||||||
id: searchField
|
id: searchField
|
||||||
height: parent.height
|
height: parent.height
|
||||||
width: parent.width - 40
|
width: parent.width - 40
|
||||||
onAccepted: songsqlmodel.setFilterRegExp(searchField.text)
|
onAccepted: songProxyModel.setFilterRegularExpression(searchField.text)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* visible: selectedLibrary == "songs" */
|
/* visible: selectedLibrary == "songs" */
|
||||||
|
@ -146,7 +146,7 @@ Item {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.alignment: Qt.AlignTop
|
Layout.alignment: Qt.AlignTop
|
||||||
id: songLibraryList
|
id: songLibraryList
|
||||||
model: songsqlmodel
|
model: songProxyModel
|
||||||
delegate: songDelegate
|
delegate: songDelegate
|
||||||
state: "selected"
|
state: "selected"
|
||||||
|
|
||||||
|
@ -190,6 +190,8 @@ Item {
|
||||||
clip: true
|
clip: true
|
||||||
label: title
|
label: title
|
||||||
subtitle: author
|
subtitle: author
|
||||||
|
icon: "folder-music-symbolic"
|
||||||
|
iconSize: Kirigami.Units.gridUnit
|
||||||
supportsMouseEvents: false
|
supportsMouseEvents: false
|
||||||
backgroundColor: {
|
backgroundColor: {
|
||||||
if (parent.ListView.isCurrentItem) {
|
if (parent.ListView.isCurrentItem) {
|
||||||
|
@ -286,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: songSqlModel.deleteSong(index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -310,8 +312,8 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
function newSong() {
|
function newSong() {
|
||||||
songsqlmodel.newSong();
|
songSqlModel.newSong();
|
||||||
songLibraryList.currentIndex = songsqlmodel.rowCount() - 1;
|
songLibraryList.currentIndex = songSqlModel.rowCount() - 1;
|
||||||
if (!editMode)
|
if (!editMode)
|
||||||
editMode = true;
|
editMode = true;
|
||||||
editType = "song";
|
editType = "song";
|
||||||
|
@ -341,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: videoSqlModel.rowCount()
|
||||||
font.pixelSize: 15
|
font.pixelSize: 15
|
||||||
color: Kirigami.Theme.disabledTextColor
|
color: Kirigami.Theme.disabledTextColor
|
||||||
}
|
}
|
||||||
|
@ -429,7 +431,7 @@ Item {
|
||||||
id: searchField
|
id: searchField
|
||||||
height: parent.height
|
height: parent.height
|
||||||
width: parent.width - 40
|
width: parent.width - 40
|
||||||
onAccepted: videosqlmodel.setFilterRegExp(searchField.text)
|
onAccepted: videoProxyModel.setFilterRegularExpression(searchField.text)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* visible: selectedLibrary == "videos" */
|
/* visible: selectedLibrary == "videos" */
|
||||||
|
@ -450,7 +452,7 @@ Item {
|
||||||
Layout.preferredHeight: parent.height - 240
|
Layout.preferredHeight: parent.height - 240
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.alignment: Qt.AlignTop
|
Layout.alignment: Qt.AlignTop
|
||||||
model: videosqlmodel
|
model: videoProxyModel
|
||||||
delegate: videoDelegate
|
delegate: videoDelegate
|
||||||
clip: true
|
clip: true
|
||||||
state: "deselected"
|
state: "deselected"
|
||||||
|
@ -584,7 +586,7 @@ Item {
|
||||||
rightClickVideoMenu.popup()
|
rightClickVideoMenu.popup()
|
||||||
else{
|
else{
|
||||||
videoLibraryList.currentIndex = index
|
videoLibraryList.currentIndex = index
|
||||||
const video = videosqlmodel.getVideo(videoLibraryList.currentIndex);
|
const video = videoSqlModel.getVideo(videoLibraryList.currentIndex);
|
||||||
if (!editMode)
|
if (!editMode)
|
||||||
editMode = true;
|
editMode = true;
|
||||||
editType = "video";
|
editType = "video";
|
||||||
|
@ -600,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: videoSqlModel.deleteVideo(index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -637,7 +639,7 @@ Item {
|
||||||
anchors {left: imageLabel.right
|
anchors {left: imageLabel.right
|
||||||
verticalCenter: imageLabel.verticalCenter
|
verticalCenter: imageLabel.verticalCenter
|
||||||
leftMargin: 15}
|
leftMargin: 15}
|
||||||
text: imagesqlmodel.rowCount()
|
text: imageSqlModel.rowCount()
|
||||||
font.pixelSize: 15
|
font.pixelSize: 15
|
||||||
color: Kirigami.Theme.disabledTextColor
|
color: Kirigami.Theme.disabledTextColor
|
||||||
}
|
}
|
||||||
|
@ -725,7 +727,7 @@ Item {
|
||||||
id: searchField
|
id: searchField
|
||||||
height: parent.height
|
height: parent.height
|
||||||
width: parent.width - 40
|
width: parent.width - 40
|
||||||
onAccepted: imagesqlmodel.setFilterRegExp(searchField.text)
|
onAccepted: imageProxyModel.setFilterRegularExpression(searchField.text)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* visible: selectedLibrary == "images" */
|
/* visible: selectedLibrary == "images" */
|
||||||
|
@ -746,7 +748,7 @@ Item {
|
||||||
Layout.preferredHeight: parent.height - 240
|
Layout.preferredHeight: parent.height - 240
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.alignment: Qt.AlignTop
|
Layout.alignment: Qt.AlignTop
|
||||||
model: imagesqlmodel
|
model: imageProxyModel
|
||||||
delegate: imageDelegate
|
delegate: imageDelegate
|
||||||
clip: true
|
clip: true
|
||||||
state: "deselected"
|
state: "deselected"
|
||||||
|
@ -879,7 +881,7 @@ Item {
|
||||||
rightClickImageMenu.popup()
|
rightClickImageMenu.popup()
|
||||||
else{
|
else{
|
||||||
imageLibraryList.currentIndex = index
|
imageLibraryList.currentIndex = index
|
||||||
const image = imagesqlmodel.getImage(imageLibraryList.currentIndex);
|
const image = imageSqlModel.getImage(imageLibraryList.currentIndex);
|
||||||
if (!editMode)
|
if (!editMode)
|
||||||
editMode = true;
|
editMode = true;
|
||||||
editType = "image";
|
editType = "image";
|
||||||
|
@ -895,7 +897,7 @@ Item {
|
||||||
y: imageClickHandler.mouseY + 10
|
y: imageClickHandler.mouseY + 10
|
||||||
Kirigami.Action {
|
Kirigami.Action {
|
||||||
text: "delete"
|
text: "delete"
|
||||||
onTriggered: imagesqlmodel.deleteImage(index)
|
onTriggered: imageSqlModel.deleteImage(index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -931,7 +933,7 @@ Item {
|
||||||
anchors {left: presentationLabel.right
|
anchors {left: presentationLabel.right
|
||||||
verticalCenter: presentationLabel.verticalCenter
|
verticalCenter: presentationLabel.verticalCenter
|
||||||
leftMargin: 10}
|
leftMargin: 10}
|
||||||
text: pressqlmodel.rowCount()
|
text: presSqlModel.rowCount()
|
||||||
font.pixelSize: 15
|
font.pixelSize: 15
|
||||||
color: Kirigami.Theme.disabledTextColor
|
color: Kirigami.Theme.disabledTextColor
|
||||||
}
|
}
|
||||||
|
@ -1019,7 +1021,7 @@ Item {
|
||||||
id: searchField
|
id: searchField
|
||||||
height: parent.height
|
height: parent.height
|
||||||
width: parent.width - 40
|
width: parent.width - 40
|
||||||
onAccepted: pressqlmodel.setFilterRegExp(searchField.text)
|
onAccepted: presProxyModel.setFilterRegularExpression(searchField.text)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* visible: selectedLibrary == "presentations" */
|
/* visible: selectedLibrary == "presentations" */
|
||||||
|
@ -1041,7 +1043,7 @@ Item {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.alignment: Qt.AlignTop
|
Layout.alignment: Qt.AlignTop
|
||||||
clip: true
|
clip: true
|
||||||
model: pressqlmodel
|
model: presProxyModel
|
||||||
delegate: presDelegate
|
delegate: presDelegate
|
||||||
state: "deselected"
|
state: "deselected"
|
||||||
|
|
||||||
|
@ -1084,6 +1086,8 @@ Item {
|
||||||
height: selectedLibrary == "presentations" ? 50 : 0
|
height: selectedLibrary == "presentations" ? 50 : 0
|
||||||
clip: true
|
clip: true
|
||||||
label: title
|
label: title
|
||||||
|
icon: "x-office-presentation-symbolic"
|
||||||
|
iconSize: Kirigami.Units.gridUnit
|
||||||
/* subtitle: author */
|
/* subtitle: author */
|
||||||
supportsMouseEvents: false
|
supportsMouseEvents: false
|
||||||
backgroundColor: {
|
backgroundColor: {
|
||||||
|
@ -1162,7 +1166,7 @@ Item {
|
||||||
rightClickPresMenu.popup()
|
rightClickPresMenu.popup()
|
||||||
else{
|
else{
|
||||||
presentationLibraryList.currentIndex = index
|
presentationLibraryList.currentIndex = index
|
||||||
const pres = pressqlmodel.getPresentation(presentationLibraryList.currentIndex);
|
const pres = presSqlModel.getPresentation(presentationLibraryList.currentIndex);
|
||||||
if (!editMode)
|
if (!editMode)
|
||||||
editMode = true;
|
editMode = true;
|
||||||
editType = "presentation";
|
editType = "presentation";
|
||||||
|
@ -1178,7 +1182,7 @@ Item {
|
||||||
y: presClickHandler.mouseY + 10
|
y: presClickHandler.mouseY + 10
|
||||||
Kirigami.Action {
|
Kirigami.Action {
|
||||||
text: "delete"
|
text: "delete"
|
||||||
onTriggered: pressqlmodel.deletePresentation(index)
|
onTriggered: presSqlModel.deletePresentation(index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1351,11 +1355,11 @@ Item {
|
||||||
onExited: overlay = false
|
onExited: overlay = false
|
||||||
|
|
||||||
function addVideo(url) {
|
function addVideo(url) {
|
||||||
videosqlmodel.newVideo(url);
|
videoSqlModel.newVideo(url);
|
||||||
selectedLibrary = "videos";
|
selectedLibrary = "videos";
|
||||||
videoLibraryList.currentIndex = videosqlmodel.rowCount();
|
videoLibraryList.currentIndex = videoSqlModel.rowCount();
|
||||||
console.log(videosqlmodel.getVideo(videoLibraryList.currentIndex));
|
console.log(videoSqlModel.getVideo(videoLibraryList.currentIndex));
|
||||||
const video = videosqlmodel.getVideo(videoLibraryList.currentIndex);
|
const video = videoSqlModel.getVideo(videoLibraryList.currentIndex);
|
||||||
showPassiveNotification("newest video: " + video.title);
|
showPassiveNotification("newest video: " + video.title);
|
||||||
if (!editMode)
|
if (!editMode)
|
||||||
editMode = true;
|
editMode = true;
|
||||||
|
@ -1363,11 +1367,11 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
function addImg(url) {
|
function addImg(url) {
|
||||||
imagesqlmodel.newImage(url);
|
imageSqlModel.newImage(url);
|
||||||
selectedLibrary = "images";
|
selectedLibrary = "images";
|
||||||
imageLibraryList.currentIndex = imagesqlmodel.rowCount();
|
imageLibraryList.currentIndex = imageSqlModel.rowCount();
|
||||||
console.log(imagesqlmodel.getImage(imageLibraryList.currentIndex));
|
console.log(imageSqlModel.getImage(imageLibraryList.currentIndex));
|
||||||
const image = imagesqlmodel.getImage(imageLibraryList.currentIndex);
|
const image = imageSqlModel.getImage(imageLibraryList.currentIndex);
|
||||||
showPassiveNotification("newest image: " + image.title);
|
showPassiveNotification("newest image: " + image.title);
|
||||||
if (!editMode)
|
if (!editMode)
|
||||||
editMode = true;
|
editMode = true;
|
||||||
|
@ -1381,11 +1385,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);
|
presSqlModel.newPresentation(url, pdf.pageCount);
|
||||||
selectedLibrary = "presentations";
|
selectedLibrary = "presentations";
|
||||||
presentationLibraryList.currentIndex = pressqlmodel.rowCount();
|
presentationLibraryList.currentIndex = presSqlModel.rowCount();
|
||||||
console.log(pressqlmodel.getPresentation(presentationLibraryList.currentIndex));
|
console.log(presSqlModel.getPresentation(presentationLibraryList.currentIndex));
|
||||||
const presentation = pressqlmodel.getImage(presentationLibraryList.currentIndex);
|
const presentation = presSqlModel.getImage(presentationLibraryList.currentIndex);
|
||||||
showPassiveNotification("newest image: " + presentation.title);
|
showPassiveNotification("newest image: " + presentation.title);
|
||||||
if (!editMode)
|
if (!editMode)
|
||||||
editMode = true;
|
editMode = true;
|
||||||
|
|
|
@ -132,25 +132,16 @@ Controls.Page {
|
||||||
id: pWindow
|
id: pWindow
|
||||||
}
|
}
|
||||||
|
|
||||||
SongSqlModel {
|
SongProxyModel { id: songProxyModel }
|
||||||
id: songsqlmodel
|
VideoProxyModel { id: videoProxyModel }
|
||||||
}
|
ImageProxyModel { id: imageProxyModel }
|
||||||
|
PresentationProxyModel { id: presProxyModel }
|
||||||
VideoSqlModel {
|
SongSqlModel { id: songSqlModel }
|
||||||
id: videosqlmodel
|
VideoSqlModel { id: videoSqlModel }
|
||||||
}
|
ImageSqlModel { id: imageSqlModel }
|
||||||
|
PresentationSqlModel { id: presSqlModel }
|
||||||
ImageSqlModel {
|
ServiceThing { id: serviceThing }
|
||||||
id: imagesqlmodel
|
FileHelper { id: fileHelper }
|
||||||
}
|
|
||||||
|
|
||||||
PresentationSqlModel {
|
|
||||||
id: pressqlmodel
|
|
||||||
}
|
|
||||||
|
|
||||||
ServiceThing {
|
|
||||||
id: serviceThing
|
|
||||||
}
|
|
||||||
|
|
||||||
function changeServiceItem(index) {
|
function changeServiceItem(index) {
|
||||||
const item = ServiceItemModel.getItem(index);
|
const item = ServiceItemModel.getItem(index);
|
||||||
|
|
|
@ -110,6 +110,13 @@ Item {
|
||||||
Layout.columnSpan: 2
|
Layout.columnSpan: 2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Controls.Label {
|
||||||
|
id: filePathLabel
|
||||||
|
Layout.columnSpan: 2
|
||||||
|
Layout.preferredWidth: 600
|
||||||
|
Layout.alignment: Qt.AlignCenter
|
||||||
|
text: video.filePath
|
||||||
|
}
|
||||||
|
|
||||||
MpvObject {
|
MpvObject {
|
||||||
id: videoPreview
|
id: videoPreview
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue