1 /* 2 Copyright 2006-2019 The QElectroTech Team 3 This file is part of QElectroTech. 4 5 QElectroTech is free software: you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published by 7 the Free Software Foundation, either version 2 of the License, or 8 (at your option) any later version. 9 10 QElectroTech is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. 17 */ 18 #ifndef NEW_ELEMENT_WIZARD_H 19 #define NEW_ELEMENT_WIZARD_H 20 21 #include <QWizard> 22 #include "elementslocation.h" 23 24 class NameListWidget; 25 class QFileNameEdit; 26 class QTreeView; 27 class ElementsCollectionModel; 28 29 /** 30 This class provides a wizard dialog enabling users to to specify the basic 31 parameters of the electrical elements they intend to draw. 32 33 These parameters include: 34 - the category the element should be saved to 35 - the filename the element should be saved to 36 - localized names 37 */ 38 class NewElementWizard : public QWizard 39 { 40 Q_OBJECT 41 42 // constructors, destructor 43 public: 44 NewElementWizard(QWidget * = nullptr, Qt::WindowFlags = nullptr); 45 ~NewElementWizard() override; 46 47 void preselectedLocation(const ElementsLocation &location); 48 49 private: 50 NewElementWizard(const NewElementWizard &); 51 52 // attributes 53 private: 54 enum WizardState { Category, Filename, Names }; 55 QFileNameEdit *m_qle_filename; 56 NameListWidget *m_names_list; 57 QString m_chosen_file; 58 QTreeView *m_tree_view = nullptr; 59 ElementsLocation m_chosen_location; 60 ElementsCollectionModel *m_model = nullptr; 61 62 // methods 63 private: 64 QWizardPage *buildStep1(); 65 QWizardPage *buildStep2(); 66 QWizardPage *buildStep3(); 67 bool validStep1(); 68 bool validStep2(); 69 bool validateCurrentPage() override; 70 void createNewElement(); 71 }; 72 #endif 73