diff --git a/GUI/Model/Group/GroupItem.cpp b/GUI/Model/Group/GroupItem.cpp index f42f75cb97b95cf704113cf9c0c43d4d8c8f05fc..61b58dfebe922de0a2c3b79bc05dbfee77db2e60 100644 --- a/GUI/Model/Group/GroupItem.cpp +++ b/GUI/Model/Group/GroupItem.cpp @@ -52,7 +52,7 @@ SessionItem* GroupItem::setCurrentType(const QString& modelType) return currentItem(); } -SessionItem* GroupItem::getItemOfType(const QString& type) +SessionItem* GroupItem::getItemOfType(const QString& type) const { return m_controller->getItemOfType(type); } diff --git a/GUI/Model/Group/GroupItem.h b/GUI/Model/Group/GroupItem.h index 26a99685c454c530fda256cc1785f77d96731782..7971efe314157df0d760a2359bc411dc98025a85 100644 --- a/GUI/Model/Group/GroupItem.h +++ b/GUI/Model/Group/GroupItem.h @@ -39,7 +39,7 @@ public: SessionItem* setCurrentType(const QString& modelType); - SessionItem* getItemOfType(const QString& type); + SessionItem* getItemOfType(const QString& type) const; template <typename T> T* itemOfType() const; diff --git a/GUI/Model/Session/SessionItem.cpp b/GUI/Model/Session/SessionItem.cpp index 51098d6d37035ece603000961acf14dd9723fb6a..dd2570de1a24a8bda5a66578fe4401dd694fcd2c 100644 --- a/GUI/Model/Session/SessionItem.cpp +++ b/GUI/Model/Session/SessionItem.cpp @@ -159,7 +159,7 @@ bool SessionItem::isTag(const QString& name) const return m_tags->isValid(name); } -SessionItemTags* SessionItem::sessionItemTags() +const SessionItemTags* SessionItem::sessionItemTags() const { return m_tags.get(); } diff --git a/GUI/Model/Session/SessionItem.h b/GUI/Model/Session/SessionItem.h index 3304cf83dd2cfb9fe9f5bc5eba4559f9ea9632d4..732316529118b1aae03b2624b4cc763c150333c6 100644 --- a/GUI/Model/Session/SessionItem.h +++ b/GUI/Model/Session/SessionItem.h @@ -231,7 +231,7 @@ public: // manage and check tags bool registerTag(const QString& name, int min = 0, int max = -1, QStringList modelTypes = {}); bool isTag(const QString& name) const; - SessionItemTags* sessionItemTags(); + const SessionItemTags* sessionItemTags() const; QString tagFromItem(const SessionItem* item) const; bool acceptsAsDefaultItem(const QString& item_name) const; QVector<QString> acceptableDefaultItemTypes() const; diff --git a/GUI/Model/Session/SessionItemTags.cpp b/GUI/Model/Session/SessionItemTags.cpp index e436e7a7fee90286d0c79c303041bb4995022183..852cb54df0809a97389f1117b78c8844f9ff78c6 100644 --- a/GUI/Model/Session/SessionItemTags.cpp +++ b/GUI/Model/Session/SessionItemTags.cpp @@ -128,7 +128,7 @@ void SessionItemTags::removeChild(const QString& tagName) tag.childCount--; } -bool SessionItemTags::isSingleItemTag(const QString& tagName) +bool SessionItemTags::isSingleItemTag(const QString& tagName) const { if (!isValid(tagName)) return false; diff --git a/GUI/Model/Session/SessionItemTags.h b/GUI/Model/Session/SessionItemTags.h index b10d6c1c3499735ad5e3d316efad6091261b65a2..bdee3b108ad25c60b44c1e38ee3d21e274a6138b 100644 --- a/GUI/Model/Session/SessionItemTags.h +++ b/GUI/Model/Session/SessionItemTags.h @@ -42,7 +42,7 @@ public: void addChild(const QString& tagName); void removeChild(const QString& tagName); - bool isSingleItemTag(const QString& tagName); + bool isSingleItemTag(const QString& tagName) const; bool maximumReached(const QString& tagName) const; diff --git a/GUI/Model/Session/SessionXML.cpp b/GUI/Model/Session/SessionXML.cpp index 3b9cf517c0aa99fccdc16f61d213af0fc881515e..9fbe143a3b1bfd851c4bf1e769636e89f8a774e8 100644 --- a/GUI/Model/Session/SessionXML.cpp +++ b/GUI/Model/Session/SessionXML.cpp @@ -40,18 +40,18 @@ void report_error(MessageService* messageService, SessionItem* item, const QStri messageService->addWarning(item->model(), message); } -SessionItem* createItem(SessionItem* item, const QString& modelType, const QString& tag) +SessionItem* createItem(SessionItem* parent, const QString& modelType, const QString& tag) { - ASSERT(item); - if (item->hasModelType<GroupItem>()) { - if (auto groupItem = dynamic_cast<GroupItem*>(item)) + ASSERT(parent); + if (parent->hasModelType<GroupItem>()) { + if (auto groupItem = dynamic_cast<const GroupItem*>(parent)) return groupItem->getItemOfType(modelType); return nullptr; } - if (item->sessionItemTags()->isSingleItemTag(tag)) - return item->getItem(tag); + if (parent->sessionItemTags()->isSingleItemTag(tag)) + return parent->getItem(tag); try { - return item->model()->insertNewItem(modelType, item, -1, tag); + return parent->model()->insertNewItem(modelType, parent, -1, tag); } catch (const std::exception&) { return nullptr; // error will be reported later }