mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-18 05:00:33 +01:00
Search and replace widget improvement
Add a popup menu to select the elements, conductors and texts of the current selected diagram in the tree widget.
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 The QElectroTech Team
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
@@ -33,6 +33,7 @@
|
|||||||
#include "elementtextitemgroup.h"
|
#include "elementtextitemgroup.h"
|
||||||
#include "QWidgetAnimation/qwidgetanimation.h"
|
#include "QWidgetAnimation/qwidgetanimation.h"
|
||||||
#include "qetinformation.h"
|
#include "qetinformation.h"
|
||||||
|
#include "diagramcontent.h"
|
||||||
|
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
|
|
||||||
@@ -62,9 +63,8 @@ SearchAndReplaceWidget::SearchAndReplaceWidget(QWidget *parent) :
|
|||||||
|
|
||||||
setHideAdvanced(true);
|
setHideAdvanced(true);
|
||||||
setUpTreeItems();
|
setUpTreeItems();
|
||||||
|
setUpActions();
|
||||||
connect(ui->m_search_le, &QLineEdit::textEdited,
|
setUpConenctions();
|
||||||
this, &SearchAndReplaceWidget::search);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -441,6 +441,69 @@ void SearchAndReplaceWidget::search()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief SearchAndReplaceWidget::setUpActions
|
||||||
|
* Setup some actions used in this widget
|
||||||
|
*/
|
||||||
|
void SearchAndReplaceWidget::setUpActions()
|
||||||
|
{
|
||||||
|
m_select_elements = new QAction(QET::Icons::Element, tr("Sélectionner les éléments de ce folio"), ui->m_tree_widget);
|
||||||
|
m_select_conductors = new QAction(QET::Icons::Conductor, tr("Sélectionner les conducteurs de ce folio"), ui->m_tree_widget);
|
||||||
|
m_select_texts = new QAction(QET::Icons::PartText, tr("Sélectionner les textes de ce folio"), ui->m_tree_widget);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief SearchAndReplaceWidget::setUpConenctions
|
||||||
|
* Setup some connection used in this widget
|
||||||
|
*/
|
||||||
|
void SearchAndReplaceWidget::setUpConenctions()
|
||||||
|
{
|
||||||
|
connect(ui->m_search_le, &QLineEdit::textEdited,
|
||||||
|
this, &SearchAndReplaceWidget::search);
|
||||||
|
|
||||||
|
connect(ui->m_tree_widget, &QTreeWidget::customContextMenuRequested, [this](const QPoint &pos)
|
||||||
|
{
|
||||||
|
if (m_diagram_hash.keys().contains(ui->m_tree_widget->currentItem()))
|
||||||
|
{
|
||||||
|
QMenu *menu = new QMenu(ui->m_tree_widget);
|
||||||
|
menu->addAction(m_select_elements);
|
||||||
|
menu->addAction(m_select_conductors);
|
||||||
|
menu->addAction(m_select_texts);
|
||||||
|
menu->popup(ui->m_tree_widget->mapToGlobal(pos));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
connect(m_select_elements, &QAction::triggered, [this]()
|
||||||
|
{
|
||||||
|
DiagramContent dc(m_diagram_hash.value(ui->m_tree_widget->currentItem()), false);
|
||||||
|
for (auto elmt : dc.m_elements) {
|
||||||
|
if (auto item = m_element_hash.key(elmt)) {
|
||||||
|
item->setCheckState(0, Qt::Checked);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
connect(m_select_conductors, &QAction::triggered, [this]()
|
||||||
|
{
|
||||||
|
DiagramContent dc(m_diagram_hash.value(ui->m_tree_widget->currentItem()), false);
|
||||||
|
for (auto cond : dc.conductors()) {
|
||||||
|
if (auto item = m_conductor_hash.key(cond)) {
|
||||||
|
item->setCheckState(0, Qt::Checked);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
connect(m_select_texts, &QAction::triggered, [this]()
|
||||||
|
{
|
||||||
|
DiagramContent dc(m_diagram_hash.value(ui->m_tree_widget->currentItem()), false);
|
||||||
|
for (auto text : dc.m_text_fields) {
|
||||||
|
if (auto item = m_text_hash.key(text)) {
|
||||||
|
item->setCheckState(0, Qt::Checked);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief SearchAndReplaceWidget::setVisibleAllParents
|
@brief SearchAndReplaceWidget::setVisibleAllParents
|
||||||
Set visible all parents of item until the invisible root item
|
Set visible all parents of item until the invisible root item
|
||||||
@@ -583,7 +646,7 @@ void SearchAndReplaceWidget::updateNextPreviousButtons()
|
|||||||
*/
|
*/
|
||||||
void SearchAndReplaceWidget::itemChanged(QTreeWidgetItem *item, int column)
|
void SearchAndReplaceWidget::itemChanged(QTreeWidgetItem *item, int column)
|
||||||
{
|
{
|
||||||
Q_UNUSED(column);
|
Q_UNUSED(column)
|
||||||
ui->m_tree_widget->blockSignals(true);
|
ui->m_tree_widget->blockSignals(true);
|
||||||
|
|
||||||
setChildCheckState(item, item->checkState(0));
|
setChildCheckState(item, item->checkState(0));
|
||||||
@@ -929,7 +992,7 @@ void SearchAndReplaceWidget::on_m_tree_widget_currentItemChanged(
|
|||||||
QTreeWidgetItem *current,
|
QTreeWidgetItem *current,
|
||||||
QTreeWidgetItem *previous)
|
QTreeWidgetItem *previous)
|
||||||
{
|
{
|
||||||
Q_UNUSED(previous);
|
Q_UNUSED(previous)
|
||||||
|
|
||||||
if(m_highlighted_element) {
|
if(m_highlighted_element) {
|
||||||
m_highlighted_element.data()->setHighlighted(false);
|
m_highlighted_element.data()->setHighlighted(false);
|
||||||
@@ -1223,7 +1286,7 @@ void SearchAndReplaceWidget::on_m_element_pb_clicked()
|
|||||||
*/
|
*/
|
||||||
void SearchAndReplaceWidget::on_m_mode_cb_currentIndexChanged(int index)
|
void SearchAndReplaceWidget::on_m_mode_cb_currentIndexChanged(int index)
|
||||||
{
|
{
|
||||||
Q_UNUSED(index);
|
Q_UNUSED(index)
|
||||||
search();
|
search();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1234,7 +1297,7 @@ void SearchAndReplaceWidget::on_m_mode_cb_currentIndexChanged(int index)
|
|||||||
*/
|
*/
|
||||||
void SearchAndReplaceWidget::on_m_case_sensitive_cb_stateChanged(int arg1)
|
void SearchAndReplaceWidget::on_m_case_sensitive_cb_stateChanged(int arg1)
|
||||||
{
|
{
|
||||||
Q_UNUSED(arg1);
|
Q_UNUSED(arg1)
|
||||||
search();
|
search();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,12 +27,14 @@
|
|||||||
#include "QWidgetAnimation/qwidgetanimation.h"
|
#include "QWidgetAnimation/qwidgetanimation.h"
|
||||||
|
|
||||||
class QTreeWidgetItem;
|
class QTreeWidgetItem;
|
||||||
|
class QETDiagramEditor;
|
||||||
|
class QAction;
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class SearchAndReplaceWidget;
|
class SearchAndReplaceWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
class QETDiagramEditor;
|
|
||||||
|
|
||||||
class SearchAndReplaceWidget : public QWidget
|
class SearchAndReplaceWidget : public QWidget
|
||||||
{
|
{
|
||||||
@@ -52,17 +54,22 @@ class SearchAndReplaceWidget : public QWidget
|
|||||||
void fillItemsList();
|
void fillItemsList();
|
||||||
void addElement(Element *element);
|
void addElement(Element *element);
|
||||||
void search();
|
void search();
|
||||||
|
void setUpActions();
|
||||||
|
void setUpConenctions();
|
||||||
|
|
||||||
void setVisibleAllParents(QTreeWidgetItem *item,
|
void setVisibleAllParents(QTreeWidgetItem *item,
|
||||||
bool expend_parent = true);
|
bool expend_parent = true);
|
||||||
|
|
||||||
QTreeWidgetItem *nextItem(
|
QTreeWidgetItem *nextItem(
|
||||||
QTreeWidgetItem *item=nullptr,
|
QTreeWidgetItem *item=nullptr,
|
||||||
QTreeWidgetItemIterator::IteratorFlag flags
|
QTreeWidgetItemIterator::IteratorFlag flags
|
||||||
= QTreeWidgetItemIterator::All) const;
|
= QTreeWidgetItemIterator::All) const;
|
||||||
|
|
||||||
QTreeWidgetItem *previousItem(
|
QTreeWidgetItem *previousItem(
|
||||||
QTreeWidgetItem *item=nullptr,
|
QTreeWidgetItem *item=nullptr,
|
||||||
QTreeWidgetItemIterator::IteratorFlag flags
|
QTreeWidgetItemIterator::IteratorFlag flags
|
||||||
= QTreeWidgetItemIterator::All) const;
|
= QTreeWidgetItemIterator::All) const;
|
||||||
|
|
||||||
void updateNextPreviousButtons();
|
void updateNextPreviousButtons();
|
||||||
void itemChanged(QTreeWidgetItem *item, int column);
|
void itemChanged(QTreeWidgetItem *item, int column);
|
||||||
void setChildCheckState(QTreeWidgetItem *item,
|
void setChildCheckState(QTreeWidgetItem *item,
|
||||||
@@ -126,6 +133,10 @@ class SearchAndReplaceWidget : public QWidget
|
|||||||
SearchAndReplaceWorker m_worker;
|
SearchAndReplaceWorker m_worker;
|
||||||
QWidgetAnimation *m_vertical_animation;
|
QWidgetAnimation *m_vertical_animation;
|
||||||
QWidgetAnimation *m_horizontal_animation;
|
QWidgetAnimation *m_horizontal_animation;
|
||||||
|
|
||||||
|
QAction *m_select_elements = nullptr,
|
||||||
|
*m_select_conductors = nullptr,
|
||||||
|
*m_select_texts = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SEARCHANDREPLACEWIDGET_H
|
#endif // SEARCHANDREPLACEWIDGET_H
|
||||||
|
|||||||
@@ -295,6 +295,9 @@
|
|||||||
<height>0</height>
|
<height>0</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="contextMenuPolicy">
|
||||||
|
<enum>Qt::CustomContextMenu</enum>
|
||||||
|
</property>
|
||||||
<property name="uniformRowHeights">
|
<property name="uniformRowHeights">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
|
|||||||
Reference in New Issue
Block a user