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:
xavierqet 2007-09-28 17:39:30 +00:00
parent 2c184a46da
commit 9bdbf3aea5
6 changed files with 129 additions and 14 deletions

View File

@ -1,5 +1,6 @@
#ifndef BORDERINSET_H
#define BORDERINSET_H
#include "insetproperties.h"
#include <QObject>
#include <QRectF>
#include <QPainter>
@ -63,6 +64,22 @@ class BorderInset : public QObject {
void setTitle (const QString &title) { bi_title = title; }
void setFolio (const QString &folio) { bi_folio = folio; }
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
void displayInset (bool di) { display_inset = di; }
@ -78,8 +95,8 @@ class BorderInset : public QObject {
QString bi_author;
QDate bi_date;
QString bi_title;
QString bi_folio; // vraiment necessaire ce truc ?
QString bi_filename; // meme remarque
QString bi_folio;
QString bi_filename;
// dimensions du cadre et du cartouche
int nb_columns;

View File

@ -387,3 +387,37 @@ void ChangeConducerCommand::redo() {
if (first_redo) first_redo = false;
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);
}

View File

@ -234,4 +234,30 @@ class ChangeConducerCommand : public QUndoCommand {
/// booleen pour ne pas executer le premier 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

View File

@ -459,21 +459,21 @@ void DiagramView::dialogPrint() {
*/
void DiagramView::dialogEditInfos() {
// recupere le cartouche du schema
BorderInset *inset = &(scene -> border_and_inset);
InsetProperties inset = scene -> border_and_inset.exportInset();
// construit le dialogue
QDialog popup;
popup.setMinimumWidth(400);
popup.setWindowTitle(tr("Cartouche du sch\351ma"));
QLineEdit *titre = new QLineEdit(inset -> title(), &popup);
QLineEdit *auteur = new QLineEdit(inset -> author(), &popup);
QDate date_diagram = QDate(inset -> date());
QLineEdit *titre = new QLineEdit(inset.title, &popup);
QLineEdit *auteur = new QLineEdit(inset.author, &popup);
QDate date_diagram = QDate(inset.date);
if (date_diagram.isNull() || !date_diagram.isValid()) date_diagram = QDate::currentDate();
QDateEdit *date = new QDateEdit(date_diagram, &popup);
date -> setCalendarPopup(true);
QLineEdit *fichier = new QLineEdit(inset -> fileName(), &popup);
QLineEdit *folio = new QLineEdit(inset -> folio(), &popup);
QLineEdit *fichier = new QLineEdit(inset.filename, &popup);
QLineEdit *folio = new QLineEdit(inset.folio, &popup);
QWidget bidon(&popup);
QGridLayout layout_champs(&bidon);
layout_champs.addWidget(new QLabel(tr("Titre : ")), 0, 0);
@ -496,12 +496,19 @@ void DiagramView::dialogEditInfos() {
QVBoxLayout layout_v(&popup);
layout_v.addWidget(&bidon);
layout_v.addWidget(&boutons);
// si le dialogue est accepte
if (popup.exec() == QDialog::Accepted) {
inset -> setTitle(titre -> text());
inset -> setAuthor(auteur -> text());
inset -> setDate(date -> date());
inset -> setFileName(fichier -> text());
inset -> setFolio(folio -> text());
InsetProperties new_inset;
new_inset.title = titre -> text();
new_inset.author = auteur -> text();
new_inset.date = date -> date();
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
View 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

View File

@ -66,7 +66,8 @@ HEADERS += aboutqet.h \
editor/textfieldeditor.h \
diagramcommands.h \
diagramitem.h \
diagramtextitem.h
diagramtextitem.h \
insetproperties.h
SOURCES += aboutqet.cpp \
borderinset.cpp \
conducer.cpp \