[qet] [858] Optimisations diverses dans l'editeur d'elememt. |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/qet Archives
]
Revision: 858
Author: xavier
Date: 2010-02-22 20:37:46 +0100 (Mon, 22 Feb 2010)
Log Message:
-----------
Optimisations diverses dans l'editeur d'elememt.
Inclut la desactivation de la liste des primitives au-dela de 200 primitives.
Modified Paths:
--------------
trunk/sources/editor/editorcommands.cpp
trunk/sources/editor/elementscene.cpp
trunk/sources/editor/elementview.cpp
trunk/sources/editor/qetelementeditor.cpp
Modified: trunk/sources/editor/editorcommands.cpp
===================================================================
--- trunk/sources/editor/editorcommands.cpp 2010-02-18 15:09:52 UTC (rev 857)
+++ trunk/sources/editor/editorcommands.cpp 2010-02-22 19:37:46 UTC (rev 858)
@@ -47,16 +47,20 @@
/// 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 @@
/// 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 @@
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_;
Modified: trunk/sources/editor/elementscene.cpp
===================================================================
--- trunk/sources/editor/elementscene.cpp 2010-02-18 15:09:52 UTC (rev 857)
+++ trunk/sources/editor/elementscene.cpp 2010-02-22 19:37:46 UTC (rev 858)
@@ -45,6 +45,7 @@
qgi_manager(this),
element_editor(editor)
{
+ setItemIndexMethod(NoIndex);
current_polygon = NULL;
setGrid(1, 1);
initPasteArea();
@@ -391,7 +392,6 @@
case Qt::Key_Down: movement = QPointF(0.0, +movement_length); break;
}
if (!movement.isNull() && !focusItem()) {
- qDebug() << "keyPressEvent: let's move by " << movement;
if (!moving_parts_) {
moving_parts_ = true;
fsi_pos = movement;
@@ -759,6 +759,7 @@
*/
void ElementScene::slot_select(const ElementContent &content) {
blockSignals(true);
+ clearSelection();
foreach(QGraphicsItem *qgi, content) qgi -> setSelected(true);
blockSignals(false);
emit(selectionChanged());
@@ -775,7 +776,7 @@
Deselectionne tout
*/
void ElementScene::slot_deselectAll() {
- clearSelection();
+ slot_select(ElementContent());
}
/**
Modified: trunk/sources/editor/elementview.cpp
===================================================================
--- trunk/sources/editor/elementview.cpp 2010-02-18 15:09:52 UTC (rev 857)
+++ trunk/sources/editor/elementview.cpp 2010-02-22 19:37:46 UTC (rev 858)
@@ -28,6 +28,7 @@
scene_(scene),
offset_paste_count_(0)
{
+ setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
setInteractive(true);
setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
setResizeAnchor(QGraphicsView::AnchorUnderMouse);
Modified: trunk/sources/editor/qetelementeditor.cpp
===================================================================
--- trunk/sources/editor/qetelementeditor.cpp 2010-02-18 15:09:52 UTC (rev 857)
+++ trunk/sources/editor/qetelementeditor.cpp 2010-02-22 19:37:46 UTC (rev 858)
@@ -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
@@ -1119,17 +1126,25 @@
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);
}
@@ -1138,9 +1153,10 @@
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);