! * \brief AbstractAspect::setName * sets the name of the abstract aspect * \param value - the new value for the name that needs to be checked and made unique if it's not the case yet * \param autoUnique - if set to \true the new name is automatically made unique, the name is not changed and \c false is returned otherwise. default is \true. * \param skipAutoUnique - if set to \true, don't che
| 216 | * \return returns, if the new name is valid or not |
| 217 | */ |
| 218 | bool AbstractAspect::setName(const QString& value, NameHandling handling, QUndoCommand* /*parent*/) { |
| 219 | if (value.isEmpty()) |
| 220 | return setName(QLatin1String("1"), handling); |
| 221 | |
| 222 | if (value == d->m_name) |
| 223 | return true; // name not changed, but the name is valid |
| 224 | |
| 225 | QString new_name; |
| 226 | if ((handling == NameHandling::UniqueRequired || handling == NameHandling::AutoUnique) && d->m_parent) { |
| 227 | new_name = d->m_parent->uniqueNameFor(value); |
| 228 | |
| 229 | if (handling == NameHandling::UniqueRequired && new_name.compare(value) != 0) // value is not unique, so don't change name |
| 230 | return false; // this value is used in the dock to check if the name is valid |
| 231 | |
| 232 | // NameHandling::Autounique |
| 233 | if (new_name != value) |
| 234 | info(i18n(R"(Intended name "%1" was changed to "%2" in order to avoid name collision.)", value, new_name)); |
| 235 | } else |
| 236 | new_name = value; |
| 237 | exec(new AspectNameChangeCmd(this->d, new_name)); |
| 238 | return true; |
| 239 | } |
| 240 | |
| 241 | QString AbstractAspect::comment() const { |
| 242 | return d->m_comment; |
no test coverage detected