Merge commit 'b021ac3e1fb98a56810773c7c701e3329efb3148'

Conflicts:
	sources/qetgraphicsitem/element.h
This commit is contained in:
Martin Marmsoler
2021-03-04 21:31:55 +01:00
113 changed files with 6245 additions and 1179 deletions

View File

@@ -188,13 +188,13 @@ void ElementPropertiesEditorWidget::updateTree()
*/
void ElementPropertiesEditorWidget::populateTree()
{
auto keys = QETInformation::elementEditorElementInfoKeys();
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_data.m_informations.value(key).toString());
}
@@ -256,6 +256,8 @@ void ElementPropertiesEditorWidget::on_m_base_type_cb_currentIndexChanged(int in
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();
}

View File

@@ -1325,6 +1325,15 @@ void Element::setElementInformations(DiagramContext dc)
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;
}
/**
@brief comparPos
Compare position of the two elements. Compare 3 points:

View File

@@ -1,4 +1,4 @@
/*
/*
Copyright 2006-2021 The QElectroTech Team
This file is part of QElectroTech.
@@ -103,6 +103,15 @@ class Element : public QetGraphicsItem // TODO: derive from propertiesInterface!
DiagramContext elementInformations()const
{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
@@ -159,8 +168,20 @@ class Element : public QetGraphicsItem // TODO: derive from propertiesInterface!
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:

View File

@@ -255,3 +255,16 @@ QStringList QETInformation::elementEditorElementInfoKeys()
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;
}

View File

@@ -108,6 +108,8 @@ namespace QETInformation
QStringList elementEditorElementInfoKeys();
QString elementInfoToVar(const QString &info);
QStringList terminalElementInfoKeys();
QString infoToVar(const QString &info);
QString translatedInfoKey(const QString &info);
}

View File

@@ -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();

View File

@@ -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