diff --git a/sources/diagramview.cpp b/sources/diagramview.cpp index e8323ce5b..3da9fce7b 100644 --- a/sources/diagramview.cpp +++ b/sources/diagramview.cpp @@ -1055,50 +1055,17 @@ bool DiagramView::selectedItemHasFocus() { ); } -/** To edit the text through the htmlEditor -*/ -void DiagramView::editText() { - if (scene -> isReadOnly()) return; - // Get text to edit - QList texts_to_edit; - foreach (QGraphicsItem *item, scene -> selectedItems()) { - if (IndependentTextItem *iti = qgraphicsitem_cast(item)) { - texts_to_edit << iti; - } else if (ElementTextItem *eti = qgraphicsitem_cast(item)) { - // here... - texts_to_edit << eti; - } - } - // Test if any text existe.. - if (texts_to_edit.isEmpty()) return; - else texts_to_edit.at(0)->edit(); -} - /** - * @brief DiagramView::editImage - * open edit image dialog if only one image is selected + * @brief DiagramView::editSelection + * Edit the selected item if he can be edited and if only one item is selected */ -void DiagramView::editImage() { - if (scene -> isReadOnly()) return; - QList images = diagram() -> selectedContent().items(DiagramContent::Images); - if (images.count() != 1) return; - DiagramImageItem *image; - if ((image = qgraphicsitem_cast (images.first()))) { - image -> editProperty(); - } -} +void DiagramView::editSelection() { + if (scene -> isReadOnly() || scene -> selectedItems().size() != 1 ) return; -/** - * @brief DiagramView::editShape - * open edit image dialog if only one shape is selected - */ -void DiagramView::editShape() { - if (scene -> isReadOnly()) return; - QList shapes = diagram() -> selectedContent().items(DiagramContent::Shapes); - if (shapes.count() != 1) return; - QetShapeItem *shape; - if ((shape = qgraphicsitem_cast (shapes.first()))) { - shape -> editProperty(); + if (IndependentTextItem *iti = qgraphicsitem_cast(scene->selectedItems().first())) { + iti -> edit(); + } else if (QetGraphicsItem *qgi = qgraphicsitem_cast (scene->selectedItems().first())) { + qgi -> editProperty(); } } diff --git a/sources/diagramview.h b/sources/diagramview.h index 853ab61c0..cd50905b8 100644 --- a/sources/diagramview.h +++ b/sources/diagramview.h @@ -69,10 +69,7 @@ class DiagramView : public QGraphicsView { bool hasSelectedItems(); bool hasCopiableItems(); bool hasDeletableItems(); - void addText(); - void editText(); - void editImage(); - void editShape(); + void editSelection(); void setEventInterface (DVEventInterface *interface); protected: diff --git a/sources/qetdiagrameditor.cpp b/sources/qetdiagrameditor.cpp index a6a476f5f..737f02d51 100644 --- a/sources/qetdiagrameditor.cpp +++ b/sources/qetdiagrameditor.cpp @@ -1575,14 +1575,7 @@ void QETDiagramEditor::slot_editSelection() { if (DiagramView *dv = currentDiagram()) { DiagramContent dc = dv -> diagram() -> selectedContent(); if (dc.count(DiagramContent::SelectedOnly | DiagramContent::All) != 1) return; - - if (dc.count(DiagramContent::Elements)) { - findSelectedElementInPanel(); - editSelectedElementInEditor(); - } - else if (dc.count(DiagramContent::TextFields)) dv -> editText(); - else if (dc.count(DiagramContent::Images)) dv -> editImage(); - else if (dc.count(DiagramContent::Shapes)) dv -> editShape(); + dv->editSelection(); } }