2007-12-01 10:47:15 +00:00
|
|
|
/*
|
2012-01-01 22:51:51 +00:00
|
|
|
Copyright 2006-2012 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>
|
2012-02-06 21:21:43 +00:00
|
|
|
#include "genericpanel.h"
|
2009-04-03 19:30:25 +00:00
|
|
|
#include "elementslocation.h"
|
2012-01-08 17:04:34 +00:00
|
|
|
#include "templatelocation.h"
|
2009-04-03 19:30:25 +00:00
|
|
|
class QETProject;
|
|
|
|
class Diagram;
|
|
|
|
class ElementsCollection;
|
|
|
|
class ElementsCollectionItem;
|
|
|
|
class ElementsCategory;
|
|
|
|
class ElementDefinition;
|
2011-09-13 21:46:10 +00:00
|
|
|
class ElementsCollectionCache;
|
2012-01-08 17:04:34 +00:00
|
|
|
class TitleBlockTemplatesFilesCollection;
|
|
|
|
|
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.
|
|
|
|
*/
|
2012-02-06 21:21:43 +00:00
|
|
|
class ElementsPanel : public GenericPanel {
|
2007-04-12 03:13:13 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
// constructeurs, destructeur
|
|
|
|
public:
|
|
|
|
ElementsPanel(QWidget * = 0);
|
|
|
|
virtual ~ElementsPanel();
|
|
|
|
|
|
|
|
private:
|
|
|
|
ElementsPanel(const ElementsPanel &);
|
|
|
|
|
2012-02-06 21:21:43 +00:00
|
|
|
// methods
|
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 itemIsWritable(QTreeWidgetItem *) const;
|
2012-02-06 21:21:43 +00:00
|
|
|
bool selectedItemIsWritable() const;
|
2009-04-03 19:30:25 +00:00
|
|
|
|
|
|
|
// methodes pour obtenir ce que represente un item donne
|
|
|
|
ElementsCollectionItem *collectionItemForItem(QTreeWidgetItem *) const;
|
2012-02-06 21:21:43 +00:00
|
|
|
ElementsCollectionItem *selectedItem() const;
|
2009-04-03 19:30:25 +00:00
|
|
|
ElementsCategory *categoryForItem(QTreeWidgetItem *);
|
|
|
|
ElementsCategory *categoryForPos(const QPoint &);
|
|
|
|
|
2011-03-15 20:06:40 +00:00
|
|
|
void reloadCollections();
|
|
|
|
int elementsCollectionItemsCount();
|
2012-04-29 20:29:40 +00:00
|
|
|
bool mustHighlightIntegratedElements() const;
|
2011-03-15 20:06:40 +00:00
|
|
|
|
2009-04-03 19:30:25 +00:00
|
|
|
signals:
|
|
|
|
void requestForProject(QETProject *);
|
|
|
|
void requestForDiagram(Diagram *);
|
2012-02-06 21:21:43 +00:00
|
|
|
void requestForCollectionItem(const ElementsLocation &);
|
2009-04-03 19:30:25 +00:00
|
|
|
void requestForMoveElements(ElementsCollectionItem *, ElementsCollectionItem *, QPoint);
|
2012-01-08 17:04:34 +00:00
|
|
|
void requestForTitleBlockTemplate(const TitleBlockTemplateLocation &);
|
2011-03-15 20:06:40 +00:00
|
|
|
void readingAboutToBegin();
|
|
|
|
void readingFinished();
|
|
|
|
void loadingProgressed(int, int);
|
2007-04-12 03:13:13 +00:00
|
|
|
|
|
|
|
public slots:
|
2007-06-30 17:41:07 +00:00
|
|
|
void slot_doubleClick(QTreeWidgetItem *, int);
|
2011-03-15 20:06:40 +00:00
|
|
|
void reload(bool = false);
|
2012-02-06 21:21:43 +00:00
|
|
|
void filter(const QString &, QET::Filtering = QET::RegularFilter);
|
2009-04-03 19:30:25 +00:00
|
|
|
void projectWasOpened(QETProject *);
|
|
|
|
void projectWasClosed(QETProject *);
|
2009-05-19 19:00:37 +00:00
|
|
|
bool scrollToElement(const ElementsLocation &);
|
2012-02-12 15:33:04 +00:00
|
|
|
void applyCurrentFilter(const QList<QTreeWidgetItem *> &);
|
|
|
|
void ensureHierarchyIsVisible(const QList<QTreeWidgetItem *> &);
|
2012-04-28 16:45:16 +00:00
|
|
|
void scrollToSelectedItem();
|
|
|
|
void highlightItems(const QList<QTreeWidgetItem *> &, const QObject * = 0, const char * = 0);
|
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);
|
2012-01-22 10:40:37 +00:00
|
|
|
void startElementDrag(const ElementsLocation &);
|
|
|
|
void startTitleBlockTemplateDrag(const TitleBlockTemplateLocation &);
|
2012-02-12 15:33:04 +00:00
|
|
|
bool matchesCurrentFilter(const QTreeWidgetItem *) const;
|
2012-02-06 21:21:43 +00:00
|
|
|
|
|
|
|
protected slots:
|
|
|
|
void firstActivation();
|
2012-02-12 15:33:04 +00:00
|
|
|
void panelContentChange();
|
2012-04-28 16:45:16 +00:00
|
|
|
virtual QList<ElementsLocation> elementIntegrated(QETProject *, const ElementsLocation &);
|
2009-04-03 19:30:25 +00:00
|
|
|
|
|
|
|
private:
|
2012-02-06 21:21:43 +00:00
|
|
|
QTreeWidgetItem *addProject (QETProject *);
|
2012-02-06 22:34:52 +00:00
|
|
|
QTreeWidgetItem *addCollection(ElementsCollection *);
|
2012-02-06 21:21:43 +00:00
|
|
|
QTreeWidgetItem *updateTemplateItem (QTreeWidgetItem *, const TitleBlockTemplateLocation &, PanelOptions, bool = false);
|
|
|
|
QTreeWidgetItem *updateElementsCategoryItem(QTreeWidgetItem *, ElementsCategory *, PanelOptions, bool = false);
|
|
|
|
QTreeWidgetItem *updateElementItem (QTreeWidgetItem *, ElementDefinition *, PanelOptions, bool = false);
|
|
|
|
|
|
|
|
// attributes
|
2009-04-03 19:30:25 +00:00
|
|
|
private:
|
2012-02-06 21:21:43 +00:00
|
|
|
QSet<QETProject *> projects_to_display_; ///< list of projects that have been added to this panel
|
|
|
|
QTreeWidgetItem *common_collection_item_; ///< pointer to the item representing the common elements collection
|
|
|
|
QTreeWidgetItem *common_tbt_collection_item_; ///< pointer to the item representing the common templates collection
|
|
|
|
QTreeWidgetItem *custom_collection_item_; ///< pointer to the item representing the user elements collection
|
|
|
|
QTreeWidgetItem *custom_tbt_collection_item_; ///< pointer to the item representing the user templates collection
|
|
|
|
int loading_progress_; ///< used to track the loading progress of elements collections
|
|
|
|
bool first_reload_; ///< used to distinguish the first time this panel is reloaded
|
2012-02-12 15:33:04 +00:00
|
|
|
QString filter_; ///< Currently applied filter
|
2007-04-12 03:13:13 +00:00
|
|
|
};
|
2006-10-27 15:47:22 +00:00
|
|
|
#endif
|