2009-04-03 19:30:25 +00:00
|
|
|
/*
|
2020-06-15 17:42:37 +02:00
|
|
|
Copyright 2006-2020 The QElectroTech Team
|
2009-04-03 19:30:25 +00:00
|
|
|
This file is part of QElectroTech.
|
2020-09-18 23:05:42 +02:00
|
|
|
|
2009-04-03 19:30:25 +00:00
|
|
|
QElectroTech is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
2020-09-18 23:05:42 +02:00
|
|
|
|
2009-04-03 19:30:25 +00:00
|
|
|
QElectroTech is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
2020-09-18 23:05:42 +02:00
|
|
|
|
2009-04-03 19:30:25 +00:00
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
#ifndef Q_FILENAME_EDIT_H
|
|
|
|
#define Q_FILENAME_EDIT_H
|
|
|
|
#include <QLineEdit>
|
|
|
|
#include <QString>
|
2020-09-18 23:05:42 +02:00
|
|
|
#include <QRegularExpression>
|
2009-04-03 19:30:25 +00:00
|
|
|
class QETRegExpValidator;
|
|
|
|
/**
|
2012-11-09 21:09:24 +00:00
|
|
|
This class represents a textfield dedicated to input a portable filename (not
|
|
|
|
a path).
|
|
|
|
It enables users to input a name matching the regular expression
|
|
|
|
^[0-9a-z_-\.]+$, thus avoiding problems with diacritics, non-printable,
|
|
|
|
non-ASCII or uppercase characters, which should improve the portability of
|
|
|
|
elements created by users.
|
2009-04-03 19:30:25 +00:00
|
|
|
*/
|
|
|
|
class QFileNameEdit : public QLineEdit {
|
|
|
|
Q_OBJECT
|
2020-09-18 23:05:42 +02:00
|
|
|
|
2012-11-09 21:09:24 +00:00
|
|
|
// constructors, destructor
|
2009-04-03 19:30:25 +00:00
|
|
|
public:
|
2017-08-05 02:06:59 +00:00
|
|
|
QFileNameEdit(QWidget * = nullptr);
|
|
|
|
QFileNameEdit(const QString &, QWidget * = nullptr);
|
2017-08-05 02:10:01 +00:00
|
|
|
~QFileNameEdit() override;
|
2009-04-03 19:30:25 +00:00
|
|
|
private:
|
|
|
|
QFileNameEdit(const QFileNameEdit &);
|
2020-09-18 23:05:42 +02:00
|
|
|
|
2012-11-09 21:09:24 +00:00
|
|
|
// methods
|
2009-04-03 19:30:25 +00:00
|
|
|
public:
|
|
|
|
bool isEmpty();
|
|
|
|
bool isValid();
|
2020-09-18 23:05:42 +02:00
|
|
|
|
2009-04-03 19:30:25 +00:00
|
|
|
private:
|
|
|
|
void init();
|
|
|
|
void displayToolTip();
|
2020-09-18 23:05:42 +02:00
|
|
|
|
2009-04-03 19:30:25 +00:00
|
|
|
private slots:
|
|
|
|
void validationFailed();
|
2020-09-18 23:05:42 +02:00
|
|
|
|
2012-11-09 21:09:24 +00:00
|
|
|
// attributes
|
2009-04-03 19:30:25 +00:00
|
|
|
private:
|
2020-09-18 23:05:42 +02:00
|
|
|
QRegularExpression regexp_;
|
2009-04-03 19:30:25 +00:00
|
|
|
QETRegExpValidator *validator_;
|
|
|
|
QString tooltip_text_;
|
|
|
|
};
|
|
|
|
#endif
|