2009-04-03 19:30:25 +00:00
|
|
|
/*
|
2015-02-20 14:56:22 +00:00
|
|
|
Copyright 2006-2015 The QElectroTech Team
|
2009-04-03 19:30:25 +00:00
|
|
|
This file is part of QElectroTech.
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
#ifndef ELEMENT_DIALOG_H
|
|
|
|
#define ELEMENT_DIALOG_H
|
|
|
|
#include <QtCore>
|
|
|
|
#include "elementslocation.h"
|
|
|
|
class QDialog;
|
|
|
|
class QDialogButtonBox;
|
|
|
|
class ElementsCategoriesList;
|
|
|
|
class QFileNameEdit;
|
|
|
|
/**
|
2012-11-09 21:09:24 +00:00
|
|
|
This class provides several dialogs to select an element or a category
|
|
|
|
(e.g. new or existing, for opening or for saving...).
|
2009-04-03 19:30:25 +00:00
|
|
|
*/
|
|
|
|
class ElementDialog : public QObject {
|
|
|
|
Q_OBJECT
|
|
|
|
// enumerations
|
|
|
|
/**
|
2012-11-09 21:09:24 +00:00
|
|
|
This enum represents the available configurations for the required dialog
|
2009-04-03 19:30:25 +00:00
|
|
|
*/
|
|
|
|
enum {
|
2012-11-09 21:09:24 +00:00
|
|
|
OpenElement = 0, ///< The dialog should open an element
|
|
|
|
SaveElement = 1, ///< The dialog should select an element for saving
|
|
|
|
OpenCategory = 2, ///< The dialog should open a category
|
|
|
|
SaveCategory = 3 ///< The dialog should select a category for saving
|
2009-04-03 19:30:25 +00:00
|
|
|
};
|
|
|
|
|
2012-11-09 21:09:24 +00:00
|
|
|
// constructors, destructor
|
2009-04-03 19:30:25 +00:00
|
|
|
public:
|
2009-08-13 18:30:06 +00:00
|
|
|
ElementDialog(uint = ElementDialog::OpenElement, QWidget * = 0, QObject * = 0);
|
2009-04-03 19:30:25 +00:00
|
|
|
virtual ~ElementDialog();
|
|
|
|
private:
|
|
|
|
ElementDialog(const ElementDialog &);
|
|
|
|
|
2012-11-09 21:09:24 +00:00
|
|
|
// methods
|
2009-04-03 19:30:25 +00:00
|
|
|
public:
|
|
|
|
int exec();
|
|
|
|
ElementsLocation location() const;
|
2009-08-13 18:30:06 +00:00
|
|
|
static ElementsLocation getExistingCategoryLocation(QWidget * = 0);
|
|
|
|
static ElementsLocation getNewCategoryLocation(QWidget * = 0);
|
|
|
|
static ElementsLocation getOpenElementLocation(QWidget * = 0);
|
|
|
|
static ElementsLocation getSaveElementLocation(QWidget * = 0);
|
2009-04-03 19:30:25 +00:00
|
|
|
|
|
|
|
private:
|
2009-08-13 18:30:06 +00:00
|
|
|
static ElementsLocation execConfiguredDialog(int, QWidget * = 0);
|
2009-04-03 19:30:25 +00:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
void locationChanged(const ElementsLocation &);
|
|
|
|
void textFieldChanged(const QString &);
|
|
|
|
void dialogAccepted();
|
|
|
|
void dialogRejected();
|
|
|
|
void checkDialog();
|
|
|
|
|
|
|
|
private:
|
|
|
|
void makeInterface();
|
|
|
|
|
2012-11-09 21:09:24 +00:00
|
|
|
// attributes
|
2009-04-03 19:30:25 +00:00
|
|
|
private:
|
|
|
|
uint mode_;
|
|
|
|
ElementsLocation location_;
|
|
|
|
QString title_;
|
|
|
|
QString label_;
|
|
|
|
QDialog *dialog_;
|
|
|
|
QDialogButtonBox *buttons_;
|
|
|
|
ElementsCategoriesList *list_;
|
|
|
|
QFileNameEdit *textfield_;
|
|
|
|
};
|
|
|
|
#endif
|