diff --git a/sources/qetgraphicsitem/elementtextitemgroup.cpp b/sources/qetgraphicsitem/elementtextitemgroup.cpp
index ece17556e..80b09d799 100644
--- a/sources/qetgraphicsitem/elementtextitemgroup.cpp
+++ b/sources/qetgraphicsitem/elementtextitemgroup.cpp
@@ -195,6 +195,7 @@ void ElementTextItemGroup::setVerticalAdjustment(int v)
void ElementTextItemGroup::setName(QString name)
{
m_name = name;
+ emit nameChanged(m_name);
}
/**
diff --git a/sources/qetgraphicsitem/elementtextitemgroup.h b/sources/qetgraphicsitem/elementtextitemgroup.h
index a10e060ed..0b03c4bdc 100644
--- a/sources/qetgraphicsitem/elementtextitemgroup.h
+++ b/sources/qetgraphicsitem/elementtextitemgroup.h
@@ -39,12 +39,14 @@ class ElementTextItemGroup : public QObject, public QGraphicsItemGroup
Q_PROPERTY(qreal rotation READ rotation WRITE setRotation NOTIFY rotationChanged)
Q_PROPERTY(int verticalAdjustment READ verticalAdjustment WRITE setVerticalAdjustment NOTIFY verticalAdjustmentChanged)
Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment NOTIFY alignmentChanged)
+ Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
public:
signals:
void rotationChanged(qreal);
void verticalAdjustmentChanged(int);
void alignmentChanged(Qt::Alignment);
+ void nameChanged(QString);
public:
ElementTextItemGroup(const QString &name, Element *parent);
diff --git a/sources/ui/dynamicelementtextitemeditor.cpp b/sources/ui/dynamicelementtextitemeditor.cpp
index 1f538e4fe..b6fd32cf0 100644
--- a/sources/ui/dynamicelementtextitemeditor.cpp
+++ b/sources/ui/dynamicelementtextitemeditor.cpp
@@ -36,18 +36,13 @@ DynamicElementTextItemEditor::DynamicElementTextItemEditor(Element *element, QWi
{
ui->setupUi(this);
- m_tree_view = new QTreeView(this);
- m_tree_view->header()->setDefaultSectionSize(150);
- m_tree_view->setItemDelegate(new DynamicTextItemDelegate(m_tree_view));
- m_tree_view->setAlternatingRowColors(true);
- m_tree_view->setEditTriggers(QAbstractItemView::CurrentChanged);
- m_tree_view->installEventFilter(this);
- m_tree_view->setDragDropMode(QAbstractItemView::InternalMove);
- ui->verticalLayout->addWidget(m_tree_view);
-
- connect(m_tree_view, &QTreeView::clicked, this, &DynamicElementTextItemEditor::treeViewClicked);
+ ui->m_tree_view->setItemDelegate(new DynamicTextItemDelegate(ui->m_tree_view));
+ ui->m_tree_view->installEventFilter(this);
ui->m_remove_selection->setDisabled(true);
+ ui->m_export_pb->hide();
+ ui->m_import_pb->hide();
+
setElement(element);
}
@@ -64,9 +59,9 @@ void DynamicElementTextItemEditor::setElement(Element *element)
m_element = element;
DynamicElementTextModel *old_model = m_model;
- m_model = new DynamicElementTextModel(element, m_tree_view);
+ m_model = new DynamicElementTextModel(element, ui->m_tree_view);
connect(m_model, &DynamicElementTextModel::dataChanged, this, &DynamicElementTextItemEditor::dataEdited);
- m_tree_view->setModel(m_model);
+ ui->m_tree_view->setModel(m_model);
if(old_model)
delete old_model;
@@ -153,9 +148,9 @@ void DynamicElementTextItemEditor::setCurrentText(DynamicElementTextItem *text)
if(!index.isValid())
return;
- m_tree_view->expand(index);
- m_tree_view->expand(index.child(0,0));
- m_tree_view->setCurrentIndex(index);
+ ui->m_tree_view->expand(index);
+ ui->m_tree_view->expand(index.child(0,0));
+ ui->m_tree_view->setCurrentIndex(index);
ui->m_remove_selection->setEnabled(true);
}
@@ -170,8 +165,8 @@ void DynamicElementTextItemEditor::setCurrentGroup(ElementTextItemGroup *group)
if(!index.isValid())
return;
- m_tree_view->expand(index);
- m_tree_view->setCurrentIndex(index);
+ ui->m_tree_view->expand(index);
+ ui->m_tree_view->setCurrentIndex(index);
ui->m_remove_selection->setEnabled(true);
}
@@ -197,14 +192,6 @@ void DynamicElementTextItemEditor::dataEdited()
apply();
}
-void DynamicElementTextItemEditor::treeViewClicked(const QModelIndex &index)
-{
- if(m_model->indexIsText(index) || m_model->indexIsGroup(index))
- ui->m_remove_selection->setEnabled(true);
- else
- ui->m_remove_selection->setDisabled(true);
-}
-
/**
* @brief DynamicElementTextItemEditor::on_m_add_text_clicked
* Add a new dynamic text
@@ -232,7 +219,7 @@ void DynamicElementTextItemEditor::on_m_add_text_clicked()
*/
void DynamicElementTextItemEditor::on_m_remove_selection_clicked()
{
- DynamicElementTextItem *deti = m_model->textFromIndex(m_tree_view->currentIndex());
+ DynamicElementTextItem *deti = m_model->textFromIndex(ui->m_tree_view->currentIndex());
if(deti)
{
if(m_element->diagram())
@@ -243,7 +230,7 @@ void DynamicElementTextItemEditor::on_m_remove_selection_clicked()
}
return;
}
- ElementTextItemGroup *group = m_model->groupFromIndex(m_tree_view->currentIndex());
+ ElementTextItemGroup *group = m_model->groupFromIndex(ui->m_tree_view->currentIndex());
if(group && m_element.data()->diagram())
m_element.data()->diagram()->undoStack().push(new RemoveTextsGroupCommand(m_element.data(), group));
}
@@ -261,3 +248,11 @@ void DynamicElementTextItemEditor::on_m_add_group_clicked()
else if (m_element.data()->diagram())
m_element.data()->diagram()->undoStack().push(new AddTextsGroupCommand(m_element, name));
}
+
+void DynamicElementTextItemEditor::on_m_tree_view_clicked(const QModelIndex &index)
+{
+ if(m_model->indexIsText(index) || m_model->indexIsGroup(index))
+ ui->m_remove_selection->setEnabled(true);
+ else
+ ui->m_remove_selection->setDisabled(true);
+}
diff --git a/sources/ui/dynamicelementtextitemeditor.h b/sources/ui/dynamicelementtextitemeditor.h
index 2d4b2ca31..a47baaad9 100644
--- a/sources/ui/dynamicelementtextitemeditor.h
+++ b/sources/ui/dynamicelementtextitemeditor.h
@@ -22,7 +22,6 @@
class DynamicElementTextItem;
class DynamicElementTextModel;
-class QTreeView;
class QStandardItem;
class ElementTextItemGroup;
@@ -48,16 +47,15 @@ class DynamicElementTextItemEditor : public AbstractElementPropertiesEditorWidge
private:
void dataEdited();
- void treeViewClicked(const QModelIndex &index);
private slots:
void on_m_add_text_clicked();
void on_m_remove_selection_clicked();
void on_m_add_group_clicked();
+ void on_m_tree_view_clicked(const QModelIndex &index);
private:
Ui::DynamicElementTextItemEditor *ui;
- QTreeView *m_tree_view = nullptr;
DynamicElementTextModel *m_model = nullptr;
};
diff --git a/sources/ui/dynamicelementtextitemeditor.ui b/sources/ui/dynamicelementtextitemeditor.ui
index bd9cfbfcf..ed379f75a 100644
--- a/sources/ui/dynamicelementtextitemeditor.ui
+++ b/sources/ui/dynamicelementtextitemeditor.ui
@@ -73,6 +73,43 @@
+ -
+
+
+ QAbstractItemView::CurrentChanged|QAbstractItemView::SelectedClicked
+
+
+ QAbstractItemView::DragDrop
+
+
+ true
+
+
+ true
+
+
+ 150
+
+
+
+ -
+
+
-
+
+
+ Exporter
+
+
+
+ -
+
+
+ Importer
+
+
+
+
+
diff --git a/sources/ui/dynamicelementtextmodel.cpp b/sources/ui/dynamicelementtextmodel.cpp
index ac94dd06e..e41ce7b4f 100644
--- a/sources/ui/dynamicelementtextmodel.cpp
+++ b/sources/ui/dynamicelementtextmodel.cpp
@@ -520,6 +520,11 @@ QUndoCommand *DynamicElementTextModel::undoForEditedGroup(ElementTextItemGroup *
if(group->verticalAdjustment() != v_adjustment)
new QPropertyUndoCommand(group, "verticalAdjustment", QVariant(group->verticalAdjustment()), QVariant(v_adjustment), undo);
+ QString name = group_qsi->data(Qt::DisplayRole).toString();
+ if(group->name() != name)
+ new QPropertyUndoCommand(group, "name", QVariant(group->name()), QVariant(name), undo);
+
+
return undo;
}
@@ -535,7 +540,7 @@ void DynamicElementTextModel::addGroup(ElementTextItemGroup *group)
//Group
QStandardItem *grp = new QStandardItem(group->name());
- grp->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDropEnabled);
+ grp->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDropEnabled | Qt::ItemIsEditable);
grp->setIcon(QET::Icons::textGroup);
QStandardItem *empty_qsi = new QStandardItem(0);
@@ -836,7 +841,7 @@ bool DynamicElementTextModel::dropMimeData(const QMimeData *data, Qt::DropAction
if(group && deti) //Text successfully added in a group
{
m_element.data()->diagram()->undoStack().push(new AddTextToGroupCommand(deti, group));
- return false;
+ return true;
}
}
}
@@ -860,7 +865,7 @@ bool DynamicElementTextModel::dropMimeData(const QMimeData *data, Qt::DropAction
stack.push(new AddTextToGroupCommand(deti, group));
stack.endMacro();
- return false;
+ return true;
}
}
}
@@ -889,7 +894,7 @@ bool DynamicElementTextModel::dropMimeData(const QMimeData *data, Qt::DropAction
if(deti && group) //Text successfully removed from group
{
m_element.data()->diagram()->undoStack().push((new RemoveTextFromGroupCommand(deti, group)));
- return false;
+ return true;
}
return false;
@@ -1020,8 +1025,8 @@ void DynamicElementTextModel::itemDataChanged(QStandardItem *qsi)
}
//We emit the signal only if @qsi is in the second column, because the data are stored on this column
- //the first column is use only for display the title of the property
- if(qsi->column() == 1 && !m_block_dataChanged)
+ //the first column is use only for display the title of the property, except for the name of texts group
+ if((m_groups_list.values().contains(qsi) || qsi->column() == 1) && !m_block_dataChanged)
emit dataChanged();
}
@@ -1083,6 +1088,7 @@ void DynamicElementTextModel::setConnection(ElementTextItemGroup *group, bool se
connection_list << connect(group, &ElementTextItemGroup::alignmentChanged, [group, this]() {this->updateDataFromGroup(group, grp_alignment);});
connection_list << connect(group, &ElementTextItemGroup::rotationChanged, [group, this]() {this->updateDataFromGroup(group, grp_rotation);});
connection_list << connect(group, &ElementTextItemGroup::verticalAdjustmentChanged, [group, this]() {this->updateDataFromGroup(group, grp_v_adjust);});
+ connection_list << connect(group, &ElementTextItemGroup::verticalAdjustmentChanged, [group, this]() {this->updateDataFromGroup(group, grp_name);});
m_hash_group_connect.insert(group, connection_list);
}
@@ -1203,6 +1209,9 @@ void DynamicElementTextModel::updateDataFromGroup(ElementTextItemGroup *group, D
case grp_v_adjust:
qsi->child(adjust_grp_row,1)->setData(group->verticalAdjustment(), Qt::EditRole);
break;
+ case grp_name:
+ qsi->setData(group->name(), Qt::DisplayRole);
+ break;
}
m_block_dataChanged = false;
diff --git a/sources/ui/dynamicelementtextmodel.h b/sources/ui/dynamicelementtextmodel.h
index 2c08c5508..0c64b8e56 100644
--- a/sources/ui/dynamicelementtextmodel.h
+++ b/sources/ui/dynamicelementtextmodel.h
@@ -49,7 +49,8 @@ class DynamicElementTextModel : public QStandardItemModel
rotation,
grp_alignment,
grp_rotation,
- grp_v_adjust
+ grp_v_adjust,
+ grp_name
};
DynamicElementTextModel(Element *element, QObject *parent = nullptr);