[qet] [848] Introduction de la classe QTextOrientationSPinBoxWidget, qui regroupe un QTextOrientationWidget et un QSpinBox pour faciliter la saisie d 'un angle d'orientation pour un texte. |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/qet Archives
]
- To: qet@xxxxxxxxxxxxxxxxxxx
- Subject: [qet] [848] Introduction de la classe QTextOrientationSPinBoxWidget, qui regroupe un QTextOrientationWidget et un QSpinBox pour faciliter la saisie d 'un angle d'orientation pour un texte.
- From: subversion@xxxxxxxxxxxxx
- Date: Tue, 09 Feb 2010 20:29:55 +0100
Revision: 848
Author: xavier
Date: 2010-02-09 20:29:55 +0100 (Tue, 09 Feb 2010)
Log Message:
-----------
Introduction de la classe QTextOrientationSPinBoxWidget, qui regroupe un QTextOrientationWidget et un QSpinBox pour faciliter la saisie d'un angle d'orientation pour un texte.
Modified Paths:
--------------
branches/0.3/sources/editor/textfieldeditor.cpp
branches/0.3/sources/editor/textfieldeditor.h
branches/0.3/sources/qetapp.cpp
branches/0.3/sources/qetapp.h
Added Paths:
-----------
branches/0.3/sources/qtextorientationspinboxwidget.cpp
branches/0.3/sources/qtextorientationspinboxwidget.h
Modified: branches/0.3/sources/editor/textfieldeditor.cpp
===================================================================
--- branches/0.3/sources/editor/textfieldeditor.cpp 2010-02-07 20:02:53 UTC (rev 847)
+++ branches/0.3/sources/editor/textfieldeditor.cpp 2010-02-09 19:29:55 UTC (rev 848)
@@ -17,7 +17,7 @@
*/
#include "textfieldeditor.h"
#include "parttextfield.h"
-#include "qtextorientationwidget.h"
+#include "qtextorientationspinboxwidget.h"
#include "qetapp.h"
/**
Constructeur
@@ -35,22 +35,9 @@
font_size -> setRange(0, 144);
rotate = new QCheckBox(tr("Ne pas subir les rotations de l'\351l\351ment parent"));
rotate -> setChecked(true);
- rotation_angle_ = new QDoubleSpinBox();
- rotation_angle_ -> setRange(-360.0, 360.0);
- rotation_angle_ -> setSuffix("\260");
- rotation_widget_ = new QTextOrientationWidget();
- rotation_widget_ -> setFont(QETApp::diagramTextsFont());
- rotation_widget_ -> setUsableTexts(QList<QString>()
- << tr("Q", "Single-letter example text - translate length, not meaning")
- << tr("QET", "Small example text - translate length, not meaning")
- << tr("Schema", "Normal example text - translate length, not meaning")
- << tr("Electrique", "Normal example text - translate length, not meaning")
- << tr("QElectroTech", "Long example text - translate length, not meaning")
- );
- rotation_widget_ -> setMinimumSize(90.0, 90.0);
- connect(rotation_angle_, SIGNAL(valueChanged(double)), rotation_widget_, SLOT(setOrientation(double)));
- connect(rotation_widget_, SIGNAL(orientationChanged(double)), rotation_angle_, SLOT(setValue(double)));
- connect(rotation_widget_, SIGNAL(orientationChanged(double)), rotation_angle_, SIGNAL(editingFinished()));
+ QLabel *rotation_angle_label = new QLabel(tr("Angle de rotation par d\351faut : "));
+ rotation_angle_label -> setWordWrap(true);
+ rotation_angle_ = QETApp::createTextOrientationSpinBoxWidget();
qle_x -> setValidator(new QDoubleValidator(qle_x));
qle_y -> setValidator(new QDoubleValidator(qle_y));
@@ -76,8 +63,7 @@
main_layout -> addLayout(t);
QHBoxLayout *rotation_angle_layout = new QHBoxLayout();
- rotation_angle_layout -> addWidget(new QLabel(tr("Angle de rotation par d\351faut : ")));
- rotation_angle_layout -> addWidget(rotation_widget_);
+ rotation_angle_layout -> addWidget(rotation_angle_label);
rotation_angle_layout -> addWidget(rotation_angle_);
main_layout -> addLayout(rotation_angle_layout);
@@ -128,7 +114,6 @@
font_size -> setValue(part -> property("size").toInt());
rotate -> setChecked(!part -> property("rotate").toBool());
rotation_angle_ -> setValue(part -> property("rotation angle").toDouble());
- rotation_widget_ -> setOrientation(part -> property("rotation angle").toDouble());
activeConnections(true);
}
Modified: branches/0.3/sources/editor/textfieldeditor.h
===================================================================
--- branches/0.3/sources/editor/textfieldeditor.h 2010-02-07 20:02:53 UTC (rev 847)
+++ branches/0.3/sources/editor/textfieldeditor.h 2010-02-09 19:29:55 UTC (rev 848)
@@ -20,7 +20,7 @@
#include <QtGui>
#include "elementitemeditor.h"
class PartTextField;
-class QTextOrientationWidget;
+class QTextOrientationSpinBoxWidget;
/**
Cette classe represente un editeur de champ de texte
Elle permet d'editer a travers une interface graphique les
@@ -42,8 +42,7 @@
QLineEdit *qle_x, *qle_y, *qle_text;
QSpinBox *font_size;
QCheckBox *rotate;
- QDoubleSpinBox *rotation_angle_;
- QTextOrientationWidget *rotation_widget_;
+ QTextOrientationSpinBoxWidget *rotation_angle_;
// methodes
public slots:
Modified: branches/0.3/sources/qetapp.cpp
===================================================================
--- branches/0.3/sources/qetapp.cpp 2010-02-07 20:02:53 UTC (rev 847)
+++ branches/0.3/sources/qetapp.cpp 2010-02-09 19:29:55 UTC (rev 848)
@@ -23,6 +23,7 @@
#include "elementscollectionitem.h"
#include "fileelementscollection.h"
#include "qetproject.h"
+#include "qtextorientationspinboxwidget.h"
#include "recentfiles.h"
#include "qeticons.h"
#include <cstdlib>
@@ -505,6 +506,28 @@
}
/**
+ Instancie un QTextOrientationSpinBoxWidget et configure :
+ * sa police de caracteres
+ * ses chaines de caracteres
+ A noter que la suppression du widget ainsi alloue est a la charge de
+ l'appelant.
+ @return un QTextOrientationSpinBoxWidget adapte pour une utilisation
+ "directe" dans QET.
+ @see QTextOrientationSpinBoxWidget
+*/
+QTextOrientationSpinBoxWidget *QETApp::createTextOrientationSpinBoxWidget() {
+ QTextOrientationSpinBoxWidget *widget = new QTextOrientationSpinBoxWidget();
+ widget -> orientationWidget() -> setFont(QETApp::diagramTextsFont());
+ widget -> orientationWidget() -> setUsableTexts(QList<QString>()
+ << QETApp::tr("Q", "Single-letter example text - translate length, not meaning")
+ << QETApp::tr("QET", "Small example text - translate length, not meaning")
+ << QETApp::tr("Schema", "Normal example text - translate length, not meaning")
+ << QETApp::tr("Electrique", "Normal example text - translate length, not meaning")
+ << QETApp::tr("QElectroTech", "Long example text - translate length, not meaning")
+ );
+ return(widget);
+}
+/**
@param project un projet
@return les editeurs d'elements editant un element appartenant au projet
project
Modified: branches/0.3/sources/qetapp.h
===================================================================
--- branches/0.3/sources/qetapp.h 2010-02-07 20:02:53 UTC (rev 847)
+++ branches/0.3/sources/qetapp.h 2010-02-09 19:29:55 UTC (rev 848)
@@ -31,6 +31,7 @@
class ElementsCategory;
class ElementDefinition;
class QETProject;
+class QTextOrientationSpinBoxWidget;
class RecentFiles;
/**
Cette classe represente l'application QElectroTech.
@@ -96,6 +97,7 @@
static QList<QETDiagramEditor *> diagramEditors();
static QList<QETElementEditor *> elementEditors();
static QList<QETElementEditor *> elementEditors(QETProject *);
+ static QTextOrientationSpinBoxWidget *createTextOrientationSpinBoxWidget();
protected:
#ifdef Q_OS_DARWIN
Added: branches/0.3/sources/qtextorientationspinboxwidget.cpp
===================================================================
--- branches/0.3/sources/qtextorientationspinboxwidget.cpp (rev 0)
+++ branches/0.3/sources/qtextorientationspinboxwidget.cpp 2010-02-09 19:29:55 UTC (rev 848)
@@ -0,0 +1,116 @@
+#include "qtextorientationspinboxwidget.h"
+
+/**
+ Constructeur
+ @param parent QWidget parent de ce QTextOrientationSpinBoxWidget
+*/
+QTextOrientationSpinBoxWidget::QTextOrientationSpinBoxWidget(QWidget *parent) :
+ QWidget(parent)
+{
+ build();
+}
+
+/**
+ Destructeur
+*/
+QTextOrientationSpinBoxWidget::~QTextOrientationSpinBoxWidget() {
+}
+
+/**
+ @return un pointeur vers le QTextOrientationWidget
+*/
+QTextOrientationWidget *QTextOrientationSpinBoxWidget::orientationWidget() const {
+ return(orientation_widget_);
+}
+
+/**
+ @return un pointeur vers le QSpinBox
+*/
+QDoubleSpinBox *QTextOrientationSpinBoxWidget::spinBox() const {
+ return(spin_box_);
+}
+
+/**
+ @return l'orientation en cours
+*/
+double QTextOrientationSpinBoxWidget::orientation() const {
+ return(orientation_widget_ -> orientation());
+}
+
+/**
+ Synonyme pour orientation()
+ @return l'orientation en cours
+ @see orientation()
+*/
+double QTextOrientationSpinBoxWidget::value() const {
+ return(orientation());
+}
+
+/**
+ @return true si le widget est en mode "lecture seule", false sinon
+*/
+bool QTextOrientationSpinBoxWidget::isReadOnly() const {
+ return(orientation_widget_ -> isReadOnly());
+}
+
+/**
+ @param value Nouvelle valeur de l'orientation a afficher
+*/
+void QTextOrientationSpinBoxWidget::setOrientation(const double &value) {
+ orientation_widget_ -> setOrientation(value);
+ spin_box_ -> setValue(value);
+}
+
+/**
+ Synonyme pour setOrientation(value)
+ @param value Nouvelle valeur de l'orientation a afficher
+ @see setOrientation
+*/
+void QTextOrientationSpinBoxWidget::setValue(const double &value) {
+ setOrientation(value);
+}
+
+/**
+ @param ro true pour passer le widget en mode "lecture seule", false sinon
+*/
+void QTextOrientationSpinBoxWidget::setReadOnly(bool ro) {
+ orientation_widget_ -> setReadOnly(ro);
+ spin_box_ -> setReadOnly(ro);
+}
+
+/**
+ Construit le widget
+*/
+void QTextOrientationSpinBoxWidget::build() {
+ orientation_widget_ = new QTextOrientationWidget();
+ orientation_widget_ -> setMinimumSize(90.0, 90.0);
+
+ spin_box_ = new QDoubleSpinBox();
+ spin_box_ -> setRange(-360.0, 360.0);
+ spin_box_ -> setSuffix("\260");
+
+ // met en place les relations entre le SpinBox et le QTextOrientationWidget
+ connect(spin_box_, SIGNAL(valueChanged(double)), orientation_widget_, SLOT(setOrientation(double)));
+ connect(orientation_widget_, SIGNAL(orientationChanged(double)), spin_box_, SLOT(setValue(double)));
+
+ // cliquer sur un des carres du QTextOrientationWidget revient a finir une saisie dans le SpinBox
+ connect(orientation_widget_, SIGNAL(orientationChanged(double)), spin_box_, SIGNAL(editingFinished()));
+
+ // lorsque l'utilisateur a change l'orientation, on emet un signal avec la valeur de la nouvelle orientation
+ connect(spin_box_, SIGNAL(editingFinished()), this, SLOT(emitChangeSignals()));
+
+ // dispose les widgets : le QTextOrientationWidget a gauche, le SpinBox a droite
+ QHBoxLayout *main_layout = new QHBoxLayout();
+ main_layout -> addWidget(orientation_widget_);
+ main_layout -> addWidget(spin_box_);
+ setLayout(main_layout);
+}
+
+
+/**
+ Emet le signal orientationEditingFinished avec la valeur de l'orientation en cours
+*/
+void QTextOrientationSpinBoxWidget::emitChangeSignals() {
+ emit(editingFinished(orientation()));
+ emit(editingFinished());
+}
Added: branches/0.3/sources/qtextorientationspinboxwidget.h
===================================================================
--- branches/0.3/sources/qtextorientationspinboxwidget.h (rev 0)
+++ branches/0.3/sources/qtextorientationspinboxwidget.h 2010-02-09 19:29:55 UTC (rev 848)
@@ -0,0 +1,69 @@
+/*
+ Copyright 2006-2010 Xavier Guerrin
+ This file is part of QElectroTech.
+
+ QElectroTech is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 2 of the License, or
+ (at your option) any later version.
+
+ QElectroTech is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
+*/
+#ifndef Q_TEXT_ORIENTATION_SPINBOX_WIDGET_H
+#define Q_TEXT_ORIENTATION_SPINBOX_WIDGET_H
+#include <QtGui>
+#include "qtextorientationwidget.h"
+/**
+ Cette classe est un widget regroupant cote a cote un QTextOrientationWidget
+ et un QSpinBox.
+ @see QTextOrientationWidget
+*/
+class QTextOrientationSpinBoxWidget : public QWidget {
+ Q_OBJECT
+
+ // constructeurs, destructeur
+ public:
+ QTextOrientationSpinBoxWidget(QWidget * = 0);
+ virtual ~QTextOrientationSpinBoxWidget();
+ private:
+ QTextOrientationSpinBoxWidget(const QTextOrientationSpinBoxWidget &);
+
+ // signaux
+ signals:
+ /**
+ Signaux emis lorsque l'utilisateur a fini d'editer l'orientation
+ */
+ void editingFinished(double);
+ void editingFinished();
+
+ // methodes
+ public:
+ QTextOrientationWidget *orientationWidget() const;
+ QDoubleSpinBox *spinBox() const;
+ double orientation() const;
+ double value() const;
+ bool isReadOnly() const;
+
+ public slots:
+ void setOrientation(const double &);
+ void setValue(const double &);
+ void setReadOnly(bool);
+
+ private:
+ void build();
+
+ private slots:
+ void emitChangeSignals();
+
+ // attributs
+ private:
+ QTextOrientationWidget *orientation_widget_;
+ QDoubleSpinBox *spin_box_;
+};
+#endif