mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-02-24 22:09:58 +01:00
conductor autonum. Diagram save current selected autonum.
Readd dialog to select texts, when potential have different texts git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3251 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
104
sources/ui/potentialtextsdialog.cpp
Normal file
104
sources/ui/potentialtextsdialog.cpp
Normal file
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
Copyright 2006-2014 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 "conductor.h"
|
||||
#include "potentialtextsdialog.h"
|
||||
#include "ui_potentialtextsdialog.h"
|
||||
#include <QSignalMapper>
|
||||
|
||||
/**
|
||||
* @brief PotentialTextsDialog::PotentialTextsDialog
|
||||
* Constructor
|
||||
* @param conductor : A Conductor of the potential to check
|
||||
* @param parent : parent widget
|
||||
*/
|
||||
PotentialTextsDialog::PotentialTextsDialog(Conductor *conductor, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::PotentialTextsDialog),
|
||||
m_conductor (conductor)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
conductorsTextToMap();
|
||||
buildRadioList();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief PotentialTextsDialog::~PotentialTextsDialog
|
||||
* Destructor
|
||||
*/
|
||||
PotentialTextsDialog::~PotentialTextsDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief PotentialTextsDialog::selectedText
|
||||
* @return the selected text
|
||||
*/
|
||||
QString PotentialTextsDialog::selectedText() const {
|
||||
return m_selected_text;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief PotentialTextsDialog::buildRadioList
|
||||
* Build the radio list of this dialog, for selected a text
|
||||
*/
|
||||
void PotentialTextsDialog::buildRadioList() {
|
||||
//map the signal for each radio button create in buildRadioList
|
||||
m_signal_mapper = new QSignalMapper(this);
|
||||
connect(m_signal_mapper, SIGNAL(mapped(QString)), this, SLOT(setSelectedText(QString)));
|
||||
|
||||
//create a new radio button for each text of @conductorList
|
||||
for (QMultiMap<int, QString>::ConstIterator it = m_texts.constEnd()-1; it != m_texts.constBegin()-1; --it) {
|
||||
QRadioButton *rb= new QRadioButton(it.value() + tr(" : est pr\351sent ") + QString::number(it.key()) + tr(" fois."), this);
|
||||
if (it == m_texts.constEnd()-1) {
|
||||
rb -> setChecked(true);
|
||||
m_selected_text = it.value();
|
||||
}
|
||||
//connect the button to mapper @m_signal_mapper
|
||||
connect(rb, SIGNAL(clicked()), m_signal_mapper, SLOT(map()));
|
||||
m_signal_mapper -> setMapping(rb, it.value());
|
||||
ui -> m_buttons_layout -> addWidget(rb);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief PotentialTextsDialog::conductorsTextToMap
|
||||
* Fill the multimap @m_text with all different text found in the same potentil of @m_conductor
|
||||
* The key "int" of multimap is the number of conductors with the same text.
|
||||
* The value "QString" of multimap is the text.
|
||||
*/
|
||||
void PotentialTextsDialog::conductorsTextToMap() {
|
||||
QStringList textList;
|
||||
textList << m_conductor -> text();
|
||||
foreach(Conductor *c, m_conductor->relatedPotentialConductors()) textList << c -> text();
|
||||
|
||||
while (!textList.size() == 0) {
|
||||
QString t = textList.at(0);
|
||||
int n = textList.count(t);
|
||||
textList.removeAll(t);
|
||||
m_texts.insert(n, t);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief PotentialTextsDialog::setSelectedText
|
||||
* @param text
|
||||
*/
|
||||
void PotentialTextsDialog::setSelectedText(QString text) {
|
||||
m_selected_text = text;
|
||||
}
|
||||
61
sources/ui/potentialtextsdialog.h
Normal file
61
sources/ui/potentialtextsdialog.h
Normal file
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
Copyright 2006-2014 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 POTENTIALTEXTSDIALOG_H
|
||||
#define POTENTIALTEXTSDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QMultiMap>
|
||||
class Conductor;
|
||||
class QSignalMapper;
|
||||
|
||||
namespace Ui {
|
||||
class PotentialTextsDialog;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief The PotentialTextsDialog class
|
||||
* This dialog show all differents conductors texts at the same
|
||||
* potential of @conductor.
|
||||
* The user can select a text in the list.
|
||||
*/
|
||||
class PotentialTextsDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PotentialTextsDialog(Conductor *conductor, QWidget *parent = 0);
|
||||
~PotentialTextsDialog();
|
||||
|
||||
QString selectedText () const;
|
||||
|
||||
private:
|
||||
void buildRadioList();
|
||||
void conductorsTextToMap();
|
||||
|
||||
private slots:
|
||||
void setSelectedText (QString text);
|
||||
|
||||
private:
|
||||
Ui::PotentialTextsDialog *ui;
|
||||
Conductor *m_conductor;
|
||||
QSignalMapper *m_signal_mapper;
|
||||
QString m_selected_text;
|
||||
QMultiMap <int, QString> m_texts;
|
||||
};
|
||||
|
||||
#endif // POTENTIALTEXTSDIALOG_H
|
||||
92
sources/ui/potentialtextsdialog.ui
Normal file
92
sources/ui/potentialtextsdialog.ui
Normal file
@@ -0,0 +1,92 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>PotentialTextsDialog</class>
|
||||
<widget class="QDialog" name="PotentialTextsDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>94</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Textes de potentiel</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Les textes de ce potentiel électrique ne sont pas identiques.
|
||||
Appliquer un texte à l'ensemble de ces conducteurs?</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="m_buttons_layout"/>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</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>PotentialTextsDialog</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>PotentialTextsDialog</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>
|
||||
Reference in New Issue
Block a user