From 1e486712cc333b47f115bd5e4198fb5e3f42e7bd Mon Sep 17 00:00:00 2001 From: xavierqet Date: Sat, 3 Feb 2007 02:00:18 +0000 Subject: [PATCH] Ajout de la possibilite de modifier la hauteur du schema git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@53 bfdf4180-ca20-0410-9c96-a3a8aa849046 --- borderinset.cpp | 8 +++++--- borderinset.h | 16 ++++++++-------- diagramview.cpp | 21 +++++++++++++++++++++ diagramview.h | 2 ++ qetapp.cpp | 30 ++++++++++++++++++++++++++++-- qetapp.h | 4 ++++ 6 files changed, 68 insertions(+), 13 deletions(-) diff --git a/borderinset.cpp b/borderinset.cpp index e9180e4bf..a04afe45b 100644 --- a/borderinset.cpp +++ b/borderinset.cpp @@ -34,7 +34,7 @@ void BorderInset::updateRectangles() { border = QRectF(0, 0, nb_columns * columns_width, columns_height); // rectangles relatifs au cartouche - inset = QRectF(border.bottomRight().x() - inset_width, border.bottomRight().y() - inset_height, inset_width, inset_height); + inset = QRectF(border.bottomLeft().x(), border.bottomLeft().y(), inset_width, inset_height); inset_author = QRectF(inset.topLeft(), QSizeF(2.0 * inset_width / 9.0, 0.5 * inset_height)); inset_date = QRectF(inset_author.bottomLeft(), inset_author.size()); inset_title = QRectF(inset_author.topRight(), QSizeF(5.0 * inset_width / 9.0, inset_height)); @@ -118,6 +118,7 @@ void BorderInset::draw(QPainter *qp, qreal x, qreal y) { */ void BorderInset::addColumn() { ++ nb_columns; + setInsetWidth(nb_columns * columns_width); updateRectangles(); } @@ -127,6 +128,7 @@ void BorderInset::addColumn() { void BorderInset::removeColumn() { if (nb_columns == 3) return; -- nb_columns; + setInsetWidth(nb_columns * columns_width); updateRectangles(); } @@ -150,10 +152,10 @@ void BorderInset::setColumnsHeaderHeight(const qreal &new_chh) { /** Change la hauteur des colonnes (et donc du cadre). Cette hauteur doit - rester superieure a 10px. + rester superieure a la hauteur des en-tetes de colonnes + 20px. */ void BorderInset::setColumnsHeight(const qreal &new_ch) { - columns_height = qMax(10.0, new_ch); + columns_height = qMax(columns_header_height + 20.0, new_ch); updateRectangles(); } diff --git a/borderinset.h b/borderinset.h index 2f0ee6a96..1de25ef63 100644 --- a/borderinset.h +++ b/borderinset.h @@ -16,14 +16,14 @@ void draw(QPainter *, qreal = 0.0, qreal = 0.0); // methodes d'acces en lecture aux dimensions - int nbColumn() const { return(nb_columns); } - qreal columnsWidth() const { return(columns_width); } - qreal columnsHeaderHeight() const { return(columns_header_height); } - qreal columnsHeight() const { return(columns_height); } - qreal borderWidth() const { return(nb_columns * columns_width); } - qreal borderHeight() const { return(columns_height); } - qreal insetWidth() const { return(inset_width); } - qreal insetHeight() const { return(inset_height); } + int nbColumn() const { return(nb_columns); } + qreal columnsWidth() const { return(columns_width); } + qreal columnsHeaderHeight() const { return(columns_header_height); } + qreal columnsHeight() const { return(columns_height); } + qreal borderWidth() const { return(nb_columns * columns_width); } + qreal borderHeight() const { return(columns_height + inset_height); } + qreal insetWidth() const { return(inset_width); } + qreal insetHeight() const { return(inset_height); } // methodes d'acces en lecture aux informations du cartouche QString author() const { return(bi_author); } diff --git a/diagramview.cpp b/diagramview.cpp index d1e1fdd64..3afcd5fc7 100644 --- a/diagramview.cpp +++ b/diagramview.cpp @@ -526,3 +526,24 @@ void DiagramView::removeColumn() { // rafraichit la vue scene -> update(sceneRect()); } + +void DiagramView::expand() { + // ajoute 10 pixels + scene -> border_and_inset.setColumnsHeight(scene -> border_and_inset.columnsHeight() + 20.0); + + // met a jour la zone affichee par la vue + QRectF sr = sceneRect(); + sr.setHeight(20.0 + sr.height()); + setSceneRect(sr); + + // rafraichit la vue + scene -> update(sceneRect()); +} + +void DiagramView::shrink() { + // enleve 10 pixels + scene -> border_and_inset.setColumnsHeight(scene -> border_and_inset.columnsHeight() - 20.0); + + // rafraichit la vue + scene -> update(sceneRect()); +} diff --git a/diagramview.h b/diagramview.h index e98197602..4acd010e4 100644 --- a/diagramview.h +++ b/diagramview.h @@ -31,6 +31,8 @@ void dialogPrint(); void addColumn(); void removeColumn(); + void expand(); + void shrink(); Diagram *diagram() { return(scene); } bool hasSelectedItems(); diff --git a/qetapp.cpp b/qetapp.cpp index df96d9027..62f7b5ff3 100644 --- a/qetapp.cpp +++ b/qetapp.cpp @@ -225,9 +225,11 @@ void QETApp::actions() { sel_inverse = new QAction( tr("Inverser la s\351lection"), this); supprimer = new QAction(QIcon(":/ico/delete.png"), tr("Supprimer"), this); pivoter = new QAction(QIcon(":/ico/pivoter.png"), tr("Pivoter"), this); - infos_diagram = new QAction(QIcon(":/ico/info.png"), tr("Informations sur le sch\351ma"), this); + infos_diagram = new QAction(QIcon(":/ico/info.png"), tr("Informations sur le sch\351ma"), this); add_column = new QAction( tr("Ajouter une colonne"), this); remove_column = new QAction( tr("Enlever une colonne"), this); + expand_diagram = new QAction( tr("Agrandir le sch\351ma"), this); + shrink_diagram = new QAction( tr("R\351tr\351cir le sch\351ma"), this); toggle_aa = new QAction( tr("D\351sactiver l'&antialiasing"), this); zoom_avant = new QAction(QIcon(":/ico/viewmag+.png"), tr("Zoom avant"), this); @@ -308,9 +310,11 @@ void QETApp::actions() { sel_inverse -> setStatusTip(tr("D\351s\351lectionne les \351l\351ments s\351lectionn\351s et s\351lectionne les \351l\351ments non s\351lectionn\351s")); supprimer -> setStatusTip(tr("Enl\350ve les \351l\351ments s\351lectionn\351s du sch\351ma")); pivoter -> setStatusTip(tr("Pivote les \351l\351ments s\351lectionn\351s")); - infos_diagram -> setStatusTip(tr("\311dite les informations affich\351es par le cartouche")); + infos_diagram -> setStatusTip(tr("\311dite les informations affich\351es par le cartouche")); add_column -> setStatusTip(tr("Ajoute une colonne au sch\351ma")); remove_column -> setStatusTip(tr("Enl\350ve une colonne au sch\351ma")); + expand_diagram -> setStatusTip(tr("Agrandit le sch\351ma en hauteur")); + shrink_diagram -> setStatusTip(tr("R\351tr\351cit le sch\351ma en hauteur")); toggle_aa -> setStatusTip(tr("Active / d\351sactive l'antialiasing pour le rendu du sch\351ma courant")); zoom_avant -> setStatusTip(tr("Agrandit le sch\351ma")); @@ -382,6 +386,8 @@ void QETApp::actions() { connect(infos_diagram, SIGNAL(activated()), this, SLOT(slot_editInfos()) ); connect(add_column, SIGNAL(activated()), this, SLOT(slot_addColumn()) ); connect(remove_column, SIGNAL(activated()), this, SLOT(slot_removeColumn()) ); + connect(expand_diagram, SIGNAL(activated()), this, SLOT(slot_expand()) ); + connect(shrink_diagram, SIGNAL(activated()), this, SLOT(slot_shrink()) ); } /** @@ -436,6 +442,8 @@ void QETApp::menus() { menu_edition -> addAction(infos_diagram); menu_edition -> addAction(add_column); menu_edition -> addAction(remove_column); + menu_edition -> addAction(expand_diagram); + menu_edition -> addAction(shrink_diagram); // menu Affichage > Afficher QMenu *menu_aff_aff = new QMenu(tr("Afficher")); @@ -947,3 +955,21 @@ void QETApp::slot_removeColumn() { if (!sv) return; sv -> removeColumn(); } + +/** + Allonge le schema en cours en hauteur +*/ +void QETApp::slot_expand() { + DiagramView *sv = diagramEnCours(); + if (!sv) return; + sv -> expand(); +} + +/** + Retrecit le schema en cours en hauteur +*/ +void QETApp::slot_shrink() { + DiagramView *sv = diagramEnCours(); + if (!sv) return; + sv -> shrink(); +} diff --git a/qetapp.h b/qetapp.h index 5846747c0..16527a01d 100644 --- a/qetapp.h +++ b/qetapp.h @@ -57,6 +57,8 @@ void slot_updateMenuFenetres(); void slot_addColumn(); void slot_removeColumn(); + void slot_expand(); + void slot_shrink(); protected: // Actions faisables au travers de menus dans l'application QElectroTech @@ -85,6 +87,8 @@ QAction *infos_diagram; QAction *add_column; QAction *remove_column; + QAction *expand_diagram; + QAction *shrink_diagram; QAction *poser_fil; QAction *reduce_appli; QAction *restore_appli;