adding deactivate and inserts default to deactivated and deselected

This commit is contained in:
Chris Cochrun 2022-10-18 16:57:25 -05:00
parent 6eea7cc7af
commit 13b0b0348a
2 changed files with 33 additions and 0 deletions

View file

@ -217,12 +217,16 @@ void ServiceItemModel::insertItem(const int &index, ServiceItem *item) {
void ServiceItemModel::addItem(const QString &name, const QString &type) { void ServiceItemModel::addItem(const QString &name, const QString &type) {
ServiceItem *item = new ServiceItem(name, type); ServiceItem *item = new ServiceItem(name, type);
item->setSelected(false);
item->setActive(false);
addItem(item); addItem(item);
} }
void ServiceItemModel::addItem(const QString &name, const QString &type, void ServiceItemModel::addItem(const QString &name, const QString &type,
const QString &background, const QString &backgroundType) { const QString &background, const QString &backgroundType) {
ServiceItem *item = new ServiceItem(name, type, background, backgroundType); ServiceItem *item = new ServiceItem(name, type, background, backgroundType);
item->setSelected(false);
item->setActive(false);
addItem(item); addItem(item);
} }
@ -230,6 +234,8 @@ void ServiceItemModel::addItem(const QString &name, const QString &type,
const QString &background, const QString &backgroundType, const QString &background, const QString &backgroundType,
const QStringList &text) { const QStringList &text) {
ServiceItem *item = new ServiceItem(name, type, background, backgroundType, text); ServiceItem *item = new ServiceItem(name, type, background, backgroundType, text);
item->setSelected(false);
item->setActive(false);
addItem(item); addItem(item);
qDebug() << name << type << background; qDebug() << name << type << background;
} }
@ -239,6 +245,8 @@ void ServiceItemModel::addItem(const QString &name, const QString &type,
const QStringList &text, const QString &audio) { const QStringList &text, const QString &audio) {
ServiceItem *item = new ServiceItem(name, type, background, backgroundType, ServiceItem *item = new ServiceItem(name, type, background, backgroundType,
text, audio); text, audio);
item->setSelected(false);
item->setActive(false);
addItem(item); addItem(item);
qDebug() << name << type << background; qDebug() << name << type << background;
} }
@ -249,6 +257,8 @@ void ServiceItemModel::addItem(const QString &name, const QString &type,
const QString &font, const int &fontSize) { const QString &font, const int &fontSize) {
ServiceItem *item = new ServiceItem(name, type, background, backgroundType, ServiceItem *item = new ServiceItem(name, type, background, backgroundType,
text, audio, font, fontSize); text, audio, font, fontSize);
item->setSelected(false);
item->setActive(false);
addItem(item); addItem(item);
qDebug() << "#################################"; qDebug() << "#################################";
qDebug() << name << type << font << fontSize; qDebug() << name << type << font << fontSize;
@ -257,6 +267,8 @@ void ServiceItemModel::addItem(const QString &name, const QString &type,
void ServiceItemModel::insertItem(const int &index, const QString &name, const QString &type) { void ServiceItemModel::insertItem(const int &index, const QString &name, const QString &type) {
ServiceItem *item = new ServiceItem(name, type); ServiceItem *item = new ServiceItem(name, type);
item->setSelected(false);
item->setActive(false);
insertItem(index, item); insertItem(index, item);
qDebug() << name << type; qDebug() << name << type;
} }
@ -264,6 +276,8 @@ void ServiceItemModel::insertItem(const int &index, const QString &name, const Q
void ServiceItemModel::insertItem(const int &index, const QString &name, const QString &type, void ServiceItemModel::insertItem(const int &index, const QString &name, const QString &type,
const QString &background, const QString &backgroundType) { const QString &background, const QString &backgroundType) {
ServiceItem *item = new ServiceItem(name, type, background, backgroundType); ServiceItem *item = new ServiceItem(name, type, background, backgroundType);
item->setSelected(false);
item->setActive(false);
insertItem(index, item); insertItem(index, item);
qDebug() << name << type << background; qDebug() << name << type << background;
} }
@ -282,6 +296,8 @@ void ServiceItemModel::insertItem(const int &index, const QString &name,
const QString &audio) { const QString &audio) {
ServiceItem *item = new ServiceItem(name, type, background, backgroundType, ServiceItem *item = new ServiceItem(name, type, background, backgroundType,
text, audio); text, audio);
item->setSelected(false);
item->setActive(false);
insertItem(index, item); insertItem(index, item);
qDebug() << name << type << background << text; qDebug() << name << type << background << text;
} }
@ -292,6 +308,8 @@ void ServiceItemModel::insertItem(const int &index, const QString &name,
const QString &audio, const QString &font, const int &fontSize) { const QString &audio, const QString &font, const int &fontSize) {
ServiceItem *item = new ServiceItem(name, type, background, backgroundType, ServiceItem *item = new ServiceItem(name, type, background, backgroundType,
text, audio, font, fontSize); text, audio, font, fontSize);
item->setSelected(false);
item->setActive(false);
insertItem(index, item); insertItem(index, item);
qDebug() << "#################################"; qDebug() << "#################################";
qDebug() << name << type << font << fontSize; qDebug() << name << type << font << fontSize;
@ -406,6 +424,8 @@ QVariantList ServiceItemModel::getItems() {
itm["audio"] = item->audio(); itm["audio"] = item->audio();
itm["font"] = item->font(); itm["font"] = item->font();
itm["fontSize"] = item->fontSize(); itm["fontSize"] = item->fontSize();
itm["selected"] = item->selected();
itm["active"] = item->active();
data.append(itm); data.append(itm);
} }
qDebug() << "$$$$$$$$$$$$$$$$$$$$$$$$$$$"; qDebug() << "$$$$$$$$$$$$$$$$$$$$$$$$$$$";
@ -461,6 +481,18 @@ bool ServiceItemModel::activate(int id) {
return true; return true;
} }
bool ServiceItemModel::deactivate(int id) {
QModelIndex idx = index(id);
ServiceItem *item = m_items[idx.row()];
item->setActive(false);
qDebug() << "################";
qDebug() << "deactivated" << item->name();
qDebug() << "################";
emit dataChanged(idx, idx, QVector<int>() << ActiveRole);
return true;
}
bool ServiceItemModel::save(QUrl file) { bool ServiceItemModel::save(QUrl file) {
qDebug() << "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"; qDebug() << "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@";
qDebug() << "Saving..."; qDebug() << "Saving...";

View file

@ -87,6 +87,7 @@ public:
Q_INVOKABLE bool moveUp(int index); Q_INVOKABLE bool moveUp(int index);
Q_INVOKABLE bool select(int id); Q_INVOKABLE bool select(int id);
Q_INVOKABLE bool activate(int id); Q_INVOKABLE bool activate(int id);
Q_INVOKABLE bool deactivate(int id);
Q_INVOKABLE QVariantMap getItem(int index) const; Q_INVOKABLE QVariantMap getItem(int index) const;
Q_INVOKABLE QVariantList getItems(); Q_INVOKABLE QVariantList getItems();
Q_INVOKABLE void clearAll(); Q_INVOKABLE void clearAll();