adding a signal/slot for clearing all items

This commit is contained in:
Chris Cochrun 2023-01-27 16:44:46 -06:00
parent 1b8e8202a1
commit 441ec22542
4 changed files with 7 additions and 1 deletions

View file

@ -832,6 +832,7 @@ void ServiceItemModel::clearAll() {
for (int i = m_items.size(); i >= 0; i--) {
removeItem(i);
}
emit allRemoved();
}
bool ServiceItemModel::loadLastSaved() {

View file

@ -116,6 +116,7 @@ signals:
void itemInserted(const int &, const ServiceItem &);
void rowMoved(const int &, const int &, const ServiceItem &);
void rowRemoved(const int &, const ServiceItem &);
void allRemoved();
private:

View file

@ -78,7 +78,6 @@ public:
Q_INVOKABLE bool moveUp(int index);
Q_INVOKABLE QVariantMap getItem(int index) const;
Q_INVOKABLE QVariantList getItems();
Q_INVOKABLE void clearAll();
Q_INVOKABLE int findSlideIdFromServItm(int index);
public slots:
@ -86,6 +85,7 @@ public slots:
Q_INVOKABLE bool activate(int id);
Q_INVOKABLE bool deactivate(int id);
Q_INVOKABLE void removeServiceItem(const int &index, const ServiceItem &item);
Q_INVOKABLE void clearAll();
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);

View file

@ -159,6 +159,10 @@ int main(int argc, char *argv[])
SIGNAL(rowRemoved(const int&, const ServiceItem&)),
slideModel.get(),
SLOT(removeServiceItem(const int&, const ServiceItem&)));
QObject::connect(serviceItemModel.get(),
SIGNAL(allRemoved()),
slideModel.get(),
SLOT(clearAll()));
bool loading = serviceItemModel.get()->loadLastSaved();