From 275d08b2bcded6ca6f10f8e887fa12f2488635b0 Mon Sep 17 00:00:00 2001 From: xavier Date: Sun, 7 Feb 2010 17:07:22 +0000 Subject: [PATCH] Ajout d'un champ "informations" dans le format .elmt afin de stocker diverses informations complementaires, a commencer par l'auteur et la licence de l'element. git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@845 bfdf4180-ca20-0410-9c96-a3a8aa849046 --- ico/16x16/preferences-desktop-user.png | Bin 0 -> 825 bytes ico/22x22/preferences-desktop-user.png | Bin 0 -> 1229 bytes qelectrotech.qrc | 2 + sources/editor/editorcommands.cpp | 29 ++++++++++++ sources/editor/editorcommands.h | 27 +++++++++++ sources/editor/elementscene.cpp | 61 ++++++++++++++++++++++++- sources/editor/elementscene.h | 19 ++++++++ sources/editor/qetelementeditor.cpp | 5 ++ sources/editor/qetelementeditor.h | 2 +- sources/qeticons.cpp | 3 ++ sources/qeticons.h | 1 + 11 files changed, 147 insertions(+), 2 deletions(-) create mode 100644 ico/16x16/preferences-desktop-user.png create mode 100644 ico/22x22/preferences-desktop-user.png diff --git a/ico/16x16/preferences-desktop-user.png b/ico/16x16/preferences-desktop-user.png new file mode 100644 index 0000000000000000000000000000000000000000..346f21e7bdab6f68ef31c1ee6e6db224fdeab0c2 GIT binary patch literal 825 zcmV-91IGM`P)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01ejw01ejxLMWSf00007bV*G`2iOAw z4j&`Bv(#Sz00Oy5L_t(|+KrJ(XcJ)=hTnfOnXOq(+GH{x) z@PF_7eSAMb8AmoPWH^rBCRR9B3!5t@1vZuiD2SfdV$ncF_ro_o>3ADVZ)m6|t!?dq z;0CdADCQMhy?Cw~fX~t(%3v@GkJnQ>vD$AL?O^R3I9>oJNQgAfD21b(@&G-r5Bj_= z049hfTGXww00zYZfREz_ke*SXd_?4&eagS&n$!w}| z4o(eE-ptzwOhd)@FQ0Jt&iy^s+t2^{MnzHX_77xGV^9C)D&6k zayz~KpTEDjdgH+p{qZStOu)QojOot`E4M}FBKi9V)I3G7ekM8FOAh#_w;WW(3crJ8 zV0c4_trD(05v1*aiLf&8A_8!GbdDuc=iLR(~V(GM=B9Vib__$0T_i|MjlotWwQ!&qfk=O zG{-1XUxUr_eE=unL$ZkHeFHE>4+ukYypcXe8fGmL1A%Zyv?aQ{Zc1PV&+`Ea>M|*K zYbzUTV`N>|GnZffPW7?V!U{y5(~_^Hp}xZd&-9)@^};4LQ{9l000000NkvXXu0mjf DyzOz> literal 0 HcmV?d00001 diff --git a/ico/22x22/preferences-desktop-user.png b/ico/22x22/preferences-desktop-user.png new file mode 100644 index 0000000000000000000000000000000000000000..d95b259ab6c57c2e051584742ac01e95c5395206 GIT binary patch literal 1229 zcmV;;1Ty=HP)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L011Qu011Qvs^VjL00007bV*G`2iOAw z4jv^+%Rnmt00d1*L_t(|+MSe3Ok7nQ#=mo)^XASB!_4sLFbp8zNT4fZNSFXMh(`sQb{RL2Ij>K^SpCk$HPQJ z4VH?(Gxy* zL2wQq){|+toK7&i`03I`2!hxT#=adBKvt9naH0*IAfT;13V*N#9-kla!GkbO!_V3! z?n{_$=x96867qZ903rAMUy5xM#e=S{XaGQHzmD$;0>34RB0wz=P!MXesSa2sD+85E zWqEtuzJys$wWY<|=kmEMs9puk8mO^dRaPpBxeRVCEWX3m(S7$gpU=O36-T8|H?7Ts2Oi|$+1{;(k2j4Q-{UeXVWRnUHb9k>GR)xw$Hfj zpjOqng_SG@?KViFiCRs?om3I|OnM#+`^0IkJKPiqhC@AS&8YtJ>%xtqXRC}a-luyC zGxXMI7gkF;{U-a0TxX0Q z&Z@gw(bYF1w=_qNJvuu1=J>=DVUe&Dl!{Ok1-_A8zSfaK)!?5WP}tXK zxV)k|sLeg@b~!sY&^9C7BiIy;wx1e1JbH3+Vl2=c4npGq%V8oAp%CqE*jwV5H;jPB z=IPBMx*H`tb?^Xs)^oUUc^%u%CAaUm&D;1T`Af8OYHDikh2zhK{5}tCvH*eSK?niI z%CszS9EYt^1ryUVuqgq6f(co8dLW3UR2kP+3ZS5M@qBvYV%_oh`1nW1jvfj56*p{> z2vOMSkVR?z0LsSYL>9%W0fR5IX97{=(HnNwTk(B$J2@ISP-vRoE%f#uerR}jXvF2V z0|elCt}X_;`?i*tP`+42*%U!!CmxG)q1YxqxKe;+Fws&0TA{28ot?3xg9DG$ z9T|oN%c3AV*TX+(ZSq2~5vYimemvViQWzay|TQO}>{Dd*T+O=QL-N%lA# z4!E3l=(@p#tompeW_{F+?L#d*+}?!r-6dSh%g7Qh2+!lIga^w-4y2UQT=|7ps@08| zzf-}BqWpL;+&mNtwRE(#h9i30>)j8`y(Z00000NkvXXu0mjfS2IBP literal 0 HcmV?d00001 diff --git a/qelectrotech.qrc b/qelectrotech.qrc index ebf6f384a..7824abad1 100644 --- a/qelectrotech.qrc +++ b/qelectrotech.qrc @@ -55,6 +55,7 @@ ico/16x16/object-rotate-right.png ico/16x16/orientations.png ico/16x16/phase.png + ico/16x16/preferences-desktop-user.png ico/16x16/project.png ico/16x16/qet.png ico/16x16/remove_col.png @@ -129,6 +130,7 @@ ico/22x22/object-unlocked.png ico/22x22/polygon.png ico/22x22/portrait.png + ico/22x22/preferences-desktop-user.png ico/22x22/raise.png ico/22x22/rectangle.png ico/22x22/restaurer.png diff --git a/sources/editor/editorcommands.cpp b/sources/editor/editorcommands.cpp index c42cce446..65618d128 100644 --- a/sources/editor/editorcommands.cpp +++ b/sources/editor/editorcommands.cpp @@ -590,3 +590,32 @@ void AllowInternalConnectionsCommand::undo() { void AllowInternalConnectionsCommand::redo() { element -> setInternalConnections(ic); } + +/** + Constructeur + @param elmt ElementScene concernee + @param old_infos Informations complementaires precedentes + @param old_infos Nouvelles informations complementaires + @param parent QUndoCommand parent +*/ +ChangeInformationsCommand::ChangeInformationsCommand(ElementScene *elmt, const QString &old_infos, const QString &new_infos, QUndoCommand *parent) : + QUndoCommand(QObject::tr("modification informations complementaires", "undo caption"), parent), + element(elmt), + old_informations_(old_infos), + new_informations_(new_infos) +{ +} + +/// Destructeur +ChangeInformationsCommand::~ChangeInformationsCommand() { +} + +/// Annule le changement d'autorisation pour les connexions internes +void ChangeInformationsCommand::undo() { + element -> setInformations(old_informations_); +} + +/// Refait le changement d'autorisation pour les connexions internes +void ChangeInformationsCommand::redo() { + element -> setInformations(new_informations_); +} diff --git a/sources/editor/editorcommands.h b/sources/editor/editorcommands.h index b9f1c45f9..9b58a7a92 100644 --- a/sources/editor/editorcommands.h +++ b/sources/editor/editorcommands.h @@ -356,4 +356,31 @@ class AllowInternalConnectionsCommand : public QUndoCommand { /// autorisation des connexions internes apres modification bool ic; }; + +/** + Cette classe represente l'action de changer les informations + complementaires d'un element. +*/ +class ChangeInformationsCommand : public QUndoCommand { + // constructeurs, destructeur + public: + ChangeInformationsCommand(ElementScene *, const QString &, const QString &, QUndoCommand * = 0); + virtual ~ChangeInformationsCommand(); + private: + ChangeInformationsCommand(const ChangeInformationsCommand &); + + // methodes + public: + virtual void undo(); + virtual void redo(); + + // attributs + private: + /// Element edite auquel il faut appliquer les modifications + ElementScene *element; + /// Informations avant modification + QString old_informations_; + /// Informations apres modification + QString new_informations_; +}; #endif diff --git a/sources/editor/elementscene.cpp b/sources/editor/elementscene.cpp index da0f1f394..3384ddaa0 100644 --- a/sources/editor/elementscene.cpp +++ b/sources/editor/elementscene.cpp @@ -559,6 +559,11 @@ const QDomDocument ElementScene::toXml(bool all_parts) const { // noms de l'element root.appendChild(_names.toXml(xml_document)); + // informations complementaires de l'element + QDomElement informations_element = xml_document.createElement("informations"); + root.appendChild(informations_element); + informations_element.appendChild(xml_document.createTextNode(informations())); + QDomElement description = xml_document.createElement("description"); // description de l'element foreach(QGraphicsItem *qgi, zItems(true)) { @@ -887,6 +892,50 @@ void ElementScene::slot_editOrientations() { } } +/** + Lance un dialogue pour editer les informations complementaires de cet + element. Concretement, ce champ libre est destine a accueillir des informations + sur l'auteur de l'element, sa licence, etc. +*/ +void ElementScene::slot_editAuthorInformations() { + + // cree un dialogue + QDialog dialog_author(element_editor); + dialog_author.setModal(true); +#ifdef Q_WS_MAC + dialog_author.setWindowFlags(Qt::Sheet); +#endif + dialog_author.setMinimumSize(400, 260); + dialog_author.setWindowTitle(tr("\311diter les informations sur l'auteur", "window title")); + QVBoxLayout *dialog_layout = new QVBoxLayout(&dialog_author); + + // ajoute un champ explicatif au dialogue + QLabel *information_label = new QLabel(tr("Vous pouvez utiliser ce champ libre pour mentionner les auteurs de l'\351l\351ment, sa licence, ou tout autre renseignement que vous jugerez utile.")); + information_label -> setAlignment(Qt::AlignJustify | Qt::AlignVCenter); + information_label -> setWordWrap(true); + dialog_layout -> addWidget(information_label); + + // ajoute un QTextEdit au dialogue + QTextEdit *text_field = new QTextEdit(); + text_field -> setAcceptRichText(false); + text_field -> setPlainText(informations()); + dialog_layout -> addWidget(text_field); + + // ajoute deux boutons au dialogue + QDialogButtonBox *dialog_buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); + dialog_layout -> addWidget(dialog_buttons); + connect(dialog_buttons, SIGNAL(accepted()), &dialog_author, SLOT(accept())); + connect(dialog_buttons, SIGNAL(rejected()), &dialog_author, SLOT(reject())); + + // lance le dialogue + if (dialog_author.exec() == QDialog::Accepted) { + QString new_infos = text_field -> toPlainText(); + if (new_infos != informations()) { + undoStack().push(new ChangeInformationsCommand(this, informations(), new_infos)); + } + } +} + /** Lance un dialogue pour editer les noms de cet element */ @@ -1044,7 +1093,7 @@ QRectF ElementScene::elementContentBoundingRect(const ElementContent &content) { /** Applique les informations (dimensions, hostpot, orientations, connexions - internes et noms) contenu dans un document XML. + internes, noms et informations complementaires) contenu dans un document XML. @param xml_document Document XML a analyser @param error_message pointeur vers une QString ; si error_message est different de 0, un message d'erreur sera stocke dedans si necessaire @@ -1093,6 +1142,16 @@ bool ElementScene::applyInformations(const QDomDocument &xml_document, QString * // extrait les noms de la definition XML _names.fromXml(root); + // extrait les informations complementaires + for (QDomNode node = root.firstChild() ; !node.isNull() ; node = node.nextSibling()) { + QDomElement elmt = node.toElement(); + if (elmt.isNull()) continue; + if (elmt.tagName() == "informations") { + setInformations(elmt.text()); + break; + } + } + return(true); } diff --git a/sources/editor/elementscene.h b/sources/editor/elementscene.h index 9ed1e71a0..757ad9bb2 100644 --- a/sources/editor/elementscene.h +++ b/sources/editor/elementscene.h @@ -64,6 +64,8 @@ class ElementScene : public QGraphicsScene { OrientationSet ori; /// booleen indiquant si les bornes de l'element peuvent etre reliees a des bornes de ce meme element bool internal_connections; + /// Chaine contenant les informations complementaires de l'element + QString informations_; /// Gestionnaire de QGraphicsItem QGIManager qgi_manager; /// Pile des actions annulables @@ -114,6 +116,8 @@ class ElementScene : public QGraphicsScene { void setOrientations(const OrientationSet &); bool internalConnections(); void setInternalConnections(bool); + QString informations() const; + void setInformations(const QString &); virtual int xGrid() const; virtual int yGrid() const; virtual void setGrid(int, int); @@ -175,6 +179,7 @@ class ElementScene : public QGraphicsScene { void slot_editSizeHotSpot(); void slot_editNames(); void slot_editOrientations(); + void slot_editAuthorInformations(); void slot_bringForward(); void slot_raise(); void slot_lower(); @@ -284,4 +289,18 @@ inline void ElementScene::setInternalConnections(bool ic) { internal_connections = ic; } +/** + @return les informations complementaires de cet element +*/ +inline QString ElementScene::informations() const { + return(informations_); +} + +/** + @param infos les nouvelles informations complementaires de cet element +*/ +inline void ElementScene::setInformations(const QString &infos) { + informations_ = infos; +} + #endif diff --git a/sources/editor/qetelementeditor.cpp b/sources/editor/qetelementeditor.cpp index b57f0d7d6..144257b9b 100644 --- a/sources/editor/qetelementeditor.cpp +++ b/sources/editor/qetelementeditor.cpp @@ -96,6 +96,7 @@ void QETElementEditor::setupActions() { edit_size_hs = new QAction(QET::Icons::HotSpot, tr("\311diter la taille et le point de saisie"), 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); edit_backward = new QAction(QET::Icons::SendBackward, tr("Envoyer au fond"), this); @@ -167,6 +168,7 @@ void QETElementEditor::setupActions() { edit_names -> setShortcut(QKeySequence(tr("Ctrl+E"))); edit_size_hs -> setShortcut(QKeySequence(tr("Ctrl+R"))); edit_ori -> setShortcut(QKeySequence(tr("Ctrl+T"))); + edit_author -> setShortcut(tr("Ctrl+Y")); edit_raise -> setShortcut(QKeySequence(tr("Ctrl+Shift+Up"))); edit_lower -> setShortcut(QKeySequence(tr("Ctrl+Shift+Down"))); @@ -202,6 +204,7 @@ void QETElementEditor::setupActions() { connect(fullscreen, SIGNAL(triggered()), this, SLOT(toggleFullScreen())); connect(configure, SIGNAL(triggered()), qet_app, SLOT(configureQET())); 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())); connect(edit_lower, SIGNAL(triggered()), ce_scene, SLOT(slot_lower())); @@ -368,6 +371,7 @@ void QETElementEditor::setupMenus() { edit_menu -> addAction(edit_names); edit_menu -> addAction(edit_size_hs); edit_menu -> addAction(edit_ori); + edit_menu -> addAction(edit_author); edit_menu -> addSeparator(); edit_menu -> addAction(edit_forward); edit_menu -> addAction(edit_raise); @@ -417,6 +421,7 @@ void QETElementEditor::slot_updateMenus() { edit_size_hs -> setEnabled(!read_only); edit_names -> setEnabled(!read_only); edit_ori -> setEnabled(!read_only); + edit_author -> setEnabled(!read_only); parts_list -> setEnabled(!read_only); // actions dependant de la presence de parties selectionnees diff --git a/sources/editor/qetelementeditor.h b/sources/editor/qetelementeditor.h index 9090aa9f2..01150c3a5 100644 --- a/sources/editor/qetelementeditor.h +++ b/sources/editor/qetelementeditor.h @@ -68,7 +68,7 @@ class QETElementEditor : public QMainWindow { 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; + QAction *edit_delete, *edit_size_hs, *edit_names, *edit_ori, *edit_author; QAction *edit_raise, *edit_lower, *edit_backward, *edit_forward; /// actions du menu affichage QAction *zoom_in, *zoom_out, *zoom_fit, *zoom_reset; diff --git a/sources/qeticons.cpp b/sources/qeticons.cpp index 79a39ffe4..568a1fd0c 100644 --- a/sources/qeticons.cpp +++ b/sources/qeticons.cpp @@ -126,6 +126,7 @@ namespace QET { QIcon South; QIcon Start; QIcon Terminal; + QIcon UserInformations; QIcon ViewFitWidth; QIcon ViewFitWindow; QIcon ViewMove; @@ -297,6 +298,8 @@ void QET::Icons::initIcons() { South .addFile(":/ico/16x16/south.png"); Start .addFile(":/ico/22x22/start.png"); Terminal .addFile(":/ico/22x22/terminal.png"); + UserInformations .addFile(":/ico/16x16/preferences-desktop-user.png"); + UserInformations .addFile(":/ico/22x22/preferences-desktop-user.png"); ViewFitWidth .addFile(":/ico/22x22/view_fit_width.png"); ViewFitWindow .addFile(":/ico/22x22/view_fit_window.png"); ViewMove .addFile(":/ico/22x22/move.png"); diff --git a/sources/qeticons.h b/sources/qeticons.h index 86fc53b1e..9768d9e87 100644 --- a/sources/qeticons.h +++ b/sources/qeticons.h @@ -136,6 +136,7 @@ namespace QET { extern QIcon South; extern QIcon Start; extern QIcon Terminal; + extern QIcon UserInformations; extern QIcon ViewFitWidth; extern QIcon ViewFitWindow; extern QIcon ViewMove;