QGIS API Documentation 3.43.0-Master (3ee7834ace6)
qgsnewnamedialog.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsnewnamedialog.h
3 -------------------
4 begin : May, 2015
5 copyright : (C) 2015 Radim Blazek
6 email : radim.blazek@gmail.com
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:
48 QgsNewNameDialog( const QString &source = QString(), const QString &initial = QString(), const QStringList &extensions = QStringList(), const QStringList &existing = QStringList(), Qt::CaseSensitivity cs = Qt::CaseSensitive, QWidget *parent SIP_TRANSFERTHIS = nullptr, Qt::WindowFlags flags = QgsGuiUtils::ModalDialogFlags );
49
56 void setHintString( const QString &hintString );
57
63 QString hintString() const;
64
71 void setOverwriteEnabled( bool enabled );
72
78 bool overwriteEnabled() const { return mOverwriteEnabled; }
79
86 void setAllowEmptyName( bool allowed );
87
93 bool allowEmptyName() const { return mAllowEmptyName; }
94
100 void setConflictingNameWarning( const QString &string );
101
106 QString conflictingNameWarning() const { return mConflictingNameWarning; }
107
113 void setRegularExpression( const QString &expression );
114
126 void setShowExistingNamesCompleter( bool show );
127
133 QString name() const;
134
143 static bool exists( const QString &name, const QStringList &extensions, const QStringList &existing, Qt::CaseSensitivity cs = Qt::CaseSensitive );
144 signals:
145
146 // TODO QGIS 4.0 - rename to nameChanged
147
153
154 public slots:
155 // TODO QGIS 4.0 - rename to onNameChanged
156 void nameChanged();
157
158 protected:
159 QStringList mExiting;
160 QStringList mExtensions;
161 Qt::CaseSensitivity mCaseSensitivity = Qt::CaseSensitive;
162 QLabel *mHintLabel = nullptr;
163 QLineEdit *mLineEdit = nullptr;
165 QLabel *mNamesLabel = nullptr;
166 QLabel *mErrorLabel = nullptr;
167 QString mOkString;
168 QRegularExpression mRegularExpression;
169 bool mOverwriteEnabled = true;
170 bool mAllowEmptyName = false;
172
173 QString highlightText( const QString &text );
174 static QStringList fullNames( const QString &name, const QStringList &extensions );
175 // get list of existing names
176 static QStringList matching( const QStringList &newNames, const QStringList &existingNames, Qt::CaseSensitivity cs = Qt::CaseSensitive );
177};
178
179#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