mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-20 16:20:52 +01:00
xref properties widget: user can define the behavior of xref for coil and protection.
They don't work now with official collection, because we must to update the information of element (type coil or protection). You can test it by creating new master element (dont forget to define the master type, coil or protection). git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3185 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -87,7 +87,12 @@ void NewDiagramPage::applyConf() {
|
|||||||
rpw->toSettings(settings, "diagrameditor/defaultreport");
|
rpw->toSettings(settings, "diagrameditor/defaultreport");
|
||||||
|
|
||||||
// default xref properties
|
// default xref properties
|
||||||
xrefpw -> properties().toSettings(settings, "diagrameditor/defaultxref");
|
QHash <QString, XRefProperties> hash_xrp = xrefpw -> properties();
|
||||||
|
foreach (QString key, hash_xrp.keys()) {
|
||||||
|
XRefProperties xrp = hash_xrp[key];
|
||||||
|
QString str("diagrameditor/defaultxref");
|
||||||
|
xrp.toSettings(settings, str += key);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @return l'icone de cette page
|
/// @return l'icone de cette page
|
||||||
|
|||||||
@@ -1203,12 +1203,12 @@ QETProject *Diagram::project() const {
|
|||||||
void Diagram::setProject(QETProject *project) {
|
void Diagram::setProject(QETProject *project) {
|
||||||
if (project_) {
|
if (project_) {
|
||||||
disconnect (project_, SIGNAL(reportPropertiesChanged(QString)), this, SIGNAL(reportPropertiesChanged(QString)));
|
disconnect (project_, SIGNAL(reportPropertiesChanged(QString)), this, SIGNAL(reportPropertiesChanged(QString)));
|
||||||
disconnect (project_, SIGNAL(XRefPropertiesChanged(XRefProperties)), this, SIGNAL(XRefPropertiesChanged(XRefProperties)));
|
disconnect (project_, SIGNAL(XRefPropertiesChanged()), this, SIGNAL(XRefPropertiesChanged()));
|
||||||
}
|
}
|
||||||
project_ = project;
|
project_ = project;
|
||||||
if (project_) {
|
if (project_) {
|
||||||
connect (project_, SIGNAL(reportPropertiesChanged(QString)), this, SIGNAL(reportPropertiesChanged(QString)));
|
connect (project_, SIGNAL(reportPropertiesChanged(QString)), this, SIGNAL(reportPropertiesChanged(QString)));
|
||||||
connect (project_, SIGNAL(XRefPropertiesChanged(XRefProperties)), this, SIGNAL(XRefPropertiesChanged(XRefProperties)));
|
connect (project_, SIGNAL(XRefPropertiesChanged()), this, SIGNAL(XRefPropertiesChanged()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ class Diagram : public QGraphicsScene {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
QString defaultReportProperties () const {return project_ -> defaultReportProperties();}
|
QString defaultReportProperties () const {return project_ -> defaultReportProperties();}
|
||||||
XRefProperties defaultXRefProperties () const {return project_ -> defaultXrefProperties();}
|
XRefProperties defaultXRefProperties (const QString &str) const {return project_ -> defaultXRefProperties(str);}
|
||||||
static bool clipboardMayContainDiagram();
|
static bool clipboardMayContainDiagram();
|
||||||
bool setNumerotation (NumerotationType, NumerotationContext);
|
bool setNumerotation (NumerotationType, NumerotationContext);
|
||||||
NumerotationContext getNumerotation (NumerotationType) const;
|
NumerotationContext getNumerotation (NumerotationType) const;
|
||||||
@@ -213,7 +213,7 @@ class Diagram : public QGraphicsScene {
|
|||||||
/// Signal emitted when users wish to edit an element from the diagram
|
/// Signal emitted when users wish to edit an element from the diagram
|
||||||
void editElementRequired(const ElementsLocation &);
|
void editElementRequired(const ElementsLocation &);
|
||||||
void reportPropertiesChanged(QString);
|
void reportPropertiesChanged(QString);
|
||||||
void XRefPropertiesChanged(XRefProperties);
|
void XRefPropertiesChanged();
|
||||||
};
|
};
|
||||||
Q_DECLARE_METATYPE(Diagram *)
|
Q_DECLARE_METATYPE(Diagram *)
|
||||||
|
|
||||||
|
|||||||
@@ -262,8 +262,8 @@ void ProjectNewDiagramConfigPage::applyProjectConf() {
|
|||||||
modified_project = true;
|
modified_project = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
XRefProperties new_xref_properties = xref_ -> properties();
|
QHash<QString, XRefProperties> new_xref_properties = xref_ -> properties();
|
||||||
if (project_ -> defaultXrefProperties() != new_xref_properties) {
|
if (project_ -> defaultXRefProperties() != new_xref_properties) {
|
||||||
project_ -> setDefaultXRefProperties(new_xref_properties);
|
project_ -> setDefaultXRefProperties(new_xref_properties);
|
||||||
modified_project = true;
|
modified_project = true;
|
||||||
}
|
}
|
||||||
@@ -288,7 +288,7 @@ void ProjectNewDiagramConfigPage::initWidgets() {
|
|||||||
conductor_ = new ConductorPropertiesWidget();
|
conductor_ = new ConductorPropertiesWidget();
|
||||||
conductor_ -> setContentsMargins(0, 0, 0, 0);
|
conductor_ -> setContentsMargins(0, 0, 0, 0);
|
||||||
report_ = new ReportPropertieWidget("_");
|
report_ = new ReportPropertieWidget("_");
|
||||||
xref_ = new XRefPropertiesWidget(XRefProperties());
|
xref_ = new XRefPropertiesWidget();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -322,7 +322,7 @@ void ProjectNewDiagramConfigPage::readValuesFromProject() {
|
|||||||
conductor_ -> setConductorProperties (project_ -> defaultConductorProperties());
|
conductor_ -> setConductorProperties (project_ -> defaultConductorProperties());
|
||||||
titleblock_ -> setTitleBlockProperties (project_ -> defaultTitleBlockProperties());
|
titleblock_ -> setTitleBlockProperties (project_ -> defaultTitleBlockProperties());
|
||||||
report_ -> setReportProperties (project_ -> defaultReportProperties());
|
report_ -> setReportProperties (project_ -> defaultReportProperties());
|
||||||
xref_ -> setProperties (project_ -> defaultXrefProperties());
|
xref_ -> setProperties (project_ -> defaultXRefProperties());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -22,7 +22,11 @@
|
|||||||
* Default Constructor
|
* Default Constructor
|
||||||
*/
|
*/
|
||||||
XRefProperties::XRefProperties()
|
XRefProperties::XRefProperties()
|
||||||
{}
|
{
|
||||||
|
m_show_power_ctc = true;
|
||||||
|
m_display = Cross;
|
||||||
|
m_snap_to = Bottom;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief XRefProperties::toSettings
|
* @brief XRefProperties::toSettings
|
||||||
|
|||||||
@@ -2076,8 +2076,15 @@ QString QETDiagramEditor::defaultReportProperties() {
|
|||||||
* @brief QETDiagramEditor::defaultXRefProperties
|
* @brief QETDiagramEditor::defaultXRefProperties
|
||||||
* @return the default setting for Xref
|
* @return the default setting for Xref
|
||||||
*/
|
*/
|
||||||
XRefProperties QETDiagramEditor::defaultXRefProperties() {
|
QHash <QString, XRefProperties> QETDiagramEditor::defaultXRefProperties() {
|
||||||
XRefProperties properties;
|
QHash <QString, XRefProperties> hash;
|
||||||
properties.fromSettings(QETApp::settings(), "diagrameditor/defaultxref");
|
QStringList keys;
|
||||||
return properties;
|
keys << "coil" << "protection";
|
||||||
|
foreach (QString key, keys) {
|
||||||
|
XRefProperties properties;
|
||||||
|
QString str("diagrameditor/defaultxref");
|
||||||
|
properties.fromSettings(QETApp::settings(), str += key);
|
||||||
|
hash.insert(key, properties);
|
||||||
|
}
|
||||||
|
return hash;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,13 +59,13 @@ class QETDiagramEditor : public QETMainWindow {
|
|||||||
QList<DiagramView *> projectViews() const;
|
QList<DiagramView *> projectViews() const;
|
||||||
QList<QString> editedFiles() const;
|
QList<QString> editedFiles() const;
|
||||||
ProjectView *viewForFile(const QString &) const;
|
ProjectView *viewForFile(const QString &) const;
|
||||||
static TitleBlockProperties defaultTitleBlockProperties();
|
static TitleBlockProperties defaultTitleBlockProperties();
|
||||||
static BorderProperties defaultBorderProperties();
|
static BorderProperties defaultBorderProperties();
|
||||||
static ConductorProperties defaultConductorProperties();
|
static ConductorProperties defaultConductorProperties();
|
||||||
static ExportProperties defaultExportProperties();
|
static ExportProperties defaultExportProperties();
|
||||||
static ExportProperties defaultPrintProperties();
|
static ExportProperties defaultPrintProperties();
|
||||||
static QString defaultReportProperties();
|
static QString defaultReportProperties();
|
||||||
static XRefProperties defaultXRefProperties();
|
static QHash<QString, XRefProperties> defaultXRefProperties();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void actions();
|
void actions();
|
||||||
|
|||||||
@@ -35,10 +35,10 @@ CrossRefItem::CrossRefItem(Element *elmt) :
|
|||||||
QGraphicsObject(elmt),
|
QGraphicsObject(elmt),
|
||||||
m_element (elmt)
|
m_element (elmt)
|
||||||
{
|
{
|
||||||
m_properties = elmt->diagram()->defaultXRefProperties();
|
m_properties = elmt->diagram()->defaultXRefProperties(elmt->kindInformations()["type"].toString());
|
||||||
connect(elmt, SIGNAL(elementInfoChange(DiagramContext)), this, SLOT(updateLabel()));
|
connect(elmt, SIGNAL(elementInfoChange(DiagramContext)), this, SLOT(updateLabel()));
|
||||||
connect(elmt->diagram()->project(), SIGNAL(projectDiagramsOrderChanged(QETProject*,int,int)), this, SLOT(updateLabel()));
|
connect(elmt->diagram()->project(), SIGNAL(projectDiagramsOrderChanged(QETProject*,int,int)), this, SLOT(updateLabel()));
|
||||||
connect(elmt->diagram(), SIGNAL(XRefPropertiesChanged(XRefProperties)), this, SLOT(setProperties(XRefProperties)));
|
connect(elmt->diagram(), SIGNAL(XRefPropertiesChanged()), this, SLOT(updateProperties()));
|
||||||
|
|
||||||
//set specific behavior related to the parent item.
|
//set specific behavior related to the parent item.
|
||||||
if(m_properties.snapTo() == XRefProperties::Bottom) {
|
if(m_properties.snapTo() == XRefProperties::Bottom) {
|
||||||
@@ -61,7 +61,7 @@ CrossRefItem::~CrossRefItem() {
|
|||||||
}
|
}
|
||||||
disconnect(m_element, SIGNAL(elementInfoChange(DiagramContext)), this, SLOT(updateLabel()));
|
disconnect(m_element, SIGNAL(elementInfoChange(DiagramContext)), this, SLOT(updateLabel()));
|
||||||
disconnect(m_element->diagram()->project(), SIGNAL(projectDiagramsOrderChanged(QETProject*,int,int)), this, SLOT(updateLabel()));
|
disconnect(m_element->diagram()->project(), SIGNAL(projectDiagramsOrderChanged(QETProject*,int,int)), this, SLOT(updateLabel()));
|
||||||
disconnect(m_element->diagram(), SIGNAL(XRefPropertiesChanged(XRefProperties)), this, SLOT(setProperties(XRefProperties)));
|
disconnect(m_element->diagram(), SIGNAL(XRefPropertiesChanged()), this, SLOT(updateProperties()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -119,7 +119,13 @@ void CrossRefItem::allElementsPositionText(QString &no_str, QString &nc_str, con
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CrossRefItem::setProperties(const XRefProperties &xrp) {
|
/**
|
||||||
|
* @brief CrossRefItem::updateProperties
|
||||||
|
* update the curent properties
|
||||||
|
*/
|
||||||
|
void CrossRefItem::updateProperties() {
|
||||||
|
XRefProperties xrp = m_element->diagram()->defaultXRefProperties(m_element->kindInformations()["type"].toString());
|
||||||
|
|
||||||
if (m_properties != xrp) {
|
if (m_properties != xrp) {
|
||||||
if (m_properties.snapTo() != xrp.snapTo()) {
|
if (m_properties.snapTo() != xrp.snapTo()) {
|
||||||
if (xrp.snapTo() == XRefProperties::Bottom) {
|
if (xrp.snapTo() == XRefProperties::Bottom) {
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ class CrossRefItem : public QGraphicsObject
|
|||||||
signals:
|
signals:
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setProperties (const XRefProperties &xrp);
|
void updateProperties ();
|
||||||
void updateLabel ();
|
void updateLabel ();
|
||||||
void autoPos ();
|
void autoPos ();
|
||||||
|
|
||||||
|
|||||||
@@ -451,13 +451,14 @@ void QETProject::setDefaultReportProperties(const QString &properties) {
|
|||||||
emit reportPropertiesChanged(properties);
|
emit reportPropertiesChanged(properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
XRefProperties QETProject::defaultXrefProperties() const{
|
void QETProject::setDefaultXRefProperties(const QString type, const XRefProperties &properties) {
|
||||||
return m_default_xref_properties;
|
m_default_xref_properties.insert(type, properties);
|
||||||
|
emit XRefPropertiesChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QETProject::setDefaultXRefProperties(const XRefProperties &properties) {
|
void QETProject::setDefaultXRefProperties(QHash<QString, XRefProperties> hash) {
|
||||||
m_default_xref_properties = properties;
|
m_default_xref_properties.swap(hash);
|
||||||
emit XRefPropertiesChanged(properties);
|
emit XRefPropertiesChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1179,7 +1180,7 @@ void QETProject::readDefaultPropertiesXml() {
|
|||||||
conductors_elmt = child_elmt;
|
conductors_elmt = child_elmt;
|
||||||
} else if (child_elmt.tagName() == "report") {
|
} else if (child_elmt.tagName() == "report") {
|
||||||
report_elmt = child_elmt;
|
report_elmt = child_elmt;
|
||||||
} else if (child_elmt.tagName() == "xref") {
|
} else if (child_elmt.tagName() == "xrefs") {
|
||||||
xref_elmt = child_elmt;
|
xref_elmt = child_elmt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1189,7 +1190,13 @@ void QETProject::readDefaultPropertiesXml() {
|
|||||||
if (!titleblock_elmt.isNull()) default_titleblock_properties_.fromXml(titleblock_elmt);
|
if (!titleblock_elmt.isNull()) default_titleblock_properties_.fromXml(titleblock_elmt);
|
||||||
if (!conductors_elmt.isNull()) default_conductor_properties_.fromXml(conductors_elmt);
|
if (!conductors_elmt.isNull()) default_conductor_properties_.fromXml(conductors_elmt);
|
||||||
if (!report_elmt.isNull()) setDefaultReportProperties(report_elmt.attribute("label"));
|
if (!report_elmt.isNull()) setDefaultReportProperties(report_elmt.attribute("label"));
|
||||||
if (!xref_elmt.isNull()) m_default_xref_properties.fromXml(xref_elmt);
|
if (!xref_elmt.isNull()) {
|
||||||
|
foreach(QDomElement elmt, QET::findInDomElement(xref_elmt, "xref")) {
|
||||||
|
XRefProperties xrp;
|
||||||
|
xrp.fromXml(elmt);
|
||||||
|
m_default_xref_properties.insert(elmt.attribute("type"), xrp);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1227,9 +1234,15 @@ void QETProject::writeDefaultPropertiesXml(QDomElement &xml_element) {
|
|||||||
xml_element.appendChild(report_elmt);
|
xml_element.appendChild(report_elmt);
|
||||||
|
|
||||||
// export default XRef properties
|
// export default XRef properties
|
||||||
QDomElement xref_elmt = xml_document.createElement("xref");
|
QDomElement xrefs_elmt = xml_document.createElement("xrefs");
|
||||||
defaultXrefProperties().toXml(xref_elmt);
|
foreach (QString key, defaultXRefProperties().keys()) {
|
||||||
xml_element.appendChild(xref_elmt);
|
QDomElement xref_elmt = xml_document.createElement("xref");
|
||||||
|
xref_elmt.setAttribute("type", key);
|
||||||
|
defaultXRefProperties()[key].toXml(xref_elmt);
|
||||||
|
xrefs_elmt.appendChild(xref_elmt);
|
||||||
|
}
|
||||||
|
|
||||||
|
xml_element.appendChild(xrefs_elmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -92,6 +92,8 @@ class QETProject : public QObject {
|
|||||||
QDomElement getTemplateXmlDescriptionByName(const QString &);
|
QDomElement getTemplateXmlDescriptionByName(const QString &);
|
||||||
bool setTemplateXmlDescription(const QString &, const QDomElement &);
|
bool setTemplateXmlDescription(const QString &, const QDomElement &);
|
||||||
void removeTemplateByName(const QString &);
|
void removeTemplateByName(const QString &);
|
||||||
|
|
||||||
|
///DEFAULT PROPERTIES
|
||||||
BorderProperties defaultBorderProperties() const;
|
BorderProperties defaultBorderProperties() const;
|
||||||
void setDefaultBorderProperties(const BorderProperties &);
|
void setDefaultBorderProperties(const BorderProperties &);
|
||||||
TitleBlockProperties defaultTitleBlockProperties() const;
|
TitleBlockProperties defaultTitleBlockProperties() const;
|
||||||
@@ -100,8 +102,11 @@ class QETProject : public QObject {
|
|||||||
void setDefaultConductorProperties(const ConductorProperties &);
|
void setDefaultConductorProperties(const ConductorProperties &);
|
||||||
QString defaultReportProperties() const;
|
QString defaultReportProperties() const;
|
||||||
void setDefaultReportProperties (const QString &properties);
|
void setDefaultReportProperties (const QString &properties);
|
||||||
XRefProperties defaultXrefProperties () const;
|
XRefProperties defaultXRefProperties (const QString &type) const {return m_default_xref_properties[type];}
|
||||||
void setDefaultXRefProperties(const XRefProperties &properties);
|
QHash <QString, XRefProperties> defaultXRefProperties() const {return m_default_xref_properties;}
|
||||||
|
void setDefaultXRefProperties(const QString type, const XRefProperties &properties);
|
||||||
|
void setDefaultXRefProperties(QHash <QString, XRefProperties> hash);
|
||||||
|
|
||||||
QDomDocument toXml();
|
QDomDocument toXml();
|
||||||
bool close();
|
bool close();
|
||||||
QETResult write();
|
QETResult write();
|
||||||
@@ -147,7 +152,7 @@ class QETProject : public QObject {
|
|||||||
void diagramUsedTemplate(TitleBlockTemplatesCollection *, const QString &);
|
void diagramUsedTemplate(TitleBlockTemplatesCollection *, const QString &);
|
||||||
void readOnlyChanged(QETProject *, bool);
|
void readOnlyChanged(QETProject *, bool);
|
||||||
void reportPropertiesChanged(QString);
|
void reportPropertiesChanged(QString);
|
||||||
void XRefPropertiesChanged (XRefProperties);
|
void XRefPropertiesChanged ();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void updateDiagramsFolioData();
|
void updateDiagramsFolioData();
|
||||||
@@ -206,7 +211,7 @@ class QETProject : public QObject {
|
|||||||
/// Default report properties
|
/// Default report properties
|
||||||
QString default_report_properties_;
|
QString default_report_properties_;
|
||||||
/// Default xref properties
|
/// Default xref properties
|
||||||
XRefProperties m_default_xref_properties;
|
QHash <QString, XRefProperties> m_default_xref_properties;
|
||||||
/// Embedded title block templates collection
|
/// Embedded title block templates collection
|
||||||
TitleBlockTemplatesProjectCollection titleblocks_;
|
TitleBlockTemplatesProjectCollection titleblocks_;
|
||||||
/// project-wide variables that will be made available to child diagrams
|
/// project-wide variables that will be made available to child diagrams
|
||||||
|
|||||||
@@ -25,16 +25,15 @@
|
|||||||
* @param properties: properties to use
|
* @param properties: properties to use
|
||||||
* @param parent: parent widget
|
* @param parent: parent widget
|
||||||
*/
|
*/
|
||||||
XRefPropertiesWidget::XRefPropertiesWidget(XRefProperties properties, QWidget *parent) :
|
XRefPropertiesWidget::XRefPropertiesWidget(QHash <QString, XRefProperties> properties, QWidget *parent) :
|
||||||
QWidget(parent),
|
QWidget(parent),
|
||||||
ui(new Ui::XRefPropertiesWidget),
|
ui(new Ui::XRefPropertiesWidget),
|
||||||
m_properties(properties)
|
m_properties(properties)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
buildUi();
|
||||||
ui->m_snap_to_cb->addItem(tr("En bas de page"), "bottom");
|
connect(ui->m_display_has_cross_rb, SIGNAL(toggled(bool)), ui->m_cross_properties_gb, SLOT(setEnabled(bool)));
|
||||||
ui->m_snap_to_cb->addItem(tr("Sous le label de l'\351l\351ment"), "label");
|
connect(ui->m_type_cb, SIGNAL(currentIndexChanged(int)), this, SLOT(typeChanged()));
|
||||||
connect(ui->m_display_has_cross_rb, SIGNAL(toggled(bool)), ui->m_cross_properties_gb, SLOT(setEnabled(bool)));
|
|
||||||
updateDisplay();
|
updateDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,7 +43,8 @@ XRefPropertiesWidget::XRefPropertiesWidget(XRefProperties properties, QWidget *p
|
|||||||
*/
|
*/
|
||||||
XRefPropertiesWidget::~XRefPropertiesWidget()
|
XRefPropertiesWidget::~XRefPropertiesWidget()
|
||||||
{
|
{
|
||||||
disconnect(ui->m_display_has_cross_rb, SIGNAL(toggled(bool)), ui->m_cross_properties_gb, SLOT(setEnabled(bool)));
|
disconnect(ui->m_display_has_cross_rb, SIGNAL(toggled(bool)), ui->m_cross_properties_gb, SLOT(setEnabled(bool)));
|
||||||
|
disconnect(ui->m_type_cb, SIGNAL(currentIndexChanged(int)), this, SLOT(typeChanged()));
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,25 +53,18 @@ XRefPropertiesWidget::~XRefPropertiesWidget()
|
|||||||
* set new properties for this widget
|
* set new properties for this widget
|
||||||
* @param properties
|
* @param properties
|
||||||
*/
|
*/
|
||||||
void XRefPropertiesWidget::setProperties(const XRefProperties &properties) {
|
void XRefPropertiesWidget::setProperties(const QHash <QString, XRefProperties> &properties) {
|
||||||
m_properties = properties;
|
m_properties = properties;
|
||||||
updateDisplay();
|
updateDisplay();
|
||||||
|
m_previous_type_index = ui->m_type_cb->currentIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief XRefPropertiesWidget::properties
|
* @brief XRefPropertiesWidget::properties
|
||||||
* @return the propertie edited by this widget
|
* @return the properties edited by this widget
|
||||||
*/
|
*/
|
||||||
XRefProperties XRefPropertiesWidget::properties() {
|
QHash <QString, XRefProperties> XRefPropertiesWidget::properties(){
|
||||||
if (ui->m_display_has_cross_rb->isChecked()) m_properties.setDisplayHas(XRefProperties::Cross);
|
saveProperties(ui->m_type_cb->currentIndex());
|
||||||
else if (ui->m_display_has_contacts_rb->isChecked()) m_properties.setDisplayHas(XRefProperties::Contacts);
|
|
||||||
if (ui->m_snap_to_cb->itemData(ui->m_snap_to_cb->currentIndex()).toString() == "bottom")
|
|
||||||
m_properties.setSnapTo(XRefProperties::Bottom);
|
|
||||||
else m_properties.setSnapTo(XRefProperties::Label);
|
|
||||||
m_properties.setShowPowerContac(ui->m_show_power_cb->isChecked());
|
|
||||||
m_properties.setPrefix("power", ui->m_power_prefix_le->text());
|
|
||||||
m_properties.setPrefix("delay", ui->m_delay_prefix_le->text());
|
|
||||||
|
|
||||||
return m_properties;
|
return m_properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,21 +74,57 @@ XRefProperties XRefPropertiesWidget::properties() {
|
|||||||
* @param ro
|
* @param ro
|
||||||
*/
|
*/
|
||||||
void XRefPropertiesWidget::setReadOnly(bool ro) {
|
void XRefPropertiesWidget::setReadOnly(bool ro) {
|
||||||
ui->m_display_has_cross_rb->setDisabled(ro);
|
ui->m_type_cb->setDisabled(ro);
|
||||||
ui->m_display_has_contacts_rb->setDisabled(ro);
|
ui->m_display_gb->setDisabled(ro);
|
||||||
|
ui->m_cross_properties_gb->setDisabled(ro);
|
||||||
|
|
||||||
if (m_properties.displayHas() != XRefProperties::Cross)
|
if (!ro && ui->m_display_has_contacts_rb->isChecked()) {
|
||||||
ui->m_cross_properties_gb->setDisabled(true);
|
ui->m_cross_properties_gb->setDisabled(true);
|
||||||
else
|
}
|
||||||
ui->m_cross_properties_gb->setDisabled(ro);
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief XRefPropertiesWidget::buildUi
|
||||||
|
* Build some widget of this ui.
|
||||||
|
*/
|
||||||
|
void XRefPropertiesWidget::buildUi() {
|
||||||
|
ui -> m_type_cb -> addItem(tr("Bobine"), "coil");
|
||||||
|
ui -> m_type_cb -> addItem(tr("Organe de protection"), "protection");
|
||||||
|
ui -> m_snap_to_cb -> addItem(tr("En bas de page"), "bottom");
|
||||||
|
ui -> m_snap_to_cb -> addItem(tr("Sous le label de l'\351l\351ment"), "label");
|
||||||
|
m_previous_type_index = ui -> m_type_cb -> currentIndex();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief XRefPropertiesWidget::saveProperties
|
||||||
|
* Save the properties of the type define at @index of the combo box m_type_cb
|
||||||
|
* @param index
|
||||||
|
*/
|
||||||
|
void XRefPropertiesWidget::saveProperties(int index) {
|
||||||
|
QString type = ui->m_type_cb->itemData(index).toString();
|
||||||
|
XRefProperties xrp = m_properties[type];
|
||||||
|
|
||||||
|
if (ui->m_display_has_cross_rb->isChecked()) xrp.setDisplayHas(XRefProperties::Cross);
|
||||||
|
else if (ui->m_display_has_contacts_rb->isChecked()) xrp.setDisplayHas(XRefProperties::Contacts);
|
||||||
|
if (ui->m_snap_to_cb->itemData(ui->m_snap_to_cb->currentIndex()).toString() == "bottom")
|
||||||
|
xrp.setSnapTo(XRefProperties::Bottom);
|
||||||
|
else xrp.setSnapTo(XRefProperties::Label);
|
||||||
|
xrp.setShowPowerContac(ui->m_show_power_cb->isChecked());
|
||||||
|
xrp.setPrefix("power", ui->m_power_prefix_le->text());
|
||||||
|
xrp.setPrefix("delay", ui->m_delay_prefix_le->text());
|
||||||
|
|
||||||
|
m_properties.insert(type, xrp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief XRefPropertiesWidget::updateDisplay
|
* @brief XRefPropertiesWidget::updateDisplay
|
||||||
* Update display with the content of the properties
|
* Update display with the curent displayed type.
|
||||||
*/
|
*/
|
||||||
void XRefPropertiesWidget::updateDisplay() {
|
void XRefPropertiesWidget::updateDisplay() {
|
||||||
XRefProperties::DisplayHas dh = m_properties.displayHas();
|
QString type = ui->m_type_cb->itemData(ui->m_type_cb->currentIndex()).toString();
|
||||||
|
XRefProperties xrp = m_properties[type];
|
||||||
|
|
||||||
|
XRefProperties::DisplayHas dh = xrp.displayHas();
|
||||||
if (dh == XRefProperties::Cross) {
|
if (dh == XRefProperties::Cross) {
|
||||||
ui->m_display_has_cross_rb->setChecked(true);
|
ui->m_display_has_cross_rb->setChecked(true);
|
||||||
}
|
}
|
||||||
@@ -103,11 +132,26 @@ void XRefPropertiesWidget::updateDisplay() {
|
|||||||
ui->m_display_has_contacts_rb->setChecked(true);
|
ui->m_display_has_contacts_rb->setChecked(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_properties.snapTo() == XRefProperties::Bottom)
|
if (xrp.snapTo() == XRefProperties::Bottom)
|
||||||
ui->m_snap_to_cb->setCurrentIndex(ui->m_snap_to_cb->findData("bottom"));
|
ui->m_snap_to_cb->setCurrentIndex(ui->m_snap_to_cb->findData("bottom"));
|
||||||
else ui->m_snap_to_cb->setCurrentIndex(ui->m_snap_to_cb->findData("label"));
|
else ui->m_snap_to_cb->setCurrentIndex(ui->m_snap_to_cb->findData("label"));
|
||||||
ui->m_show_power_cb->setChecked(m_properties.showPowerContact());
|
ui->m_show_power_cb->setChecked(xrp.showPowerContact());
|
||||||
ui->m_power_prefix_le->setText(m_properties.prefix("power"));
|
ui->m_power_prefix_le->setText(xrp.prefix("power"));
|
||||||
ui->m_delay_prefix_le->setText(m_properties.prefix("delay"));
|
ui->m_delay_prefix_le->setText(xrp.prefix("delay"));
|
||||||
ui->m_cross_properties_gb->setDisabled(!ui->m_display_has_cross_rb->isChecked());
|
ui->m_cross_properties_gb->setDisabled(!ui->m_display_has_cross_rb->isChecked());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief XRefPropertiesWidget::typeChanged
|
||||||
|
* manage the save of the current properties,
|
||||||
|
* when the combo box of type change.
|
||||||
|
*/
|
||||||
|
void XRefPropertiesWidget::typeChanged() {
|
||||||
|
//save the properties of the previous xref type
|
||||||
|
saveProperties(m_previous_type_index);
|
||||||
|
//update display with the current xref type
|
||||||
|
updateDisplay();
|
||||||
|
//everything is done
|
||||||
|
//previous index is now the current index
|
||||||
|
m_previous_type_index = ui->m_type_cb->currentIndex();
|
||||||
|
}
|
||||||
|
|||||||
@@ -34,20 +34,27 @@ class XRefPropertiesWidget : public QWidget
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
XRefPropertiesWidget(XRefProperties properties = XRefProperties(), QWidget *parent = 0);
|
XRefPropertiesWidget(QHash <QString, XRefProperties> properties = QHash <QString, XRefProperties>(), QWidget *parent = 0);
|
||||||
~XRefPropertiesWidget();
|
~XRefPropertiesWidget();
|
||||||
|
|
||||||
void setProperties (const XRefProperties &properties);
|
void setProperties (const QHash <QString, XRefProperties> &properties);
|
||||||
XRefProperties properties();
|
QHash <QString, XRefProperties> properties();
|
||||||
|
|
||||||
void setReadOnly (bool = true);
|
void setReadOnly (bool = true);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void buildUi();
|
||||||
|
void saveProperties(int index);
|
||||||
|
|
||||||
|
private slots:
|
||||||
void updateDisplay();
|
void updateDisplay();
|
||||||
|
void typeChanged();
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::XRefPropertiesWidget *ui;
|
Ui::XRefPropertiesWidget *ui;
|
||||||
XRefProperties m_properties;
|
QHash <QString, XRefProperties> m_properties;
|
||||||
|
int m_previous_type_index;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // XREFPROPERTIESWIDGET_H
|
#endif // XREFPROPERTIESWIDGET_H
|
||||||
|
|||||||
@@ -6,14 +6,28 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>400</width>
|
<width>484</width>
|
||||||
<height>300</height>
|
<height>470</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Form</string>
|
<string>Form</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_4">
|
||||||
|
<property name="text">
|
||||||
|
<string>Type :</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QComboBox" name="m_type_cb"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="m_display_gb">
|
<widget class="QGroupBox" name="m_display_gb">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
|
|||||||
Reference in New Issue
Block a user