QElectroTech  0.8-dev
elementscollectionwidget.h
Go to the documentation of this file.
1 /*
2  Copyright 2006-2020 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 ELEMENTSCOLLECTIONWIDGET_H
19 #define ELEMENTSCOLLECTIONWIDGET_H
20 
21 #include "elementslocation.h"
22 
23 #include <QWidget>
24 #include <QModelIndex>
25 #include <QTimer>
26 
28 class QVBoxLayout;
29 class QMenu;
30 class QLineEdit;
32 class QProgressBar;
33 class QETProject;
34 class ElementsTreeView;
35 
42 class ElementsCollectionWidget : public QWidget
43 {
44  Q_OBJECT
45 
46  public:
47  ElementsCollectionWidget(QWidget *parent = nullptr);
48 
49  void expandFirstItems();
50 
51  void addProject (QETProject *project);
52  void removeProject (QETProject *project);
54  void setCurrentLocation(const ElementsLocation &location);
55 
56  protected:
57  void leaveEvent(QEvent *event) override;
58 
59  private:
60  void setUpAction();
61  void setUpWidget();
62  void setUpConnection();
63  void customContextMenu(const QPoint &point);
64  void openDir();
65  void editElement();
66  void deleteElement();
67  void deleteDirectory();
68  void editDirectory();
69  void newDirectory();
70  void newElement();
71  void showThisDir();
72  void resetShowThisDir();
73  void dirProperties();
74  void search();
75  void hideCollection(bool hide = true);
76  void hideItem(bool hide, const QModelIndex &index = QModelIndex(), bool recursive = true);
77  void showAndExpandItem (const QModelIndex &index, bool parent = true, bool child = false);
78  ElementCollectionItem *elementCollectionItemForIndex (const QModelIndex &index);
79 
80  public slots:
81  void reload();
82  void loadingFinished();
83 
84  private:
85  void locationWasSaved(const ElementsLocation& location);
86 
87 
88  private:
91  QLineEdit *m_search_field;
94  QVBoxLayout *m_main_vlayout;
97  QModelIndex m_showed_index;
98  QProgressBar *m_progress_bar;
99 
100  QAction *m_open_dir,
111 
112  bool m_first_show = true;
113  QList<QETProject *> m_waiting_project;
114 };
115 
116 #endif // ELEMENTSCOLLECTIONWIDGET_H
ElementsLocation::exist
bool exist() const
ElementsLocation::exist.
Definition: elementslocation.cpp:472
QETApp::diagramEditorAncestorOf
static QETDiagramEditor * diagramEditorAncestorOf(const QWidget *child)
QETApp::diagramEditorAncestorOf.
Definition: qetapp.cpp:961
NewElementWizard
Definition: newelementwizard.h:39
setUpData
void setUpData(ElementCollectionItem *eci)
Definition: elementcollectionitem.cpp:250
ElementsTreeView
The ElementsTreeView class This class just reimplement startDrag from QTreeView, for set a custom pix...
Definition: elementstreeview.h:32
ElementsCollectionWidget::m_edit_dir
QAction * m_edit_dir
Definition: elementscollectionwidget.h:105
QET::Icons::FolderOnlyThis
QIcon FolderOnlyThis
Definition: qeticons.cpp:98
ElementsCollectionModel::addLocation
void addLocation(const ElementsLocation &location)
ElementsCollectionModel::addLocation Add the element or directory to this model. If the location is a...
Definition: elementscollectionmodel.cpp:336
QETApp::elementEditors
static QList< QETElementEditor * > elementEditors()
QETApp::elementEditors.
Definition: qetapp.cpp:1223
QET::Icons::FolderEdit
QIcon FolderEdit
Definition: qeticons.cpp:96
ElementsCollectionWidget::m_context_menu
QMenu * m_context_menu
Definition: elementscollectionwidget.h:95
ElementsCollectionWidget::m_dir_propertie
QAction * m_dir_propertie
Definition: elementscollectionwidget.h:110
QETApp
The QETApp class This class represents the QElectroTech application.
Definition: qetapp.h:55
ElementsCollectionWidget::loadingFinished
void loadingFinished()
ElementsCollectionWidget::loadingFinished Process when collection finished to be loaded.
Definition: elementscollectionwidget.cpp:656
ElementsCollectionWidget::m_new_element
QAction * m_new_element
Definition: elementscollectionwidget.h:107
ElementCollectionItem::directoriesChild
QList< ElementCollectionItem * > directoriesChild() const
ElementCollectionItem::directoriesChild.
Definition: elementcollectionitem.cpp:221
ElementsCollectionWidget::editDirectory
void editDirectory()
ElementsCollectionWidget::editDirectory Edit the directory represented by the current selected item.
Definition: elementscollectionwidget.cpp:461
QET::Icons::FolderDelete
QIcon FolderDelete
Definition: qeticons.cpp:95
ElementsCollectionModel::loadCollections
void loadCollections(bool common_collection, bool custom_collection, QList< QETProject * > projects)
ElementsCollectionModel::loadCollections Load the several collections in this model....
Definition: elementscollectionmodel.cpp:259
ElementsCollectionWidget::m_reload
QAction * m_reload
Definition: elementscollectionwidget.h:104
ElementsCollectionWidget::dirProperties
void dirProperties()
ElementsCollectionWidget::dirProperties Open an informative dialog about the curent index.
Definition: elementscollectionwidget.cpp:585
ElementsCollectionModel::removeProject
void removeProject(QETProject *project)
ElementsCollectionModel::removeProject Remove project from this model.
Definition: elementscollectionmodel.cpp:424
elementscollectionmodel.h
ElementCollectionItem::elementsChild
QList< ElementCollectionItem * > elementsChild() const
ElementCollectionItem::elementsChild.
Definition: elementcollectionitem.cpp:207
ElementsCollectionWidget::m_open_dir
QAction * m_open_dir
Definition: elementscollectionwidget.h:100
ElementsCategoryEditor::createdLocation
ElementsLocation createdLocation() const
ElementsCategoryEditor::createdLocation.
Definition: elementscategoryeditor.cpp:97
ElementsCollectionWidget::m_model
ElementsCollectionModel * m_model
Definition: elementscollectionwidget.h:89
ElementsCollectionWidget::m_search_timer
QTimer m_search_timer
Definition: elementscollectionwidget.h:92
ElementCollectionItem::collectionPath
virtual QString collectionPath() const =0
elementcollectionitem.h
FileElementCollectionItem::isDir
bool isDir() const override
FileElementCollectionItem::isDir.
Definition: fileelementcollectionitem.cpp:93
ElementsCollectionWidget::removeProject
void removeProject(QETProject *project)
Definition: elementscollectionwidget.cpp:101
ElementsCollectionWidget::m_delete_dir
QAction * m_delete_dir
Definition: elementscollectionwidget.h:103
elementscollectionwidget.h
ElementCollectionItem::clearData
virtual void clearData()
ElementCollectionItem::clearData Reset the data.
Definition: elementcollectionitem.cpp:32
qetmessagebox.h
ElementsCollectionWidget
The ElementsCollectionWidget class This widget embedd a tree view that display the element collection...
Definition: elementscollectionwidget.h:43
ElementsCollectionModel::project
QList< QETProject * > project() const
ElementsCollectionModel::project.
Definition: elementscollectionmodel.cpp:455
ElementsCollectionWidget::m_waiting_project
QList< QETProject * > m_waiting_project
Definition: elementscollectionwidget.h:113
elementstreeview.h
ElementsCollectionWidget::locationWasSaved
void locationWasSaved(const ElementsLocation &location)
ElementsCollectionWidget::locationWasSaved This method is connected with the signal savedToLocation o...
Definition: elementscollectionwidget.cpp:684
FileElementCollectionItem::Type
@ Type
Definition: fileelementcollectionitem.h:34
ElementCollectionItem
The ElementCollectionItem class This class represent a item (a directory or an element) in a element ...
Definition: elementcollectionitem.h:30
ElementsLocation::isFileSystem
bool isFileSystem() const
ElementsLocation::isFileSystem.
Definition: elementslocation.cpp:428
ElementsCollectionWidget::m_showed_index
QModelIndex m_showed_index
Definition: elementscollectionwidget.h:97
ElementsCollectionWidget::m_delete_element
QAction * m_delete_element
Definition: elementscollectionwidget.h:102
ElementsCollectionWidget::m_show_all_dir
QAction * m_show_all_dir
Definition: elementscollectionwidget.h:109
qetapp.h
ElementsCollectionModel::loadingProgressValueChanged
void loadingProgressValueChanged(int)
ElementsCollectionWidget::ElementsCollectionWidget
ElementsCollectionWidget(QWidget *parent=nullptr)
ElementsCollectionWidget::ElementsCollectionWidget Default constructor.
Definition: elementscollectionwidget.cpp:45
ElementsLocation::isElement
bool isElement() const
ElementsLocation::isElement.
Definition: elementslocation.cpp:412
ElementsCategoryEditor
The ElementsCategoryEditor class This class provides a dialog to edit an existing category or create ...
Definition: elementscategoryeditor.h:34
qetelementeditor.h
ElementsCollectionWidget::m_new_directory
QAction * m_new_directory
Definition: elementscollectionwidget.h:106
ElementsCollectionWidget::setCurrentLocation
void setCurrentLocation(const ElementsLocation &location)
ElementsCollectionWidget::setCurrentLocation Set the current item to be the item for location.
Definition: elementscollectionwidget.cpp:122
ElementCollectionItem::isDir
virtual bool isDir() const =0
ElementsCollectionWidget::m_first_show
bool m_first_show
Definition: elementscollectionwidget.h:112
ElementsCollectionWidget::setUpWidget
void setUpWidget()
ElementsCollectionWidget::setUpWidget Setup this widget.
Definition: elementscollectionwidget.cpp:172
qeticons.h
ElementsCollectionWidget::m_progress_bar
QProgressBar * m_progress_bar
Definition: elementscollectionwidget.h:98
QET::QetMessageBox::question
QMessageBox::StandardButton question(QWidget *, const QString &, const QString &, QMessageBox::StandardButtons=QMessageBox::Ok, QMessageBox::StandardButton=QMessageBox::NoButton)
Definition: qetmessagebox.cpp:53
QET::Icons::ElementEdit
QIcon ElementEdit
Definition: qeticons.cpp:85
ElementsCollectionWidget::customContextMenu
void customContextMenu(const QPoint &point)
ElementsCollectionWidget::customContextMenu Display the context menu of this widget at point.
Definition: elementscollectionwidget.cpp:261
QET::Icons::FolderNew
QIcon FolderNew
Definition: qeticons.cpp:97
ElementCollectionItem::localName
virtual QString localName()=0
QET::Icons::FolderOpen
QIcon FolderOpen
Definition: qeticons.cpp:99
elementslocation.h
ElementsCollectionWidget::m_index_at_context_menu
QModelIndex m_index_at_context_menu
Definition: elementscollectionwidget.h:96
ElementsCollectionWidget::editElement
void editElement()
ElementsCollectionWidget::editElement Edit the element represented by the current selected item.
Definition: elementscollectionwidget.cpp:352
QET::QetMessageBox::information
QMessageBox::StandardButton information(QWidget *, const QString &, const QString &, QMessageBox::StandardButtons=QMessageBox::Ok, QMessageBox::StandardButton=QMessageBox::NoButton)
Definition: qetmessagebox.cpp:38
ElementsLocation::isDirectory
bool isDirectory() const
ElementsLocation::isDirectory.
Definition: elementslocation.cpp:420
ElementsCollectionWidget::showAndExpandItem
void showAndExpandItem(const QModelIndex &index, bool parent=true, bool child=false)
ElementsCollectionWidget::showAndExpandItem Show the item index and expand it. If parent is true,...
Definition: elementscollectionwidget.cpp:801
ElementsCollectionWidget::setUpConnection
void setUpConnection()
ElementsCollectionWidget::setUpConnection Setup the connection used in this widget.
Definition: elementscollectionwidget.cpp:209
QET::Icons::FolderProperties
QIcon FolderProperties
Definition: qeticons.cpp:100
NewElementWizard::preselectedLocation
void preselectedLocation(const ElementsLocation &location)
NewElementWizard::preselectedLocation Select item in the tree view represented by location,...
Definition: newelementwizard.cpp:62
QET::Icons::ElementNew
QIcon ElementNew
Definition: qeticons.cpp:86
elementscategoryeditor.h
FileElementCollectionItem
The FileElementCollectionItem class This class specialise ElementCollectionItem for manage a collecti...
Definition: fileelementcollectionitem.h:30
ElementsCollectionWidget::m_main_vlayout
QVBoxLayout * m_main_vlayout
Definition: elementscollectionwidget.h:94
XmlProjectElementCollectionItem::Type
@ Type
Definition: xmlprojectelementcollectionitem.h:36
ElementsLocation::fileSystemPath
QString fileSystemPath() const
ElementsLocation::fileSystemPath.
Definition: elementslocation.cpp:193
QET::Icons::ElementDelete
QIcon ElementDelete
Definition: qeticons.cpp:84
ElementsCollectionWidget::m_tree_view
ElementsTreeView * m_tree_view
Definition: elementscollectionwidget.h:93
ElementsCollectionModel::loadingFinished
void loadingFinished()
QET::Icons::ViewRefresh
QIcon ViewRefresh
Definition: qeticons.cpp:173
ElementsCollectionWidget::expandFirstItems
void expandFirstItems()
ElementsCollectionWidget::expandFirstItems Expand each first item in the tree view.
Definition: elementscollectionwidget.cpp:73
QETApp::openElementLocations
void openElementLocations(const QList< ElementsLocation > &)
QETApp::openElementLocations Open the elements whose location is passed in parameter....
Definition: qetapp.cpp:1637
qetproject.h
xmlprojectelementcollectionitem.h
ElementsLocation::collectionPath
QString collectionPath(bool protocol=true) const
ElementsLocation::collectionPath Return the path of the represented element relative to collection if...
Definition: elementslocation.cpp:160
ElementsLocation
The ElementsLocation class This class represents the location, the location of an element or of a cat...
Definition: elementslocation.h:46
FileElementCollectionItem::isCollectionRoot
bool isCollectionRoot() const override
FileElementCollectionItem::isCollectionRoot.
Definition: fileelementcollectionitem.cpp:216
ElementsCollectionWidget::m_search_field
QLineEdit * m_search_field
Definition: elementscollectionwidget.h:91
ElementsCollectionModel::loadingProgressRangeChanged
void loadingProgressRangeChanged(int, int)
QETApp::instance
static QETApp * instance()
QETApp::instance.
Definition: qetapp.cpp:153
ElementsCollectionWidget::m_edit_element
QAction * m_edit_element
Definition: elementscollectionwidget.h:101
ElementsCollectionWidget::deleteDirectory
void deleteDirectory()
ElementsCollectionWidget::deleteDirectory Delete directory represented by the current selected item.
Definition: elementscollectionwidget.cpp:417
QETProject
Definition: qetproject.h:51
ElementsCollectionWidget::hideItem
void hideItem(bool hide, const QModelIndex &index=QModelIndex(), bool recursive=true)
ElementsCollectionWidget::hideItem Hide the item index. If recursive is true, hide all subchilds of i...
Definition: elementscollectionwidget.cpp:781
ElementsCollectionModel::indexFromLocation
QModelIndex indexFromLocation(const ElementsLocation &location)
ElementsCollectionModel::indexFromLocation Return the index who represent location....
Definition: elementscollectionmodel.cpp:543
newelementwizard.h
ElementsCollectionWidget::hideCollection
void hideCollection(bool hide=true)
ElementsCollectionWidget::hideCollection Hide all collection displayed in this tree.
Definition: elementscollectionwidget.cpp:767
FileElementCollectionItem::collectionPath
QString collectionPath() const override
FileElementCollectionItem::collectionPath.
Definition: fileelementcollectionitem.cpp:191
ElementsCollectionWidget::m_new_model
ElementsCollectionModel * m_new_model
Definition: elementscollectionwidget.h:90
ElementsCollectionWidget::leaveEvent
void leaveEvent(QEvent *event) override
Definition: elementscollectionwidget.cpp:133
ElementsCollectionWidget::m_show_this_dir
QAction * m_show_this_dir
Definition: elementscollectionwidget.h:108
QETDiagramEditor
Definition: qetdiagrameditor.h:51
XmlProjectElementCollectionItem::isCollectionRoot
bool isCollectionRoot() const override
XmlProjectElementCollectionItem::isCollectionRoot.
Definition: xmlprojectelementcollectionitem.cpp:120
ElementsCollectionWidget::newDirectory
void newDirectory()
ElementsCollectionWidget::newDirectory Create a new directory.
Definition: elementscollectionwidget.cpp:483
ElementCollectionItem::type
int type() const override
Definition: elementcollectionitem.h:35
QET::QetMessageBox::warning
QMessageBox::StandardButton warning(QWidget *, const QString &, const QString &, QMessageBox::StandardButtons=QMessageBox::Ok, QMessageBox::StandardButton=QMessageBox::NoButton)
Definition: qetmessagebox.cpp:68
ElementsCollectionModel
Definition: elementscollectionmodel.h:32
XmlProjectElementCollectionItem
The XmlProjectElementCollectionItem class This class specialise ElementCollectionItem for manage an x...
Definition: xmlprojectelementcollectionitem.h:32
ElementsCollectionWidget::highlightUnusedElement
void highlightUnusedElement()
ElementsCollectionWidget::highlightUnusedElement highlight the unused element.
Definition: elementscollectionwidget.cpp:111
ElementsCollectionWidget::elementCollectionItemForIndex
ElementCollectionItem * elementCollectionItemForIndex(const QModelIndex &index)
ElementsCollectionWidget::elementCollectionItemForIndex.
Definition: elementscollectionwidget.cpp:819
ElementsCollectionWidget::openDir
void openDir()
ElementsCollectionWidget::openDir Open the directory represented by the current selected item.
Definition: elementscollectionwidget.cpp:325
ElementsCollectionWidget::newElement
void newElement()
ElementsCollectionWidget::newElement Create a new element.
Definition: elementscollectionwidget.cpp:504
ElementsCollectionWidget::search
void search()
ElementsCollectionWidget::search Search every item (directory or element) that match the text of m_se...
Definition: elementscollectionwidget.cpp:712
qetdiagrameditor.h
QET::Icons::FolderShowAll
QIcon FolderShowAll
Definition: qeticons.cpp:101
ElementsCollectionWidget::reload
void reload()
ElementsCollectionWidget::reload, the displayed collections.
Definition: elementscollectionwidget.cpp:615
ElementsCollectionWidget::deleteElement
void deleteElement()
ElementsCollectionWidget::deleteElement Delete the element represented by the current selected item.
Definition: elementscollectionwidget.cpp:374
QETElementEditor::saveToLocation
void saveToLocation(ElementsLocation loc)
ElementsCollectionWidget::showThisDir
void showThisDir()
ElementsCollectionWidget::showThisDir Hide all directories except the pointed dir;.
Definition: elementscollectionwidget.cpp:536
ElementCollectionItem::isElement
virtual bool isElement() const =0
ElementsCollectionWidget::setUpAction
void setUpAction()
Definition: elementscollectionwidget.cpp:141
ElementsCollectionWidget::resetShowThisDir
void resetShowThisDir()
ElementsCollectionWidget::resetShowThisDir reset show this dir, all collection are show....
Definition: elementscollectionwidget.cpp:567
QET::Icons::tr
QIcon tr
Definition: qeticons.cpp:206
fileelementcollectionitem.h
FileElementCollectionItem::isCommonCollection
bool isCommonCollection() const
FileElementCollectionItem::isCommonCollection.
Definition: fileelementcollectionitem.cpp:229
QETElementEditor
Definition: qetelementeditor.h:33
ElementsCollectionModel::highlightUnusedElement
void highlightUnusedElement()
ElementsCollectionModel::highlightUnusedElement Highlight every unused element of managed project.
Definition: elementscollectionmodel.cpp:465
ElementsCollectionWidget::addProject
void addProject(QETProject *project)
ElementsCollectionWidget::addProject Add project to be displayed.
Definition: elementscollectionwidget.cpp:87