QElectroTech 0.200.1-dev
Loading...
Searching...
No Matches
elementscollectionmodel.h
Go to the documentation of this file.
1/*
2 Copyright 2006-2026 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 ~ElementsCollectionModel() override;
39
40 QVariant data(const QModelIndex &index, int role) const override;
41 QMimeData *mimeData(const QModelIndexList &indexes) const override;
42 QStringList mimeTypes() const override;
43 bool canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const override;
44 bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override;
45
46 void loadCollections(bool common_collection, bool company_collection, bool custom_collection, QList<QETProject *> projects);
47
48 void addCommonCollection(bool set_data = true);
49 void addCompanyCollection(bool set_data = true);
50 void addCustomCollection(bool set_data = true);
51 void addMacrosCollection(bool set_data = true);
53 void addLocation(const ElementsLocation& location);
54
55 void addProject(QETProject *project, bool set_data = true);
57 QList<QETProject *> project() const;
59
60
61 QList <ElementCollectionItem *> items() const;
62 QList <ElementCollectionItem *> projectItems(QETProject *project) const;
63 void hideElement();
65 QModelIndex indexFromLocation(const ElementsLocation &location);
66
67 signals:
71
72 private:
73 void elementIntegratedToCollection (const QString& path);
74 void itemRemovedFromCollection (const QString& path);
75 void updateItem (const QString& path);
76
77 private:
78 QList <QETProject *> m_project_list;
79 QHash <QETProject *, XmlProjectElementCollectionItem *> m_project_hash;
80 bool m_hide_element = false;
81 QFuture<void> m_future;
82 QList <ElementCollectionItem *> m_items_list_to_setUp;
83};
84
85#endif // ELEMENTSCOLLECTIONMODEL2_H
The ElementCollectionItem class This class represent a item (a directory or an element) in a element ...
Definition elementcollectionitem.h:30
void highlightUnusedElement()
ElementsCollectionModel::highlightUnusedElement Highlight every unused element of managed project.
Definition elementscollectionmodel.cpp:546
void elementIntegratedToCollection(const QString &path)
ElementsCollectionModel::elementIntegratedToCollection When an element is added to embedded collectio...
Definition elementscollectionmodel.cpp:680
QVariant data(const QModelIndex &index, int role) const override
ElementsCollectionModel::data Reimplemented from QStandardItemModel.
Definition elementscollectionmodel.cpp:62
void loadMacrosCollection()
ElementsCollectionModel::loadMacrosCollection Load the macros collection synchronously to avoid threa...
Definition elementscollectionmodel.cpp:320
QStringList mimeTypes() const override
ElementsCollectionModel::mimeTypes Reimplemented from QStandardItemModel.
Definition elementscollectionmodel.cpp:110
bool isHideElement()
Definition elementscollectionmodel.h:64
QList< ElementCollectionItem * > m_items_list_to_setUp
Definition elementscollectionmodel.h:82
void itemRemovedFromCollection(const QString &path)
ElementsCollectionModel::itemRemovedFromCollection This method must be called by a signal,...
Definition elementscollectionmodel.cpp:715
void addMacrosCollection(bool set_data=true)
ElementsCollectionModel::addMacrosCollection Add the user macros collection to this model.
Definition elementscollectionmodel.cpp:331
bool m_hide_element
Definition elementscollectionmodel.h:80
void addCompanyCollection(bool set_data=true)
ElementsCollectionModel::addCompanyCollection Add the company elements collection to this model.
Definition elementscollectionmodel.cpp:374
QList< QETProject * > m_project_list
Definition elementscollectionmodel.h:78
void hideElement()
ElementsCollectionModel::hideElement Hide element in this model, only directory is managed.
Definition elementscollectionmodel.cpp:617
ElementsCollectionModel(QObject *parent=Q_NULLPTR)
ElementsCollectionModel::ElementsCollectionModel Constructor.
Definition elementscollectionmodel.cpp:36
QMimeData * mimeData(const QModelIndexList &indexes) const override
ElementsCollectionModel::mimeData Reimplemented from QStandardItemModel.
Definition elementscollectionmodel.cpp:83
QList< ElementCollectionItem * > projectItems(QETProject *project) const
ElementsCollectionModel::projectItems.
Definition elementscollectionmodel.cpp:599
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override
ElementsCollectionModel::dropMimeData Reimplemented from QStandardItemModel.
Definition elementscollectionmodel.cpp:179
QHash< QETProject *, XmlProjectElementCollectionItem * > m_project_hash
Definition elementscollectionmodel.h:79
QModelIndex indexFromLocation(const ElementsLocation &location)
ElementsCollectionModel::indexFromLocation Return the index who represent location....
Definition elementscollectionmodel.cpp:634
QFuture< void > m_future
Definition elementscollectionmodel.h:81
void updateItem(const QString &path)
ElementsCollectionModel::updateItem Update the item at path.
Definition elementscollectionmodel.cpp:744
void addCommonCollection(bool set_data=true)
ElementsCollectionModel::addCommonCollection Add the common elements collection to this model.
Definition elementscollectionmodel.cpp:355
void addCustomCollection(bool set_data=true)
ElementsCollectionModel::addCustomCollection Add the custom elements collection to this model.
Definition elementscollectionmodel.cpp:393
void loadingProgressRangeChanged(int, int)
void addProject(QETProject *project, bool set_data=true)
ElementsCollectionModel::addProject Add project to this model.
Definition elementscollectionmodel.cpp:472
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:277
QList< QETProject * > project() const
ElementsCollectionModel::project.
Definition elementscollectionmodel.cpp:536
~ElementsCollectionModel() override
ElementsCollectionModel::~ElementsCollectionModel Destructor. loadCollections() may still have backgr...
Definition elementscollectionmodel.cpp:50
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:128
void removeProject(QETProject *project)
ElementsCollectionModel::removeProject Remove project from this model.
Definition elementscollectionmodel.cpp:505
void addLocation(const ElementsLocation &location)
ElementsCollectionModel::addLocation Add the element or directory to this model. If the location is a...
Definition elementscollectionmodel.cpp:413
void loadingProgressValueChanged(int)
QList< ElementCollectionItem * > items() const
ElementsCollectionModel::items.
Definition elementscollectionmodel.cpp:581
The ElementsLocation class This class represents the location, the location of an element or of a cat...
Definition elementslocation.h:47
Definition qetproject.h:77
The XmlProjectElementCollectionItem class This class specialise ElementCollectionItem for manage an x...
Definition xmlprojectelementcollectionitem.h:32