QElectroTech  0.70
replaceadvanceddialog.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 */
18 #include "replaceadvanceddialog.h"
19 #include "ui_replaceadvanceddialog.h"
20 #include "qetapp.h"
21 
22 #include <QAbstractButton>
23 
30  QDialog(parent),
31  ui(new Ui::replaceAdvancedDialog)
32 {
33  ui->setupUi(this);
34 
35  connect(ui->m_button_box, &QDialogButtonBox::clicked, [this](QAbstractButton *button_) {
36  this->done(ui->m_button_box->buttonRole(button_));
37  });
38 
39  fillWhatComboBox(ui->m_who_cb->currentIndex());
40  ui->m_search_le->setFocus();
41  setAdvancedStruct(advanced);
42 }
43 
45 {
46  delete ui;
47 }
48 
55 {
56  int index = advanced.who;
57  if (index == -1) {
58  return;
59  }
60  ui->m_who_cb->setCurrentIndex(index);
61 
62  for (int i=0 ; i < ui->m_what_cb->count() ; i++)
63  {
64  if (ui->m_what_cb->itemData(i).toString() == advanced.what)
65  {
66  ui->m_what_cb->setCurrentIndex(i);
67  continue;
68  }
69  }
70 
71  ui->m_search_le->setText(advanced.search);
72  ui->m_replace_le->setText(advanced.replace);
73 }
74 
80 {
82  a.who = ui->m_who_cb->currentIndex();
83  a.what = ui->m_what_cb->currentData().toString();
84  a.search = ui->m_search_le->text();
85  a.replace = ui->m_replace_le->text();
86 
87  return a;
88 }
89 
91 {
92  ui->m_what_cb->clear();
93 
94  if (index == 0)
95  {
96  for (QString str : QETApp::diagramInfoKeys()) {
97  ui->m_what_cb->addItem(QETApp::diagramTranslatedInfoKey(str), str);
98  }
99  }
100  else if (index == 1) {
101  for (QString str : QETApp::elementInfoKeys()) {
102  ui->m_what_cb->addItem(QETApp::elementTranslatedInfoKey(str), str);
103  }
104  }
105  else if (index == 2) {
106  for (QString str : QETApp::conductorInfoKeys()) {
107  ui->m_what_cb->addItem(QETApp::conductorTranslatedInfoKey(str), str);
108  }
109  }
110 }
111 
117  fillWhatComboBox(index);
118 }
replaceAdvancedDialog(advancedReplaceStruct advanced, QWidget *parent=nullptr)
replaceAdvancedDialog::replaceAdvancedDialog
void setAdvancedStruct(advancedReplaceStruct advanced)
replaceAdvancedDialog::setAdvancedStruct Set the edited advanced struct
Ui::replaceAdvancedDialog * ui
static QStringList conductorInfoKeys()
QETApp::conductorInfoKeys.
Definition: qetapp.cpp:382
static QString diagramTranslatedInfoKey(const QString &key)
QETApp::diagramTranslatedInfoKey.
Definition: qetapp.cpp:432
void on_m_who_cb_currentIndexChanged(int index)
replaceAdvancedDialog::on_m_who_cb_currentIndexChanged
static QStringList elementInfoKeys()
QETApp::elementInfoKeys.
Definition: qetapp.cpp:289
static QString conductorTranslatedInfoKey(const QString &key)
QETApp::conductorTranslatedInfoKey.
Definition: qetapp.cpp:399
advancedReplaceStruct advancedStruct() const
replaceAdvancedDialog::advancedStruct
static QString elementTranslatedInfoKey(const QString &)
ElementsProperties::translatedInfo Return the translated information key given by If don&#39;t match...
Definition: qetapp.cpp:321
static QStringList diagramInfoKeys()
QETApp::diagramInfoKeys.
Definition: qetapp.cpp:412