QGIS API Documentation 3.43.0-Master (c67cf405802)
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
33class GUI_EXPORT QgsNewNameDialog : public QgsDialog
34{
35 Q_OBJECT
36 public:
49 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 );
50
57 void setHintString( const QString &hintString );
58
64 QString hintString() const;
65
72 void setOverwriteEnabled( bool enabled );
73
79 bool overwriteEnabled() const { return mOverwriteEnabled; }
80
87 void setAllowEmptyName( bool allowed );
88
94 bool allowEmptyName() const { return mAllowEmptyName; }
95
101 void setConflictingNameWarning( const QString &string );
102
107 QString conflictingNameWarning() const { return mConflictingNameWarning; }
108
114 void setRegularExpression( const QString &expression );
115
127 void setShowExistingNamesCompleter( bool show );
128
134 QString name() const;
135
144 static bool exists( const QString &name, const QStringList &extensions, const QStringList &existing, Qt::CaseSensitivity cs = Qt::CaseSensitive );
145 signals:
146
147 // TODO QGIS 4.0 - rename to nameChanged
148
154
155 public slots:
156 // TODO QGIS 4.0 - rename to onNameChanged
157 void nameChanged();
158
159 protected:
160 QStringList mExiting;
161 QStringList mExtensions;
162 Qt::CaseSensitivity mCaseSensitivity = Qt::CaseSensitive;
163 QLabel *mHintLabel = nullptr;
164 QLineEdit *mLineEdit = nullptr;
166 QLabel *mNamesLabel = nullptr;
167 QLabel *mErrorLabel = nullptr;
168 QString mOkString;
169 QRegularExpression mRegularExpression;
170 bool mOverwriteEnabled = true;
171 bool mAllowEmptyName = false;
173
174 QString highlightText( const QString &text );
175 static QStringList fullNames( const QString &name, const QStringList &extensions );
176 // get list of existing names
177 static QStringList matching( const QStringList &newNames, const QStringList &existingNames, Qt::CaseSensitivity cs = Qt::CaseSensitive );
178};
179
180#endif // QGSNEWNAMEDIALOG_H
A generic dialog with layout and button box.
Definition qgsdialog.h:34
A dialog for prompting users for a 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