mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-06-02 13:43:13 +02:00
Compare commits
42 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 34eb6e9f71 | |||
| faf4235bed | |||
| 0a51e22b7d | |||
| 632fba5366 | |||
| 0ca883f114 | |||
| 170d856007 | |||
| 0424eb9fba | |||
| 8210f06919 | |||
| 468618adda | |||
| 8141a75738 | |||
| 8f201a6e5d | |||
| b8745c0a6b | |||
| 7c3bde9118 | |||
| 28cd389695 | |||
| 56bb2a399b | |||
| dc726792d3 | |||
| d8707a4ef2 | |||
| 77710e1cc5 | |||
| 1d2c00819d | |||
| eee0469bd7 | |||
| 5118037cb5 | |||
| 1f53c39290 | |||
| b71aec9548 | |||
| c7798e1a80 | |||
| f97edad75a | |||
| 454b2c8a0f | |||
| b2782bc460 | |||
| 059f0eb1b6 | |||
| ce318ac667 | |||
| be2067148e | |||
| 444f62a1f8 | |||
| 8f85cacb06 | |||
| ffe3d98279 | |||
| dea926e4b4 | |||
| a1779d1a7a | |||
| 252106178b | |||
| a00404bc9f | |||
| e2ebb445a8 | |||
| 24ec94d73e | |||
| edb42caa16 | |||
| c110acc0ac | |||
| 3467c09c1e |
+1
-1
@@ -19,7 +19,7 @@ include(cmake/hoto_update_cmake_message.cmake)
|
||||
cmake_minimum_required(VERSION 3.14...3.19 FATAL_ERROR)
|
||||
|
||||
project(qelectrotech
|
||||
VERSION 0.8.0
|
||||
VERSION 0.9.0
|
||||
DESCRIPTION "QET is a CAD/CAE editor focusing on schematics drawing features."
|
||||
HOMEPAGE_URL "https://qelectrotech.org/"
|
||||
LANGUAGES CXX)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"id": "org.qelectrotech.QElectroTech",
|
||||
"runtime": "org.kde.Platform",
|
||||
"runtime-version": "5.14",
|
||||
"runtime-version": "5.15",
|
||||
"sdk": "org.kde.Sdk",
|
||||
"command": "qelectrotech",
|
||||
"rename-desktop-file": "qelectrotech.desktop",
|
||||
|
||||
@@ -21,6 +21,6 @@ Include(FetchContent)
|
||||
FetchContent_Declare(
|
||||
pugixml
|
||||
GIT_REPOSITORY https://github.com/zeux/pugixml.git
|
||||
GIT_TAG v1.11.1)
|
||||
GIT_TAG v1.11.4)
|
||||
|
||||
FetchContent_MakeAvailable(pugixml)
|
||||
|
||||
@@ -26,6 +26,6 @@ Include(FetchContent)
|
||||
FetchContent_Declare(
|
||||
SingleApplication
|
||||
GIT_REPOSITORY https://github.com/itay-grudev/SingleApplication.git
|
||||
GIT_TAG v3.1.5)
|
||||
GIT_TAG v3.2.0)
|
||||
|
||||
FetchContent_MakeAvailable(SingleApplication)
|
||||
|
||||
@@ -52,6 +52,8 @@ set(QET_RES_FILES
|
||||
${QET_DIR}/sources/editor/ui/lineeditor.ui
|
||||
${QET_DIR}/sources/editor/ui/polygoneditor.ui
|
||||
${QET_DIR}/sources/editor/ui/rectangleeditor.ui
|
||||
${QET_DIR}/sources/editor/ui/qetelementeditor.ui
|
||||
${QET_DIR}/sources/editor/ui/terminaleditor.ui
|
||||
${QET_DIR}/sources/ElementsCollection/ui/renamedialog.ui
|
||||
${QET_DIR}/sources/factory/ui/addtabledialog.ui
|
||||
${QET_DIR}/sources/NameList/ui/namelistdialog.ui
|
||||
@@ -260,12 +262,8 @@ set(QET_SRC_FILES
|
||||
${QET_DIR}/sources/editor/elementscene.h
|
||||
${QET_DIR}/sources/editor/elementview.cpp
|
||||
${QET_DIR}/sources/editor/elementview.h
|
||||
${QET_DIR}/sources/editor/qetelementeditor.cpp
|
||||
${QET_DIR}/sources/editor/qetelementeditor.h
|
||||
${QET_DIR}/sources/editor/styleeditor.cpp
|
||||
${QET_DIR}/sources/editor/styleeditor.h
|
||||
${QET_DIR}/sources/editor/terminaleditor.cpp
|
||||
${QET_DIR}/sources/editor/terminaleditor.h
|
||||
|
||||
${QET_DIR}/sources/editor/esevent/eseventaddarc.cpp
|
||||
${QET_DIR}/sources/editor/esevent/eseventaddarc.h
|
||||
@@ -320,8 +318,12 @@ set(QET_SRC_FILES
|
||||
${QET_DIR}/sources/editor/ui/polygoneditor.h
|
||||
${QET_DIR}/sources/editor/ui/rectangleeditor.cpp
|
||||
${QET_DIR}/sources/editor/ui/rectangleeditor.h
|
||||
${QET_DIR}/sources/editor/ui/terminaleditor.cpp
|
||||
${QET_DIR}/sources/editor/ui/terminaleditor.h
|
||||
${QET_DIR}/sources/editor/ui/texteditor.cpp
|
||||
${QET_DIR}/sources/editor/ui/texteditor.h
|
||||
${QET_DIR}/sources/editor/ui/qetelementeditor.h
|
||||
${QET_DIR}/sources/editor/ui/qetelementeditor.cpp
|
||||
|
||||
${QET_DIR}/sources/editor/UndoCommand/pastepartscommand.cpp
|
||||
${QET_DIR}/sources/editor/UndoCommand/pastepartscommand.h
|
||||
@@ -371,6 +373,8 @@ set(QET_SRC_FILES
|
||||
${QET_DIR}/sources/print/projectprintwindow.cpp
|
||||
${QET_DIR}/sources/print/projectprintwindow.h
|
||||
|
||||
${QET_DIR}/sources/properties/elementdata.cpp
|
||||
${QET_DIR}/sources/properties/elementdata.h
|
||||
${QET_DIR}/sources/properties/propertiesinterface.cpp
|
||||
${QET_DIR}/sources/properties/propertiesinterface.h
|
||||
${QET_DIR}/sources/properties/reportproperties.cpp
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 112 KiB After Width: | Height: | Size: 309 KiB |
+712
-583
File diff suppressed because it is too large
Load Diff
+720
-591
File diff suppressed because it is too large
Load Diff
+712
-583
File diff suppressed because it is too large
Load Diff
+723
-592
File diff suppressed because it is too large
Load Diff
Binary file not shown.
+723
-595
File diff suppressed because it is too large
Load Diff
Binary file not shown.
+1006
-874
File diff suppressed because it is too large
Load Diff
+719
-590
File diff suppressed because it is too large
Load Diff
Binary file not shown.
+721
-590
File diff suppressed because it is too large
Load Diff
+714
-585
File diff suppressed because it is too large
Load Diff
Binary file not shown.
+708
-579
File diff suppressed because it is too large
Load Diff
+711
-582
File diff suppressed because it is too large
Load Diff
Binary file not shown.
+718
-587
File diff suppressed because it is too large
Load Diff
+723
-594
File diff suppressed because it is too large
Load Diff
+712
-583
File diff suppressed because it is too large
Load Diff
+708
-579
File diff suppressed because it is too large
Load Diff
+712
-583
File diff suppressed because it is too large
Load Diff
Binary file not shown.
+722
-591
File diff suppressed because it is too large
Load Diff
+720
-591
File diff suppressed because it is too large
Load Diff
+720
-588
File diff suppressed because it is too large
Load Diff
+714
-585
File diff suppressed because it is too large
Load Diff
+712
-583
File diff suppressed because it is too large
Load Diff
+712
-583
File diff suppressed because it is too large
Load Diff
+708
-579
File diff suppressed because it is too large
Load Diff
+708
-579
File diff suppressed because it is too large
Load Diff
+708
-579
File diff suppressed because it is too large
Load Diff
+712
-583
File diff suppressed because it is too large
Load Diff
+708
-579
File diff suppressed because it is too large
Load Diff
@@ -17,7 +17,7 @@
|
||||
*/
|
||||
#include "elementscollectionwidget.h"
|
||||
|
||||
#include "../editor/qetelementeditor.h"
|
||||
#include "../editor/ui/qetelementeditor.h"
|
||||
#include "../elementscategoryeditor.h"
|
||||
#include "../newelementwizard.h"
|
||||
#include "../qetapp.h"
|
||||
@@ -38,6 +38,9 @@
|
||||
#include <QUrl>
|
||||
#include <QVBoxLayout>
|
||||
#include <QtGlobal>
|
||||
#include <QProgressBar>
|
||||
#include <QStatusBar>
|
||||
#include <QLineEdit>
|
||||
|
||||
/**
|
||||
@brief ElementsCollectionWidget::ElementsCollectionWidget
|
||||
|
||||
@@ -368,14 +368,6 @@ void ConductorProperties::fromXml(QDomElement &e)
|
||||
"vertical-alignment",
|
||||
"AlignRight"
|
||||
).toStdString().data()));
|
||||
|
||||
//Keep retrocompatible with version older than 0,4
|
||||
//If the propertie @type is simple (removed since QET 0,4), we set text no visible.
|
||||
//@TODO remove this code for qet 0.6 or later
|
||||
#if TODO_LIST
|
||||
#pragma message("@TODO remove this code for qet 0.6 or later")
|
||||
#endif
|
||||
if (e.attribute("type") == "simple") m_show_text = false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -222,11 +222,6 @@ void DiagramEventAddElement::addElement()
|
||||
element -> setPos(m_element->pos());
|
||||
element -> setRotation(m_element -> rotation());
|
||||
m_diagram -> addItem(element);
|
||||
|
||||
//The element is dropped by the user, the dynamic text field stored in m_converted_text_from_xml_description
|
||||
//can be moved to m_dynamic_text_list, because we are sure fromXml will be not called.
|
||||
element->m_dynamic_text_list.append(element->m_converted_text_from_xml_description.keys());
|
||||
element->m_converted_text_from_xml_description.clear();
|
||||
|
||||
QUndoCommand *undo_object = new QUndoCommand(tr("Ajouter %1").arg(element->name()));
|
||||
new AddGraphicsObjectCommand(element, m_diagram, m_element -> pos(), undo_object);
|
||||
|
||||
@@ -282,13 +282,17 @@ ChangeNamesCommand::~ChangeNamesCommand()
|
||||
/// Annule le changement
|
||||
void ChangeNamesCommand::undo()
|
||||
{
|
||||
m_scene -> setNames(names_before);
|
||||
auto data = m_scene->elementData();
|
||||
data.m_names_list = names_before;
|
||||
m_scene->setElementData(data);
|
||||
}
|
||||
|
||||
/// Refait le changement
|
||||
void ChangeNamesCommand::redo()
|
||||
{
|
||||
m_scene -> setNames(names_after);
|
||||
auto data = m_scene->elementData();
|
||||
data.m_names_list = names_after;
|
||||
m_scene->setElementData(data);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -453,13 +457,17 @@ ChangeInformationsCommand::~ChangeInformationsCommand()
|
||||
/// Annule le changement d'autorisation pour les connexions internes
|
||||
void ChangeInformationsCommand::undo()
|
||||
{
|
||||
m_scene -> setInformations(old_informations_);
|
||||
auto data = m_scene->elementData();
|
||||
data.m_drawing_information = old_informations_;
|
||||
m_scene->setElementData(data);
|
||||
}
|
||||
|
||||
/// Refait le changement d'autorisation pour les connexions internes
|
||||
void ChangeInformationsCommand::redo()
|
||||
{
|
||||
m_scene -> setInformations(new_informations_);
|
||||
auto data = m_scene->elementData();
|
||||
data.m_drawing_information = new_informations_;
|
||||
m_scene->setElementData(data);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -572,45 +580,32 @@ void ScalePartsCommand::adjustText()
|
||||
setText(QObject::tr("redimensionnement de %1 primitives", "undo caption -- %1 always > 1").arg(scaled_primitives_.count()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@brief ChangePropertiesCommand::ChangePropertiesCommand
|
||||
Change the properties of the drawed element
|
||||
@param scene : scene to belong the property
|
||||
@param type : new type of element.
|
||||
@param info
|
||||
@param elmt_info : new info about type.
|
||||
@param parent : parent undo
|
||||
*/
|
||||
ChangePropertiesCommand::ChangePropertiesCommand(
|
||||
ElementScene *scene,
|
||||
const QString& type,
|
||||
const DiagramContext& info,
|
||||
const DiagramContext& elmt_info,
|
||||
QUndoCommand *parent) :
|
||||
ElementEditionCommand(scene, nullptr, parent)
|
||||
* @brief changeElementDataCommand::changeElementDataCommand
|
||||
* Change the properties of the drawed element
|
||||
* @param scene : scene to belong the property
|
||||
* @param old_data : old data
|
||||
* @param new_data : new data
|
||||
* @param parent : parent undo command
|
||||
*/
|
||||
changeElementDataCommand::changeElementDataCommand(ElementScene *scene,
|
||||
ElementData old_data,
|
||||
ElementData new_data,
|
||||
QUndoCommand *parent) :
|
||||
ElementEditionCommand(scene, nullptr, parent),
|
||||
m_old(old_data),
|
||||
m_new(new_data)
|
||||
{
|
||||
m_type << scene->m_elmt_type << type;
|
||||
m_kind_info << scene->m_elmt_kindInfo << info;
|
||||
m_elmt_info << scene->m_elmt_information << elmt_info;
|
||||
setText(QObject::tr("Modifier les propriétés"));
|
||||
setText(QObject::tr("Modifier les propriétées de l'élément"));
|
||||
}
|
||||
|
||||
ChangePropertiesCommand::~ChangePropertiesCommand()
|
||||
{}
|
||||
|
||||
void ChangePropertiesCommand::undo()
|
||||
{
|
||||
m_scene->m_elmt_type = m_type.first();
|
||||
m_scene->m_elmt_kindInfo = m_kind_info.first();
|
||||
m_scene->setElementInfo(m_elmt_info.first());
|
||||
void changeElementDataCommand::undo() {
|
||||
m_scene->setElementData(m_old);
|
||||
QUndoCommand::undo();
|
||||
}
|
||||
|
||||
void ChangePropertiesCommand::redo()
|
||||
{
|
||||
m_scene->m_elmt_type = m_type.last();
|
||||
m_scene->m_elmt_kindInfo = m_kind_info.last();
|
||||
m_scene->setElementInfo(m_elmt_info.last());
|
||||
void changeElementDataCommand::redo() {
|
||||
m_scene->setElementData(m_new);
|
||||
QUndoCommand::redo();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -262,23 +262,21 @@ class ScalePartsCommand : public ElementEditionCommand {
|
||||
bool first_redo;
|
||||
};
|
||||
|
||||
class ChangePropertiesCommand : public ElementEditionCommand {
|
||||
class changeElementDataCommand : public ElementEditionCommand
|
||||
{
|
||||
public:
|
||||
ChangePropertiesCommand (
|
||||
ElementScene *scene,
|
||||
const QString& type,
|
||||
const DiagramContext& info,
|
||||
const DiagramContext& elmt_info,
|
||||
QUndoCommand *parent=nullptr);
|
||||
~ChangePropertiesCommand () override;
|
||||
changeElementDataCommand(ElementScene *scene,
|
||||
ElementData old_data,
|
||||
ElementData new_data,
|
||||
QUndoCommand *parent = nullptr);
|
||||
~changeElementDataCommand() override {}
|
||||
|
||||
void undo() override;
|
||||
void redo() override;
|
||||
void undo() override;
|
||||
void redo() override;
|
||||
|
||||
private:
|
||||
QList <QString> m_type;
|
||||
QList <DiagramContext> m_kind_info;
|
||||
QList < DiagramContext> m_elmt_info;
|
||||
ElementData m_old,
|
||||
m_new;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "elementitemeditor.h"
|
||||
#include "qetelementeditor.h"
|
||||
#include "ui/qetelementeditor.h"
|
||||
#include "editorcommands.h"
|
||||
|
||||
/**
|
||||
|
||||
+55
-105
@@ -33,7 +33,7 @@
|
||||
#include "graphicspart/partrectangle.h"
|
||||
#include "graphicspart/partterminal.h"
|
||||
#include "graphicspart/parttext.h"
|
||||
#include "qetelementeditor.h"
|
||||
#include "ui/qetelementeditor.h"
|
||||
#include "ui/elementpropertieseditorwidget.h"
|
||||
|
||||
#include <QKeyEvent>
|
||||
@@ -51,7 +51,6 @@
|
||||
*/
|
||||
ElementScene::ElementScene(QETElementEditor *editor, QObject *parent) :
|
||||
QGraphicsScene(parent),
|
||||
m_elmt_type("simple"),
|
||||
m_qgi_manager(this),
|
||||
m_element_editor(editor)
|
||||
{
|
||||
@@ -71,7 +70,25 @@ ElementScene::ElementScene(QETElementEditor *editor, QObject *parent) :
|
||||
connect(&m_undo_stack, SIGNAL(indexChanged(int)),
|
||||
this, SLOT(managePrimitivesGroups()));
|
||||
connect(this, SIGNAL(selectionChanged()),
|
||||
this, SLOT(managePrimitivesGroups()));
|
||||
this, SLOT(managePrimitivesGroups()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ElementScene::elementData
|
||||
* @return the elementdata using by the scene
|
||||
*/
|
||||
ElementData ElementScene::elementData() {
|
||||
return m_element_data;
|
||||
}
|
||||
|
||||
void ElementScene::setElementData(ElementData data)
|
||||
{
|
||||
bool emit_ = m_element_data.m_informations != data.m_informations;
|
||||
|
||||
m_element_data = data;
|
||||
|
||||
if (emit_)
|
||||
emit elementInfoChanged();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -437,7 +454,7 @@ const QDomDocument ElementScene::toXml(bool all_parts)
|
||||
-(qRound(size.y() - (ymargin/2)))));
|
||||
|
||||
root.setAttribute("version", QET::version);
|
||||
root.setAttribute("link_type", m_elmt_type);
|
||||
root.setAttribute("link_type", m_element_data.typeToString(m_element_data.m_type));
|
||||
|
||||
//Uuid used to compare two elements
|
||||
QDomElement uuid = xml_document.createElement("uuid");
|
||||
@@ -445,29 +462,29 @@ const QDomDocument ElementScene::toXml(bool all_parts)
|
||||
root.appendChild(uuid);
|
||||
|
||||
//names of element
|
||||
root.appendChild(m_names_list.toXml(xml_document));
|
||||
root.appendChild(m_element_data.m_names_list.toXml(xml_document));
|
||||
|
||||
if (m_elmt_type == "slave" || m_elmt_type == "master")
|
||||
auto type_ = m_element_data.m_type;
|
||||
if (type_ == ElementData::Slave ||
|
||||
type_ == ElementData::Master ||
|
||||
type_ == ElementData::Terminale)
|
||||
{
|
||||
QDomElement kindInfo = xml_document.createElement("kindInformations");
|
||||
m_elmt_kindInfo.toXml(kindInfo, "kindInformation");
|
||||
root.appendChild(kindInfo);
|
||||
root.appendChild(m_element_data.kindInfoToXml(xml_document));
|
||||
}
|
||||
|
||||
if(
|
||||
m_elmt_type == "simple"
|
||||
|| m_elmt_type == "master"
|
||||
|| m_elmt_type == "terminal")
|
||||
if(type_ == ElementData::Simple ||
|
||||
type_ == ElementData::Master ||
|
||||
type_ == ElementData::Terminale)
|
||||
{
|
||||
QDomElement element_info = xml_document.createElement("elementInformations");
|
||||
m_elmt_information.toXml(element_info, "elementInformation");
|
||||
m_element_data.m_informations.toXml(element_info, "elementInformation");
|
||||
root.appendChild(element_info);
|
||||
}
|
||||
|
||||
//complementary information about the element
|
||||
QDomElement informations_element = xml_document.createElement("informations");
|
||||
root.appendChild(informations_element);
|
||||
informations_element.appendChild(xml_document.createTextNode(informations()));
|
||||
informations_element.appendChild(xml_document.createTextNode(m_element_data.m_drawing_information));
|
||||
|
||||
QDomElement description = xml_document.createElement("description");
|
||||
|
||||
@@ -545,9 +562,16 @@ void ElementScene::fromXml(
|
||||
{
|
||||
bool state = true;
|
||||
|
||||
//Consider the informations of the element
|
||||
if (consider_informations) {
|
||||
state = applyInformations(xml_document);
|
||||
//Consider the informations of the element
|
||||
if (consider_informations)
|
||||
{
|
||||
// Root must be an element definition
|
||||
QDomElement root = xml_document.documentElement();
|
||||
|
||||
if (root.tagName() == "definition" &&
|
||||
root.attribute("type") == "element") {
|
||||
m_element_data.fromXml(root);
|
||||
}
|
||||
}
|
||||
|
||||
if (state)
|
||||
@@ -699,19 +723,6 @@ QETElementEditor* ElementScene::editor() const
|
||||
return m_element_editor;
|
||||
}
|
||||
|
||||
/**
|
||||
@brief ElementScene::setElementInfo
|
||||
@param dc
|
||||
*/
|
||||
void ElementScene::setElementInfo(const DiagramContext& dc)
|
||||
{
|
||||
if(m_elmt_information != dc)
|
||||
{
|
||||
m_elmt_information = dc;
|
||||
emit elementInfoChanged();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@brief ElementScene::slot_select
|
||||
Select the item in content,
|
||||
@@ -833,7 +844,7 @@ void ElementScene::slot_editAuthorInformations()
|
||||
// ajoute un QTextEdit au dialogue
|
||||
QTextEdit *text_field = new QTextEdit();
|
||||
text_field -> setAcceptRichText(false);
|
||||
text_field -> setPlainText(informations());
|
||||
text_field -> setPlainText(m_element_data.m_drawing_information);
|
||||
text_field -> setReadOnly(is_read_only);
|
||||
dialog_layout -> addWidget(text_field);
|
||||
|
||||
@@ -851,10 +862,10 @@ void ElementScene::slot_editAuthorInformations()
|
||||
if (dialog_author.exec() == QDialog::Accepted && !is_read_only)
|
||||
{
|
||||
QString new_infos = text_field -> toPlainText().remove(QChar(13)); // CR-less text
|
||||
if (new_infos != informations())
|
||||
if (new_infos != m_element_data.m_drawing_information)
|
||||
{
|
||||
undoStack().push(new ChangeInformationsCommand(
|
||||
this, informations(), new_infos));
|
||||
this, m_element_data.m_drawing_information, new_infos));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -865,20 +876,15 @@ void ElementScene::slot_editAuthorInformations()
|
||||
*/
|
||||
void ElementScene::slot_editProperties()
|
||||
{
|
||||
QString type = m_elmt_type;
|
||||
DiagramContext kind_info = m_elmt_kindInfo;
|
||||
DiagramContext elmt_info = m_elmt_information;
|
||||
|
||||
ElementPropertiesEditorWidget epew(type, kind_info, elmt_info);
|
||||
ElementPropertiesEditorWidget epew(m_element_data);
|
||||
epew.exec();
|
||||
|
||||
if (type != m_elmt_type ||
|
||||
kind_info != m_elmt_kindInfo ||
|
||||
elmt_info != m_elmt_information)
|
||||
undoStack().push(new ChangePropertiesCommand(this,
|
||||
type,
|
||||
kind_info,
|
||||
elmt_info));
|
||||
if (m_element_data != epew.editedData())
|
||||
{
|
||||
undoStack().push(new changeElementDataCommand(this,
|
||||
m_element_data,
|
||||
epew.editedData()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -898,15 +904,15 @@ void ElementScene::slot_editNames()
|
||||
dialog_.setInformationText(tr("Vous pouvez spécifier le nom de l'élément dans plusieurs langues."));
|
||||
|
||||
NameListWidget *nlw_ = dialog_.namelistWidget();
|
||||
nlw_->setNames(m_names_list);
|
||||
nlw_->setNames(m_element_data.m_names_list);
|
||||
nlw_->setReadOnly(is_read_only);
|
||||
|
||||
if (dialog_.exec() == QDialog::Accepted && !is_read_only && !nlw_->isEmpty())
|
||||
{
|
||||
NamesList new_names = nlw_->names();
|
||||
if (new_names != m_names_list) {
|
||||
if (new_names != m_element_data. m_names_list) {
|
||||
undoStack().push(new ChangeNamesCommand(this,
|
||||
m_names_list,
|
||||
m_element_data.m_names_list,
|
||||
new_names));
|
||||
}
|
||||
}
|
||||
@@ -1087,62 +1093,6 @@ QRectF ElementScene::elementContentBoundingRect(
|
||||
return(bounding_rect);
|
||||
}
|
||||
|
||||
/**
|
||||
@brief ElementScene::applyInformations
|
||||
Applies the information (dimensions, hostpot, orientations,
|
||||
internal connections, names and additional information)
|
||||
contained in an XML document.
|
||||
\~French Applique les informations (dimensions, hostpot, orientations,
|
||||
connexions internes, noms et informations complementaires)
|
||||
contenu dans un document XML.
|
||||
\~ @param xml_document : Document XML a analyser
|
||||
\~ @return
|
||||
true if reading and applying the information went well, false otherwise.
|
||||
\~French true si la lecture et l'application
|
||||
des informations s'est bien passee, false sinon.
|
||||
*/
|
||||
bool ElementScene::applyInformations(const QDomDocument &xml_document)
|
||||
{
|
||||
// Root must be an element definition
|
||||
QDomElement root = xml_document.documentElement();
|
||||
|
||||
if (
|
||||
root.tagName() != "definition"
|
||||
||
|
||||
root.attribute("type") != "element")
|
||||
return(false);
|
||||
|
||||
//Extract info about element type
|
||||
m_elmt_type = root.attribute("link_type", "simple");
|
||||
m_elmt_kindInfo.fromXml(
|
||||
root.firstChildElement("kindInformations"),
|
||||
"kindInformation");
|
||||
//Extract info of element
|
||||
m_elmt_information.fromXml(
|
||||
root.firstChildElement("elementInformations"),
|
||||
"elementInformation");
|
||||
|
||||
//Extract names of xml definition
|
||||
m_names_list.fromXml(root);
|
||||
|
||||
//extract additional informations
|
||||
setInformations(QString());
|
||||
for (QDomNode node = root.firstChild() ;
|
||||
!node.isNull() ;
|
||||
node = node.nextSibling())
|
||||
{
|
||||
QDomElement elmt = node.toElement();
|
||||
if (elmt.isNull()) continue;
|
||||
if (elmt.tagName() == "informations")
|
||||
{
|
||||
setInformations(elmt.text());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
/**
|
||||
@brief ElementScene::loadContent
|
||||
Create and load the content describe in the xml document.
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "../diagramcontext.h"
|
||||
#include "../qgimanager.h"
|
||||
#include "elementcontent.h"
|
||||
#include "../properties/elementdata.h"
|
||||
|
||||
#include <QtWidgets>
|
||||
#include <QtXml>
|
||||
@@ -65,11 +66,7 @@ class ElementScene : public QGraphicsScene
|
||||
|
||||
// attributes
|
||||
private:
|
||||
NamesList m_names_list; /// List of localized names
|
||||
QString m_informations; /// Extra informations
|
||||
QString m_elmt_type; /// element type
|
||||
DiagramContext m_elmt_kindInfo,
|
||||
m_elmt_information; /// element kind info
|
||||
ElementData m_element_data; ///ElementData. Actualy in transition with old data storage
|
||||
QGIManager m_qgi_manager;
|
||||
QUndoStack m_undo_stack;
|
||||
|
||||
@@ -90,21 +87,20 @@ class ElementScene : public QGraphicsScene
|
||||
|
||||
// methods
|
||||
public:
|
||||
ElementData elementData();
|
||||
void setElementData(ElementData data);
|
||||
|
||||
void setEventInterface (ESEventInterface *event_interface);
|
||||
void clearEventInterface();
|
||||
|
||||
void setBehavior (ElementScene::Behavior);
|
||||
ElementScene::Behavior behavior() const;
|
||||
|
||||
QPointF snapToGrid(QPointF point);
|
||||
void setNames(const NamesList &);
|
||||
NamesList names() const;
|
||||
QString informations() const;
|
||||
void setInformations(const QString &);
|
||||
QString elementType () const {return m_elmt_type;}
|
||||
DiagramContext elementKindInfo () const {return m_elmt_kindInfo;}
|
||||
DiagramContext elementInformation() const {return m_elmt_information;}
|
||||
virtual int xGrid() const;
|
||||
virtual int yGrid() const;
|
||||
virtual void setGrid(int, int);
|
||||
|
||||
virtual const QDomDocument toXml(bool = true);
|
||||
virtual QRectF boundingRectFromXml(const QDomDocument &);
|
||||
virtual void fromXml(const QDomDocument &,
|
||||
@@ -128,7 +124,6 @@ class ElementScene : public QGraphicsScene
|
||||
void cut();
|
||||
void copy();
|
||||
QETElementEditor* editor() const;
|
||||
void setElementInfo(const DiagramContext& dc);
|
||||
|
||||
protected:
|
||||
void mouseMoveEvent (QGraphicsSceneMouseEvent *) override;
|
||||
@@ -137,12 +132,10 @@ class ElementScene : public QGraphicsScene
|
||||
void mouseDoubleClickEvent (QGraphicsSceneMouseEvent *event) override;
|
||||
void keyPressEvent (QKeyEvent *event) override;
|
||||
void contextMenuEvent(QGraphicsSceneContextMenuEvent *event) override;
|
||||
|
||||
void drawForeground(QPainter *, const QRectF &) override;
|
||||
|
||||
private:
|
||||
QRectF elementContentBoundingRect(const ElementContent &) const;
|
||||
bool applyInformations(const QDomDocument &);
|
||||
ElementContent loadContent(const QDomDocument &);
|
||||
ElementContent addContent(const ElementContent &);
|
||||
ElementContent addContentAtPos(const ElementContent &, const QPointF &);
|
||||
@@ -180,39 +173,4 @@ class ElementScene : public QGraphicsScene
|
||||
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(ElementScene::ItemOptions)
|
||||
|
||||
|
||||
/**
|
||||
@brief ElementScene::setNames
|
||||
@param nameslist New set of naes for the currently edited element
|
||||
*/
|
||||
inline void ElementScene::setNames(const NamesList &nameslist) {
|
||||
m_names_list = nameslist;
|
||||
}
|
||||
|
||||
/**
|
||||
@brief ElementScene::names
|
||||
@return the list of names of the currently edited element
|
||||
*/
|
||||
inline NamesList ElementScene::names() const
|
||||
{
|
||||
return(m_names_list);
|
||||
}
|
||||
|
||||
/**
|
||||
@brief ElementScene::informations
|
||||
@return extra informations of the currently edited element
|
||||
*/
|
||||
inline QString ElementScene::informations() const
|
||||
{
|
||||
return(m_informations);
|
||||
}
|
||||
|
||||
/**
|
||||
@brief ElementScene::setInformations
|
||||
@param infos new extra information for the currently edited element
|
||||
*/
|
||||
inline void ElementScene::setInformations(const QString &infos) {
|
||||
m_informations = infos;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
#include "../qetapp.h"
|
||||
#include "UndoCommand/pastepartscommand.h"
|
||||
#include "qetelementeditor.h"
|
||||
#include "ui/qetelementeditor.h"
|
||||
/**
|
||||
Constructeur
|
||||
@param scene ElementScene visualisee par cette ElementView
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#include "../editorcommands.h"
|
||||
#include "../elementscene.h"
|
||||
#include "../graphicspart/partline.h"
|
||||
#include "../qetelementeditor.h"
|
||||
#include "../ui/qetelementeditor.h"
|
||||
|
||||
#include <QGraphicsSceneMouseEvent>
|
||||
#include <QObject>
|
||||
|
||||
@@ -18,7 +18,8 @@
|
||||
#include "eseventinterface.h"
|
||||
|
||||
#include "../elementscene.h"
|
||||
#include "../qetelementeditor.h"
|
||||
#include "../ui/qetelementeditor.h"
|
||||
#include "../elementview.h"
|
||||
|
||||
#include <QGraphicsSceneMouseEvent>
|
||||
|
||||
@@ -40,7 +41,7 @@ ESEventInterface::ESEventInterface(ElementScene *scene) :
|
||||
void ESEventInterface::init()
|
||||
{
|
||||
m_scene->setBehavior(ElementScene::Behavior::AddPart);
|
||||
m_editor->slot_setNoDragToView();
|
||||
m_editor->elementView()->setDragMode(QGraphicsView::NoDrag);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -53,31 +54,31 @@ ESEventInterface::~ESEventInterface()
|
||||
delete m_help_verti;
|
||||
|
||||
m_scene->setBehavior(ElementScene::Behavior::Normal);
|
||||
m_editor->slot_setRubberBandToView();
|
||||
m_editor->elementView()->setDragMode(QGraphicsView::RubberBandDrag);
|
||||
}
|
||||
|
||||
bool ESEventInterface::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) {
|
||||
Q_UNUSED (event);
|
||||
Q_UNUSED (event)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ESEventInterface::mousePressEvent(QGraphicsSceneMouseEvent *event) {
|
||||
Q_UNUSED (event);
|
||||
Q_UNUSED (event)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ESEventInterface::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
|
||||
Q_UNUSED (event);
|
||||
Q_UNUSED (event)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ESEventInterface::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) {
|
||||
Q_UNUSED (event);
|
||||
Q_UNUSED (event)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ESEventInterface::wheelEvent(QGraphicsSceneWheelEvent *event) {
|
||||
Q_UNUSED (event);
|
||||
Q_UNUSED (event)
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -97,7 +98,7 @@ bool ESEventInterface::keyPressEvent(QKeyEvent *event) {
|
||||
}
|
||||
|
||||
bool ESEventInterface::KeyReleaseEvent(QKeyEvent *event) {
|
||||
Q_UNUSED (event);
|
||||
Q_UNUSED (event)
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1264,24 +1264,6 @@ void CustomElementGraphicPart::drawShadowShape(QPainter *painter)
|
||||
painter -> restore ();
|
||||
}
|
||||
|
||||
/**
|
||||
@brief CustomElementGraphicPart::itemChange
|
||||
Reimplemented from QGraphicsObject.
|
||||
If the item position change call updateCurrentPartEditor()
|
||||
the change is always send to QGraphicsObject
|
||||
@param change
|
||||
@param value
|
||||
@return the returned value of QGraphicsObject::itemChange
|
||||
*/
|
||||
QVariant CustomElementGraphicPart::itemChange(GraphicsItemChange change, const QVariant &value)
|
||||
{
|
||||
if (scene())
|
||||
if (change == QGraphicsItem::ItemPositionChange || change == QGraphicsItem::ItemPositionHasChanged)
|
||||
updateCurrentPartEditor();
|
||||
|
||||
return(QGraphicsObject::itemChange(change, value));
|
||||
}
|
||||
|
||||
/**
|
||||
@brief CustomElementGraphicPart::hoverEnterEvent
|
||||
Reimplemented from QGraphicsObject.
|
||||
|
||||
@@ -309,8 +309,6 @@ class CustomElementGraphicPart : public QGraphicsObject, public CustomElementPar
|
||||
void applyStylesToQPainter(QPainter &) const;
|
||||
void drawShadowShape (QPainter *painter);
|
||||
|
||||
QVariant itemChange(GraphicsItemChange change,
|
||||
const QVariant &value) override;
|
||||
void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override;
|
||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override;
|
||||
|
||||
|
||||
@@ -17,7 +17,8 @@
|
||||
*/
|
||||
#include "customelementpart.h"
|
||||
|
||||
#include "../qetelementeditor.h"
|
||||
#include "../ui/qetelementeditor.h"
|
||||
#include "../elementscene.h"
|
||||
|
||||
/// @return le QETElementEditor auquel cet editeur appartient
|
||||
QETElementEditor *CustomElementPart::elementEditor() const
|
||||
|
||||
@@ -318,7 +318,7 @@ void PartDynamicTextField::setText(const QString &text) {
|
||||
void PartDynamicTextField::setInfoName(const QString &info_name) {
|
||||
m_info_name = info_name;
|
||||
if(m_text_from == DynamicElementTextItem::ElementInfo && elementScene())
|
||||
setPlainText(elementScene() -> elementInformation().value(m_info_name).toString());
|
||||
setPlainText(elementScene()->elementData().m_informations.value(m_info_name).toString());
|
||||
emit infoNameChanged(m_info_name);
|
||||
}
|
||||
|
||||
@@ -338,7 +338,7 @@ QString PartDynamicTextField::infoName() const{
|
||||
void PartDynamicTextField::setCompositeText(const QString &text) {
|
||||
m_composite_text = text;
|
||||
if(m_text_from == DynamicElementTextItem::CompositeText && elementScene())
|
||||
setPlainText(autonum::AssignVariables::replaceVariable(m_composite_text, elementScene() -> elementInformation()));
|
||||
setPlainText(autonum::AssignVariables::replaceVariable(m_composite_text, elementScene()->elementData().m_informations));
|
||||
emit compositeTextChanged(m_composite_text);
|
||||
}
|
||||
|
||||
@@ -551,10 +551,10 @@ void PartDynamicTextField::elementInfoChanged()
|
||||
return;
|
||||
|
||||
if(m_text_from == DynamicElementTextItem::ElementInfo)
|
||||
setPlainText(elementScene() -> elementInformation().value(m_info_name).toString());
|
||||
setPlainText(elementScene()->elementData().m_informations.value(m_info_name).toString());
|
||||
else if (m_text_from == DynamicElementTextItem::CompositeText && elementScene())
|
||||
setPlainText(autonum::AssignVariables::replaceVariable(
|
||||
m_composite_text, elementScene() -> elementInformation()));
|
||||
m_composite_text, elementScene()->elementData().m_informations));
|
||||
}
|
||||
|
||||
void PartDynamicTextField::prepareAlignment()
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#include "../../QetGraphicsItemModeler/qetgraphicshandlerutility.h"
|
||||
#include "../../qeticons.h"
|
||||
#include "../elementscene.h"
|
||||
#include "../qetelementeditor.h"
|
||||
#include "../ui/qetelementeditor.h"
|
||||
|
||||
/**
|
||||
@brief PartPolygon::PartPolygon
|
||||
|
||||
@@ -72,7 +72,7 @@ void PartTerminal::paint(
|
||||
const QStyleOptionGraphicsItem *options,
|
||||
QWidget *widget)
|
||||
{
|
||||
Q_UNUSED(widget);
|
||||
Q_UNUSED(widget)
|
||||
painter -> save();
|
||||
|
||||
// annulation des renderhints
|
||||
@@ -98,7 +98,7 @@ void PartTerminal::paint(
|
||||
// dessin de la borne en rouge
|
||||
t.setColor(isSelected() ? Terminal::neutralColor : Qt::red);
|
||||
painter -> setPen(t);
|
||||
painter -> drawLine(QPointF(0.0, 0.0), d -> second_point);
|
||||
painter -> drawLine(QPointF(0.0, 0.0), d -> m_second_point);
|
||||
|
||||
// dessin du point d'amarrage au conducteur en bleu
|
||||
t.setColor(isSelected() ? Qt::red : Terminal::neutralColor);
|
||||
@@ -118,7 +118,7 @@ void PartTerminal::paint(
|
||||
QPainterPath PartTerminal::shape() const
|
||||
{
|
||||
QPainterPath shape;
|
||||
shape.lineTo(d -> second_point);
|
||||
shape.lineTo(d -> m_second_point);
|
||||
|
||||
QPainterPathStroker pps;
|
||||
pps.setWidth(1);
|
||||
@@ -132,7 +132,7 @@ QPainterPath PartTerminal::shape() const
|
||||
*/
|
||||
QRectF PartTerminal::boundingRect() const
|
||||
{
|
||||
QRectF br(QPointF(0, 0), d -> second_point);
|
||||
QRectF br(QPointF(0, 0), d -> m_second_point);
|
||||
br = br.normalized();
|
||||
|
||||
qreal adjust = (SHADOWS_HEIGHT + 1) / 2;
|
||||
@@ -161,6 +161,20 @@ void PartTerminal::setName(QString& name) {
|
||||
emit nameChanged();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief PartTerminal::setTerminalType
|
||||
* Set the type of terminal to 'type'
|
||||
* @param type
|
||||
*/
|
||||
void PartTerminal::setTerminalType(TerminalData::Type type)
|
||||
{
|
||||
if (d->m_type == type) {
|
||||
return;
|
||||
}
|
||||
d->m_type = type;
|
||||
emit terminalTypeChanged();
|
||||
}
|
||||
|
||||
void PartTerminal::setNewUuid()
|
||||
{
|
||||
d -> m_uuid = QUuid::createUuid();
|
||||
@@ -174,10 +188,10 @@ void PartTerminal::updateSecondPoint()
|
||||
{
|
||||
qreal ts = 4.0; // terminal size
|
||||
switch(d -> m_orientation) {
|
||||
case Qet::North: d -> second_point = QPointF(0.0, ts); break;
|
||||
case Qet::East : d -> second_point = QPointF(-ts, 0.0); break;
|
||||
case Qet::South: d -> second_point = QPointF(0.0, -ts); break;
|
||||
case Qet::West : d -> second_point = QPointF(ts, 0.0); break;
|
||||
case Qet::North: d -> m_second_point = QPointF(0.0, ts); break;
|
||||
case Qet::East : d -> m_second_point = QPointF(-ts, 0.0); break;
|
||||
case Qet::South: d -> m_second_point = QPointF(0.0, -ts); break;
|
||||
case Qet::West : d -> m_second_point = QPointF(ts, 0.0); break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,10 +27,13 @@
|
||||
This class represents a terminal which may be used to compose the drawing of
|
||||
an electrical element within the element editor.
|
||||
*/
|
||||
class PartTerminal : public CustomElementGraphicPart {
|
||||
class PartTerminal : public CustomElementGraphicPart
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(Qet::Orientation orientation READ orientation WRITE setOrientation)
|
||||
Q_PROPERTY(QString name READ name WRITE setName)
|
||||
Q_PROPERTY(TerminalData::Type terminal_type READ terminalType WRITE setTerminalType)
|
||||
|
||||
public:
|
||||
// constructors, destructor
|
||||
@@ -42,6 +45,7 @@ class PartTerminal : public CustomElementGraphicPart {
|
||||
signals:
|
||||
void orientationChanged();
|
||||
void nameChanged();
|
||||
void terminalTypeChanged();
|
||||
|
||||
// methods
|
||||
public:
|
||||
@@ -51,7 +55,6 @@ class PartTerminal : public CustomElementGraphicPart {
|
||||
@return the QGraphicsItem type
|
||||
*/
|
||||
int type() const override { return Type; }
|
||||
QString name() const override { return d -> m_name; }
|
||||
QString xmlName() const override { return(QString("terminal")); }
|
||||
void fromXml(const QDomElement &) override;
|
||||
const QDomElement toXml(QDomDocument &) const override;
|
||||
@@ -71,7 +74,12 @@ class PartTerminal : public CustomElementGraphicPart {
|
||||
Qet::Orientation orientation() const {return d -> m_orientation;}
|
||||
void setOrientation(Qet::Orientation ori);
|
||||
|
||||
QString name() const override { return d -> m_name; }
|
||||
void setName(QString& name);
|
||||
|
||||
TerminalData::Type terminalType() const {return d->m_type;}
|
||||
void setTerminalType(TerminalData::Type type);
|
||||
|
||||
void setNewUuid();
|
||||
|
||||
private:
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,189 +0,0 @@
|
||||
/*
|
||||
Copyright 2006-2021 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 CUSTOM_ELEMENT_EDITOR_H
|
||||
#define CUSTOM_ELEMENT_EDITOR_H
|
||||
#include "../ElementsCollection/elementslocation.h"
|
||||
#include "../qet.h"
|
||||
#include "../qetmainwindow.h"
|
||||
#include "elementscene.h"
|
||||
|
||||
class ElementItemEditor;
|
||||
class ElementView;
|
||||
|
||||
/**
|
||||
This class represents an element editor, allowing users to draw, change and
|
||||
configure a particular electrical element.
|
||||
*/
|
||||
class QETElementEditor : public QETMainWindow {
|
||||
Q_OBJECT
|
||||
|
||||
// constructor, destructor
|
||||
public:
|
||||
QETElementEditor(QWidget * = nullptr);
|
||||
~QETElementEditor() override;
|
||||
private:
|
||||
QETElementEditor(const QETElementEditor &);
|
||||
void setupActions();
|
||||
void setupMenus();
|
||||
void setupInterface();
|
||||
|
||||
// attributes
|
||||
private:
|
||||
/// whether the editor is "read-only"
|
||||
bool read_only;
|
||||
/// menus
|
||||
QMenu *file_menu, *edit_menu, *paste_from_menu, *display_menu, *tools_menu;
|
||||
/// view widget for the editing scene
|
||||
ElementView *m_view;
|
||||
/// editing scene
|
||||
ElementScene *m_elmt_scene;
|
||||
/// container for widgets dedicated to primitive edition
|
||||
QDockWidget *m_tools_dock;
|
||||
/// Stack of widgets for tools_dock
|
||||
QStackedWidget *m_tools_dock_stack;
|
||||
/// label displayed when several primitives are selected
|
||||
QLabel *m_default_informations;
|
||||
/// Hash associating primitive names with their matching edition widget
|
||||
QHash<QString, ElementItemEditor *> m_editors;
|
||||
/// container for the undo list
|
||||
QDockWidget *m_undo_dock;
|
||||
/// Container for the list of existing primitives
|
||||
QDockWidget *m_parts_dock;
|
||||
/// List of primitives
|
||||
QListWidget *m_parts_list;
|
||||
/// actions for the "file" menu
|
||||
QAction *new_element, *open, *open_dxf, *open_file, *save, *save_as, *save_as_file, *reload, *quit;
|
||||
/// actions for the "edit" menu
|
||||
QAction *selectall, *deselectall, *inv_select;
|
||||
QAction *cut, *copy, *paste, *paste_in_area, *paste_from_file, *paste_from_elmt;
|
||||
QAction *undo, *redo;
|
||||
QAction *edit_delete, *edit_size_hs, *edit_names, *edit_author, *m_edit_properties;
|
||||
/// toolbars
|
||||
QToolBar *parts_toolbar, *main_toolbar, *view_toolbar, *depth_toolbar, *element_toolbar;
|
||||
/// Action group
|
||||
QActionGroup *parts, *m_zoom_ag, *m_depth_action_group;
|
||||
/// minimum window title
|
||||
QString min_title;
|
||||
/// filename of the currently edited element
|
||||
QString filename_;
|
||||
/// location of the currently edited element
|
||||
ElementsLocation location_;
|
||||
/// whether the currently edited element comes from a file or a location
|
||||
bool opened_from_file;
|
||||
|
||||
// methods
|
||||
public:
|
||||
void setNames(const NamesList &);
|
||||
void setLocation(const ElementsLocation &);
|
||||
ElementsLocation location() const;
|
||||
void setFileName(const QString &);
|
||||
QString fileName() const;
|
||||
void setReadOnly(bool);
|
||||
bool isReadOnly() const;
|
||||
void fromFile(const QString &);
|
||||
void fromLocation(const ElementsLocation &);
|
||||
bool toFile(const QString &);
|
||||
bool toLocation(const ElementsLocation &location);
|
||||
bool isEditing(const ElementsLocation &);
|
||||
bool isEditing(const QString &);
|
||||
ElementScene *elementScene() const;
|
||||
void readSettings();
|
||||
void writeSettings();
|
||||
static QPointF pasteOffset();
|
||||
static QString getOpenElementFileName(QWidget * = nullptr, const QString & = QString());
|
||||
void contextMenu(QPoint p, QList<QAction *> actions = QList<QAction*>());
|
||||
|
||||
signals:
|
||||
void saveToLocation(ElementsLocation loc);
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent *) override;
|
||||
void firstActivation(QEvent *) override;
|
||||
|
||||
private:
|
||||
bool canClose();
|
||||
QWidget *clearToolsDock();
|
||||
void copyAndPasteXml(const QDomDocument &);
|
||||
|
||||
public slots:
|
||||
void addLine();
|
||||
void addRect();
|
||||
void addEllipse();
|
||||
void addPolygon();
|
||||
void addArc();
|
||||
void addText();
|
||||
void addTerminal();
|
||||
void addDynamicTextField();
|
||||
void UncheckAddPrimitive();
|
||||
|
||||
void slot_new();
|
||||
void slot_open();
|
||||
void slot_openDxf();
|
||||
void slot_openFile();
|
||||
void openRecentFile(const QString &);
|
||||
void openElement(const QString &);
|
||||
void slot_reload();
|
||||
bool slot_save();
|
||||
bool slot_saveAs();
|
||||
bool slot_saveAsFile();
|
||||
void slot_setRubberBandToView();
|
||||
void slot_setNoDragToView();
|
||||
void slot_updateInformations();
|
||||
void slot_updateMenus();
|
||||
void slot_updateTitle();
|
||||
void slot_createPartsList();
|
||||
void slot_updatePartsList();
|
||||
void slot_updateSelectionFromPartsList();
|
||||
bool checkElement();
|
||||
void pasteFromFile();
|
||||
void pasteFromElement();
|
||||
void updateCurrentPartEditor();
|
||||
};
|
||||
|
||||
/**
|
||||
@param nameslist the new list of names for the currently edited element
|
||||
*/
|
||||
inline void QETElementEditor::setNames(const NamesList &nameslist) {
|
||||
m_elmt_scene -> setNames(nameslist);
|
||||
}
|
||||
|
||||
/**
|
||||
@return the location of the currently edited element
|
||||
*/
|
||||
inline ElementsLocation QETElementEditor::location() const
|
||||
{
|
||||
return(location_);
|
||||
}
|
||||
|
||||
/**
|
||||
@return the filename of the currently edited element
|
||||
*/
|
||||
inline QString QETElementEditor::fileName() const
|
||||
{
|
||||
return(filename_);
|
||||
}
|
||||
|
||||
/**
|
||||
@return the editing scene
|
||||
*/
|
||||
inline ElementScene *QETElementEditor::elementScene() const
|
||||
{
|
||||
return(m_elmt_scene);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,322 +0,0 @@
|
||||
/*
|
||||
Copyright 2006-2021 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 "terminaleditor.h"
|
||||
|
||||
#include "../QPropertyUndoCommand/qpropertyundocommand.h"
|
||||
#include "../editor/graphicspart/partterminal.h"
|
||||
#include "../qeticons.h"
|
||||
|
||||
#include <QComboBox>
|
||||
#include <QDoubleSpinBox>
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
/**
|
||||
@brief TerminalEditor::TerminalEditor
|
||||
@param editor
|
||||
@param parent
|
||||
*/
|
||||
TerminalEditor::TerminalEditor(QETElementEditor* editor, QWidget* parent):
|
||||
ElementItemEditor(editor, parent) {
|
||||
m_part = nullptr;
|
||||
m_terminals.clear();
|
||||
init();
|
||||
}
|
||||
|
||||
/**
|
||||
@brief TerminalEditor::TerminalEditor
|
||||
Constructeur
|
||||
@param editor :
|
||||
L'editeur d'element concerne
|
||||
@param terms :
|
||||
La borne a editer
|
||||
@param parent :
|
||||
QWidget parent de ce widget
|
||||
*/
|
||||
TerminalEditor::TerminalEditor(
|
||||
QETElementEditor *editor,
|
||||
QList<PartTerminal *> &terms,
|
||||
QWidget *parent) :
|
||||
ElementItemEditor(editor, parent),
|
||||
m_terminals(terms),
|
||||
m_part(terms.first()) {
|
||||
init();
|
||||
}
|
||||
|
||||
/**
|
||||
@brief TerminalEditor::init
|
||||
*/
|
||||
void TerminalEditor::init()
|
||||
{
|
||||
qle_x = new QDoubleSpinBox();
|
||||
qle_y = new QDoubleSpinBox();
|
||||
name = new QLineEdit();
|
||||
|
||||
qle_x -> setRange(-5000, 5000);
|
||||
qle_y -> setRange(-5000, 5000);
|
||||
|
||||
orientation = new QComboBox();
|
||||
orientation -> addItem(QET::Icons::North, tr("Nord"), Qet::North);
|
||||
orientation -> addItem(QET::Icons::East, tr("Est"), Qet::East);
|
||||
orientation -> addItem(QET::Icons::South, tr("Sud"), Qet::South);
|
||||
orientation -> addItem(QET::Icons::West, tr("Ouest"), Qet::West);
|
||||
|
||||
QVBoxLayout *main_layout = new QVBoxLayout();
|
||||
main_layout -> addWidget(new QLabel(tr("Position : ")));
|
||||
|
||||
QHBoxLayout *position = new QHBoxLayout();
|
||||
position -> addWidget(new QLabel(tr("x : ")));
|
||||
position -> addWidget(qle_x );
|
||||
position -> addWidget(new QLabel(tr("y : ")));
|
||||
position -> addWidget(qle_y );
|
||||
main_layout -> addLayout(position);
|
||||
|
||||
QHBoxLayout *ori = new QHBoxLayout();
|
||||
ori -> addWidget(new QLabel(tr("Orientation : ")));
|
||||
ori -> addWidget(orientation );
|
||||
main_layout -> addLayout(ori);
|
||||
|
||||
QHBoxLayout *lay_name = new QHBoxLayout();
|
||||
lay_name -> addWidget(new QLabel(tr("Name : ")));
|
||||
lay_name -> addWidget(name);
|
||||
main_layout -> addLayout(lay_name);
|
||||
|
||||
main_layout -> addStretch();
|
||||
setLayout(main_layout);
|
||||
|
||||
activeConnections(true);
|
||||
updateForm();
|
||||
}
|
||||
|
||||
/**
|
||||
@brief TerminalEditor::~TerminalEditor
|
||||
Destructeur
|
||||
*/
|
||||
TerminalEditor::~TerminalEditor()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
Permet de specifier a cet editeur quelle primitive il doit editer. A noter
|
||||
qu'un editeur peut accepter ou refuser d'editer une primitive.
|
||||
L'editeur de borne acceptera d'editer la primitive new_part s'il s'agit d'un
|
||||
objet de la classe PartTerminal.
|
||||
@param new_part Nouvelle primitive a editer
|
||||
@return true si l'editeur a accepter d'editer la primitive, false sinon
|
||||
*/
|
||||
bool TerminalEditor::setPart(CustomElementPart* new_part) {
|
||||
m_terminals.clear();
|
||||
if (!new_part) {
|
||||
if (m_part) {
|
||||
disconnect(m_part, &PartTerminal::orientationChanged, this, &TerminalEditor::updateForm);
|
||||
}
|
||||
m_part = nullptr;
|
||||
return(true);
|
||||
}
|
||||
if (PartTerminal *part_terminal = static_cast<PartTerminal *>(new_part)) {
|
||||
if(m_part == part_terminal) return true;
|
||||
if (m_part) {
|
||||
disconnect(m_part, &PartTerminal::orientationChanged, this, &TerminalEditor::updateForm);
|
||||
}
|
||||
m_part = part_terminal;
|
||||
updateForm();
|
||||
connect(m_part, &PartTerminal::orientationChanged, this, &TerminalEditor::updateForm);
|
||||
return(true);
|
||||
}
|
||||
return(false);
|
||||
}
|
||||
|
||||
bool TerminalEditor::setParts(QList<CustomElementPart *> parts) {
|
||||
if (parts.isEmpty()) {
|
||||
m_terminals.clear();
|
||||
if (m_part) {
|
||||
disconnect(m_part, &PartTerminal::orientationChanged, this, &TerminalEditor::updateForm);
|
||||
}
|
||||
m_part = nullptr;
|
||||
return(true);
|
||||
}
|
||||
|
||||
if (PartTerminal *part_terminal = static_cast<PartTerminal *>(parts.first())) {
|
||||
if (m_part) {
|
||||
disconnect(m_part, &PartTerminal::orientationChanged, this, &TerminalEditor::updateForm);
|
||||
}
|
||||
m_part = part_terminal;
|
||||
m_terminals.clear();
|
||||
m_terminals.append(part_terminal);
|
||||
for (int i=1; i < parts.length(); i++) {
|
||||
m_terminals.append(static_cast<PartTerminal*>(parts[i]));
|
||||
}
|
||||
updateForm();
|
||||
connect(m_part, &PartTerminal::orientationChanged, this, &TerminalEditor::updateForm);
|
||||
return(true);
|
||||
}
|
||||
return(false);
|
||||
}
|
||||
|
||||
/**
|
||||
@return la primitive actuellement editee, ou 0 si ce widget n'en edite pas
|
||||
*/
|
||||
CustomElementPart *TerminalEditor::currentPart() const
|
||||
{
|
||||
return(m_part);
|
||||
}
|
||||
|
||||
QList<CustomElementPart*> TerminalEditor::currentParts() const
|
||||
{
|
||||
QList<CustomElementPart*> parts;
|
||||
for (auto term: m_terminals) {
|
||||
parts.append(static_cast<CustomElementPart*>(term));
|
||||
}
|
||||
return parts;
|
||||
}
|
||||
|
||||
/// Met a jour l'orientation de la borne et cree un objet d'annulation
|
||||
void TerminalEditor::updateTerminalO()
|
||||
{
|
||||
if (m_locked) return;
|
||||
m_locked = true;
|
||||
QVariant var(orientation -> itemData(orientation -> currentIndex()));
|
||||
|
||||
for (int i=0; i < m_terminals.length(); i++) {
|
||||
PartTerminal* term = m_terminals[i];
|
||||
if (var != term->property("orientation"))
|
||||
{
|
||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(term, "orientation", term->property("orientation"), var);
|
||||
undo->setText(tr("Modifier l'orientation d'une borne"));
|
||||
undoStack().push(undo);
|
||||
}
|
||||
}
|
||||
m_locked = false;
|
||||
}
|
||||
|
||||
/**
|
||||
@brief TerminalEditor::updateXPos
|
||||
*/
|
||||
void TerminalEditor::updateXPos()
|
||||
{
|
||||
if (m_locked) return;
|
||||
m_locked = true;
|
||||
QPointF new_pos(qle_x->value(), 0);
|
||||
|
||||
for (int i=0; i < m_terminals.length(); i++) {
|
||||
PartTerminal* term = m_terminals[i];
|
||||
new_pos.setY(term->pos().y()); // change only x value
|
||||
if (term->pos() != new_pos) {
|
||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(term, "pos", term->property("pos"), new_pos);
|
||||
undo->setText(tr("Déplacer une borne"));
|
||||
undo->enableAnimation();
|
||||
undoStack().push(undo);
|
||||
}
|
||||
}
|
||||
m_locked=false;
|
||||
}
|
||||
|
||||
/**
|
||||
@brief TerminalEditor::updateYPos
|
||||
*/
|
||||
void TerminalEditor::updateYPos()
|
||||
{
|
||||
if (m_locked) return;
|
||||
m_locked = true;
|
||||
QPointF new_pos(0, qle_y->value()); // change only y value
|
||||
|
||||
for (int i=0; i < m_terminals.length(); i++) {
|
||||
PartTerminal* term = m_terminals[i];
|
||||
new_pos.setX(term->pos().x());
|
||||
if (term->pos() != new_pos) {
|
||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(term, "pos", term->property("pos"), new_pos);
|
||||
undo->setText(tr("Déplacer une borne"));
|
||||
undo->enableAnimation();
|
||||
undoStack().push(undo);
|
||||
}
|
||||
}
|
||||
m_locked=false;
|
||||
}
|
||||
|
||||
/**
|
||||
@brief TerminalEditor::updateName
|
||||
SLOT set name to Terminal
|
||||
*/
|
||||
void TerminalEditor::updateName() {
|
||||
if (m_locked) return;
|
||||
m_locked = true;
|
||||
QVariant var(name->text());
|
||||
|
||||
for (int i=0; i < m_terminals.length(); i++) {
|
||||
PartTerminal* term = m_terminals[i];
|
||||
if (var != term->property("name"))
|
||||
{
|
||||
QPropertyUndoCommand *undo;
|
||||
undo = new QPropertyUndoCommand(term,
|
||||
"name",
|
||||
term->property("name"),
|
||||
var);
|
||||
undo->setText(tr("Modifier le nom du terminal"));
|
||||
undoStack().push(undo);
|
||||
}
|
||||
}
|
||||
m_locked=false;
|
||||
|
||||
}
|
||||
|
||||
/// update Number and name, create cancel object
|
||||
|
||||
/**
|
||||
Met a jour le formulaire d'edition
|
||||
*/
|
||||
void TerminalEditor::updateForm()
|
||||
{
|
||||
if (!m_part) return;
|
||||
activeConnections(false);
|
||||
qle_x -> setValue(m_part->property("x").toReal());
|
||||
qle_y -> setValue(m_part->property("y").toReal());
|
||||
orientation -> setCurrentIndex(orientation->findData(m_part->property("orientation")));
|
||||
name -> setText(m_part->name());
|
||||
activeConnections(true);
|
||||
}
|
||||
|
||||
/**
|
||||
Active ou desactive les connexionx signaux/slots entre les widgets internes.
|
||||
@param active true pour activer les connexions, false pour les desactiver
|
||||
*/
|
||||
void TerminalEditor::activeConnections(bool active) {
|
||||
if (active) {
|
||||
connect(qle_x,
|
||||
&QDoubleSpinBox::editingFinished,
|
||||
this, &TerminalEditor::updateXPos);
|
||||
connect(qle_y,
|
||||
&QDoubleSpinBox::editingFinished,
|
||||
this, &TerminalEditor::updateYPos);
|
||||
connect(orientation,
|
||||
QOverload<int>::of(&QComboBox::activated),
|
||||
this, &TerminalEditor::updateTerminalO);
|
||||
connect(name, &QLineEdit::editingFinished,
|
||||
this, &TerminalEditor::updateName);
|
||||
}
|
||||
else {
|
||||
disconnect(qle_x, &QDoubleSpinBox::editingFinished,
|
||||
this, &TerminalEditor::updateXPos);
|
||||
disconnect(qle_y, &QDoubleSpinBox::editingFinished,
|
||||
this, &TerminalEditor::updateYPos);
|
||||
disconnect(orientation, QOverload<int>::of(&QComboBox::activated),
|
||||
this, &TerminalEditor::updateTerminalO);
|
||||
disconnect(name, &QLineEdit::editingFinished,
|
||||
this, &TerminalEditor::updateName);
|
||||
}
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
/*
|
||||
Copyright 2006-2021 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 TERMINAL_EDITOR_H
|
||||
#define TERMINAL_EDITOR_H
|
||||
|
||||
#include "elementitemeditor.h"
|
||||
|
||||
#include <QLineEdit>
|
||||
|
||||
class PartTerminal;
|
||||
class QDoubleSpinBox;
|
||||
class QComboBox;
|
||||
|
||||
/**
|
||||
@brief The TerminalEditor class
|
||||
This class provides a widget to edit terminals within the element editor.
|
||||
The class is capable to change the values of multiple parts of the same time.
|
||||
The displayed values are from the first selected element
|
||||
*/
|
||||
class TerminalEditor : public ElementItemEditor {
|
||||
Q_OBJECT
|
||||
|
||||
// Constructors, destructor
|
||||
public:
|
||||
TerminalEditor(
|
||||
QETElementEditor *,
|
||||
QList<PartTerminal *>& terms,
|
||||
QWidget * = nullptr);
|
||||
TerminalEditor(QETElementEditor *, QWidget * = nullptr);
|
||||
~TerminalEditor() override;
|
||||
private:
|
||||
TerminalEditor(const TerminalEditor &);
|
||||
void init();
|
||||
|
||||
// attributes
|
||||
private:
|
||||
QList<PartTerminal *> m_terminals;
|
||||
PartTerminal *m_part{nullptr};
|
||||
QDoubleSpinBox *qle_x, *qle_y;
|
||||
QComboBox *orientation;
|
||||
QLineEdit *name;
|
||||
bool m_locked{false};
|
||||
|
||||
// methods
|
||||
public:
|
||||
bool setPart(CustomElementPart *) override;
|
||||
bool setParts(QList<CustomElementPart *> parts) override;
|
||||
CustomElementPart *currentPart() const override;
|
||||
QList<CustomElementPart*> currentParts() const override;
|
||||
|
||||
public slots:
|
||||
void updateTerminalO();
|
||||
void updateXPos();
|
||||
void updateYPos();
|
||||
void updateName();
|
||||
void updateForm() override;
|
||||
|
||||
private:
|
||||
void activeConnections(bool);
|
||||
};
|
||||
#endif
|
||||
@@ -24,7 +24,8 @@
|
||||
#include "../../qetinformation.h"
|
||||
#include "../../ui/alignmenttextdialog.h"
|
||||
#include "../../ui/compositetexteditdialog.h"
|
||||
#include "../qetelementeditor.h"
|
||||
#include "../ui/qetelementeditor.h"
|
||||
#include "../elementscene.h"
|
||||
#include "ui_dynamictextfieldeditor.h"
|
||||
|
||||
#include <QColorDialog>
|
||||
@@ -224,9 +225,9 @@ void DynamicTextFieldEditor::fillInfoComboBox()
|
||||
ui -> m_elmt_info_cb -> clear();
|
||||
|
||||
QStringList strl;
|
||||
QString type = elementEditor() -> elementScene() -> elementType();
|
||||
auto type = elementEditor()->elementScene()->elementData().m_type;
|
||||
|
||||
if(type.contains("report")) {
|
||||
if(type & ElementData::AllReport) {
|
||||
strl = QETInformation::folioReportInfoKeys();
|
||||
}
|
||||
else {
|
||||
@@ -332,8 +333,8 @@ void DynamicTextFieldEditor::on_m_elmt_info_cb_activated(const QString &arg1) {
|
||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "infoName", m_parts[i] -> infoName(), info);
|
||||
undo->setText(tr("Modifier l'information d'un texte"));
|
||||
undoStack().push(undo);
|
||||
m_parts[i] -> setPlainText(
|
||||
elementEditor() -> elementScene() -> elementInformation().value(m_parts[i] -> infoName()).toString());
|
||||
m_parts[i]->setPlainText(
|
||||
elementEditor()->elementScene()->elementData().m_informations.value(m_parts[i] -> infoName()).toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "../../qetapp.h"
|
||||
#include "../../qetinformation.h"
|
||||
#include "ui_elementpropertieseditorwidget.h"
|
||||
#include "../../qetinformation.h"
|
||||
|
||||
#include <QItemDelegate>
|
||||
|
||||
@@ -37,7 +38,7 @@ class EditorDelegate : public QItemDelegate
|
||||
|
||||
QWidget* createEditor(QWidget *parent,
|
||||
const QStyleOptionViewItem &option,
|
||||
const QModelIndex &index) const
|
||||
const QModelIndex &index) const override
|
||||
{
|
||||
if(index.column() == 1)
|
||||
{
|
||||
@@ -50,23 +51,14 @@ class EditorDelegate : public QItemDelegate
|
||||
};
|
||||
|
||||
/**
|
||||
@brief ElementPropertiesEditorWidget::ElementPropertiesEditorWidget
|
||||
Default constructor
|
||||
@param basic_type : QString of the drawed element
|
||||
@param kind_info : DiagramContext to store kindInfo of drawed element
|
||||
@param elmt_info : the information of element (label, manufacturer etc...]
|
||||
@param parent : parent widget
|
||||
*/
|
||||
ElementPropertiesEditorWidget::ElementPropertiesEditorWidget(
|
||||
QString &basic_type,
|
||||
DiagramContext &kind_info,
|
||||
DiagramContext &elmt_info,
|
||||
QWidget *parent) :
|
||||
* @brief ElementPropertiesEditorWidget::ElementPropertiesEditorWidget
|
||||
* @param data
|
||||
* @param parent
|
||||
*/
|
||||
ElementPropertiesEditorWidget::ElementPropertiesEditorWidget(ElementData data, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::ElementPropertiesEditorWidget),
|
||||
m_basic_type(basic_type),
|
||||
m_kind_info (kind_info),
|
||||
m_elmt_info (elmt_info)
|
||||
m_data(data)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
setUpInterface();
|
||||
@@ -90,22 +82,29 @@ void ElementPropertiesEditorWidget::upDateInterface()
|
||||
{
|
||||
ui->m_base_type_cb->setCurrentIndex(
|
||||
ui->m_base_type_cb->findData(
|
||||
QVariant(m_basic_type)));
|
||||
m_data.m_type));
|
||||
|
||||
if (m_basic_type == "slave")
|
||||
if (m_data.m_type == ElementData::Slave)
|
||||
{
|
||||
ui->m_state_cb->setCurrentIndex(
|
||||
ui->m_state_cb->findData(
|
||||
m_kind_info["state"].toString()));
|
||||
m_data.m_slave_state));
|
||||
ui->m_type_cb->setCurrentIndex (
|
||||
ui->m_type_cb->findData(
|
||||
m_kind_info["type"].toString()));
|
||||
ui->m_number_ctc->setValue(m_kind_info["number"].toInt());
|
||||
m_data.m_slave_type));
|
||||
ui->m_number_ctc->setValue(m_data.m_contact_count);
|
||||
}
|
||||
else if (m_basic_type == "master") {
|
||||
else if (m_data.m_type == ElementData::Master) {
|
||||
ui->m_master_type_cb->setCurrentIndex(
|
||||
ui->m_master_type_cb->findData (
|
||||
m_kind_info["type"]));
|
||||
m_data.m_master_type));
|
||||
} else if (m_data.m_type == ElementData::Terminale) {
|
||||
ui->m_terminal_type_cb->setCurrentIndex(
|
||||
ui->m_terminal_type_cb->findData(
|
||||
m_data.m_terminal_type));
|
||||
ui->m_terminal_func_cb->setCurrentIndex(
|
||||
ui->m_terminal_func_cb->findData(
|
||||
m_data.m_terminal_function));
|
||||
}
|
||||
|
||||
on_m_base_type_cb_currentIndexChanged(ui->m_base_type_cb->currentIndex());
|
||||
@@ -117,33 +116,39 @@ void ElementPropertiesEditorWidget::upDateInterface()
|
||||
void ElementPropertiesEditorWidget::setUpInterface()
|
||||
{
|
||||
// Type combo box
|
||||
ui->m_base_type_cb->addItem (tr("Simple"), QVariant("simple"));
|
||||
ui->m_base_type_cb->addItem (tr("Maître"), 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écédent"),
|
||||
QVariant("previous_report"));
|
||||
ui->m_base_type_cb->addItem (tr("Bornier"), QVariant("terminal"));
|
||||
ui->m_base_type_cb->addItem (tr("Simple"), ElementData::Simple);
|
||||
ui->m_base_type_cb->addItem (tr("Maître"), ElementData::Master);
|
||||
ui->m_base_type_cb->addItem (tr("Esclave"), ElementData::Slave);
|
||||
ui->m_base_type_cb->addItem (tr("Renvoi de folio suivant"), ElementData::NextReport);
|
||||
ui->m_base_type_cb->addItem (tr("Renvoi de folio précédent"), ElementData::PreviousReport);
|
||||
ui->m_base_type_cb->addItem (tr("Bornier"), ElementData::Terminale);
|
||||
|
||||
// Slave option
|
||||
ui->m_state_cb->addItem(tr("Normalement ouvert"),QVariant("NO"));
|
||||
ui->m_state_cb->addItem(tr("Normalement fermé"), QVariant("NC"));
|
||||
ui->m_state_cb->addItem(tr("Inverseur"), QVariant("SW"));
|
||||
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é travail"), QVariant("delayOn"));
|
||||
ui->m_type_cb->addItem(tr("Temporisé repos"), QVariant("delayOff"));
|
||||
ui->m_type_cb->addItem(tr("Temporisé travail & repos"),
|
||||
QVariant("delayOnOff"));
|
||||
ui->m_state_cb->addItem(tr("Normalement ouvert"), ElementData::NO);
|
||||
ui->m_state_cb->addItem(tr("Normalement fermé"), ElementData::NC);
|
||||
ui->m_state_cb->addItem(tr("Inverseur"), ElementData::SW);
|
||||
ui->m_type_cb->addItem(tr("Simple"), ElementData::SSimple);
|
||||
ui->m_type_cb->addItem(tr("Puissance"), ElementData::Power);
|
||||
ui->m_type_cb->addItem(tr("Temporisé travail"), ElementData::DelayOn);
|
||||
ui->m_type_cb->addItem(tr("Temporisé repos"), ElementData::DelayOff);
|
||||
ui->m_type_cb->addItem(tr("Temporisé travail & repos"), ElementData::delayOnOff);
|
||||
|
||||
//Master option
|
||||
ui->m_master_type_cb->addItem(tr("Bobine"), QVariant("coil"));
|
||||
ui->m_master_type_cb->addItem(tr("Organe de protection"),
|
||||
QVariant("protection"));
|
||||
ui->m_master_type_cb->addItem(tr("Commutateur / bouton"),
|
||||
QVariant("commutator"));
|
||||
|
||||
ui->m_master_type_cb->addItem(tr("Bobine"), ElementData::Coil);
|
||||
ui->m_master_type_cb->addItem(tr("Organe de protection"), ElementData::Protection);
|
||||
ui->m_master_type_cb->addItem(tr("Commutateur / bouton"), ElementData::Commutator);
|
||||
|
||||
//Terminal option
|
||||
ui->m_terminal_type_cb->addItem(tr("Générique"), ElementData::TTGeneric);
|
||||
ui->m_terminal_type_cb->addItem(tr("Fusible"), ElementData::Fuse);
|
||||
ui->m_terminal_type_cb->addItem(tr("Séctionnable"), ElementData::Sectional);
|
||||
ui->m_terminal_type_cb->addItem(tr("Diode"), ElementData::Diode);
|
||||
|
||||
ui->m_terminal_func_cb->addItem(tr("Générique"), ElementData::TFGeneric);
|
||||
ui->m_terminal_func_cb->addItem(tr("Phase"), ElementData::Phase);
|
||||
ui->m_terminal_func_cb->addItem(tr("Neutre"), ElementData::Neutral);
|
||||
ui->m_terminal_func_cb->addItem(tr("Terre"), ElementData::PE);
|
||||
|
||||
//Disable the edition of the first column of the information tree
|
||||
//by this little workaround
|
||||
ui->m_tree->setItemDelegate(new EditorDelegate(this));
|
||||
@@ -153,21 +158,28 @@ void ElementPropertiesEditorWidget::setUpInterface()
|
||||
|
||||
void ElementPropertiesEditorWidget::updateTree()
|
||||
{
|
||||
QString type = ui->m_base_type_cb->itemData(
|
||||
ui->m_base_type_cb->currentIndex()).toString();
|
||||
|
||||
if (type == "master")
|
||||
ui->m_tree->setEnabled(true);
|
||||
else if (type == "slave")
|
||||
ui->m_tree->setDisabled(true);
|
||||
else if (type == "simple")
|
||||
ui->m_tree->setEnabled(true);
|
||||
else if (type == "next_report")
|
||||
ui->m_tree->setDisabled(true);
|
||||
else if (type == "previous_report")
|
||||
ui->m_tree->setDisabled(true);
|
||||
else if (type == "terminal")
|
||||
ui->m_tree->setEnabled(true);
|
||||
auto type_ = ui->m_base_type_cb->currentData().value<ElementData::Type>();
|
||||
|
||||
switch (type_) {
|
||||
case ElementData::Simple:
|
||||
ui->m_tree->setEnabled(true);
|
||||
break;
|
||||
case ElementData::NextReport:
|
||||
ui->m_tree->setDisabled(true);
|
||||
break;
|
||||
case ElementData::PreviousReport:
|
||||
ui->m_tree->setDisabled(true);
|
||||
break;
|
||||
case ElementData::Master:
|
||||
ui->m_tree->setEnabled(true);
|
||||
break;
|
||||
case ElementData::Slave:
|
||||
ui->m_tree->setDisabled(true);
|
||||
break;
|
||||
case ElementData::Terminale:
|
||||
ui->m_tree->setEnabled(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -175,20 +187,16 @@ void ElementPropertiesEditorWidget::updateTree()
|
||||
Create QTreeWidgetItem of the tree widget and populate it
|
||||
*/
|
||||
void ElementPropertiesEditorWidget::populateTree()
|
||||
{
|
||||
QStringList keys{"label", "plant", "comment", "description",
|
||||
"designation", "manufacturer",
|
||||
"manufacturer_reference", "supplier", "quantity",
|
||||
"unity", "machine_manufacturer_reference"};
|
||||
|
||||
{
|
||||
const auto keys = QETInformation::elementEditorElementInfoKeys();
|
||||
for(const QString& key : keys)
|
||||
{
|
||||
QTreeWidgetItem *qtwi = new QTreeWidgetItem(ui->m_tree);
|
||||
qtwi->setFlags(Qt::ItemIsEnabled | Qt::ItemIsEditable);
|
||||
qtwi->setData(0, Qt::DisplayRole,
|
||||
QETInformation::translatedInfoKey(key));
|
||||
QETInformation::translatedInfoKey(key));
|
||||
qtwi->setData(0, Qt::UserRole, key);
|
||||
qtwi->setText(1, m_elmt_info.value(key).toString());
|
||||
qtwi->setText(1, m_data.m_informations.value(key).toString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,23 +206,21 @@ void ElementPropertiesEditorWidget::populateTree()
|
||||
*/
|
||||
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_data.m_type = ui->m_base_type_cb->currentData().value<ElementData::Type>();
|
||||
|
||||
if (m_data.m_type == ElementData::Slave)
|
||||
{
|
||||
m_kind_info.addValue("state",
|
||||
ui->m_state_cb->itemData(
|
||||
ui->m_state_cb->currentIndex()));
|
||||
m_kind_info.addValue("type",
|
||||
ui->m_type_cb->itemData(
|
||||
ui->m_type_cb->currentIndex()));
|
||||
m_kind_info.addValue("number",
|
||||
QVariant(ui->m_number_ctc->value()));
|
||||
m_data.m_slave_state = ui->m_state_cb->currentData().value<ElementData::SlaveState>();
|
||||
m_data.m_slave_type = ui->m_type_cb->currentData().value<ElementData::SlaveType>();
|
||||
m_data.m_contact_count = ui->m_number_ctc->value();
|
||||
}
|
||||
else if(m_basic_type == "master") {
|
||||
m_kind_info.addValue("type",
|
||||
ui->m_master_type_cb->itemData(
|
||||
ui->m_master_type_cb->currentIndex()));
|
||||
else if (m_data.m_type == ElementData::Master) {
|
||||
m_data.m_master_type = ui->m_master_type_cb->currentData().value<ElementData::MasterType>();
|
||||
}
|
||||
else if (m_data.m_type == ElementData::Terminale)
|
||||
{
|
||||
m_data.m_terminal_type = ui->m_terminal_type_cb->currentData().value<ElementData::TerminalType>();
|
||||
m_data.m_terminal_function = ui->m_terminal_func_cb->currentData().value<ElementData::TerminalFunction>();
|
||||
}
|
||||
|
||||
for (QTreeWidgetItem *qtwi : ui->m_tree->invisibleRootItem()->takeChildren())
|
||||
@@ -224,8 +230,8 @@ void ElementPropertiesEditorWidget::on_m_buttonBox_accepted()
|
||||
txt.remove("\r");
|
||||
txt.remove("\n");
|
||||
|
||||
m_elmt_info.addValue(qtwi->data(0, Qt::UserRole).toString(),
|
||||
txt);
|
||||
m_data.m_informations.addValue(qtwi->data(0, Qt::UserRole).toString(),
|
||||
txt);
|
||||
}
|
||||
|
||||
this->close();
|
||||
@@ -235,18 +241,23 @@ void ElementPropertiesEditorWidget::on_m_buttonBox_accepted()
|
||||
@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)
|
||||
void ElementPropertiesEditorWidget::on_m_base_type_cb_currentIndexChanged(int index)
|
||||
{
|
||||
bool slave = false , master = false;
|
||||
bool slave = false , master = false, terminal = false;
|
||||
|
||||
if (ui->m_base_type_cb->itemData(index).toString() == "slave")
|
||||
auto type_ = ui->m_base_type_cb->itemData(index).value<ElementData::Type>();
|
||||
if (type_ == ElementData::Slave)
|
||||
slave = true;
|
||||
else if (ui->m_base_type_cb->itemData(index).toString() == "master")
|
||||
else if (type_ == ElementData::Master)
|
||||
master = true;
|
||||
else if (type_ == ElementData::Terminale)
|
||||
terminal = true;
|
||||
|
||||
ui->m_slave_gb->setVisible(slave);
|
||||
ui->m_master_gb->setVisible(master);
|
||||
|
||||
ui->m_terminal_gb->setVisible(terminal);
|
||||
ui->tabWidget->setTabVisible(1,
|
||||
(type_ == ElementData::Simple ||
|
||||
type_ == ElementData::Master));
|
||||
updateTree();
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#define ELEMENTPROPERTIESEDITORWIDGET_H
|
||||
|
||||
#include "../../diagramcontext.h"
|
||||
#include "../../properties/elementdata.h"
|
||||
|
||||
#include <QAbstractButton>
|
||||
#include <QDialog>
|
||||
@@ -38,12 +39,13 @@ class ElementPropertiesEditorWidget : public QDialog
|
||||
|
||||
//METHODS
|
||||
public:
|
||||
explicit ElementPropertiesEditorWidget(QString &basic_type, DiagramContext &kind_info, DiagramContext &elmt_info, QWidget *parent = nullptr);
|
||||
explicit ElementPropertiesEditorWidget(ElementData data, QWidget *parent = nullptr);
|
||||
~ElementPropertiesEditorWidget() override;
|
||||
|
||||
void upDateInterface();
|
||||
ElementData editedData() {return m_data;}
|
||||
|
||||
private:
|
||||
void upDateInterface();
|
||||
void setUpInterface();
|
||||
void updateTree();
|
||||
void populateTree();
|
||||
@@ -56,9 +58,7 @@ class ElementPropertiesEditorWidget : public QDialog
|
||||
//ATTRIBUTES
|
||||
private:
|
||||
Ui::ElementPropertiesEditorWidget *ui;
|
||||
QString &m_basic_type;
|
||||
DiagramContext &m_kind_info,
|
||||
&m_elmt_info;
|
||||
ElementData m_data;
|
||||
};
|
||||
|
||||
#endif // ELEMENTPROPERTIESEDITORWIDGET_H
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>450</width>
|
||||
<height>321</height>
|
||||
<width>527</width>
|
||||
<height>442</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@@ -107,6 +107,35 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="m_terminal_gb">
|
||||
<property name="title">
|
||||
<string>Élément bornier</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>Type</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string>Fonction</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="m_terminal_type_cb"/>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="m_terminal_func_cb"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,163 @@
|
||||
/*
|
||||
Copyright 2006-2021 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 QETELEMENTEDITOR_H
|
||||
#define QETELEMENTEDITOR_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include "../../ElementsCollection/elementslocation.h"
|
||||
|
||||
class ElementScene;
|
||||
class QActionGroup;
|
||||
class ElementItemEditor;
|
||||
class ElementView;
|
||||
class QListWidget;
|
||||
class QStackedWidget;
|
||||
class QLabel;
|
||||
|
||||
namespace Ui {
|
||||
class QETElementEditor;
|
||||
}
|
||||
|
||||
class QETElementEditor : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
signals:
|
||||
void saveToLocation(ElementsLocation loc);
|
||||
|
||||
public:
|
||||
explicit QETElementEditor(QWidget *parent = nullptr);
|
||||
~QETElementEditor() override;
|
||||
|
||||
void contextMenu(QPoint p, QList<QAction *> actions = QList<QAction *>());
|
||||
void setNames(const NamesList &name_list);
|
||||
void setLocation(const ElementsLocation &location);
|
||||
ElementsLocation location() const;
|
||||
void setFileName(const QString &file_name);
|
||||
QString fileName() const;
|
||||
void setReadOnly(bool ro);
|
||||
bool isReadOnly() const;
|
||||
void fromFile(const QString &filepath);
|
||||
bool toFile(const QString &filepath);
|
||||
void fromLocation(const ElementsLocation &location);
|
||||
bool toLocation(const ElementsLocation &location);
|
||||
bool isEditing(const ElementsLocation &location);
|
||||
bool isEditing(const QString &filepath);
|
||||
ElementScene *elementScene() const;
|
||||
ElementView *elementView() const;
|
||||
static QPointF pasteOffset();
|
||||
static QString getOpenElementFileName(QWidget *parent = nullptr, const QString &dir = QString());
|
||||
void updateTitle();
|
||||
void fillPartsList();
|
||||
void UncheckAddPrimitive();
|
||||
void updateCurrentPartEditor();
|
||||
void updateInformations();
|
||||
void updatePartsList();
|
||||
void updateSelectionFromPartsList();
|
||||
void openElement(const QString &filepath);
|
||||
bool checkElement();
|
||||
|
||||
protected:
|
||||
bool event(QEvent *event) override;
|
||||
void closeEvent(QCloseEvent *) override;
|
||||
|
||||
|
||||
private slots:
|
||||
bool on_m_save_action_triggered();
|
||||
bool on_m_save_as_action_triggered();
|
||||
void on_m_select_all_act_triggered();
|
||||
void on_m_edit_element_properties_action_triggered();
|
||||
void on_m_new_action_triggered();
|
||||
void on_m_open_action_triggered();
|
||||
void on_m_open_from_file_action_triggered();
|
||||
void on_m_open_dxf_action_triggered();
|
||||
bool on_m_save_as_file_action_triggered();
|
||||
void on_m_reload_action_triggered();
|
||||
void on_m_quit_action_triggered();
|
||||
void on_m_deselect_all_action_triggered();
|
||||
void on_m_cut_action_triggered();
|
||||
void on_m_copy_action_triggered();
|
||||
void on_m_paste_action_triggered();
|
||||
void on_m_paste_in_area_action_triggered();
|
||||
void on_m_paste_from_file_action_triggered();
|
||||
void on_m_paste_from_element_action_triggered();
|
||||
void on_m_revert_selection_action_triggered();
|
||||
void on_m_delete_action_triggered();
|
||||
void on_m_edit_names_action_triggered();
|
||||
void on_m_edit_author_action_triggered();
|
||||
void on_m_zoom_in_action_triggered();
|
||||
void on_m_zoom_out_action_triggered();
|
||||
void on_m_zoom_fit_best_action_triggered();
|
||||
void on_m_zoom_original_action_triggered();
|
||||
void on_m_about_qet_action_triggered();
|
||||
void on_m_online_manual_triggered();
|
||||
void on_m_youtube_action_triggered();
|
||||
void on_m_donate_action_triggered();
|
||||
void on_m_about_qt_action_triggered();
|
||||
|
||||
private:
|
||||
bool canClose();
|
||||
void readSettings();
|
||||
void writeSettings() const;
|
||||
void setupActions();
|
||||
void updateAction();
|
||||
void setupConnection();
|
||||
void initGui();
|
||||
QWidget *clearToolsDock();
|
||||
void copyAndPasteXml(const QDomDocument &xml_document);
|
||||
|
||||
private:
|
||||
Ui::QETElementEditor *ui;
|
||||
|
||||
bool
|
||||
m_read_only = false,
|
||||
m_opened_from_file = false,
|
||||
m_first_activation = true;
|
||||
|
||||
ElementScene *m_elmt_scene = nullptr;
|
||||
|
||||
QActionGroup
|
||||
*m_add_part_action_grp = nullptr,
|
||||
*m_depth_action_group = nullptr;
|
||||
|
||||
QList<QAction *> m_context_menu_action_list;
|
||||
|
||||
QAction
|
||||
*m_undo_action = nullptr,
|
||||
*m_redo_action = nullptr;
|
||||
|
||||
|
||||
/// Hash associating primitive names with their matching edition widget
|
||||
QHash<QString, ElementItemEditor *> m_editors;
|
||||
|
||||
ElementsLocation m_location;
|
||||
|
||||
QString
|
||||
m_file_name,
|
||||
m_min_title;
|
||||
|
||||
ElementView *m_view = nullptr;
|
||||
|
||||
QListWidget *m_parts_list = nullptr;
|
||||
|
||||
QStackedWidget *m_tools_dock_stack = nullptr;
|
||||
|
||||
QLabel *m_default_informations = nullptr;
|
||||
|
||||
};
|
||||
|
||||
#endif // QETELEMENTEDITOR_H
|
||||
@@ -0,0 +1,496 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>QETElementEditor</class>
|
||||
<widget class="QMainWindow" name="QETElementEditor">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>600</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>QElectroTech - Éditeur d'élément</string>
|
||||
</property>
|
||||
<property name="windowIcon">
|
||||
<iconset resource="../../../qelectrotech.qrc">
|
||||
<normaloff>:/ico/16x16/qet.png</normaloff>:/ico/16x16/qet.png</iconset>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget"/>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="m_file_menu">
|
||||
<property name="title">
|
||||
<string>&Fichier</string>
|
||||
</property>
|
||||
<addaction name="m_new_action"/>
|
||||
<addaction name="m_open_action"/>
|
||||
<addaction name="m_open_from_file_action"/>
|
||||
<addaction name="m_open_dxf_action"/>
|
||||
<addaction name="m_save_action"/>
|
||||
<addaction name="m_save_as_action"/>
|
||||
<addaction name="m_save_as_file_action"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="m_reload_action"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="m_quit_action"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="m_edit_menu">
|
||||
<property name="title">
|
||||
<string>&Édition</string>
|
||||
</property>
|
||||
<widget class="QMenu" name="m_paste_from_menu">
|
||||
<property name="title">
|
||||
<string>Coller depuis...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../qelectrotech.qrc">
|
||||
<normaloff>:/ico/16x16/edit-paste.png</normaloff>:/ico/16x16/edit-paste.png</iconset>
|
||||
</property>
|
||||
<addaction name="m_paste_from_file_action"/>
|
||||
<addaction name="m_paste_from_element_action"/>
|
||||
</widget>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="m_select_all_act"/>
|
||||
<addaction name="m_deselect_all_action"/>
|
||||
<addaction name="m_revert_selection_action"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="m_cut_action"/>
|
||||
<addaction name="m_copy_action"/>
|
||||
<addaction name="m_paste_action"/>
|
||||
<addaction name="m_paste_in_area_action"/>
|
||||
<addaction name="m_paste_from_menu"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="m_delete_action"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="m_edit_names_action"/>
|
||||
<addaction name="m_edit_author_action"/>
|
||||
<addaction name="m_edit_element_properties_action"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="m_display_menu">
|
||||
<property name="title">
|
||||
<string>Afficha&ge</string>
|
||||
</property>
|
||||
<addaction name="m_zoom_in_action"/>
|
||||
<addaction name="m_zoom_out_action"/>
|
||||
<addaction name="m_zoom_fit_best_action"/>
|
||||
<addaction name="m_zoom_original_action"/>
|
||||
<addaction name="separator"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menu_Aide">
|
||||
<property name="title">
|
||||
<string>&Aide</string>
|
||||
</property>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="m_about_qet_action"/>
|
||||
<addaction name="m_online_manual"/>
|
||||
<addaction name="m_youtube_action"/>
|
||||
<addaction name="m_donate_action"/>
|
||||
<addaction name="m_about_qt_action"/>
|
||||
</widget>
|
||||
<addaction name="m_file_menu"/>
|
||||
<addaction name="m_edit_menu"/>
|
||||
<addaction name="m_display_menu"/>
|
||||
<addaction name="menu_Aide"/>
|
||||
</widget>
|
||||
<widget class="QDockWidget" name="m_undo_dock">
|
||||
<property name="allowedAreas">
|
||||
<set>Qt::LeftDockWidgetArea|Qt::RightDockWidgetArea</set>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Annulations</string>
|
||||
</property>
|
||||
<attribute name="dockWidgetArea">
|
||||
<number>1</number>
|
||||
</attribute>
|
||||
<widget class="QWidget" name="dockWidgetContents"/>
|
||||
</widget>
|
||||
<widget class="QDockWidget" name="m_parts_dock">
|
||||
<property name="allowedAreas">
|
||||
<set>Qt::LeftDockWidgetArea|Qt::RightDockWidgetArea</set>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Parties</string>
|
||||
</property>
|
||||
<attribute name="dockWidgetArea">
|
||||
<number>2</number>
|
||||
</attribute>
|
||||
<widget class="QWidget" name="dockWidgetContents_2"/>
|
||||
</widget>
|
||||
<widget class="QDockWidget" name="m_tools_dock">
|
||||
<property name="allowedAreas">
|
||||
<set>Qt::LeftDockWidgetArea|Qt::RightDockWidgetArea</set>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Informations</string>
|
||||
</property>
|
||||
<attribute name="dockWidgetArea">
|
||||
<number>1</number>
|
||||
</attribute>
|
||||
<widget class="QWidget" name="dockWidgetContents_3"/>
|
||||
</widget>
|
||||
<widget class="QToolBar" name="m_main_toolbar">
|
||||
<property name="windowTitle">
|
||||
<string>Outils</string>
|
||||
</property>
|
||||
<attribute name="toolBarArea">
|
||||
<enum>TopToolBarArea</enum>
|
||||
</attribute>
|
||||
<attribute name="toolBarBreak">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<addaction name="m_new_action"/>
|
||||
<addaction name="m_open_action"/>
|
||||
<addaction name="m_save_action"/>
|
||||
<addaction name="m_save_as_action"/>
|
||||
<addaction name="m_reload_action"/>
|
||||
<addaction name="m_delete_action"/>
|
||||
</widget>
|
||||
<widget class="QToolBar" name="m_view_toolbar">
|
||||
<property name="windowTitle">
|
||||
<string>Affichage</string>
|
||||
</property>
|
||||
<attribute name="toolBarArea">
|
||||
<enum>TopToolBarArea</enum>
|
||||
</attribute>
|
||||
<attribute name="toolBarBreak">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<addaction name="m_zoom_in_action"/>
|
||||
<addaction name="m_zoom_out_action"/>
|
||||
<addaction name="m_zoom_fit_best_action"/>
|
||||
<addaction name="m_zoom_original_action"/>
|
||||
</widget>
|
||||
<widget class="QToolBar" name="m_element_toolbar">
|
||||
<property name="windowTitle">
|
||||
<string>Élément</string>
|
||||
</property>
|
||||
<attribute name="toolBarArea">
|
||||
<enum>TopToolBarArea</enum>
|
||||
</attribute>
|
||||
<attribute name="toolBarBreak">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<addaction name="m_edit_names_action"/>
|
||||
<addaction name="m_edit_element_properties_action"/>
|
||||
</widget>
|
||||
<widget class="QToolBar" name="m_undo_toolbar">
|
||||
<property name="windowTitle">
|
||||
<string>Annulation</string>
|
||||
</property>
|
||||
<attribute name="toolBarArea">
|
||||
<enum>TopToolBarArea</enum>
|
||||
</attribute>
|
||||
<attribute name="toolBarBreak">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
<action name="m_select_all_act">
|
||||
<property name="icon">
|
||||
<iconset resource="../../../qelectrotech.qrc">
|
||||
<normaloff>:/ico/16x16/edit-select-all.png</normaloff>:/ico/16x16/edit-select-all.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Tout sélectionner</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="m_new_action">
|
||||
<property name="icon">
|
||||
<iconset resource="../../../qelectrotech.qrc">
|
||||
<normaloff>:/ico/22x22/document-new.png</normaloff>:/ico/22x22/document-new.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Nouveau</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="m_open_action">
|
||||
<property name="icon">
|
||||
<iconset resource="../../../qelectrotech.qrc">
|
||||
<normaloff>:/ico/22x22/folder-open.png</normaloff>:/ico/22x22/folder-open.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Ouvrir</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="m_open_from_file_action">
|
||||
<property name="icon">
|
||||
<iconset resource="../../../qelectrotech.qrc">
|
||||
<normaloff>:/ico/22x22/folder-open.png</normaloff>:/ico/22x22/folder-open.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Ouvrir depuis un fichier</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="m_open_dxf_action">
|
||||
<property name="icon">
|
||||
<iconset resource="../../../qelectrotech.qrc">
|
||||
<normaloff>:/ico/16x16/run-dxf.png</normaloff>:/ico/16x16/run-dxf.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Lancer le plugin convertisseur DXF</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="m_save_action">
|
||||
<property name="icon">
|
||||
<iconset resource="../../../qelectrotech.qrc">
|
||||
<normaloff>:/ico/22x22/document-save.png</normaloff>:/ico/22x22/document-save.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Enregistrer</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="m_save_as_action">
|
||||
<property name="icon">
|
||||
<iconset resource="../../../qelectrotech.qrc">
|
||||
<normaloff>:/ico/22x22/document-save-as.png</normaloff>:/ico/22x22/document-save-as.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Enregistrer sous</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="m_save_as_file_action">
|
||||
<property name="icon">
|
||||
<iconset resource="../../../qelectrotech.qrc">
|
||||
<normaloff>:/ico/22x22/document-save.png</normaloff>:/ico/22x22/document-save.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Enregistrer dans un fichier</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="m_reload_action">
|
||||
<property name="icon">
|
||||
<iconset resource="../../../qelectrotech.qrc">
|
||||
<normaloff>:/ico/22x22/view-refresh.png</normaloff>:/ico/22x22/view-refresh.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Recharger</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="m_quit_action">
|
||||
<property name="icon">
|
||||
<iconset resource="../../../qelectrotech.qrc">
|
||||
<normaloff>:/ico/16x16/application-exit.png</normaloff>:/ico/16x16/application-exit.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Quitter</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="m_deselect_all_action">
|
||||
<property name="icon">
|
||||
<iconset resource="../../../qelectrotech.qrc">
|
||||
<normaloff>:/ico/16x16/edit-select-none.png</normaloff>:/ico/16x16/edit-select-none.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Désélectionner tout</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="m_cut_action">
|
||||
<property name="icon">
|
||||
<iconset resource="../../../qelectrotech.qrc">
|
||||
<normaloff>:/ico/16x16/edit-cut.png</normaloff>:/ico/16x16/edit-cut.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Co&uper</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="m_copy_action">
|
||||
<property name="icon">
|
||||
<iconset resource="../../../qelectrotech.qrc">
|
||||
<normaloff>:/ico/16x16/edit-copy.png</normaloff>:/ico/16x16/edit-copy.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Cop&ier</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="m_paste_action">
|
||||
<property name="icon">
|
||||
<iconset resource="../../../qelectrotech.qrc">
|
||||
<normaloff>:/ico/16x16/edit-paste.png</normaloff>:/ico/16x16/edit-paste.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>C&oller</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="m_paste_in_area_action">
|
||||
<property name="icon">
|
||||
<iconset resource="../../../qelectrotech.qrc">
|
||||
<normaloff>:/ico/16x16/edit-paste.png</normaloff>:/ico/16x16/edit-paste.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>C&oller dans la zone</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="m_paste_from_file_action">
|
||||
<property name="icon">
|
||||
<iconset resource="../../../qelectrotech.qrc">
|
||||
<normaloff>:/ico/16x16/text-xml.png</normaloff>:/ico/16x16/text-xml.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Un fichier</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="m_paste_from_element_action">
|
||||
<property name="icon">
|
||||
<iconset resource="../../../qelectrotech.qrc">
|
||||
<normaloff>:/ico/16x16/element.png</normaloff>:/ico/16x16/element.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Un élément</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="m_revert_selection_action">
|
||||
<property name="icon">
|
||||
<iconset resource="../../../qelectrotech.qrc">
|
||||
<normaloff>:/ico/16x16/edit-select-invert.png</normaloff>:/ico/16x16/edit-select-invert.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Inverser la sélection</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="m_delete_action">
|
||||
<property name="icon">
|
||||
<iconset resource="../../../qelectrotech.qrc">
|
||||
<normaloff>:/ico/22x22/edit-delete.png</normaloff>:/ico/22x22/edit-delete.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Supprimer</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="m_edit_names_action">
|
||||
<property name="icon">
|
||||
<iconset resource="../../../qelectrotech.qrc">
|
||||
<normaloff>:/ico/22x22/names.png</normaloff>:/ico/22x22/names.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Éditer le nom et les traductions de l'élément</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="m_edit_author_action">
|
||||
<property name="icon">
|
||||
<iconset resource="../../../qelectrotech.qrc">
|
||||
<normaloff>:/ico/16x16/preferences-desktop-user.png</normaloff>:/ico/16x16/preferences-desktop-user.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Éditer les informations sur l'auteur</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="m_edit_element_properties_action">
|
||||
<property name="icon">
|
||||
<iconset resource="../../../qelectrotech.qrc">
|
||||
<normaloff>:/ico/22x22/element-edit.png</normaloff>:/ico/22x22/element-edit.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Éditer les propriétés de l'élément</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="m_zoom_in_action">
|
||||
<property name="icon">
|
||||
<iconset resource="../../../qelectrotech.qrc">
|
||||
<normaloff>:/ico/22x22/zoom-in.png</normaloff>:/ico/22x22/zoom-in.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Zoom avant</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="m_zoom_out_action">
|
||||
<property name="icon">
|
||||
<iconset resource="../../../qelectrotech.qrc">
|
||||
<normaloff>:/ico/22x22/zoom-out.png</normaloff>:/ico/22x22/zoom-out.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Zoom arrière</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="m_zoom_fit_best_action">
|
||||
<property name="icon">
|
||||
<iconset resource="../../../qelectrotech.qrc">
|
||||
<normaloff>:/ico/22x22/zoom-fit-best.png</normaloff>:/ico/22x22/zoom-fit-best.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Zoom adapté</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="m_zoom_original_action">
|
||||
<property name="icon">
|
||||
<iconset resource="../../../qelectrotech.qrc">
|
||||
<normaloff>:/ico/22x22/zoom-original.png</normaloff>:/ico/22x22/zoom-original.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Pas de zoom</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="m_about_qet_action">
|
||||
<property name="icon">
|
||||
<iconset resource="../../../qelectrotech.qrc">
|
||||
<normaloff>:/ico/16x16/qet.png</normaloff>:/ico/16x16/qet.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>À &propos de QElectroTech</string>
|
||||
</property>
|
||||
<property name="statusTip">
|
||||
<string>Affiche des informations sur QElectroTech</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="m_online_manual">
|
||||
<property name="icon">
|
||||
<iconset resource="../../../qelectrotech.qrc">
|
||||
<normaloff>:/ico/16x16/help-contents.png</normaloff>:/ico/16x16/help-contents.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Manuel en ligne</string>
|
||||
</property>
|
||||
<property name="statusTip">
|
||||
<string>Lance le navigateur par défaut vers le manuel en ligne de QElectroTech</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="m_youtube_action">
|
||||
<property name="icon">
|
||||
<iconset resource="../../../qelectrotech.qrc">
|
||||
<normaloff>:/ico/16x16/kdenlive-show-video.png</normaloff>:/ico/16x16/kdenlive-show-video.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Chaine Youtube</string>
|
||||
</property>
|
||||
<property name="statusTip">
|
||||
<string>Lance le navigateur par défaut vers la chaine Youtube de QElectroTech</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="m_donate_action">
|
||||
<property name="icon">
|
||||
<iconset resource="../../../qelectrotech.qrc">
|
||||
<normaloff>:/ico/16x16/help-donate.png</normaloff>:/ico/16x16/help-donate.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Soutenir le projet par un don</string>
|
||||
</property>
|
||||
<property name="statusTip">
|
||||
<string>Soutenir le projet QElectroTech par un don</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="m_about_qt_action">
|
||||
<property name="icon">
|
||||
<iconset resource="../../../qelectrotech.qrc">
|
||||
<normaloff>:/ico/16x16/qt.png</normaloff>:/ico/16x16/qt.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>À propos de &Qt</string>
|
||||
</property>
|
||||
<property name="statusTip">
|
||||
<string>Affiche des informations sur la bibliothèque Qt</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../../../qelectrotech.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,254 @@
|
||||
/*
|
||||
Copyright 2006-2021 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 "terminaleditor.h"
|
||||
#include "ui_terminaleditor.h"
|
||||
#include "../../qeticons.h"
|
||||
#include "../../qet.h"
|
||||
#include "../graphicspart/partterminal.h"
|
||||
#include "../../QPropertyUndoCommand/qpropertyundocommand.h"
|
||||
|
||||
/**
|
||||
* @brief TerminalEditor::TerminalEditor
|
||||
* Default constructor
|
||||
* @param editor : element editor of which this terminal editor belong
|
||||
* @param parent : parent widget
|
||||
*/
|
||||
TerminalEditor::TerminalEditor(QETElementEditor *editor, QWidget *parent) :
|
||||
ElementItemEditor(editor, parent),
|
||||
ui(new Ui::TerminalEditor)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
init();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief TerminalEditor::~TerminalEditor
|
||||
* Destructor
|
||||
*/
|
||||
TerminalEditor::~TerminalEditor()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief TerminalEditor::updateForm
|
||||
* Reimplemented from ElementItemEditor
|
||||
* Update the content of this widget
|
||||
*/
|
||||
void TerminalEditor::updateForm()
|
||||
{
|
||||
if (!m_part) {
|
||||
return;
|
||||
}
|
||||
activeConnections(false);
|
||||
|
||||
ui->m_x_dsb->setValue(m_part->property("x").toReal());
|
||||
ui->m_y_dsb->setValue(m_part->property("y").toReal());
|
||||
ui->m_orientation_cb->setCurrentIndex(ui->m_orientation_cb->findData(m_part->property("orientation")));
|
||||
ui->m_name_le->setText(m_part->name());
|
||||
ui->m_type_cb->setCurrentIndex(ui->m_orientation_cb->findData(m_part->terminalType()));
|
||||
|
||||
activeConnections(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief TerminalEditor::setPart
|
||||
* Set the part to edit.
|
||||
* The part must be a PartTerminal, in other case return false.
|
||||
* @param new_part : the part to edit
|
||||
* @return true if the part can be edited.
|
||||
*/
|
||||
bool TerminalEditor::setPart(CustomElementPart *new_part)
|
||||
{
|
||||
if (m_part == new_part) {
|
||||
return true;
|
||||
}
|
||||
|
||||
activeChangeConnections(false);
|
||||
|
||||
if (!new_part)
|
||||
{
|
||||
m_part = nullptr;
|
||||
return(true);
|
||||
}
|
||||
|
||||
if (PartTerminal *part_terminal = dynamic_cast<PartTerminal *>(new_part))
|
||||
{
|
||||
m_part = part_terminal;
|
||||
updateForm();
|
||||
activeChangeConnections(true);
|
||||
return(true);
|
||||
}
|
||||
return(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief TerminalEditor::currentPart
|
||||
* @return the current edited part
|
||||
* or nullptr if there is no part or several part
|
||||
* @see QList<CustomElementPart *> TerminalEditor::currentParts() const
|
||||
*/
|
||||
CustomElementPart *TerminalEditor::currentPart() const
|
||||
{
|
||||
return m_part;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief TerminalEditor::init
|
||||
* Some init about this class
|
||||
*/
|
||||
void TerminalEditor::init()
|
||||
{
|
||||
ui->m_orientation_cb->addItem(QET::Icons::North, tr("Nord"), Qet::North);
|
||||
ui->m_orientation_cb->addItem(QET::Icons::East, tr("Est"), Qet::East);
|
||||
ui->m_orientation_cb->addItem(QET::Icons::South, tr("Sud"), Qet::South);
|
||||
ui->m_orientation_cb->addItem(QET::Icons::West, tr("Ouest"), Qet::West);
|
||||
|
||||
ui->m_type_cb->addItem(tr("Générique"), TerminalData::Generic);
|
||||
ui->m_type_cb->addItem(tr("Bornier intérieur"), TerminalData::Inner);
|
||||
ui->m_type_cb->addItem(tr("Bornier extérieur"), TerminalData::Outer);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief TerminalEditor::posEdited
|
||||
*/
|
||||
void TerminalEditor::posEdited()
|
||||
{
|
||||
if (m_locked) {
|
||||
return;
|
||||
}
|
||||
m_locked = true;
|
||||
|
||||
QPointF new_pos(ui->m_x_dsb->value(),
|
||||
ui->m_y_dsb->value());
|
||||
|
||||
if (m_part->pos() != new_pos)
|
||||
{
|
||||
auto undo = new QPropertyUndoCommand(m_part, "pos", m_part->property("pos"), new_pos);
|
||||
undo->setText(tr("Déplacer une borne"));
|
||||
undo->setAnimated(true, false);
|
||||
undoStack().push(undo);
|
||||
}
|
||||
|
||||
m_locked = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief TerminalEditor::orientationEdited
|
||||
*/
|
||||
void TerminalEditor::orientationEdited()
|
||||
{
|
||||
if (m_locked) {
|
||||
return;
|
||||
}
|
||||
m_locked = true;
|
||||
|
||||
auto ori_ = ui->m_orientation_cb->currentData();
|
||||
if (m_part->orientation() != ori_)
|
||||
{
|
||||
auto undo = new QPropertyUndoCommand(m_part, "orientation", m_part->property("orientation"), ori_);
|
||||
undo->setText(tr("Modifier l'orientation d'une borne"));
|
||||
undoStack().push(undo);
|
||||
}
|
||||
|
||||
m_locked = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief TerminalEditor::nameEdited
|
||||
*/
|
||||
void TerminalEditor::nameEdited()
|
||||
{
|
||||
if (m_locked) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_locked = true;
|
||||
QString name_(ui->m_name_le->text());
|
||||
|
||||
if (m_part->name() != name_)
|
||||
{
|
||||
auto undo = new QPropertyUndoCommand(m_part, "name", m_part->property("name"), name_);
|
||||
undo->setText(tr("Modifier le nom du terminal"));
|
||||
undoStack().push(undo);
|
||||
}
|
||||
m_locked=false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief TerminalEditor::typeEdited
|
||||
*/
|
||||
void TerminalEditor::typeEdited()
|
||||
{
|
||||
if (m_locked) {
|
||||
return;
|
||||
}
|
||||
m_locked = true;
|
||||
|
||||
auto type = ui->m_type_cb->currentData();
|
||||
if (type != m_part->terminalType()) {
|
||||
auto undo = new QPropertyUndoCommand(m_part, "terminal_type", m_part->terminalType(), type);
|
||||
undo->setText(tr("Modifier le type d'une borne"));
|
||||
undoStack().push(undo);
|
||||
}
|
||||
m_locked = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief TerminalEditor::activeConnections
|
||||
* Active connection between the widgets used in this editor
|
||||
* and method of this class.
|
||||
* @param active
|
||||
*/
|
||||
void TerminalEditor::activeConnections(bool active)
|
||||
{
|
||||
if (active) {
|
||||
m_editor_connections << connect(ui->m_x_dsb, QOverload<qreal>::of(&QDoubleSpinBox::valueChanged),
|
||||
this, &TerminalEditor::posEdited);
|
||||
m_editor_connections << connect(ui->m_y_dsb, QOverload<qreal>::of(&QDoubleSpinBox::valueChanged),
|
||||
this, &TerminalEditor::posEdited);
|
||||
m_editor_connections << connect(ui->m_orientation_cb, QOverload<int>::of(&QComboBox::activated),
|
||||
this, &TerminalEditor::orientationEdited);
|
||||
m_editor_connections << connect(ui->m_name_le, &QLineEdit::editingFinished,
|
||||
this, &TerminalEditor::nameEdited);
|
||||
m_editor_connections << connect(ui->m_type_cb, QOverload<int>::of(&QComboBox::activated),
|
||||
this, &TerminalEditor::typeEdited);
|
||||
} else {
|
||||
for (auto const & con : qAsConst(m_editor_connections)) {
|
||||
QObject::disconnect(con);
|
||||
}
|
||||
m_editor_connections.clear();
|
||||
}
|
||||
}
|
||||
|
||||
void TerminalEditor::activeChangeConnections(bool active)
|
||||
{
|
||||
if (active)
|
||||
{
|
||||
m_change_connections << connect(m_part, &PartTerminal::xChanged, this, &TerminalEditor::updateForm);
|
||||
m_change_connections << connect(m_part, &PartTerminal::yChanged, this, &TerminalEditor::updateForm);
|
||||
m_change_connections << connect(m_part, &PartTerminal::orientationChanged, this, &TerminalEditor::updateForm);
|
||||
m_change_connections << connect(m_part, &PartTerminal::nameChanged, this, &TerminalEditor::updateForm);
|
||||
m_change_connections << connect(m_part, &PartTerminal::terminalTypeChanged, this, &TerminalEditor::updateForm);
|
||||
} else {
|
||||
for (auto &con : m_change_connections) {
|
||||
QObject::disconnect(con);
|
||||
}
|
||||
m_change_connections.clear();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
Copyright 2006-2021 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 TERMINALEDITOR_H
|
||||
#define TERMINALEDITOR_H
|
||||
|
||||
#include <QWidget>
|
||||
#include "../elementitemeditor.h"
|
||||
|
||||
namespace Ui {
|
||||
class TerminalEditor;
|
||||
}
|
||||
|
||||
class PartTerminal;
|
||||
|
||||
/**
|
||||
* @brief The TerminalEditor class
|
||||
* Provide a widget used to edit the properties of a PartTerminal
|
||||
*/
|
||||
class TerminalEditor : public ElementItemEditor
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TerminalEditor(QETElementEditor *editor, QWidget *parent = nullptr);
|
||||
~TerminalEditor() override;
|
||||
|
||||
void updateForm() override;
|
||||
bool setPart(CustomElementPart *new_part) override;
|
||||
CustomElementPart *currentPart() const override;
|
||||
QList<CustomElementPart *> currentParts() const override {return QList<CustomElementPart *>();}
|
||||
|
||||
private:
|
||||
void init();
|
||||
void posEdited();
|
||||
void orientationEdited();
|
||||
void nameEdited();
|
||||
void typeEdited();
|
||||
void activeConnections(bool active);
|
||||
void activeChangeConnections(bool active);
|
||||
|
||||
private:
|
||||
Ui::TerminalEditor *ui;
|
||||
QVector<QMetaObject::Connection> m_editor_connections,
|
||||
m_change_connections;
|
||||
PartTerminal *m_part = nullptr;
|
||||
bool m_locked = false;
|
||||
};
|
||||
|
||||
#endif // TERMINALEDITOR_H
|
||||
@@ -0,0 +1,98 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>TerminalEditor</class>
|
||||
<widget class="QWidget" name="TerminalEditor">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>511</width>
|
||||
<height>236</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>y :</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QDoubleSpinBox" name="m_x_dsb">
|
||||
<property name="minimum">
|
||||
<double>-5000.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>5000.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QDoubleSpinBox" name="m_y_dsb">
|
||||
<property name="minimum">
|
||||
<double>-5000.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>5000.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Orientation :</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QLineEdit" name="m_name_le"/>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="m_orientation_cb"/>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>x :</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Nom :</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Type :</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QComboBox" name="m_type_cb"/>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<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>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -53,31 +53,6 @@ ElementsCollectionCache::ElementsCollectionCache(const QString &database_path, Q
|
||||
cache_db_.exec("PRAGMA synchronous = OFF");
|
||||
|
||||
#if TODO_LIST
|
||||
#pragma message("@TODO This code remove old table with mtime for create table with uuid, created at version 0,5")
|
||||
#endif
|
||||
//TODO This code remove old table with mtime for create table with uuid, created at version 0,5
|
||||
//see to remove this code at version 0,6 or 0,7 when all users will table with uuid.
|
||||
#if TODO_LIST
|
||||
#pragma message("@TODO remove this code for qet 0.6 or later")
|
||||
#endif
|
||||
QSqlQuery table_name(cache_db_);
|
||||
if (table_name.exec("PRAGMA table_info(names)"))
|
||||
{
|
||||
if (table_name.seek(2))
|
||||
{
|
||||
QString str = table_name.value(1).toString();
|
||||
table_name.finish();
|
||||
if (str == "mtime")
|
||||
{
|
||||
QSqlQuery error;
|
||||
error = cache_db_.exec("DROP TABLE names");
|
||||
error = cache_db_.exec("DROP TABLE pixmaps");
|
||||
}
|
||||
}
|
||||
else
|
||||
table_name.finish();
|
||||
}
|
||||
#if TODO_LIST
|
||||
#pragma message("@TODO the tables could already exist, handle that case.")
|
||||
#endif
|
||||
//@TODO the tables could already exist, handle that case.
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#include "elementspanelwidget.h"
|
||||
|
||||
#include "diagram.h"
|
||||
#include "editor/qetelementeditor.h"
|
||||
#include "editor/ui/qetelementeditor.h"
|
||||
#include "elementscategoryeditor.h"
|
||||
#include "qetapp.h"
|
||||
#include "qeticons.h"
|
||||
|
||||
+2
-17
@@ -18,10 +18,10 @@
|
||||
#include "machine_info.h"
|
||||
#include "qet.h"
|
||||
#include "qetapp.h"
|
||||
#include "singleapplication.h"
|
||||
#include "utils/macosxopenevent.h"
|
||||
|
||||
#include <QStyleFactory>
|
||||
#include <QApplication>
|
||||
|
||||
/**
|
||||
@brief myMessageOutput
|
||||
@@ -174,7 +174,7 @@ int main(int argc, char **argv)
|
||||
#pragma message("@TODO remove code for QT 6 or later")
|
||||
#endif
|
||||
#endif
|
||||
SingleApplication app(argc, argv, true);
|
||||
QApplication app(argc, argv, true);
|
||||
#ifdef Q_OS_MACOS
|
||||
//Handle the opening of QET when user double click on a .qet .elmt .tbt file
|
||||
//or drop these same files to the QET icon of the dock
|
||||
@@ -182,23 +182,8 @@ int main(int argc, char **argv)
|
||||
app.installEventFilter(&open_event);
|
||||
app.setStyle(QStyleFactory::create("Fusion"));
|
||||
#endif
|
||||
|
||||
if (app.isSecondary())
|
||||
{
|
||||
QStringList arg_list = app.arguments();
|
||||
//Remove the first argument, it's the binary file
|
||||
arg_list.takeFirst();
|
||||
QETArguments qetarg(arg_list);
|
||||
QString message = "launched-with-args: " + QET::joinWithSpaces(
|
||||
QStringList(qetarg.arguments()));
|
||||
app.sendMessage(message.toUtf8());
|
||||
return 0;
|
||||
}
|
||||
|
||||
QETApp qetapp;
|
||||
QETApp::instance()->installEventFilter(&qetapp);
|
||||
QObject::connect(&app, &SingleApplication::receivedMessage,
|
||||
&qetapp, &QETApp::receiveMessage);
|
||||
|
||||
// for debugging
|
||||
qInstallMessageHandler(myMessageOutput);
|
||||
|
||||
@@ -20,10 +20,14 @@
|
||||
#include "ElementsCollection/elementcollectionitem.h"
|
||||
#include "ElementsCollection/elementscollectionmodel.h"
|
||||
#include "NameList/ui/namelistwidget.h"
|
||||
#include "editor/qetelementeditor.h"
|
||||
#include "editor/ui/qetelementeditor.h"
|
||||
#include "qetmessagebox.h"
|
||||
#include "qfilenameedit.h"
|
||||
|
||||
#include <QTreeView>
|
||||
#include <QVBoxLayout>
|
||||
#include <QLabel>
|
||||
|
||||
/**
|
||||
Constructeur
|
||||
@param parent QWidget parent de ce dialogue
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include "autoNum/assignvariables.h"
|
||||
#include "diagram.h"
|
||||
#include "diagramview.h"
|
||||
#include "editor/qetelementeditor.h"
|
||||
#include "editor/ui/qetelementeditor.h"
|
||||
#include "exportdialog.h"
|
||||
#include "qetapp.h"
|
||||
#include "qeticons.h"
|
||||
|
||||
@@ -0,0 +1,406 @@
|
||||
/*
|
||||
Copyright 2006-2021 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 "elementdata.h"
|
||||
#include "../qetxml.h"
|
||||
#include <QDebug>
|
||||
|
||||
void ElementData::toSettings(QSettings &settings, const QString prefix) const {
|
||||
Q_UNUSED(settings)
|
||||
Q_UNUSED(prefix)
|
||||
}
|
||||
|
||||
void ElementData::fromSettings(const QSettings &settings, const QString prefix) {
|
||||
Q_UNUSED(settings)
|
||||
Q_UNUSED(prefix)
|
||||
}
|
||||
|
||||
QDomElement ElementData::toXml(QDomDocument &xml_element) const {
|
||||
Q_UNUSED(xml_element)
|
||||
return QDomElement();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ElementData::fromXml
|
||||
* load properties from xml element.
|
||||
* The tag name of xml_element must be definition
|
||||
* and have an attribute "type"
|
||||
* @param xml_element : tagName must be 'definition'
|
||||
* @return true is successfuly loaded
|
||||
*/
|
||||
bool ElementData::fromXml(const QDomElement &xml_element)
|
||||
{
|
||||
if(xml_element.tagName() != "definition" ||
|
||||
xml_element.attribute("type") != "element") {
|
||||
return false;
|
||||
}
|
||||
|
||||
m_type = typeFromString(xml_element.attribute("link_type", "simple"));
|
||||
kindInfoFromXml(xml_element);
|
||||
m_informations.fromXml(xml_element.firstChildElement("elementInformations"),
|
||||
"elementInformation");
|
||||
m_names_list.fromXml(xml_element);
|
||||
|
||||
auto xml_draw_info = xml_element.firstChildElement("informations");
|
||||
if(xml_draw_info.tagName() == "informations") {
|
||||
m_drawing_information = xml_draw_info.text();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
QDomElement ElementData::kindInfoToXml(QDomDocument &document)
|
||||
{
|
||||
//kindInformations
|
||||
auto returned_elmt = document.createElement("kindInformations");
|
||||
|
||||
if (m_type == ElementData::Master)
|
||||
{
|
||||
auto xml_type = document.createElement("kindInformation");
|
||||
xml_type.setAttribute("name", "type");
|
||||
auto type_txt = document.createTextNode(masterTypeToString(m_master_type));
|
||||
xml_type.appendChild(type_txt);
|
||||
|
||||
returned_elmt.appendChild(xml_type);
|
||||
}
|
||||
else if (m_type == ElementData::Slave)
|
||||
{
|
||||
//type
|
||||
auto xml_type = document.createElement("kindInformation");
|
||||
xml_type.setAttribute("name", "type");
|
||||
auto type_txt = document.createTextNode(slaveTypeToString(m_slave_type));
|
||||
xml_type.appendChild(type_txt);
|
||||
returned_elmt.appendChild(xml_type);
|
||||
|
||||
//state
|
||||
auto xml_state = document.createElement("kindInformation");
|
||||
xml_state.setAttribute("name", "state");
|
||||
auto state_txt = document.createTextNode(slaveStateToString(m_slave_state));
|
||||
xml_state.appendChild(state_txt);
|
||||
|
||||
returned_elmt.appendChild(xml_state);
|
||||
|
||||
//contact count
|
||||
auto xml_count = document.createElement("kindInformation");
|
||||
xml_count.setAttribute("name", "number");
|
||||
auto count_txt = document.createTextNode(QString::number(m_contact_count));
|
||||
xml_count.appendChild(count_txt);
|
||||
|
||||
returned_elmt.appendChild(xml_count);
|
||||
}
|
||||
else if (m_type == ElementData::Terminale)
|
||||
{
|
||||
//type
|
||||
auto xml_type = document.createElement("kindInformation");
|
||||
xml_type.setAttribute("name", "type");
|
||||
auto type_txt = document.createTextNode(terminalTypeToString(m_terminal_type));
|
||||
xml_type.appendChild(type_txt);
|
||||
returned_elmt.appendChild(xml_type);
|
||||
|
||||
//function
|
||||
auto xml_func = document.createElement("kindInformation");
|
||||
xml_func.setAttribute("name", "function");
|
||||
auto func_txt = document.createTextNode(terminalFunctionToString(m_terminal_function));
|
||||
xml_func.appendChild(func_txt);
|
||||
returned_elmt.appendChild(xml_func);
|
||||
}
|
||||
|
||||
return returned_elmt;
|
||||
}
|
||||
|
||||
bool ElementData::operator==(const ElementData &data) const
|
||||
{
|
||||
if (data.m_type != m_type) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (data.m_type == ElementData::Master) {
|
||||
if(data.m_master_type != m_master_type) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (data.m_type == ElementData::Slave) {
|
||||
if (data.m_slave_state != m_slave_state ||
|
||||
data.m_slave_type != m_slave_type ||
|
||||
data.m_contact_count != m_contact_count) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (data.m_type == ElementData::Terminale) {
|
||||
if (data.m_terminal_type != m_terminal_type ||
|
||||
data.m_terminal_function != m_terminal_function) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(data.m_informations != m_informations) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (data.m_names_list != m_names_list) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_drawing_information != m_drawing_information) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ElementData::operator !=(const ElementData &data) const {
|
||||
return !(*this == data);
|
||||
}
|
||||
|
||||
QString ElementData::typeToString(ElementData::Type type)
|
||||
{
|
||||
switch (type) {
|
||||
case ElementData::Simple :
|
||||
return QString("simple");
|
||||
case ElementData::NextReport :
|
||||
return QString ("next_report");
|
||||
case ElementData::PreviousReport :
|
||||
return QString("previous_report");
|
||||
case ElementData::Master :
|
||||
return QString("master");
|
||||
case ElementData::Slave :
|
||||
return QString("slave");
|
||||
case ElementData::Terminale :
|
||||
return QString("terminal");
|
||||
default:
|
||||
qDebug() << "ElementData::typeToString : type don't exist"
|
||||
<< "return failsafe value 'simple'";
|
||||
return QString("simple");
|
||||
}
|
||||
}
|
||||
|
||||
ElementData::Type ElementData::typeFromString(const QString &string)
|
||||
{
|
||||
if (string == "simple") {
|
||||
return ElementData::Simple;
|
||||
} else if (string == "next_report") {
|
||||
return ElementData::NextReport;
|
||||
} else if (string == "previous_report") {
|
||||
return ElementData::PreviousReport;
|
||||
} else if (string == "master") {
|
||||
return ElementData::Master;
|
||||
} else if (string == "slave") {
|
||||
return ElementData::Slave;
|
||||
} else if (string == "terminal") {
|
||||
return ElementData::Terminale;
|
||||
}
|
||||
|
||||
//Return simple if nothing match
|
||||
qDebug() << "ElementData::typeFromString : string "
|
||||
<< string
|
||||
<< " don't exist, return failsafe value 'simple";
|
||||
return ElementData::Simple;
|
||||
}
|
||||
|
||||
QString ElementData::masterTypeToString(ElementData::MasterType type)
|
||||
{
|
||||
switch (type) {
|
||||
case ElementData::Coil:
|
||||
return QString ("coil");
|
||||
case ElementData::Protection:
|
||||
return QString ("protection");
|
||||
case ElementData::Commutator:
|
||||
return QString ("commutator");
|
||||
}
|
||||
}
|
||||
|
||||
ElementData::MasterType ElementData::masterTypeFromString(const QString &string)
|
||||
{
|
||||
if (string == "coil") {
|
||||
return ElementData::Coil;
|
||||
} else if (string == "protection") {
|
||||
return ElementData::Protection;
|
||||
} else if (string == "commutator") {
|
||||
return ElementData::Commutator;
|
||||
}
|
||||
|
||||
qDebug() << "ElementData::masterTypeFromString : string "
|
||||
<< string
|
||||
<< " don't exist, return failsafe value 'coil'";
|
||||
return ElementData::Coil;
|
||||
}
|
||||
|
||||
QString ElementData::slaveTypeToString(ElementData::SlaveType type)
|
||||
{
|
||||
switch (type) {
|
||||
case ElementData::SSimple:
|
||||
return QString ("simple");
|
||||
case ElementData::Power:
|
||||
return QString ("power");
|
||||
case ElementData::DelayOn:
|
||||
return QString("delayOn");
|
||||
case ElementData::DelayOff:
|
||||
return QString("delayOff");
|
||||
case ElementData::delayOnOff:
|
||||
return QString("delayOnOff");
|
||||
}
|
||||
}
|
||||
|
||||
ElementData::SlaveType ElementData::slaveTypeFromString(const QString &string)
|
||||
{
|
||||
if (string == "simple") {
|
||||
return ElementData::SSimple;
|
||||
} else if (string == "power") {
|
||||
return ElementData::Power;
|
||||
} else if (string == "delayOn") {
|
||||
return ElementData::DelayOn;
|
||||
} else if (string == "delayOff") {
|
||||
return ElementData::DelayOff;
|
||||
} else if (string == "delayOnOff") {
|
||||
return ElementData::delayOnOff;
|
||||
}
|
||||
|
||||
qDebug() << "ElementData::slaveTypeFromSting : string "
|
||||
<< string
|
||||
<< " don't exist, return failsafe value 'simple'";
|
||||
return ElementData::SSimple;
|
||||
}
|
||||
|
||||
QString ElementData::slaveStateToString(ElementData::SlaveState type)
|
||||
{
|
||||
switch (type) {
|
||||
case NO:
|
||||
return QString("NO");
|
||||
case NC:
|
||||
return QString("NC");
|
||||
case SW:
|
||||
return QString("SW");
|
||||
}
|
||||
}
|
||||
|
||||
ElementData::SlaveState ElementData::slaveStateFromString(const QString &string)
|
||||
{
|
||||
if (string == "NO") {
|
||||
return ElementData::NO;
|
||||
} else if (string == "NC") {
|
||||
return ElementData::NC;
|
||||
} else if (string == "SW") {
|
||||
return ElementData::SW;
|
||||
}
|
||||
|
||||
qDebug() << "ElementData::slaveStateFromString : string : "
|
||||
<< string
|
||||
<< " don't exist, return failsafe value 'NO'";
|
||||
return ElementData::NO;
|
||||
}
|
||||
|
||||
QString ElementData::terminalTypeToString(ElementData::TerminalType type)
|
||||
{
|
||||
switch (type) {
|
||||
case ElementData::TTGeneric :
|
||||
return QString("generic");
|
||||
case ElementData::Fuse :
|
||||
return QString("fuse");
|
||||
case ElementData::Sectional:
|
||||
return QString("sectional");
|
||||
case ElementData::Diode:
|
||||
return QString("diode");
|
||||
}
|
||||
}
|
||||
|
||||
ElementData::TerminalType ElementData::terminalTypeFromString(const QString &string)
|
||||
{
|
||||
if (string == "generic") {
|
||||
return ElementData::TTGeneric;
|
||||
} else if (string == "fuse") {
|
||||
return ElementData::Fuse;
|
||||
} else if (string == "sectional") {
|
||||
return ElementData::Sectional;
|
||||
} else if (string == "diode") {
|
||||
return ElementData::Diode;
|
||||
}
|
||||
|
||||
qDebug() << "ElementData::terminalTypeFromString : string : "
|
||||
<< string
|
||||
<< " don't exist, return failsafe value 'generic'";
|
||||
return ElementData::TTGeneric;
|
||||
}
|
||||
|
||||
QString ElementData::terminalFunctionToString(ElementData::TerminalFunction function)
|
||||
{
|
||||
switch (function) {
|
||||
case ElementData::TFGeneric:
|
||||
return QString("generic");
|
||||
case ElementData::Phase:
|
||||
return QString ("phase");
|
||||
case ElementData::Neutral:
|
||||
return QString("neutral");
|
||||
case ElementData::PE:
|
||||
return QString("pe");
|
||||
}
|
||||
}
|
||||
|
||||
ElementData::TerminalFunction ElementData::terminalFunctionFromString(const QString &string)
|
||||
{
|
||||
if (string == "generic") {
|
||||
return ElementData::TFGeneric;
|
||||
} else if (string == "phase") {
|
||||
return ElementData::Phase;
|
||||
} else if (string == "neutral") {
|
||||
return ElementData::Neutral;
|
||||
} else if (string == "pe") {
|
||||
return ElementData::PE;
|
||||
}
|
||||
|
||||
qDebug() << "ElementData::terminalFunctionFromString : string : "
|
||||
<< string
|
||||
<< " don't exist, return failsafe value 'generic'";
|
||||
return ElementData::TFGeneric;
|
||||
}
|
||||
|
||||
void ElementData::kindInfoFromXml(const QDomElement &xml_element)
|
||||
{
|
||||
if (m_type == ElementData::Master ||
|
||||
m_type == ElementData::Slave ||
|
||||
m_type == ElementData::Terminale)
|
||||
{
|
||||
auto xml_kind = xml_element.firstChildElement("kindInformations");
|
||||
for (const auto &dom_elmt : QETXML::findInDomElement(xml_kind, "kindInformation"))
|
||||
{
|
||||
if (!dom_elmt.hasAttribute("name")) {
|
||||
continue;
|
||||
}
|
||||
auto name = dom_elmt.attribute("name");
|
||||
|
||||
if (m_type == ElementData::Master &&
|
||||
name == "type") {
|
||||
m_master_type = masterTypeFromString(dom_elmt.text());
|
||||
}
|
||||
else if (m_type == ElementData::Slave ) {
|
||||
if (name == "type") {
|
||||
m_slave_type = slaveTypeFromString(dom_elmt.text());
|
||||
} else if (name == "state") {
|
||||
m_slave_state = slaveStateFromString(dom_elmt.text());
|
||||
} else if (name == "number") {
|
||||
m_contact_count = dom_elmt.text().toInt();
|
||||
}
|
||||
}
|
||||
else if (m_type == ElementData::Terminale) {
|
||||
if (name == "type") {
|
||||
m_terminal_type = terminalTypeFromString(dom_elmt.text());
|
||||
} else if (name == "function") {
|
||||
m_terminal_function = terminalFunctionFromString(dom_elmt.text());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
/*
|
||||
Copyright 2006-2021 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 ELEMENTDATA_H
|
||||
#define ELEMENTDATA_H
|
||||
|
||||
#include "propertiesinterface.h"
|
||||
#include "../diagramcontext.h"
|
||||
#include "../NameList/nameslist.h"
|
||||
|
||||
/**
|
||||
* @brief The ElementData class
|
||||
* WARNING
|
||||
* This class inherit from PropertiesInterface but
|
||||
* only fromXml is actually reimplemented.
|
||||
*/
|
||||
class ElementData : public PropertiesInterface
|
||||
{
|
||||
Q_GADGET
|
||||
|
||||
public:
|
||||
enum Type {
|
||||
Simple = 1,
|
||||
NextReport = 2,
|
||||
PreviousReport = 4,
|
||||
AllReport = 6,
|
||||
Master = 8,
|
||||
Slave = 16,
|
||||
Terminale = 32};
|
||||
Q_ENUM(Type)
|
||||
|
||||
enum MasterType {
|
||||
Coil,
|
||||
Protection,
|
||||
Commutator
|
||||
};
|
||||
Q_ENUM(MasterType)
|
||||
|
||||
enum SlaveType {
|
||||
SSimple,
|
||||
Power,
|
||||
DelayOn,
|
||||
DelayOff,
|
||||
delayOnOff
|
||||
};
|
||||
Q_ENUM(SlaveType)
|
||||
|
||||
enum SlaveState {
|
||||
NO,
|
||||
NC,
|
||||
SW
|
||||
};
|
||||
Q_ENUM(SlaveState)
|
||||
|
||||
enum TerminalType {
|
||||
TTGeneric,
|
||||
Fuse,
|
||||
Sectional,
|
||||
Diode
|
||||
};
|
||||
Q_ENUM(TerminalType)
|
||||
|
||||
enum TerminalFunction {
|
||||
TFGeneric,
|
||||
Phase,
|
||||
Neutral,
|
||||
PE
|
||||
};
|
||||
Q_ENUM(TerminalFunction)
|
||||
|
||||
ElementData() {}
|
||||
~ElementData() override {}
|
||||
|
||||
void toSettings(QSettings &settings, const QString prefix = QString()) const override;
|
||||
void fromSettings(const QSettings &settings, const QString prefix = QString()) override;
|
||||
QDomElement toXml(QDomDocument &xml_element) const override;
|
||||
bool fromXml(const QDomElement &xml_element) override;
|
||||
QDomElement kindInfoToXml(QDomDocument &document);
|
||||
|
||||
bool operator==(const ElementData &data) const;
|
||||
bool operator!=(const ElementData &data) const;
|
||||
|
||||
static QString typeToString(ElementData::Type type);
|
||||
static ElementData::Type typeFromString(const QString &string);
|
||||
|
||||
static QString masterTypeToString(ElementData::MasterType type);
|
||||
static ElementData::MasterType masterTypeFromString(const QString &string);
|
||||
|
||||
static QString slaveTypeToString (ElementData::SlaveType type);
|
||||
static ElementData::SlaveType slaveTypeFromString(const QString &string);
|
||||
|
||||
static QString slaveStateToString(ElementData::SlaveState type);
|
||||
static ElementData::SlaveState slaveStateFromString(const QString &string);
|
||||
|
||||
static QString terminalTypeToString(ElementData::TerminalType type);
|
||||
static ElementData::TerminalType terminalTypeFromString(const QString &string);
|
||||
|
||||
static QString terminalFunctionToString(ElementData::TerminalFunction function);
|
||||
static ElementData::TerminalFunction terminalFunctionFromString(const QString &string);
|
||||
|
||||
// must be public, because this class is a private member
|
||||
// of Element/ element editor and they must access this data
|
||||
ElementData::Type m_type = ElementData::Simple;
|
||||
|
||||
ElementData::MasterType m_master_type = ElementData::Coil;
|
||||
|
||||
ElementData::SlaveType m_slave_type = ElementData::SSimple;
|
||||
ElementData::SlaveState m_slave_state = ElementData::NO;
|
||||
|
||||
ElementData::TerminalType m_terminal_type = ElementData::TTGeneric;
|
||||
ElementData::TerminalFunction m_terminal_function = ElementData::TFGeneric;
|
||||
|
||||
int m_contact_count = 1;
|
||||
DiagramContext m_informations;
|
||||
NamesList m_names_list;
|
||||
QString m_drawing_information;
|
||||
|
||||
private:
|
||||
void kindInfoFromXml(const QDomElement &xml_element);
|
||||
};
|
||||
#endif // ELEMENTDATA_H
|
||||
@@ -1,6 +1,24 @@
|
||||
/*
|
||||
Copyright 2006-2021 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 "terminaldata.h"
|
||||
|
||||
#include <QGraphicsObject>
|
||||
#include <QDebug>
|
||||
|
||||
TerminalData::TerminalData():
|
||||
PropertiesInterface()
|
||||
@@ -44,8 +62,8 @@ void TerminalData::setParent(QGraphicsObject* parent)
|
||||
void TerminalData::toSettings(QSettings &settings, const QString prefix) const
|
||||
|
||||
{
|
||||
Q_UNUSED(settings);
|
||||
Q_UNUSED(prefix);
|
||||
Q_UNUSED(settings)
|
||||
Q_UNUSED(prefix)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -58,8 +76,8 @@ void TerminalData::toSettings(QSettings &settings, const QString prefix) const
|
||||
*/
|
||||
void TerminalData::fromSettings(const QSettings &settings, const QString prefix)
|
||||
{
|
||||
Q_UNUSED(settings);
|
||||
Q_UNUSED(prefix);
|
||||
Q_UNUSED(settings)
|
||||
Q_UNUSED(prefix)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -78,20 +96,17 @@ QDomElement TerminalData::toXml(QDomDocument &xml_document) const
|
||||
{
|
||||
QDomElement xml_element = xml_document.createElement("terminal");
|
||||
|
||||
// write the position of the terminal
|
||||
// ecrit la position de la borne
|
||||
xml_element.setAttribute("x", QString("%1").arg(q->scenePos().x()));
|
||||
xml_element.setAttribute("y", QString("%1").arg(q->scenePos().y()));
|
||||
|
||||
// Write name and number to XML
|
||||
xml_element.setAttribute("uuid", m_uuid.toString());
|
||||
xml_element.setAttribute("name", m_name);
|
||||
|
||||
// write the orientation of the terminal
|
||||
// ecrit l'orientation de la borne
|
||||
xml_element.setAttribute("orientation",
|
||||
Qet::orientationToString(m_orientation));
|
||||
|
||||
xml_element.setAttribute("type", typeToString(m_type));
|
||||
|
||||
return(xml_element);
|
||||
}
|
||||
|
||||
@@ -137,5 +152,45 @@ bool TerminalData::fromXml (const QDomElement &xml_element)
|
||||
m_orientation = Qet::orientationFromString(
|
||||
xml_element.attribute("orientation"));
|
||||
|
||||
m_type = typeFromString(xml_element.attribute("type"));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief TerminalData::typeToString
|
||||
* @param type
|
||||
* @return type into a QString
|
||||
*/
|
||||
QString TerminalData::typeToString(TerminalData::Type type)
|
||||
{
|
||||
switch (type) {
|
||||
case Generic:
|
||||
return QString("Generic");
|
||||
case Inner :
|
||||
return QString("Inner");
|
||||
case Outer :
|
||||
return QString("Outer");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief TerminalData::typeFromString
|
||||
* @param string
|
||||
* @return The type describe in string to TerminalData::Type.
|
||||
* if string doesn't describe a type, TerminalData::Generic is returned
|
||||
*/
|
||||
TerminalData::Type TerminalData::typeFromString(const QString &string)
|
||||
{
|
||||
if (string == "Generic") {
|
||||
return TerminalData::Generic;
|
||||
} else if (string == "Inner") {
|
||||
return TerminalData::Inner;
|
||||
} else if (string == "Outer") {
|
||||
return TerminalData::Outer;
|
||||
} else {
|
||||
qDebug() << "TerminalData::typeFromString, argument string is invalid"
|
||||
" failsafe type 'TerminalData::Generic' is returned";
|
||||
return TerminalData::Generic;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
Copyright 2006-2021 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 TERMINALDATA_H
|
||||
#define TERMINALDATA_H
|
||||
|
||||
@@ -18,10 +35,19 @@ class QGraphicsObject;
|
||||
*/
|
||||
class TerminalData : public PropertiesInterface
|
||||
{
|
||||
Q_GADGET
|
||||
|
||||
public:
|
||||
enum Type {
|
||||
Generic,
|
||||
Inner,
|
||||
Outer
|
||||
};
|
||||
Q_ENUM(Type)
|
||||
|
||||
TerminalData();
|
||||
TerminalData(QGraphicsObject* parent);
|
||||
~TerminalData();
|
||||
~TerminalData() override;
|
||||
|
||||
void init();
|
||||
|
||||
@@ -33,6 +59,9 @@ class TerminalData : public PropertiesInterface
|
||||
QDomElement toXml(QDomDocument &xml_element) const override;
|
||||
bool fromXml(const QDomElement &xml_element) override;
|
||||
|
||||
static QString typeToString(TerminalData::Type type);
|
||||
static TerminalData::Type typeFromString(const QString &string);
|
||||
|
||||
// must be public, because this class is a private member
|
||||
// of PartTerminal/Terminal and they must access this data
|
||||
public:
|
||||
@@ -46,7 +75,7 @@ class TerminalData : public PropertiesInterface
|
||||
Position of the second point of the terminal
|
||||
in scene coordinates
|
||||
*/
|
||||
QPointF second_point;
|
||||
QPointF m_second_point;
|
||||
/**
|
||||
@brief m_uuid
|
||||
Uuid of the terminal.
|
||||
@@ -80,6 +109,9 @@ class TerminalData : public PropertiesInterface
|
||||
PartTerminal and Terminal have access to it.
|
||||
*/
|
||||
QPointF m_pos;
|
||||
|
||||
TerminalData::Type m_type = TerminalData::Generic;
|
||||
|
||||
private:
|
||||
QGraphicsObject* q{nullptr};
|
||||
};
|
||||
|
||||
+2
-2
@@ -29,9 +29,9 @@ class QActionGroup;
|
||||
*/
|
||||
namespace QET {
|
||||
/// QElectroTech version (as string, used to mark projects and elements XML documents)
|
||||
const QString version = "0.80";
|
||||
const QString version = "0.90";
|
||||
/// QElectroTech displayed version
|
||||
const QString displayedVersion = "0.80";
|
||||
const QString displayedVersion = "0.90-DEV";
|
||||
QString license();
|
||||
|
||||
//Describe the current state of a graphic item
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@
|
||||
|
||||
#include "configdialog.h"
|
||||
#include "configpages.h"
|
||||
#include "editor/qetelementeditor.h"
|
||||
#include "editor/ui/qetelementeditor.h"
|
||||
#include "elementscollectioncache.h"
|
||||
#include "factory/elementfactory.h"
|
||||
#include "factory/elementpicturefactory.h"
|
||||
|
||||
@@ -464,8 +464,8 @@ bool Element::buildFromXml(const QDomElement &xml_def_elmt, int *state)
|
||||
m_state = QET::GIOK;
|
||||
return(false);
|
||||
}
|
||||
//Extract the names
|
||||
m_names.fromXml(xml_def_elmt);
|
||||
|
||||
m_data.fromXml(xml_def_elmt);
|
||||
setToolTip(name());
|
||||
|
||||
//load kind informations
|
||||
@@ -473,7 +473,7 @@ bool Element::buildFromXml(const QDomElement &xml_def_elmt, int *state)
|
||||
xml_def_elmt.firstChildElement("kindInformations"),
|
||||
"kindInformation");
|
||||
//load element information
|
||||
m_element_informations.fromXml(
|
||||
m_data.m_informations.fromXml(
|
||||
xml_def_elmt.firstChildElement("elementInformations"),
|
||||
"elementInformation");
|
||||
|
||||
@@ -623,7 +623,7 @@ bool Element::parseInput(const QDomElement &dom_element)
|
||||
QString::number(0)).toDouble());
|
||||
transform.translate(p.x(), p.y());
|
||||
deti->setPos(transform.map(pos));
|
||||
m_converted_text_from_xml_description.insert(deti, p);
|
||||
m_dynamic_text_list.append(deti);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -848,99 +848,6 @@ bool Element::fromXml(
|
||||
deti->fromXml(qde);
|
||||
}
|
||||
|
||||
//************************//
|
||||
//***Element texts item***//
|
||||
//************************//
|
||||
QList<QDomElement> inputs = QET::findInDomElement(e, "inputs", "input");
|
||||
|
||||
//First case, we check for the text item converted to dynamic text item
|
||||
const QList <DynamicElementTextItem *> conv_deti_list =
|
||||
m_converted_text_from_xml_description.keys();
|
||||
QList <DynamicElementTextItem *> successfully_converted;
|
||||
const QList <QDomElement> dom_inputs = inputs;
|
||||
|
||||
for (DynamicElementTextItem *deti : conv_deti_list)
|
||||
{
|
||||
for(const QDomElement& dom_input : dom_inputs)
|
||||
{
|
||||
//we use the same method used in ElementTextItem::fromXml
|
||||
//to compar and know if the input dom element is for one of the text stored.
|
||||
//The comparaison is made from the text position :
|
||||
//if the position of the text is the same as the position stored in 'input' dom element
|
||||
//that mean this is the good text
|
||||
if (qFuzzyCompare(qreal(dom_input.attribute("x").toDouble()),
|
||||
m_converted_text_from_xml_description.value(deti).x()) &&
|
||||
qFuzzyCompare(qreal(dom_input.attribute("y").toDouble()),
|
||||
m_converted_text_from_xml_description.value(deti).y()))
|
||||
{
|
||||
//Once again this 'if', is only for retrocompatibility with old old old project
|
||||
//when element text with tagg "label" is not null, but the element information "label" is.
|
||||
if((deti->textFrom() == DynamicElementTextItem::ElementInfo)
|
||||
&& (deti->infoName() == "label"))
|
||||
m_element_informations.addValue(
|
||||
"label",
|
||||
dom_input.attribute("text"));
|
||||
|
||||
deti->setText(dom_input.attribute("text"));
|
||||
|
||||
qreal rotation = deti->rotation();
|
||||
QPointF xml_pos = m_converted_text_from_xml_description.value(deti);
|
||||
|
||||
if (dom_input.attribute("userrotation").toDouble())
|
||||
rotation = dom_input.attribute("userrotation").toDouble();
|
||||
|
||||
if (dom_input.hasAttribute("userx"))
|
||||
xml_pos.setX(dom_input.attribute("userx").toDouble());
|
||||
if(dom_input.hasAttribute("usery"))
|
||||
xml_pos.setY(dom_input.attribute("usery", "0").toDouble());
|
||||
|
||||
//the origin transformation point of PartDynamicTextField
|
||||
//is the top left corner, no matter the font size
|
||||
//The origin transformation point of PartTextField
|
||||
//is the middle of left edge, and so by definition,
|
||||
//change with the size of the font
|
||||
//We need to use a QTransform to find the pos of
|
||||
//this text from the saved pos of text item
|
||||
|
||||
deti->setPos(xml_pos);
|
||||
deti->setRotation(rotation);
|
||||
|
||||
QTransform transform;
|
||||
//First make the rotation
|
||||
transform.rotate(rotation);
|
||||
QPointF pos = transform.map(
|
||||
QPointF(0,
|
||||
-deti->boundingRect().height()/2));
|
||||
transform.reset();
|
||||
//Second translate to the pos
|
||||
transform.translate(xml_pos.x(), xml_pos.y());
|
||||
deti->setPos(transform.map(pos));
|
||||
|
||||
//dom_input and deti matched we remove
|
||||
//the dom_input from inputs list,
|
||||
//to avoid unnecessary checking made below
|
||||
//we also move deti from the
|
||||
//m_converted_text_from_xml_description to m_dynamic_text_list
|
||||
inputs.removeAll(dom_input);
|
||||
m_dynamic_text_list.append(deti);
|
||||
m_converted_text_from_xml_description.remove(deti);
|
||||
successfully_converted << deti;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//###Firts case : if this is the first time the user open the project since text item are converted to dynamic text,
|
||||
//in the previous opening of the project, every texts field present in the element description was created.
|
||||
//At save time, the values of each of them was save in the 'input' dom element.
|
||||
//The loop upper is made for the first case, to import the values in 'input' to the new converted dynamic texts field.
|
||||
//###Second case : this is not the first time the user open the project since text item are converted to dynamic text.
|
||||
//That mean, in a previous opening of the project, the text item was already converted and save as a dynamic text field.
|
||||
//So there isn't 'input' dom element in the project, and every dynamic text item present in m_converted_text_from_xml_description
|
||||
//need to be deleted (because already exist in m_dynamic_text_list, from a previous save)
|
||||
for (DynamicElementTextItem *deti : m_converted_text_from_xml_description.keys())
|
||||
delete deti;
|
||||
m_converted_text_from_xml_description.clear();
|
||||
|
||||
for (QDomElement qde : QET::findInDomElement(
|
||||
e,
|
||||
"texts_groups",
|
||||
@@ -955,27 +862,6 @@ bool Element::fromXml(
|
||||
DiagramContext dc;
|
||||
dc.fromXml(e.firstChildElement("elementInformations"),
|
||||
"elementInformation");
|
||||
/*
|
||||
* Since the commit 4791, the value used as "label" and "formula"
|
||||
* is stored in differents keys (instead of the same key,
|
||||
* "label" in previous version), so, if "label" contain "%"
|
||||
* (Use variable value), and "formula" does not exist,
|
||||
* this mean the label was made before commit 4791 (0.51 dev).
|
||||
* So we swap the value stored in "label" to "formula" as expected.
|
||||
* @TODO remove this code at version 0.7 or more (probably useless).
|
||||
*/
|
||||
#if TODO_LIST
|
||||
#pragma message("@TODO remove this code for qet 0.7 or later")
|
||||
#endif
|
||||
if (dc["label"].toString().contains("%")
|
||||
&& dc["formula"].toString().isNull())
|
||||
{
|
||||
dc.addValue("formula", dc["label"]);
|
||||
}
|
||||
//retrocompatibility with older version
|
||||
if(dc.value("label").toString().isEmpty() &&
|
||||
!m_element_informations.value("label").toString().isEmpty())
|
||||
dc.addValue("label", m_element_informations.value("label"));
|
||||
|
||||
//We must to block the update of the alignment when load the information
|
||||
//otherwise the pos of the text will not be the same as it was at save time.
|
||||
@@ -985,181 +871,6 @@ bool Element::fromXml(
|
||||
for(DynamicElementTextItem *deti : m_dynamic_text_list)
|
||||
deti->m_block_alignment = false;
|
||||
|
||||
|
||||
/* During the devel of the version 0.7,
|
||||
* the "old text" was replaced by the dynamic element text item.
|
||||
* When open a project made befor the 0.7,
|
||||
* we must to reproduce the same visual when
|
||||
* the label are not empty and visible,
|
||||
* and comment are not empty
|
||||
* and visible and/or location are not empty and visible.
|
||||
* we create a text group with inside the needed texts,
|
||||
* label and comment and/or location.
|
||||
*/
|
||||
//#1 There must be old text converted to dynamic text
|
||||
if(!successfully_converted.isEmpty())
|
||||
{
|
||||
//#2 the element information must have label not empty and visible
|
||||
//and a least comment or location not empty and visible
|
||||
QString label = m_element_informations.value(
|
||||
"label").toString();
|
||||
QString comment = m_element_informations.value(
|
||||
"comment").toString();
|
||||
QString location = m_element_informations.value(
|
||||
"location").toString();
|
||||
bool la = m_element_informations.keyMustShow("label");
|
||||
bool c = m_element_informations.keyMustShow("comment");
|
||||
bool lo = m_element_informations.keyMustShow("location");
|
||||
|
||||
if((m_link_type != Master) ||
|
||||
((m_link_type == Master) &&
|
||||
(diagram()->project()->defaultXRefProperties(
|
||||
m_kind_informations["type"].toString()).snapTo()
|
||||
== XRefProperties::Label))
|
||||
)
|
||||
{
|
||||
if(!label.isEmpty() && la &&
|
||||
((!comment.isEmpty() && c)
|
||||
|| (!location.isEmpty() && lo)))
|
||||
{
|
||||
//#2 in the converted list one text must have text from = element info and info name = label
|
||||
for(DynamicElementTextItem *deti
|
||||
: successfully_converted)
|
||||
{
|
||||
if(deti->textFrom()== DynamicElementTextItem::ElementInfo
|
||||
&& deti->infoName() == "label")
|
||||
{
|
||||
qDebug() << "see 'Mod overlapping comparisons' in git";
|
||||
qreal rotation = deti->rotation();
|
||||
|
||||
//Create the comment item
|
||||
DynamicElementTextItem *comment_text = nullptr;
|
||||
if (m_link_type != PreviousReport
|
||||
&& m_link_type != NextReport)
|
||||
{
|
||||
m_state = QET::GIOK;
|
||||
return(true);
|
||||
}
|
||||
if(!comment.isEmpty() && c)
|
||||
{
|
||||
comment_text = new DynamicElementTextItem(this);
|
||||
comment_text->setTextFrom(DynamicElementTextItem::ElementInfo);
|
||||
comment_text->setInfoName("comment");
|
||||
QFont font = comment_text->font();
|
||||
font.setPointSize(6);
|
||||
comment_text->setFont(font);
|
||||
comment_text->setFrame(true);
|
||||
if(comment_text->toPlainText().count() > 17)
|
||||
comment_text->setTextWidth(80);
|
||||
comment_text->setPos(deti->x(), deti->y()+10); //+10 is arbitrary, comment_text must be below deti
|
||||
addDynamicTextItem(comment_text);
|
||||
}
|
||||
//create the location item
|
||||
DynamicElementTextItem *location_text = nullptr;
|
||||
if (m_link_type != PreviousReport
|
||||
&& m_link_type != NextReport)
|
||||
{
|
||||
m_state = QET::GIOK;
|
||||
return(true);
|
||||
}
|
||||
if(!location.isEmpty() && lo)
|
||||
{
|
||||
location_text = new DynamicElementTextItem(this);
|
||||
location_text->setTextFrom(DynamicElementTextItem::ElementInfo);
|
||||
location_text->setInfoName("location");
|
||||
QFont font = location_text->font();
|
||||
font.setPointSize(6);
|
||||
location_text->setFont(font);
|
||||
if(location_text->toPlainText().count() > 17)
|
||||
location_text->setTextWidth(80);
|
||||
location_text->setPos(deti->x(), deti->y()+20); //+20 is arbitrary, location_text must be below deti and comment
|
||||
addDynamicTextItem(location_text);
|
||||
}
|
||||
|
||||
QPointF pos = deti->pos();
|
||||
if (m_link_type != PreviousReport
|
||||
&& m_link_type != NextReport)
|
||||
{
|
||||
m_state = QET::GIOK;
|
||||
return(true);
|
||||
}
|
||||
//Create the group
|
||||
ElementTextItemGroup *group =
|
||||
addTextGroup(tr("Label + commentaire"));
|
||||
addTextToGroup(deti, group);
|
||||
if(comment_text)
|
||||
addTextToGroup(comment_text,
|
||||
group);
|
||||
if(location_text)
|
||||
addTextToGroup(location_text,
|
||||
group);
|
||||
group->setAlignment(Qt::AlignVCenter);
|
||||
group->setVerticalAdjustment(-4);
|
||||
group->setRotation(rotation);
|
||||
//Change the position of the group,
|
||||
//so that the text "label" stay in the same
|
||||
//position in scene coordinate
|
||||
group->setPos(pos - deti->pos());
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//This element is supposed to be a master and Xref property snap to bottom
|
||||
if((!comment.isEmpty() && c) || (!location.isEmpty() && lo))
|
||||
{
|
||||
//Create the comment item
|
||||
DynamicElementTextItem *comment_text = nullptr;
|
||||
if(!comment.isEmpty() && c)
|
||||
{
|
||||
comment_text = new DynamicElementTextItem(this);
|
||||
comment_text
|
||||
->setTextFrom(
|
||||
DynamicElementTextItem::ElementInfo);
|
||||
comment_text->setInfoName("comment");
|
||||
QFont font = comment_text->font();
|
||||
font.setPointSize(6);
|
||||
comment_text->setFont(font);
|
||||
comment_text->setFrame(true);
|
||||
comment_text->setTextWidth(80);
|
||||
addDynamicTextItem(comment_text);
|
||||
}
|
||||
//create the location item
|
||||
DynamicElementTextItem *location_text = nullptr;
|
||||
if(!location.isEmpty() && lo)
|
||||
{
|
||||
location_text = new DynamicElementTextItem(this);
|
||||
location_text
|
||||
->setTextFrom(
|
||||
DynamicElementTextItem::ElementInfo);
|
||||
location_text->setInfoName("location");
|
||||
QFont font = location_text->font();
|
||||
font.setPointSize(6);
|
||||
location_text->setFont(font);
|
||||
location_text->setTextWidth(80);
|
||||
if(comment_text)
|
||||
location_text->setPos(
|
||||
comment_text->x(),
|
||||
comment_text->y()+10); //+10 is arbitrary, location_text must be below the comment
|
||||
addDynamicTextItem(location_text);
|
||||
}
|
||||
|
||||
//Create the group
|
||||
ElementTextItemGroup *group =
|
||||
addTextGroup(tr("Label + commentaire"));
|
||||
if(comment_text)
|
||||
addTextToGroup(comment_text, group);
|
||||
if(location_text)
|
||||
addTextToGroup(location_text, group);
|
||||
group->setAlignment(Qt::AlignVCenter);
|
||||
group->setVerticalAdjustment(-4);
|
||||
group->setHoldToBottomPage(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
m_state = QET::GIOK;
|
||||
return(true);
|
||||
}
|
||||
@@ -1254,10 +965,10 @@ QDomElement Element::toXml(
|
||||
}
|
||||
|
||||
//save information of this element
|
||||
if (! m_element_informations.keys().isEmpty()) {
|
||||
if (! m_data.m_informations.keys().isEmpty()) {
|
||||
QDomElement infos =
|
||||
document.createElement("elementInformations");
|
||||
m_element_informations.toXml(infos, "elementInformation");
|
||||
m_data.m_informations.toXml(infos, "elementInformation");
|
||||
element.appendChild(infos);
|
||||
}
|
||||
|
||||
@@ -1601,14 +1312,23 @@ QString Element::linkTypeToString() const
|
||||
*/
|
||||
void Element::setElementInformations(DiagramContext dc)
|
||||
{
|
||||
if (m_element_informations == dc) {
|
||||
if (m_data.m_informations == dc) {
|
||||
return;
|
||||
}
|
||||
|
||||
DiagramContext old_info = m_element_informations;
|
||||
m_element_informations = dc;
|
||||
m_element_informations.addValue("label", actualLabel()); //Update the label if there is a formula
|
||||
emit elementInfoChange(old_info, m_element_informations);
|
||||
DiagramContext old_info = m_data.m_informations;
|
||||
m_data.m_informations = dc;
|
||||
m_data.m_informations.addValue("label", actualLabel()); //Update the label if there is a formula
|
||||
emit elementInfoChange(old_info, m_data.m_informations);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Element::elementData
|
||||
* @return the element data used by this element
|
||||
*/
|
||||
ElementData Element::elementData() const
|
||||
{
|
||||
return m_data;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1722,7 +1442,7 @@ void Element::setUpFormula(bool code_letter)
|
||||
->project()
|
||||
->elementAutoNumCurrentFormula();
|
||||
|
||||
m_element_informations.addValue("formula", formula);
|
||||
m_data.m_informations.addValue("formula", formula);
|
||||
|
||||
QString element_currentAutoNum = diagram()
|
||||
->project()
|
||||
@@ -1743,9 +1463,9 @@ void Element::setUpFormula(bool code_letter)
|
||||
|
||||
if(!m_freeze_label && !formula.isEmpty())
|
||||
{
|
||||
DiagramContext dc = m_element_informations;
|
||||
m_element_informations.addValue("label", actualLabel());
|
||||
emit elementInfoChange(dc, m_element_informations);
|
||||
DiagramContext dc = m_data.m_informations;
|
||||
m_data.m_informations.addValue("label", actualLabel());
|
||||
emit elementInfoChange(dc, m_data.m_informations);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1798,11 +1518,11 @@ void Element::freezeNewAddedElement()
|
||||
*/
|
||||
QString Element::actualLabel()
|
||||
{
|
||||
if (m_element_informations.value("formula").toString().isEmpty()) {
|
||||
return m_element_informations.value("label").toString();
|
||||
if (m_data.m_informations.value("formula").toString().isEmpty()) {
|
||||
return m_data.m_informations.value("label").toString();
|
||||
} else {
|
||||
return autonum::AssignVariables::formulaToLabel(
|
||||
m_element_informations.value(
|
||||
m_data.m_informations.value(
|
||||
"formula").toString(),
|
||||
m_autoNum_seq,
|
||||
diagram(),
|
||||
@@ -1814,9 +1534,8 @@ QString Element::actualLabel()
|
||||
@brief Element::name
|
||||
@return the human name of this element
|
||||
*/
|
||||
QString Element::name() const
|
||||
{
|
||||
return m_names.name(m_location.baseName());
|
||||
QString Element::name() const {
|
||||
return m_data.m_names_list.name(m_location.baseName());
|
||||
}
|
||||
|
||||
ElementsLocation Element::location() const
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "../diagramcontext.h"
|
||||
#include "../qet.h"
|
||||
#include "qetgraphicsitem.h"
|
||||
#include "../properties/elementdata.h"
|
||||
|
||||
#include <QHash>
|
||||
#include <QPicture>
|
||||
@@ -100,8 +101,17 @@ class Element : public QetGraphicsItem
|
||||
|
||||
//METHODS related to information
|
||||
DiagramContext elementInformations()const
|
||||
{return m_element_informations;}
|
||||
{return m_data.m_informations;}
|
||||
virtual void setElementInformations(DiagramContext dc);
|
||||
|
||||
ElementData elementData() const;
|
||||
|
||||
/**
|
||||
* @brief kindInformations
|
||||
* @deprecated
|
||||
* use elementData function instead
|
||||
* @return
|
||||
*/
|
||||
DiagramContext kindInformations() const
|
||||
{return m_kind_informations;}
|
||||
//@kind_information_ is used to store more information
|
||||
@@ -164,8 +174,20 @@ class Element : public QetGraphicsItem
|
||||
virtual void unlinkElement(Element *) {}
|
||||
virtual void initLink(QETProject *);
|
||||
QList<Element *> linkedElements ();
|
||||
|
||||
/**
|
||||
* @brief linkType
|
||||
* use elementData function instead
|
||||
* @return
|
||||
*/
|
||||
virtual kind linkType() const {return m_link_type;} // return the linkable type
|
||||
/**
|
||||
* @brief linkTypeToString
|
||||
* use elementData function instead
|
||||
* @return
|
||||
*/
|
||||
QString linkTypeToString() const;
|
||||
|
||||
void newUuid() {m_uuid = QUuid::createUuid();} //create new uuid for this element
|
||||
|
||||
protected:
|
||||
@@ -201,18 +223,6 @@ class Element : public QetGraphicsItem
|
||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent *) override;
|
||||
|
||||
protected:
|
||||
// m_converted_text_from_description,
|
||||
// when a element is created from his description,
|
||||
// the old element text item (tagged as 'input' in the xml)
|
||||
// are converted to dynamic text field,
|
||||
// the QPointF is the original position of the text item,
|
||||
// because the origin transformation point of text item
|
||||
// and dynamic text item are not the same,
|
||||
// so we must to keep a track of this value,
|
||||
// to be use in the function element::fromXml
|
||||
QHash <DynamicElementTextItem *, QPointF>
|
||||
m_converted_text_from_xml_description;
|
||||
|
||||
//ATTRIBUTES related to linked element
|
||||
QList <Element *> connected_elements;
|
||||
QList <QUuid> tmp_uuids_link;
|
||||
@@ -220,16 +230,16 @@ class Element : public QetGraphicsItem
|
||||
kind m_link_type = Element::Simple;
|
||||
|
||||
//ATTRIBUTES related to informations
|
||||
DiagramContext m_element_informations, m_kind_informations;
|
||||
DiagramContext m_kind_informations;
|
||||
autonum::sequentialNumbers m_autoNum_seq;
|
||||
bool m_freeze_label = false;
|
||||
QString m_F_str;
|
||||
|
||||
ElementsLocation m_location;
|
||||
NamesList m_names;
|
||||
QList <Terminal *> m_terminals;
|
||||
const QPicture m_picture;
|
||||
const QPicture m_low_zoom_picture;
|
||||
ElementData m_data;
|
||||
|
||||
private:
|
||||
bool m_must_highlight = false;
|
||||
|
||||
@@ -852,26 +852,8 @@ bool QetShapeItem::fromXml(const QDomElement &e)
|
||||
m_brush = QETXML::brushFromXml(e.firstChildElement("brush"));
|
||||
|
||||
QString type = e.attribute("type");
|
||||
#if TODO_LIST
|
||||
#pragma message("@TODO Compatibility for version older than N°4075, shape type was stored with an int")
|
||||
#endif
|
||||
//@TODO Compatibility for version older than N°4075, shape type was stored with an int
|
||||
if (type.size() == 1)
|
||||
{
|
||||
switch(e.attribute("type","0").toInt())
|
||||
{
|
||||
case 0: m_shapeType = Line; break;
|
||||
case 1: m_shapeType = Rectangle; break;
|
||||
case 2: m_shapeType = Ellipse; break;
|
||||
case 3: m_shapeType = Polygon; break;
|
||||
}
|
||||
}
|
||||
//For version after N°4075, shape is stored with a string
|
||||
else
|
||||
{
|
||||
QMetaEnum me = metaObject()->enumerator(metaObject()->indexOfEnumerator("ShapeType"));
|
||||
m_shapeType = QetShapeItem::ShapeType(me.keysToValue(type.toStdString().data()));
|
||||
}
|
||||
QMetaEnum me = metaObject()->enumerator(metaObject()->indexOfEnumerator("ShapeType"));
|
||||
m_shapeType = QetShapeItem::ShapeType(me.keysToValue(type.toStdString().data()));
|
||||
|
||||
if (m_shapeType != Polygon)
|
||||
{
|
||||
|
||||
@@ -41,138 +41,50 @@ const qreal Terminal::Z = 1000;
|
||||
@param name of terminal
|
||||
@param hiddenName
|
||||
*/
|
||||
void Terminal::init(
|
||||
QString number, QString name, bool hiddenName)
|
||||
void Terminal::init()
|
||||
{
|
||||
hovered_color_ = Terminal::neutralColor;
|
||||
|
||||
// calcul de la position du point d'amarrage a l'element
|
||||
//Calcul the docking point of the element
|
||||
//m_pos of d is the docking point of conductor
|
||||
dock_elmt_ = d->m_pos;
|
||||
switch(d->m_orientation) {
|
||||
case Qet::North: dock_elmt_ += QPointF(0, Terminal::terminalSize); break;
|
||||
case Qet::East : dock_elmt_ += QPointF(-Terminal::terminalSize, 0); break;
|
||||
case Qet::West : dock_elmt_ += QPointF(Terminal::terminalSize, 0); break;
|
||||
case Qet::South:
|
||||
default : dock_elmt_ += QPointF(0, -Terminal::terminalSize);
|
||||
case Qet::South: dock_elmt_ += QPointF(0, -Terminal::terminalSize); break;
|
||||
}
|
||||
// Number of terminal
|
||||
number_terminal_ = std::move(number);
|
||||
// Name of terminal
|
||||
name_terminal_ = std::move(name);
|
||||
name_terminal_hidden = hiddenName;
|
||||
// par defaut : pas de conducteur
|
||||
|
||||
// QRectF null
|
||||
br_ = new QRectF();
|
||||
previous_terminal_ = nullptr;
|
||||
// divers
|
||||
//Calcul the bounding rect
|
||||
qreal dcx = d->m_pos.x();
|
||||
qreal dcy = d->m_pos.y();
|
||||
qreal dex = dock_elmt_.x();
|
||||
qreal dey = dock_elmt_.y();
|
||||
QPointF origin = (dcx <= dex && dcy <= dey ? d->m_pos : dock_elmt_);
|
||||
origin += QPointF(-3.0, -3.0);
|
||||
qreal w = qAbs(dcx - dex) + 7;
|
||||
qreal h = qAbs(dcy - dey) + 7;
|
||||
m_br = QRectF(origin, QSizeF(w, h));
|
||||
|
||||
setAcceptHoverEvents(true);
|
||||
setAcceptedMouseButtons(Qt::LeftButton);
|
||||
hovered_ = false;
|
||||
setToolTip(QObject::tr("Borne", "tooltip"));
|
||||
setZValue(Z);
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Terminal::init
|
||||
Additionaly to the init above, this method stores position and orientation into the data class
|
||||
\param pf
|
||||
\param o
|
||||
\param number
|
||||
\param name
|
||||
\param hiddenName
|
||||
*/
|
||||
void Terminal::init(
|
||||
QPointF pf,
|
||||
Qet::Orientation o,
|
||||
QString number,
|
||||
QString name,
|
||||
bool hiddenName)
|
||||
{
|
||||
// definition du pount d'amarrage pour un conducteur
|
||||
d->m_pos = pf;
|
||||
|
||||
// definition de l'orientation de la borne (par defaut : sud)
|
||||
if (o < Qet::North || o > Qet::West) d->m_orientation = Qet::South;
|
||||
else d->m_orientation = o;
|
||||
|
||||
init(number, name, hiddenName);
|
||||
}
|
||||
|
||||
/**
|
||||
initialise une borne
|
||||
@param pf position du point d'amarrage pour un conducteur
|
||||
@param o orientation de la borne : Qt::Horizontal ou Qt::Vertical
|
||||
@param e Element auquel cette borne appartient
|
||||
*/
|
||||
Terminal::Terminal(QPointF pf, Qet::Orientation o, Element *e) :
|
||||
QGraphicsObject(e),
|
||||
d(new TerminalData(this)),
|
||||
parent_element_ (e)
|
||||
{
|
||||
init(pf, o, "_", "_", false);
|
||||
}
|
||||
|
||||
/**
|
||||
initialise une borne
|
||||
@param pf_x Abscisse du point d'amarrage pour un conducteur
|
||||
@param pf_y Ordonnee du point d'amarrage pour un conducteur
|
||||
@param o orientation de la borne : Qt::Horizontal ou Qt::Vertical
|
||||
@param e Element auquel cette borne appartient
|
||||
*/
|
||||
Terminal::Terminal(qreal pf_x, qreal pf_y, Qet::Orientation o, Element *e) :
|
||||
QGraphicsObject(e),
|
||||
d(new TerminalData(this)),
|
||||
parent_element_ (e)
|
||||
{
|
||||
init(QPointF(pf_x, pf_y), o, "_", "_", false);
|
||||
}
|
||||
|
||||
/**
|
||||
initialise une borne
|
||||
@param pf position du point d'amarrage pour un conducteur
|
||||
@param o orientation de la borne : Qt::Horizontal ou Qt::Vertical
|
||||
@param num number of terminal (ex 3 - 4 for NO)
|
||||
@param name of terminal
|
||||
@param hiddenName hide or show the name
|
||||
@param e Element auquel cette borne appartient
|
||||
*/
|
||||
Terminal::Terminal(
|
||||
QPointF pf,
|
||||
Qet::Orientation o,
|
||||
QString num,
|
||||
QString name,
|
||||
bool hiddenName,
|
||||
Element *e) :
|
||||
QGraphicsObject (e),
|
||||
d(new TerminalData(this)),
|
||||
parent_element_ (e)
|
||||
{
|
||||
init(pf, o, std::move(num), std::move(name), hiddenName);
|
||||
}
|
||||
|
||||
Terminal::Terminal(TerminalData* data, Element* e) :
|
||||
QGraphicsObject(e),
|
||||
d(data),
|
||||
parent_element_(e)
|
||||
{
|
||||
#if TODO_LIST
|
||||
#pragma message("@TODO what is when multiple parents exist. So the other relation is lost.")
|
||||
#endif
|
||||
// TODO: what is when multiple parents exist. So the other relation is lost.
|
||||
d->setParent(this);
|
||||
init("_", "_", false);
|
||||
init();
|
||||
}
|
||||
|
||||
/**
|
||||
Destructeur
|
||||
La destruction de la borne entraine la destruction des conducteurs
|
||||
associes.
|
||||
*/
|
||||
Terminal::~Terminal()
|
||||
{
|
||||
foreach(Conductor *c, conductors_) delete c;
|
||||
delete br_;
|
||||
* @brief Terminal::~Terminal
|
||||
* Destruction of the terminal, and also docked conductor
|
||||
*/
|
||||
Terminal::~Terminal() {
|
||||
qDeleteAll(m_conductors_list);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -198,27 +110,6 @@ Qet::Orientation Terminal::orientation() const
|
||||
} else return(d->m_orientation);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@brief Terminal::setNumber
|
||||
@param number
|
||||
*/
|
||||
void Terminal::setNumber(QString number)
|
||||
{
|
||||
number_terminal_ = std::move(number);
|
||||
}
|
||||
|
||||
/**
|
||||
@brief Terminal::setName
|
||||
@param name : QString
|
||||
@param hiddenName : bool
|
||||
*/
|
||||
void Terminal::setName(QString name, bool hiddenName)
|
||||
{
|
||||
name_terminal_ = std::move(name);
|
||||
name_terminal_hidden = hiddenName;
|
||||
}
|
||||
|
||||
/**
|
||||
@brief Terminal::addConductor
|
||||
Add a conductor to this terminal
|
||||
@@ -238,11 +129,11 @@ bool Terminal::addConductor(Conductor *conductor)
|
||||
? conductor->terminal2 : conductor->terminal1;
|
||||
|
||||
//Check if this terminal isn't already linked with other_terminal
|
||||
foreach (Conductor* cond, conductors_)
|
||||
foreach (Conductor* cond, m_conductors_list)
|
||||
if (cond -> terminal1 == other_terminal || cond -> terminal2 == other_terminal)
|
||||
return false; //They already a conductor linked to this and other_terminal
|
||||
|
||||
conductors_.append(conductor);
|
||||
m_conductors_list.append(conductor);
|
||||
emit conductorWasAdded(conductor);
|
||||
return(true);
|
||||
}
|
||||
@@ -254,9 +145,9 @@ bool Terminal::addConductor(Conductor *conductor)
|
||||
*/
|
||||
void Terminal::removeConductor(Conductor *conductor)
|
||||
{
|
||||
int index = conductors_.indexOf(conductor);
|
||||
int index = m_conductors_list.indexOf(conductor);
|
||||
if (index == -1) return;
|
||||
conductors_.removeAt(index);
|
||||
m_conductors_list.removeAt(index);
|
||||
emit conductorWasRemoved(conductor);
|
||||
}
|
||||
|
||||
@@ -313,10 +204,10 @@ void Terminal::paint(
|
||||
painter -> drawLine(c, e);
|
||||
|
||||
// dessin du point d'amarrage au conducteur en bleu
|
||||
t.setColor(hovered_color_);
|
||||
t.setColor(m_hovered_color);
|
||||
painter -> setPen(t);
|
||||
painter -> setBrush(hovered_color_);
|
||||
if (hovered_) {
|
||||
painter -> setBrush(m_hovered_color);
|
||||
if (m_hovered) {
|
||||
painter -> setRenderHint(QPainter::Antialiasing, true);
|
||||
painter -> drawEllipse(QRectF(c.x() - 2.5, c.y() - 2.5, 5.0, 5.0));
|
||||
} else painter -> drawPoint(c);
|
||||
@@ -448,21 +339,8 @@ QLineF Terminal::HelpLine() const
|
||||
@brief Terminal::boundingRect
|
||||
@return Le rectangle (en precision flottante) delimitant la borne et ses alentours.
|
||||
*/
|
||||
QRectF Terminal::boundingRect() const
|
||||
{
|
||||
if (br_ -> isNull())
|
||||
{
|
||||
qreal dcx = d->m_pos.x();
|
||||
qreal dcy = d->m_pos.y();
|
||||
qreal dex = dock_elmt_.x();
|
||||
qreal dey = dock_elmt_.y();
|
||||
QPointF origin = (dcx <= dex && dcy <= dey ? d->m_pos : dock_elmt_);
|
||||
origin += QPointF(-3.0, -3.0);
|
||||
qreal w = qAbs((int)(dcx - dex)) + 7;
|
||||
qreal h = qAbs((int)(dcy - dey)) + 7;
|
||||
*br_ = QRectF(origin, QSizeF(w, h));
|
||||
}
|
||||
return(*br_);
|
||||
QRectF Terminal::boundingRect() const {
|
||||
return m_br;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -533,7 +411,7 @@ Terminal* Terminal::alignedWithTerminal() const
|
||||
*/
|
||||
void Terminal::hoverEnterEvent(QGraphicsSceneHoverEvent *)
|
||||
{
|
||||
hovered_ = true;
|
||||
m_hovered = true;
|
||||
update();
|
||||
}
|
||||
|
||||
@@ -549,7 +427,7 @@ void Terminal::hoverMoveEvent(QGraphicsSceneHoverEvent *) {}
|
||||
*/
|
||||
void Terminal::hoverLeaveEvent(QGraphicsSceneHoverEvent *)
|
||||
{
|
||||
hovered_ = false;
|
||||
m_hovered = false;
|
||||
update();
|
||||
}
|
||||
|
||||
@@ -579,11 +457,11 @@ void Terminal::mouseMoveEvent(QGraphicsSceneMouseEvent *e)
|
||||
//setCursor(Qt::CrossCursor);
|
||||
|
||||
// d'un mouvement a l'autre, il faut retirer l'effet hover de la borne precedente
|
||||
if (previous_terminal_) {
|
||||
if (previous_terminal_ == this) hovered_ = true;
|
||||
else previous_terminal_ -> hovered_ = false;
|
||||
previous_terminal_ -> hovered_color_ = previous_terminal_ -> neutralColor;
|
||||
previous_terminal_ -> update();
|
||||
if (m_previous_terminal) {
|
||||
if (m_previous_terminal == this) m_hovered = true;
|
||||
else m_previous_terminal -> m_hovered = false;
|
||||
m_previous_terminal -> m_hovered_color = m_previous_terminal -> neutralColor;
|
||||
m_previous_terminal -> update();
|
||||
}
|
||||
|
||||
Diagram *diag = diagram();
|
||||
@@ -610,18 +488,18 @@ void Terminal::mouseMoveEvent(QGraphicsSceneMouseEvent *e)
|
||||
// si le qgi est une borne...
|
||||
Terminal *other_terminal = qgraphicsitem_cast<Terminal *>(qgi);
|
||||
if (!other_terminal) return;
|
||||
previous_terminal_ = other_terminal;
|
||||
m_previous_terminal = other_terminal;
|
||||
|
||||
// s'il s'agit d'une borne, on lui applique l'effet hover approprie
|
||||
if (!canBeLinkedTo(other_terminal)) {
|
||||
other_terminal -> hovered_color_ = forbiddenColor;
|
||||
other_terminal -> m_hovered_color = forbiddenColor;
|
||||
} else if (other_terminal -> conductorsCount()) {
|
||||
other_terminal -> hovered_color_ = warningColor;
|
||||
other_terminal -> m_hovered_color = warningColor;
|
||||
} else {
|
||||
other_terminal -> hovered_color_ = allowedColor;
|
||||
other_terminal -> m_hovered_color = allowedColor;
|
||||
}
|
||||
|
||||
other_terminal -> hovered_ = true;
|
||||
other_terminal -> m_hovered = true;
|
||||
other_terminal -> update();
|
||||
}
|
||||
|
||||
@@ -632,8 +510,8 @@ void Terminal::mouseMoveEvent(QGraphicsSceneMouseEvent *e)
|
||||
*/
|
||||
void Terminal::mouseReleaseEvent(QGraphicsSceneMouseEvent *e)
|
||||
{
|
||||
previous_terminal_ = nullptr;
|
||||
hovered_color_ = neutralColor;
|
||||
m_previous_terminal = nullptr;
|
||||
m_hovered_color = neutralColor;
|
||||
|
||||
if (!diagram()) return;
|
||||
|
||||
@@ -648,8 +526,8 @@ void Terminal::mouseReleaseEvent(QGraphicsSceneMouseEvent *e)
|
||||
Terminal *other_terminal = qgraphicsitem_cast<Terminal *>(qgi);
|
||||
if (!other_terminal) return;
|
||||
|
||||
other_terminal -> hovered_color_ = neutralColor;
|
||||
other_terminal -> hovered_ = false;
|
||||
other_terminal -> m_hovered_color = neutralColor;
|
||||
other_terminal -> m_hovered = false;
|
||||
|
||||
//We stop her if we can't link this terminal with other terminal
|
||||
if (!canBeLinkedTo(other_terminal)) return;
|
||||
@@ -706,7 +584,7 @@ void Terminal::mouseReleaseEvent(QGraphicsSceneMouseEvent *e)
|
||||
*/
|
||||
void Terminal::updateConductor()
|
||||
{
|
||||
foreach (Conductor *conductor, conductors_)
|
||||
foreach (Conductor *conductor, m_conductors_list)
|
||||
conductor->updatePath();
|
||||
}
|
||||
|
||||
@@ -719,7 +597,7 @@ bool Terminal::isLinkedTo(Terminal *other_terminal) {
|
||||
if (other_terminal == this) return(false);
|
||||
|
||||
bool already_linked = false;
|
||||
foreach (Conductor *c, conductors_) {
|
||||
foreach (Conductor *c, m_conductors_list) {
|
||||
if (c -> terminal1 == other_terminal || c -> terminal2 == other_terminal) {
|
||||
already_linked = true;
|
||||
break;
|
||||
@@ -752,7 +630,7 @@ bool Terminal::canBeLinkedTo(Terminal *other_terminal)
|
||||
*/
|
||||
QList<Conductor *> Terminal::conductors() const
|
||||
{
|
||||
return(conductors_);
|
||||
return(m_conductors_list);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -771,9 +649,6 @@ QDomElement Terminal::toXml(QDomDocument &doc) const
|
||||
// end for backward compatibility
|
||||
|
||||
qdo.setAttribute("orientation", d->m_orientation);
|
||||
qdo.setAttribute("number", number_terminal_);
|
||||
qdo.setAttribute("name", name_terminal_);
|
||||
qdo.setAttribute("nameHidden", name_terminal_hidden);
|
||||
return(qdo);
|
||||
}
|
||||
|
||||
@@ -828,10 +703,6 @@ bool Terminal::valideXml(QDomElement &terminal)
|
||||
*/
|
||||
bool Terminal::fromXml(QDomElement &terminal)
|
||||
{
|
||||
number_terminal_ = terminal.attribute("number");
|
||||
name_terminal_ = terminal.attribute("name");
|
||||
name_terminal_hidden = terminal.attribute("nameHidden").toInt();
|
||||
|
||||
return (
|
||||
qFuzzyCompare(terminal.attribute("x").toDouble(), dock_elmt_.x()) &&
|
||||
qFuzzyCompare(terminal.attribute("y").toDouble(), dock_elmt_.y()) &&
|
||||
|
||||
@@ -42,11 +42,7 @@ class Terminal : public QGraphicsObject
|
||||
|
||||
// constructors, destructor
|
||||
public:
|
||||
Terminal(QPointF, Qet::Orientation, Element * = nullptr);
|
||||
Terminal(qreal, qreal, Qet::Orientation, Element * = nullptr);
|
||||
Terminal(TerminalData* data, Element *e = nullptr);
|
||||
Terminal(QPointF, Qet::Orientation, QString number,
|
||||
QString name, bool hiddenName, Element * = nullptr);
|
||||
~Terminal() override;
|
||||
|
||||
private:
|
||||
@@ -82,10 +78,6 @@ class Terminal : public QGraphicsObject
|
||||
QList<Conductor *> conductors() const;
|
||||
Qet::Orientation orientation() const;
|
||||
QPointF dockConductor() const;
|
||||
QString number() const;
|
||||
QString name() const;
|
||||
void setNumber(QString number);
|
||||
void setName(QString name, bool hiddenName);
|
||||
void updateConductor();
|
||||
bool isLinkedTo(Terminal *);
|
||||
bool canBeLinkedTo(Terminal *);
|
||||
@@ -135,29 +127,18 @@ class Terminal : public QGraphicsObject
|
||||
QPointF dock_elmt_;
|
||||
private:
|
||||
/// List of conductors attached to the terminal
|
||||
QList<Conductor *> conductors_;
|
||||
/**
|
||||
Pointer to a rectangle representing the terminal bounding rect;
|
||||
used to calculate the bounding rect once only;
|
||||
used a pointer because boundingRect() is supposed to be const.
|
||||
*/
|
||||
QRectF *br_{nullptr};
|
||||
/// Last terminal seen through an attached conductor
|
||||
Terminal *previous_terminal_;
|
||||
/// Whether the mouse pointer is hovering the terminal
|
||||
bool hovered_;
|
||||
/// Color used for the hover effect
|
||||
QColor hovered_color_;
|
||||
/// Number of Terminal
|
||||
QString number_terminal_;
|
||||
/// Name of Terminal
|
||||
QString name_terminal_;
|
||||
bool name_terminal_hidden;
|
||||
QList<Conductor *> m_conductors_list;
|
||||
QRectF m_br;
|
||||
/// Last terminal seen through an attached conductor
|
||||
Terminal *m_previous_terminal = nullptr;
|
||||
/// Whether the mouse pointer is hovering the terminal
|
||||
bool m_hovered = false;
|
||||
/// Color used for the hover effect
|
||||
QColor m_hovered_color = Terminal::neutralColor;
|
||||
|
||||
private:
|
||||
void init(QString number, QString name, bool hiddenName);
|
||||
void init(QPointF pf, Qet::Orientation o, QString number,
|
||||
QString name, bool hiddenName);
|
||||
void init();
|
||||
void init(QPointF pf, Qet::Orientation o);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -166,25 +147,7 @@ class Terminal : public QGraphicsObject
|
||||
*/
|
||||
inline int Terminal::conductorsCount() const
|
||||
{
|
||||
return(conductors_.size());
|
||||
}
|
||||
|
||||
/**
|
||||
@brief Terminal::number
|
||||
@return the number of terminal.
|
||||
*/
|
||||
inline QString Terminal::number() const
|
||||
{
|
||||
return(number_terminal_);
|
||||
}
|
||||
|
||||
/**
|
||||
@brief Terminal::name
|
||||
@return the name of terminal.
|
||||
*/
|
||||
inline QString Terminal::name() const
|
||||
{
|
||||
return(name_terminal_);
|
||||
return(m_conductors_list.size());
|
||||
}
|
||||
|
||||
QList<Terminal *> relatedPotentialTerminal (const Terminal *terminal,
|
||||
|
||||
@@ -239,3 +239,32 @@ QString QETInformation::translatedInfoKey(const QString &info)
|
||||
else if (info == COND_FORMULA) return QObject::tr("Formule du texte");
|
||||
else return QString();
|
||||
}
|
||||
|
||||
QStringList QETInformation::elementEditorElementInfoKeys()
|
||||
{
|
||||
QStringList list = { ELMT_LABEL,
|
||||
ELMT_PLANT,
|
||||
ELMT_COMMENT,
|
||||
ELMT_DESCRIPTION,
|
||||
ELMT_DESIGNATION,
|
||||
ELMT_MANUFACTURER,
|
||||
ELMT_MANUFACTURER_REF,
|
||||
ELMT_SUPPLIER,
|
||||
ELMT_QUANTITY,
|
||||
ELMT_UNITY,
|
||||
ELMT_MACHINE_MANUFACTURER_REF};
|
||||
return list;
|
||||
}
|
||||
|
||||
QStringList QETInformation::terminalElementInfoKeys()
|
||||
{
|
||||
QStringList list = { ELMT_FORMULA,
|
||||
ELMT_LABEL,
|
||||
ELMT_COMMENT,
|
||||
ELMT_DESIGNATION,
|
||||
ELMT_MANUFACTURER,
|
||||
ELMT_MANUFACTURER_REF,
|
||||
ELMT_MACHINE_MANUFACTURER_REF,
|
||||
ELMT_SUPPLIER };
|
||||
return list;
|
||||
}
|
||||
|
||||
@@ -105,8 +105,11 @@ namespace QETInformation
|
||||
QStringList diagramInfoKeys();
|
||||
|
||||
QStringList elementInfoKeys();
|
||||
QStringList elementEditorElementInfoKeys();
|
||||
QString elementInfoToVar(const QString &info);
|
||||
|
||||
QStringList terminalElementInfoKeys();
|
||||
|
||||
QString infoToVar(const QString &info);
|
||||
QString translatedInfoKey(const QString &info);
|
||||
}
|
||||
|
||||
@@ -1311,6 +1311,27 @@ void QETProject::readProjectXml(QDomDocument &xml_project)
|
||||
return;
|
||||
}
|
||||
}
|
||||
//Since QElectrotech 0.9 the compatibility with project made with
|
||||
//Qet 0.6 or lower is break;
|
||||
if (conv_ok && m_project_qet_version <= 0.6 )
|
||||
{
|
||||
auto ret = QET::QetMessageBox::warning(
|
||||
nullptr,
|
||||
tr("Avertissement ", "message box title"),
|
||||
tr("Le projet que vous tentez d'ouvrir est partiellement "
|
||||
"compatible avec votre version de QElectroTech.\n"
|
||||
"Afin de le rendre totalement compatible veuillez ouvrir ce même projet "
|
||||
"avec la version 0.8 de QElectroTech sauvegarder le projet "
|
||||
"et l'ouvrir à nouveau avec cette version.\n"
|
||||
"Que désirez vous faire ?"),
|
||||
QMessageBox::Open | QMessageBox::Cancel);
|
||||
|
||||
if (ret == QMessageBox::Cancel)
|
||||
{
|
||||
m_state = FileOpenDiscard;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
setTitle(root_elmt.attribute("title"));
|
||||
}
|
||||
|
||||
@@ -554,3 +554,30 @@ void QETXML::modelHeaderDataFromXml(
|
||||
model->setHeaderData(section_, orientation_, data_, role_);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief QETXML::findInDomElement
|
||||
* @param dom_elmt
|
||||
* @param tag_name
|
||||
* @return all direct child of dom_elmt with tag name tag_name
|
||||
*/
|
||||
QVector<QDomElement> QETXML::findInDomElement(const QDomElement &dom_elmt, const QString &tag_name)
|
||||
{
|
||||
QVector<QDomElement> return_list;
|
||||
for (auto node = dom_elmt.firstChild() ;
|
||||
!node.isNull() ;
|
||||
node = node.nextSibling())
|
||||
{
|
||||
if (!node.isElement()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
auto element = node.toElement();
|
||||
if (element.isNull() || element.tagName() != tag_name) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return_list << element;
|
||||
}
|
||||
return(return_list);
|
||||
}
|
||||
|
||||
@@ -86,6 +86,9 @@ namespace QETXML
|
||||
void modelHeaderDataFromXml(
|
||||
const QDomElement &element,
|
||||
QAbstractItemModel *model);
|
||||
|
||||
QVector<QDomElement> findInDomElement(const QDomElement &dom_elmt,
|
||||
const QString &tag_name);
|
||||
}
|
||||
|
||||
#endif // QETXML_H
|
||||
|
||||
@@ -37,7 +37,6 @@ ElementInfoWidget::ElementInfoWidget(Element *elmt, QWidget *parent) :
|
||||
m_first_activation (false)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
buildInterface();
|
||||
setElement(elmt);
|
||||
}
|
||||
|
||||
@@ -179,7 +178,14 @@ void ElementInfoWidget::disableLiveEdit()
|
||||
*/
|
||||
void ElementInfoWidget::buildInterface()
|
||||
{
|
||||
for (auto str : QETInformation::elementInfoKeys())
|
||||
QStringList keys;
|
||||
auto type_ = m_element.data()->elementData().m_type;
|
||||
if (type_ == ElementData::Terminale)
|
||||
keys = QETInformation::terminalElementInfoKeys();
|
||||
else
|
||||
keys = QETInformation::elementInfoKeys();
|
||||
|
||||
for (auto str : keys)
|
||||
{
|
||||
ElementInfoPartWidget *eipw = new ElementInfoPartWidget(str, QETInformation::translatedInfoKey(str), this);
|
||||
ui->scroll_vlayout->addWidget(eipw);
|
||||
@@ -212,6 +218,10 @@ ElementInfoPartWidget *ElementInfoWidget::infoPartWidgetForKey(const QString &ke
|
||||
*/
|
||||
void ElementInfoWidget::updateUi()
|
||||
{
|
||||
if (!m_ui_builded) {
|
||||
buildInterface();
|
||||
m_ui_builded = true;
|
||||
}
|
||||
//We disable live edit to avoid wrong undo when we fill the line edit with new text
|
||||
if (m_live_edit) disableLiveEdit();
|
||||
|
||||
|
||||
@@ -72,6 +72,7 @@ class ElementInfoWidget : public AbstractElementPropertiesEditorWidget
|
||||
Ui::ElementInfoWidget *ui;
|
||||
QList <ElementInfoPartWidget *> m_eipw_list;
|
||||
bool m_first_activation;
|
||||
bool m_ui_builded = false;
|
||||
};
|
||||
|
||||
#endif // ELEMENTINFOWIDGET_H
|
||||
|
||||
Reference in New Issue
Block a user