QGIS API Documentation 3.41.0-Master (af5edcb665c)
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:
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
77 bool overwriteEnabled() const { return mOverwriteEnabled; }
78
85 void setAllowEmptyName( bool allowed );
86
92 bool allowEmptyName() const { return mAllowEmptyName; }
93
99 void setConflictingNameWarning( const QString &string );
100
105 QString conflictingNameWarning() const { return mConflictingNameWarning; }
106
112 void setRegularExpression( const QString &expression );
113
119 QString name() const;
120
129 static bool exists( const QString &name, const QStringList &extensions, const QStringList &existing, Qt::CaseSensitivity cs = Qt::CaseSensitive );
130 signals:
131
132 // TODO QGIS 4.0 - rename to nameChanged
133
139
140 public slots:
141 // TODO QGIS 4.0 - rename to onNameChanged
142 void nameChanged();
143
144 protected:
145 QStringList mExiting;
146 QStringList mExtensions;
147 Qt::CaseSensitivity mCaseSensitivity = Qt::CaseSensitive;
148 QLabel *mHintLabel = nullptr;
149 QLineEdit *mLineEdit = nullptr;
151 QLabel *mNamesLabel = nullptr;
152 QLabel *mErrorLabel = nullptr;
153 QString mOkString;
154 QRegularExpression mRegularExpression;
155 bool mOverwriteEnabled = true;
156 bool mAllowEmptyName = false;
158
159 QString highlightText( const QString &text );
160 static QStringList fullNames( const QString &name, const QStringList &extensions );
161 // get list of existing names
162 static QStringList matching( const QStringList &newNames, const QStringList &existingNames, Qt::CaseSensitivity cs = Qt::CaseSensitive );
163};
164
165#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