QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
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 : [email protected]
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 
20 class QLabel;
21 class QLineEdit;
22 
23 #include "qgsdialog.h"
24 #include "qgis_gui.h"
25 
32 class GUI_EXPORT QgsNewNameDialog : public QgsDialog
33 {
34  Q_OBJECT
35  public:
36 
48  QgsNewNameDialog( const QString &source = QString(), const QString &initial = QString(),
49  const QStringList &extensions = QStringList(), const QStringList &existing = QStringList(),
50  const QRegExp &regexp = QRegExp(), Qt::CaseSensitivity cs = Qt::CaseSensitive,
51  QWidget *parent SIP_TRANSFERTHIS = nullptr, Qt::WindowFlags flags = QgsGuiUtils::ModalDialogFlags );
52 
60  void setHintString( const QString &hintString );
61 
68  QString hintString() const;
69 
77  void setOverwriteEnabled( bool enabled );
78 
84  bool overwriteEnabled() const { return mOverwriteEnabled; }
85 
92  void setAllowEmptyName( bool allowed );
93 
99  bool allowEmptyName() const { return mAllowEmptyName; }
100 
107  void setConflictingNameWarning( const QString &string );
108 
114  QString conflictingNameWarning() const { return mConflictingNameWarning; }
115 
121  QString name() const;
122 
131  static bool exists( const QString &name, const QStringList &extensions,
132  const QStringList &existing, Qt::CaseSensitivity cs = Qt::CaseSensitive );
133  signals:
134 
135  // TODO QGIS 4.0 - rename to nameChanged
136 
142 
143  public slots:
144  // TODO QGIS 4.0 - rename to onNameChanged
145  void nameChanged();
146 
147  protected:
148  QStringList mExiting;
149  QStringList mExtensions;
150  Qt::CaseSensitivity mCaseSensitivity;
151  QLabel *mHintLabel = nullptr;
152  QLineEdit *mLineEdit = nullptr;
154  QLabel *mNamesLabel = nullptr;
155  QLabel *mErrorLabel = nullptr;
156  QString mOkString;
157  QRegExp mRegexp;
158  bool mOverwriteEnabled = true;
159  bool mAllowEmptyName = false;
161 
162  QString highlightText( const QString &text );
163  static QStringList fullNames( const QString &name, const QStringList &extensions );
164  // get list of existing names
165  static QStringList matching( const QStringList &newNames, const QStringList &existingNames,
166  Qt::CaseSensitivity cs = Qt::CaseSensitive );
167 };
168 
169 #endif // QGSNEWNAMEDIALOG_H
QgsNewNameDialog::newNameChanged
void newNameChanged()
Emitted when the name is changed in the dialog.
QgsNewNameDialog::mRegexp
QRegExp mRegexp
Definition: qgsnewnamedialog.h:157
QgsDialog
A generic dialog with layout and button box.
Definition: qgsdialog.h:34
QgsNewNameDialog::allowEmptyName
bool allowEmptyName() const
Returns true if the widget can be left empty (no name filled).
Definition: qgsnewnamedialog.h:99
QgsNewNameDialog::mOkString
QString mOkString
Definition: qgsnewnamedialog.h:156
QgsNewNameDialog::mExiting
QStringList mExiting
Definition: qgsnewnamedialog.h:148
QgsNewNameDialog
New name, for example new layer name dialog.
Definition: qgsnewnamedialog.h:33
QgsNewNameDialog::mCaseSensitivity
Qt::CaseSensitivity mCaseSensitivity
Definition: qgsnewnamedialog.h:150
QgsNewNameDialog::mConflictingNameWarning
QString mConflictingNameWarning
Definition: qgsnewnamedialog.h:160
qgsdialog.h
QgsNewNameDialog::overwriteEnabled
bool overwriteEnabled() const
Returns whether users are permitted to overwrite existing names.
Definition: qgsnewnamedialog.h:84
QgsNewNameDialog::conflictingNameWarning
QString conflictingNameWarning() const
Returns the string used for warning users if a conflicting name exists.
Definition: qgsnewnamedialog.h:114
SIP_TRANSFERTHIS
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
QgsNewNameDialog::mExtensions
QStringList mExtensions
Definition: qgsnewnamedialog.h:149