2015-12-08 16:52:10 +00:00
|
|
|
/*
|
2016-05-13 17:40:36 +00:00
|
|
|
Copyright 2006-2016 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
|
|
|
|
|
|
|
|
#include <QWidget>
|
|
|
|
#include <QModelIndex>
|
|
|
|
|
|
|
|
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-05 16:34:46 +00:00
|
|
|
protected:
|
|
|
|
virtual bool event(QEvent *event);
|
|
|
|
|
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();
|
2015-12-08 16:52:10 +00:00
|
|
|
void search(const QString &text);
|
|
|
|
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
|
|
|
|
2016-06-05 19:55:41 +00:00
|
|
|
private slots:
|
|
|
|
void reload();
|
|
|
|
|
|
|
|
|
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-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,
|
|
|
|
*m_show_all_dir;
|
2016-06-05 16:34:46 +00:00
|
|
|
|
|
|
|
bool m_first_show = true;
|
2015-12-08 16:52:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // ELEMENTSCOLLECTIONWIDGET_H
|