QGIS API Documentation  3.0.2-Girona (307d082)
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 
105  QString name() const;
106 
115  static bool exists( const QString &name, const QStringList &extensions,
116  const QStringList &existing, Qt::CaseSensitivity cs = Qt::CaseSensitive );
117  public slots:
118  void nameChanged();
119 
120  protected:
121  QStringList mExiting;
122  QStringList mExtensions;
123  Qt::CaseSensitivity mCaseSensitivity;
124  QLabel *mHintLabel = nullptr;
125  QLineEdit *mLineEdit = nullptr;
127  QLabel *mNamesLabel = nullptr;
128  QLabel *mErrorLabel = nullptr;
129  QString mOkString;
130  QRegExp mRegexp;
131  bool mOverwriteEnabled = true;
133 
134  QString highlightText( const QString &text );
135  static QStringList fullNames( const QString &name, const QStringList &extensions );
136  // get list of existing names
137  static QStringList matching( const QStringList &newNames, const QStringList &existingNames,
138  Qt::CaseSensitivity cs = Qt::CaseSensitive );
139 };
140 
141 #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 mConflictingNameWarning
bool overwriteEnabled() const
Returns whether users are permitted to overwrite existing names.
QString conflictingNameWarning() const
Returns the string used for warning users if a conflicting name exists.
New name, for example new layer name dialog.