switching to a more model based adding of items to serviceListModel
This commit is contained in:
parent
903cee065b
commit
d6a92ee3cb
3 changed files with 86 additions and 66 deletions
|
@ -226,7 +226,9 @@ QModelIndex ImageProxyModel::idx(int row) {
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariantMap ImageProxyModel::getImage(const int &row) {
|
QVariantMap ImageProxyModel::getImage(const int &row) {
|
||||||
return QVariantMap();
|
auto model = qobject_cast<ImageSqlModel *>(sourceModel());
|
||||||
|
QVariantMap image = model->getImage(mapToSource(index(row, 0)).row());
|
||||||
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImageProxyModel::deleteImage(const int &row) {
|
void ImageProxyModel::deleteImage(const int &row) {
|
||||||
|
|
|
@ -261,7 +261,9 @@ QModelIndex PresentationProxyModel::idx(int row) {
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariantMap PresentationProxyModel::getPresentation(const int &row) {
|
QVariantMap PresentationProxyModel::getPresentation(const int &row) {
|
||||||
return QVariantMap();
|
auto model = qobject_cast<PresentationSqlModel *>(sourceModel());
|
||||||
|
QVariantMap presentation = model->getPresentation(mapToSource(index(row, 0)).row());
|
||||||
|
return presentation;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PresentationProxyModel::deletePresentation(const int &row) {
|
void PresentationProxyModel::deletePresentation(const int &row) {
|
||||||
|
|
|
@ -61,14 +61,7 @@ Item {
|
||||||
onDropped: (drag) => {
|
onDropped: (drag) => {
|
||||||
console.log("DROPPED AT END");
|
console.log("DROPPED AT END");
|
||||||
showPassiveNotification(drag.source.title);
|
showPassiveNotification(drag.source.title);
|
||||||
appendItem(dragItemTitle,
|
appendItem(dragItemType,
|
||||||
dragItemType,
|
|
||||||
dragItemBackground,
|
|
||||||
dragItemBackgroundType,
|
|
||||||
dragItemText,
|
|
||||||
dragItemAudio,
|
|
||||||
dragItemFont,
|
|
||||||
dragItemFontSize,
|
|
||||||
dragItemIndex);
|
dragItemIndex);
|
||||||
dropHighlightLine.visible = false;
|
dropHighlightLine.visible = false;
|
||||||
}
|
}
|
||||||
|
@ -112,14 +105,7 @@ Item {
|
||||||
const hlIndex = serviceItemList.currentIndex;
|
const hlIndex = serviceItemList.currentIndex;
|
||||||
if (drag.keys[0] === "library") {
|
if (drag.keys[0] === "library") {
|
||||||
addItem(index,
|
addItem(index,
|
||||||
dragItemTitle,
|
|
||||||
dragItemType,
|
dragItemType,
|
||||||
dragItemBackground,
|
|
||||||
dragItemBackgroundType,
|
|
||||||
dragItemText,
|
|
||||||
dragItemAudio,
|
|
||||||
dragItemFont,
|
|
||||||
dragItemFontSize,
|
|
||||||
dragItemIndex);
|
dragItemIndex);
|
||||||
} else if (drag.keys[0] === "serviceitem") {
|
} else if (drag.keys[0] === "serviceitem") {
|
||||||
/* ServiceItemModel.moveRows(serviceItemList.indexDragged, */
|
/* ServiceItemModel.moveRows(serviceItemList.indexDragged, */
|
||||||
|
@ -539,67 +525,97 @@ Item {
|
||||||
ServiceItemModel.removeItems();
|
ServiceItemModel.removeItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
function addItem(index, name, type,
|
function addItem(index, type, itemID) {
|
||||||
background, backgroundType, text, audio,
|
switch (type) {
|
||||||
font, fontSize, itemID) {
|
case 'image': {
|
||||||
if (type === "song") {
|
const image = imageProxyModel.getImage(itemID);
|
||||||
const newtext = songProxyModel.songModel.getLyricList(itemID);
|
console.log("adding: " + image.title + " of type " + type);
|
||||||
console.log("adding: " + name + " of type " + type + " with " + newtext.length + " slides");
|
ServiceItemModel.insertItem(index, image.title,
|
||||||
const song = SongProxyModel.getSong(itemID);
|
type, image.filePath,
|
||||||
ServiceItemModel.insertItem(index, song.name,
|
"image", "", "",
|
||||||
|
"", 0, 0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
case 'video': {
|
||||||
|
const video = videoProxyModel.getVideo(itemID);
|
||||||
|
console.log("adding: " + video.title + " of type " + type);
|
||||||
|
ServiceItemModel.insertItem(index, video.title,
|
||||||
|
type, video.filePath,
|
||||||
|
"video", "", "",
|
||||||
|
"", 0, 0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
case 'song': {
|
||||||
|
const newtext = songProxyModel.getLyricList(itemID);
|
||||||
|
const song = songProxyModel.getSong(itemID);
|
||||||
|
console.log("adding: " + song.title +
|
||||||
|
" of type " + type +
|
||||||
|
" with " + newtext.length + " slides");
|
||||||
|
ServiceItemModel.insertItem(index, song.title,
|
||||||
type, song.background,
|
type, song.background,
|
||||||
song.backgroundType, newtext,
|
song.backgroundType, newtext,
|
||||||
song.audio, song.font, song.fontSize, newtext.length);
|
song.audio, song.font, song.fontSize, newtext.length);
|
||||||
/* totalServiceItems++; */
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (type === "presentation") {
|
case 'presentation': {
|
||||||
console.log("adding: " + name + " of type " + type + " with " + dragItemSlideNumber + " slides");
|
const pres = presProxyModel.getPresentation(itemID);
|
||||||
ServiceItemModel.insertItem(index, name,
|
console.log("adding: " + pres.title +
|
||||||
type, background,
|
" of type " + type +
|
||||||
backgroundType, "",
|
" with " + pres.pageCount + " slides");
|
||||||
"", "", 0, dragItemSlideNumber);
|
ServiceItemModel.insertItem(index, pres.title,
|
||||||
/* totalServiceItems++; */
|
type, pres.filePath,
|
||||||
|
"image", "",
|
||||||
|
"", "", 0, pres.pageCount);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
console.log("adding: " + name + " of type " + type);
|
default: return;
|
||||||
ServiceItemModel.insertItem(index, name,
|
}
|
||||||
type, background,
|
|
||||||
backgroundType, "", "",
|
|
||||||
"", 0, 0);
|
|
||||||
/* totalServiceItems++; */
|
/* totalServiceItems++; */
|
||||||
}
|
}
|
||||||
|
|
||||||
function appendItem(name, type, background, backgroundType,
|
function appendItem(type, itemID) {
|
||||||
text, audio, font, fontSize, itemID) {
|
switch (type) {
|
||||||
console.log("adding: " + name + " of type " + type);
|
case 'image': {
|
||||||
if (type === "song") {
|
const image = imageProxyModel.getImage(itemID);
|
||||||
console.log("THIS IS A SONG!!!!!");
|
console.log("adding: " + image.title + " of type " + type);
|
||||||
let lyrics = songProxyModel.songModel.getLyricList(itemID);
|
ServiceItemModel.addItem(image.title,
|
||||||
console.log(lyrics);
|
type, image.filePath,
|
||||||
ServiceItemModel.addItem(name, type, background,
|
"image", "", "",
|
||||||
backgroundType, lyrics,
|
"", 0, 0);
|
||||||
audio, font, fontSize, lyrics.length);
|
}
|
||||||
/* totalServiceItems++; */
|
case 'video': {
|
||||||
|
const video = videoProxyModel.getVideo(itemID);
|
||||||
|
console.log("adding: " + video.title + " of type " + type);
|
||||||
|
ServiceItemModel.addItem(video.title,
|
||||||
|
type, video.filePath,
|
||||||
|
"video", "", "",
|
||||||
|
"", 0, 0);
|
||||||
|
}
|
||||||
|
case 'song': {
|
||||||
|
const lyrics = songProxyModel.getLyricList(itemID);
|
||||||
|
const song = songProxyModel.getSong(itemID);
|
||||||
|
console.log("adding: " + song.title +
|
||||||
|
" of type " + type +
|
||||||
|
" with " + lyrics.length + " slides");
|
||||||
|
ServiceItemModel.addItem(song.title,
|
||||||
|
type, song.background,
|
||||||
|
song.backgroundType, lyrics,
|
||||||
|
song.audio, song.font, song.fontSize, lyrics.length);
|
||||||
return;
|
return;
|
||||||
};
|
}
|
||||||
|
case 'presentation': {
|
||||||
if (type === "presentation") {
|
const pres = presProxyModel.getPresentation(itemID);
|
||||||
console.log("THIS IS A PRESENTATION!!!!!");
|
console.log("adding: " + pres.title +
|
||||||
ServiceItemModel.addItem(name, type, background,
|
" of type " + type +
|
||||||
backgroundType, "",
|
" with " + pres.pageCount + " slides");
|
||||||
audio, font, fontSize,
|
ServiceItemModel.addItem(pres.title,
|
||||||
dragSlideItemNumber);
|
type, pres.filePath,
|
||||||
/* totalServiceItems++; */
|
"image", "",
|
||||||
|
"", "", 0, pres.pageCount);
|
||||||
return;
|
return;
|
||||||
};
|
}
|
||||||
console.log(background);
|
default: return;
|
||||||
console.log(backgroundType);
|
}
|
||||||
|
|
||||||
ServiceItemModel.addItem(name, type, background,
|
|
||||||
backgroundType, [""], "",
|
|
||||||
"", 0, 0);
|
|
||||||
/* totalServiceItems++; */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectItems(index) {
|
function selectItems(index) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue