mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-28 06:40:51 +01:00
Merge sources dir branch devel to trunk
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@2613 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -16,7 +16,7 @@
|
||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "customelementpart.h"
|
||||
#include "customelement.h"
|
||||
#include "qetgraphicsitem/customelement.h"
|
||||
#include "qetelementeditor.h"
|
||||
|
||||
/// @return le QETElementEditor auquel cet editeur appartient
|
||||
|
||||
@@ -409,39 +409,6 @@ void ChangeNamesCommand::redo() {
|
||||
editor_scene_ -> setNames(names_after);
|
||||
}
|
||||
|
||||
/**
|
||||
Constructeur
|
||||
@param element_scene Element edite
|
||||
@param before Orientations avant changement
|
||||
@param after Orientations apres changement
|
||||
@param parent QUndoCommand parent
|
||||
*/
|
||||
ChangeOrientationsCommand::ChangeOrientationsCommand(
|
||||
ElementScene *element_scene,
|
||||
const OrientationSet &before,
|
||||
const OrientationSet &after,
|
||||
QUndoCommand *parent
|
||||
) :
|
||||
ElementEditionCommand(QObject::tr("modification orientations", "undo caption"), element_scene, 0, parent),
|
||||
ori_before(before),
|
||||
ori_after(after)
|
||||
{
|
||||
}
|
||||
|
||||
/// Destructeur
|
||||
ChangeOrientationsCommand::~ChangeOrientationsCommand() {
|
||||
}
|
||||
|
||||
/// Annule le changement
|
||||
void ChangeOrientationsCommand::undo() {
|
||||
editor_scene_ -> setOrientations(ori_before);
|
||||
}
|
||||
|
||||
/// Refait le changement
|
||||
void ChangeOrientationsCommand::redo() {
|
||||
editor_scene_ -> setOrientations(ori_after);
|
||||
}
|
||||
|
||||
/**
|
||||
Constructeur
|
||||
@param elmt ElementScene concernee
|
||||
@@ -565,32 +532,6 @@ void ChangeZValueCommand::applySendBackward(const QList<QGraphicsItem *> &items_
|
||||
foreach(QGraphicsItem *qgi, non_selected_items) redo_hash.insert(qgi, z ++);
|
||||
}
|
||||
|
||||
/**
|
||||
Constructeur
|
||||
@param elmt ElementScene concernee
|
||||
@param allow true pour que les connexions internes soient acceptees, false sinon
|
||||
@param parent QUndoCommand parent
|
||||
*/
|
||||
AllowInternalConnectionsCommand::AllowInternalConnectionsCommand(ElementScene *elmt, bool allow, QUndoCommand *parent) :
|
||||
ElementEditionCommand(QObject::tr("modification connexions internes", "undo caption"), elmt, 0, parent),
|
||||
ic(allow)
|
||||
{
|
||||
}
|
||||
|
||||
/// Destructeur
|
||||
AllowInternalConnectionsCommand::~AllowInternalConnectionsCommand() {
|
||||
}
|
||||
|
||||
/// Annule le changement d'autorisation pour les connexions internes
|
||||
void AllowInternalConnectionsCommand::undo() {
|
||||
editor_scene_ -> setInternalConnections(!ic);
|
||||
}
|
||||
|
||||
/// Refait le changement d'autorisation pour les connexions internes
|
||||
void AllowInternalConnectionsCommand::redo() {
|
||||
editor_scene_ -> setInternalConnections(ic);
|
||||
}
|
||||
|
||||
/**
|
||||
Constructeur
|
||||
@param elmt ElementScene concernee
|
||||
|
||||
@@ -248,30 +248,6 @@ class ChangeNamesCommand : public ElementEditionCommand {
|
||||
NamesList names_after;
|
||||
};
|
||||
|
||||
/**
|
||||
This command changes the allowed orientations of an electrical element.
|
||||
*/
|
||||
class ChangeOrientationsCommand : public ElementEditionCommand {
|
||||
// constructors, destructor
|
||||
public:
|
||||
ChangeOrientationsCommand(ElementScene *, const OrientationSet &, const OrientationSet &, QUndoCommand * = 0);
|
||||
virtual ~ChangeOrientationsCommand();
|
||||
private:
|
||||
ChangeOrientationsCommand(const ChangeOrientationsCommand &);
|
||||
|
||||
// methods
|
||||
public:
|
||||
virtual void undo();
|
||||
virtual void redo();
|
||||
|
||||
// attributes
|
||||
private:
|
||||
/// Former orientations
|
||||
OrientationSet ori_before;
|
||||
/// New orientations
|
||||
OrientationSet ori_after;
|
||||
};
|
||||
|
||||
/**
|
||||
This command changes the zValue of a set of primitives when editing an
|
||||
electrical element.
|
||||
@@ -312,29 +288,6 @@ class ChangeZValueCommand : public ElementEditionCommand {
|
||||
Option option;
|
||||
};
|
||||
|
||||
/**
|
||||
This command enables or disables internal connections for an electrical
|
||||
element.
|
||||
*/
|
||||
class AllowInternalConnectionsCommand : public ElementEditionCommand {
|
||||
// constructors, destructor
|
||||
public:
|
||||
AllowInternalConnectionsCommand(ElementScene *, bool, QUndoCommand * = 0);
|
||||
virtual ~AllowInternalConnectionsCommand();
|
||||
private:
|
||||
AllowInternalConnectionsCommand(const AllowInternalConnectionsCommand &);
|
||||
|
||||
// methods
|
||||
public:
|
||||
virtual void undo();
|
||||
virtual void redo();
|
||||
|
||||
// attributes
|
||||
private:
|
||||
/// whether internal connections are allowed afterward
|
||||
bool ic;
|
||||
};
|
||||
|
||||
/**
|
||||
This command changes extra information carried by an electrical element.
|
||||
*/
|
||||
|
||||
@@ -38,7 +38,6 @@
|
||||
*/
|
||||
ElementScene::ElementScene(QETElementEditor *editor, QObject *parent) :
|
||||
QGraphicsScene(parent),
|
||||
internal_connections(false),
|
||||
qgi_manager(this),
|
||||
element_editor(editor),
|
||||
decorator_(0)
|
||||
@@ -415,9 +414,9 @@ const QDomDocument ElementScene::toXml(bool all_parts) {
|
||||
root.setAttribute("height", QString("%1").arg(upheight));
|
||||
root.setAttribute("hotspot_x", QString("%1").arg(-(qRound(size.x() - (xmargin/2)))));
|
||||
root.setAttribute("hotspot_y", QString("%1").arg(-(qRound(size.y() - (ymargin/2)))));
|
||||
root.setAttribute("orientation", ori.toString());
|
||||
root.setAttribute("orientation", "dyyy"); //we keep the orientation for compatibility with previous version of qet
|
||||
root.setAttribute("version", QET::version);
|
||||
if (internal_connections) root.setAttribute("ic", "true");
|
||||
root.setAttribute("ic", "true"); //we keep the internal connection for compatibility with previous version of qet
|
||||
|
||||
// noms de l'element
|
||||
root.appendChild(_names.toXml(xml_document));
|
||||
@@ -663,58 +662,6 @@ void ElementScene::slot_delete() {
|
||||
emit(selectionChanged());
|
||||
}
|
||||
|
||||
/**
|
||||
Lance un dialogue pour editer les noms de cete element
|
||||
*/
|
||||
void ElementScene::slot_editOrientations() {
|
||||
bool is_read_only = element_editor && element_editor -> isReadOnly();
|
||||
|
||||
// cree un dialogue
|
||||
QDialog dialog_ori(element_editor);
|
||||
dialog_ori.setModal(true);
|
||||
#ifdef Q_WS_MAC
|
||||
dialog_ori.setWindowFlags(Qt::Sheet);
|
||||
#endif
|
||||
dialog_ori.setMinimumSize(400, 260);
|
||||
dialog_ori.setWindowTitle(tr("\311diter les orientations", "window title"));
|
||||
QVBoxLayout *dialog_layout = new QVBoxLayout(&dialog_ori);
|
||||
|
||||
// ajoute un champ explicatif au dialogue
|
||||
QLabel *information_label = new QLabel(tr("L'orientation par d\351faut est l'orientation dans laquelle s'effectue la cr\351ation de l'\351l\351ment."));
|
||||
information_label -> setAlignment(Qt::AlignJustify | Qt::AlignVCenter);
|
||||
information_label -> setWordWrap(true);
|
||||
dialog_layout -> addWidget(information_label);
|
||||
|
||||
// ajoute un OrientationSetWidget au dialogue
|
||||
OrientationSetWidget *ori_widget = new OrientationSetWidget();
|
||||
ori_widget -> setOrientationSet(ori);
|
||||
ori_widget -> setReadOnly(is_read_only);
|
||||
dialog_layout -> addWidget(ori_widget);
|
||||
|
||||
// ajoute une case a cocher pour les connexions internes
|
||||
QCheckBox *ic_checkbox = new QCheckBox(tr("Autoriser les connexions internes"));
|
||||
ic_checkbox -> setChecked(internal_connections);
|
||||
ic_checkbox -> setDisabled(is_read_only);
|
||||
dialog_layout -> addWidget(ic_checkbox);
|
||||
dialog_layout -> addStretch();
|
||||
// ajoute deux boutons au dialogue
|
||||
QDialogButtonBox *dialog_buttons = new QDialogButtonBox(is_read_only ? QDialogButtonBox::Ok : QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||
dialog_layout -> addWidget(dialog_buttons);
|
||||
connect(dialog_buttons, SIGNAL(accepted()), &dialog_ori, SLOT(accept()));
|
||||
connect(dialog_buttons, SIGNAL(rejected()), &dialog_ori, SLOT(reject()));
|
||||
|
||||
// lance le dialogue
|
||||
if (dialog_ori.exec() == QDialog::Accepted && !is_read_only) {
|
||||
OrientationSet new_ori = ori_widget -> orientationSet();
|
||||
if (new_ori != ori) {
|
||||
undoStack().push(new ChangeOrientationsCommand(this, ori, new_ori));
|
||||
}
|
||||
if (ic_checkbox -> isChecked() != internal_connections) {
|
||||
undoStack().push(new AllowInternalConnectionsCommand(this, ic_checkbox -> isChecked()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Lance un dialogue pour editer les informations complementaires de cet
|
||||
element. Concretement, ce champ libre est destine a accueillir des informations
|
||||
@@ -979,18 +926,7 @@ bool ElementScene::applyInformations(const QDomDocument &xml_document, QString *
|
||||
}
|
||||
return(false);
|
||||
}
|
||||
|
||||
// orientations
|
||||
internal_connections = (root.attribute("ic") == "true");
|
||||
|
||||
// connexions internes
|
||||
if (!ori.fromString(root.attribute("orientation"))) {
|
||||
if (error_message) {
|
||||
*error_message = tr("Les orientations ne sont pas valides.", "error message");
|
||||
}
|
||||
return(false);
|
||||
}
|
||||
|
||||
|
||||
// extrait les noms de la definition XML
|
||||
_names.fromXml(root);
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
#include <QtGui>
|
||||
#include <QtXml>
|
||||
#include "nameslistwidget.h"
|
||||
#include "orientationsetwidget.h"
|
||||
#include "qgimanager.h"
|
||||
#include "elementcontent.h"
|
||||
class CustomElementPart;
|
||||
@@ -65,10 +64,6 @@ class ElementScene : public QGraphicsScene {
|
||||
private:
|
||||
/// List of localized names
|
||||
NamesList _names;
|
||||
/// Set of orientations
|
||||
OrientationSet ori;
|
||||
/// whether internal connections (i.e. connections between terminals of a same element) are accepted
|
||||
bool internal_connections;
|
||||
/// Extra informations
|
||||
QString informations_;
|
||||
/// QGraphicsItem manager
|
||||
@@ -112,8 +107,6 @@ class ElementScene : public QGraphicsScene {
|
||||
public:
|
||||
void setNames(const NamesList &);
|
||||
NamesList names() const;
|
||||
OrientationSet orientations();
|
||||
void setOrientations(const OrientationSet &);
|
||||
bool internalConnections();
|
||||
void setInternalConnections(bool);
|
||||
QString informations() const;
|
||||
@@ -178,7 +171,6 @@ class ElementScene : public QGraphicsScene {
|
||||
void slot_invertSelection();
|
||||
void slot_delete();
|
||||
void slot_editNames();
|
||||
void slot_editOrientations();
|
||||
void slot_editAuthorInformations();
|
||||
void slot_bringForward();
|
||||
void slot_raise();
|
||||
@@ -222,34 +214,6 @@ inline NamesList ElementScene::names() const {
|
||||
return(_names);
|
||||
}
|
||||
|
||||
/**
|
||||
@return the orientation set of the currently edited element
|
||||
*/
|
||||
inline OrientationSet ElementScene::orientations() {
|
||||
return(ori);
|
||||
}
|
||||
|
||||
/**
|
||||
@param orientation_set the new orientation set for the currently edited element
|
||||
*/
|
||||
inline void ElementScene::setOrientations(const OrientationSet &orientation_set) {
|
||||
ori = orientation_set;
|
||||
}
|
||||
|
||||
/**
|
||||
@return whether internal connections are accepted
|
||||
*/
|
||||
inline bool ElementScene::internalConnections() {
|
||||
return(internal_connections);
|
||||
}
|
||||
|
||||
/**
|
||||
@param ic true for internal connections to be accepted, false otherwise
|
||||
*/
|
||||
inline void ElementScene::setInternalConnections(bool ic) {
|
||||
internal_connections = ic;
|
||||
}
|
||||
|
||||
/**
|
||||
@return extra informations of the currently edited element
|
||||
*/
|
||||
|
||||
@@ -322,7 +322,6 @@ ElementContent ElementView::pasteWithOffset(const QDomDocument &xml_document) {
|
||||
// on applique le decalage qui convient
|
||||
final_pasted_content_bounding_rect = applyMovement(
|
||||
pasted_content_bounding_rect,
|
||||
QETElementEditor::pasteMovement(),
|
||||
QETElementEditor::pasteOffset()
|
||||
);
|
||||
}
|
||||
@@ -483,21 +482,11 @@ void ElementView::drawBackground(QPainter *p, const QRectF &r) {
|
||||
@param movement Orientation du decalage a appliquer
|
||||
@param offset Decalage a appliquer
|
||||
*/
|
||||
QRectF ElementView::applyMovement(const QRectF &start, const QET::OrientedMovement &movement, const QPointF &offset) {
|
||||
// calcule le decalage a appliquer a partir de l'offset indique et du mouvement
|
||||
QRectF ElementView::applyMovement(const QRectF &start, const QPointF &offset) {
|
||||
// calcule le decalage a appliquer a partir de l'offset
|
||||
QPointF final_offset;
|
||||
if (movement == QET::ToNorthEast || movement == QET::ToEast || movement == QET::ToSouthEast) {
|
||||
final_offset.rx() = start.width() + offset.x();
|
||||
} else if (movement == QET::ToNorthWest || movement == QET::ToWest || movement == QET::ToSouthWest) {
|
||||
final_offset.rx() = -start.width() - offset.x();
|
||||
}
|
||||
|
||||
if (movement == QET::ToNorthWest || movement == QET::ToNorth || movement == QET::ToNorthEast) {
|
||||
final_offset.ry() = -start.height() - offset.y();
|
||||
} else if (movement == QET::ToSouthWest || movement == QET::ToSouth || movement == QET::ToSouthEast) {
|
||||
final_offset.ry() = start.height() + offset.y();
|
||||
}
|
||||
|
||||
final_offset.rx() = start.width() + offset.x();
|
||||
|
||||
// applique le decalage ainsi calcule
|
||||
return(start.translated(final_offset));
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#define ELEMENT_VIEW_H
|
||||
#include <QGraphicsView>
|
||||
#include "elementscene.h"
|
||||
|
||||
/**
|
||||
This class provides a widget to render an ElementScene instance, i.e. the
|
||||
edition class for electrical elements.
|
||||
@@ -50,7 +51,7 @@ class ElementView : public QGraphicsView {
|
||||
virtual void drawBackground(QPainter *, const QRectF &);
|
||||
|
||||
private:
|
||||
QRectF applyMovement(const QRectF &, const QET::OrientedMovement &, const QPointF &);
|
||||
QRectF applyMovement(const QRectF &, const QPointF &);
|
||||
|
||||
public slots:
|
||||
void setVisualisationMode();
|
||||
|
||||
@@ -145,7 +145,6 @@ void QETElementEditor::setupActions() {
|
||||
zoom_fit = new QAction(QET::Icons::ZoomFitBest, tr("Zoom adapt\351"), this);
|
||||
zoom_reset = new QAction(QET::Icons::ZoomOriginal, tr("Pas de zoom"), this);
|
||||
edit_names = new QAction(QET::Icons::Names, tr("\311diter les noms"), this);
|
||||
edit_ori = new QAction(QET::Icons::Orientations, tr("\311diter les orientations"), this);
|
||||
edit_author = new QAction(QET::Icons::UserInformations, tr("\311diter les informations sur l'auteur"), this);
|
||||
edit_raise = new QAction(QET::Icons::Raise, tr("Rapprocher"), this);
|
||||
edit_lower = new QAction(QET::Icons::Lower, tr("\311loigner"), this);
|
||||
@@ -204,7 +203,6 @@ void QETElementEditor::setupActions() {
|
||||
zoom_reset -> setShortcut(QKeySequence(tr("Ctrl+0")));
|
||||
|
||||
edit_names -> setShortcut(QKeySequence(tr("Ctrl+E")));
|
||||
edit_ori -> setShortcut(QKeySequence(tr("Ctrl+T")));
|
||||
edit_author -> setShortcut(tr("Ctrl+Y"));
|
||||
|
||||
edit_raise -> setShortcut(QKeySequence(tr("Ctrl+Shift+Up")));
|
||||
@@ -235,7 +233,6 @@ void QETElementEditor::setupActions() {
|
||||
connect(zoom_reset, SIGNAL(triggered()), ce_view, SLOT(zoomReset()));
|
||||
connect(edit_delete, SIGNAL(triggered()), ce_scene, SLOT(slot_delete()));
|
||||
connect(edit_names, SIGNAL(triggered()), ce_scene, SLOT(slot_editNames()));
|
||||
connect(edit_ori, SIGNAL(triggered()), ce_scene, SLOT(slot_editOrientations()));
|
||||
connect(edit_author, SIGNAL(triggered()), ce_scene, SLOT(slot_editAuthorInformations()));
|
||||
connect(edit_forward, SIGNAL(triggered()), ce_scene, SLOT(slot_bringForward()));
|
||||
connect(edit_raise, SIGNAL(triggered()), ce_scene, SLOT(slot_raise()));
|
||||
@@ -318,7 +315,6 @@ void QETElementEditor::setupActions() {
|
||||
view_toolbar -> addAction(zoom_fit);
|
||||
view_toolbar -> addAction(zoom_reset);
|
||||
element_toolbar -> addAction(edit_names);
|
||||
element_toolbar -> addAction(edit_ori);
|
||||
depth_toolbar -> addAction(edit_forward);
|
||||
depth_toolbar -> addAction(edit_raise);
|
||||
depth_toolbar -> addAction(edit_lower);
|
||||
@@ -393,7 +389,6 @@ void QETElementEditor::setupMenus() {
|
||||
edit_menu -> addAction(edit_delete);
|
||||
edit_menu -> addSeparator();
|
||||
edit_menu -> addAction(edit_names);
|
||||
edit_menu -> addAction(edit_ori);
|
||||
edit_menu -> addAction(edit_author);
|
||||
edit_menu -> addSeparator();
|
||||
edit_menu -> addAction(edit_forward);
|
||||
@@ -1238,14 +1233,6 @@ QPointF QETElementEditor::pasteOffset() {
|
||||
return(paste_offset);
|
||||
}
|
||||
|
||||
/**
|
||||
@return Le type de mouvement a effectuer lors d'un copier/coller avec
|
||||
decalage.
|
||||
*/
|
||||
QET::OrientedMovement QETElementEditor::pasteMovement() {
|
||||
return(QET::ToEast);
|
||||
}
|
||||
|
||||
/**
|
||||
Demande a l'utilisateur d'ouvrir un fichier sense etre un element.
|
||||
@param parent QWidget parent du dialogue d'ouverture de fichier
|
||||
|
||||
@@ -71,7 +71,7 @@ class QETElementEditor : public QETMainWindow {
|
||||
QAction *selectall, *deselectall, *inv_select;
|
||||
QAction *cut, *copy, *paste, *paste_in_area, *paste_from_file, *paste_from_elmt;
|
||||
QAction *undo, *redo;
|
||||
QAction *edit_delete, *edit_size_hs, *edit_names, *edit_ori, *edit_author;
|
||||
QAction *edit_delete, *edit_size_hs, *edit_names, *edit_author;
|
||||
QAction *edit_raise, *edit_lower, *edit_backward, *edit_forward;
|
||||
/// actions for the "display" menu
|
||||
QAction *zoom_in, *zoom_out, *zoom_fit, *zoom_reset;
|
||||
@@ -93,7 +93,6 @@ class QETElementEditor : public QETMainWindow {
|
||||
// methods
|
||||
public:
|
||||
void setNames(const NamesList &);
|
||||
void setOrientations(const OrientationSet &orientation_set);
|
||||
OrientationSet orientations() const;
|
||||
void setLocation(const ElementsLocation &);
|
||||
ElementsLocation location() const;
|
||||
@@ -111,7 +110,6 @@ class QETElementEditor : public QETMainWindow {
|
||||
void readSettings();
|
||||
void writeSettings();
|
||||
static QPointF pasteOffset();
|
||||
static QET::OrientedMovement pasteMovement();
|
||||
static QString getOpenElementFileName(QWidget * = 0, const QString & = QString());
|
||||
void contextMenu(QContextMenuEvent *event);
|
||||
|
||||
@@ -160,20 +158,6 @@ inline void QETElementEditor::setNames(const NamesList &nameslist) {
|
||||
ce_scene -> setNames(nameslist);
|
||||
}
|
||||
|
||||
/**
|
||||
@param orientation_set the new set of orientations for the currently edited element
|
||||
*/
|
||||
inline void QETElementEditor::setOrientations(const OrientationSet &orientation_set) {
|
||||
ce_scene -> setOrientations(orientation_set);
|
||||
}
|
||||
|
||||
/**
|
||||
@param the set of orientations for the currently edited element
|
||||
*/
|
||||
inline OrientationSet QETElementEditor::orientations() const {
|
||||
return(ce_scene -> orientations());
|
||||
}
|
||||
|
||||
/**
|
||||
@return the location of the currently edited element
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user