QElectroTech  0.70
elementscollectionwidget.h
Go to the documentation of this file.
1 /*
2  Copyright 2006-2019 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 
83  private:
84  void locationWasSaved(const ElementsLocation& location);
85 
86 
87  private:
89  QLineEdit *m_search_field;
92  QVBoxLayout *m_main_vlayout;
95  QModelIndex m_showed_index;
96  QProgressBar *m_progress_bar;
97 
98  QAction *m_open_dir,
101  *m_delete_dir,
102  *m_reload,
103  *m_edit_dir,
105  *m_new_element,
109 
110  bool m_first_show = true;
111  QList<QETProject *> m_waiting_project;
112 };
113 
114 #endif // ELEMENTSCOLLECTIONWIDGET_H
The ElementCollectionItem class This class represent a item (a directory or an element) in a element ...
void locationWasSaved(const ElementsLocation &location)
ElementsCollectionWidget::locationWasSaved This method is connected with the signal savedToLocation o...
QList< QETProject * > m_waiting_project
void addProject(QETProject *project)
ElementsCollectionWidget::addProject Add to be displayed.
void deleteElement()
ElementsCollectionWidget::deleteElement Delete the element represented by the current selected item...
void editDirectory()
ElementsCollectionWidget::editDirectory Edit the directory represented by the current selected item...
void editElement()
ElementsCollectionWidget::editElement Edit the element represented by the current selected item...
ElementCollectionItem * elementCollectionItemForIndex(const QModelIndex &index)
ElementsCollectionWidget::elementCollectionItemForIndex.
The ElementsTreeView class This class just reimplement startDrag from QTreeView, for set a custom pix...
The ElementsCollectionWidget class This widget embedd a tree view that display the element collection...
void newElement()
ElementsCollectionWidget::newElement Create a new element.
void openDir()
ElementsCollectionWidget::openDir Open the directory represented by the current selected item...
void deleteDirectory()
ElementsCollectionWidget::deleteDirectory Delete directory represented by the current selected item...
void showThisDir()
ElementsCollectionWidget::showThisDir Hide all directories except the pointed dir;.
void removeProject(QETProject *project)
void hideCollection(bool hide=true)
ElementsCollectionWidget::hideCollection Hide all collection displayed in this tree.
void reload()
ElementsCollectionWidget::reload, the displayed collections.
void dirProperties()
ElementsCollectionWidget::dirProperties Open an informative dialog about the curent index...
void newDirectory()
ElementsCollectionWidget::newDirectory Create a new directory.
void highlightUnusedElement()
ElementsCollectionWidget::highlightUnusedElement highlight the unused element ElementsCollectionMode...
void showAndExpandItem(const QModelIndex &index, bool parent=true, bool child=false)
ElementsCollectionWidget::showAndExpandItem Show the item and expand it. If parent is true...
void search()
ElementsCollectionWidget::search Search every item (directory or element) that match the text of m_se...
void setCurrentLocation(const ElementsLocation &location)
ElementsCollectionWidget::setCurrentLocation Set the current item to be the item for ...
void leaveEvent(QEvent *event) override
ElementsCollectionWidget(QWidget *parent=nullptr)
ElementsCollectionWidget::ElementsCollectionWidget Default constructor.
void resetShowThisDir()
ElementsCollectionWidget::resetShowThisDir reset show this dir, all collection are show...
ElementsCollectionModel * m_model
void customContextMenu(const QPoint &point)
ElementsCollectionWidget::customContextMenu Display the context menu of this widget at ...
void setUpWidget()
ElementsCollectionWidget::setUpWidget Setup this widget.
void expandFirstItems()
ElementsCollectionWidget::expandFirstItems Expand each first item in the tree view.
void setUpConnection()
ElementsCollectionWidget::setUpConnection Setup the connection used in this widget.
void hideItem(bool hide, const QModelIndex &index=QModelIndex(), bool recursive=true)
ElementsCollectionWidget::hideItem Hide the item . If is true, hide all subchilds of ...