mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-19 23:20:52 +01:00
Minor : imrpove method
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4753 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -97,11 +97,6 @@ DiagramView::DiagramView(Diagram *diagram, QWidget *parent) :
|
|||||||
connect(diagram, SIGNAL(editElementRequired(ElementsLocation)), this, SIGNAL(editElementRequired(ElementsLocation)));
|
connect(diagram, SIGNAL(editElementRequired(ElementsLocation)), this, SIGNAL(editElementRequired(ElementsLocation)));
|
||||||
connect(diagram, SIGNAL(findElementRequired(ElementsLocation)), this, SIGNAL(findElementRequired(ElementsLocation)));
|
connect(diagram, SIGNAL(findElementRequired(ElementsLocation)), this, SIGNAL(findElementRequired(ElementsLocation)));
|
||||||
|
|
||||||
connect(
|
|
||||||
this, SIGNAL(aboutToSetDroppedTitleBlockTemplate(const TitleBlockTemplateLocation &)),
|
|
||||||
this, SLOT(setDroppedTitleBlockTemplate(const TitleBlockTemplateLocation &)),
|
|
||||||
Qt::QueuedConnection
|
|
||||||
);
|
|
||||||
QShortcut *edit_conductor_color_shortcut = new QShortcut(QKeySequence(Qt::Key_F2), this);
|
QShortcut *edit_conductor_color_shortcut = new QShortcut(QKeySequence(Qt::Key_F2), this);
|
||||||
connect(edit_conductor_color_shortcut, SIGNAL(activated()), this, SLOT(editSelectedConductorColor()));
|
connect(edit_conductor_color_shortcut, SIGNAL(activated()), this, SLOT(editSelectedConductorColor()));
|
||||||
}
|
}
|
||||||
@@ -299,15 +294,51 @@ void DiagramView::handleElementDrop(QDropEvent *event)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Handle the drop of an element.
|
* @brief DiagramView::handleTitleBlockDrop
|
||||||
@param e the QDropEvent describing the current drag'n drop
|
* Handle the dropEvent that contain data of a titleblock
|
||||||
*/
|
* @param e
|
||||||
|
*/
|
||||||
void DiagramView::handleTitleBlockDrop(QDropEvent *e) {
|
void DiagramView::handleTitleBlockDrop(QDropEvent *e) {
|
||||||
// fetch the title block template location from the drop event
|
// fetch the title block template location from the drop event
|
||||||
TitleBlockTemplateLocation tbt_loc;
|
TitleBlockTemplateLocation tbt_loc;
|
||||||
tbt_loc.fromString(e -> mimeData() -> text());
|
tbt_loc.fromString(e->mimeData()->text());
|
||||||
if (tbt_loc.isValid()) {
|
|
||||||
emit(aboutToSetDroppedTitleBlockTemplate(tbt_loc));
|
|
||||||
|
if (tbt_loc.isValid())
|
||||||
|
{
|
||||||
|
// fetch the current title block properties
|
||||||
|
TitleBlockProperties titleblock_properties_before = scene->border_and_titleblock.exportTitleBlock();
|
||||||
|
|
||||||
|
// check the provided template is not already applied
|
||||||
|
QETProject *tbt_parent_project = tbt_loc.parentProject();
|
||||||
|
if (tbt_parent_project && tbt_parent_project == scene -> project())
|
||||||
|
{
|
||||||
|
// same parent project and same name = same title block template
|
||||||
|
if (tbt_loc.name() == titleblock_properties_before.template_name)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// integrate the provided template into the project if needed
|
||||||
|
QString integrated_template_name = tbt_loc.name();
|
||||||
|
if (mustIntegrateTitleBlockTemplate(tbt_loc))
|
||||||
|
{
|
||||||
|
IntegrationMoveTitleBlockTemplatesHandler *handler = new IntegrationMoveTitleBlockTemplatesHandler(this);
|
||||||
|
//QString error_message;
|
||||||
|
integrated_template_name = scene->project()->integrateTitleBlockTemplate(tbt_loc, handler);
|
||||||
|
|
||||||
|
if (integrated_template_name.isEmpty())
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// apply the provided title block template
|
||||||
|
if (titleblock_properties_before.template_name == integrated_template_name)
|
||||||
|
return;
|
||||||
|
|
||||||
|
TitleBlockProperties titleblock_properties_after = titleblock_properties_before;
|
||||||
|
titleblock_properties_after.template_name = integrated_template_name;
|
||||||
|
scene->undoStack().push(new ChangeTitleBlockCommand(scene, titleblock_properties_before, titleblock_properties_after));
|
||||||
|
|
||||||
|
adjustSceneRect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1250,34 +1281,3 @@ void DiagramView::mouseDoubleClickEvent(QMouseEvent *e)
|
|||||||
}
|
}
|
||||||
QGraphicsView::mouseDoubleClickEvent(e);
|
QGraphicsView::mouseDoubleClickEvent(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
@param tbt TitleBlockTemplateLocation
|
|
||||||
*/
|
|
||||||
void DiagramView::setDroppedTitleBlockTemplate(const TitleBlockTemplateLocation &tbt) {
|
|
||||||
// fetch the current title block properties
|
|
||||||
TitleBlockProperties titleblock_properties_before = scene -> border_and_titleblock.exportTitleBlock();
|
|
||||||
|
|
||||||
// check the provided template is not already applied
|
|
||||||
QETProject *tbt_parent_project = tbt.parentProject();
|
|
||||||
if (tbt_parent_project && tbt_parent_project == scene -> project()) {
|
|
||||||
// same parent project and same name = same title block template
|
|
||||||
if (tbt.name() == titleblock_properties_before.template_name) return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// integrate the provided template into the project if needed
|
|
||||||
QString integrated_template_name = tbt.name();
|
|
||||||
if (mustIntegrateTitleBlockTemplate(tbt)) {
|
|
||||||
IntegrationMoveTitleBlockTemplatesHandler *handler = new IntegrationMoveTitleBlockTemplatesHandler(this);
|
|
||||||
//QString error_message;
|
|
||||||
integrated_template_name = scene -> project() -> integrateTitleBlockTemplate(tbt, handler);
|
|
||||||
if (integrated_template_name.isEmpty()) return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// apply the provided title block template
|
|
||||||
if (titleblock_properties_before.template_name == integrated_template_name) return;
|
|
||||||
TitleBlockProperties titleblock_properties_after = titleblock_properties_before;
|
|
||||||
titleblock_properties_after.template_name = integrated_template_name;
|
|
||||||
scene -> undoStack().push(new ChangeTitleBlockCommand(scene, titleblock_properties_before, titleblock_properties_after));
|
|
||||||
adjustSceneRect();
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -58,98 +58,93 @@ class DiagramView : public QGraphicsView
|
|||||||
bool fresh_focus_in_; ///< Indicate the focus was freshly gained
|
bool fresh_focus_in_; ///< Indicate the focus was freshly gained
|
||||||
bool m_first_activation;
|
bool m_first_activation;
|
||||||
|
|
||||||
|
|
||||||
// methods
|
|
||||||
public:
|
public:
|
||||||
QString title() const;
|
QString title() const;
|
||||||
void editDiagramProperties();
|
void editDiagramProperties();
|
||||||
void addColumn();
|
void addColumn();
|
||||||
void removeColumn();
|
void removeColumn();
|
||||||
void addRow();
|
void addRow();
|
||||||
void removeRow();
|
void removeRow();
|
||||||
/// @return the diagram rendered by this view
|
/// @return the diagram rendered by this view
|
||||||
Diagram *diagram() { return(scene); }
|
Diagram *diagram() { return(scene); }
|
||||||
QETDiagramEditor *diagramEditor() const;
|
QETDiagramEditor *diagramEditor() const;
|
||||||
bool hasSelectedItems();
|
bool hasSelectedItems();
|
||||||
bool hasCopiableItems();
|
bool hasCopiableItems();
|
||||||
bool hasTextItems();
|
bool hasTextItems();
|
||||||
bool hasDeletableItems();
|
bool hasDeletableItems();
|
||||||
void editSelection();
|
void editSelection();
|
||||||
void setEventInterface (DVEventInterface *event_interface);
|
void setEventInterface (DVEventInterface *event_interface);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void mouseDoubleClickEvent(QMouseEvent *);
|
virtual void mouseDoubleClickEvent(QMouseEvent *);
|
||||||
virtual void contextMenuEvent(QContextMenuEvent *);
|
virtual void contextMenuEvent(QContextMenuEvent *);
|
||||||
virtual void wheelEvent(QWheelEvent *);
|
virtual void wheelEvent(QWheelEvent *);
|
||||||
virtual void focusInEvent(QFocusEvent *);
|
virtual void focusInEvent(QFocusEvent *);
|
||||||
virtual void keyPressEvent(QKeyEvent *);
|
virtual void keyPressEvent(QKeyEvent *);
|
||||||
virtual void keyReleaseEvent(QKeyEvent *);
|
virtual void keyReleaseEvent(QKeyEvent *);
|
||||||
virtual bool event(QEvent *);
|
virtual bool event(QEvent *);
|
||||||
virtual bool switchToVisualisationModeIfNeeded(QInputEvent *e);
|
virtual bool switchToVisualisationModeIfNeeded(QInputEvent *e);
|
||||||
virtual bool switchToSelectionModeIfNeeded(QInputEvent *e);
|
virtual bool switchToSelectionModeIfNeeded(QInputEvent *e);
|
||||||
virtual bool isCtrlShifting(QInputEvent *);
|
virtual bool isCtrlShifting(QInputEvent *);
|
||||||
virtual bool selectedItemHasFocus();
|
virtual bool selectedItemHasFocus();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void mousePressEvent(QMouseEvent *);
|
void mousePressEvent(QMouseEvent *);
|
||||||
void mouseMoveEvent(QMouseEvent *);
|
void mouseMoveEvent(QMouseEvent *);
|
||||||
void mouseReleaseEvent(QMouseEvent *);
|
void mouseReleaseEvent(QMouseEvent *);
|
||||||
void dragEnterEvent(QDragEnterEvent *);
|
void dragEnterEvent(QDragEnterEvent *);
|
||||||
void dragLeaveEvent(QDragLeaveEvent *);
|
void dragLeaveEvent(QDragLeaveEvent *);
|
||||||
void dragMoveEvent(QDragMoveEvent *);
|
void dragMoveEvent(QDragMoveEvent *);
|
||||||
void dropEvent(QDropEvent *);
|
void dropEvent(QDropEvent *);
|
||||||
void handleElementDrop(QDropEvent *);
|
void handleElementDrop(QDropEvent *);
|
||||||
void handleTitleBlockDrop(QDropEvent *);
|
void handleTitleBlockDrop(QDropEvent *);
|
||||||
void handleTextDrop(QDropEvent *);
|
void handleTextDrop(QDropEvent *);
|
||||||
void scrollOnMovement(QKeyEvent *);
|
void scrollOnMovement(QKeyEvent *);
|
||||||
bool gestureEvent(QGestureEvent *event);
|
bool gestureEvent(QGestureEvent *event);
|
||||||
QRectF viewedSceneRect() const;
|
QRectF viewedSceneRect() const;
|
||||||
bool mustIntegrateTitleBlockTemplate(const TitleBlockTemplateLocation &) const;
|
bool mustIntegrateTitleBlockTemplate(const TitleBlockTemplateLocation &) const;
|
||||||
bool gestures() const;
|
bool gestures() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
/// Signal emitted after the selection changed
|
/// Signal emitted after the selection changed
|
||||||
void selectionChanged();
|
void selectionChanged();
|
||||||
/// Signal emitted after the selection mode changed
|
/// Signal emitted after the selection mode changed
|
||||||
void modeChanged();
|
void modeChanged();
|
||||||
/// Signal emitted after the diagram title changed
|
/// Signal emitted after the diagram title changed
|
||||||
void titleChanged(DiagramView *, const QString &);
|
void titleChanged(DiagramView *, const QString &);
|
||||||
/// Signal emitted before integrating a title block template
|
/// Signal emitted when users wish to locate an element from the diagram within elements collection
|
||||||
void aboutToSetDroppedTitleBlockTemplate(const TitleBlockTemplateLocation &);
|
void findElementRequired(const ElementsLocation &);
|
||||||
/// Signal emitted when users wish to locate an element from the diagram within elements collection
|
/// Signal emitted when users wish to edit an element from the diagram
|
||||||
void findElementRequired(const ElementsLocation &);
|
void editElementRequired(const ElementsLocation &);
|
||||||
/// Signal emitted when users wish to edit an element from the diagram
|
/// Signal emmitted when diagram must be show
|
||||||
void editElementRequired(const ElementsLocation &);
|
void showDiagram (Diagram *);
|
||||||
/// Signal emmitted when diagram must be show
|
|
||||||
void showDiagram (Diagram *);
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void selectNothing();
|
void selectNothing();
|
||||||
void selectAll();
|
void selectAll();
|
||||||
void selectInvert();
|
void selectInvert();
|
||||||
void deleteSelection();
|
void deleteSelection();
|
||||||
void rotateSelection();
|
void rotateSelection();
|
||||||
void rotateTexts();
|
void rotateTexts();
|
||||||
void setVisualisationMode();
|
void setVisualisationMode();
|
||||||
void setSelectionMode();
|
void setSelectionMode();
|
||||||
void zoom(const qreal zoom_factor);
|
void zoom(const qreal zoom_factor);
|
||||||
void zoomFit();
|
void zoomFit();
|
||||||
void zoomContent();
|
void zoomContent();
|
||||||
void zoomReset();
|
void zoomReset();
|
||||||
void cut();
|
void cut();
|
||||||
void copy();
|
void copy();
|
||||||
void paste(const QPointF & = QPointF(), QClipboard::Mode = QClipboard::Clipboard);
|
void paste(const QPointF & = QPointF(), QClipboard::Mode = QClipboard::Clipboard);
|
||||||
void pasteHere();
|
void pasteHere();
|
||||||
void adjustSceneRect();
|
void adjustSceneRect();
|
||||||
void updateWindowTitle();
|
void updateWindowTitle();
|
||||||
void editSelectionProperties();
|
void editSelectionProperties();
|
||||||
void editSelectedConductorColor();
|
void editSelectedConductorColor();
|
||||||
void editConductorColor(Conductor *);
|
void editConductorColor(Conductor *);
|
||||||
void resetConductors();
|
void resetConductors();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void setDroppedTitleBlockTemplate(const TitleBlockTemplateLocation &);
|
void adjustGridToZoom();
|
||||||
void adjustGridToZoom();
|
void applyReadOnly();
|
||||||
void applyReadOnly();
|
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user