mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-19 23:20:52 +01:00
Lors du deplacement d'un champ de texte rattache a un conducteur, ce dernier est desormais mis en evidence.
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/branches/0.3@988 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -48,7 +48,8 @@ Conductor::Conductor(Terminal *p1, Terminal* p2, Diagram *parent_diagram) :
|
||||
previous_z_value(zValue()),
|
||||
modified_path(false),
|
||||
has_to_save_profile(false),
|
||||
segments_squares_scale_(1.0)
|
||||
segments_squares_scale_(1.0),
|
||||
must_highlight_(Conductor::None)
|
||||
{
|
||||
// ajout du conducteur a la liste de conducteurs de chacune des deux bornes
|
||||
bool ajout_p1 = terminal1 -> addConductor(this);
|
||||
@@ -419,16 +420,13 @@ void Conductor::paint(QPainter *qp, const QStyleOptionGraphicsItem *options, QWi
|
||||
qp -> save();
|
||||
qp -> setRenderHint(QPainter::Antialiasing, false);
|
||||
|
||||
/*
|
||||
qp -> save();
|
||||
qp -> setPen(Qt::blue);
|
||||
qp -> drawPath(variableShape(60.0).simplified());
|
||||
qp -> restore();
|
||||
*/
|
||||
|
||||
// determine la couleur du conducteur
|
||||
QColor final_conductor_color(properties_.color);
|
||||
if (isSelected()) {
|
||||
if (must_highlight_ == Normal) {
|
||||
final_conductor_color = QColor::fromRgb(69, 137, 255, 255);
|
||||
} else if (must_highlight_ == Alert) {
|
||||
final_conductor_color =QColor::fromRgb(255, 69, 0, 255);
|
||||
} else if (isSelected()) {
|
||||
final_conductor_color = Qt::red;
|
||||
} else {
|
||||
if (Diagram *parent_diagram = diagram()) {
|
||||
@@ -1234,6 +1232,21 @@ void Conductor::adjustTextItemPosition() {
|
||||
calculateTextItemPosition();
|
||||
}
|
||||
|
||||
/**
|
||||
@return true si le conducteur est mis en evidence
|
||||
*/
|
||||
Conductor::Highlight Conductor::highlight() const {
|
||||
return(must_highlight_);
|
||||
}
|
||||
|
||||
/**
|
||||
@param hl true pour mettre le conducteur en evidence, false sinon
|
||||
*/
|
||||
void Conductor::setHighlighted(Conductor::Highlight hl) {
|
||||
must_highlight_ = hl;
|
||||
update();
|
||||
}
|
||||
|
||||
/**
|
||||
Met a jour les proprietes du conducteur apres modification du champ de texte affiche
|
||||
*/
|
||||
|
||||
@@ -44,6 +44,7 @@ class Conductor : public QObject, public QGraphicsPathItem {
|
||||
// attributs
|
||||
public:
|
||||
enum { Type = UserType + 1001 };
|
||||
enum Highlight { None, Normal, Alert };
|
||||
|
||||
/// premiere borne a laquelle le fil est rattache
|
||||
Terminal *terminal1;
|
||||
@@ -87,6 +88,8 @@ class Conductor : public QObject, public QGraphicsPathItem {
|
||||
ConductorProfilesGroup profiles() const;
|
||||
void readProperties();
|
||||
void adjustTextItemPosition();
|
||||
virtual Highlight highlight() const;
|
||||
virtual void setHighlighted(Highlight);
|
||||
|
||||
public slots:
|
||||
void displayedTextChanged();
|
||||
@@ -130,6 +133,8 @@ class Conductor : public QObject, public QGraphicsPathItem {
|
||||
static bool pen_and_brush_initialized;
|
||||
/// facteur de taille du carre de saisie du segment
|
||||
qreal segments_squares_scale_;
|
||||
/// Definit la facon dont le conducteur doit etre mis en evidence
|
||||
Highlight must_highlight_;
|
||||
|
||||
private:
|
||||
void segmentsToPath();
|
||||
|
||||
@@ -27,7 +27,8 @@
|
||||
ConductorTextItem::ConductorTextItem(Conductor *parent_conductor, Diagram *parent_diagram) :
|
||||
DiagramTextItem(parent_conductor, parent_diagram),
|
||||
parent_conductor_(parent_conductor),
|
||||
moved_by_user_(false)
|
||||
moved_by_user_(false),
|
||||
first_move_(true)
|
||||
{
|
||||
// par defaut, les DiagramTextItem sont Selectable et Movable
|
||||
// cela nous convient, on ne touche pas a ces flags
|
||||
@@ -42,7 +43,8 @@ ConductorTextItem::ConductorTextItem(Conductor *parent_conductor, Diagram *paren
|
||||
ConductorTextItem::ConductorTextItem(const QString &text, Conductor *parent_conductor, Diagram *parent_diagram) :
|
||||
DiagramTextItem(text, parent_conductor, parent_diagram),
|
||||
parent_conductor_(parent_conductor),
|
||||
moved_by_user_(false)
|
||||
moved_by_user_(false),
|
||||
first_move_(true)
|
||||
{
|
||||
// par defaut, les DiagramTextItem sont Selectable et Movable
|
||||
// cela nous convient, on ne touche pas a ces flags
|
||||
@@ -128,6 +130,7 @@ void ConductorTextItem::mousePressEvent(QGraphicsSceneMouseEvent *e) {
|
||||
if ((flags() & QGraphicsItem::ItemIsMovable) && (e -> buttons() & Qt::LeftButton)) {
|
||||
before_mov_pos_ = pos();
|
||||
}
|
||||
first_move_ = true;
|
||||
DiagramTextItem::mousePressEvent(e);
|
||||
}
|
||||
|
||||
@@ -147,10 +150,17 @@ void ConductorTextItem::mouseMoveEvent(QGraphicsSceneMouseEvent *e) {
|
||||
if (parent_conductor_) {
|
||||
if (parent_conductor_ -> isNearConductor(intended_pos)) {
|
||||
setPos(intended_pos);
|
||||
parent_conductor_ -> setHighlighted(Conductor::Normal);
|
||||
} else {
|
||||
parent_conductor_ -> setHighlighted(Conductor::Alert);
|
||||
}
|
||||
}
|
||||
|
||||
} else e -> ignore();
|
||||
|
||||
if (first_move_) {
|
||||
first_move_ = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -174,6 +184,10 @@ void ConductorTextItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) {
|
||||
|
||||
diagram_ptr -> undoStack().push(undo_object);
|
||||
}
|
||||
|
||||
if (parent_conductor_) {
|
||||
parent_conductor_ -> setHighlighted(Conductor::None);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!(e -> modifiers() & Qt::ControlModifier)) {
|
||||
|
||||
@@ -60,5 +60,6 @@ class ConductorTextItem : public DiagramTextItem {
|
||||
Conductor *parent_conductor_;
|
||||
bool moved_by_user_;
|
||||
QPointF before_mov_pos_;
|
||||
bool first_move_;
|
||||
};
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user