QElectroTech  0.8-dev
elementspanel.h
Go to the documentation of this file.
1 /*
2  Copyright 2006-2020 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 PANELAPPAREILS_H
19 #define PANELAPPAREILS_H
20 
21 #include "genericpanel.h"
22 #include "templatelocation.h"
23 
24 class QETProject;
25 class Diagram;
27 
34 class ElementsPanel : public GenericPanel {
35  Q_OBJECT
36 
37  // constructors, destructor
38  public:
39  ElementsPanel(QWidget * = nullptr);
40  ~ElementsPanel() override;
41 
42  private:
44 
45  // methods
46  public:
47  // methods used to determine what is represented by a particular visual item
48 
49  // methods used to get what is represented by a particular visual item
50  QString dirPathForItem(QTreeWidgetItem *);
51  QString filePathForItem(QTreeWidgetItem *);
52 
53  signals:
57 
58  public slots:
59  void slot_doubleClick(QTreeWidgetItem *, int);
60  void reload(bool = false);
61  void filter(const QString &, QET::Filtering = QET::RegularFilter);
64  void buildFilterList();
65  void applyCurrentFilter(const QList<QTreeWidgetItem *> &);
66  void ensureHierarchyIsVisible(const QList<QTreeWidgetItem *> &);
67 
68  protected:
69  void startDrag(Qt::DropActions) override;
71  bool matchesFilter(const QTreeWidgetItem *, const QString&) const;
72 
73  protected slots:
74  void panelContentChange();
75 
76  private:
77  QTreeWidgetItem *addProject (QETProject *, QTreeWidgetItem * = nullptr, PanelOptions = AddAllChild) override;
78  QTreeWidgetItem *updateTemplatesCollectionItem(QTreeWidgetItem *, TitleBlockTemplatesCollection *, PanelOptions = AddAllChild, bool = false) override;
79  QTreeWidgetItem *updateTemplateItem (QTreeWidgetItem *, const TitleBlockTemplateLocation &, PanelOptions, bool = false) override;
80 
81  // attributes
82  private:
83  QSet<QETProject *> projects_to_display_;
84  QTreeWidgetItem *common_tbt_collection_item_;
85  QTreeWidgetItem *custom_tbt_collection_item_;
87  QString filter_;
88  QStringList filter_list_;
89 };
90 #endif
QET::Project
@ Project
Definition: qet.h:109
ElementsPanel::common_tbt_collection_item_
QTreeWidgetItem * common_tbt_collection_item_
pointer to the item representing the common templates collection
Definition: elementspanel.h:84
ElementsPanel::filter_list_
QStringList filter_list_
Currently applied list of filter.
Definition: elementspanel.h:88
ElementsPanel::panelContentChange
void panelContentChange()
Definition: elementspanel.cpp:114
ElementsPanel::~ElementsPanel
~ElementsPanel() override
Definition: elementspanel.cpp:77
GenericPanel
The GenericPanel class The generic panel is a QTreeWidget subclass providing extra methods allowing d...
Definition: genericpanel.h:36
GenericPanel::updateTemplateItem
virtual QTreeWidgetItem * updateTemplateItem(QTreeWidgetItem *, const TitleBlockTemplateLocation &, PanelOptions=AddAllChild, bool=false)
GenericPanel::updateTemplateItem.
Definition: genericpanel.cpp:621
ElementsPanel::updateTemplatesCollectionItem
QTreeWidgetItem * updateTemplatesCollectionItem(QTreeWidgetItem *, TitleBlockTemplatesCollection *, PanelOptions=AddAllChild, bool=false) override
GenericPanel::updateTemplatesCollectionItem.
Definition: elementspanel.cpp:160
ElementsPanel::startTitleBlockTemplateDrag
void startTitleBlockTemplateDrag(const TitleBlockTemplateLocation &)
Definition: elementspanel.cpp:98
GenericPanel::templateLocationForItem
virtual TitleBlockTemplateLocation templateLocationForItem(QTreeWidgetItem *) const
GenericPanel::templateLocationForItem.
Definition: genericpanel.cpp:84
QET::RegularFilter
@ RegularFilter
Definition: qet.h:118
ElementsPanel::startDrag
void startDrag(Qt::DropActions) override
Definition: elementspanel.cpp:84
QETApp::commonTitleBlockTemplatesCollection
static TitleBlockTemplatesFilesCollection * commonTitleBlockTemplatesCollection()
QETApp::commonTitleBlockTemplatesCollection.
Definition: qetapp.cpp:521
GenericPanel::updateTemplatesCollectionItem
virtual QTreeWidgetItem * updateTemplatesCollectionItem(QTreeWidgetItem *, TitleBlockTemplatesCollection *, PanelOptions=AddAllChild, bool=false)
GenericPanel::updateTemplatesCollectionItem.
Definition: genericpanel.cpp:483
GenericPanel::firstActivated
bool firstActivated()
ElementsPanel::ElementsPanel
ElementsPanel(QWidget *=nullptr)
Definition: elementspanel.cpp:39
GenericPanel::projectForItem
virtual QETProject * projectForItem(QTreeWidgetItem *) const
GenericPanel::projectForItem.
Definition: genericpanel.cpp:59
QET::Diagram
@ Diagram
Definition: qet.h:108
ElementsPanel::updateTemplateItem
QTreeWidgetItem * updateTemplateItem(QTreeWidgetItem *, const TitleBlockTemplateLocation &, PanelOptions, bool=false) override
GenericPanel::updateTemplateItem.
Definition: elementspanel.cpp:177
GenericPanel::addTemplatesCollection
virtual QTreeWidgetItem * addTemplatesCollection(TitleBlockTemplatesCollection *, QTreeWidgetItem *=nullptr, PanelOptions=AddAllChild)
GenericPanel::addTemplatesCollection.
Definition: genericpanel.cpp:417
qetapp.h
QET::TitleBlockTemplate
@ TitleBlockTemplate
Definition: qet.h:105
GenericPanel::itemForProject
virtual QTreeWidgetItem * itemForProject(QETProject *)
Definition: genericpanel.cpp:143
ElementsPanel::requestForDiagram
void requestForDiagram(Diagram *)
TitleBlockTemplatesFilesCollection
Definition: templatescollection.h:124
ElementsPanel::custom_tbt_collection_item_
QTreeWidgetItem * custom_tbt_collection_item_
pointer to the item representing the user templates collection
Definition: elementspanel.h:85
Diagram
The Diagram class This class represents an electric diagram. It manages its various child elements,...
Definition: diagram.h:56
ElementsPanel::projectWasOpened
void projectWasOpened(QETProject *)
Definition: elementspanel.cpp:356
qeticons.h
GenericPanel::All
@ All
Definition: genericpanel.h:46
GenericPanel::itemForTemplatesCollection
virtual QTreeWidgetItem * itemForTemplatesCollection(TitleBlockTemplatesCollection *)
GenericPanel::itemForTemplatesCollection.
Definition: genericpanel.cpp:446
ElementsPanel::filter_
QString filter_
Currently applied filter.
Definition: elementspanel.h:87
ElementsPanel::filePathForItem
QString filePathForItem(QTreeWidgetItem *)
ElementsPanel::filePathForItem.
Definition: elementspanel.cpp:295
TitleBlockTemplateLocation::isValid
bool isValid() const
Definition: templatelocation.cpp:87
TitleBlockTemplateLocation
Definition: templatelocation.h:29
QETApp::customTitleBlockTemplatesCollection
static TitleBlockTemplatesFilesCollection * customTitleBlockTemplatesCollection()
QETApp::customTitleBlockTemplatesCollection.
Definition: qetapp.cpp:541
ElementsPanel::filter
void filter(const QString &, QET::Filtering=QET::RegularFilter)
Definition: elementspanel.cpp:321
TitleBlockTemplateLocation::toString
QString toString() const
Definition: templatelocation.cpp:108
templatescollection.h
ElementsPanel::applyCurrentFilter
void applyCurrentFilter(const QList< QTreeWidgetItem * > &)
Definition: elementspanel.cpp:392
ElementsPanel::dirPathForItem
QString dirPathForItem(QTreeWidgetItem *)
ElementsPanel::dirPathForItem.
Definition: elementspanel.cpp:276
ElementsPanel::first_reload_
bool first_reload_
used to distinguish the first time this panel is reloaded
Definition: elementspanel.h:86
ElementsPanel::requestForProject
void requestForProject(QETProject *)
GenericPanel::selectedTemplateLocation
virtual TitleBlockTemplateLocation selectedTemplateLocation() const
GenericPanel::selectedTemplateLocation.
Definition: genericpanel.cpp:112
GenericPanel::AddAllChild
@ AddAllChild
Definition: genericpanel.h:45
qetproject.h
GenericPanel::panelContentChanged
void panelContentChanged()
ElementsPanel::reload
void reload(bool=false)
ElementsPanel::reload Reload the elements tree.
Definition: elementspanel.cpp:218
GenericPanel::addProject
virtual QTreeWidgetItem * addProject(QETProject *, QTreeWidgetItem *=nullptr, PanelOptions=AddAllChild)
GenericPanel::addProject.
Definition: genericpanel.cpp:123
QETProject
Definition: qetproject.h:51
ElementsPanel::ensureHierarchyIsVisible
void ensureHierarchyIsVisible(const QList< QTreeWidgetItem * > &)
Definition: elementspanel.cpp:416
ElementsPanel::projects_to_display_
QSet< QETProject * > projects_to_display_
list of projects that have been added to this panel
Definition: elementspanel.h:83
QET::EndFilter
@ EndFilter
Definition: qet.h:119
TitleBlockTemplateLocation::parentCollection
TitleBlockTemplatesCollection * parentCollection() const
Definition: templatelocation.cpp:57
QET::Filtering
Filtering
Definition: qet.h:116
ElementsPanel::ElementsPanel
ElementsPanel(const ElementsPanel &)
ElementsPanel
Definition: elementspanel.h:34
ElementsPanel::addProject
QTreeWidgetItem * addProject(QETProject *, QTreeWidgetItem *=nullptr, PanelOptions=AddAllChild) override
ElementsPanel::addProject Methode permettant d'ajouter un projet au panel d'elements.
Definition: elementspanel.cpp:131
TitleBlockTemplatesCollection
Definition: templatescollection.h:34
templatelocation.h
genericpanel.h
elementspanel.h
QET::BeginFilter
@ BeginFilter
Definition: qet.h:117
ElementsPanel::buildFilterList
void buildFilterList()
Definition: elementspanel.cpp:377
QET::Icons::tr
QIcon tr
Definition: qeticons.cpp:206
ElementsPanel::requestForTitleBlockTemplate
void requestForTitleBlockTemplate(const TitleBlockTemplateLocation &)
QET::Icons::TitleBlock
QIcon TitleBlock
Definition: qeticons.cpp:165
ElementsPanel::projectWasClosed
void projectWasClosed(QETProject *)
Definition: elementspanel.cpp:366
GenericPanel::deleteItem
virtual void deleteItem(QTreeWidgetItem *, bool=false)
GenericPanel::deleteItem Delete and item and its children.
Definition: genericpanel.cpp:887
ElementsPanel::slot_doubleClick
void slot_doubleClick(QTreeWidgetItem *, int)
Definition: elementspanel.cpp:257
diagram.h
ElementsPanel::matchesFilter
bool matchesFilter(const QTreeWidgetItem *, const QString &) const
Definition: elementspanel.cpp:199