multi select and removal. Slides aren't perfect yet.

This commit is contained in:
Chris Cochrun 2023-01-24 15:29:56 -06:00
parent 4bf1790708
commit 7a8c7cc389
7 changed files with 77 additions and 3 deletions

View file

@ -372,6 +372,22 @@ void ServiceItemModel::removeItem(int index) {
endRemoveRows();
}
void ServiceItemModel::removeItems() {
for (int i = m_items.length() - 1; i > -1; i--) {
QModelIndex idx = index(i);
ServiceItem *item = m_items[idx.row()];
if (item->selected()) {
qDebug() << "Removing item:" << i;
beginRemoveRows(QModelIndex(), i, i);
m_items.removeAt(i);
endRemoveRows();
emit rowRemoved(i, *item);
qDebug() << "emitted removal of item:" << item->name();
}
}
}
bool ServiceItemModel::moveRows(int sourceIndex, int destIndex, int count) {
qDebug() << sourceIndex;
qDebug() << destIndex;

View file

@ -95,6 +95,7 @@ public:
const QString &audio, const QString &font,
const int &fontSize, const int &slideNumber);
Q_INVOKABLE void removeItem(int index);
Q_INVOKABLE void removeItems();
Q_INVOKABLE bool moveRows(int sourceIndex, int destIndex, int count);
Q_INVOKABLE bool moveDown(int index);
Q_INVOKABLE bool moveUp(int index);
@ -114,6 +115,7 @@ signals:
void itemAdded(const int &, const ServiceItem &);
void itemInserted(const int &, const ServiceItem &);
void rowMoved(const int &, const int &, const ServiceItem &);
void rowRemoved(const int &, const ServiceItem &);
private:

View file

@ -112,7 +112,7 @@ void Slide::setServiceItemId(int serviceItemId)
if (m_serviceItemId == serviceItemId)
return;
qDebug() << "####changing serviceItemId to: " << serviceItemId;
qDebug() << "####changing serviceItemId of" << "to:" << serviceItemId;
m_serviceItemId = serviceItemId;
emit serviceItemIdChanged(m_serviceItemId);
}

View file

@ -287,6 +287,39 @@ void SlideModel::removeItem(int index) {
endRemoveRows();
}
void SlideModel::removeServiceItem(const int &index, const ServiceItem &item) {
qDebug() << "Need to remove serviceItem:" << item.name() << "with" << item.slideNumber() << "slides.";
int id = findSlideIdFromServItm(index);
if (item.slideNumber() > 1) {
for (int i = item.slideNumber() + id; i > id - 1; i--) {
qDebug() << "Removing serviceItem:" << i;
beginRemoveRows(QModelIndex(), i, i);
m_items.removeAt(i);
endRemoveRows();
m_items[i]->setServiceItemId(index);
}
} else {
qDebug() << "Removing serviceItem:" << id;
beginRemoveRows(QModelIndex(), id, id);
m_items.removeAt(id);
endRemoveRows();
m_items[id]->setServiceItemId(index);
}
}
void SlideModel::removeItems() {
for (int i = m_items.length() - 1; i > -1; i--) {
QModelIndex idx = index(i);
Slide *item = m_items[idx.row()];
if (item->selected()) {
qDebug() << "Removing item:" << i;
beginRemoveRows(QModelIndex(), i, i);
m_items.removeAt(i);
endRemoveRows();
}
}
}
bool SlideModel::moveRows(int sourceIndex, int destIndex, int count) {
qDebug() << index(sourceIndex).row();
qDebug() << index(destIndex).row();

View file

@ -72,6 +72,7 @@ public:
const int &slideIndex,
const int &imageCount);
Q_INVOKABLE void removeItem(int index);
Q_INVOKABLE void removeItems();
Q_INVOKABLE bool moveRows(int sourceIndex, int destIndex, int count);
Q_INVOKABLE bool moveDown(int index);
Q_INVOKABLE bool moveUp(int index);
@ -84,6 +85,7 @@ public slots:
Q_INVOKABLE bool select(int id);
Q_INVOKABLE bool activate(int id);
Q_INVOKABLE bool deactivate(int id);
Q_INVOKABLE void removeServiceItem(const int &index, const ServiceItem &item);
void addItemFromService(const int &index, const ServiceItem &item);
void insertItemFromService(const int &index, const ServiceItem &item);
void moveRowFromService(const int &fromIndex, const int &toIndex, const ServiceItem &item);