2007-12-01 10:47:15 +00:00
|
|
|
/*
|
2011-03-02 00:16:40 +00:00
|
|
|
Copyright 2006-2011 Xavier Guerrin
|
2007-12-01 10:47:15 +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/>.
|
|
|
|
*/
|
2006-10-27 15:47:22 +00:00
|
|
|
#ifndef PANELAPPAREILS_H
|
2007-04-12 03:13:13 +00:00
|
|
|
#define PANELAPPAREILS_H
|
|
|
|
#include <QtGui>
|
2009-04-03 19:30:25 +00:00
|
|
|
#include "elementslocation.h"
|
|
|
|
class QETProject;
|
|
|
|
class Diagram;
|
|
|
|
class ElementsCollection;
|
|
|
|
class ElementsCollectionItem;
|
|
|
|
class ElementsCategory;
|
|
|
|
class ElementDefinition;
|
2007-04-12 03:13:13 +00:00
|
|
|
/**
|
|
|
|
Cette classe represente le panel d'appareils (en tant qu'element
|
|
|
|
graphique) dans lequel l'utilisateur choisit les composants de
|
|
|
|
son choix et les depose sur le schema par drag'n drop.
|
|
|
|
*/
|
|
|
|
class ElementsPanel : public QTreeWidget {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
// constructeurs, destructeur
|
|
|
|
public:
|
|
|
|
ElementsPanel(QWidget * = 0);
|
|
|
|
virtual ~ElementsPanel();
|
|
|
|
|
|
|
|
private:
|
|
|
|
ElementsPanel(const ElementsPanel &);
|
|
|
|
|
|
|
|
// methodes
|
2007-08-28 21:17:11 +00:00
|
|
|
public:
|
2009-04-03 19:30:25 +00:00
|
|
|
// methodes pour determiner ce que represente un item donne
|
|
|
|
bool itemIsACollection(QTreeWidgetItem *) const;
|
|
|
|
bool itemIsACategory(QTreeWidgetItem *) const;
|
|
|
|
bool itemIsAnElement(QTreeWidgetItem *) const;
|
|
|
|
bool itemIsAProject(QTreeWidgetItem *) const;
|
|
|
|
bool itemIsADiagram(QTreeWidgetItem *) const;
|
|
|
|
bool itemHasLocation(QTreeWidgetItem *) const;
|
|
|
|
bool itemIsWritable(QTreeWidgetItem *) const;
|
2010-12-24 21:00:11 +00:00
|
|
|
bool itemIsATitleBlockTemplatesDirectory(QTreeWidgetItem *) const;
|
|
|
|
bool itemIsATitleBlockTemplate(QTreeWidgetItem *) const;
|
2009-04-03 19:30:25 +00:00
|
|
|
|
|
|
|
// methodes pour obtenir ce que represente un item donne
|
|
|
|
ElementsCollectionItem *collectionItemForItem(QTreeWidgetItem *) const;
|
|
|
|
QETProject *projectForItem(QTreeWidgetItem *) const;
|
|
|
|
Diagram *diagramForItem(QTreeWidgetItem *) const;
|
|
|
|
ElementsLocation locationForItem(QTreeWidgetItem *) const;
|
|
|
|
ElementsCategory *categoryForItem(QTreeWidgetItem *);
|
|
|
|
ElementsCategory *categoryForPos(const QPoint &);
|
2010-12-24 21:00:11 +00:00
|
|
|
QETProject *projectForTitleBlockTemplatesDirectory(QTreeWidgetItem *);
|
|
|
|
QETProject *projectForTitleBlockTemplate(QTreeWidgetItem *);
|
|
|
|
QString nameOfTitleBlockTemplate(QTreeWidgetItem *);
|
2009-04-03 19:30:25 +00:00
|
|
|
|
|
|
|
// methodes pour determiner ce que represente l'item selectionne
|
|
|
|
bool selectedItemIsACollection() const;
|
2007-08-28 21:17:11 +00:00
|
|
|
bool selectedItemIsACategory() const;
|
2009-04-03 19:30:25 +00:00
|
|
|
bool selectedItemIsAnElement() const;
|
|
|
|
bool selectedItemIsAProject() const;
|
|
|
|
bool selectedItemIsADiagram() const;
|
|
|
|
bool selectedItemHasLocation() const;
|
|
|
|
bool selectedItemIsWritable() const;
|
2010-12-24 21:00:11 +00:00
|
|
|
bool selectedItemIsATitleBlockTemplatesDirectory() const;
|
|
|
|
bool selectedItemIsATitleBlockTemplate() const;
|
2007-08-28 21:17:11 +00:00
|
|
|
|
2009-04-03 19:30:25 +00:00
|
|
|
// methodes pour obtenir ce que represente l'item selectionne
|
|
|
|
ElementsCollectionItem *selectedItem() const;
|
|
|
|
QETProject *selectedProject() const;
|
|
|
|
Diagram *selectedDiagram() const;
|
|
|
|
ElementsLocation selectedLocation() const;
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void requestForProject(QETProject *);
|
|
|
|
void requestForDiagram(Diagram *);
|
|
|
|
void requestForCollectionItem(ElementsCollectionItem *);
|
|
|
|
void requestForMoveElements(ElementsCollectionItem *, ElementsCollectionItem *, QPoint);
|
2007-04-12 03:13:13 +00:00
|
|
|
|
|
|
|
public slots:
|
2007-06-30 17:41:07 +00:00
|
|
|
void slot_doubleClick(QTreeWidgetItem *, int);
|
2009-04-03 19:30:25 +00:00
|
|
|
void reload(bool = true);
|
|
|
|
void filter(const QString &);
|
|
|
|
void projectWasOpened(QETProject *);
|
|
|
|
void projectWasClosed(QETProject *);
|
|
|
|
void projectInformationsChanged(QETProject *);
|
2010-12-24 21:00:11 +00:00
|
|
|
void projectTemplatesChanged(QETProject *);
|
2009-04-03 19:30:25 +00:00
|
|
|
void diagramWasAdded(QETProject *, Diagram *);
|
|
|
|
void diagramWasRemoved(QETProject *, Diagram *);
|
|
|
|
void diagramTitleChanged(QETProject *, Diagram *);
|
|
|
|
void diagramOrderChanged(QETProject *, int, int);
|
2009-05-19 19:00:37 +00:00
|
|
|
bool scrollToElement(const ElementsLocation &);
|
2009-04-03 19:30:25 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void dragEnterEvent(QDragEnterEvent *);
|
2007-04-12 03:13:13 +00:00
|
|
|
void dragMoveEvent(QDragMoveEvent *);
|
|
|
|
void dropEvent(QDropEvent *);
|
|
|
|
void startDrag(Qt::DropActions);
|
2009-04-03 19:30:25 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
QTreeWidgetItem *addProject (QTreeWidgetItem *, QETProject *);
|
|
|
|
QTreeWidgetItem *addDiagram (QTreeWidgetItem *, Diagram *);
|
|
|
|
QTreeWidgetItem *addCollection(QTreeWidgetItem *, ElementsCollection *, const QString & = QString(), const QIcon & = QIcon());
|
|
|
|
QTreeWidgetItem *addCategory (QTreeWidgetItem *, ElementsCategory *, const QString & = QString(), const QIcon & = QIcon());
|
|
|
|
QTreeWidgetItem *addElement (QTreeWidgetItem *, ElementDefinition *, const QString & = QString());
|
|
|
|
void saveExpandedCategories();
|
2009-05-19 19:00:37 +00:00
|
|
|
QTreeWidgetItem *findLocation(const ElementsLocation &) const;
|
|
|
|
QTreeWidgetItem *findLocation(const QString &) const;
|
2009-04-03 19:30:25 +00:00
|
|
|
void deleteItem(QTreeWidgetItem *);
|
|
|
|
void updateProjectItemInformations(QETProject *);
|
2010-12-24 21:00:11 +00:00
|
|
|
void updateProjectTemplates(QETProject *);
|
2009-04-03 19:30:25 +00:00
|
|
|
QString diagramTitleToDisplay(Diagram *) const;
|
2009-05-19 19:00:37 +00:00
|
|
|
void ensureHierarchyIsVisible(QList<QTreeWidgetItem *>);
|
2009-04-03 19:30:25 +00:00
|
|
|
|
|
|
|
// attributs
|
|
|
|
private:
|
|
|
|
QStringList expanded_directories;
|
|
|
|
QString last_selected_item;
|
|
|
|
QHash<QTreeWidgetItem *, ElementsLocation> locations_;
|
|
|
|
QSet<QETProject *> projects_to_display_;
|
|
|
|
QHash<QTreeWidgetItem *, QETProject *> projects_;
|
|
|
|
QHash<QTreeWidgetItem *, Diagram *> diagrams_;
|
2010-12-24 21:00:11 +00:00
|
|
|
QHash<QTreeWidgetItem *, QETProject *> title_blocks_directories_;
|
2009-04-03 19:30:25 +00:00
|
|
|
QTreeWidgetItem *common_collection_item_;
|
|
|
|
QTreeWidgetItem *custom_collection_item_;
|
2007-04-12 03:13:13 +00:00
|
|
|
};
|
2006-10-27 15:47:22 +00:00
|
|
|
#endif
|