mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 20:50:34 +01:00
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:
@@ -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
|
* @brief DiagramView::editSelection
|
||||||
* open edit image dialog if only one image is selected
|
* Edit the selected item if he can be edited and if only one item is selected
|
||||||
*/
|
*/
|
||||||
void DiagramView::editImage() {
|
void DiagramView::editSelection() {
|
||||||
if (scene -> isReadOnly()) return;
|
if (scene -> isReadOnly() || scene -> selectedItems().size() != 1 ) 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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
if (IndependentTextItem *iti = qgraphicsitem_cast<IndependentTextItem *>(scene->selectedItems().first())) {
|
||||||
* @brief DiagramView::editShape
|
iti -> edit();
|
||||||
* open edit image dialog if only one shape is selected
|
} else if (QetGraphicsItem *qgi = qgraphicsitem_cast<QetGraphicsItem *> (scene->selectedItems().first())) {
|
||||||
*/
|
qgi -> editProperty();
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -69,10 +69,7 @@ class DiagramView : public QGraphicsView {
|
|||||||
bool hasSelectedItems();
|
bool hasSelectedItems();
|
||||||
bool hasCopiableItems();
|
bool hasCopiableItems();
|
||||||
bool hasDeletableItems();
|
bool hasDeletableItems();
|
||||||
void addText();
|
void editSelection();
|
||||||
void editText();
|
|
||||||
void editImage();
|
|
||||||
void editShape();
|
|
||||||
void setEventInterface (DVEventInterface *interface);
|
void setEventInterface (DVEventInterface *interface);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
@@ -1575,14 +1575,7 @@ void QETDiagramEditor::slot_editSelection() {
|
|||||||
if (DiagramView *dv = currentDiagram()) {
|
if (DiagramView *dv = currentDiagram()) {
|
||||||
DiagramContent dc = dv -> diagram() -> selectedContent();
|
DiagramContent dc = dv -> diagram() -> selectedContent();
|
||||||
if (dc.count(DiagramContent::SelectedOnly | DiagramContent::All) != 1) return;
|
if (dc.count(DiagramContent::SelectedOnly | DiagramContent::All) != 1) return;
|
||||||
|
dv->editSelection();
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user