Element text pattern dialog : add a check box 'erase existing texts'

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@5541 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
blacksun
2018-09-30 17:19:50 +00:00
parent aaab9b0f15
commit 63fd76231a
5 changed files with 240 additions and 16 deletions

View File

@@ -0,0 +1,74 @@
/*
Copyright 2006-2018 The QElectroTech Team
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 "importelementtextpatterndialog.h"
#include "ui_importelementtextpatterndialog.h"
ImportElementTextPatternDialog::ImportElementTextPatternDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::ImportElementTextPatternDialog) {
ui->setupUi(this);
}
ImportElementTextPatternDialog::~ImportElementTextPatternDialog()
{
delete ui;
}
/**
* @brief ImportElementTextPatternDialog::getItem
* For all arguments see QInputDialog::getItem, except for erase, they store the state of the check box.
* @param parent
* @param title
* @param label
* @param items
* @param ok
* @param erase
* @return
*/
QString ImportElementTextPatternDialog::getItem(QWidget *parent, const QString &title, const QString &label, const QStringList &items, bool *ok, bool *erase)
{
QString text(items.value(0));
QScopedPointer<ImportElementTextPatternDialog> dialog(new ImportElementTextPatternDialog(parent));
dialog->setWindowTitle(title);
dialog->setLabelText(label);
dialog->setComboBoxItems(items);
dialog->setInputMethodHints(Qt::ImhNone);
const int ret = dialog->exec();
if (ok)
*ok = !!ret;
if(erase)
*erase = dialog->ui->m_erase_existing_text->isChecked();
if (ret) {
return dialog->textValue();
} else {
return text;
}
}
void ImportElementTextPatternDialog::setLabelText(const QString &label) {
ui->m_label->setText(label);
}
void ImportElementTextPatternDialog::setComboBoxItems(const QStringList &items) {
ui->m_combo_box->addItems(items);
}
QString ImportElementTextPatternDialog::textValue() const {
return ui->m_combo_box->currentText();
}

View File

@@ -0,0 +1,52 @@
/*
Copyright 2006-2018 The QElectroTech Team
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 IMPORTELEMENTTEXTPATTERNDIALOG_H
#define IMPORTELEMENTTEXTPATTERNDIALOG_H
#include <QDialog>
namespace Ui {
class ImportElementTextPatternDialog;
}
/**
* @brief The ImportElementTextPatternDialog class
* A dialog use for ask user to select a element text pattern.
* This dialog is highly inspired from QInputDialog::getItem.
* In fact this the same + a check box.
*/
class ImportElementTextPatternDialog : public QDialog
{
Q_OBJECT
public:
explicit ImportElementTextPatternDialog (QWidget *parent = nullptr);
~ImportElementTextPatternDialog();
static QString getItem (QWidget *parent, const QString &title, const QString &label,
const QStringList &items, bool *ok = nullptr, bool *erase = nullptr);
void setLabelText (const QString &label);
void setComboBoxItems (const QStringList &items);
QString textValue() const;
private:
Ui::ImportElementTextPatternDialog *ui;
};
#endif // IMPORTELEMENTTEXTPATTERNDIALOG_H

View File

@@ -0,0 +1,81 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ImportElementTextPatternDialog</class>
<widget class="QDialog" name="ImportElementTextPatternDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>187</width>
<height>116</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="m_label">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="m_combo_box"/>
</item>
<item>
<widget class="QCheckBox" name="m_erase_existing_text">
<property name="text">
<string>Écraser les textes existants</string>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>ImportElementTextPatternDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>ImportElementTextPatternDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>