fixed moving down of slide items, need to still fix serviceItemID changes
This commit is contained in:
parent
056cf91983
commit
b48e96a282
1 changed files with 38 additions and 30 deletions
|
@ -364,7 +364,11 @@ bool SlideModel::moveRows(int sourceIndex, int destIndex, int count) {
|
||||||
|
|
||||||
qDebug() << "starting move: " << "source: " << sourceIndex << "dest: " << destIndex;
|
qDebug() << "starting move: " << "source: " << sourceIndex << "dest: " << destIndex;
|
||||||
|
|
||||||
m_items.move(sourceIndex, destIndex);
|
qDebug() << "items " << m_items;
|
||||||
|
for (int i = 0; i < count; i++) {
|
||||||
|
m_items.move(sourceIndex, destIndex);
|
||||||
|
}
|
||||||
|
qDebug() << "items " << m_items;
|
||||||
|
|
||||||
endMoveRows();
|
endMoveRows();
|
||||||
return true;
|
return true;
|
||||||
|
@ -613,10 +617,7 @@ void SlideModel::moveRowFromService(const int &fromIndex,
|
||||||
const ServiceItem &item) {
|
const ServiceItem &item) {
|
||||||
const bool isMoveDown = toIndex > fromIndex;
|
const bool isMoveDown = toIndex > fromIndex;
|
||||||
qDebug() << "@@@Move SIs" << fromIndex << "to" << toIndex << "@@@";
|
qDebug() << "@@@Move SIs" << fromIndex << "to" << toIndex << "@@@";
|
||||||
int slideId = findSlideIdFromServItm(fromIndex);
|
int sourceStartId = findSlideIdFromServItm(fromIndex);
|
||||||
int toSlideId = isMoveDown ? findSlideIdFromServItm(toIndex + 1) - 1 : findSlideIdFromServItm(toIndex);
|
|
||||||
qDebug() << slideId << toSlideId;
|
|
||||||
// Slide toSlide = m_items[toSlideId];
|
|
||||||
int count;
|
int count;
|
||||||
if (item.type() == "song")
|
if (item.type() == "song")
|
||||||
count = item.text().length();
|
count = item.text().length();
|
||||||
|
@ -624,41 +625,48 @@ void SlideModel::moveRowFromService(const int &fromIndex,
|
||||||
count = item.slideNumber();
|
count = item.slideNumber();
|
||||||
else
|
else
|
||||||
count = 1;
|
count = 1;
|
||||||
|
int sourceEndId = sourceStartId + count;
|
||||||
|
qDebug() << sourceStartId << sourceEndId;
|
||||||
|
// Slide toSlide = m_items[sourceEndId];
|
||||||
// int toCount = toSlide.imageCount();
|
// int toCount = toSlide.imageCount();
|
||||||
int toId = count + slideId;
|
// int toId = count + sourceStartId;
|
||||||
qDebug() << "@@@Move Row" << slideId << "to" << toSlideId << "@@@";
|
qDebug() << "@@@Move Row" << sourceStartId << "to" << sourceEndId << "@@@";
|
||||||
qDebug() << count;
|
qDebug() << count;
|
||||||
if (isMoveDown) {
|
// if (isMoveDown) {
|
||||||
qDebug() << "Moving Down in service list" << slideId << "to" << toSlideId;
|
// qDebug() << "Moving Down in service list" << sourceStartId << "to" << sourceEndId;
|
||||||
if (toSlideId - slideId > 1)
|
// if (sourceEndId - sourceStartId > 1)
|
||||||
if (!moveRows(slideId, toSlideId - 1, count)) {
|
// if (!moveRows(sourceStartId, sourceEndId - 1, count)) {
|
||||||
// failed code
|
// // failed code
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
if (!moveRows(slideId, toSlideId, count)) {
|
// if (!moveRows(sourceStartId, sourceEndId, count)) {
|
||||||
|
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
} else {
|
// } else {
|
||||||
if (slideId - toSlideId > 1)
|
// if (sourceStartId - sourceEndId > 1)
|
||||||
if (!moveRows(slideId - 1, toSlideId, count)) {
|
// if (!moveRows(sourceStartId - 1, sourceEndId, count)) {
|
||||||
|
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
if (!moveRows(slideId, toSlideId, count)) {
|
// if (!moveRows(sourceStartId, sourceEndId, count)) {
|
||||||
|
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
|
if (!moveRows(sourceStartId, sourceEndId, count)) {
|
||||||
|
qDebug() << "Failed to move rows";
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
m_items[toSlideId]->setServiceItemId(toIndex);
|
m_items[sourceEndId]->setServiceItemId(toIndex);
|
||||||
if (isMoveDown) {
|
if (isMoveDown) {
|
||||||
for (int i = slideId; i < toSlideId; i++) {
|
for (int i = sourceStartId; i < sourceEndId; i++) {
|
||||||
m_items[i]->setServiceItemId(m_items[i]->serviceItemId() - 1);
|
m_items[i]->setServiceItemId(m_items[i]->serviceItemId() - 1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (int i = slideId; i > toSlideId; i--) {
|
for (int i = sourceStartId; i > sourceEndId; i--) {
|
||||||
m_items[i]->setServiceItemId(m_items[i]->serviceItemId() + 1);
|
m_items[i]->setServiceItemId(m_items[i]->serviceItemId() + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue