mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-09-14 20:33:05 +02:00
Les editions du cartouche sont desormais annulables
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@141 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
parent
2c184a46da
commit
9bdbf3aea5
@ -1,5 +1,6 @@
|
|||||||
#ifndef BORDERINSET_H
|
#ifndef BORDERINSET_H
|
||||||
#define BORDERINSET_H
|
#define BORDERINSET_H
|
||||||
|
#include "insetproperties.h"
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QRectF>
|
#include <QRectF>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
@ -63,6 +64,22 @@ class BorderInset : public QObject {
|
|||||||
void setTitle (const QString &title) { bi_title = title; }
|
void setTitle (const QString &title) { bi_title = title; }
|
||||||
void setFolio (const QString &folio) { bi_folio = folio; }
|
void setFolio (const QString &folio) { bi_folio = folio; }
|
||||||
void setFileName (const QString &filename) { bi_filename = filename; }
|
void setFileName (const QString &filename) { bi_filename = filename; }
|
||||||
|
InsetProperties exportInset() {
|
||||||
|
InsetProperties ip;
|
||||||
|
ip.author = bi_author;
|
||||||
|
ip.date = bi_date;
|
||||||
|
ip.title = bi_title;
|
||||||
|
ip.folio = bi_folio;
|
||||||
|
ip.filename = bi_filename;
|
||||||
|
return(ip);
|
||||||
|
}
|
||||||
|
void importInset(const InsetProperties &ip) {
|
||||||
|
bi_author = ip.author;
|
||||||
|
bi_date = ip.date;
|
||||||
|
bi_title = ip.title;
|
||||||
|
bi_folio = ip.folio;
|
||||||
|
bi_filename = ip.filename;
|
||||||
|
}
|
||||||
|
|
||||||
// methodes d'acces en ecriture aux options
|
// methodes d'acces en ecriture aux options
|
||||||
void displayInset (bool di) { display_inset = di; }
|
void displayInset (bool di) { display_inset = di; }
|
||||||
@ -78,8 +95,8 @@ class BorderInset : public QObject {
|
|||||||
QString bi_author;
|
QString bi_author;
|
||||||
QDate bi_date;
|
QDate bi_date;
|
||||||
QString bi_title;
|
QString bi_title;
|
||||||
QString bi_folio; // vraiment necessaire ce truc ?
|
QString bi_folio;
|
||||||
QString bi_filename; // meme remarque
|
QString bi_filename;
|
||||||
|
|
||||||
// dimensions du cadre et du cartouche
|
// dimensions du cadre et du cartouche
|
||||||
int nb_columns;
|
int nb_columns;
|
||||||
|
@ -387,3 +387,37 @@ void ChangeConducerCommand::redo() {
|
|||||||
if (first_redo) first_redo = false;
|
if (first_redo) first_redo = false;
|
||||||
else conducer -> setProfile(new_profile);
|
else conducer -> setProfile(new_profile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Constructeur
|
||||||
|
@param d Schema dont on modifie le cartouche
|
||||||
|
@param old_ip Anciennes proprietes du cartouches
|
||||||
|
@param new_ip Nouvelles proprietes du cartouches
|
||||||
|
@param parent QUndoCommand parent
|
||||||
|
*/
|
||||||
|
ChangeInsetCommand::ChangeInsetCommand(
|
||||||
|
Diagram *d,
|
||||||
|
const InsetProperties &old_ip,
|
||||||
|
const InsetProperties &new_ip,
|
||||||
|
QUndoCommand *parent
|
||||||
|
) :
|
||||||
|
QUndoCommand(QObject::tr("modifier le cartouche"), parent),
|
||||||
|
diagram(d),
|
||||||
|
old_inset(old_ip),
|
||||||
|
new_inset(new_ip)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Destructeur
|
||||||
|
ChangeInsetCommand::~ChangeInsetCommand() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Annule la modification de cartouche
|
||||||
|
void ChangeInsetCommand::undo() {
|
||||||
|
diagram -> border_and_inset.importInset(old_inset);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Refait la modification de cartouche
|
||||||
|
void ChangeInsetCommand::redo() {
|
||||||
|
diagram -> border_and_inset.importInset(new_inset);
|
||||||
|
}
|
||||||
|
@ -234,4 +234,30 @@ class ChangeConducerCommand : public QUndoCommand {
|
|||||||
/// booleen pour ne pas executer le premier redo()
|
/// booleen pour ne pas executer le premier redo()
|
||||||
bool first_redo;
|
bool first_redo;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
Cette classe represente l'action de modifier les informations du cartouche d'un schema
|
||||||
|
*/
|
||||||
|
class ChangeInsetCommand : public QUndoCommand {
|
||||||
|
// constructeurs, destructeur
|
||||||
|
public:
|
||||||
|
ChangeInsetCommand(Diagram *, const InsetProperties &, const InsetProperties &, QUndoCommand * = 0);
|
||||||
|
virtual ~ChangeInsetCommand();
|
||||||
|
private:
|
||||||
|
ChangeInsetCommand(const ChangeInsetCommand &);
|
||||||
|
|
||||||
|
// methodes
|
||||||
|
public:
|
||||||
|
virtual void undo();
|
||||||
|
virtual void redo();
|
||||||
|
|
||||||
|
// attributs
|
||||||
|
private:
|
||||||
|
/// DiagramTextItem modifie
|
||||||
|
Diagram *diagram;
|
||||||
|
/// texte avant changement
|
||||||
|
InsetProperties old_inset;
|
||||||
|
/// texte apres changement
|
||||||
|
InsetProperties new_inset;
|
||||||
|
};
|
||||||
#endif
|
#endif
|
||||||
|
@ -459,21 +459,21 @@ void DiagramView::dialogPrint() {
|
|||||||
*/
|
*/
|
||||||
void DiagramView::dialogEditInfos() {
|
void DiagramView::dialogEditInfos() {
|
||||||
// recupere le cartouche du schema
|
// recupere le cartouche du schema
|
||||||
BorderInset *inset = &(scene -> border_and_inset);
|
InsetProperties inset = scene -> border_and_inset.exportInset();
|
||||||
|
|
||||||
// construit le dialogue
|
// construit le dialogue
|
||||||
QDialog popup;
|
QDialog popup;
|
||||||
popup.setMinimumWidth(400);
|
popup.setMinimumWidth(400);
|
||||||
popup.setWindowTitle(tr("Cartouche du sch\351ma"));
|
popup.setWindowTitle(tr("Cartouche du sch\351ma"));
|
||||||
|
|
||||||
QLineEdit *titre = new QLineEdit(inset -> title(), &popup);
|
QLineEdit *titre = new QLineEdit(inset.title, &popup);
|
||||||
QLineEdit *auteur = new QLineEdit(inset -> author(), &popup);
|
QLineEdit *auteur = new QLineEdit(inset.author, &popup);
|
||||||
QDate date_diagram = QDate(inset -> date());
|
QDate date_diagram = QDate(inset.date);
|
||||||
if (date_diagram.isNull() || !date_diagram.isValid()) date_diagram = QDate::currentDate();
|
if (date_diagram.isNull() || !date_diagram.isValid()) date_diagram = QDate::currentDate();
|
||||||
QDateEdit *date = new QDateEdit(date_diagram, &popup);
|
QDateEdit *date = new QDateEdit(date_diagram, &popup);
|
||||||
date -> setCalendarPopup(true);
|
date -> setCalendarPopup(true);
|
||||||
QLineEdit *fichier = new QLineEdit(inset -> fileName(), &popup);
|
QLineEdit *fichier = new QLineEdit(inset.filename, &popup);
|
||||||
QLineEdit *folio = new QLineEdit(inset -> folio(), &popup);
|
QLineEdit *folio = new QLineEdit(inset.folio, &popup);
|
||||||
QWidget bidon(&popup);
|
QWidget bidon(&popup);
|
||||||
QGridLayout layout_champs(&bidon);
|
QGridLayout layout_champs(&bidon);
|
||||||
layout_champs.addWidget(new QLabel(tr("Titre : ")), 0, 0);
|
layout_champs.addWidget(new QLabel(tr("Titre : ")), 0, 0);
|
||||||
@ -496,12 +496,19 @@ void DiagramView::dialogEditInfos() {
|
|||||||
QVBoxLayout layout_v(&popup);
|
QVBoxLayout layout_v(&popup);
|
||||||
layout_v.addWidget(&bidon);
|
layout_v.addWidget(&bidon);
|
||||||
layout_v.addWidget(&boutons);
|
layout_v.addWidget(&boutons);
|
||||||
|
// si le dialogue est accepte
|
||||||
if (popup.exec() == QDialog::Accepted) {
|
if (popup.exec() == QDialog::Accepted) {
|
||||||
inset -> setTitle(titre -> text());
|
InsetProperties new_inset;
|
||||||
inset -> setAuthor(auteur -> text());
|
new_inset.title = titre -> text();
|
||||||
inset -> setDate(date -> date());
|
new_inset.author = auteur -> text();
|
||||||
inset -> setFileName(fichier -> text());
|
new_inset.date = date -> date();
|
||||||
inset -> setFolio(folio -> text());
|
new_inset.filename = fichier -> text();
|
||||||
|
new_inset.folio = folio -> text();
|
||||||
|
|
||||||
|
// s'il y a des modifications
|
||||||
|
if (new_inset != inset) {
|
||||||
|
scene -> undoStack().push(new ChangeInsetCommand(scene, inset, new_inset));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
30
insetproperties.h
Normal file
30
insetproperties.h
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
#ifndef INSET_PROPERTIES_H
|
||||||
|
#define INSET_PROPERTIES_H
|
||||||
|
#include <QDate>
|
||||||
|
#include <QString>
|
||||||
|
class InsetProperties {
|
||||||
|
public:
|
||||||
|
InsetProperties() {
|
||||||
|
}
|
||||||
|
virtual ~InsetProperties() {
|
||||||
|
}
|
||||||
|
bool operator==(const InsetProperties &ip) {
|
||||||
|
return(
|
||||||
|
ip.title == title &&\
|
||||||
|
ip.author == author &&\
|
||||||
|
ip.date == date &&\
|
||||||
|
ip.filename == filename &&\
|
||||||
|
ip.folio == folio
|
||||||
|
);
|
||||||
|
}
|
||||||
|
bool operator!=(const InsetProperties &ip) {
|
||||||
|
return(!(*this == ip));
|
||||||
|
}
|
||||||
|
// attributs
|
||||||
|
QString title;
|
||||||
|
QString author;
|
||||||
|
QDate date;
|
||||||
|
QString filename;
|
||||||
|
QString folio;
|
||||||
|
};
|
||||||
|
#endif
|
@ -66,7 +66,8 @@ HEADERS += aboutqet.h \
|
|||||||
editor/textfieldeditor.h \
|
editor/textfieldeditor.h \
|
||||||
diagramcommands.h \
|
diagramcommands.h \
|
||||||
diagramitem.h \
|
diagramitem.h \
|
||||||
diagramtextitem.h
|
diagramtextitem.h \
|
||||||
|
insetproperties.h
|
||||||
SOURCES += aboutqet.cpp \
|
SOURCES += aboutqet.cpp \
|
||||||
borderinset.cpp \
|
borderinset.cpp \
|
||||||
conducer.cpp \
|
conducer.cpp \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user