Diagrameditor / view, revamp the way to edit selection.

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3331 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
blacksun
2014-09-25 09:44:41 +00:00
parent 69f239d197
commit 016f24dcda
3 changed files with 10 additions and 53 deletions

View File

@@ -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<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();
}
}

View File

@@ -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:

View File

@@ -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();
}
}