QElectroTech  0.70
elementscollectionmodel.h
Go to the documentation of this file.
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 ELEMENTSCOLLECTIONMODEL2_H
19 #define ELEMENTSCOLLECTIONMODEL2_H
20 
21 #include <QStandardItemModel>
22 #include "elementslocation.h"
23 
26 template<> class QList<QETProject>;
27 template<> class QHash<QETProject, XmlProjectElementCollectionItem>;
28 template<> class QList<ElementCollectionItem>;
29 
30 
31 class ElementsCollectionModel : public QStandardItemModel
32 {
33  Q_OBJECT
34 
35  public:
36  ElementsCollectionModel(QObject *parent = Q_NULLPTR);
37 
38  QVariant data(const QModelIndex &index, int role) const override;
39  QMimeData *mimeData(const QModelIndexList &indexes) const override;
40  QStringList mimeTypes() const override;
41  bool canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const override;
42  bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override;
43 
44  void loadCollections(bool common_collection, bool custom_collection, QList<QETProject *> projects);
45 
46  void addCommonCollection(bool set_data = true);
47  void addCustomCollection(bool set_data = true);
48  void addLocation(const ElementsLocation& location);
49 
50  void addProject(QETProject *project, bool set_data = true);
52  QList<QETProject *> project() const;
54 
55 
56  QList <ElementCollectionItem *> items() const;
57  QList <ElementCollectionItem *> projectItems(QETProject *project) const;
58  void hideElement();
59  bool isHideElement() {return m_hide_element;}
60  QModelIndex indexFromLocation(const ElementsLocation &location);
61 
62  signals:
63  void loadingMaxValue(int);
64  void loadingProgressValue(int);
65 
66  private:
67  void elementIntegratedToCollection (const QString& path);
68  void itemRemovedFromCollection (const QString& path);
69  void updateItem (const QString& path);
70 
71  private:
72  QList <QETProject *> m_project_list;
73  QHash <QETProject *, XmlProjectElementCollectionItem *> m_project_hash;
74  bool m_hide_element = false;
75 };
76 
77 #endif // ELEMENTSCOLLECTIONMODEL2_H
The ElementCollectionItem class This class represent a item (a directory or an element) in a element ...
void addCommonCollection(bool set_data=true)
ElementsCollectionModel::addCommonCollection Add the common elements collection to this model...
QVariant data(const QModelIndex &index, int role) const override
ElementsCollectionModel::data Reimplemented from QStandardItemModel.
QList< ElementCollectionItem * > projectItems(QETProject *project) const
ElementsCollectionModel::projectItems.
void highlightUnusedElement()
ElementsCollectionModel::highlightUnusedElement Highlight every unused element of managed project...
ElementsCollectionModel(QObject *parent=Q_NULLPTR)
ElementsCollectionModel::ElementsCollectionModel Constructor.
void loadingProgressValue(int)
QHash< QETProject *, XmlProjectElementCollectionItem * > m_project_hash
QList< QETProject * > project() const
ElementsCollectionModel::project.
QStringList mimeTypes() const override
ElementsCollectionModel::mimeTypes Reimplemented from QStandardItemModel.
The XmlProjectElementCollectionItem class This class specialise ElementCollectionItem for manage an x...
void removeProject(QETProject *project)
ElementsCollectionModel::removeProject Remove project from this model.
void loadCollections(bool common_collection, bool custom_collection, QList< QETProject *> projects)
ElementsCollectionModel::loadCollections Load the several collections in this model. Prefer use this method instead of addCommonCollection, addCustomCollection and addProject, because it use multithreading to speed up the loading. This method emit loadingMaxValue(int) for know the maximum progress value This method emit loadingProgressValue(int) for know the current progress value.
void elementIntegratedToCollection(const QString &path)
ElementsCollectionModel::elementIntegratedToCollection When an element is added to embedded collectio...
QList< ElementCollectionItem * > items() const
ElementsCollectionModel::items.
bool canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const override
ElementsCollectionModel::canDropMimeData Reimplemented from QStandardItemModel.
void addLocation(const ElementsLocation &location)
ElementsCollectionModel::addLocation Add the element or directory to this model. If the location is a...
void hideElement()
ElementsCollectionModel::hideElement Hide element in this model, only directory is managed...
QList< QETProject * > m_project_list
void itemRemovedFromCollection(const QString &path)
ElementsCollectionModel::itemRemovedFromCollection This method must be called by a signal...
void updateItem(const QString &path)
ElementsCollectionModel::updateItem Update the item at path.
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override
ElementsCollectionModel::dropMimeData Reimplemented from QStandardItemModel.
void addProject(QETProject *project, bool set_data=true)
ElementsCollectionModel::addProject Add project to this model.
QMimeData * mimeData(const QModelIndexList &indexes) const override
ElementsCollectionModel::mimeData Reimplemented from QStandardItemModel.
void addCustomCollection(bool set_data=true)
ElementsCollectionModel::addCustomCollection Add the custom elements collection to this model...
QModelIndex indexFromLocation(const ElementsLocation &location)
ElementsCollectionModel::indexFromLocation Return the index who represent . Index can be non valid...