mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-18 22:00:35 +01:00
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
This commit is contained in:
BIN
ico/16x16/preferences-desktop-user.png
Normal file
BIN
ico/16x16/preferences-desktop-user.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 825 B |
BIN
ico/22x22/preferences-desktop-user.png
Normal file
BIN
ico/22x22/preferences-desktop-user.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
@@ -55,6 +55,7 @@
|
||||
<file>ico/16x16/object-rotate-right.png</file>
|
||||
<file>ico/16x16/orientations.png</file>
|
||||
<file>ico/16x16/phase.png</file>
|
||||
<file>ico/16x16/preferences-desktop-user.png</file>
|
||||
<file>ico/16x16/project.png</file>
|
||||
<file>ico/16x16/qet.png</file>
|
||||
<file>ico/16x16/remove_col.png</file>
|
||||
@@ -129,6 +130,7 @@
|
||||
<file>ico/22x22/object-unlocked.png</file>
|
||||
<file>ico/22x22/polygon.png</file>
|
||||
<file>ico/22x22/portrait.png</file>
|
||||
<file>ico/22x22/preferences-desktop-user.png</file>
|
||||
<file>ico/22x22/raise.png</file>
|
||||
<file>ico/22x22/rectangle.png</file>
|
||||
<file>ico/22x22/restaurer.png</file>
|
||||
|
||||
@@ -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_);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user