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 DIAGRAMS_CHOOSER_H 19 #define DIAGRAMS_CHOOSER_H 20 #include <QtWidgets> 21 class QETProject; 22 class Diagram; 23 /** 24 This class provides a widget which allows users to select 0 to n diagrams 25 among those of a particular project. 26 */ 27 class DiagramsChooser : public QScrollArea { 28 Q_OBJECT 29 30 // constructors, destructor 31 public: 32 DiagramsChooser(QETProject *, QWidget * = nullptr); 33 ~DiagramsChooser() override; 34 private: 35 DiagramsChooser(const DiagramsChooser &); 36 37 // methods 38 public: 39 QETProject *project() const; 40 QList<Diagram *> selectedDiagrams() const; 41 QList<Diagram *> nonSelectedDiagrams() const; 42 bool diagramIsSelected(Diagram * const) const; 43 void setSelectedDiagrams(const QList<Diagram *> &, bool = true, bool = true); 44 void setSelectedAllDiagrams(bool = true); 45 46 public slots: 47 void updateList(); 48 49 signals: 50 void selectionChanged(); 51 52 private: 53 void buildLayout(); 54 55 // attributes 56 private: 57 QETProject *project_; 58 QWidget *widget0_; 59 QVBoxLayout *vlayout0_; 60 QHash<Diagram *, QCheckBox *> diagrams_; 61 }; 62 #endif 63