Element editor : clear the event interface befor save, to avoid the save of the primitive owned by the interface.

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4996 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
blacksun
2017-07-31 17:41:48 +00:00
parent ecfb49c227
commit fbae3da33f
4 changed files with 260 additions and 236 deletions

View File

@@ -44,16 +44,16 @@
ElementScene::ElementScene(QETElementEditor *editor, QObject *parent) : ElementScene::ElementScene(QETElementEditor *editor, QObject *parent) :
QGraphicsScene(parent), QGraphicsScene(parent),
m_elmt_type("simple"), m_elmt_type("simple"),
qgi_manager(this), m_qgi_manager(this),
element_editor(editor) m_element_editor(editor)
{ {
behavior = Normal; m_behavior = Normal;
setItemIndexMethod(NoIndex); setItemIndexMethod(NoIndex);
setGrid(1, 1); setGrid(1, 1);
initPasteArea(); initPasteArea();
undo_stack.setClean(); m_undo_stack.setClean();
m_decorator_lock = new QMutex(QMutex::NonRecursive); m_decorator_lock = new QMutex(QMutex::NonRecursive);
connect(&undo_stack, SIGNAL(indexChanged(int)), this, SLOT(managePrimitivesGroups())); connect(&m_undo_stack, SIGNAL(indexChanged(int)), this, SLOT(managePrimitivesGroups()));
connect(this, SIGNAL(selectionChanged()), this, SLOT(managePrimitivesGroups())); connect(this, SIGNAL(selectionChanged()), this, SLOT(managePrimitivesGroups()));
} }
@@ -63,7 +63,7 @@ ElementScene::ElementScene(QETElementEditor *editor, QObject *parent) :
ElementScene::~ElementScene() ElementScene::~ElementScene()
{ {
//Disconnect to avoid crash, see bug report N° 122. //Disconnect to avoid crash, see bug report N° 122.
disconnect(&undo_stack, SIGNAL(indexChanged(int)), this, SLOT(managePrimitivesGroups())); disconnect(&m_undo_stack, SIGNAL(indexChanged(int)), this, SLOT(managePrimitivesGroups()));
delete m_decorator_lock; delete m_decorator_lock;
if (m_event_interface) if (m_event_interface)
@@ -92,10 +92,10 @@ void ElementScene::mouseMoveEvent(QGraphicsSceneMouseEvent *e) {
if (!(e -> modifiers() & Qt::ControlModifier)) if (!(e -> modifiers() & Qt::ControlModifier))
event_pos = snapToGrid(event_pos); event_pos = snapToGrid(event_pos);
if (behavior == PasteArea) { if (m_behavior == PasteArea) {
QRectF current_rect(paste_area_ -> rect()); QRectF current_rect(m_paste_area -> rect());
current_rect.moveCenter(event_pos); current_rect.moveCenter(event_pos);
paste_area_ -> setRect(current_rect); m_paste_area -> setRect(current_rect);
return; return;
} }
@@ -135,11 +135,11 @@ void ElementScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) {
} }
} }
if (behavior == PasteArea) { if (m_behavior == PasteArea) {
defined_paste_area_ = paste_area_ -> rect(); m_defined_paste_area = m_paste_area -> rect();
removeItem(paste_area_); removeItem(m_paste_area);
emit(pasteAreaDefined(defined_paste_area_)); emit(pasteAreaDefined(m_defined_paste_area));
behavior = Normal; m_behavior = Normal;
return; return;
} }
@@ -189,8 +189,8 @@ void ElementScene::keyPressEvent(QKeyEvent *event) {
*/ */
void ElementScene::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) void ElementScene::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{ {
if (behavior == ElementScene::Normal) if (m_behavior == ElementScene::Normal)
element_editor -> contextMenu(event->screenPos()); m_element_editor -> contextMenu(event->screenPos());
} }
/** /**
@@ -221,8 +221,10 @@ void ElementScene::drawForeground(QPainter *p, const QRectF &rect) {
* Set a new event interface * Set a new event interface
* @param interface * @param interface
*/ */
void ElementScene::setEventInterface(ESEventInterface *event_interface) { void ElementScene::setEventInterface(ESEventInterface *event_interface)
if (m_event_interface) { {
if (m_event_interface)
{
delete m_event_interface; delete m_event_interface;
//We must to re-init because previous interface //We must to re-init because previous interface
//Reset his own init when deleted //Reset his own init when deleted
@@ -231,6 +233,19 @@ void ElementScene::setEventInterface(ESEventInterface *event_interface) {
m_event_interface = event_interface; m_event_interface = event_interface;
} }
/**
* @brief ElementScene::clearEventInterface
* Clear the current event interface
*/
void ElementScene::clearEventInterface()
{
if(m_event_interface)
{
delete m_event_interface;
m_event_interface = nullptr;
}
}
/** /**
* @brief ElementScene::setBehavior * @brief ElementScene::setBehavior
* Modifie the current behavior of this scene * Modifie the current behavior of this scene
@@ -238,21 +253,21 @@ void ElementScene::setEventInterface(ESEventInterface *event_interface) {
*/ */
void ElementScene::setBehavior(ElementScene::Behavior b) void ElementScene::setBehavior(ElementScene::Behavior b)
{ {
behavior = b; m_behavior = b;
} }
/** /**
@return la taille horizontale de la grille @return la taille horizontale de la grille
*/ */
int ElementScene::xGrid() const { int ElementScene::xGrid() const {
return(x_grid); return(m_x_grid);
} }
/** /**
@return la taille verticale de la grille @return la taille verticale de la grille
*/ */
int ElementScene::yGrid() const { int ElementScene::yGrid() const {
return(y_grid); return(m_y_grid);
} }
/** /**
@@ -260,8 +275,8 @@ int ElementScene::yGrid() const {
@param y_g Taille verticale de la grille @param y_g Taille verticale de la grille
*/ */
void ElementScene::setGrid(int x_g, int y_g) { void ElementScene::setGrid(int x_g, int y_g) {
x_grid = x_g ? x_g : 1; m_x_grid = x_g ? x_g : 1;
y_grid = y_g ? y_g : 1; m_y_grid = y_g ? y_g : 1;
} }
/** /**
@@ -315,7 +330,7 @@ const QDomDocument ElementScene::toXml(bool all_parts)
root.appendChild(uuid); root.appendChild(uuid);
//names of element //names of element
root.appendChild(_names.toXml(xml_document)); root.appendChild(m_names_list.toXml(xml_document));
if (m_elmt_type == "slave" || m_elmt_type == "master") if (m_elmt_type == "slave" || m_elmt_type == "master")
{ {
@@ -444,14 +459,14 @@ bool ElementScene::containsTerminals() const {
@return la pile d'annulations de cet editeur d'element @return la pile d'annulations de cet editeur d'element
*/ */
QUndoStack &ElementScene::undoStack() { QUndoStack &ElementScene::undoStack() {
return(undo_stack); return(m_undo_stack);
} }
/** /**
@return le gestionnaire de QGraphicsItem de cet editeur d'element @return le gestionnaire de QGraphicsItem de cet editeur d'element
*/ */
QGIManager &ElementScene::qgiManager() { QGIManager &ElementScene::qgiManager() {
return(qgi_manager); return(m_qgi_manager);
} }
/** /**
@@ -469,7 +484,7 @@ bool ElementScene::clipboardMayContainElement() {
@return true si clipboard_content a ete copie depuis cet element. @return true si clipboard_content a ete copie depuis cet element.
*/ */
bool ElementScene::wasCopiedFromThisElement(const QString &clipboard_content) { bool ElementScene::wasCopiedFromThisElement(const QString &clipboard_content) {
return(clipboard_content == last_copied_); return(clipboard_content == m_last_copied);
} }
/** /**
@@ -501,11 +516,11 @@ void ElementScene::copy() {
clipboard -> setText(clipboard_content); clipboard -> setText(clipboard_content);
// retient le dernier contenu copie // retient le dernier contenu copie
last_copied_ = clipboard_content; m_last_copied = clipboard_content;
} }
QETElementEditor* ElementScene::editor() const { QETElementEditor* ElementScene::editor() const {
return element_editor; return m_element_editor;
} }
/** /**
@@ -553,7 +568,7 @@ void ElementScene::slot_delete() {
if (selected_items.isEmpty()) return; if (selected_items.isEmpty()) return;
// efface tout ce qui est selectionne // efface tout ce qui est selectionne
undo_stack.push(new DeletePartsCommand(this, selected_items)); m_undo_stack.push(new DeletePartsCommand(this, selected_items));
// removing items does not trigger QGraphicsScene::selectionChanged() // removing items does not trigger QGraphicsScene::selectionChanged()
emit(partsRemoved()); emit(partsRemoved());
@@ -566,10 +581,10 @@ void ElementScene::slot_delete() {
sur l'auteur de l'element, sa licence, etc. sur l'auteur de l'element, sa licence, etc.
*/ */
void ElementScene::slot_editAuthorInformations() { void ElementScene::slot_editAuthorInformations() {
bool is_read_only = element_editor && element_editor -> isReadOnly(); bool is_read_only = m_element_editor && m_element_editor -> isReadOnly();
// cree un dialogue // cree un dialogue
QDialog dialog_author(element_editor); QDialog dialog_author(m_element_editor);
dialog_author.setModal(true); dialog_author.setModal(true);
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
dialog_author.setWindowFlags(Qt::Sheet); dialog_author.setWindowFlags(Qt::Sheet);
@@ -623,10 +638,10 @@ void ElementScene::slot_editProperties() {
Lance un dialogue pour editer les noms de cet element Lance un dialogue pour editer les noms de cet element
*/ */
void ElementScene::slot_editNames() { void ElementScene::slot_editNames() {
bool is_read_only = element_editor && element_editor -> isReadOnly(); bool is_read_only = m_element_editor && m_element_editor -> isReadOnly();
// cree un dialogue // cree un dialogue
QDialog dialog(element_editor); QDialog dialog(m_element_editor);
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
dialog.setWindowFlags(Qt::Sheet); dialog.setWindowFlags(Qt::Sheet);
#endif #endif
@@ -643,7 +658,7 @@ void ElementScene::slot_editNames() {
// ajoute un NamesListWidget au dialogue // ajoute un NamesListWidget au dialogue
NamesListWidget *names_widget = new NamesListWidget(); NamesListWidget *names_widget = new NamesListWidget();
names_widget -> setNames(_names); names_widget -> setNames(m_names_list);
names_widget -> setReadOnly(is_read_only); names_widget -> setReadOnly(is_read_only);
dialog_layout -> addWidget(names_widget); dialog_layout -> addWidget(names_widget);
@@ -657,7 +672,7 @@ void ElementScene::slot_editNames() {
// lance le dialogue // lance le dialogue
if (dialog.exec() == QDialog::Accepted && !is_read_only) { if (dialog.exec() == QDialog::Accepted && !is_read_only) {
NamesList new_names(names_widget -> names()); NamesList new_names(names_widget -> names());
if (new_names != _names) undoStack().push(new ChangeNamesCommand(this, _names, new_names)); if (new_names != m_names_list) undoStack().push(new ChangeNamesCommand(this, m_names_list, new_names));
} }
} }
@@ -780,11 +795,11 @@ ElementContent ElementScene::selectedContent() const {
*/ */
void ElementScene::getPasteArea(const QRectF &to_paste) { void ElementScene::getPasteArea(const QRectF &to_paste) {
// on le dessine sur la scene // on le dessine sur la scene
paste_area_ -> setRect(to_paste); m_paste_area -> setRect(to_paste);
addItem(paste_area_); addItem(m_paste_area);
// on passe la scene en mode "recherche de zone pour copier/coller" // on passe la scene en mode "recherche de zone pour copier/coller"
behavior = PasteArea; m_behavior = PasteArea;
} }
/** /**
@@ -846,7 +861,7 @@ bool ElementScene::applyInformations(const QDomDocument &xml_document, QString *
m_elmt_kindInfo.fromXml(root.firstChildElement("kindInformations"), "kindInformation"); m_elmt_kindInfo.fromXml(root.firstChildElement("kindInformations"), "kindInformation");
//Extract names of xml definition //Extract names of xml definition
_names.fromXml(root); m_names_list.fromXml(root);
//extract additional informations //extract additional informations
setInformations(QString()); setInformations(QString());
@@ -893,15 +908,15 @@ ElementContent ElementScene::loadContent(const QDomDocument &xml_document, QStri
QDomElement qde = n.toElement(); QDomElement qde = n.toElement();
if (qde.isNull()) continue; if (qde.isNull()) continue;
CustomElementPart *cep; CustomElementPart *cep;
if (qde.tagName() == "line") cep = new PartLine (element_editor); if (qde.tagName() == "line") cep = new PartLine (m_element_editor);
else if (qde.tagName() == "rect") cep = new PartRectangle(element_editor); else if (qde.tagName() == "rect") cep = new PartRectangle(m_element_editor);
else if (qde.tagName() == "ellipse") cep = new PartEllipse (element_editor); else if (qde.tagName() == "ellipse") cep = new PartEllipse (m_element_editor);
else if (qde.tagName() == "circle") cep = new PartEllipse (element_editor); else if (qde.tagName() == "circle") cep = new PartEllipse (m_element_editor);
else if (qde.tagName() == "polygon") cep = new PartPolygon (element_editor); else if (qde.tagName() == "polygon") cep = new PartPolygon (m_element_editor);
else if (qde.tagName() == "terminal") cep = new PartTerminal (element_editor); else if (qde.tagName() == "terminal") cep = new PartTerminal (m_element_editor);
else if (qde.tagName() == "text") cep = new PartText (element_editor); else if (qde.tagName() == "text") cep = new PartText (m_element_editor);
else if (qde.tagName() == "input") cep = new PartTextField(element_editor); else if (qde.tagName() == "input") cep = new PartTextField(m_element_editor);
else if (qde.tagName() == "arc") cep = new PartArc (element_editor); else if (qde.tagName() == "arc") cep = new PartArc (m_element_editor);
else continue; else continue;
if (QGraphicsItem *qgi = dynamic_cast<QGraphicsItem *>(cep)) { if (QGraphicsItem *qgi = dynamic_cast<QGraphicsItem *>(cep)) {
if (!qgi -> zValue()) qgi -> setZValue(z++); if (!qgi -> zValue()) qgi -> setZValue(z++);
@@ -967,8 +982,8 @@ void ElementScene::addPrimitive(QGraphicsItem *primitive) {
Initialise la zone de collage Initialise la zone de collage
*/ */
void ElementScene::initPasteArea() { void ElementScene::initPasteArea() {
paste_area_ = new QGraphicsRectItem(); m_paste_area = new QGraphicsRectItem();
paste_area_ -> setZValue(1000000); m_paste_area -> setZValue(1000000);
QPen paste_area_pen; QPen paste_area_pen;
paste_area_pen.setStyle(Qt::DashDotLine); paste_area_pen.setStyle(Qt::DashDotLine);
@@ -978,8 +993,8 @@ void ElementScene::initPasteArea() {
paste_area_brush.setStyle(Qt::SolidPattern); paste_area_brush.setStyle(Qt::SolidPattern);
paste_area_brush.setColor(QColor(90, 167, 255, 64)); paste_area_brush.setColor(QColor(90, 167, 255, 64));
paste_area_ -> setPen(paste_area_pen); m_paste_area -> setPen(paste_area_pen);
paste_area_ -> setBrush(paste_area_brush); m_paste_area -> setBrush(paste_area_brush);
} }
/** /**
@@ -989,8 +1004,8 @@ void ElementScene::initPasteArea() {
*/ */
QPointF ElementScene::snapToGrid(QPointF point) { QPointF ElementScene::snapToGrid(QPointF point) {
point.rx() = qRound(point.x() / x_grid) * x_grid; point.rx() = qRound(point.x() / m_x_grid) * m_x_grid;
point.ry() = qRound(point.y() / y_grid) * y_grid; point.ry() = qRound(point.y() / m_y_grid) * m_y_grid;
return point; return point;
} }

View File

@@ -35,7 +35,8 @@ class QKeyEvent;
It displays the various primitives composing the drawing of the element, the It displays the various primitives composing the drawing of the element, the
border due to its fixed size and its hotspot. border due to its fixed size and its hotspot.
*/ */
class ElementScene : public QGraphicsScene { class ElementScene : public QGraphicsScene
{
friend class ChangePropertiesCommand; friend class ChangePropertiesCommand;
Q_OBJECT Q_OBJECT
@@ -63,48 +64,42 @@ class ElementScene : public QGraphicsScene {
// attributes // attributes
private: private:
/// List of localized names /// List of localized names
NamesList _names; NamesList m_names_list;
/// Extra informations /// Extra informations
QString informations_; QString m_informations;
/// element type /// element type
QString m_elmt_type; QString m_elmt_type;
/// element kind info /// element kind info
DiagramContext m_elmt_kindInfo; DiagramContext m_elmt_kindInfo;
/// QGraphicsItem manager /// QGraphicsItem manager
QGIManager qgi_manager; QGIManager m_qgi_manager;
/// Undo stack /// Undo stack
QUndoStack undo_stack; QUndoStack m_undo_stack;
/**
fsi_pos (first selected item pos) : Position of the forst selected item: used
to cancel mouse movements; also used to handle movements using keybard
arrwows.
*/
QPointF fsi_pos;
QPointF moving_press_pos;
/// Variables related to drawing /// Variables related to drawing
ESEventInterface *m_event_interface = nullptr; ESEventInterface *m_event_interface = nullptr;
Behavior behavior; Behavior m_behavior;
QETElementEditor *element_editor = nullptr; QETElementEditor *m_element_editor = nullptr;
/// Variables to manage the paste area on the scene /// Variables to manage the paste area on the scene
QGraphicsRectItem *paste_area_; QGraphicsRectItem *m_paste_area = nullptr;
QRectF defined_paste_area_; QRectF m_defined_paste_area;
/// Variables to handle copy/paste with offset /// Variables to handle copy/paste with offset
QString last_copied_; QString m_last_copied;
/// Decorator item displayed when at least one item is selected /// Decorator item displayed when at least one item is selected
ElementPrimitiveDecorator *m_decorator = nullptr; ElementPrimitiveDecorator *m_decorator = nullptr;
///< Size of the horizontal grid step ///< Size of the horizontal grid step
int x_grid; int m_x_grid;
///< Size of the vertical grid step ///< Size of the vertical grid step
int y_grid; int m_y_grid;
// methods // methods
public: public:
void setEventInterface (ESEventInterface *event_interface); void setEventInterface (ESEventInterface *event_interface);
void clearEventInterface();
void setBehavior (ElementScene::Behavior); void setBehavior (ElementScene::Behavior);
QPointF snapToGrid(QPointF point); QPointF snapToGrid(QPointF point);
void setNames(const NamesList &); void setNames(const NamesList &);
@@ -192,28 +187,28 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(ElementScene::ItemOptions)
@param nameslist New set of naes for the currently edited element @param nameslist New set of naes for the currently edited element
*/ */
inline void ElementScene::setNames(const NamesList &nameslist) { inline void ElementScene::setNames(const NamesList &nameslist) {
_names = nameslist; m_names_list = nameslist;
} }
/** /**
@return the list of names of the currently edited element @return the list of names of the currently edited element
*/ */
inline NamesList ElementScene::names() const { inline NamesList ElementScene::names() const {
return(_names); return(m_names_list);
} }
/** /**
@return extra informations of the currently edited element @return extra informations of the currently edited element
*/ */
inline QString ElementScene::informations() const { inline QString ElementScene::informations() const {
return(informations_); return(m_informations);
} }
/** /**
@param infos new extra information for the currently edited element @param infos new extra information for the currently edited element
*/ */
inline void ElementScene::setInformations(const QString &infos) { inline void ElementScene::setInformations(const QString &infos) {
informations_ = infos; m_informations = infos;
} }
#endif #endif

View File

@@ -160,8 +160,8 @@ void QETElementEditor::setupActions() {
edit_author = new QAction(QET::Icons::UserInformations, tr("Éditer les informations sur l'auteur"), this); edit_author = new QAction(QET::Icons::UserInformations, tr("Éditer les informations sur l'auteur"), this);
m_edit_properties = new QAction(QET::Icons::ElementEdit, tr("Éditer les propriétés de l'élément"), this); m_edit_properties = new QAction(QET::Icons::ElementEdit, tr("Éditer les propriétés de l'élément"), this);
undo = ce_scene -> undoStack().createUndoAction(this, tr("Annuler")); undo = m_elmt_scene -> undoStack().createUndoAction(this, tr("Annuler"));
redo = ce_scene -> undoStack().createRedoAction(this, tr("Refaire")); redo = m_elmt_scene -> undoStack().createRedoAction(this, tr("Refaire"));
undo -> setIcon(QET::Icons::EditUndo); undo -> setIcon(QET::Icons::EditUndo);
redo -> setIcon(QET::Icons::EditRedo); redo -> setIcon(QET::Icons::EditRedo);
undo -> setShortcuts(QKeySequence::Undo); undo -> setShortcuts(QKeySequence::Undo);
@@ -199,19 +199,19 @@ void QETElementEditor::setupActions() {
connect(save_as_file, SIGNAL(triggered()), this, SLOT(slot_saveAsFile())); connect(save_as_file, SIGNAL(triggered()), this, SLOT(slot_saveAsFile()));
connect(reload, SIGNAL(triggered()), this, SLOT(slot_reload())); connect(reload, SIGNAL(triggered()), this, SLOT(slot_reload()));
connect(quit, SIGNAL(triggered()), this, SLOT(close())); connect(quit, SIGNAL(triggered()), this, SLOT(close()));
connect(selectall, SIGNAL(triggered()), ce_scene, SLOT(slot_selectAll())); connect(selectall, SIGNAL(triggered()), m_elmt_scene, SLOT(slot_selectAll()));
connect(deselectall, SIGNAL(triggered()), ce_scene, SLOT(slot_deselectAll())); connect(deselectall, SIGNAL(triggered()), m_elmt_scene, SLOT(slot_deselectAll()));
connect(inv_select, SIGNAL(triggered()), ce_scene, SLOT(slot_invertSelection())); connect(inv_select, SIGNAL(triggered()), m_elmt_scene, SLOT(slot_invertSelection()));
connect(cut, SIGNAL(triggered()), ce_view, SLOT(cut())); connect(cut, SIGNAL(triggered()), ce_view, SLOT(cut()));
connect(copy, SIGNAL(triggered()), ce_view, SLOT(copy())); connect(copy, SIGNAL(triggered()), ce_view, SLOT(copy()));
connect(paste, SIGNAL(triggered()), ce_view, SLOT(paste())); connect(paste, SIGNAL(triggered()), ce_view, SLOT(paste()));
connect(paste_in_area, SIGNAL(triggered()), ce_view, SLOT(pasteInArea())); connect(paste_in_area, SIGNAL(triggered()), ce_view, SLOT(pasteInArea()));
connect(paste_from_file, SIGNAL(triggered()), this, SLOT(pasteFromFile())); connect(paste_from_file, SIGNAL(triggered()), this, SLOT(pasteFromFile()));
connect(paste_from_elmt, SIGNAL(triggered()), this, SLOT(pasteFromElement())); connect(paste_from_elmt, SIGNAL(triggered()), this, SLOT(pasteFromElement()));
connect(edit_delete, SIGNAL(triggered()), ce_scene, SLOT(slot_delete())); connect(edit_delete, SIGNAL(triggered()), m_elmt_scene, SLOT(slot_delete()));
connect(edit_names, SIGNAL(triggered()), ce_scene, SLOT(slot_editNames())); connect(edit_names, SIGNAL(triggered()), m_elmt_scene, SLOT(slot_editNames()));
connect(edit_author, SIGNAL(triggered()), ce_scene, SLOT(slot_editAuthorInformations())); connect(edit_author, SIGNAL(triggered()), m_elmt_scene, SLOT(slot_editAuthorInformations()));
connect(m_edit_properties, SIGNAL(triggered()), ce_scene, SLOT(slot_editProperties())); connect(m_edit_properties, SIGNAL(triggered()), m_elmt_scene, SLOT(slot_editProperties()));
/* /*
@@ -229,10 +229,10 @@ void QETElementEditor::setupActions() {
edit_backward -> setShortcut(QKeySequence(tr("Ctrl+Shift+End"))); edit_backward -> setShortcut(QKeySequence(tr("Ctrl+Shift+End")));
edit_forward -> setShortcut(QKeySequence(tr("Ctrl+Shift+Home"))); edit_forward -> setShortcut(QKeySequence(tr("Ctrl+Shift+Home")));
connect(edit_forward, SIGNAL(triggered()), ce_scene, SLOT(slot_bringForward() )); connect(edit_forward, SIGNAL(triggered()), m_elmt_scene, SLOT(slot_bringForward() ));
connect(edit_raise, SIGNAL(triggered()), ce_scene, SLOT(slot_raise() )); connect(edit_raise, SIGNAL(triggered()), m_elmt_scene, SLOT(slot_raise() ));
connect(edit_lower, SIGNAL(triggered()), ce_scene, SLOT(slot_lower() )); connect(edit_lower, SIGNAL(triggered()), m_elmt_scene, SLOT(slot_lower() ));
connect(edit_backward, SIGNAL(triggered()), ce_scene, SLOT(slot_sendBackward() )); connect(edit_backward, SIGNAL(triggered()), m_elmt_scene, SLOT(slot_sendBackward() ));
depth_toolbar = addToolBar(tr("Profondeur", "toolbar title")); depth_toolbar = addToolBar(tr("Profondeur", "toolbar title"));
depth_toolbar -> setObjectName("depth_toolbar"); depth_toolbar -> setObjectName("depth_toolbar");
@@ -264,7 +264,7 @@ void QETElementEditor::setupActions() {
/* /*
* Action related to primitive creation * Action related to primitive creation
*/ */
connect (ce_scene, SIGNAL(partsAdded()), this, SLOT(UncheckAddPrimitive())); connect (m_elmt_scene, SIGNAL(partsAdded()), this, SLOT(UncheckAddPrimitive()));
parts = new QActionGroup(this); parts = new QActionGroup(this);
QAction *add_line = new QAction(QET::Icons::PartLine, tr("Ajouter une ligne"), parts); QAction *add_line = new QAction(QET::Icons::PartLine, tr("Ajouter une ligne"), parts);
@@ -323,19 +323,19 @@ void QETElementEditor::setupActions() {
addToolBar(Qt::TopToolBarArea, view_toolbar); addToolBar(Qt::TopToolBarArea, view_toolbar);
addToolBar(Qt::TopToolBarArea, element_toolbar); addToolBar(Qt::TopToolBarArea, element_toolbar);
connect(ce_scene, SIGNAL(selectionChanged()), this, SLOT(slot_updateInformations()), Qt::QueuedConnection); connect(m_elmt_scene, SIGNAL(selectionChanged()), this, SLOT(slot_updateInformations()), Qt::QueuedConnection);
connect(ce_scene, SIGNAL(selectionChanged()), this, SLOT(slot_updateMenus())); connect(m_elmt_scene, SIGNAL(selectionChanged()), this, SLOT(slot_updateMenus()));
connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(slot_updateMenus())); connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(slot_updateMenus()));
connect(&(ce_scene -> undoStack()), SIGNAL(cleanChanged(bool)), this, SLOT(slot_updateMenus())); connect(&(m_elmt_scene -> undoStack()), SIGNAL(cleanChanged(bool)), this, SLOT(slot_updateMenus()));
connect(&(ce_scene -> undoStack()), SIGNAL(cleanChanged(bool)), this, SLOT(slot_updateTitle())); connect(&(m_elmt_scene -> undoStack()), SIGNAL(cleanChanged(bool)), this, SLOT(slot_updateTitle()));
// Annuler ou refaire une action met a jour la liste des primitives ; cela sert notamment pour les // Annuler ou refaire une action met a jour la liste des primitives ; cela sert notamment pour les
// ajouts et suppressions de primitives ainsi que pour les actions entrainant un change // ajouts et suppressions de primitives ainsi que pour les actions entrainant un change
connect(&(ce_scene -> undoStack()), SIGNAL(indexChanged(int)), this, SLOT(slot_updatePartsList())); connect(&(m_elmt_scene -> undoStack()), SIGNAL(indexChanged(int)), this, SLOT(slot_updatePartsList()));
// Annuler ou refaire une action met a jour les informations affichees sur les primitives selectionnees, // Annuler ou refaire une action met a jour les informations affichees sur les primitives selectionnees,
// celles-ci etant potentiellement impactees // celles-ci etant potentiellement impactees
connect(&(ce_scene -> undoStack()), SIGNAL(indexChanged(int)), this, SLOT(slot_updateInformations())); connect(&(m_elmt_scene -> undoStack()), SIGNAL(indexChanged(int)), this, SLOT(slot_updateInformations()));
} }
/** /**
@@ -429,7 +429,7 @@ void QETElementEditor::contextMenu(QPoint p) {
Met a jour les menus Met a jour les menus
*/ */
void QETElementEditor::slot_updateMenus() { void QETElementEditor::slot_updateMenus() {
bool selected_items = !read_only && !ce_scene -> selectedItems().isEmpty(); bool selected_items = !read_only && !m_elmt_scene -> selectedItems().isEmpty();
bool clipboard_elmt = !read_only && ElementScene::clipboardMayContainElement(); bool clipboard_elmt = !read_only && ElementScene::clipboardMayContainElement();
// actions dependant seulement de l'etat "lecture seule" de l'editeur // actions dependant seulement de l'etat "lecture seule" de l'editeur
@@ -455,9 +455,9 @@ void QETElementEditor::slot_updateMenus() {
paste_in_area -> setEnabled(clipboard_elmt); paste_in_area -> setEnabled(clipboard_elmt);
// actions dependant de l'etat de la pile d'annulation // actions dependant de l'etat de la pile d'annulation
save -> setEnabled(!read_only && !ce_scene -> undoStack().isClean()); save -> setEnabled(!read_only && !m_elmt_scene -> undoStack().isClean());
undo -> setEnabled(!read_only && ce_scene -> undoStack().canUndo()); undo -> setEnabled(!read_only && m_elmt_scene -> undoStack().canUndo());
redo -> setEnabled(!read_only && ce_scene -> undoStack().canRedo()); redo -> setEnabled(!read_only && m_elmt_scene -> undoStack().canRedo());
} }
/** /**
@@ -465,9 +465,9 @@ void QETElementEditor::slot_updateMenus() {
*/ */
void QETElementEditor::slot_updateTitle() { void QETElementEditor::slot_updateTitle() {
QString title = min_title; QString title = min_title;
title += " - " + ce_scene -> names().name() + " "; title += " - " + m_elmt_scene -> names().name() + " ";
if (!filename_.isEmpty() || !location_.isNull()) { if (!filename_.isEmpty() || !location_.isNull()) {
if (!ce_scene -> undoStack().isClean()) title += tr("[Modifié]", "window title tag"); if (!m_elmt_scene -> undoStack().isClean()) title += tr("[Modifié]", "window title tag");
} }
if (isReadOnly()) title += tr(" [lecture seule]", "window title tag"); if (isReadOnly()) title += tr(" [lecture seule]", "window title tag");
setWindowTitle(title); setWindowTitle(title);
@@ -478,8 +478,8 @@ void QETElementEditor::slot_updateTitle() {
*/ */
void QETElementEditor::setupInterface() { void QETElementEditor::setupInterface() {
// editeur // editeur
ce_scene = new ElementScene(this, this); m_elmt_scene = new ElementScene(this, this);
ce_view = new ElementView(ce_scene, this); ce_view = new ElementView(m_elmt_scene, this);
slot_setRubberBandToView(); slot_setRubberBandToView();
setCentralWidget(ce_view); setCentralWidget(ce_view);
@@ -523,17 +523,17 @@ void QETElementEditor::setupInterface() {
undo_dock -> setFeatures(QDockWidget::AllDockWidgetFeatures); undo_dock -> setFeatures(QDockWidget::AllDockWidgetFeatures);
undo_dock -> setMinimumWidth(290); undo_dock -> setMinimumWidth(290);
addDockWidget(Qt::RightDockWidgetArea, undo_dock); addDockWidget(Qt::RightDockWidgetArea, undo_dock);
QUndoView* undo_view = new QUndoView(&(ce_scene -> undoStack()), this); QUndoView* undo_view = new QUndoView(&(m_elmt_scene -> undoStack()), this);
undo_view -> setEmptyLabel(tr("Aucune modification")); undo_view -> setEmptyLabel(tr("Aucune modification"));
undo_dock -> setWidget(undo_view); undo_dock -> setWidget(undo_view);
// panel sur le cote pour la liste des parties // panel sur le cote pour la liste des parties
parts_list = new QListWidget(this); parts_list = new QListWidget(this);
parts_list -> setSelectionMode(QAbstractItemView::ExtendedSelection); parts_list -> setSelectionMode(QAbstractItemView::ExtendedSelection);
connect(ce_scene, SIGNAL(partsAdded()), this, SLOT(slot_createPartsList())); connect(m_elmt_scene, SIGNAL(partsAdded()), this, SLOT(slot_createPartsList()));
connect(ce_scene, SIGNAL(partsRemoved()), this, SLOT(slot_createPartsList())); connect(m_elmt_scene, SIGNAL(partsRemoved()), this, SLOT(slot_createPartsList()));
connect(ce_scene, SIGNAL(partsZValueChanged()), this, SLOT(slot_createPartsList())); connect(m_elmt_scene, SIGNAL(partsZValueChanged()), this, SLOT(slot_createPartsList()));
connect(ce_scene, SIGNAL(selectionChanged()), this, SLOT(slot_updatePartsList())); connect(m_elmt_scene, SIGNAL(selectionChanged()), this, SLOT(slot_updatePartsList()));
connect(parts_list, SIGNAL(itemSelectionChanged()), this, SLOT(slot_updateSelectionFromPartsList())); connect(parts_list, SIGNAL(itemSelectionChanged()), this, SLOT(slot_updateSelectionFromPartsList()));
parts_dock = new QDockWidget(tr("Parties", "dock title"), this); parts_dock = new QDockWidget(tr("Parties", "dock title"), this);
parts_dock -> setObjectName("parts_list"); parts_dock -> setObjectName("parts_list");
@@ -571,7 +571,7 @@ void QETElementEditor::slot_setNoDragToView() {
affichee. Sinon, un widget d'edition approprie est mis en place. affichee. Sinon, un widget d'edition approprie est mis en place.
*/ */
void QETElementEditor::slot_updateInformations() { void QETElementEditor::slot_updateInformations() {
QList<QGraphicsItem *> selected_qgis = ce_scene -> selectedItems(); QList<QGraphicsItem *> selected_qgis = m_elmt_scene -> selectedItems();
QList<CustomElementPart *> cep_list; QList<CustomElementPart *> cep_list;
bool style_editable = false; bool style_editable = false;
@@ -652,7 +652,7 @@ void QETElementEditor::xmlPreview() {
QET::QetMessageBox::information( QET::QetMessageBox::information(
this, this,
"Export XML", "Export XML",
ce_scene -> toXml().toString(4) m_elmt_scene -> toXml().toString(4)
); );
} }
@@ -670,7 +670,7 @@ bool QETElementEditor::checkElement()
/// Warning #1: Element haven't got terminal /// Warning #1: Element haven't got terminal
/// (except for report, because report must have one terminal and this checking is do below) /// (except for report, because report must have one terminal and this checking is do below)
if (!ce_scene -> containsTerminals() && !ce_scene -> elementType().contains("report")) if (!m_elmt_scene -> containsTerminals() && !m_elmt_scene -> elementType().contains("report"))
{ {
warnings << qMakePair( warnings << qMakePair(
tr("Absence de borne", "warning title"), tr("Absence de borne", "warning title"),
@@ -683,13 +683,13 @@ bool QETElementEditor::checkElement()
} }
/// Check master, slave, simple and report element /// Check master, slave, simple and report element
if(ce_scene -> elementType() == "master" || if(m_elmt_scene -> elementType() == "master" ||
ce_scene -> elementType() == "slave" || m_elmt_scene -> elementType() == "slave" ||
ce_scene -> elementType() == "simple") m_elmt_scene -> elementType() == "simple")
{ {
bool wrng = true; bool wrng = true;
foreach (CustomElementPart *cep, ce_scene->primitives()) foreach (CustomElementPart *cep, m_elmt_scene->primitives())
if (cep->property("tagg").toString() == "label") wrng = false; if (cep->property("tagg").toString() == "label") wrng = false;
///Error #1: element is master, slave or simple but havent got input tagged 'label' ///Error #1: element is master, slave or simple but havent got input tagged 'label'
@@ -704,11 +704,11 @@ bool QETElementEditor::checkElement()
} }
/// Check folio report element /// Check folio report element
if (ce_scene -> elementType().contains("report")) if (m_elmt_scene -> elementType().contains("report"))
{ {
int text =0, terminal =0; int text =0, terminal =0;
foreach(QGraphicsItem *qgi, ce_scene->items()) foreach(QGraphicsItem *qgi, m_elmt_scene->items())
{ {
if (qgraphicsitem_cast<PartTerminal *>(qgi)) terminal ++; if (qgraphicsitem_cast<PartTerminal *>(qgi)) terminal ++;
else if (qgraphicsitem_cast<PartTextField *>(qgi)) text ++; else if (qgraphicsitem_cast<PartTextField *>(qgi)) text ++;
@@ -803,7 +803,7 @@ void QETElementEditor::fromFile(const QString &filepath) {
} }
// chargement de l'element // chargement de l'element
ce_scene -> fromXml(document_xml); m_elmt_scene -> fromXml(document_xml);
slot_createPartsList(); slot_createPartsList();
// gestion de la lecture seule // gestion de la lecture seule
@@ -825,12 +825,16 @@ void QETElementEditor::fromFile(const QString &filepath) {
} }
/** /**
Enregistre l'element vers un fichier * @brief QETElementEditor::toFile
@param fn Chemin du fichier a enregistrer * Save to file the drawed element.
@return true en cas de reussite, false sinon * @param fn : path of the file
*/ * @return : true if succesfully save.
bool QETElementEditor::toFile(const QString &fn) { */
QDomDocument element_xml = ce_scene -> toXml(); bool QETElementEditor::toFile(const QString &fn)
{
m_elmt_scene->clearEventInterface();
m_elmt_scene->clearSelection();
QDomDocument element_xml = m_elmt_scene->toXml();
bool writing = QET::writeXmlFile(element_xml, fn); bool writing = QET::writeXmlFile(element_xml, fn);
if (!writing) { if (!writing) {
QET::QetMessageBox::warning( QET::QetMessageBox::warning(
@@ -851,7 +855,10 @@ bool QETElementEditor::toFile(const QString &fn) {
*/ */
bool QETElementEditor::toLocation(const ElementsLocation &location) bool QETElementEditor::toLocation(const ElementsLocation &location)
{ {
if (!location.setXml(ce_scene->toXml())) m_elmt_scene->clearEventInterface();
m_elmt_scene->clearSelection();
if (!location.setXml(m_elmt_scene->toXml()))
{ {
QET::QetMessageBox::critical(this, QET::QetMessageBox::critical(this,
tr("Erreur", "message box title"), tr("Erreur", "message box title"),
@@ -926,7 +933,7 @@ bool QETElementEditor::isReadOnly() const {
* Set line creation interface to scene * Set line creation interface to scene
*/ */
void QETElementEditor::addLine() { void QETElementEditor::addLine() {
ce_scene -> setEventInterface(new ESEventAddLine(ce_scene)); m_elmt_scene -> setEventInterface(new ESEventAddLine(m_elmt_scene));
} }
/** /**
@@ -934,7 +941,7 @@ void QETElementEditor::addLine() {
* Set rectangle creation interface to scene * Set rectangle creation interface to scene
*/ */
void QETElementEditor::addRect() { void QETElementEditor::addRect() {
ce_scene -> setEventInterface(new ESEventAddRect(ce_scene)); m_elmt_scene -> setEventInterface(new ESEventAddRect(m_elmt_scene));
} }
/** /**
@@ -942,7 +949,7 @@ void QETElementEditor::addRect() {
* Set ellipse creation interface to scene * Set ellipse creation interface to scene
*/ */
void QETElementEditor::addEllipse() { void QETElementEditor::addEllipse() {
ce_scene -> setEventInterface(new ESEventAddEllipse(ce_scene)); m_elmt_scene -> setEventInterface(new ESEventAddEllipse(m_elmt_scene));
} }
/** /**
@@ -950,7 +957,7 @@ void QETElementEditor::addEllipse() {
* Set polygon creation interface to scene * Set polygon creation interface to scene
*/ */
void QETElementEditor::addPolygon() { void QETElementEditor::addPolygon() {
ce_scene -> setEventInterface(new ESEventAddPolygon(ce_scene)); m_elmt_scene -> setEventInterface(new ESEventAddPolygon(m_elmt_scene));
} }
/** /**
@@ -958,7 +965,7 @@ void QETElementEditor::addPolygon() {
* Set arc creation interface to scene * Set arc creation interface to scene
*/ */
void QETElementEditor::addArc() { void QETElementEditor::addArc() {
ce_scene -> setEventInterface(new ESEventAddArc(ce_scene)); m_elmt_scene -> setEventInterface(new ESEventAddArc(m_elmt_scene));
} }
/** /**
@@ -966,7 +973,7 @@ void QETElementEditor::addArc() {
* Set text creation interface to scene * Set text creation interface to scene
*/ */
void QETElementEditor::addText() { void QETElementEditor::addText() {
ce_scene -> setEventInterface(new ESEventAddText(ce_scene)); m_elmt_scene -> setEventInterface(new ESEventAddText(m_elmt_scene));
} }
/** /**
@@ -974,7 +981,7 @@ void QETElementEditor::addText() {
* Set text field creation interface to scene * Set text field creation interface to scene
*/ */
void QETElementEditor::addTextField() { void QETElementEditor::addTextField() {
ce_scene -> setEventInterface(new ESEventAddTextField(ce_scene)); m_elmt_scene -> setEventInterface(new ESEventAddTextField(m_elmt_scene));
} }
/** /**
@@ -982,7 +989,7 @@ void QETElementEditor::addTextField() {
* Set terminal creation interface to scene * Set terminal creation interface to scene
*/ */
void QETElementEditor::addTerminal() { void QETElementEditor::addTerminal() {
ce_scene -> setEventInterface(new ESEventAddTerminal(ce_scene)); m_elmt_scene -> setEventInterface(new ESEventAddTerminal(m_elmt_scene));
} }
/** /**
@@ -1088,7 +1095,7 @@ void QETElementEditor::openElement(const QString &filepath) {
void QETElementEditor::slot_reload() void QETElementEditor::slot_reload()
{ {
//If user already edit the element, ask confirmation to reload //If user already edit the element, ask confirmation to reload
if (!ce_scene -> undoStack().isClean()) if (!m_elmt_scene -> undoStack().isClean())
{ {
QMessageBox::StandardButton answer = QET::QetMessageBox::question(this, QMessageBox::StandardButton answer = QET::QetMessageBox::question(this,
tr("Recharger l'élément", "dialog title"), tr("Recharger l'élément", "dialog title"),
@@ -1099,7 +1106,7 @@ void QETElementEditor::slot_reload()
} }
//Reload the element //Reload the element
ce_scene -> reset(); m_elmt_scene -> reset();
if (opened_from_file) if (opened_from_file)
fromFile(filename_); fromFile(filename_);
else else
@@ -1125,7 +1132,7 @@ bool QETElementEditor::slot_save()
//Else wa save to the file at filename_ path //Else wa save to the file at filename_ path
bool result_save = toFile(filename_); bool result_save = toFile(filename_);
if (result_save) ce_scene -> undoStack().setClean(); if (result_save) m_elmt_scene -> undoStack().setClean();
return(result_save); return(result_save);
} }
else else
@@ -1136,7 +1143,7 @@ bool QETElementEditor::slot_save()
//Else save to the known location //Else save to the known location
bool result_save = toLocation(location_); bool result_save = toLocation(location_);
if (result_save) { if (result_save) {
ce_scene -> undoStack().setClean(); m_elmt_scene -> undoStack().setClean();
emit saveToLocation(location_); emit saveToLocation(location_);
} }
return(result_save); return(result_save);
@@ -1153,17 +1160,21 @@ bool QETElementEditor::slot_save()
* to this location * to this location
* @return true if save with success * @return true if save with success
*/ */
bool QETElementEditor::slot_saveAs() { bool QETElementEditor::slot_saveAs()
{
// Check element befor writing // Check element befor writing
if (checkElement()) { if (checkElement())
{
//Ask a location to user //Ask a location to user
ElementsLocation location = ElementDialog::getSaveElementLocation(this); ElementsLocation location = ElementDialog::getSaveElementLocation(this);
if (location.isNull()) return(false); if (location.isNull())
return(false);
bool result_save = toLocation(location); bool result_save = toLocation(location);
if (result_save) { if (result_save)
{
setLocation(location); setLocation(location);
ce_scene -> undoStack().setClean(); m_elmt_scene->undoStack().setClean();
emit saveToLocation(location); emit saveToLocation(location);
} }
@@ -1178,9 +1189,11 @@ bool QETElementEditor::slot_saveAs() {
* Ask a file to user and save the current edited element to this file * Ask a file to user and save the current edited element to this file
* @return true if save with success * @return true if save with success
*/ */
bool QETElementEditor::slot_saveAsFile() { bool QETElementEditor::slot_saveAsFile()
{
// Check element befor writing // Check element befor writing
if (checkElement()) { if (checkElement())
{
//Ask a filename to user, for save the element //Ask a filename to user, for save the element
QString fn = QFileDialog::getSaveFileName( QString fn = QFileDialog::getSaveFileName(
this, this,
@@ -1201,10 +1214,11 @@ bool QETElementEditor::slot_saveAsFile() {
bool result_save = toFile(fn); bool result_save = toFile(fn);
//If the save success, the filename is keep //If the save success, the filename is keep
if (result_save) { if (result_save)
{
setFileName(fn); setFileName(fn);
QETApp::elementsRecentFiles() -> fileWasOpened(fn); QETApp::elementsRecentFiles() -> fileWasOpened(fn);
ce_scene -> undoStack().setClean(); m_elmt_scene -> undoStack().setClean();
} }
return(result_save); return(result_save);
@@ -1220,7 +1234,7 @@ bool QETElementEditor::slot_saveAsFile() {
l'utilisateur. l'utilisateur.
*/ */
bool QETElementEditor::canClose() { bool QETElementEditor::canClose() {
if (ce_scene -> undoStack().isClean()) return(true); if (m_elmt_scene -> undoStack().isClean()) return(true);
// demande d'abord a l'utilisateur s'il veut enregistrer l'element en cours // demande d'abord a l'utilisateur s'il veut enregistrer l'element en cours
QMessageBox::StandardButton answer = QET::QetMessageBox::question( QMessageBox::StandardButton answer = QET::QetMessageBox::question(
this, this,
@@ -1230,7 +1244,7 @@ bool QETElementEditor::canClose() {
"Voulez-vous enregistrer l'élément %1 ?", "Voulez-vous enregistrer l'élément %1 ?",
"dialog content - %1 is an element name" "dialog content - %1 is an element name"
) )
).arg(ce_scene -> names().name()), ).arg(m_elmt_scene -> names().name()),
QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel, QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel,
QMessageBox::Cancel QMessageBox::Cancel
); );
@@ -1287,7 +1301,7 @@ void QETElementEditor::closeEvent(QCloseEvent *qce) {
if (canClose()) { if (canClose()) {
writeSettings(); writeSettings();
setAttribute(Qt::WA_DeleteOnClose); setAttribute(Qt::WA_DeleteOnClose);
ce_scene -> reset(); m_elmt_scene -> reset();
qce -> accept(); qce -> accept();
} else qce -> ignore(); } else qce -> ignore();
} }
@@ -1306,7 +1320,7 @@ void QETElementEditor::firstActivation(QEvent *event) {
void QETElementEditor::slot_createPartsList() { void QETElementEditor::slot_createPartsList() {
parts_list -> blockSignals(true); parts_list -> blockSignals(true);
parts_list -> clear(); parts_list -> clear();
QList<QGraphicsItem *> qgis = ce_scene -> zItems(); QList<QGraphicsItem *> qgis = m_elmt_scene -> zItems();
// on ne construit plus la liste a partir de 200 primitives // on ne construit plus la liste a partir de 200 primitives
// c'est ingerable : la maj de la liste prend trop de temps et le resultat // c'est ingerable : la maj de la liste prend trop de temps et le resultat
@@ -1334,13 +1348,13 @@ void QETElementEditor::slot_createPartsList() {
Met a jour la selection dans la liste des parties Met a jour la selection dans la liste des parties
*/ */
void QETElementEditor::slot_updatePartsList() { void QETElementEditor::slot_updatePartsList() {
int items_count = ce_scene -> items().count(); int items_count = m_elmt_scene -> items().count();
if (parts_list -> count() != items_count) { if (parts_list -> count() != items_count) {
slot_createPartsList(); slot_createPartsList();
} else if (items_count <= QET_MAX_PARTS_IN_ELEMENT_EDITOR_LIST) { } else if (items_count <= QET_MAX_PARTS_IN_ELEMENT_EDITOR_LIST) {
parts_list -> blockSignals(true); parts_list -> blockSignals(true);
int i = 0; int i = 0;
QList<QGraphicsItem *> items = ce_scene -> zItems(); QList<QGraphicsItem *> items = m_elmt_scene -> zItems();
for (int j = items.count() - 1 ; j >= 0 ; -- j) { for (int j = items.count() - 1 ; j >= 0 ; -- j) {
QGraphicsItem *qgi = items[j]; QGraphicsItem *qgi = items[j];
QListWidgetItem *qlwi = parts_list -> item(i); QListWidgetItem *qlwi = parts_list -> item(i);
@@ -1356,7 +1370,7 @@ void QETElementEditor::slot_updatePartsList() {
parties parties
*/ */
void QETElementEditor::slot_updateSelectionFromPartsList() { void QETElementEditor::slot_updateSelectionFromPartsList() {
ce_scene -> blockSignals(true); m_elmt_scene -> blockSignals(true);
parts_list -> blockSignals(true); parts_list -> blockSignals(true);
for (int i = 0 ; i < parts_list -> count() ; ++ i) { for (int i = 0 ; i < parts_list -> count() ; ++ i) {
QListWidgetItem *qlwi = parts_list -> item(i); QListWidgetItem *qlwi = parts_list -> item(i);
@@ -1366,7 +1380,7 @@ void QETElementEditor::slot_updateSelectionFromPartsList() {
} }
} }
parts_list -> blockSignals(false); parts_list -> blockSignals(false);
ce_scene -> blockSignals(false); m_elmt_scene -> blockSignals(false);
slot_updateInformations(); slot_updateInformations();
slot_updateMenus(); slot_updateMenus();
} }
@@ -1388,7 +1402,7 @@ void QETElementEditor::readSettings()
if (state.isValid()) restoreState(state.toByteArray()); if (state.isValid()) restoreState(state.toByteArray());
// informations complementaires de l'element : valeur par defaut // informations complementaires de l'element : valeur par defaut
ce_scene -> setInformations(settings.value("elementeditor/default-informations", "").toString()); m_elmt_scene -> setInformations(settings.value("elementeditor/default-informations", "").toString());
} }
/** /**
@@ -1464,7 +1478,7 @@ void QETElementEditor::fromLocation(const ElementsLocation &location)
document_xml.appendChild(node); document_xml.appendChild(node);
//Load the element //Load the element
ce_scene -> fromXml(document_xml); m_elmt_scene -> fromXml(document_xml);
slot_createPartsList(); slot_createPartsList();
//location is read only //location is read only

View File

@@ -53,7 +53,7 @@ class QETElementEditor : public QETMainWindow {
/// view widget for the editing scene /// view widget for the editing scene
ElementView *ce_view; ElementView *ce_view;
/// editing scene /// editing scene
ElementScene *ce_scene; ElementScene *m_elmt_scene;
/// container for widgets dedicated to primitive edition /// container for widgets dedicated to primitive edition
QDockWidget *tools_dock; QDockWidget *tools_dock;
/// Stack of widgets for tools_dock /// Stack of widgets for tools_dock
@@ -164,7 +164,7 @@ class QETElementEditor : public QETMainWindow {
@param nameslist the new list of names for the currently edited element @param nameslist the new list of names for the currently edited element
*/ */
inline void QETElementEditor::setNames(const NamesList &nameslist) { inline void QETElementEditor::setNames(const NamesList &nameslist) {
ce_scene -> setNames(nameslist); m_elmt_scene -> setNames(nameslist);
} }
/** /**
@@ -185,7 +185,7 @@ inline QString QETElementEditor::fileName() const {
@return the editing scene @return the editing scene
*/ */
inline ElementScene *QETElementEditor::elementScene() const { inline ElementScene *QETElementEditor::elementScene() const {
return(ce_scene); return(m_elmt_scene);
} }
#endif #endif