QgsNewNameDialog class
New name, for example new layer name dialog.
Contents
If existing names are provided, the dialog warns users if an entered name already exists.
Base classes
- class QgsDialog
- A generic dialog with layout and button box.
Public static functions
- static auto exists(const QString& name, const QStringList& extensions, const QStringList& existing, Qt::CaseSensitivity cs = Qt::CaseSensitive) -> bool
- Test if name or name with at least one extension exists.
Constructors, destructors, conversion operators
- QgsNewNameDialog(const QString& source = QString(), const QString& initial = QString(), const QStringList& extensions = QStringList(), const QStringList& existing = QStringList(), const QRegExp& regexp = QRegExp(), Qt::CaseSensitivity cs = Qt::CaseSensitive, QWidget* parent = nullptr, Qt::WindowFlags flags = QgsGuiUtils::ModalDialogFlags)
- New dialog constructor.
Public functions
- auto conflictingNameWarning() const -> QString
- Returns the string used for warning users if a conflicting name exists.
- auto hintString() const -> QString
- Returns the hint string for the dialog (the text shown above the name input box).
- auto name() const -> QString
- Name entered by user.
- auto overwriteEnabled() const -> bool
- Returns whether users are permitted to overwrite existing names.
- void setConflictingNameWarning(const QString& string)
- Sets the string used for warning users if a conflicting name exists.
- void setHintString(const QString& hintString)
- Sets the hint string for the dialog (the text shown above the name input box).
- void setOverwriteEnabled(bool enabled)
- Sets whether users are permitted to overwrite existing names.
Signals
- void newNameChanged()
- Emitted when the name is changed in the dialog.
Protected variables
- QLabel* mNamesLabel
- List of names with extensions.
Function documentation
static bool QgsNewNameDialog:: exists(const QString& name,
const QStringList& extensions,
const QStringList& existing,
Qt::CaseSensitivity cs = Qt::CaseSensitive)
Test if name or name with at least one extension exists.
| Parameters | |
|---|---|
| name | name or base name |
| extensions | base name extensions |
| existing | existing names |
| cs | case sensitivity for new name to existing names comparison |
| Returns | true if name exists |
QgsNewNameDialog:: QgsNewNameDialog(const QString& source = QString(),
const QString& initial = QString(),
const QStringList& extensions = QStringList(),
const QStringList& existing = QStringList(),
const QRegExp& regexp = QRegExp(),
Qt::CaseSensitivity cs = Qt::CaseSensitive,
QWidget* parent = nullptr,
Qt::WindowFlags flags = QgsGuiUtils::ModalDialogFlags)
New dialog constructor.
| Parameters | |
|---|---|
| source | original data source name, e.g. original layer name of the layer to be copied |
| initial | initial name |
| extensions | base name extensions, e.g. raster base name band extensions or vector layer type extensions |
| existing | existing names |
| regexp | regular expression to be used as validator, for example db tables should have "[A-Za-z_][A-Za-z0-9_]+" |
| cs | case sensitivity for new name to existing names comparison |
| parent | |
| flags | |
QString QgsNewNameDialog:: conflictingNameWarning() const
Returns the string used for warning users if a conflicting name exists.
QString QgsNewNameDialog:: hintString() const
Returns the hint string for the dialog (the text shown above the name input box).
bool QgsNewNameDialog:: overwriteEnabled() const
Returns whether users are permitted to overwrite existing names.
void QgsNewNameDialog:: setConflictingNameWarning(const QString& string)
Sets the string used for warning users if a conflicting name exists.
| Parameters | |
|---|---|
| string | warning string. If empty a default warning string will be used. |
void QgsNewNameDialog:: setHintString(const QString& hintString)
Sets the hint string for the dialog (the text shown above the name input box).
| Parameters | |
|---|---|
| hintString | hint text |
void QgsNewNameDialog:: setOverwriteEnabled(bool enabled)
Sets whether users are permitted to overwrite existing names.
If true, then the dialog will reflect that the new name will overwrite an existing name. If false, then the dialog will not accept names which already exist.
void QgsNewNameDialog:: newNameChanged() signal
Emitted when the name is changed in the dialog.