mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-18 13:30:34 +01:00
Element editor : add text field is managed by ESEvent
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3472 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -79,14 +79,6 @@ void ElementScene::slot_addTerminal() {
|
|||||||
if (m_event_interface) delete m_event_interface; m_event_interface = nullptr;
|
if (m_event_interface) delete m_event_interface; m_event_interface = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
Passe la scene en mode "ajout de champ de texte"
|
|
||||||
*/
|
|
||||||
void ElementScene::slot_addTextField() {
|
|
||||||
behavior = TextField;
|
|
||||||
if (m_event_interface) delete m_event_interface; m_event_interface = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Gere les mouvements de la souris
|
Gere les mouvements de la souris
|
||||||
@param e objet decrivant l'evenement
|
@param e objet decrivant l'evenement
|
||||||
@@ -155,7 +147,6 @@ void ElementScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) {
|
|||||||
if (mustSnapToGrid(e)) event_pos = snapToGrid(event_pos);
|
if (mustSnapToGrid(e)) event_pos = snapToGrid(event_pos);
|
||||||
|
|
||||||
PartTerminal *terminal;
|
PartTerminal *terminal;
|
||||||
PartTextField *textfield;
|
|
||||||
|
|
||||||
if (behavior == PasteArea) {
|
if (behavior == PasteArea) {
|
||||||
defined_paste_area_ = paste_area_ -> rect();
|
defined_paste_area_ = paste_area_ -> rect();
|
||||||
@@ -174,13 +165,6 @@ void ElementScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) {
|
|||||||
emit(partsAdded());
|
emit(partsAdded());
|
||||||
endCurrentBehavior(e);
|
endCurrentBehavior(e);
|
||||||
break;
|
break;
|
||||||
case TextField:
|
|
||||||
textfield = new PartTextField(element_editor, 0, this);
|
|
||||||
textfield -> setPos(event_pos);
|
|
||||||
undo_stack.push(new AddPartCommand(tr("champ de texte"), this, textfield));
|
|
||||||
emit(partsAdded());
|
|
||||||
endCurrentBehavior(e);
|
|
||||||
break;
|
|
||||||
case Normal:
|
case Normal:
|
||||||
default:
|
default:
|
||||||
// detecte les deplacements de parties
|
// detecte les deplacements de parties
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ class ElementScene : public QGraphicsScene {
|
|||||||
|
|
||||||
// enum
|
// enum
|
||||||
public:
|
public:
|
||||||
enum Behavior { Normal, Terminal, TextField, PasteArea };
|
enum Behavior { Normal, Terminal, PasteArea };
|
||||||
enum ItemOption {
|
enum ItemOption {
|
||||||
SortByZValue = 1,
|
SortByZValue = 1,
|
||||||
IncludeTerminals = 2,
|
IncludeTerminals = 2,
|
||||||
@@ -162,7 +162,6 @@ class ElementScene : public QGraphicsScene {
|
|||||||
public slots:
|
public slots:
|
||||||
void slot_move();
|
void slot_move();
|
||||||
void slot_addTerminal();
|
void slot_addTerminal();
|
||||||
void slot_addTextField();
|
|
||||||
void slot_select(const ElementContent &);
|
void slot_select(const ElementContent &);
|
||||||
void slot_selectAll();
|
void slot_selectAll();
|
||||||
void slot_deselectAll();
|
void slot_deselectAll();
|
||||||
|
|||||||
76
sources/editor/esevent/eseventaddtextfield.cpp
Normal file
76
sources/editor/esevent/eseventaddtextfield.cpp
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2006-2014 The QElectroTech Team
|
||||||
|
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/>.
|
||||||
|
*/
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
#include "parttextfield.h"
|
||||||
|
#include "editorcommands.h"
|
||||||
|
#include "elementscene.h"
|
||||||
|
#include "eseventaddtextfield.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief ESEventAddTextField::ESEventAddTextField
|
||||||
|
* @param scene
|
||||||
|
*/
|
||||||
|
ESEventAddTextField::ESEventAddTextField(ElementScene *scene) :
|
||||||
|
ESEventInterface(scene)
|
||||||
|
{
|
||||||
|
m_text = new PartTextField(m_editor, 0, m_scene);
|
||||||
|
m_running = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief ESEventAddTextField::~ESEventAddTextField
|
||||||
|
*/
|
||||||
|
ESEventAddTextField::~ESEventAddTextField() {
|
||||||
|
delete m_text;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief ESEventAddTextField::ESEventAddTextField
|
||||||
|
* @param event
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
bool ESEventAddTextField::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
|
||||||
|
QPointF pos = m_scene -> snapToGrid(event -> scenePos());
|
||||||
|
updateHelpCross(pos);
|
||||||
|
m_text->setPos(pos);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief ESEventAddTextField::ESEventAddTextField
|
||||||
|
* @param event
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
bool ESEventAddTextField::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) {
|
||||||
|
if (event->button() == Qt::LeftButton) {
|
||||||
|
m_scene -> undoStack().push(new AddPartCommand(QObject::tr("Champ texte"), m_scene, m_text));
|
||||||
|
|
||||||
|
//Set new text
|
||||||
|
m_text = new PartTextField(m_editor, 0, m_scene);
|
||||||
|
m_text -> setPos(m_scene -> snapToGrid(event -> scenePos()));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (event->button() == Qt::RightButton) {
|
||||||
|
m_running = false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
44
sources/editor/esevent/eseventaddtextfield.h
Normal file
44
sources/editor/esevent/eseventaddtextfield.h
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2006-2014 The QElectroTech Team
|
||||||
|
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/>.
|
||||||
|
*/
|
||||||
|
#ifndef ESEVENTADDTEXTFIELD_H
|
||||||
|
#define ESEVENTADDTEXTFIELD_H
|
||||||
|
|
||||||
|
#include "eseventinterface.h"
|
||||||
|
|
||||||
|
class ElementScene;
|
||||||
|
class PartTextField;
|
||||||
|
class QGraphicsSceneMouseEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The ESEventAddTextField class
|
||||||
|
* This ESEvent manage creation of text field in an ElementScene
|
||||||
|
*/
|
||||||
|
class ESEventAddTextField : public ESEventInterface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ESEventAddTextField(ElementScene *scene);
|
||||||
|
virtual ~ESEventAddTextField();
|
||||||
|
|
||||||
|
virtual bool mouseMoveEvent (QGraphicsSceneMouseEvent *event);
|
||||||
|
virtual bool mouseReleaseEvent (QGraphicsSceneMouseEvent *event);
|
||||||
|
|
||||||
|
private:
|
||||||
|
PartTextField *m_text;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // ESEVENTADDTEXTFIELD_H
|
||||||
@@ -47,6 +47,7 @@
|
|||||||
#include "eseventaddpolygon.h"
|
#include "eseventaddpolygon.h"
|
||||||
#include "eseventaddarc.h"
|
#include "eseventaddarc.h"
|
||||||
#include "eseventaddtext.h"
|
#include "eseventaddtext.h"
|
||||||
|
#include "eseventaddtextfield.h"
|
||||||
|
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
/*
|
/*
|
||||||
@@ -258,7 +259,7 @@ void QETElementEditor::setupActions() {
|
|||||||
connect(add_text, SIGNAL(triggered()), this, SLOT(addText()));
|
connect(add_text, SIGNAL(triggered()), this, SLOT(addText()));
|
||||||
connect(add_arc, SIGNAL(triggered()), this, SLOT(addArc()));
|
connect(add_arc, SIGNAL(triggered()), this, SLOT(addArc()));
|
||||||
connect(add_terminal, SIGNAL(triggered()), ce_scene, SLOT(slot_addTerminal()));
|
connect(add_terminal, SIGNAL(triggered()), ce_scene, SLOT(slot_addTerminal()));
|
||||||
connect(add_textfield, SIGNAL(triggered()), ce_scene, SLOT(slot_addTextField()));
|
connect(add_textfield, SIGNAL(triggered()), this, SLOT(addTextField()));
|
||||||
|
|
||||||
connect(move, SIGNAL(triggered()), this, SLOT(slot_setRubberBandToView()));
|
connect(move, SIGNAL(triggered()), this, SLOT(slot_setRubberBandToView()));
|
||||||
connect(add_line, SIGNAL(triggered()), this, SLOT(slot_setNoDragToView()));
|
connect(add_line, SIGNAL(triggered()), this, SLOT(slot_setNoDragToView()));
|
||||||
@@ -975,6 +976,14 @@ void QETElementEditor::addText() {
|
|||||||
ce_scene -> setEventInterface(new ESEventAddText(ce_scene));
|
ce_scene -> setEventInterface(new ESEventAddText(ce_scene));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief QETElementEditor::addTextField
|
||||||
|
* Set text field interface to scene
|
||||||
|
*/
|
||||||
|
void QETElementEditor::addTextField() {
|
||||||
|
ce_scene -> setEventInterface(new ESEventAddTextField(ce_scene));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Lance l'assistant de creation d'un nouvel element.
|
Lance l'assistant de creation d'un nouvel element.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -134,6 +134,7 @@ class QETElementEditor : public QETMainWindow {
|
|||||||
void addPolygon();
|
void addPolygon();
|
||||||
void addArc();
|
void addArc();
|
||||||
void addText();
|
void addText();
|
||||||
|
void addTextField();
|
||||||
|
|
||||||
void slot_new();
|
void slot_new();
|
||||||
void slot_open();
|
void slot_open();
|
||||||
|
|||||||
Reference in New Issue
Block a user