adding the removal of items work on the slides
This isn't finished yet, but the core is there. I have yet to fully remove slides after a service_item is removed.
This commit is contained in:
parent
7a36b70a6d
commit
f8ac7feea0
5 changed files with 35 additions and 10 deletions
|
@ -303,7 +303,9 @@ void ServiceItemModel::removeItems() {
|
|||
beginRemoveRows(QModelIndex(), i, i);
|
||||
m_items.removeAt(i);
|
||||
endRemoveRows();
|
||||
QVariantMap map = getItem(i);
|
||||
emit rowRemoved(i, *item);
|
||||
emit rowRemovedRust(i, map);
|
||||
qDebug() << "emitted removal of item:" << item->name();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -119,7 +119,9 @@ signals:
|
|||
void itemInserted(const int &, const ServiceItem &);
|
||||
void itemInsertedRust(const int &, const QVariantMap &);
|
||||
void rowMoved(const int &, const int &, const ServiceItem &);
|
||||
void rowMovedRust(const int &, const int &, const QVariantMap &);
|
||||
void rowRemoved(const int &, const ServiceItem &);
|
||||
void rowRemovedRust(const int &, const QVariantMap &);
|
||||
void allRemoved();
|
||||
|
||||
private:
|
||||
|
|
14
src/main.cpp
14
src/main.cpp
|
@ -168,13 +168,13 @@ int main(int argc, char *argv[])
|
|||
slideModel.get(),
|
||||
SLOT(moveRowFromService(const int&, const int&, const ServiceItem&)));
|
||||
QObject::connect(serviceItemModel.get(),
|
||||
SIGNAL(rowRemoved(const int&, const ServiceItem&)),
|
||||
slideModel.get(),
|
||||
SLOT(removeServiceItem(const int&, const ServiceItem&)));
|
||||
QObject::connect(serviceItemModel.get(),
|
||||
SIGNAL(allRemoved()),
|
||||
slideModel.get(),
|
||||
SLOT(clear()));
|
||||
&ServiceItemModel::rowRemovedRust,
|
||||
slideMod.get(),
|
||||
&SlideyMod::removeItemFromService);
|
||||
// QObject::connect(serviceItemModel.get(),
|
||||
// SIGNAL(allRemoved()),
|
||||
// slideMod.get(),
|
||||
// SLOT(clear()));
|
||||
QObject::connect(slideobject.get(),
|
||||
SIGNAL(slideChanged(int)),
|
||||
slideMod.get(),
|
||||
|
|
|
@ -506,7 +506,7 @@ Item {
|
|||
icon.name: "delete"
|
||||
onTriggered: {
|
||||
showPassiveNotification("remove");
|
||||
removeItem(serviceItemList.currentIndex);
|
||||
removeItems();
|
||||
}
|
||||
},
|
||||
Kirigami.Action {
|
||||
|
@ -515,11 +515,12 @@ Item {
|
|||
onTriggered: {
|
||||
showPassiveNotification("clearing all items");
|
||||
ServiceItemModel.clearAll();
|
||||
serviceItemList.forceLayout()
|
||||
}
|
||||
},
|
||||
Kirigami.Action {
|
||||
text: "Load"
|
||||
icon.name: "list-remove-all"
|
||||
icon.name: "fileopen"
|
||||
onTriggered: {
|
||||
loadingItem.visible = !loadingItem.visible;
|
||||
}
|
||||
|
|
|
@ -165,6 +165,15 @@ mod slide_model {
|
|||
}
|
||||
}
|
||||
|
||||
#[qinvokable]
|
||||
pub fn remove_item_from_service(
|
||||
mut self: Pin<&mut Self>,
|
||||
index: i32,
|
||||
service_item: &QMap_QString_QVariant,
|
||||
) {
|
||||
println!("Removing: {:?}", index);
|
||||
}
|
||||
|
||||
#[qinvokable]
|
||||
pub fn remove_item(mut self: Pin<&mut Self>, index: i32) {
|
||||
if index < 0 || (index as usize) >= self.slides().len() {
|
||||
|
@ -387,6 +396,14 @@ mod slide_model {
|
|||
video_thumbnail: QString::from(""),
|
||||
};
|
||||
|
||||
// We need to move all the current slides service_item_id's up by one.
|
||||
let slides_len = self.as_mut().slides_mut().len() as i32;
|
||||
for slide in index..slides_len {
|
||||
if let Some(slide) = self.as_mut().slides_mut().get_mut(slide as usize) {
|
||||
slide.service_item_id += 1;
|
||||
}
|
||||
}
|
||||
|
||||
match ty {
|
||||
Some(ty) if ty == QString::from("image") => {
|
||||
slide.ty = ty;
|
||||
|
@ -624,12 +641,15 @@ mod slide_model {
|
|||
slide.active = false;
|
||||
}
|
||||
if let Some(slide) = self.as_mut().slides_mut().get_mut(index as usize) {
|
||||
println!("slide is activating {:?}", index);
|
||||
println!("slide-title: {:?}", slide.service_item_id);
|
||||
println!("slide-image-background: {:?}", slide.image_background);
|
||||
println!("slide-video-background: {:?}", slide.video_background);
|
||||
slide.active = true;
|
||||
self.as_mut().emit_data_changed(tl, br, &vector_roles);
|
||||
// We use this signal generated by our signals enum to tell QML that
|
||||
// the active slide has changed which is used to reposition views.
|
||||
self.as_mut().emit_active_changed();
|
||||
println!("slide is activating {:?}", index);
|
||||
true
|
||||
} else {
|
||||
false
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue