MCPcopy Create free account
hub / github.com/KDE/labplot / setName

Method setName

src/backend/core/AbstractAspect.cpp:218–239  ·  view source on GitHub ↗

! * \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

Source from the content-addressed store, hash-verified

216 * \return returns, if the new name is valid or not
217 */
218bool 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
241QString AbstractAspect::comment() const {
242 return d->m_comment;

Callers 15

newLiveDataSourceMethod · 0.45
nameChangedMethod · 0.45
updatePlotRangeListMethod · 0.45
directionChangedMethod · 0.45
importToMethod · 0.45
importToSpreadsheetMethod · 0.45
flattenMethod · 0.45
sampleValuesMethod · 0.45
addChildMethod · 0.45
insertChildMethod · 0.45
pasteMethod · 0.45
setDataMethod · 0.45

Calls 2

uniqueNameForMethod · 0.80
isEmptyMethod · 0.45

Tested by

no test coverage detected