QGIS API Documentation 3.99.0-Master (21b3aa880ba)
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 "qgis_gui.h"
24#include "qgsdialog.h"
25
26#include <QRegularExpression>
27
34class GUI_EXPORT QgsNewNameDialog : public QgsDialog
35{
36 Q_OBJECT
37 public:
38
51 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 );
52
59 void setHintString( const QString &hintString );
60
66 QString hintString() const;
67
74 void setOverwriteEnabled( bool enabled );
75
81 bool overwriteEnabled() const { return mOverwriteEnabled; }
82
89 void setAllowEmptyName( bool allowed );
90
96 bool allowEmptyName() const { return mAllowEmptyName; }
97
103 void setConflictingNameWarning( const QString &string );
104
110
116 void setRegularExpression( const QString &expression );
117
129 void setShowExistingNamesCompleter( bool show );
130
136 QString name() const;
137
146 static bool exists( const QString &name, const QStringList &extensions, const QStringList &existing, Qt::CaseSensitivity cs = Qt::CaseSensitive );
147 signals:
148
149 // TODO QGIS 4.0 - rename to nameChanged
150
156
157 public slots:
158 // TODO QGIS 4.0 - rename to onNameChanged
159 void nameChanged();
160
161 protected:
162 QStringList mExiting;
163 QStringList mExtensions;
164 Qt::CaseSensitivity mCaseSensitivity = Qt::CaseSensitive;
165 QLabel *mHintLabel = nullptr;
166 QLineEdit *mLineEdit = nullptr;
168 QLabel *mNamesLabel = nullptr;
169 QLabel *mErrorLabel = nullptr;
170 QString mOkString;
171 QRegularExpression mRegularExpression;
172 bool mOverwriteEnabled = true;
173 bool mAllowEmptyName = false;
175
176 static QString highlightText( const QString &text );
177 static QStringList fullNames( const QString &name, const QStringList &extensions );
178 // get list of existing names
179 static QStringList matching( const QStringList &newNames, const QStringList &existingNames, Qt::CaseSensitivity cs = Qt::CaseSensitive );
180};
181
182#endif // QGSNEWNAMEDIALOG_H
QgsDialog(QWidget *parent=nullptr, Qt::WindowFlags fl=QgsGuiUtils::ModalDialogFlags, QDialogButtonBox::StandardButtons buttons=QDialogButtonBox::Close, Qt::Orientation orientation=Qt::Horizontal)
Constructor for QgsDialog.
Definition qgsdialog.cpp:22
static QStringList fullNames(const QString &name, const QStringList &extensions)
QgsNewNameDialog(const QString &source=QString(), const QString &initial=QString(), const QStringList &extensions=QStringList(), const QStringList &existing=QStringList(), Qt::CaseSensitivity cs=Qt::CaseSensitive, QWidget *parent=nullptr, Qt::WindowFlags flags=QgsGuiUtils::ModalDialogFlags)
New dialog constructor.
Qt::CaseSensitivity mCaseSensitivity
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
static QStringList matching(const QStringList &newNames, const QStringList &existingNames, Qt::CaseSensitivity cs=Qt::CaseSensitive)
QStringList mExtensions
void setOverwriteEnabled(bool enabled)
Sets whether users are permitted to overwrite existing names.
QLabel * mNamesLabel
List of names with extensions.
static QString highlightText(const QString &text)
bool allowEmptyName() const
Returns true if the widget can be left empty (no name filled).
QString hintString() const
Returns the hint string for the dialog (the text shown above the name input box).
QString name() const
Name entered by user.
QString mConflictingNameWarning
bool overwriteEnabled() const
Returns whether users are permitted to overwrite existing names.
void setHintString(const QString &hintString)
Sets the hint string for the dialog (the text shown above the name input box).
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53