File: elementscollectionwidget.h

package info (click to toggle)
qelectrotech 1%3A0.7.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 91,680 kB
  • sloc: cpp: 62,335; xml: 750; sh: 264; perl: 258; makefile: 6
file content (114 lines) | stat: -rw-r--r-- 3,220 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/*
        Copyright 2006-2019 The QElectroTech Team
        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/>.
*/
#ifndef ELEMENTSCOLLECTIONWIDGET_H
#define ELEMENTSCOLLECTIONWIDGET_H

#include "elementslocation.h"

#include <QWidget>
#include <QModelIndex>
#include <QTimer>

class ElementsCollectionModel;
class QVBoxLayout;
class QMenu;
class QLineEdit;
class ElementCollectionItem;
class QProgressBar;
class QETProject;
class ElementsTreeView;

/**
 * @brief The ElementsCollectionWidget class
 * This widget embedd a tree view that display the element collection (common, custom, embedded)
 * and all action needed to use this widget.
 * This is the element collection widget used in the diagram editor.
 */
class ElementsCollectionWidget : public QWidget
{
        Q_OBJECT

    public:
        ElementsCollectionWidget(QWidget *parent = nullptr);

        void expandFirstItems();

		void addProject (QETProject *project);
		void removeProject (QETProject *project);
		void highlightUnusedElement();
		void setCurrentLocation(const ElementsLocation &location);

	protected:
		void leaveEvent(QEvent *event) override;

	private:
		void setUpAction();
		void setUpWidget();
		void setUpConnection();
		void customContextMenu(const QPoint &point);
		void openDir();
		void editElement();
		void deleteElement();
		void deleteDirectory();
		void editDirectory();
		void newDirectory();
		void newElement();
		void showThisDir();
		void resetShowThisDir();
		void dirProperties();
		void search();
		void hideCollection(bool hide = true);
		void hideItem(bool hide, const QModelIndex &index = QModelIndex(), bool recursive = true);
		void showAndExpandItem (const QModelIndex &index, bool parent = true, bool child = false);
		ElementCollectionItem *elementCollectionItemForIndex (const QModelIndex &index);

	public slots:
		void reload();

	private:
		void locationWasSaved(const ElementsLocation& location);


	private:
		ElementsCollectionModel *m_model;
		QLineEdit *m_search_field;
		QTimer m_search_timer;
		ElementsTreeView *m_tree_view;
		QVBoxLayout *m_main_vlayout;
		QMenu *m_context_menu;
		QModelIndex m_index_at_context_menu;
		QModelIndex m_showed_index;
		QProgressBar *m_progress_bar;

		QAction *m_open_dir,
				*m_edit_element,
				*m_delete_element,
				*m_delete_dir,
				*m_reload,
				*m_edit_dir,
				*m_new_directory,
				*m_new_element,
				*m_show_this_dir,
				*m_show_all_dir,
				*m_dir_propertie;

		bool m_first_show = true;
		QList<QETProject *> m_waiting_project;
};

#endif // ELEMENTSCOLLECTIONWIDGET_H