QElectroTech  0.70
importelementtextpatterndialog.cpp
Go to the documentation of this file.
1 /*
2  Copyright 2006-2019 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 */
19 #include "ui_importelementtextpatterndialog.h"
20 
22  QDialog(parent),
24  ui->setupUi(this);
25 }
26 
28 {
29  delete ui;
30 }
31 
43 QString ImportElementTextPatternDialog::getItem(QWidget *parent, const QString &title, const QString &label, const QStringList &items, bool *ok, bool *erase)
44 {
45  QString text(items.value(0));
46 
47  QScopedPointer<ImportElementTextPatternDialog> dialog(new ImportElementTextPatternDialog(parent));
48  dialog->setWindowTitle(title);
49  dialog->setLabelText(label);
50  dialog->setComboBoxItems(items);
51  dialog->setInputMethodHints(Qt::ImhNone);
52  const int ret = dialog->exec();
53  if (ok)
54  *ok = !!ret;
55  if(erase)
56  *erase = dialog->ui->m_erase_existing_text->isChecked();
57  if (ret) {
58  return dialog->textValue();
59  } else {
60  return text;
61  }
62 }
63 
65  ui->m_label->setText(label);
66 }
67 
68 void ImportElementTextPatternDialog::setComboBoxItems(const QStringList &items) {
69  ui->m_combo_box->addItems(items);
70 }
71 
73  return ui->m_combo_box->currentText();
74 }
The ImportElementTextPatternDialog class A dialog use for ask user to select a element text pattern...
void setComboBoxItems(const QStringList &items)
static QString getItem(QWidget *parent, const QString &title, const QString &label, const QStringList &items, bool *ok=nullptr, bool *erase=nullptr)
ImportElementTextPatternDialog::getItem For all arguments see QInputDialog::getItem, except for erase, they store the state of the check box.
ImportElementTextPatternDialog(QWidget *parent=nullptr)
Ui::ImportElementTextPatternDialog * ui