2014-02-12 17:36:35 +00:00
|
|
|
/*
|
2018-11-09 18:50:37 +00:00
|
|
|
Copyright 2006-2018 The QElectroTech Team
|
2014-02-12 17:36:35 +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/>.
|
|
|
|
*/
|
|
|
|
#include "elementinfopartwidget.h"
|
2018-07-19 14:14:31 +00:00
|
|
|
|
|
|
|
#include <utility>
|
2014-02-12 17:36:35 +00:00
|
|
|
#include "ui_elementinfopartwidget.h"
|
2018-11-09 18:50:37 +00:00
|
|
|
#include "searchandreplaceworker.h"
|
2014-02-12 17:36:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief ElementInfoPartWidget::ElementInfoPartWidget
|
|
|
|
* Constructor
|
|
|
|
* @param key the string key what represent this info part
|
|
|
|
* @param translated_key the string key translated
|
|
|
|
* @param parent parent widget
|
|
|
|
*/
|
2018-07-19 14:14:31 +00:00
|
|
|
ElementInfoPartWidget::ElementInfoPartWidget(QString key, const QString& translated_key, QWidget *parent):
|
2014-02-12 17:36:35 +00:00
|
|
|
QWidget(parent),
|
|
|
|
ui(new Ui::ElementInfoPartWidget),
|
2018-07-19 14:14:31 +00:00
|
|
|
key_(std::move(key))
|
2014-02-12 17:36:35 +00:00
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
ui->label_->setText(translated_key);
|
2018-11-09 18:50:37 +00:00
|
|
|
ui->m_erase_text->setVisible(false);
|
2015-05-31 15:02:41 +00:00
|
|
|
|
2015-06-05 08:54:14 +00:00
|
|
|
connect(ui->line_edit, &QLineEdit::textEdited, this, &ElementInfoPartWidget::textEdited);
|
2015-05-31 15:02:41 +00:00
|
|
|
connect(ui->line_edit, &QLineEdit::textChanged, this, &ElementInfoPartWidget::textChanged);
|
2014-02-12 17:36:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief ElementInfoPartWidget::~ElementInfoPartWidget
|
|
|
|
* destructor
|
|
|
|
*/
|
|
|
|
ElementInfoPartWidget::~ElementInfoPartWidget()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief ElementInfoPartWidget::setText
|
|
|
|
* Set text to line edit
|
|
|
|
* @param txt
|
|
|
|
*/
|
2018-11-09 18:50:37 +00:00
|
|
|
void ElementInfoPartWidget::setText(const QString &txt)
|
|
|
|
{
|
|
|
|
if (txt == SearchAndReplaceWorker::eraseText()) {
|
|
|
|
ui->m_erase_text->setChecked(true);
|
|
|
|
} else {
|
|
|
|
ui->line_edit->setText(txt);
|
|
|
|
}
|
2014-02-12 17:36:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief ElementInfoPartWidget::text
|
|
|
|
* @return the text in the line edit
|
|
|
|
*/
|
|
|
|
QString ElementInfoPartWidget::text() const {
|
|
|
|
return (ui->line_edit->text());
|
|
|
|
}
|
|
|
|
|
2015-03-05 10:26:09 +00:00
|
|
|
/**
|
|
|
|
* @brief ElementInfoPartWidget::setFocusTolineEdit
|
|
|
|
* Set the focus to the line edit
|
|
|
|
*/
|
|
|
|
void ElementInfoPartWidget::setFocusTolineEdit() {
|
|
|
|
ui->line_edit->setFocus();
|
|
|
|
}
|
2016-11-24 16:45:55 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief ElementInfoPartWidget::setEnabled
|
|
|
|
* enable the line edit
|
|
|
|
* @param e
|
|
|
|
*/
|
2018-11-09 18:50:37 +00:00
|
|
|
void ElementInfoPartWidget::setEnabled(bool e) {
|
2016-11-24 16:45:55 +00:00
|
|
|
ui->line_edit->setEnabled(e);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief ElementInfoPartWidget::setDisabled
|
|
|
|
* disable the line edit
|
|
|
|
* @param d
|
|
|
|
*/
|
2018-11-09 18:50:37 +00:00
|
|
|
void ElementInfoPartWidget::setDisabled(bool d) {
|
2016-11-24 16:45:55 +00:00
|
|
|
ui->line_edit->setDisabled(d);
|
|
|
|
}
|
2018-11-09 18:50:37 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief ElementInfoPartWidget::setEraseTextVisible
|
|
|
|
* @param visible
|
|
|
|
*/
|
|
|
|
void ElementInfoPartWidget::setEraseTextVisible(bool visible) {
|
|
|
|
ui->m_erase_text->setVisible(visible);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief ElementInfoPartWidget::setEraseTextChecked
|
|
|
|
* @param check
|
|
|
|
*/
|
|
|
|
void ElementInfoPartWidget::setEraseTextChecked(bool check) {
|
|
|
|
ui->m_erase_text->setChecked(check);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief ElementInfoPartWidget::EraseTextCheckState
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
Qt::CheckState ElementInfoPartWidget::EraseTextCheckState() const {
|
|
|
|
return ui->m_erase_text->checkState();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ElementInfoPartWidget::on_m_erase_text_clicked()
|
|
|
|
{
|
|
|
|
ui->line_edit->setText(ui->m_erase_text->isChecked() ? SearchAndReplaceWorker::eraseText() : QString());
|
|
|
|
ui->line_edit->setDisabled(ui->m_erase_text->isChecked());
|
|
|
|
}
|