QElectroTech 0.100.0-dev
Loading...
Searching...
No Matches
searchandreplacewidget.h
Go to the documentation of this file.
1/*
2 Copyright 2006-2024 The QElectroTech Team
3 This file is part of QElectroTech.
4
5 QElectroTech is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 2 of the License, or
8 (at your option) any later version.
9
10 QElectroTech is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
17*/
18#ifndef SEARCHANDREPLACEWIDGET_H
19#define SEARCHANDREPLACEWIDGET_H
20
21#include "../../QWidgetAnimation/qwidgetanimation.h"
22#include "../../qetgraphicsitem/element.h"
23#include "../../qetgraphicsitem/independenttextitem.h"
24#include "../searchandreplaceworker.h"
25
26#include <QTreeWidgetItemIterator>
27#include <QWidget>
28
29class QTreeWidgetItem;
31class QAction;
32
33namespace Ui {
35}
36
37
38
39class SearchAndReplaceWidget : public QWidget
40{
41 Q_OBJECT
42
43 public:
44 explicit SearchAndReplaceWidget(QWidget *parent = nullptr);
45 ~SearchAndReplaceWidget() override;
46
47 bool event(QEvent *event) override;
48 void clear();
49 void setEditor(QETDiagramEditor *editor);
50
51 private:
52 void setUpTreeItems();
53 void setHideAdvanced(bool hide);
54 void fillItemsList();
55 void addElement(Element *element);
56 void search();
57 void setUpActions();
58 void setUpConenctions();
59
60 void setVisibleAllParents(QTreeWidgetItem *item,
61 bool expend_parent = true);
62
63 QTreeWidgetItem *nextItem(
64 QTreeWidgetItem *item=nullptr,
65 QTreeWidgetItemIterator::IteratorFlag flags
66 = QTreeWidgetItemIterator::All) const;
67
68 QTreeWidgetItem *previousItem(
69 QTreeWidgetItem *item=nullptr,
70 QTreeWidgetItemIterator::IteratorFlag flags
71 = QTreeWidgetItemIterator::All) const;
72
74 void itemChanged(QTreeWidgetItem *item, int column);
75 void setChildCheckState(QTreeWidgetItem *item,
76 Qt::CheckState check,
77 bool deep = true);
78 void updateParentCheckState(QTreeWidgetItem *item,
79 bool all_parents = true);
81 QList<Diagram *> selectedDiagram() const;
82 QList<Element *> selectedElement() const;
83 QList<Conductor *> selectedConductor() const;
84 QList<IndependentTextItem *> selectedText() const;
85
86 static QStringList searchTerms(Diagram *diagram);
87 static QStringList searchTerms(Element *element);
88 static QStringList searchTerms(Conductor *conductor);
89 static QStringList searchTerms(QString str);
90
91 private slots:
93 void on_m_advanced_pb_toggled(bool checked);
94 void on_m_tree_widget_itemDoubleClicked(QTreeWidgetItem *item,
95 int column);
98 QTreeWidgetItem *current,
99 QTreeWidgetItem *previous);
106 void on_m_mode_cb_currentIndexChanged(int index);
110
111 private:
112 Ui::SearchAndReplaceWidget *ui;
114 QTreeWidgetItem *m_root_qtwi = nullptr,
115 *m_folio_qtwi = nullptr,
117 *m_elements_qtwi = nullptr,
124 QList<QTreeWidgetItem *> m_qtwi_elmts;
125 QList<QTreeWidgetItem *> m_category_qtwi;
126 QHash<QTreeWidgetItem *, QPointer <Element>> m_element_hash;
127 QHash<QTreeWidgetItem *,
128 QPointer <IndependentTextItem>> m_text_hash;
129 QHash<QTreeWidgetItem *, QPointer <Conductor>> m_conductor_hash;
130 QPointer<Element> m_highlighted_element;
131 QPointer<QGraphicsObject> m_last_selected;
132 QHash<QTreeWidgetItem *, QPointer <Diagram>> m_diagram_hash;
136
137 QAction *m_select_elements = nullptr,
139 *m_select_texts = nullptr;
140};
141
142#endif // SEARCHANDREPLACEWIDGET_H
Definition conductor.h:43
The Diagram class This class represents an electric diagram. It manages its various child elements,...
Definition diagram.h:56
Definition element.h:43
Definition qetdiagrameditor.h:55
The QWidgetAnimation class This class animate the show and hide function of a QWidget.
Definition qwidgetanimation.h:46
Definition searchandreplacewidget.h:40
Ui::SearchAndReplaceWidget * ui
Definition searchandreplacewidget.h:112
~SearchAndReplaceWidget() override
SearchAndReplaceWidget::~SearchAndReplaceWidget Destructor.
Definition searchandreplacewidget.cpp:75
void setUpConenctions()
SearchAndReplaceWidget::setUpConenctions Setup some connection used in this widget.
Definition searchandreplacewidget.cpp:471
void on_m_conductor_pb_clicked()
SearchAndReplaceWidget::on_m_conductor_pb_clicked Open a dialog to edit the condutor properties.
Definition searchandreplacewidget.cpp:1320
void setVisibleAllParents(QTreeWidgetItem *item, bool expend_parent=true)
SearchAndReplaceWidget::setVisibleAllParents Set visible all parents of item until the invisible root...
Definition searchandreplacewidget.cpp:525
void on_m_folio_pb_clicked()
Definition searchandreplacewidget.cpp:1106
QTreeWidgetItem * m_elements_qtwi
Definition searchandreplacewidget.h:117
void on_m_replace_pb_clicked()
SearchAndReplaceWidget::on_m_replace_pb_clicked Replace the current selection.
Definition searchandreplacewidget.cpp:1137
void setEditor(QETDiagramEditor *editor)
SearchAndReplaceWidget::setEditor Set the diagram editor of this widget.
Definition searchandreplacewidget.cpp:147
QPointer< Element > m_highlighted_element
Definition searchandreplacewidget.h:130
void on_m_previous_pb_clicked()
Definition searchandreplacewidget.cpp:1076
void on_m_next_pb_clicked()
Definition searchandreplacewidget.cpp:1057
QTreeWidgetItem * m_conductor_qtwi
Definition searchandreplacewidget.h:123
void on_m_tree_widget_itemDoubleClicked(QTreeWidgetItem *item, int column)
Definition searchandreplacewidget.cpp:948
void updateNextPreviousButtons()
SearchAndReplaceWidget::updateNextPreviousButtons According to the current item, if there is a next o...
Definition searchandreplacewidget.cpp:608
QHash< QTreeWidgetItem *, QPointer< Diagram > > m_diagram_hash
Definition searchandreplacewidget.h:132
SearchAndReplaceWorker m_worker
Definition searchandreplacewidget.h:133
QTreeWidgetItem * m_terminal_elmt_qtwi
Definition searchandreplacewidget.h:122
QHash< QTreeWidgetItem *, QPointer< Element > > m_element_hash
Definition searchandreplacewidget.h:126
void addElement(Element *element)
SearchAndReplaceWidget::addElement Add a tree widget item for element.
Definition searchandreplacewidget.cpp:329
void setHideAdvanced(bool hide)
SearchAndReplaceWidget::setHideAdvanced Hide advanced widgets.
Definition searchandreplacewidget.cpp:226
void search()
SearchAndReplaceWidget::search Start the search.
Definition searchandreplacewidget.cpp:373
QTreeWidgetItem * m_folio_qtwi
Definition searchandreplacewidget.h:115
void clear()
SearchAndReplaceWidget::clear Clear the content of the search and replace line edit Clear all tree it...
Definition searchandreplacewidget.cpp:113
void fillItemsList()
SearchAndReplaceWidget::fillItemsList Fill the tree.
Definition searchandreplacewidget.cpp:236
QList< Element * > selectedElement() const
SearchAndReplaceWidget::selectedElement.
Definition searchandreplacewidget.cpp:779
static QStringList searchTerms(Diagram *diagram)
SearchAndReplaceWidget::searchTerms.
Definition searchandreplacewidget.cpp:848
QWidgetAnimation * m_horizontal_animation
Definition searchandreplacewidget.h:135
void on_m_advanced_replace_pb_clicked()
SearchAndReplaceWidget::on_m_advanced_replace_pb_clicked Open the advanced editor.
Definition searchandreplacewidget.cpp:1352
QPointer< QGraphicsObject > m_last_selected
Definition searchandreplacewidget.h:131
QETDiagramEditor * m_editor
Definition searchandreplacewidget.h:113
QHash< QTreeWidgetItem *, QPointer< IndependentTextItem > > m_text_hash
Definition searchandreplacewidget.h:128
void updateParentCheckState(QTreeWidgetItem *item, bool all_parents=true)
SearchAndReplaceWidget::updateParentCheckState.
Definition searchandreplacewidget.cpp:695
QTreeWidgetItem * m_report_elmt_qtwi
Definition searchandreplacewidget.h:121
void on_m_tree_widget_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous)
Definition searchandreplacewidget.cpp:1003
QTreeWidgetItem * m_master_elmt_qtwi
Definition searchandreplacewidget.h:119
QHash< QTreeWidgetItem *, QPointer< Conductor > > m_conductor_hash
Definition searchandreplacewidget.h:129
void on_m_quit_button_clicked()
SearchAndReplaceWidget::on_m_quit_button_clicked.
Definition searchandreplacewidget.cpp:933
static QStringList searchTerms(QString str)
QAction * m_select_elements
Definition searchandreplacewidget.h:137
QList< QTreeWidgetItem * > m_qtwi_elmts
Definition searchandreplacewidget.h:124
QList< IndependentTextItem * > selectedText() const
SearchAndReplaceWidget::selectedText.
Definition searchandreplacewidget.cpp:824
QTreeWidgetItem * m_slave_elmt_qtwi
Definition searchandreplacewidget.h:120
QTreeWidgetItem * m_simple_elmt_qtwi
Definition searchandreplacewidget.h:118
QTreeWidgetItem * m_root_qtwi
Definition searchandreplacewidget.h:114
void on_m_case_sensitive_cb_stateChanged(int arg1)
SearchAndReplaceWidget::on_m_case_sensitive_cb_stateChanged Update the search when change the case se...
Definition searchandreplacewidget.cpp:1310
void setUpActions()
SearchAndReplaceWidget::setUpActions Setup some actions used in this widget.
Definition searchandreplacewidget.cpp:460
void itemChanged(QTreeWidgetItem *item, int column)
SearchAndReplaceWidget::itemChanged Reimplemented from QTreeWidget. Use to update the check state of ...
Definition searchandreplacewidget.cpp:659
QWidgetAnimation * m_vertical_animation
Definition searchandreplacewidget.h:134
void activateNextChecked()
SearchAndReplaceWidget::activateNextChecked Activate the next checked (and visible) item.
Definition searchandreplacewidget.cpp:740
void on_m_mode_cb_currentIndexChanged(int index)
SearchAndReplaceWidget::on_m_mode_cb_currentIndexChanged Update the search when user change mode.
Definition searchandreplacewidget.cpp:1299
void on_m_reload_pb_clicked()
Definition searchandreplacewidget.cpp:984
void on_m_advanced_pb_toggled(bool checked)
Definition searchandreplacewidget.cpp:944
QAction * m_select_conductors
Definition searchandreplacewidget.h:138
QTreeWidgetItem * previousItem(QTreeWidgetItem *item=nullptr, QTreeWidgetItemIterator::IteratorFlag flags=QTreeWidgetItemIterator::All) const
SearchAndReplaceWidget::previousItem.
Definition searchandreplacewidget.cpp:578
void setChildCheckState(QTreeWidgetItem *item, Qt::CheckState check, bool deep=true)
SearchAndReplaceWidget::setChildCheckState.
Definition searchandreplacewidget.cpp:676
void on_m_replace_all_pb_clicked()
SearchAndReplaceWidget::on_m_replace_all_pb_clicked Replace all checked item.
Definition searchandreplacewidget.cpp:1235
QTreeWidgetItem * m_indi_text_qtwi
Definition searchandreplacewidget.h:116
void setUpTreeItems()
SearchAndReplaceWidget::setUpTreeItems Set up the main tree widget items.
Definition searchandreplacewidget.cpp:155
QList< Conductor * > selectedConductor() const
SearchAndReplaceWidget::selectedConductor.
Definition searchandreplacewidget.cpp:801
QList< Diagram * > selectedDiagram() const
SearchAndReplaceWidget::selectedDiagram.
Definition searchandreplacewidget.cpp:757
bool event(QEvent *event) override
SearchAndReplaceWidget::event Reimplemented to clear the the lines edit and hide the advanced widgets...
Definition searchandreplacewidget.cpp:87
void on_m_element_pb_clicked()
Definition searchandreplacewidget.cpp:1267
QList< QTreeWidgetItem * > m_category_qtwi
Definition searchandreplacewidget.h:125
QAction * m_select_texts
Definition searchandreplacewidget.h:139
QTreeWidgetItem * nextItem(QTreeWidgetItem *item=nullptr, QTreeWidgetItemIterator::IteratorFlag flags=QTreeWidgetItemIterator::All) const
SearchAndReplaceWidget::nextItem.
Definition searchandreplacewidget.cpp:545
The SearchAndReplaceWorker class This class is the worker use to change properties when use the searc...
Definition searchandreplaceworker.h:52
Definition autonumberingdockwidget.h:26