Warning, file /office/calligra/libs/widgets/KoUnitDoubleSpinBox.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* This file is part of the KDE project 0002 Copyright (C) 2002, Rob Buis(buis@kde.org) 0003 Copyright (C) 2004, Nicolas GOUTTE <goutte@kde.org> 0004 Copyright (C) 2007, Thomas Zander <zander@kde.org> 0005 0006 This library is free software; you can redistribute it and/or 0007 modify it under the terms of the GNU Library General Public 0008 License as published by the Free Software Foundation; either 0009 version 2 of the License, or (at your option) any later version. 0010 0011 This library is distributed in the hope that it will be useful, 0012 but WITHOUT ANY WARRANTY; without even the implied warranty of 0013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0014 Library General Public License for more details. 0015 0016 You should have received a copy of the GNU Library General Public License 0017 along with this library; see the file COPYING.LIB. If not, write to 0018 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0019 * Boston, MA 02110-1301, USA. 0020 */ 0021 0022 #ifndef KOUNITDOUBLESPINBOX_H 0023 #define KOUNITDOUBLESPINBOX_H 0024 0025 #include "kowidgets_export.h" 0026 0027 #include <QDoubleSpinBox> 0028 0029 class KoUnit; 0030 0031 /** 0032 * Spin box for double precision numbers with unit display. 0033 * Use this widget for any value that represents a real measurable value for consistency throughout 0034 * Calligra. 0035 * This widget shows the value in the user-selected units (inch, millimeters, etc) but keeps the 0036 * calligra-widget default measurement unit internally. This has the advantage that just setting and 0037 * getting a value will not change the value due to conversions. 0038 * The KoDocument class has a unit() method for consistent (document wide) configuration of the 0039 * used unit. 0040 * It is advised to use a QDoubleSpinBox in QtDesigner and then use the context-menu item: 'Promote to Custom Widget' and use the values: 'classname=KoUnitDoubleSpinBox', 'headerfile=KoUnitDoubleSpinBox.h' 0041 * This will generate code that uses this spinbox in the correct manner. 0042 */ 0043 class KOWIDGETS_EXPORT KoUnitDoubleSpinBox : public QDoubleSpinBox 0044 { 0045 Q_OBJECT 0046 public: 0047 /** 0048 * Constructor 0049 * Create a new spinBox with very broad range predefined. 0050 * This spinbox will have min and max borders of 10000 points and use 0051 * the default unit of points. 0052 * @param parent the parent widget 0053 */ 0054 explicit KoUnitDoubleSpinBox( QWidget *parent = 0); 0055 ~KoUnitDoubleSpinBox() override; 0056 0057 /** 0058 * Set the new value in points which will then be converted to the current unit for display 0059 * @param newValue the new value 0060 * @see value() 0061 */ 0062 virtual void changeValue( double newValue ); 0063 /** 0064 * This spinbox shows the internal value after a conversion to the unit set here. 0065 */ 0066 virtual void setUnit( const KoUnit &); 0067 0068 /// @return the current value, converted in points 0069 double value( ) const; 0070 0071 /// Set minimum value in points. 0072 void setMinimum(double min); 0073 0074 /// Set maximum value in points. 0075 void setMaximum(double max); 0076 0077 /// Set step size in the current unit. 0078 void setLineStep(double step); 0079 0080 /// Set step size in points. 0081 void setLineStepPt(double step); 0082 0083 /// Set minimum, maximum value and the step size (all in points) 0084 void setMinMaxStep( double min, double max, double step ); 0085 0086 /// reimplemented from superclass, will forward to KoUnitDoubleValidator 0087 QValidator::State validate(QString &input, int &pos) const override; 0088 0089 /** 0090 * Transform the double in a nice text, using locale symbols 0091 * @param value the number as double 0092 * @return the resulting string 0093 */ 0094 QString textFromValue( double value ) const override; 0095 /** 0096 * Transform a string into a double, while taking care of locale specific symbols. 0097 * @param str the string to transform into a number 0098 * @return the value as double 0099 */ 0100 double valueFromText( const QString& str ) const override; 0101 0102 0103 Q_SIGNALS: 0104 /// emitted like valueChanged in the parent, but this one emits the point value 0105 void valueChangedPt( qreal ); 0106 0107 private: 0108 class Private; 0109 Private * const d; 0110 0111 private Q_SLOTS: 0112 // exists to do emits for valueChangedPt 0113 void privateValueChanged(); 0114 }; 0115 0116 #endif 0117