[qet] qet/qet: [5024] When we select an element dynamic text, the element properties widget switch to the tab of dynamics text and expand and select the item in the tree that represent the dynamic text. |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/qet Archives
]
- To: qet@xxxxxxxxxxxxxxxxxxx
- Subject: [qet] qet/qet: [5024] When we select an element dynamic text, the element properties widget switch to the tab of dynamics text and expand and select the item in the tree that represent the dynamic text.
- From: subversion@xxxxxxxxxxxxx
- Date: Tue, 22 Aug 2017 20:27:23 +0200
Revision: 5024
Author: blacksun
Date: 2017-08-22 20:27:23 +0200 (Tue, 22 Aug 2017)
Log Message:
-----------
When we select an element dynamic text, the element properties widget switch to the tab of dynamics text and expand and select the item in the tree that represent the dynamic text.
Modified Paths:
--------------
trunk/sources/qetgraphicsitem/dynamicelementtextitem.cpp
trunk/sources/qetgraphicsitem/dynamicelementtextitem.h
trunk/sources/ui/compositetexteditdialog.cpp
trunk/sources/ui/diagrampropertieseditordockwidget.cpp
trunk/sources/ui/dynamicelementtextitemeditor.cpp
trunk/sources/ui/dynamicelementtextitemeditor.h
trunk/sources/ui/dynamicelementtextmodel.cpp
trunk/sources/ui/dynamicelementtextmodel.h
trunk/sources/ui/elementpropertieswidget.cpp
trunk/sources/ui/elementpropertieswidget.h
trunk/sources/undocommand/deleteqgraphicsitemcommand.cpp
Modified: trunk/sources/qetgraphicsitem/dynamicelementtextitem.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/dynamicelementtextitem.cpp 2017-08-22 17:24:51 UTC (rev 5023)
+++ trunk/sources/qetgraphicsitem/dynamicelementtextitem.cpp 2017-08-22 18:27:23 UTC (rev 5024)
@@ -171,7 +171,7 @@
* @brief DynamicElementTextItem::ParentElement
* @return a pointer to the parent element. Note the pointer can be null.
*/
-Element *DynamicElementTextItem::ParentElement() const {
+Element *DynamicElementTextItem::parentElement() const {
return m_parent_element;
}
Modified: trunk/sources/qetgraphicsitem/dynamicelementtextitem.h
===================================================================
--- trunk/sources/qetgraphicsitem/dynamicelementtextitem.h 2017-08-22 17:24:51 UTC (rev 5023)
+++ trunk/sources/qetgraphicsitem/dynamicelementtextitem.h 2017-08-22 18:27:23 UTC (rev 5024)
@@ -67,7 +67,7 @@
QDomElement toXml(QDomDocument &dom_doc) const override;
void fromXml(const QDomElement &dom_elmt) override;
- Element *ParentElement() const;
+ Element *parentElement() const;
DynamicElementTextItem::TextFrom textFrom() const;
void setTextFrom (DynamicElementTextItem::TextFrom text_from);
Modified: trunk/sources/ui/compositetexteditdialog.cpp
===================================================================
--- trunk/sources/ui/compositetexteditdialog.cpp 2017-08-22 17:24:51 UTC (rev 5023)
+++ trunk/sources/ui/compositetexteditdialog.cpp 2017-08-22 18:27:23 UTC (rev 5024)
@@ -34,7 +34,7 @@
void CompositeTextEditDialog::setUpComboBox()
{
QStringList qstrl;
- Element *elmt = m_text->ParentElement();
+ Element *elmt = m_text->parentElement();
if(!elmt)
return;
Modified: trunk/sources/ui/diagrampropertieseditordockwidget.cpp
===================================================================
--- trunk/sources/ui/diagrampropertieseditordockwidget.cpp 2017-08-22 17:24:51 UTC (rev 5023)
+++ trunk/sources/ui/diagrampropertieseditordockwidget.cpp 2017-08-22 18:27:23 UTC (rev 5024)
@@ -128,13 +128,13 @@
//We already edit an element, just update the editor with a new element
if (m_edited_qgi_type == Element::Type)
{
- static_cast<ElementPropertiesWidget*>(editors().first())->setElement(deti->ParentElement());
+ static_cast<ElementPropertiesWidget*>(editors().first())->setDynamicText(deti);
return;
}
clear();
m_edited_qgi_type = Element::Type;
- addEditor(new ElementPropertiesWidget(deti->ParentElement(), this));
+ addEditor(new ElementPropertiesWidget(deti, this));
break; }
default:
Modified: trunk/sources/ui/dynamicelementtextitemeditor.cpp
===================================================================
--- trunk/sources/ui/dynamicelementtextitemeditor.cpp 2017-08-22 17:24:51 UTC (rev 5023)
+++ trunk/sources/ui/dynamicelementtextitemeditor.cpp 2017-08-22 18:27:23 UTC (rev 5024)
@@ -105,6 +105,21 @@
deti->blockSignals(false);
}
+/**
+ * @brief DynamicElementTextItemEditor::setCurrentText
+ * Expand and select the item for text @text
+ * @param text
+ */
+void DynamicElementTextItemEditor::setCurrentText(DynamicElementTextItem *text)
+{
+ QModelIndex index = m_model->indexFromText(text);
+ if(!index.isValid())
+ return;
+
+ m_tree_view->expand(index);
+ m_tree_view->setCurrentIndex(index);
+}
+
void DynamicElementTextItemEditor::dataEdited(QStandardItem *qsi)
{
Q_UNUSED(qsi)
Modified: trunk/sources/ui/dynamicelementtextitemeditor.h
===================================================================
--- trunk/sources/ui/dynamicelementtextitemeditor.h 2017-08-22 17:24:51 UTC (rev 5023)
+++ trunk/sources/ui/dynamicelementtextitemeditor.h 2017-08-22 18:27:23 UTC (rev 5024)
@@ -41,6 +41,7 @@
QString title() const override {return tr("Textes");}
bool setLiveEdit(bool live_edit) override;
void apply() override;
+ void setCurrentText(DynamicElementTextItem *text);
private:
void dataEdited(QStandardItem *qsi);
Modified: trunk/sources/ui/dynamicelementtextmodel.cpp
===================================================================
--- trunk/sources/ui/dynamicelementtextmodel.cpp 2017-08-22 17:24:51 UTC (rev 5023)
+++ trunk/sources/ui/dynamicelementtextmodel.cpp 2017-08-22 18:27:23 UTC (rev 5024)
@@ -107,7 +107,7 @@
QStandardItem *compositea = new QStandardItem(deti->compositeText().isEmpty() ?
tr("Mon texte composé") :
- autonum::AssignVariables::replaceVariable(deti->compositeText(), deti->ParentElement()->elementInformations()));
+ autonum::AssignVariables::replaceVariable(deti->compositeText(), deti->parentElement()->elementInformations()));
compositea->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
compositea->setData(DynamicElementTextModel::compositeText, Qt::UserRole+1); //Use to know the edited thing
compositea->setData(deti->compositeText(), Qt::UserRole+2); //Use to know to element composite formula
@@ -220,6 +220,19 @@
}
/**
+ * @brief DynamicElementTextModel::indexFromText
+ * @param text
+ * @return the QModelIndex for @text, or a default QModelIndex if not match
+ */
+QModelIndex DynamicElementTextModel::indexFromText(DynamicElementTextItem *text) const
+{
+ if(!m_texts_list.contains(text))
+ return QModelIndex();
+
+ return m_texts_list.value(text)->index();
+}
+
+/**
* @brief DynamicElementTextModel::undoForEditedText
* @param deti
* @return A QUndoCommand that describe all changes made for @deti.
@@ -332,15 +345,15 @@
QString text = qsi->data(Qt::DisplayRole).toString();
m_texts_list.value(deti)->setData(text, Qt::DisplayRole);
}
- else if (qsi->data().toInt() == infoText && deti->ParentElement())
+ else if (qsi->data().toInt() == infoText && deti->parentElement())
{
QString info = qsi->data(Qt::UserRole+2).toString();
- m_texts_list.value(deti)->setData(deti->ParentElement()->elementInformations().value(info), Qt::DisplayRole);
+ m_texts_list.value(deti)->setData(deti->parentElement()->elementInformations().value(info), Qt::DisplayRole);
}
- else if (qsi->data().toInt() == compositeText && deti->ParentElement())
+ else if (qsi->data().toInt() == compositeText && deti->parentElement())
{
QString compo = qsi->data(Qt::UserRole+2).toString();
- m_texts_list.value(deti)->setData(autonum::AssignVariables::replaceVariable(compo, deti->ParentElement()->elementInformations()), Qt::DisplayRole);
+ m_texts_list.value(deti)->setData(autonum::AssignVariables::replaceVariable(compo, deti->parentElement()->elementInformations()), Qt::DisplayRole);
}
blockSignals(false);
@@ -546,7 +559,7 @@
DynamicElementTextItem *deti = detm->textFromIndex(index);
if(deti)
{
- DiagramContext dc = deti->ParentElement()->elementInformations();
+ DiagramContext dc = deti->parentElement()->elementInformations();
assigned_text = autonum::AssignVariables::replaceVariable(edited_text, dc);
}
@@ -569,7 +582,7 @@
QStringList DynamicTextItemDelegate::availableInfo(DynamicElementTextItem *deti) const
{
QStringList qstrl;
- Element *elmt = deti->ParentElement();
+ Element *elmt = deti->parentElement();
if(!elmt)
return qstrl;
Modified: trunk/sources/ui/dynamicelementtextmodel.h
===================================================================
--- trunk/sources/ui/dynamicelementtextmodel.h 2017-08-22 17:24:51 UTC (rev 5023)
+++ trunk/sources/ui/dynamicelementtextmodel.h 2017-08-22 18:27:23 UTC (rev 5024)
@@ -52,6 +52,7 @@
void removeText(DynamicElementTextItem *deti);
DynamicElementTextItem *textFromIndex(const QModelIndex &index) const;
DynamicElementTextItem *textFromItem(QStandardItem *item) const;
+ QModelIndex indexFromText(DynamicElementTextItem *text) const;
QUndoCommand *undoForEditedText(DynamicElementTextItem *deti) const;
private:
Modified: trunk/sources/ui/elementpropertieswidget.cpp
===================================================================
--- trunk/sources/ui/elementpropertieswidget.cpp 2017-08-22 17:24:51 UTC (rev 5023)
+++ trunk/sources/ui/elementpropertieswidget.cpp 2017-08-22 18:27:23 UTC (rev 5024)
@@ -25,6 +25,7 @@
#include "diagramposition.h"
#include "qeticons.h"
#include "dynamicelementtextitemeditor.h"
+#include "dynamicelementtextitem.h"
#include <QVBoxLayout>
#include <QLabel>
@@ -47,6 +48,27 @@
}
/**
+ * @brief ElementPropertiesWidget::ElementPropertiesWidget
+ * Same as default constructor, the edited element, is the parent element of @text.
+ * The only difference with default constructor, is that the current tab is the tab for dynamic texts,
+ * and the item in the tree that represent @text is expanded and selected.
+ * @param text
+ * @param parent
+ */
+ElementPropertiesWidget::ElementPropertiesWidget(DynamicElementTextItem *text, QWidget *parent) :
+ AbstractElementPropertiesEditorWidget (parent),
+ m_tab (nullptr),
+ m_general_widget(nullptr)
+{
+ if(text->parentElement())
+ {
+ m_diagram = text->parentElement()->diagram();
+ buildGui();
+ setDynamicText(text);
+ }
+}
+
+/**
* @brief ElementPropertiesWidget::setElement
* Set @element to be the edited element
* @param element
@@ -74,6 +96,29 @@
}
/**
+ * @brief ElementPropertiesWidget::setDynamicText
+ * convenience function: same as call : ElementPropertiesWidget::setElement, with parameter the parent element of @text.
+ * Set the dynamics text tab as current tab, expand and select the item that represent @text
+ * @param text
+ */
+void ElementPropertiesWidget::setDynamicText(DynamicElementTextItem *text)
+{
+ if(text->parentElement())
+ {
+ setElement(text->parentElement());
+ for(AbstractElementPropertiesEditorWidget *aepew : m_list_editor)
+ {
+ if (QString(aepew->metaObject()->className()) == "DynamicElementTextItemEditor")
+ {
+ DynamicElementTextItemEditor *detie = static_cast<DynamicElementTextItemEditor *>(aepew);
+ m_tab->setCurrentWidget(detie);
+ detie->setCurrentText(text);
+ }
+ }
+ }
+}
+
+/**
* @brief ElementPropertiesWidget::apply
* Apply the new properties by pushing an undo command
* to the parent project's undo stack of element
Modified: trunk/sources/ui/elementpropertieswidget.h
===================================================================
--- trunk/sources/ui/elementpropertieswidget.h 2017-08-22 17:24:51 UTC (rev 5023)
+++ trunk/sources/ui/elementpropertieswidget.h 2017-08-22 18:27:23 UTC (rev 5024)
@@ -24,6 +24,7 @@
class Diagram;
class QTabWidget;
class ElementsLocation;
+class DynamicElementTextItem;
class ElementPropertiesWidget : public AbstractElementPropertiesEditorWidget
@@ -32,7 +33,9 @@
public:
explicit ElementPropertiesWidget(Element *elmt, QWidget *parent = nullptr);
+ explicit ElementPropertiesWidget(DynamicElementTextItem *text, QWidget *parent = nullptr);
void setElement(Element *element) override;
+ void setDynamicText(DynamicElementTextItem *text);
void apply() override;
void reset() override;
bool setLiveEdit(bool live_edit) override;
Modified: trunk/sources/undocommand/deleteqgraphicsitemcommand.cpp
===================================================================
--- trunk/sources/undocommand/deleteqgraphicsitemcommand.cpp 2017-08-22 17:24:51 UTC (rev 5023)
+++ trunk/sources/undocommand/deleteqgraphicsitemcommand.cpp 2017-08-22 18:27:23 UTC (rev 5024)
@@ -38,13 +38,13 @@
const QSet<DynamicElementTextItem *> elmt_set = m_removed_contents.m_element_texts;
for(DynamicElementTextItem *deti : elmt_set)
{
- if (m_removed_contents.m_elements.contains(deti->ParentElement()))
+ if (m_removed_contents.m_elements.contains(deti->parentElement()))
m_removed_contents.m_element_texts.remove(deti);
}
for(DynamicElementTextItem *deti : m_removed_contents.m_element_texts)
- m_elmt_text_hash.insert(deti, deti->ParentElement());
+ m_elmt_text_hash.insert(deti, deti->parentElement());
setText(QString(QObject::tr("supprimer %1", "undo caption - %1 is a sentence listing the removed content")).arg(m_removed_contents.sentence(DiagramContent::All)));
m_diagram->qgiManager().manage(m_removed_contents.items(DiagramContent::All));
@@ -109,7 +109,7 @@
for(DynamicElementTextItem *deti : m_removed_contents.m_element_texts)
{
- deti->ParentElement()->removeDynamicTextItem(deti);
+ deti->parentElement()->removeDynamicTextItem(deti);
deti->setParentItem(nullptr);
}