QGIS API Documentation 4.1.0-Master (5bf3c20f3c9)
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:
51 const QString &source = QString(),
52 const QString &initial = QString(),
53 const QStringList &extensions = QStringList(),
54 const QStringList &existing = QStringList(),
55 Qt::CaseSensitivity cs = Qt::CaseSensitive,
56 QWidget *parent SIP_TRANSFERTHIS = nullptr,
57 Qt::WindowFlags flags = QgsGuiUtils::ModalDialogFlags
58 );
59
66 void setHintString( const QString &hintString );
67
73 QString hintString() const;
74
81 void setOverwriteEnabled( bool enabled );
82
88 bool overwriteEnabled() const { return mOverwriteEnabled; }
89
96 void setAllowEmptyName( bool allowed );
97
103 bool allowEmptyName() const { return mAllowEmptyName; }
104
110 void setConflictingNameWarning( const QString &string );
111
117
123 void setRegularExpression( const QString &expression );
124
136 void setShowExistingNamesCompleter( bool show );
137
143 QString name() const;
144
153 static bool exists( const QString &name, const QStringList &extensions, const QStringList &existing, Qt::CaseSensitivity cs = Qt::CaseSensitive );
154 signals:
155
156 // TODO QGIS 5.0 - rename to nameChanged
157
163
164 public slots:
165 // TODO QGIS 5.0 - rename to onNameChanged
166 void nameChanged();
167
168 protected:
169 QStringList mExiting;
170 QStringList mExtensions;
171 Qt::CaseSensitivity mCaseSensitivity = Qt::CaseSensitive;
172 QLabel *mHintLabel = nullptr;
173 QLineEdit *mLineEdit = nullptr;
175 QLabel *mNamesLabel = nullptr;
176 QLabel *mErrorLabel = nullptr;
177 QString mOkString;
178 QRegularExpression mRegularExpression;
179 bool mOverwriteEnabled = true;
180 bool mAllowEmptyName = false;
182
183 static QString highlightText( const QString &text );
184 static QStringList fullNames( const QString &name, const QStringList &extensions );
185 // get list of existing names
186 static QStringList matching( const QStringList &newNames, const QStringList &existingNames, Qt::CaseSensitivity cs = Qt::CaseSensitive );
187};
188
189#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:52