QElectroTech 0.100.0-dev
Loading...
Searching...
No Matches
elementscollectionmodel.h
Go to the documentation of this file.
1/*
2 Copyright 2006-2024 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 <QHash>
23#include "elementslocation.h"
24
27template<> class QList<QETProject>;
28template<> class QHash<QETProject, XmlProjectElementCollectionItem>;
29template<> class QList<ElementCollectionItem>;
30
31
32class ElementsCollectionModel : public QStandardItemModel
33{
34 Q_OBJECT
35
36 public:
37 ElementsCollectionModel(QObject *parent = Q_NULLPTR);
38
39 QVariant data(const QModelIndex &index, int role) const override;
40 QMimeData *mimeData(const QModelIndexList &indexes) const override;
41 QStringList mimeTypes() const override;
42 bool canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const override;
43 bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override;
44
45 void loadCollections(bool common_collection, bool company_collection, bool custom_collection, QList<QETProject *> projects);
46
47 void addCommonCollection(bool set_data = true);
48 void addCompanyCollection(bool set_data = true);
49 void addCustomCollection(bool set_data = true);
50 void addLocation(const ElementsLocation& location);
51
52 void addProject(QETProject *project, bool set_data = true);
54 QList<QETProject *> project() const;
56
57
58 QList <ElementCollectionItem *> items() const;
59 QList <ElementCollectionItem *> projectItems(QETProject *project) const;
60 void hideElement();
62 QModelIndex indexFromLocation(const ElementsLocation &location);
63
64 signals:
68
69 private:
70 void elementIntegratedToCollection (const QString& path);
71 void itemRemovedFromCollection (const QString& path);
72 void updateItem (const QString& path);
73
74 private:
75 QList <QETProject *> m_project_list;
76 QHash <QETProject *, XmlProjectElementCollectionItem *> m_project_hash;
77 bool m_hide_element = false;
78 QFuture<void> m_future;
79 QList <ElementCollectionItem *> m_items_list_to_setUp;
80};
81
82#endif // ELEMENTSCOLLECTIONMODEL2_H
The ElementCollectionItem class This class represent a item (a directory or an element) in a element ...
Definition elementcollectionitem.h:30
Definition elementscollectionmodel.h:33
void highlightUnusedElement()
ElementsCollectionModel::highlightUnusedElement Highlight every unused element of managed project.
Definition elementscollectionmodel.cpp:499
void elementIntegratedToCollection(const QString &path)
ElementsCollectionModel::elementIntegratedToCollection When an element is added to embedded collectio...
Definition elementscollectionmodel.cpp:619
QVariant data(const QModelIndex &index, int role) const override
ElementsCollectionModel::data Reimplemented from QStandardItemModel.
Definition elementscollectionmodel.cpp:48
QStringList mimeTypes() const override
ElementsCollectionModel::mimeTypes Reimplemented from QStandardItemModel.
Definition elementscollectionmodel.cpp:95
bool isHideElement()
Definition elementscollectionmodel.h:61
QList< ElementCollectionItem * > m_items_list_to_setUp
Definition elementscollectionmodel.h:79
void itemRemovedFromCollection(const QString &path)
ElementsCollectionModel::itemRemovedFromCollection This method must be called by a signal,...
Definition elementscollectionmodel.cpp:654
bool m_hide_element
Definition elementscollectionmodel.h:77
void addCompanyCollection(bool set_data=true)
ElementsCollectionModel::addCompanyCollection Add the company elements collection to this model.
Definition elementscollectionmodel.cpp:331
QList< QETProject * > m_project_list
Definition elementscollectionmodel.h:75
void hideElement()
ElementsCollectionModel::hideElement Hide element in this model, only directory is managed.
Definition elementscollectionmodel.cpp:560
QMimeData * mimeData(const QModelIndexList &indexes) const override
ElementsCollectionModel::mimeData Reimplemented from QStandardItemModel.
Definition elementscollectionmodel.cpp:68
QList< ElementCollectionItem * > projectItems(QETProject *project) const
ElementsCollectionModel::projectItems.
Definition elementscollectionmodel.cpp:542
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override
ElementsCollectionModel::dropMimeData Reimplemented from QStandardItemModel.
Definition elementscollectionmodel.cpp:164
QHash< QETProject *, XmlProjectElementCollectionItem * > m_project_hash
Definition elementscollectionmodel.h:76
QModelIndex indexFromLocation(const ElementsLocation &location)
ElementsCollectionModel::indexFromLocation Return the index who represent location....
Definition elementscollectionmodel.cpp:577
QFuture< void > m_future
Definition elementscollectionmodel.h:78
void updateItem(const QString &path)
ElementsCollectionModel::updateItem Update the item at path.
Definition elementscollectionmodel.cpp:683
void addCommonCollection(bool set_data=true)
ElementsCollectionModel::addCommonCollection Add the common elements collection to this model.
Definition elementscollectionmodel.cpp:312
void addCustomCollection(bool set_data=true)
ElementsCollectionModel::addCustomCollection Add the custom elements collection to this model.
Definition elementscollectionmodel.cpp:350
void loadingProgressRangeChanged(int, int)
void addProject(QETProject *project, bool set_data=true)
ElementsCollectionModel::addProject Add project to this model.
Definition elementscollectionmodel.cpp:425
void loadCollections(bool common_collection, bool company_collection, bool custom_collection, QList< QETProject * > projects)
ElementsCollectionModel::loadCollections Load the several collections in this model....
Definition elementscollectionmodel.cpp:260
QList< QETProject * > project() const
ElementsCollectionModel::project.
Definition elementscollectionmodel.cpp:489
bool canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const override
ElementsCollectionModel::canDropMimeData Reimplemented from QStandardItemModel.
Definition elementscollectionmodel.cpp:113
void removeProject(QETProject *project)
ElementsCollectionModel::removeProject Remove project from this model.
Definition elementscollectionmodel.cpp:458
void addLocation(const ElementsLocation &location)
ElementsCollectionModel::addLocation Add the element or directory to this model. If the location is a...
Definition elementscollectionmodel.cpp:370
void loadingProgressValueChanged(int)
QList< ElementCollectionItem * > items() const
ElementsCollectionModel::items.
Definition elementscollectionmodel.cpp:524
The ElementsLocation class This class represents the location, the location of an element or of a cat...
Definition elementslocation.h:47
Definition qetproject.h:62
The XmlProjectElementCollectionItem class This class specialise ElementCollectionItem for manage an x...
Definition xmlprojectelementcollectionitem.h:32