2014-03-12 09:32:56 +00:00
|
|
|
/*
|
2021-02-20 12:13:46 +01:00
|
|
|
Copyright 2006-2021 The QElectroTech Team
|
2014-03-12 09:32:56 +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 LINKSINGLEELEMENTWIDGET_H
|
|
|
|
#define LINKSINGLEELEMENTWIDGET_H
|
|
|
|
|
2022-06-13 20:22:10 +02:00
|
|
|
#include "../properties/elementdata.h"
|
2015-05-25 10:22:00 +00:00
|
|
|
#include "abstractelementpropertieseditorwidget.h"
|
|
|
|
|
2020-12-08 19:57:35 +01:00
|
|
|
#include <QHash>
|
|
|
|
|
2017-01-26 10:09:07 +00:00
|
|
|
class QTreeWidgetItem;
|
2022-06-13 20:22:10 +02:00
|
|
|
class Element;
|
|
|
|
class QMenu;
|
2014-03-12 09:32:56 +00:00
|
|
|
|
|
|
|
namespace Ui {
|
|
|
|
class LinkSingleElementWidget;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-08-18 21:28:52 +02:00
|
|
|
@brief The LinkSingleElementWidget class
|
2020-08-16 11:19:36 +02:00
|
|
|
this class provide a widget to select an element to be linked
|
|
|
|
to the element given in the constructor.
|
2020-08-18 21:28:52 +02:00
|
|
|
The element given in constructor must be linked with only
|
|
|
|
one other element (like report or slave element).
|
2022-12-04 08:21:12 -05:00
|
|
|
This widget detect automatically the kind of element given in
|
2020-08-18 21:28:52 +02:00
|
|
|
the constructor and search all element that can be linked with it.
|
2020-08-16 11:19:36 +02:00
|
|
|
If the element is already linked, the widget ask user to unlink.
|
|
|
|
This widget embedded the diagram command for undo/redo the action
|
|
|
|
*/
|
2015-05-25 10:22:00 +00:00
|
|
|
class LinkSingleElementWidget : public AbstractElementPropertiesEditorWidget
|
2014-03-12 09:32:56 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
2017-01-26 10:09:07 +00:00
|
|
|
///Methods
|
2014-03-12 09:32:56 +00:00
|
|
|
public:
|
2020-08-18 21:29:12 +02:00
|
|
|
explicit LinkSingleElementWidget(Element *elmt,
|
|
|
|
QWidget *parent = nullptr);
|
2017-08-05 02:10:01 +00:00
|
|
|
~LinkSingleElementWidget() override;
|
2015-05-03 17:32:28 +00:00
|
|
|
|
2017-08-05 02:10:01 +00:00
|
|
|
void setElement (Element *element) override;
|
|
|
|
void apply() override;
|
|
|
|
QUndoCommand *associatedUndo() const override;
|
|
|
|
QString title() const override;
|
2015-05-27 07:22:50 +00:00
|
|
|
|
|
|
|
public slots:
|
2017-08-05 02:10:01 +00:00
|
|
|
void updateUi() override;
|
2017-01-26 10:09:07 +00:00
|
|
|
void buildTree();
|
2014-03-12 09:32:56 +00:00
|
|
|
|
2015-05-27 07:22:50 +00:00
|
|
|
public:
|
2017-08-05 02:10:01 +00:00
|
|
|
bool setLiveEdit(bool live_edit) override;
|
2015-05-27 07:22:50 +00:00
|
|
|
|
|
|
|
private :
|
2022-06-13 20:46:22 +02:00
|
|
|
QVector <QPointer<Element>> availableElements();
|
2017-01-29 18:43:42 +00:00
|
|
|
void setUpCompleter();
|
2017-01-26 10:09:07 +00:00
|
|
|
void clearTreeWidget();
|
2017-01-29 18:43:42 +00:00
|
|
|
void setUpHeaderLabels();
|
2014-03-12 09:32:56 +00:00
|
|
|
|
|
|
|
private slots:
|
2015-05-21 20:46:23 +00:00
|
|
|
void diagramWasRemovedFromProject();
|
2017-01-26 10:09:07 +00:00
|
|
|
void showedElementWasDeleted();
|
|
|
|
void linkTriggered();
|
|
|
|
void hideButtons();
|
|
|
|
void showButtons();
|
2017-01-30 14:29:01 +00:00
|
|
|
void headerCustomContextMenuRequested(const QPoint &pos);
|
2020-09-21 21:19:50 +02:00
|
|
|
|
2017-01-26 10:09:07 +00:00
|
|
|
void on_m_unlink_pb_clicked();
|
|
|
|
void on_m_tree_widget_itemDoubleClicked(QTreeWidgetItem *item, int column);
|
|
|
|
void on_m_tree_widget_customContextMenuRequested(const QPoint &pos);
|
|
|
|
void on_m_show_linked_pb_clicked();
|
|
|
|
void on_m_show_this_pb_clicked();
|
2020-09-21 21:19:50 +02:00
|
|
|
|
2017-01-29 18:43:42 +00:00
|
|
|
void on_m_search_field_textEdited(const QString &arg1);
|
2020-09-21 21:19:50 +02:00
|
|
|
|
2014-03-12 09:32:56 +00:00
|
|
|
private:
|
|
|
|
Ui::LinkSingleElementWidget *ui;
|
2017-01-26 10:09:07 +00:00
|
|
|
|
|
|
|
bool m_unlink = false;
|
2022-06-13 20:22:10 +02:00
|
|
|
ElementData::Type m_filter;
|
2020-09-21 21:19:50 +02:00
|
|
|
|
2017-01-26 10:09:07 +00:00
|
|
|
QHash <QTreeWidgetItem*, Element*> m_qtwi_elmt_hash;
|
2017-01-29 18:43:42 +00:00
|
|
|
QHash <QTreeWidgetItem*, QStringList> m_qtwi_strl_hash;
|
2020-09-21 21:19:50 +02:00
|
|
|
|
2017-01-26 10:09:07 +00:00
|
|
|
QTreeWidgetItem *m_qtwi_at_context_menu = nullptr,
|
|
|
|
*m_pending_qtwi = nullptr;
|
2020-09-21 21:19:50 +02:00
|
|
|
|
2017-01-26 10:09:07 +00:00
|
|
|
Element *m_showed_element = nullptr,
|
|
|
|
*m_element_to_link = nullptr;
|
2020-09-21 21:19:50 +02:00
|
|
|
|
2022-06-13 20:22:10 +02:00
|
|
|
QMenu *m_context_menu{nullptr};
|
|
|
|
QAction *m_link_action{nullptr},
|
|
|
|
*m_show_qtwi{nullptr},
|
|
|
|
*m_show_element{nullptr},
|
|
|
|
*m_save_header_state{nullptr};
|
2014-03-12 09:32:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // LINKSINGLEELEMENTWIDGET_H
|