2018-09-25 16:05:24 +00:00
|
|
|
/*
|
2021-02-06 18:33:42 +01:00
|
|
|
Copyright 2006-2021 The QElectroTech Team
|
2018-09-25 16:05:24 +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 SEARCHANDREPLACEWIDGET_H
|
|
|
|
#define SEARCHANDREPLACEWIDGET_H
|
|
|
|
|
2020-12-08 19:57:35 +01:00
|
|
|
#include "../../QWidgetAnimation/qwidgetanimation.h"
|
|
|
|
#include "../../qetgraphicsitem/element.h"
|
|
|
|
#include "../../qetgraphicsitem/independenttextitem.h"
|
|
|
|
#include "../searchandreplaceworker.h"
|
2018-10-21 09:54:59 +00:00
|
|
|
|
2020-12-08 19:57:35 +01:00
|
|
|
#include <QTreeWidgetItemIterator>
|
|
|
|
#include <QWidget>
|
2018-09-25 16:05:24 +00:00
|
|
|
|
|
|
|
class QTreeWidgetItem;
|
2020-11-15 17:19:42 +01:00
|
|
|
class QETDiagramEditor;
|
|
|
|
class QAction;
|
2018-09-25 16:05:24 +00:00
|
|
|
|
|
|
|
namespace Ui {
|
|
|
|
class SearchAndReplaceWidget;
|
|
|
|
}
|
|
|
|
|
2020-11-15 17:19:42 +01:00
|
|
|
|
2018-09-25 16:05:24 +00:00
|
|
|
|
|
|
|
class SearchAndReplaceWidget : public QWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit SearchAndReplaceWidget(QWidget *parent = nullptr);
|
2020-04-23 19:52:56 +02:00
|
|
|
~SearchAndReplaceWidget() override;
|
2018-09-25 16:05:24 +00:00
|
|
|
|
|
|
|
bool event(QEvent *event) override;
|
|
|
|
void clear();
|
|
|
|
void setEditor(QETDiagramEditor *editor);
|
|
|
|
|
|
|
|
private:
|
|
|
|
void setUpTreeItems();
|
2020-04-23 19:52:56 +02:00
|
|
|
void setHideAdvanced(bool hide);
|
2018-09-25 16:05:24 +00:00
|
|
|
void fillItemsList();
|
|
|
|
void addElement(Element *element);
|
|
|
|
void search();
|
2020-11-15 17:19:42 +01:00
|
|
|
void setUpActions();
|
|
|
|
void setUpConenctions();
|
2018-09-25 16:05:24 +00:00
|
|
|
|
2020-08-16 14:22:21 +02:00
|
|
|
void setVisibleAllParents(QTreeWidgetItem *item,
|
|
|
|
bool expend_parent = true);
|
2020-11-15 17:19:42 +01:00
|
|
|
|
2020-08-16 14:22:21 +02:00
|
|
|
QTreeWidgetItem *nextItem(
|
|
|
|
QTreeWidgetItem *item=nullptr,
|
|
|
|
QTreeWidgetItemIterator::IteratorFlag flags
|
|
|
|
= QTreeWidgetItemIterator::All) const;
|
2020-11-15 17:19:42 +01:00
|
|
|
|
2020-08-16 14:22:21 +02:00
|
|
|
QTreeWidgetItem *previousItem(
|
|
|
|
QTreeWidgetItem *item=nullptr,
|
|
|
|
QTreeWidgetItemIterator::IteratorFlag flags
|
|
|
|
= QTreeWidgetItemIterator::All) const;
|
2020-11-15 17:19:42 +01:00
|
|
|
|
2018-09-25 16:05:24 +00:00
|
|
|
void updateNextPreviousButtons();
|
|
|
|
void itemChanged(QTreeWidgetItem *item, int column);
|
2020-08-16 14:22:21 +02:00
|
|
|
void setChildCheckState(QTreeWidgetItem *item,
|
|
|
|
Qt::CheckState check,
|
|
|
|
bool deep = true);
|
|
|
|
void updateParentCheckState(QTreeWidgetItem *item,
|
|
|
|
bool all_parents = true);
|
2018-10-21 09:54:59 +00:00
|
|
|
void activateNextChecked();
|
2018-12-21 18:08:58 +00:00
|
|
|
QList<Diagram *> selectedDiagram() const;
|
|
|
|
QList<Element *> selectedElement() const;
|
|
|
|
QList<Conductor *> selectedConductor() const;
|
|
|
|
QList<IndependentTextItem *> selectedText() const;
|
|
|
|
|
2018-12-13 17:34:41 +00:00
|
|
|
static QStringList searchTerms(Diagram *diagram);
|
|
|
|
static QStringList searchTerms(Element *element);
|
|
|
|
static QStringList searchTerms(Conductor *conductor);
|
|
|
|
static QStringList searchTerms(QString str);
|
2018-09-25 16:05:24 +00:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
void on_m_quit_button_clicked();
|
|
|
|
void on_m_advanced_pb_toggled(bool checked);
|
2020-08-16 14:22:21 +02:00
|
|
|
void on_m_tree_widget_itemDoubleClicked(QTreeWidgetItem *item,
|
|
|
|
int column);
|
2018-09-25 16:05:24 +00:00
|
|
|
void on_m_reload_pb_clicked();
|
2020-08-16 14:22:21 +02:00
|
|
|
void on_m_tree_widget_currentItemChanged(
|
|
|
|
QTreeWidgetItem *current,
|
|
|
|
QTreeWidgetItem *previous);
|
2018-09-25 16:05:24 +00:00
|
|
|
void on_m_next_pb_clicked();
|
|
|
|
void on_m_previous_pb_clicked();
|
2018-10-21 09:54:59 +00:00
|
|
|
void on_m_folio_pb_clicked();
|
|
|
|
void on_m_replace_pb_clicked();
|
|
|
|
void on_m_replace_all_pb_clicked();
|
2018-11-09 18:50:37 +00:00
|
|
|
void on_m_element_pb_clicked();
|
2018-11-29 17:34:03 +00:00
|
|
|
void on_m_mode_cb_currentIndexChanged(int index);
|
|
|
|
void on_m_case_sensitive_cb_stateChanged(int arg1);
|
2018-12-09 11:50:07 +00:00
|
|
|
void on_m_conductor_pb_clicked();
|
2018-12-21 18:08:58 +00:00
|
|
|
void on_m_advanced_replace_pb_clicked();
|
2018-09-25 16:05:24 +00:00
|
|
|
|
2018-12-21 18:08:58 +00:00
|
|
|
private:
|
2018-09-25 16:05:24 +00:00
|
|
|
Ui::SearchAndReplaceWidget *ui;
|
|
|
|
QETDiagramEditor *m_editor;
|
|
|
|
QTreeWidgetItem *m_root_qtwi = nullptr,
|
|
|
|
*m_folio_qtwi = nullptr,
|
|
|
|
*m_indi_text_qtwi = nullptr,
|
|
|
|
*m_elements_qtwi = nullptr,
|
|
|
|
*m_simple_elmt_qtwi = nullptr,
|
|
|
|
*m_master_elmt_qtwi = nullptr,
|
|
|
|
*m_slave_elmt_qtwi = nullptr,
|
|
|
|
*m_report_elmt_qtwi = nullptr,
|
|
|
|
*m_terminal_elmt_qtwi = nullptr,
|
|
|
|
*m_conductor_qtwi = nullptr;
|
|
|
|
QList<QTreeWidgetItem *> m_qtwi_elmts;
|
|
|
|
QList<QTreeWidgetItem *> m_category_qtwi;
|
|
|
|
QHash<QTreeWidgetItem *, QPointer <Element>> m_element_hash;
|
2020-08-16 14:22:21 +02:00
|
|
|
QHash<QTreeWidgetItem *,
|
|
|
|
QPointer <IndependentTextItem>> m_text_hash;
|
2018-09-25 16:05:24 +00:00
|
|
|
QHash<QTreeWidgetItem *, QPointer <Conductor>> m_conductor_hash;
|
|
|
|
QPointer<Element> m_highlighted_element;
|
|
|
|
QPointer<QGraphicsObject> m_last_selected;
|
2018-10-05 07:49:07 +00:00
|
|
|
QHash<QTreeWidgetItem *, QPointer <Diagram>> m_diagram_hash;
|
2018-10-21 09:54:59 +00:00
|
|
|
SearchAndReplaceWorker m_worker;
|
2020-04-23 19:52:56 +02:00
|
|
|
QWidgetAnimation *m_vertical_animation;
|
|
|
|
QWidgetAnimation *m_horizontal_animation;
|
2020-11-15 17:19:42 +01:00
|
|
|
|
|
|
|
QAction *m_select_elements = nullptr,
|
|
|
|
*m_select_conductors = nullptr,
|
|
|
|
*m_select_texts = nullptr;
|
2018-09-25 16:05:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // SEARCHANDREPLACEWIDGET_H
|