QGIS API Documentation 3.38.0-Grenoble (exported)
Loading...
Searching...
No Matches
qgsnewnamedialog.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsnewnamedialog.h
3 -------------------
4 begin : May, 2015
5 copyright : (C) 2015 Radim Blazek
7 ***************************************************************************/
8/***************************************************************************
9 * *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 ***************************************************************************/
16
17#ifndef QGSNEWNAMEDIALOG_H
18#define QGSNEWNAMEDIALOG_H
19
20class QLabel;
21class QLineEdit;
22
23#include "qgsdialog.h"
24#include "qgis_gui.h"
25#include <QRegularExpression>
26
32class GUI_EXPORT QgsNewNameDialog : public QgsDialog
33{
34 Q_OBJECT
35 public:
36
49 QgsNewNameDialog( const QString &source = QString(), const QString &initial = QString(),
50 const QStringList &extensions = QStringList(), const QStringList &existing = QStringList(),
51 Qt::CaseSensitivity cs = Qt::CaseSensitive,
52 QWidget *parent SIP_TRANSFERTHIS = nullptr, Qt::WindowFlags flags = QgsGuiUtils::ModalDialogFlags );
53
60 void setHintString( const QString &hintString );
61
67 QString hintString() const;
68
75 void setOverwriteEnabled( bool enabled );
76
81 bool overwriteEnabled() const { return mOverwriteEnabled; }
82
89 void setAllowEmptyName( bool allowed );
90
96 bool allowEmptyName() const { return mAllowEmptyName; }
97
103 void setConflictingNameWarning( const QString &string );
104
109 QString conflictingNameWarning() const { return mConflictingNameWarning; }
110
116 void setRegularExpression( const QString &expression );
117
123 QString name() const;
124
133 static bool exists( const QString &name, const QStringList &extensions,
134 const QStringList &existing, Qt::CaseSensitivity cs = Qt::CaseSensitive );
135 signals:
136
137 // TODO QGIS 4.0 - rename to nameChanged
138
144
145 public slots:
146 // TODO QGIS 4.0 - rename to onNameChanged
147 void nameChanged();
148
149 protected:
150 QStringList mExiting;
151 QStringList mExtensions;
152 Qt::CaseSensitivity mCaseSensitivity = Qt::CaseSensitive;
153 QLabel *mHintLabel = nullptr;
154 QLineEdit *mLineEdit = nullptr;
156 QLabel *mNamesLabel = nullptr;
157 QLabel *mErrorLabel = nullptr;
158 QString mOkString;
159 QRegularExpression mRegularExpression;
160 bool mOverwriteEnabled = true;
161 bool mAllowEmptyName = false;
163
164 QString highlightText( const QString &text );
165 static QStringList fullNames( const QString &name, const QStringList &extensions );
166 // get list of existing names
167 static QStringList matching( const QStringList &newNames, const QStringList &existingNames,
168 Qt::CaseSensitivity cs = Qt::CaseSensitive );
169};
170
171#endif // QGSNEWNAMEDIALOG_H
A generic dialog with layout and button box.
Definition qgsdialog.h:34
New name, for example new layer name dialog.
QString conflictingNameWarning() const
Returns the string used for warning users if a conflicting name exists.
void newNameChanged()
Emitted when the name is changed in the dialog.
QRegularExpression mRegularExpression
QStringList mExtensions
bool allowEmptyName() const
Returns true if the widget can be left empty (no name filled).
QString mConflictingNameWarning
bool overwriteEnabled() const
Returns whether users are permitted to overwrite existing names.
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53