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
This commit is contained in:
xavierqet
2007-02-03 02:00:18 +00:00
parent 039949c0ee
commit 1e486712cc
6 changed files with 68 additions and 13 deletions

View File

@@ -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();
}

View File

@@ -21,7 +21,7 @@
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 borderHeight() const { return(columns_height + inset_height); }
qreal insetWidth() const { return(inset_width); }
qreal insetHeight() const { return(inset_height); }

View File

@@ -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());
}

View File

@@ -31,6 +31,8 @@
void dialogPrint();
void addColumn();
void removeColumn();
void expand();
void shrink();
Diagram *diagram() { return(scene); }
bool hasSelectedItems();

View File

@@ -228,6 +228,8 @@ void QETApp::actions() {
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);
@@ -311,6 +313,8 @@ void QETApp::actions() {
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();
}

View File

@@ -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;