mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-18 05:00:33 +01:00
Minor code change
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3916 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -173,6 +173,17 @@ void ElementScene::keyPressEvent(QKeyEvent *event) {
|
|||||||
QGraphicsScene::keyPressEvent(event);
|
QGraphicsScene::keyPressEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief ElementScene::contextMenuEvent
|
||||||
|
* Display the context menu event, only if behavior are Normal
|
||||||
|
* @param event
|
||||||
|
*/
|
||||||
|
void ElementScene::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||||
|
{
|
||||||
|
if (behavior == ElementScene::Normal)
|
||||||
|
element_editor -> contextMenu(event->screenPos());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Dessine l'arriere-plan de l'editeur, cad l'indicateur de hotspot.
|
Dessine l'arriere-plan de l'editeur, cad l'indicateur de hotspot.
|
||||||
@param p Le QPainter a utiliser pour dessiner
|
@param p Le QPainter a utiliser pour dessiner
|
||||||
@@ -211,6 +222,16 @@ void ElementScene::setEventInterface(ESEventInterface *event_interface) {
|
|||||||
m_event_interface = event_interface;
|
m_event_interface = event_interface;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief ElementScene::setBehavior
|
||||||
|
* Modifie the current behavior of this scene
|
||||||
|
* @param b
|
||||||
|
*/
|
||||||
|
void ElementScene::setBehavior(ElementScene::Behavior b)
|
||||||
|
{
|
||||||
|
behavior = b;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@return la taille horizontale de la grille
|
@return la taille horizontale de la grille
|
||||||
*/
|
*/
|
||||||
@@ -460,11 +481,6 @@ void ElementScene::copy() {
|
|||||||
last_copied_ = clipboard_content;
|
last_copied_ = clipboard_content;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ElementScene::contextMenu(QContextMenuEvent *event) {
|
|
||||||
if (behavior == ElementScene::Normal)
|
|
||||||
element_editor -> contextMenu(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
QETElementEditor* ElementScene::editor() const {
|
QETElementEditor* ElementScene::editor() const {
|
||||||
return element_editor;
|
return element_editor;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ class ElementScene : public QGraphicsScene {
|
|||||||
|
|
||||||
// enum
|
// enum
|
||||||
public:
|
public:
|
||||||
enum Behavior { Normal, PasteArea };
|
enum Behavior { Normal, PasteArea, AddPart };
|
||||||
enum ItemOption {
|
enum ItemOption {
|
||||||
SortByZValue = 1,
|
SortByZValue = 1,
|
||||||
IncludeTerminals = 2,
|
IncludeTerminals = 2,
|
||||||
@@ -105,6 +105,7 @@ class ElementScene : public QGraphicsScene {
|
|||||||
// methods
|
// methods
|
||||||
public:
|
public:
|
||||||
void setEventInterface (ESEventInterface *event_interface);
|
void setEventInterface (ESEventInterface *event_interface);
|
||||||
|
void setBehavior (ElementScene::Behavior);
|
||||||
QPointF snapToGrid(QPointF point);
|
QPointF snapToGrid(QPointF point);
|
||||||
void setNames(const NamesList &);
|
void setNames(const NamesList &);
|
||||||
NamesList names() const;
|
NamesList names() const;
|
||||||
@@ -131,7 +132,6 @@ class ElementScene : public QGraphicsScene {
|
|||||||
bool wasCopiedFromThisElement(const QString &);
|
bool wasCopiedFromThisElement(const QString &);
|
||||||
void cut();
|
void cut();
|
||||||
void copy();
|
void copy();
|
||||||
void contextMenu (QContextMenuEvent *event);
|
|
||||||
QETElementEditor* editor() const;
|
QETElementEditor* editor() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@@ -140,8 +140,9 @@ class ElementScene : public QGraphicsScene {
|
|||||||
virtual void mouseReleaseEvent (QGraphicsSceneMouseEvent *);
|
virtual void mouseReleaseEvent (QGraphicsSceneMouseEvent *);
|
||||||
virtual void mouseDoubleClickEvent (QGraphicsSceneMouseEvent *event);
|
virtual void mouseDoubleClickEvent (QGraphicsSceneMouseEvent *event);
|
||||||
virtual void keyPressEvent (QKeyEvent *event);
|
virtual void keyPressEvent (QKeyEvent *event);
|
||||||
|
virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent *event);
|
||||||
|
|
||||||
virtual void drawForeground(QPainter *, const QRectF &);
|
virtual void drawForeground(QPainter *, const QRectF &);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QRectF elementContentBoundingRect(const ElementContent &) const;
|
QRectF elementContentBoundingRect(const ElementContent &) const;
|
||||||
|
|||||||
@@ -67,10 +67,6 @@ QRectF ElementView::viewedSceneRect() const {
|
|||||||
return(QRectF(scene_left_top, scene_right_bottom));
|
return(QRectF(scene_left_top, scene_right_bottom));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ElementView::contextMenuEvent(QContextMenuEvent *event) {
|
|
||||||
scene_ -> contextMenu(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Definit l'ElementScene visualisee par cette ElementView
|
Definit l'ElementScene visualisee par cette ElementView
|
||||||
@param s l'ElementScene visualisee par cette ElementView
|
@param s l'ElementScene visualisee par cette ElementView
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ class ElementView : public QGraphicsView {
|
|||||||
ElementScene *scene() const;
|
ElementScene *scene() const;
|
||||||
void setScene(ElementScene *);
|
void setScene(ElementScene *);
|
||||||
QRectF viewedSceneRect() const;
|
QRectF viewedSceneRect() const;
|
||||||
void contextMenuEvent(QContextMenuEvent *event);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void mousePressEvent(QMouseEvent *);
|
void mousePressEvent(QMouseEvent *);
|
||||||
|
|||||||
@@ -31,20 +31,26 @@ ESEventInterface::ESEventInterface(ElementScene *scene) :
|
|||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ESEventInterface::init() {
|
/**
|
||||||
foreach (QGraphicsView *qgv, m_scene->views())
|
* @brief ESEventInterface::init
|
||||||
qgv->setContextMenuPolicy(Qt::NoContextMenu);
|
* Init this event interface
|
||||||
|
*/
|
||||||
|
void ESEventInterface::init()
|
||||||
|
{
|
||||||
|
m_scene->setBehavior(ElementScene::Behavior::AddPart);
|
||||||
m_editor->slot_setNoDragToView();
|
m_editor->slot_setNoDragToView();
|
||||||
}
|
}
|
||||||
|
|
||||||
ESEventInterface::~ESEventInterface() {
|
/**
|
||||||
|
* @brief ESEventInterface::~ESEventInterface
|
||||||
|
* Destructor
|
||||||
|
*/
|
||||||
|
ESEventInterface::~ESEventInterface()
|
||||||
|
{
|
||||||
delete m_help_horiz;
|
delete m_help_horiz;
|
||||||
delete m_help_verti;
|
delete m_help_verti;
|
||||||
|
|
||||||
foreach (QGraphicsView *qgv, m_scene->views())
|
m_scene->setBehavior(ElementScene::Behavior::Normal);
|
||||||
qgv->setContextMenuPolicy(Qt::DefaultContextMenu);
|
|
||||||
|
|
||||||
m_editor->slot_setRubberBandToView();
|
m_editor->slot_setRubberBandToView();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user