[qet] [3331] Diagrameditor / view, revamp the way to edit selection. |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/qet Archives
]
Revision: 3331
Author: blacksun
Date: 2014-09-25 11:44:41 +0200 (Thu, 25 Sep 2014)
Log Message:
-----------
Diagrameditor / view, revamp the way to edit selection.
Modified Paths:
--------------
trunk/sources/diagramview.cpp
trunk/sources/diagramview.h
trunk/sources/qetdiagrameditor.cpp
Modified: trunk/sources/diagramview.cpp
===================================================================
--- trunk/sources/diagramview.cpp 2014-09-24 20:15:01 UTC (rev 3330)
+++ trunk/sources/diagramview.cpp 2014-09-25 09:44:41 UTC (rev 3331)
@@ -1055,50 +1055,17 @@
);
}
-/** To edit the text through the htmlEditor
-*/
-void DiagramView::editText() {
- if (scene -> isReadOnly()) return;
- // Get text to edit
- QList<DiagramTextItem *> texts_to_edit;
- foreach (QGraphicsItem *item, scene -> selectedItems()) {
- if (IndependentTextItem *iti = qgraphicsitem_cast<IndependentTextItem *>(item)) {
- texts_to_edit << iti;
- } else if (ElementTextItem *eti = qgraphicsitem_cast<ElementTextItem *>(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 <QGraphicsItem *> images = diagram() -> selectedContent().items(DiagramContent::Images);
- if (images.count() != 1) return;
- DiagramImageItem *image;
- if ((image = qgraphicsitem_cast<DiagramImageItem *> (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 <QGraphicsItem *> shapes = diagram() -> selectedContent().items(DiagramContent::Shapes);
- if (shapes.count() != 1) return;
- QetShapeItem *shape;
- if ((shape = qgraphicsitem_cast<QetShapeItem *> (shapes.first()))) {
- shape -> editProperty();
+ if (IndependentTextItem *iti = qgraphicsitem_cast<IndependentTextItem *>(scene->selectedItems().first())) {
+ iti -> edit();
+ } else if (QetGraphicsItem *qgi = qgraphicsitem_cast<QetGraphicsItem *> (scene->selectedItems().first())) {
+ qgi -> editProperty();
}
}
Modified: trunk/sources/diagramview.h
===================================================================
--- trunk/sources/diagramview.h 2014-09-24 20:15:01 UTC (rev 3330)
+++ trunk/sources/diagramview.h 2014-09-25 09:44:41 UTC (rev 3331)
@@ -69,10 +69,7 @@
bool hasSelectedItems();
bool hasCopiableItems();
bool hasDeletableItems();
- void addText();
- void editText();
- void editImage();
- void editShape();
+ void editSelection();
void setEventInterface (DVEventInterface *interface);
protected:
Modified: trunk/sources/qetdiagrameditor.cpp
===================================================================
--- trunk/sources/qetdiagrameditor.cpp 2014-09-24 20:15:01 UTC (rev 3330)
+++ trunk/sources/qetdiagrameditor.cpp 2014-09-25 09:44:41 UTC (rev 3331)
@@ -1575,14 +1575,7 @@
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();
}
}