mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-09-13 20:23:04 +02:00
Improve code style, Wrap code for better readability
This commit is contained in:
parent
e9fcd385d5
commit
60a5a83320
@ -45,8 +45,9 @@ ReplaceConductorDialog::~ReplaceConductorDialog()
|
||||
/**
|
||||
@brief ReplaceConductorDialog::updatePreview
|
||||
Update the preview for single line
|
||||
@param b true: update from the value displayed by this widget
|
||||
false: update from the properties given at the constructor of this widget
|
||||
@param b :
|
||||
true: update from the value displayed by this widget
|
||||
false: update from the properties given at the constructor of this widget
|
||||
*/
|
||||
void ReplaceConductorDialog::updatePreview(bool b)
|
||||
{
|
||||
@ -158,37 +159,66 @@ ConductorProperties ReplaceConductorDialog::properties() const
|
||||
}
|
||||
properties_.verti_rotate_text = ui->m_vertical_angle_sb->value();
|
||||
properties_.horiz_rotate_text = ui->m_horizontal_angle_sb->value();
|
||||
properties_.color = ui->m_mod_color_cb->isChecked() ? ui->m_color_pb->palette().color(QPalette::Button) : QColor();
|
||||
properties_.style = ui->m_line_style_cb->itemData(ui->m_line_style_cb->currentIndex()).value<QPen>().style();
|
||||
properties_.color = ui->m_mod_color_cb->isChecked()
|
||||
? ui->m_color_pb->palette().color(QPalette::Button)
|
||||
: QColor();
|
||||
properties_.style = ui->m_line_style_cb->itemData(
|
||||
ui->m_line_style_cb->currentIndex())
|
||||
.value<QPen>()
|
||||
.style();
|
||||
properties_.cond_size = ui->m_cond_size_sb->value();
|
||||
properties_.m_bicolor = ui->m_second_color_gb->isChecked();
|
||||
properties_.m_color_2 = ui->m_mod_color_2_cb->isChecked() ? ui->m_color_2_pb->palette().color(QPalette::Button) : QColor();
|
||||
properties_.m_color_2 = ui->m_mod_color_2_cb->isChecked()
|
||||
? ui->m_color_2_pb->palette().color(QPalette::Button)
|
||||
: QColor();
|
||||
properties_.m_dash_size = ui->m_color_2_dash_size_sb->value();
|
||||
|
||||
properties_.singleLineProperties.hasGround = ui->m_earth_cb->isChecked();
|
||||
properties_.singleLineProperties.hasNeutral = ui->m_neutral_cb->isChecked();
|
||||
properties_.singleLineProperties.is_pen = ui->m_pen_cb->isChecked();
|
||||
properties_.singleLineProperties.setPhasesCount(ui->m_phase_cb->isChecked() ? ui->m_phase_sb->value() : 0);
|
||||
properties_.singleLineProperties.hasGround =
|
||||
ui->m_earth_cb->isChecked();
|
||||
properties_.singleLineProperties.hasNeutral =
|
||||
ui->m_neutral_cb->isChecked();
|
||||
properties_.singleLineProperties.is_pen =
|
||||
ui->m_pen_cb->isChecked();
|
||||
properties_.singleLineProperties.setPhasesCount(
|
||||
ui->m_phase_cb->isChecked()
|
||||
? ui->m_phase_sb->value()
|
||||
: 0);
|
||||
|
||||
return properties_;
|
||||
}
|
||||
|
||||
void ReplaceConductorDialog::initWidget()
|
||||
{
|
||||
connect(ui->m_button_box, &QDialogButtonBox::clicked, [this](QAbstractButton *button_) {
|
||||
connect(ui->m_button_box, &QDialogButtonBox::clicked,
|
||||
[this](QAbstractButton *button_) {
|
||||
this->done(ui->m_button_box->buttonRole(button_));
|
||||
});
|
||||
|
||||
ui->m_update_preview_pb->setHidden(true);
|
||||
|
||||
ui->m_line_style_cb->addItem(tr("Ne pas modifier"), QPen(Qt::NoPen));
|
||||
ui->m_line_style_cb->addItem(tr("Trait plein", "conductor style: solid line"), QPen(Qt::SolidLine));
|
||||
ui->m_line_style_cb->addItem(tr("Trait en pointillés", "conductor style: dashed line"), QPen(Qt::DashLine));
|
||||
ui->m_line_style_cb->addItem(tr("Traits et points", "conductor style: dashed and dotted line"), QPen(Qt::DashDotLine));
|
||||
ui->m_line_style_cb->addItem(tr("Trait plein",
|
||||
"conductor style: solid line"),
|
||||
QPen(Qt::SolidLine));
|
||||
ui->m_line_style_cb->addItem(tr("Trait en pointillés",
|
||||
"conductor style: dashed line"),
|
||||
QPen(Qt::DashLine));
|
||||
ui->m_line_style_cb->addItem(tr("Traits et points",
|
||||
"conductor style: dashed and dotted line"),
|
||||
QPen(Qt::DashDotLine));
|
||||
|
||||
connect(ui->m_multi_gb, &QGroupBox::toggled, [this](bool toggle) {this->ui->m_singlewire_gb->setChecked(!toggle);});
|
||||
connect(ui->m_singlewire_gb, &QGroupBox::toggled, [this](bool toggle) {this->ui->m_multi_gb->setChecked(!toggle);});
|
||||
connect(ui->m_formula_le, &QLineEdit::textChanged, [this](QString text) {this->ui->m_text_le->setEnabled(text.isEmpty());});
|
||||
connect(ui->m_multi_gb,
|
||||
&QGroupBox::toggled,
|
||||
[this](bool toggle)
|
||||
{this->ui->m_singlewire_gb->setChecked(!toggle);});
|
||||
connect(ui->m_singlewire_gb,
|
||||
&QGroupBox::toggled,
|
||||
[this](bool toggle)
|
||||
{this->ui->m_multi_gb->setChecked(!toggle);});
|
||||
connect(ui->m_formula_le,
|
||||
&QLineEdit::textChanged,
|
||||
[this](QString text)
|
||||
{this->ui->m_text_le->setEnabled(text.isEmpty());});
|
||||
ui->m_multi_gb->setChecked(true);
|
||||
ui->m_singlewire_gb->setChecked(true);
|
||||
}
|
||||
@ -197,50 +227,75 @@ void ReplaceConductorDialog::setColorButton(const QColor &color)
|
||||
{
|
||||
QPalette palette;
|
||||
palette.setColor(QPalette::Button, color);
|
||||
ui->m_color_pb->setStyleSheet(QString("background-color: %1; min-height: 1.5em; border-style: outset; border-width: 2px; border-color: gray; border-radius: 4px;").arg(color.name()));
|
||||
ui->m_color_pb->setStyleSheet(
|
||||
QString("background-color: %1; min-height: 1.5em; border-style:"
|
||||
" outset; border-width: 2px; border-color: gray;"
|
||||
" border-radius: 4px;").arg(color.name()));
|
||||
}
|
||||
|
||||
void ReplaceConductorDialog::setColorButton2(const QColor &color)
|
||||
{
|
||||
QPalette palette;
|
||||
palette.setColor(QPalette::Button, color);
|
||||
ui->m_color_2_pb->setStyleSheet(QString("background-color: %1; min-height: 1.5em; border-style: outset; border-width: 2px; border-color: gray; border-radius: 4px;").arg(color.name()));
|
||||
ui->m_color_2_pb->setStyleSheet(
|
||||
QString("background-color: %1;"
|
||||
" min-height: 1.5em; border-style:"
|
||||
" outset; border-width: 2px;"
|
||||
" border-color: gray;"
|
||||
" border-radius: 4px;").arg(
|
||||
color.name()));
|
||||
}
|
||||
|
||||
void ReplaceConductorDialog::on_m_erase_formula_cb_clicked()
|
||||
{
|
||||
ui->m_formula_le->setText(ui->m_erase_formula_cb->isChecked() ? SearchAndReplaceWorker::eraseText() : QString());
|
||||
ui->m_formula_le->setText(ui->m_erase_formula_cb->isChecked()
|
||||
? SearchAndReplaceWorker::eraseText()
|
||||
: QString());
|
||||
ui->m_formula_le->setDisabled(ui->m_erase_formula_cb->isChecked());
|
||||
}
|
||||
|
||||
void ReplaceConductorDialog::on_m_erase_text_cb_clicked()
|
||||
{
|
||||
ui->m_text_le->setText(ui->m_erase_text_cb->isChecked() ? SearchAndReplaceWorker::eraseText() : QString());
|
||||
ui->m_text_le->setText(ui->m_erase_text_cb->isChecked()
|
||||
? SearchAndReplaceWorker::eraseText()
|
||||
: QString());
|
||||
ui->m_text_le->setDisabled(ui->m_erase_text_cb->isChecked());
|
||||
}
|
||||
|
||||
void ReplaceConductorDialog::on_m_erase_function_cb_clicked()
|
||||
{
|
||||
ui->m_function_le->setText(ui->m_erase_function_cb->isChecked() ? SearchAndReplaceWorker::eraseText() : QString());
|
||||
ui->m_function_le->setText(ui->m_erase_function_cb->isChecked()
|
||||
? SearchAndReplaceWorker::eraseText()
|
||||
: QString());
|
||||
ui->m_function_le->setDisabled(ui->m_erase_function_cb->isChecked());
|
||||
}
|
||||
|
||||
void ReplaceConductorDialog::on_m_erase_tension_protocol_cb_clicked()
|
||||
{
|
||||
ui->m_tension_protocol_le->setText(ui->m_erase_tension_protocol_cb->isChecked() ? SearchAndReplaceWorker::eraseText() : QString());
|
||||
ui->m_tension_protocol_le->setDisabled(ui->m_erase_tension_protocol_cb->isChecked());
|
||||
ui->m_tension_protocol_le->setText(
|
||||
ui->m_erase_tension_protocol_cb->isChecked()
|
||||
? SearchAndReplaceWorker::eraseText()
|
||||
: QString());
|
||||
ui->m_tension_protocol_le->setDisabled(
|
||||
ui->m_erase_tension_protocol_cb->isChecked());
|
||||
}
|
||||
|
||||
void ReplaceConductorDialog::on_m_erase_m_wire_color_cb_clicked()
|
||||
{
|
||||
ui->m_wire_color_le->setText(ui->m_erase_wire_color_cb->isChecked() ? SearchAndReplaceWorker::eraseText() : QString());
|
||||
ui->m_wire_color_le->setDisabled(ui->m_erase_wire_color_cb->isChecked());
|
||||
ui->m_wire_color_le->setText(ui->m_erase_wire_color_cb->isChecked()
|
||||
? SearchAndReplaceWorker::eraseText()
|
||||
: QString());
|
||||
ui->m_wire_color_le->setDisabled(
|
||||
ui->m_erase_wire_color_cb->isChecked());
|
||||
}
|
||||
|
||||
void ReplaceConductorDialog::on_m_erase_m_wire_section_cb_clicked()
|
||||
{
|
||||
ui->m_wire_section_le->setText(ui->m_erase_wire_section_cb->isChecked() ? SearchAndReplaceWorker::eraseText() : QString());
|
||||
ui->m_wire_section_le->setDisabled(ui->m_erase_wire_section_cb->isChecked());
|
||||
ui->m_wire_section_le->setText(ui->m_erase_wire_section_cb->isChecked()
|
||||
? SearchAndReplaceWorker::eraseText()
|
||||
: QString());
|
||||
ui->m_wire_section_le->setDisabled(
|
||||
ui->m_erase_wire_section_cb->isChecked());
|
||||
}
|
||||
|
||||
void ReplaceConductorDialog::on_m_earth_cb_toggled(bool checked)
|
||||
@ -262,7 +317,7 @@ void ReplaceConductorDialog::on_m_neutral_cb_toggled(bool checked)
|
||||
}
|
||||
|
||||
void ReplaceConductorDialog::on_m_update_preview_pb_clicked() {
|
||||
updatePreview();
|
||||
updatePreview();
|
||||
}
|
||||
|
||||
void ReplaceConductorDialog::on_m_color_pb_clicked()
|
||||
|
@ -75,7 +75,8 @@ TitleBlockProperties ReplaceFolioWidget::titleBlockProperties() const
|
||||
Set the title block properties edited by this widget
|
||||
@param properties
|
||||
*/
|
||||
void ReplaceFolioWidget::setTitleBlockProperties(const TitleBlockProperties &properties)
|
||||
void ReplaceFolioWidget::setTitleBlockProperties(
|
||||
const TitleBlockProperties &properties)
|
||||
{
|
||||
sarw::setupLineEdit(ui->m_title_le, ui->m_title_cb, properties.title);
|
||||
sarw::setupLineEdit(ui->m_author_le, ui->m_author_cb, properties.author);
|
||||
@ -118,9 +119,15 @@ ReplaceFolioDialog::ReplaceFolioDialog(QWidget *parent) :
|
||||
{
|
||||
QVBoxLayout *layout = new QVBoxLayout(this);
|
||||
layout->addWidget(m_widget = new ReplaceFolioWidget(this));
|
||||
layout->addWidget(m_button_box = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Reset, this));
|
||||
layout->addWidget(m_button_box = new QDialogButtonBox(
|
||||
QDialogButtonBox::Ok
|
||||
| QDialogButtonBox::Cancel
|
||||
| QDialogButtonBox::Reset,
|
||||
this));
|
||||
|
||||
connect(m_button_box, &QDialogButtonBox::clicked, [this](QAbstractButton *button_)
|
||||
connect(m_button_box,
|
||||
&QDialogButtonBox::clicked,
|
||||
[this](QAbstractButton *button_)
|
||||
{
|
||||
this->done(m_button_box->buttonRole(button_));
|
||||
});
|
||||
@ -141,40 +148,55 @@ TitleBlockProperties ReplaceFolioDialog::titleBlockProperties() const {
|
||||
@brief ReplaceFolioDialog::setTitleBlockProperties
|
||||
@param properties : set the title block properties edited by this dialog
|
||||
*/
|
||||
void ReplaceFolioDialog::setTitleBlockProperties(const TitleBlockProperties &properties) {
|
||||
void ReplaceFolioDialog::setTitleBlockProperties(
|
||||
const TitleBlockProperties &properties) {
|
||||
m_widget->setTitleBlockProperties(properties);
|
||||
}
|
||||
void ReplaceFolioWidget::on_m_title_cb_clicked() {
|
||||
ui->m_title_le->setText(ui->m_title_cb->isChecked() ? SearchAndReplaceWorker::eraseText() : QString());
|
||||
ui->m_title_le->setText(ui->m_title_cb->isChecked()
|
||||
? SearchAndReplaceWorker::eraseText()
|
||||
: QString());
|
||||
ui->m_title_le->setDisabled(ui->m_title_cb->isChecked());
|
||||
}
|
||||
|
||||
void ReplaceFolioWidget::on_m_author_cb_clicked() {
|
||||
ui->m_author_le->setText(ui->m_author_cb->isChecked() ? SearchAndReplaceWorker::eraseText() : QString());
|
||||
ui->m_author_le->setText(ui->m_author_cb->isChecked()
|
||||
? SearchAndReplaceWorker::eraseText()
|
||||
: QString());
|
||||
ui->m_author_le->setDisabled(ui->m_author_cb->isChecked());
|
||||
}
|
||||
|
||||
void ReplaceFolioWidget::on_m_file_cb_clicked() {
|
||||
ui->m_file_le->setText(ui->m_file_cb->isChecked() ? SearchAndReplaceWorker::eraseText() : QString());
|
||||
ui->m_file_le->setText(ui->m_file_cb->isChecked()
|
||||
? SearchAndReplaceWorker::eraseText()
|
||||
: QString());
|
||||
ui->m_file_le->setDisabled(ui->m_file_cb->isChecked());
|
||||
}
|
||||
|
||||
void ReplaceFolioWidget::on_m_folio_cb_clicked() {
|
||||
ui->m_folio_le->setText(ui->m_folio_cb->isChecked() ? SearchAndReplaceWorker::eraseText() : QString());
|
||||
ui->m_folio_le->setText(ui->m_folio_cb->isChecked()
|
||||
? SearchAndReplaceWorker::eraseText()
|
||||
: QString());
|
||||
ui->m_folio_le->setDisabled(ui->m_folio_cb->isChecked());
|
||||
}
|
||||
|
||||
void ReplaceFolioWidget::on_m_plant_cb_clicked() {
|
||||
ui->m_plant->setText(ui->m_plant_cb->isChecked() ? SearchAndReplaceWorker::eraseText() : QString());
|
||||
ui->m_plant->setText(ui->m_plant_cb->isChecked()
|
||||
? SearchAndReplaceWorker::eraseText()
|
||||
: QString());
|
||||
ui->m_plant->setDisabled(ui->m_plant_cb->isChecked());
|
||||
}
|
||||
|
||||
void ReplaceFolioWidget::on_m_loc_cb_clicked() {
|
||||
ui->m_loc->setText(ui->m_loc_cb->isChecked() ? SearchAndReplaceWorker::eraseText() : QString());
|
||||
ui->m_loc->setText(ui->m_loc_cb->isChecked()
|
||||
? SearchAndReplaceWorker::eraseText()
|
||||
: QString());
|
||||
ui->m_loc->setDisabled(ui->m_loc_cb->isChecked());
|
||||
}
|
||||
|
||||
void ReplaceFolioWidget::on_m_indice_cb_clicked() {
|
||||
ui->m_indice->setText(ui->m_indice_cb->isChecked() ? SearchAndReplaceWorker::eraseText() : QString());
|
||||
ui->m_indice->setText(ui->m_indice_cb->isChecked()
|
||||
? SearchAndReplaceWorker::eraseText()
|
||||
: QString());
|
||||
ui->m_indice->setDisabled(ui->m_indice_cb->isChecked());
|
||||
}
|
||||
|
@ -46,8 +46,15 @@ SearchAndReplaceWidget::SearchAndReplaceWidget(QWidget *parent) :
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
m_horizontal_animation = new QWidgetAnimation(ui->m_advanced_button_widget, Qt::Horizontal, QWidgetAnimation::minimumSizeHint, 250);
|
||||
m_vertical_animation = new QWidgetAnimation(ui->m_advanced_widget, Qt::Vertical, QWidgetAnimation::availableSpace, 250);
|
||||
m_horizontal_animation = new QWidgetAnimation(
|
||||
ui->m_advanced_button_widget,
|
||||
Qt::Horizontal,
|
||||
QWidgetAnimation::minimumSizeHint,
|
||||
250);
|
||||
m_vertical_animation = new QWidgetAnimation(
|
||||
ui->m_advanced_widget,
|
||||
Qt::Vertical,
|
||||
QWidgetAnimation::availableSpace, 250);
|
||||
QVector<QWidget *> v;
|
||||
v << ui->m_header_widget;
|
||||
m_vertical_animation->widgetToSubtract(v);
|
||||
@ -55,7 +62,8 @@ SearchAndReplaceWidget::SearchAndReplaceWidget(QWidget *parent) :
|
||||
setHideAdvanced(true);
|
||||
setUpTreeItems();
|
||||
|
||||
connect(ui->m_search_le, &QLineEdit::textEdited, this, &SearchAndReplaceWidget::search);
|
||||
connect(ui->m_search_le, &QLineEdit::textEdited,
|
||||
this, &SearchAndReplaceWidget::search);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -101,7 +109,8 @@ bool SearchAndReplaceWidget::event(QEvent *event)
|
||||
*/
|
||||
void SearchAndReplaceWidget::clear()
|
||||
{
|
||||
disconnect(ui->m_tree_widget, &QTreeWidget::itemChanged, this, &SearchAndReplaceWidget::itemChanged);
|
||||
disconnect(ui->m_tree_widget, &QTreeWidget::itemChanged,
|
||||
this, &SearchAndReplaceWidget::itemChanged);
|
||||
|
||||
qDeleteAll(m_diagram_hash.keys());
|
||||
m_diagram_hash.clear();
|
||||
@ -223,7 +232,8 @@ void SearchAndReplaceWidget::setHideAdvanced(bool hide)
|
||||
*/
|
||||
void SearchAndReplaceWidget::fillItemsList()
|
||||
{
|
||||
disconnect(ui->m_tree_widget, &QTreeWidget::itemChanged, this, &SearchAndReplaceWidget::itemChanged);
|
||||
disconnect(ui->m_tree_widget, &QTreeWidget::itemChanged,
|
||||
this, &SearchAndReplaceWidget::itemChanged);
|
||||
|
||||
qDeleteAll(m_element_hash.keys());
|
||||
m_element_hash.clear();
|
||||
@ -235,7 +245,8 @@ void SearchAndReplaceWidget::fillItemsList()
|
||||
return;
|
||||
}
|
||||
ui->m_replace_all_pb->setEnabled(true);
|
||||
connect(project_, &QETProject::destroyed, this, &SearchAndReplaceWidget::on_m_reload_pb_clicked);
|
||||
connect(project_, &QETProject::destroyed, this,
|
||||
&SearchAndReplaceWidget::on_m_reload_pb_clicked);
|
||||
|
||||
|
||||
DiagramContent dc;
|
||||
@ -263,8 +274,8 @@ void SearchAndReplaceWidget::fillItemsList()
|
||||
for (Element *elmt : dc.m_elements)
|
||||
addElement(elmt);
|
||||
|
||||
//Sort child of each "element type" tree item.
|
||||
//we hide, "element type" tree item, if they do not have children
|
||||
//Sort child of each "element type" tree item.
|
||||
//we hide, "element type" tree item, if they do not have children
|
||||
for(QTreeWidgetItem *qtwi : m_qtwi_elmts)
|
||||
{
|
||||
qtwi->sortChildren(0, Qt::AscendingOrder);
|
||||
@ -292,7 +303,8 @@ void SearchAndReplaceWidget::fillItemsList()
|
||||
m_conductor_qtwi->sortChildren(0, Qt::AscendingOrder);
|
||||
|
||||
updateNextPreviousButtons();
|
||||
connect(ui->m_tree_widget, &QTreeWidget::itemChanged, this, &SearchAndReplaceWidget::itemChanged);
|
||||
connect(ui->m_tree_widget, &QTreeWidget::itemChanged,
|
||||
this, &SearchAndReplaceWidget::itemChanged);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -378,19 +390,25 @@ void SearchAndReplaceWidget::search()
|
||||
qtwi_list.append(m_conductor_hash.keys());
|
||||
for (QTreeWidgetItem *qtwi : qtwi_list)
|
||||
{
|
||||
QStringList list = qtwi->data(0, Qt::UserRole).toStringList();
|
||||
QStringList list = qtwi->data(0, Qt::UserRole)
|
||||
.toStringList();
|
||||
|
||||
if(ui->m_mode_cb->currentIndex() == 0)
|
||||
{
|
||||
//Contain string
|
||||
list = list.filter(str, ui->m_case_sensitive_cb->isChecked()? Qt::CaseSensitive : Qt::CaseInsensitive);
|
||||
list = list.filter(
|
||||
str,
|
||||
ui->m_case_sensitive_cb->isChecked()
|
||||
? Qt::CaseSensitive
|
||||
: Qt::CaseInsensitive);
|
||||
}
|
||||
else
|
||||
{
|
||||
//entire word
|
||||
QRegularExpression rx("\\b" + str + "\\b");
|
||||
if (!ui->m_case_sensitive_cb->isChecked()) {
|
||||
rx.setPatternOptions(QRegularExpression::CaseInsensitiveOption);
|
||||
rx.setPatternOptions(
|
||||
QRegularExpression::CaseInsensitiveOption);
|
||||
}
|
||||
list = list.filter(rx);
|
||||
}
|
||||
@ -403,7 +421,9 @@ void SearchAndReplaceWidget::search()
|
||||
}
|
||||
|
||||
QPalette background = ui->m_search_le->palette();
|
||||
background.setColor(QPalette::Base, match ? QColor("#E0FFF0") : QColor("#FFE0EF"));
|
||||
background.setColor(QPalette::Base, match
|
||||
? QColor("#E0FFF0")
|
||||
: QColor("#FFE0EF"));
|
||||
ui->m_search_le->setPalette(background);
|
||||
|
||||
//Go to the first occurence
|
||||
@ -418,7 +438,8 @@ void SearchAndReplaceWidget::search()
|
||||
@param item
|
||||
@param expend_parent
|
||||
*/
|
||||
void SearchAndReplaceWidget::setVisibleAllParents(QTreeWidgetItem *item, bool expend_parent)
|
||||
void SearchAndReplaceWidget::setVisibleAllParents(QTreeWidgetItem *item,
|
||||
bool expend_parent)
|
||||
{
|
||||
if (item->parent())
|
||||
{
|
||||
@ -437,7 +458,9 @@ void SearchAndReplaceWidget::setVisibleAllParents(QTreeWidgetItem *item, bool ex
|
||||
@return the next item according to flag
|
||||
or nullptr if there is not a next item
|
||||
*/
|
||||
QTreeWidgetItem *SearchAndReplaceWidget::nextItem(QTreeWidgetItem *item, QTreeWidgetItemIterator::IteratorFlag flags) const
|
||||
QTreeWidgetItem *SearchAndReplaceWidget::nextItem(
|
||||
QTreeWidgetItem *item,
|
||||
QTreeWidgetItemIterator::IteratorFlag flags) const
|
||||
{
|
||||
QTreeWidgetItem *qtwi = item;
|
||||
if (!item) {
|
||||
@ -468,7 +491,9 @@ QTreeWidgetItem *SearchAndReplaceWidget::nextItem(QTreeWidgetItem *item, QTreeWi
|
||||
@return the previous item according to flag
|
||||
or nullptr if there is not a previous item
|
||||
*/
|
||||
QTreeWidgetItem *SearchAndReplaceWidget::previousItem(QTreeWidgetItem *item, QTreeWidgetItemIterator::IteratorFlag flags) const
|
||||
QTreeWidgetItem *SearchAndReplaceWidget::previousItem(
|
||||
QTreeWidgetItem *item,
|
||||
QTreeWidgetItemIterator::IteratorFlag flags) const
|
||||
{
|
||||
QTreeWidgetItem *qtwi = item;
|
||||
if (!item) {
|
||||
@ -525,7 +550,8 @@ void SearchAndReplaceWidget::updateNextPreviousButtons()
|
||||
QTreeWidgetItem *previous_ = item_;
|
||||
do
|
||||
{
|
||||
previous_ = previousItem(previous_, QTreeWidgetItemIterator::NotHidden);
|
||||
previous_ = previousItem(previous_,
|
||||
QTreeWidgetItemIterator::NotHidden);
|
||||
if (!previous_)
|
||||
{
|
||||
ui->m_previous_pb->setDisabled(true);
|
||||
@ -563,7 +589,9 @@ void SearchAndReplaceWidget::itemChanged(QTreeWidgetItem *item, int column)
|
||||
@param check : check state
|
||||
@param deep : if true, we evaluate every subchilds.
|
||||
*/
|
||||
void SearchAndReplaceWidget::setChildCheckState(QTreeWidgetItem *item, Qt::CheckState check, bool deep)
|
||||
void SearchAndReplaceWidget::setChildCheckState(QTreeWidgetItem *item,
|
||||
Qt::CheckState check,
|
||||
bool deep)
|
||||
{
|
||||
for (int i=0 ; i<item->childCount() ; ++i)
|
||||
{
|
||||
@ -580,7 +608,8 @@ void SearchAndReplaceWidget::setChildCheckState(QTreeWidgetItem *item, Qt::Check
|
||||
@param all_parents : if true, we evaluate every parents,
|
||||
until the root item.
|
||||
*/
|
||||
void SearchAndReplaceWidget::updateParentCheckState(QTreeWidgetItem *item, bool all_parents)
|
||||
void SearchAndReplaceWidget::updateParentCheckState(QTreeWidgetItem *item,
|
||||
bool all_parents)
|
||||
{
|
||||
QTreeWidgetItem *parent = item->parent();
|
||||
|
||||
@ -632,8 +661,9 @@ void SearchAndReplaceWidget::activateNextChecked()
|
||||
|
||||
do {
|
||||
on_m_next_pb_clicked();
|
||||
} while ((ui->m_tree_widget->currentItem()->checkState(0) != Qt::Checked) &&
|
||||
ui->m_next_pb->isEnabled());
|
||||
} while ((ui->m_tree_widget->currentItem()->checkState(0)
|
||||
!= Qt::Checked
|
||||
) && ui->m_next_pb->isEnabled());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -715,7 +745,8 @@ QList<IndependentTextItem *> SearchAndReplaceWidget::selectedText() const
|
||||
{
|
||||
if (!qtwi->isHidden() && qtwi->checkState(0) == Qt::Checked)
|
||||
{
|
||||
QPointer<IndependentTextItem> t = m_text_hash.value(qtwi);
|
||||
QPointer<IndependentTextItem> t =
|
||||
m_text_hash.value(qtwi);
|
||||
if (t) {
|
||||
text_list.append(t.data());
|
||||
}
|
||||
@ -733,7 +764,8 @@ QList<IndependentTextItem *> SearchAndReplaceWidget::selectedText() const
|
||||
QStringList SearchAndReplaceWidget::searchTerms(Diagram *diagram)
|
||||
{
|
||||
QStringList list;
|
||||
TitleBlockProperties prop = diagram->border_and_titleblock.exportTitleBlock();
|
||||
TitleBlockProperties prop =
|
||||
diagram->border_and_titleblock.exportTitleBlock();
|
||||
list.append(prop.title);
|
||||
list.append(prop.author);
|
||||
list.append(prop.filename);
|
||||
@ -768,7 +800,10 @@ QStringList SearchAndReplaceWidget::searchTerms(Element *element)
|
||||
|
||||
for (DynamicElementTextItem *deti : element->dynamicTextItems())
|
||||
{
|
||||
if (deti->textFrom() == DynamicElementTextItem::UserText || deti->textFrom() == DynamicElementTextItem::CompositeText) {
|
||||
if (deti->textFrom()
|
||||
== DynamicElementTextItem::UserText
|
||||
|| deti->textFrom()
|
||||
== DynamicElementTextItem::CompositeText) {
|
||||
list.append(deti->toPlainText());
|
||||
}
|
||||
}
|
||||
@ -777,7 +812,10 @@ QStringList SearchAndReplaceWidget::searchTerms(Element *element)
|
||||
list.append(group->name());
|
||||
|
||||
for (DynamicElementTextItem *deti : group->texts()) {
|
||||
if (deti->textFrom() == DynamicElementTextItem::UserText || deti->textFrom() == DynamicElementTextItem::CompositeText) {
|
||||
if (deti->textFrom()
|
||||
== DynamicElementTextItem::UserText
|
||||
|| deti->textFrom()
|
||||
== DynamicElementTextItem::CompositeText) {
|
||||
list.append(deti->toPlainText());
|
||||
}
|
||||
}
|
||||
@ -810,7 +848,9 @@ QStringList SearchAndReplaceWidget::searchTerms(Conductor *conductor)
|
||||
*/
|
||||
void SearchAndReplaceWidget::on_m_quit_button_clicked()
|
||||
{
|
||||
if (auto animator = this->findChild<QWidgetAnimation *>("search and replace animator")) {
|
||||
if (auto animator =
|
||||
this->findChild<QWidgetAnimation *>(
|
||||
"search and replace animator")) {
|
||||
animator->setHidden(!this->isHidden());
|
||||
} else {
|
||||
this->setHidden(true);
|
||||
@ -818,10 +858,12 @@ void SearchAndReplaceWidget::on_m_quit_button_clicked()
|
||||
}
|
||||
|
||||
void SearchAndReplaceWidget::on_m_advanced_pb_toggled(bool checked) {
|
||||
setHideAdvanced(!checked);
|
||||
setHideAdvanced(!checked);
|
||||
}
|
||||
|
||||
void SearchAndReplaceWidget::on_m_tree_widget_itemDoubleClicked(QTreeWidgetItem *item, int column)
|
||||
void SearchAndReplaceWidget::on_m_tree_widget_itemDoubleClicked(
|
||||
QTreeWidgetItem *item,
|
||||
int column)
|
||||
{
|
||||
Q_UNUSED(column)
|
||||
|
||||
@ -874,7 +916,9 @@ void SearchAndReplaceWidget::on_m_reload_pb_clicked()
|
||||
m_root_qtwi->setExpanded(true);
|
||||
}
|
||||
|
||||
void SearchAndReplaceWidget::on_m_tree_widget_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous)
|
||||
void SearchAndReplaceWidget::on_m_tree_widget_currentItemChanged(
|
||||
QTreeWidgetItem *current,
|
||||
QTreeWidgetItem *previous)
|
||||
{
|
||||
Q_UNUSED(previous);
|
||||
|
||||
@ -918,7 +962,8 @@ void SearchAndReplaceWidget::on_m_tree_widget_currentItemChanged(QTreeWidgetItem
|
||||
return;
|
||||
}
|
||||
|
||||
if (current->checkState(0) == Qt::Checked && !m_category_qtwi.contains(current)) {
|
||||
if (current->checkState(0) == Qt::Checked
|
||||
&& !m_category_qtwi.contains(current)) {
|
||||
ui->m_replace_pb->setEnabled(true);
|
||||
} else {
|
||||
ui->m_replace_pb->setDisabled(true);
|
||||
@ -950,15 +995,20 @@ void SearchAndReplaceWidget::on_m_previous_pb_clicked()
|
||||
|
||||
do
|
||||
{
|
||||
item = previousItem(nullptr, QTreeWidgetItemIterator::NotHidden);
|
||||
item = previousItem(nullptr,
|
||||
QTreeWidgetItemIterator::NotHidden);
|
||||
if (item) {
|
||||
ui->m_tree_widget->setCurrentItem(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
//There is not a previous selected item, so the current item is m_root_qtwi but we know he must not be selected
|
||||
//we user click on the button 'next item'.
|
||||
//So we select the first selectable item by calling on_m_next_pb_clicked
|
||||
/* There is not a previous selected item,
|
||||
* so the current item is m_root_qtwi
|
||||
* but we know he must not be selected
|
||||
* we user click on the button 'next item'.
|
||||
* So we select the first selectable item
|
||||
* by calling on_m_next_pb_clicked
|
||||
*/
|
||||
on_m_next_pb_clicked();
|
||||
return;
|
||||
}
|
||||
@ -982,7 +1032,8 @@ void SearchAndReplaceWidget::on_m_folio_pb_clicked()
|
||||
text.append(tr(" [édité]"));
|
||||
}
|
||||
ui->m_folio_pb->setText(text);
|
||||
m_worker.m_titleblock_properties = dialog->titleBlockProperties();
|
||||
m_worker.m_titleblock_properties =
|
||||
dialog->titleBlockProperties();
|
||||
}
|
||||
else if (result == QDialogButtonBox::ResetRole)
|
||||
{
|
||||
@ -1005,7 +1056,8 @@ void SearchAndReplaceWidget::on_m_replace_pb_clicked()
|
||||
if(!qtwi) {
|
||||
return;
|
||||
}
|
||||
if (!m_category_qtwi.contains(qtwi) && qtwi->checkState(0) == Qt::Checked)
|
||||
if (!m_category_qtwi.contains(qtwi)
|
||||
&& qtwi->checkState(0) == Qt::Checked)
|
||||
{
|
||||
if (ui->m_folio_pb->text().endsWith(tr(" [édité]")) &&
|
||||
m_diagram_hash.keys().contains(qtwi))
|
||||
@ -1027,7 +1079,8 @@ void SearchAndReplaceWidget::on_m_replace_pb_clicked()
|
||||
m_text_hash.keys().contains(qtwi))
|
||||
{
|
||||
m_worker.m_indi_text = ui->m_replace_le->text();
|
||||
QPointer<IndependentTextItem> t = m_text_hash.value(qtwi);
|
||||
QPointer<IndependentTextItem> t =
|
||||
m_text_hash.value(qtwi);
|
||||
if (t) {
|
||||
m_worker.replaceIndiText(t.data());
|
||||
}
|
||||
@ -1052,28 +1105,32 @@ void SearchAndReplaceWidget::on_m_replace_pb_clicked()
|
||||
|
||||
if (m_diagram_hash.keys().contains(qtwi))
|
||||
{
|
||||
QPointer<Diagram> d = m_diagram_hash.value(qtwi);
|
||||
QPointer<Diagram> d =
|
||||
m_diagram_hash.value(qtwi);
|
||||
if (d) {
|
||||
dl.append(d.data());
|
||||
}
|
||||
}
|
||||
else if (m_element_hash.keys().contains(qtwi))
|
||||
{
|
||||
QPointer<Element> e = m_element_hash.value(qtwi);
|
||||
QPointer<Element> e =
|
||||
m_element_hash.value(qtwi);
|
||||
if (e) {
|
||||
el.append(e.data());
|
||||
}
|
||||
}
|
||||
else if (m_text_hash.keys().contains(qtwi))
|
||||
{
|
||||
QPointer<IndependentTextItem> t = m_text_hash.value(qtwi);
|
||||
QPointer<IndependentTextItem> t =
|
||||
m_text_hash.value(qtwi);
|
||||
if (t) {
|
||||
tl.append(t.data());
|
||||
}
|
||||
}
|
||||
else if (m_conductor_hash.keys().contains(qtwi))
|
||||
{
|
||||
QPointer<Conductor> c = m_conductor_hash.value(qtwi);
|
||||
QPointer<Conductor> c =
|
||||
m_conductor_hash.value(qtwi);
|
||||
if (c) {
|
||||
cl.append(c.data());
|
||||
}
|
||||
@ -1108,7 +1165,10 @@ void SearchAndReplaceWidget::on_m_replace_all_pb_clicked()
|
||||
}
|
||||
if (ui->m_advanced_replace_pb->text().endsWith(tr(" [édité]"))) {
|
||||
|
||||
m_worker.replaceAdvanced(selectedDiagram(), selectedElement(), selectedText(), selectedConductor());
|
||||
m_worker.replaceAdvanced(selectedDiagram(),
|
||||
selectedElement(),
|
||||
selectedText(),
|
||||
selectedConductor());
|
||||
}
|
||||
|
||||
//Change was made, we reload the panel
|
||||
@ -1122,7 +1182,9 @@ void SearchAndReplaceWidget::on_m_replace_all_pb_clicked()
|
||||
|
||||
void SearchAndReplaceWidget::on_m_element_pb_clicked()
|
||||
{
|
||||
ReplaceElementDialog *dialog = new ReplaceElementDialog(m_worker.m_element_context, this);
|
||||
ReplaceElementDialog *dialog = new ReplaceElementDialog(
|
||||
m_worker.m_element_context,
|
||||
this);
|
||||
|
||||
int result = dialog->exec();
|
||||
if (result == QDialogButtonBox::AcceptRole)
|
||||
@ -1173,7 +1235,9 @@ void SearchAndReplaceWidget::on_m_case_sensitive_cb_stateChanged(int arg1)
|
||||
*/
|
||||
void SearchAndReplaceWidget::on_m_conductor_pb_clicked()
|
||||
{
|
||||
ReplaceConductorDialog *dialog = new ReplaceConductorDialog(m_worker.m_conductor_properties, this);
|
||||
ReplaceConductorDialog *dialog = new ReplaceConductorDialog(
|
||||
m_worker.m_conductor_properties,
|
||||
this);
|
||||
int result = dialog->exec();
|
||||
|
||||
if (result == QDialogButtonBox::AcceptRole)
|
||||
@ -1192,7 +1256,8 @@ void SearchAndReplaceWidget::on_m_conductor_pb_clicked()
|
||||
text.remove(tr(" [édité]"));
|
||||
}
|
||||
ui->m_conductor_pb->setText(text);
|
||||
m_worker.m_conductor_properties = m_worker.invalidConductorProperties();
|
||||
m_worker.m_conductor_properties =
|
||||
m_worker.invalidConductorProperties();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1202,7 +1267,9 @@ void SearchAndReplaceWidget::on_m_conductor_pb_clicked()
|
||||
*/
|
||||
void SearchAndReplaceWidget::on_m_advanced_replace_pb_clicked()
|
||||
{
|
||||
replaceAdvancedDialog *dialog = new replaceAdvancedDialog(m_worker.m_advanced_struct, this);
|
||||
replaceAdvancedDialog *dialog = new replaceAdvancedDialog(
|
||||
m_worker.m_advanced_struct,
|
||||
this);
|
||||
int result = dialog->exec();
|
||||
|
||||
if (result == QDialogButtonBox::AcceptRole)
|
||||
|
@ -53,13 +53,23 @@ class SearchAndReplaceWidget : public QWidget
|
||||
void addElement(Element *element);
|
||||
void search();
|
||||
|
||||
void setVisibleAllParents(QTreeWidgetItem *item, bool expend_parent = true);
|
||||
QTreeWidgetItem *nextItem(QTreeWidgetItem *item=nullptr, QTreeWidgetItemIterator::IteratorFlag flags = QTreeWidgetItemIterator::All) const;
|
||||
QTreeWidgetItem *previousItem(QTreeWidgetItem *item=nullptr, QTreeWidgetItemIterator::IteratorFlag flags = QTreeWidgetItemIterator::All) const;
|
||||
void setVisibleAllParents(QTreeWidgetItem *item,
|
||||
bool expend_parent = true);
|
||||
QTreeWidgetItem *nextItem(
|
||||
QTreeWidgetItem *item=nullptr,
|
||||
QTreeWidgetItemIterator::IteratorFlag flags
|
||||
= QTreeWidgetItemIterator::All) const;
|
||||
QTreeWidgetItem *previousItem(
|
||||
QTreeWidgetItem *item=nullptr,
|
||||
QTreeWidgetItemIterator::IteratorFlag flags
|
||||
= QTreeWidgetItemIterator::All) const;
|
||||
void updateNextPreviousButtons();
|
||||
void itemChanged(QTreeWidgetItem *item, int column);
|
||||
void setChildCheckState(QTreeWidgetItem *item, Qt::CheckState check, bool deep = true);
|
||||
void updateParentCheckState(QTreeWidgetItem *item, bool all_parents = true);
|
||||
void setChildCheckState(QTreeWidgetItem *item,
|
||||
Qt::CheckState check,
|
||||
bool deep = true);
|
||||
void updateParentCheckState(QTreeWidgetItem *item,
|
||||
bool all_parents = true);
|
||||
void activateNextChecked();
|
||||
QList<Diagram *> selectedDiagram() const;
|
||||
QList<Element *> selectedElement() const;
|
||||
@ -74,9 +84,12 @@ class SearchAndReplaceWidget : public QWidget
|
||||
private slots:
|
||||
void on_m_quit_button_clicked();
|
||||
void on_m_advanced_pb_toggled(bool checked);
|
||||
void on_m_tree_widget_itemDoubleClicked(QTreeWidgetItem *item, int column);
|
||||
void on_m_tree_widget_itemDoubleClicked(QTreeWidgetItem *item,
|
||||
int column);
|
||||
void on_m_reload_pb_clicked();
|
||||
void on_m_tree_widget_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous);
|
||||
void on_m_tree_widget_currentItemChanged(
|
||||
QTreeWidgetItem *current,
|
||||
QTreeWidgetItem *previous);
|
||||
void on_m_next_pb_clicked();
|
||||
void on_m_previous_pb_clicked();
|
||||
void on_m_folio_pb_clicked();
|
||||
@ -104,7 +117,8 @@ class SearchAndReplaceWidget : public QWidget
|
||||
QList<QTreeWidgetItem *> m_qtwi_elmts;
|
||||
QList<QTreeWidgetItem *> m_category_qtwi;
|
||||
QHash<QTreeWidgetItem *, QPointer <Element>> m_element_hash;
|
||||
QHash<QTreeWidgetItem *, QPointer <IndependentTextItem>> m_text_hash;
|
||||
QHash<QTreeWidgetItem *,
|
||||
QPointer <IndependentTextItem>> m_text_hash;
|
||||
QHash<QTreeWidgetItem *, QPointer <Conductor>> m_conductor_hash;
|
||||
QPointer<Element> m_highlighted_element;
|
||||
QPointer<QGraphicsObject> m_last_selected;
|
||||
|
Loading…
x
Reference in New Issue
Block a user