QGIS API Documentation  3.4.15-Madeira (e83d02e274)
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 setConflictingNameWarning( const QString &string );
93 
99  QString conflictingNameWarning() const { return mConflictingNameWarning; }
100 
106  QString name() const;
107 
116  static bool exists( const QString &name, const QStringList &extensions,
117  const QStringList &existing, Qt::CaseSensitivity cs = Qt::CaseSensitive );
118  signals:
119 
120  // TODO QGIS 4.0 - rename to nameChanged
121 
126  void newNameChanged();
127 
128  public slots:
129  // TODO QGIS 4.0 - rename to onNameChanged
130  void nameChanged();
131 
132  protected:
133  QStringList mExiting;
134  QStringList mExtensions;
135  Qt::CaseSensitivity mCaseSensitivity;
136  QLabel *mHintLabel = nullptr;
137  QLineEdit *mLineEdit = nullptr;
139  QLabel *mNamesLabel = nullptr;
140  QLabel *mErrorLabel = nullptr;
141  QString mOkString;
142  QRegExp mRegexp;
143  bool mOverwriteEnabled = true;
145 
146  QString highlightText( const QString &text );
147  static QStringList fullNames( const QString &name, const QStringList &extensions );
148  // get list of existing names
149  static QStringList matching( const QStringList &newNames, const QStringList &existingNames,
150  Qt::CaseSensitivity cs = Qt::CaseSensitive );
151 };
152 
153 #endif // QGSNEWNAMEDIALOG_H
Qt::CaseSensitivity mCaseSensitivity
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:46
QStringList mExiting
A generic dialog with layout and button box.
Definition: qgsdialog.h:33
QStringList mExtensions
QString conflictingNameWarning() const
Returns the string used for warning users if a conflicting name exists.
QString mConflictingNameWarning
New name, for example new layer name dialog.
bool overwriteEnabled() const
Returns whether users are permitted to overwrite existing names.