QGIS API Documentation 3.99.0-Master (2fe06baccd8)
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:
50 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 );
51
58 void setHintString( const QString &hintString );
59
65 QString hintString() const;
66
73 void setOverwriteEnabled( bool enabled );
74
80 bool overwriteEnabled() const { return mOverwriteEnabled; }
81
88 void setAllowEmptyName( bool allowed );
89
95 bool allowEmptyName() const { return mAllowEmptyName; }
96
102 void setConflictingNameWarning( const QString &string );
103
109
115 void setRegularExpression( const QString &expression );
116
128 void setShowExistingNamesCompleter( bool show );
129
135 QString name() const;
136
145 static bool exists( const QString &name, const QStringList &extensions, const QStringList &existing, Qt::CaseSensitivity cs = Qt::CaseSensitive );
146 signals:
147
148 // TODO QGIS 4.0 - rename to nameChanged
149
155
156 public slots:
157 // TODO QGIS 4.0 - rename to onNameChanged
158 void nameChanged();
159
160 protected:
161 QStringList mExiting;
162 QStringList mExtensions;
163 Qt::CaseSensitivity mCaseSensitivity = Qt::CaseSensitive;
164 QLabel *mHintLabel = nullptr;
165 QLineEdit *mLineEdit = nullptr;
167 QLabel *mNamesLabel = nullptr;
168 QLabel *mErrorLabel = nullptr;
169 QString mOkString;
170 QRegularExpression mRegularExpression;
171 bool mOverwriteEnabled = true;
172 bool mAllowEmptyName = false;
174
175 static QString highlightText( const QString &text );
176 static QStringList fullNames( const QString &name, const QStringList &extensions );
177 // get list of existing names
178 static QStringList matching( const QStringList &newNames, const QStringList &existingNames, Qt::CaseSensitivity cs = Qt::CaseSensitive );
179};
180
181#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