2015-12-08 16:52:10 +00:00
|
|
|
/*
|
2017-01-20 10:55:49 +00:00
|
|
|
Copyright 2006-2017 The QElectroTech Team
|
2015-12-08 16:52:10 +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/>.
|
|
|
|
*/
|
|
|
|
#ifndef ELEMENTSCOLLECTIONWIDGET_H
|
|
|
|
#define ELEMENTSCOLLECTIONWIDGET_H
|
|
|
|
|
2016-06-17 08:41:09 +00:00
|
|
|
#include "elementslocation.h"
|
|
|
|
|
2015-12-08 16:52:10 +00:00
|
|
|
#include <QWidget>
|
|
|
|
#include <QModelIndex>
|
2016-06-10 16:20:01 +00:00
|
|
|
#include <QTimer>
|
2015-12-08 16:52:10 +00:00
|
|
|
|
|
|
|
class ElementsCollectionModel;
|
|
|
|
class QVBoxLayout;
|
|
|
|
class QMenu;
|
|
|
|
class QLineEdit;
|
|
|
|
class ElementCollectionItem;
|
2015-12-09 20:27:31 +00:00
|
|
|
class QProgressBar;
|
2015-12-16 17:16:15 +00:00
|
|
|
class QETProject;
|
2016-05-22 14:51:09 +00:00
|
|
|
class ElementsTreeView;
|
2015-12-08 16:52:10 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @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();
|
|
|
|
|
2015-12-16 17:16:15 +00:00
|
|
|
void addProject (QETProject *project);
|
|
|
|
void removeProject (QETProject *project);
|
2016-06-30 09:12:25 +00:00
|
|
|
void highlightUnusedElement();
|
2017-05-01 11:42:55 +00:00
|
|
|
void setCurrentLocation(const ElementsLocation &location);
|
2015-12-16 17:16:15 +00:00
|
|
|
|
2016-06-05 16:34:46 +00:00
|
|
|
protected:
|
2017-08-05 02:10:01 +00:00
|
|
|
void leaveEvent(QEvent *event) override;
|
2016-06-05 16:34:46 +00:00
|
|
|
|
2015-12-08 16:52:10 +00:00
|
|
|
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();
|
2016-02-26 09:58:55 +00:00
|
|
|
void showThisDir();
|
|
|
|
void resetShowThisDir();
|
2016-10-15 13:39:02 +00:00
|
|
|
void dirProperties();
|
2016-06-10 16:20:01 +00:00
|
|
|
void search();
|
2015-12-08 16:52:10 +00:00
|
|
|
void hideCollection(bool hide = true);
|
|
|
|
void hideItem(bool hide, const QModelIndex &index = QModelIndex(), bool recursive = true);
|
2016-02-26 09:58:55 +00:00
|
|
|
void showAndExpandItem (const QModelIndex &index, bool parent = true, bool child = false);
|
2015-12-16 17:16:15 +00:00
|
|
|
ElementCollectionItem *elementCollectionItemForIndex (const QModelIndex &index);
|
2015-12-08 16:52:10 +00:00
|
|
|
|
2017-05-01 16:22:34 +00:00
|
|
|
public slots:
|
2016-06-05 19:55:41 +00:00
|
|
|
void reload();
|
|
|
|
|
2016-06-17 08:41:09 +00:00
|
|
|
private:
|
|
|
|
void locationWasSaved(ElementsLocation location);
|
|
|
|
|
2016-06-05 19:55:41 +00:00
|
|
|
|
2016-06-05 16:34:46 +00:00
|
|
|
private:
|
|
|
|
ElementsCollectionModel *m_model;
|
2015-12-08 16:52:10 +00:00
|
|
|
QLineEdit *m_search_field;
|
2016-06-10 16:20:01 +00:00
|
|
|
QTimer m_search_timer;
|
2016-05-22 14:51:09 +00:00
|
|
|
ElementsTreeView *m_tree_view;
|
2016-06-05 16:34:46 +00:00
|
|
|
QVBoxLayout *m_main_vlayout;
|
2015-12-08 16:52:10 +00:00
|
|
|
QMenu *m_context_menu;
|
2015-12-12 11:09:31 +00:00
|
|
|
QModelIndex m_index_at_context_menu;
|
2016-02-26 09:58:55 +00:00
|
|
|
QModelIndex m_showed_index;
|
2015-12-09 20:27:31 +00:00
|
|
|
QProgressBar *m_progress_bar;
|
2015-12-08 16:52:10 +00:00
|
|
|
|
|
|
|
QAction *m_open_dir,
|
|
|
|
*m_edit_element,
|
|
|
|
*m_delete_element,
|
|
|
|
*m_delete_dir,
|
|
|
|
*m_reload,
|
|
|
|
*m_edit_dir,
|
|
|
|
*m_new_directory,
|
2016-02-26 09:58:55 +00:00
|
|
|
*m_new_element,
|
|
|
|
*m_show_this_dir,
|
2016-10-15 13:39:02 +00:00
|
|
|
*m_show_all_dir,
|
|
|
|
*m_dir_propertie;
|
2016-06-05 16:34:46 +00:00
|
|
|
|
|
|
|
bool m_first_show = true;
|
2016-06-06 19:07:13 +00:00
|
|
|
QList<QETProject *> m_waiting_project;
|
2015-12-08 16:52:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // ELEMENTSCOLLECTIONWIDGET_H
|