mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-02-14 05:19:58 +01:00
element editor: add dialog for edit element properties (master, slave etc...)
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3102 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
104
sources/editor/ui/elementpropertieseditorwidget.cpp
Normal file
104
sources/editor/ui/elementpropertieseditorwidget.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 "elementpropertieseditorwidget.h"
|
||||
#include "ui_elementpropertieseditorwidget.h"
|
||||
|
||||
/**
|
||||
* @brief ElementPropertiesEditorWidget::ElementPropertiesEditorWidget
|
||||
* Default constructor
|
||||
* @param basic_type : QString of the drawed element
|
||||
* @param dc : DiagramContext to store kindInfo of drawed element
|
||||
* @param parent : parent widget
|
||||
*/
|
||||
ElementPropertiesEditorWidget::ElementPropertiesEditorWidget(QString &basic_type, DiagramContext &dc, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::ElementPropertiesEditorWidget),
|
||||
m_basic_type(basic_type),
|
||||
m_dc (dc)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
setUpInterface();
|
||||
upDateInterface();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ElementPropertiesEditorWidget::~ElementPropertiesEditorWidget
|
||||
* Default destructor
|
||||
*/
|
||||
ElementPropertiesEditorWidget::~ElementPropertiesEditorWidget()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void ElementPropertiesEditorWidget::upDateInterface() {
|
||||
ui -> m_base_type_cb -> setCurrentIndex (ui -> m_base_type_cb -> findData (QVariant(m_basic_type)));
|
||||
ui -> m_state_cb -> setCurrentIndex (ui -> m_state_cb -> findData (m_dc["state"].toString()));
|
||||
ui -> m_type_cb -> setCurrentIndex (ui -> m_type_cb -> findData (m_dc["type"].toString()));
|
||||
ui -> m_number_ctc -> setValue (m_dc["number"].toInt());
|
||||
|
||||
on_m_base_type_cb_currentIndexChanged(ui->m_base_type_cb->currentIndex());
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ElementPropertiesEditorWidget::setUpInterface
|
||||
*/
|
||||
void ElementPropertiesEditorWidget::setUpInterface() {
|
||||
// Type combo box
|
||||
ui -> m_base_type_cb -> addItem (tr("Simple"), QVariant("simple"));
|
||||
ui -> m_base_type_cb -> addItem (tr("Ma\356tre"), QVariant("master"));
|
||||
ui -> m_base_type_cb -> addItem (tr("Esclave"), QVariant("slave"));
|
||||
ui -> m_base_type_cb -> addItem (tr("Renvoi de folio suivant"), QVariant("next_report"));
|
||||
ui -> m_base_type_cb -> addItem (tr("Renvoi de folio pr\351c\351dent"), QVariant("previous_report"));
|
||||
|
||||
// Slave option
|
||||
ui -> m_state_cb -> addItem(tr("Normalement ouvert"), QVariant("NO"));
|
||||
ui -> m_state_cb -> addItem(tr("Normalement ferm\351"), QVariant("NC"));
|
||||
ui -> m_type_cb -> addItem(tr("Simple"), QVariant("simple"));
|
||||
ui -> m_type_cb -> addItem(tr("Puissance"), QVariant("power"));
|
||||
ui -> m_type_cb -> addItem(tr("Temporis\351 travail"), QVariant("delayOn"));
|
||||
ui -> m_type_cb -> addItem(tr("Temporis\351 repos"), QVariant("delayOff"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ElementPropertiesEditorWidget::on_m_buttonBox_accepted
|
||||
* Action on button accepted : the new information is set
|
||||
*/
|
||||
void ElementPropertiesEditorWidget::on_m_buttonBox_accepted()
|
||||
{
|
||||
m_basic_type = ui -> m_base_type_cb -> itemData(ui -> m_base_type_cb -> currentIndex()).toString();
|
||||
if (m_basic_type == "slave") {
|
||||
m_dc.addValue("state", ui -> m_state_cb -> itemData(ui -> m_state_cb -> currentIndex()));
|
||||
m_dc.addValue("type", ui -> m_type_cb -> itemData(ui -> m_type_cb -> currentIndex()));
|
||||
m_dc.addValue("number", QVariant(ui -> m_number_ctc -> value()));
|
||||
}
|
||||
this->close();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ElementPropertiesEditorWidget::on_m_base_type_cb_currentIndexChanged
|
||||
* @param index : Action when combo-box base type index change
|
||||
*/
|
||||
void ElementPropertiesEditorWidget::on_m_base_type_cb_currentIndexChanged(int index)
|
||||
{
|
||||
if (ui->m_base_type_cb->itemData(index).toString() == "slave") {
|
||||
ui->m_slave_gb->setEnabled(true);
|
||||
} else {
|
||||
ui->m_slave_gb->setEnabled(false);
|
||||
}
|
||||
|
||||
}
|
||||
60
sources/editor/ui/elementpropertieseditorwidget.h
Normal file
60
sources/editor/ui/elementpropertieseditorwidget.h
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
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 ELEMENTPROPERTIESEDITORWIDGET_H
|
||||
#define ELEMENTPROPERTIESEDITORWIDGET_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QAbstractButton>
|
||||
#include "diagramcontext.h"
|
||||
|
||||
namespace Ui {
|
||||
class ElementPropertiesEditorWidget;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief The ElementPropertiesEditorWidget class
|
||||
* This class provide a dialog for edit various property of element, like
|
||||
* the type (master, slave, report etc....) and kind info.
|
||||
*/
|
||||
class ElementPropertiesEditorWidget : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
//METHODS
|
||||
public:
|
||||
explicit ElementPropertiesEditorWidget(QString &basic_type, DiagramContext &dc, QWidget *parent = 0);
|
||||
~ElementPropertiesEditorWidget();
|
||||
|
||||
void upDateInterface();
|
||||
|
||||
private:
|
||||
void setUpInterface();
|
||||
|
||||
//SLOTS
|
||||
private slots:
|
||||
void on_m_buttonBox_accepted();
|
||||
void on_m_base_type_cb_currentIndexChanged(int index);
|
||||
|
||||
//ATTRIBUTES
|
||||
private:
|
||||
Ui::ElementPropertiesEditorWidget *ui;
|
||||
QString &m_basic_type;
|
||||
DiagramContext &m_dc;
|
||||
};
|
||||
|
||||
#endif // ELEMENTPROPERTIESEDITORWIDGET_H
|
||||
141
sources/editor/ui/elementpropertieseditorwidget.ui
Normal file
141
sources/editor/ui/elementpropertieseditorwidget.ui
Normal file
@@ -0,0 +1,141 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ElementPropertiesEditorWidget</class>
|
||||
<widget class="QDialog" name="ElementPropertiesEditorWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Propriété de l'élément</string>
|
||||
</property>
|
||||
<property name="sizeGripEnabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Type de base :</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="m_base_type_cb"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="m_slave_gb">
|
||||
<property name="title">
|
||||
<string>Élément esclave</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="3" column="1">
|
||||
<widget class="QSpinBox" name="m_number_ctc">
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Nombre de contact représenté</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Type de contact</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>État du contact</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="m_state_cb"/>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="m_type_cb"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</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="m_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>m_buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>ElementPropertiesEditorWidget</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>m_buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>ElementPropertiesEditorWidget</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