2007-12-01 10:47:15 +00:00
|
|
|
/*
|
|
|
|
Copyright 2006-2007 Xavier Guerrin
|
|
|
|
This file is part of QElectroTech.
|
|
|
|
|
|
|
|
QElectroTech is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
QElectroTech is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2007-08-25 03:43:05 +00:00
|
|
|
#include "elementview.h"
|
|
|
|
/**
|
|
|
|
Constructeur
|
|
|
|
@param scene ElementScene visualisee par cette ElementView
|
|
|
|
@param parent QWidget parent de cette ElementView
|
|
|
|
*/
|
|
|
|
ElementView::ElementView(ElementScene *scene, QWidget *parent) :
|
|
|
|
QGraphicsView(scene, parent),
|
2007-10-12 10:58:57 +00:00
|
|
|
scene_(scene)
|
2007-08-25 03:43:05 +00:00
|
|
|
{
|
|
|
|
setInteractive(true);
|
|
|
|
setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
|
|
|
//setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
|
|
|
|
setResizeAnchor(QGraphicsView::AnchorUnderMouse);
|
|
|
|
//setSceneRect(QRectF(0.0, 0.0, 50.0, 200.0));
|
|
|
|
scale(4.0, 4.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Destructeur
|
|
|
|
ElementView::~ElementView() {
|
|
|
|
}
|
|
|
|
|
|
|
|
/// @return l'ElementScene visualisee par cette ElementView
|
|
|
|
ElementScene *ElementView::scene() const {
|
2007-10-12 10:58:57 +00:00
|
|
|
return(scene_);
|
2007-08-25 03:43:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Definit l'ElementScene visualisee par cette ElementView
|
|
|
|
@param s l'ElementScene visualisee par cette ElementView
|
|
|
|
*/
|
|
|
|
void ElementView::setScene(ElementScene *s) {
|
|
|
|
QGraphicsView::setScene(s);
|
2007-10-12 10:58:57 +00:00
|
|
|
scene_ = s;
|
|
|
|
}
|
|
|
|
|
2007-12-05 21:16:01 +00:00
|
|
|
/**
|
|
|
|
Gere les evenements envoyes a la vue.
|
|
|
|
Methode reimplentee pour gerer le conflit de raccourcis avec Suppr
|
|
|
|
(supprimer une partie ou supprimer le caractere suivant)
|
|
|
|
@param e evenement a gerer
|
|
|
|
*/
|
2007-10-12 10:58:57 +00:00
|
|
|
bool ElementView::event(QEvent *e) {
|
|
|
|
if (e -> type() == QEvent::ShortcutOverride && scene_ -> focusItem()) {
|
|
|
|
e -> accept();
|
|
|
|
return(true);
|
|
|
|
}
|
|
|
|
return(QGraphicsView::event(e));
|
2007-08-25 03:43:05 +00:00
|
|
|
}
|