finished loading function

This commit is contained in:
Chris Cochrun 2022-10-16 07:33:39 -05:00
parent ae7911fd51
commit 7a038ac141
2 changed files with 26 additions and 0 deletions

View file

@ -580,9 +580,34 @@ bool ServiceItemModel::load(QUrl file) {
QVariantList serviceList = array.toVariantList();
qDebug() << serviceList;
// now lets remove all items from current list and add loaded ones
clearAll();
for (int i = 0; i < serviceList.length(); i++) {
// int id = serviceList
qDebug() << "*********************************";
qDebug() << serviceList[i].toMap();
qDebug() << "*********************************";
QMap item = serviceList[i].toMap();
insertItem(i, item.value("name").toString(), item.value("type").toString(),
item.value("background").toString(),
item.value("backgroundType").toString(),
item.value("text").toStringList(), item.value("audio").toString(),
item.value("font").toString(), item.value("fontSize").toInt());
}
return true;
}
return false;
}
void ServiceItemModel::clearAll() {
for (int i = m_items.size(); i >= 0; i--) {
removeItem(i);
}
}

View file

@ -89,6 +89,7 @@ public:
Q_INVOKABLE bool activate(int id);
Q_INVOKABLE QVariantMap getItem(int index) const;
Q_INVOKABLE QVariantList getItems();
Q_INVOKABLE void clearAll();
Q_INVOKABLE bool save(QUrl file);
Q_INVOKABLE bool load(QUrl file);