2015-12-08 16:52:10 +00:00
|
|
|
/*
|
2021-02-20 12:13:46 +01:00
|
|
|
Copyright 2006-2021 The QElectroTech Team
|
2015-12-08 16:52:10 +00:00
|
|
|
This file is part of QElectroTech.
|
|
|
|
|
|
|
|
QElectroTech is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
QElectroTech is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2016-06-05 16:34:46 +00:00
|
|
|
#ifndef ELEMENTSCOLLECTIONMODEL2_H
|
|
|
|
#define ELEMENTSCOLLECTIONMODEL2_H
|
2015-12-08 16:52:10 +00:00
|
|
|
|
2016-06-05 16:34:46 +00:00
|
|
|
#include <QStandardItemModel>
|
2020-09-21 21:19:50 +02:00
|
|
|
#include <QHash>
|
2016-05-15 14:46:01 +00:00
|
|
|
#include "elementslocation.h"
|
2015-12-08 16:52:10 +00:00
|
|
|
|
2016-01-08 17:01:51 +00:00
|
|
|
class XmlProjectElementCollectionItem;
|
2016-06-05 16:34:46 +00:00
|
|
|
class ElementCollectionItem;
|
2016-06-30 09:12:25 +00:00
|
|
|
template<> class QList<QETProject>;
|
|
|
|
template<> class QHash<QETProject, XmlProjectElementCollectionItem>;
|
|
|
|
template<> class QList<ElementCollectionItem>;
|
|
|
|
|
|
|
|
|
2016-06-05 16:34:46 +00:00
|
|
|
class ElementsCollectionModel : public QStandardItemModel
|
2015-12-08 16:52:10 +00:00
|
|
|
{
|
2016-06-05 16:34:46 +00:00
|
|
|
Q_OBJECT
|
2015-12-08 16:52:10 +00:00
|
|
|
|
|
|
|
public:
|
2016-06-05 16:34:46 +00:00
|
|
|
ElementsCollectionModel(QObject *parent = Q_NULLPTR);
|
2015-12-12 11:09:31 +00:00
|
|
|
|
2017-08-05 02:10:01 +00:00
|
|
|
QVariant data(const QModelIndex &index, int role) const override;
|
|
|
|
QMimeData *mimeData(const QModelIndexList &indexes) const override;
|
|
|
|
QStringList mimeTypes() const override;
|
|
|
|
bool canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const override;
|
|
|
|
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override;
|
2015-12-08 16:52:10 +00:00
|
|
|
|
2016-07-14 11:58:56 +00:00
|
|
|
void loadCollections(bool common_collection, bool custom_collection, QList<QETProject *> projects);
|
|
|
|
|
2016-06-05 16:34:46 +00:00
|
|
|
void addCommonCollection(bool set_data = true);
|
|
|
|
void addCustomCollection(bool set_data = true);
|
2018-07-19 14:14:31 +00:00
|
|
|
void addLocation(const ElementsLocation& location);
|
2016-06-05 16:34:46 +00:00
|
|
|
|
|
|
|
void addProject(QETProject *project, bool set_data = true);
|
|
|
|
void removeProject(QETProject *project);
|
2015-12-16 17:16:15 +00:00
|
|
|
QList<QETProject *> project() const;
|
2016-06-30 09:12:25 +00:00
|
|
|
void highlightUnusedElement();
|
|
|
|
|
2016-06-05 16:34:46 +00:00
|
|
|
|
|
|
|
QList <ElementCollectionItem *> items() const;
|
2016-08-10 05:23:48 +00:00
|
|
|
QList <ElementCollectionItem *> projectItems(QETProject *project) const;
|
2016-05-15 14:46:01 +00:00
|
|
|
void hideElement();
|
2016-06-05 16:34:46 +00:00
|
|
|
bool isHideElement() {return m_hide_element;}
|
|
|
|
QModelIndex indexFromLocation(const ElementsLocation &location);
|
2015-12-08 16:52:10 +00:00
|
|
|
|
2016-07-14 11:58:56 +00:00
|
|
|
signals:
|
2020-01-19 11:53:40 +01:00
|
|
|
void loadingProgressValueChanged(int);
|
|
|
|
void loadingProgressRangeChanged(int, int);
|
|
|
|
void loadingFinished();
|
2016-07-14 11:58:56 +00:00
|
|
|
|
2016-01-08 17:01:51 +00:00
|
|
|
private:
|
2018-07-19 14:14:31 +00:00
|
|
|
void elementIntegratedToCollection (const QString& path);
|
|
|
|
void itemRemovedFromCollection (const QString& path);
|
|
|
|
void updateItem (const QString& path);
|
2016-01-08 17:01:51 +00:00
|
|
|
|
2015-12-08 16:52:10 +00:00
|
|
|
private:
|
2015-12-16 17:16:15 +00:00
|
|
|
QList <QETProject *> m_project_list;
|
2016-06-05 16:34:46 +00:00
|
|
|
QHash <QETProject *, XmlProjectElementCollectionItem *> m_project_hash;
|
2016-05-15 14:46:01 +00:00
|
|
|
bool m_hide_element = false;
|
2020-01-19 11:53:40 +01:00
|
|
|
QFuture<void> m_future;
|
|
|
|
QList <ElementCollectionItem *> m_items_list_to_setUp;
|
2015-12-08 16:52:10 +00:00
|
|
|
};
|
|
|
|
|
2016-06-05 16:34:46 +00:00
|
|
|
#endif // ELEMENTSCOLLECTIONMODEL2_H
|