Rapatriement dans la branche 0.3 des revisions 855 a 870.

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/branches/0.3@871 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
xavier
2010-02-28 16:13:45 +00:00
parent f6f320a0a6
commit 815a2ea3e8
50 changed files with 3500 additions and 2942 deletions

View File

@@ -48,7 +48,7 @@ ArcEditor::ArcEditor(QETElementEditor *editor, PartArc *arc, QWidget *parent) :
QGridLayout *grid = new QGridLayout();
grid -> addWidget(new QLabel(tr("Centre : ")), 0, 0);
grid -> addWidget(new QLabel("x"), 1, 0);
grid -> addWidget(new QLabel("x"), 1, 0, Qt::AlignRight);
grid -> addWidget(x, 1, 1);
grid -> addWidget(new QLabel("y"), 1, 2);
grid -> addWidget(y, 1, 3);

View File

@@ -43,7 +43,7 @@ CircleEditor::CircleEditor(QETElementEditor *editor, PartCircle *circle, QWidget
QGridLayout *grid = new QGridLayout();
grid -> addWidget(new QLabel(tr("Centre : ")), 0, 0);
grid -> addWidget(new QLabel("x"), 1, 0);
grid -> addWidget(new QLabel("x"), 1, 0, Qt::AlignRight);
grid -> addWidget(x, 1, 1);
grid -> addWidget(new QLabel("y"), 1, 2);
grid -> addWidget(y, 1, 3);

View File

@@ -47,16 +47,20 @@ DeletePartsCommand::~DeletePartsCommand() {
/// Restaure les parties supprimees
void DeletePartsCommand::undo() {
editor_scene -> blockSignals(true);
foreach(QGraphicsItem *qgi, deleted_parts) {
editor_scene -> addItem(qgi);
}
editor_scene -> blockSignals(false);
}
/// Supprime les parties
void DeletePartsCommand::redo() {
editor_scene -> blockSignals(true);
foreach(QGraphicsItem *qgi, deleted_parts) {
editor_scene -> removeItem(qgi);
}
editor_scene -> blockSignals(false);
}
/*** CutPartsCommand ***/
@@ -90,7 +94,11 @@ PastePartsCommand::~PastePartsCommand() {
/// annule le coller
void PastePartsCommand::undo() {
// enleve les parties
foreach(QGraphicsItem *part, content_) editor_scene_ -> removeItem(part);
editor_scene_ -> blockSignals(true);
foreach(QGraphicsItem *part, content_) {
editor_scene_ -> removeItem(part);
}
editor_scene_ -> blockSignals(false);
if (uses_offset) {
editor_view_ -> offset_paste_count_ = old_offset_paste_count_;
editor_view_ -> start_top_left_corner_ = old_start_top_left_corner_;
@@ -103,7 +111,11 @@ void PastePartsCommand::redo() {
if (first_redo) first_redo = false;
else {
// pose les parties
foreach(QGraphicsItem *part, content_) editor_scene_ -> addItem(part);
editor_scene_ -> blockSignals(true);
foreach(QGraphicsItem *part, content_) {
editor_scene_ -> addItem(part);
}
editor_scene_ -> blockSignals(false);
if (uses_offset) {
editor_view_ -> offset_paste_count_ = new_offset_paste_count_;
editor_view_ -> start_top_left_corner_ = new_start_top_left_corner_;

View File

@@ -45,6 +45,7 @@ ElementScene::ElementScene(QETElementEditor *editor, QObject *parent) :
qgi_manager(this),
element_editor(editor)
{
setItemIndexMethod(NoIndex);
current_polygon = NULL;
setGrid(1, 1);
initPasteArea();
@@ -758,6 +759,7 @@ void ElementScene::paste() {
*/
void ElementScene::slot_select(const ElementContent &content) {
blockSignals(true);
clearSelection();
foreach(QGraphicsItem *qgi, content) qgi -> setSelected(true);
blockSignals(false);
emit(selectionChanged());
@@ -774,7 +776,7 @@ void ElementScene::slot_selectAll() {
Deselectionne tout
*/
void ElementScene::slot_deselectAll() {
clearSelection();
slot_select(ElementContent());
}
/**
@@ -805,6 +807,8 @@ void ElementScene::slot_delete() {
(hotspot) de l'element.
*/
void ElementScene::slot_editSizeHotSpot() {
bool is_read_only = element_editor && element_editor -> isReadOnly();
// cree un dialogue
QDialog dialog_sh(element_editor);
dialog_sh.setModal(true);
@@ -822,23 +826,25 @@ void ElementScene::slot_editSizeHotSpot() {
hotspot_editor -> setOldHotspot(hotspot());
hotspot_editor -> setPartsRect(itemsBoundingRect());
hotspot_editor -> setPartsRectEnabled(true);
hotspot_editor -> setReadOnly(is_read_only);
dialog_layout -> addWidget(hotspot_editor);
// ajoute deux boutons au dialogue
QDialogButtonBox *dialog_buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
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_sh, SLOT(accept()));
connect(dialog_buttons, SIGNAL(rejected()), &dialog_sh, SLOT(reject()));
// lance le dialogue
if (dialog_sh.exec() != QDialog::Accepted) return;
QSize new_size(hotspot_editor -> elementSize());
QSize old_size(width(), height());
QPoint new_hotspot(hotspot_editor -> hotspot());
QPoint old_hotspot(_hotspot);
if (new_size != old_size || new_hotspot != old_hotspot) {
undo_stack.push(new ChangeHotspotCommand(this, old_size, new_size, old_hotspot, new_hotspot, hotspot_editor -> offsetParts()));
if (dialog_sh.exec() == QDialog::Accepted && is_read_only) {
QSize new_size(hotspot_editor -> elementSize());
QSize old_size(width(), height());
QPoint new_hotspot(hotspot_editor -> hotspot());
QPoint old_hotspot(_hotspot);
if (new_size != old_size || new_hotspot != old_hotspot) {
undo_stack.push(new ChangeHotspotCommand(this, old_size, new_size, old_hotspot, new_hotspot, hotspot_editor -> offsetParts()));
}
}
}
@@ -846,6 +852,7 @@ void ElementScene::slot_editSizeHotSpot() {
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);
@@ -866,21 +873,23 @@ void ElementScene::slot_editOrientations() {
// 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(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
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) {
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));
@@ -897,6 +906,7 @@ void ElementScene::slot_editOrientations() {
sur l'auteur de l'element, sa licence, etc.
*/
void ElementScene::slot_editAuthorInformations() {
bool is_read_only = element_editor && element_editor -> isReadOnly();
// cree un dialogue
QDialog dialog_author(element_editor);
@@ -918,16 +928,17 @@ void ElementScene::slot_editAuthorInformations() {
QTextEdit *text_field = new QTextEdit();
text_field -> setAcceptRichText(false);
text_field -> setPlainText(informations());
text_field -> setReadOnly(is_read_only);
dialog_layout -> addWidget(text_field);
// ajoute deux boutons au dialogue
QDialogButtonBox *dialog_buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
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_author, SLOT(accept()));
connect(dialog_buttons, SIGNAL(rejected()), &dialog_author, SLOT(reject()));
// lance le dialogue
if (dialog_author.exec() == QDialog::Accepted) {
if (dialog_author.exec() == QDialog::Accepted && !is_read_only) {
QString new_infos = text_field -> toPlainText();
if (new_infos != informations()) {
undoStack().push(new ChangeInformationsCommand(this, informations(), new_infos));
@@ -939,6 +950,7 @@ void ElementScene::slot_editAuthorInformations() {
Lance un dialogue pour editer les noms de cet element
*/
void ElementScene::slot_editNames() {
bool is_read_only = element_editor && element_editor -> isReadOnly();
// cree un dialogue
QDialog dialog(element_editor);
@@ -959,17 +971,18 @@ void ElementScene::slot_editNames() {
// ajoute un NamesListWidget au dialogue
NamesListWidget *names_widget = new NamesListWidget();
names_widget -> setNames(_names);
names_widget -> setReadOnly(is_read_only);
dialog_layout -> addWidget(names_widget);
// ajoute deux boutons au dialogue
QDialogButtonBox *dialog_buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
QDialogButtonBox *dialog_buttons = new QDialogButtonBox(is_read_only ? QDialogButtonBox::Ok : QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
dialog_layout -> addWidget(dialog_buttons);
connect(dialog_buttons, SIGNAL(accepted()), names_widget, SLOT(check()));
connect(names_widget, SIGNAL(inputChecked()), &dialog, SLOT(accept()));
connect(dialog_buttons, SIGNAL(rejected()), &dialog, SLOT(reject()));
// lance le dialogue
if (dialog.exec() == QDialog::Accepted) {
if (dialog.exec() == QDialog::Accepted && !is_read_only) {
NamesList new_names(names_widget -> names());
if (new_names != _names) undoStack().push(new ChangeNamesCommand(this, _names, new_names));
}

View File

@@ -28,6 +28,7 @@ ElementView::ElementView(ElementScene *scene, QWidget *parent) :
scene_(scene),
offset_paste_count_(0)
{
setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
setInteractive(true);
setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
setResizeAnchor(QGraphicsView::AnchorUnderMouse);

View File

@@ -45,7 +45,7 @@ EllipseEditor::EllipseEditor(QETElementEditor *editor, PartEllipse *ellipse, QWi
QGridLayout *grid = new QGridLayout();
grid -> addWidget(new QLabel(tr("Centre : ")), 0, 0);
grid -> addWidget(new QLabel("x"), 1, 0);
grid -> addWidget(new QLabel("x"), 1, 0, Qt::AlignRight);
grid -> addWidget(x, 1, 1);
grid -> addWidget(new QLabel("y"), 1, 2);
grid -> addWidget(y, 1, 3);

View File

@@ -39,6 +39,13 @@
#include "texteditor.h"
#include "textfieldeditor.h"
/*
Nombre maximum de primitives affichees par la "liste des parties"
Au-dela, un petit message est affiche, indiquant que ce nombre a ete depasse
et que la liste ne sera donc pas mise a jour.
*/
#define QET_MAX_PARTS_IN_ELEMENT_EDITOR_LIST 200
/**
Constructeur
@param parent QWidget parent
@@ -439,10 +446,6 @@ void QETElementEditor::slot_updateMenus() {
inv_select -> setEnabled(!read_only);
paste_from_file -> setEnabled(!read_only);
paste_from_elmt -> setEnabled(!read_only);
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
@@ -511,6 +514,8 @@ void QETElementEditor::setupInterface() {
// ScrollArea pour accueillir un widget d'edition (change a la volee)
tools_dock_scroll_area_ = new QScrollArea();
tools_dock_scroll_area_ -> setFrameStyle(QFrame::NoFrame);
tools_dock_scroll_area_ -> setAlignment(Qt::AlignHCenter|Qt::AlignTop);
// Pile de widgets pour accueillir les deux widgets precedents
tools_dock_stack_ = new QStackedWidget();
@@ -1117,17 +1122,25 @@ void QETElementEditor::slot_createPartsList() {
parts_list -> blockSignals(true);
parts_list -> clear();
QList<QGraphicsItem *> qgis = ce_scene -> zItems(true);
for (int j = qgis.count() - 1 ; j >= 0 ; -- j) {
QGraphicsItem *qgi = qgis[j];
if (CustomElementPart *cep = dynamic_cast<CustomElementPart *>(qgi)) {
QString part_desc = cep -> name();
QListWidgetItem *qlwi = new QListWidgetItem(part_desc);
QVariant v;
v.setValue<QGraphicsItem *>(qgi);
qlwi -> setData(42, v);
parts_list -> addItem(qlwi);
qlwi -> setSelected(qgi -> isSelected());
// on ne construit plus la liste a partir de 200 primitives
// c'est ingerable : la maj de la liste prend trop de temps et le resultat
// est inexploitable
if (qgis.count() <= QET_MAX_PARTS_IN_ELEMENT_EDITOR_LIST) {
for (int j = qgis.count() - 1 ; j >= 0 ; -- j) {
QGraphicsItem *qgi = qgis[j];
if (CustomElementPart *cep = dynamic_cast<CustomElementPart *>(qgi)) {
QString part_desc = cep -> name();
QListWidgetItem *qlwi = new QListWidgetItem(part_desc);
QVariant v;
v.setValue<QGraphicsItem *>(qgi);
qlwi -> setData(42, v);
parts_list -> addItem(qlwi);
qlwi -> setSelected(qgi -> isSelected());
}
}
} else {
parts_list -> addItem(new QListWidgetItem(tr("Trop de primitives, liste non g\351n\351r\351e.")));
}
parts_list -> blockSignals(false);
}
@@ -1136,9 +1149,10 @@ void QETElementEditor::slot_createPartsList() {
Met a jour la selection dans la liste des parties
*/
void QETElementEditor::slot_updatePartsList() {
if (parts_list -> count() != ce_scene -> items().count()) {
int items_count = ce_scene -> items().count();
if (parts_list -> count() != items_count) {
slot_createPartsList();
} else {
} else if (items_count <= QET_MAX_PARTS_IN_ELEMENT_EDITOR_LIST) {
parts_list -> blockSignals(true);
int i = 0;
QList<QGraphicsItem *> items = ce_scene -> zItems(true);

View File

@@ -43,12 +43,12 @@ RectangleEditor::RectangleEditor(QETElementEditor *editor, PartRectangle *rect,
QVBoxLayout *v_layout = new QVBoxLayout(this);
QGridLayout *grid = new QGridLayout();
grid -> addWidget(new QLabel(tr("Coin sup\351rieur gauche\240: ")), 0, 0);
grid -> addWidget(new QLabel("x"), 1, 0);
grid -> addWidget(new QLabel(tr("Coin sup\351rieur gauche\240: ")), 0, 0, 1, 4);
grid -> addWidget(new QLabel("x"), 1, 0, Qt::AlignRight);
grid -> addWidget(x, 1, 1);
grid -> addWidget(new QLabel("y"), 1, 2);
grid -> addWidget(y, 1, 3);
grid -> addWidget(new QLabel(tr("Dimensions\240: ")), 2, 0);
grid -> addWidget(new QLabel(tr("Dimensions\240: ")), 2, 0, 1, 4);
grid -> addWidget(new QLabel(tr("Largeur\240:")), 3, 0);
grid -> addWidget(w, 3, 1);
grid -> addWidget(new QLabel(tr("Hauteur\240:")), 4, 0);