diff options
author | Marius Storm-Olsen <marius.storm-olsen@nokia.com> | 2009-11-06 10:37:33 (GMT) |
---|---|---|
committer | Marius Storm-Olsen <marius.storm-olsen@nokia.com> | 2009-11-09 11:10:33 (GMT) |
commit | 9e0c2d6f00cb1195bf7bc1eae34a6f8f9b43191f (patch) | |
tree | 2f24f0f0243ca547e942d8b641057e8b1cfeea22 /src | |
parent | 8d4f3c94411d21f0b7d851b56f951ad54d64340f (diff) | |
download | Qt-9e0c2d6f00cb1195bf7bc1eae34a6f8f9b43191f.zip Qt-9e0c2d6f00cb1195bf7bc1eae34a6f8f9b43191f.tar.gz Qt-9e0c2d6f00cb1195bf7bc1eae34a6f8f9b43191f.tar.bz2 |
API review: Rename numDigits() and setNumDigits()
QLCDNumber doesn't follow the API convention of *Count and set*Count().
Introduce properly named functions, and obsolete the old ones.
Reviewed-by: Andreas Aardal Hanssen
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/widgets/qlcdnumber.cpp | 41 | ||||
-rw-r--r-- | src/gui/widgets/qlcdnumber.h | 7 | ||||
-rw-r--r-- | src/plugins/accessible/widgets/simplewidgets.cpp | 2 |
3 files changed, 36 insertions, 14 deletions
diff --git a/src/gui/widgets/qlcdnumber.cpp b/src/gui/widgets/qlcdnumber.cpp index 9f9e353..f33a98f 100644 --- a/src/gui/widgets/qlcdnumber.cpp +++ b/src/gui/widgets/qlcdnumber.cpp @@ -85,7 +85,7 @@ public: decimal point with setSmallDecimalPoint(). QLCDNumber emits the overflow() signal when it is asked to display - something beyond its range. The range is set by setNumDigits(), + something beyond its range. The range is set by setDigitCount(), but setSmallDecimalPoint() also influences it. If the display is set to hexadecimal, octal or binary, the integer equivalent of the value is displayed. @@ -160,7 +160,7 @@ public: This signal is emitted whenever the QLCDNumber is asked to display a too-large number or a too-long string. - It is never emitted by setNumDigits(). + It is never emitted by setDigitCount(). */ @@ -345,7 +345,7 @@ static const char *getSegments(char ch) // gets list of segments f The \a parent and \a name arguments are passed to the QFrame constructor. - \sa setNumDigits(), setSmallDecimalPoint() + \sa setDigitCount(), setSmallDecimalPoint() */ QLCDNumber::QLCDNumber(QWidget *parent, const char *name) @@ -367,7 +367,7 @@ QLCDNumber::QLCDNumber(QWidget *parent, const char *name) The \a parent and \a name arguments are passed to the QFrame constructor. - \sa setNumDigits(), setSmallDecimalPoint() + \sa setDigitCount(), setSmallDecimalPoint() */ QLCDNumber::QLCDNumber(uint numDigits, QWidget *parent, const char *name) @@ -387,7 +387,7 @@ QLCDNumber::QLCDNumber(uint numDigits, QWidget *parent, const char *name) The \a parent argument is passed to the QFrame constructor. - \sa setNumDigits(), setSmallDecimalPoint() + \sa setDigitCount(), setSmallDecimalPoint() */ QLCDNumber::QLCDNumber(QWidget *parent) @@ -407,7 +407,7 @@ QLCDNumber::QLCDNumber(QWidget *parent) The \a parent argument is passed to the QFrame constructor. - \sa setNumDigits(), setSmallDecimalPoint() + \sa setDigitCount(), setSmallDecimalPoint() */ QLCDNumber::QLCDNumber(uint numDigits, QWidget *parent) @@ -426,7 +426,7 @@ void QLCDNumberPrivate::init() val = 0; base = QLCDNumber::Dec; smallPoint = false; - q->setNumDigits(ndigits); + q->setDigitCount(ndigits); q->setSegmentStyle(QLCDNumber::Filled); q->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum)); } @@ -441,8 +441,21 @@ QLCDNumber::~QLCDNumber() /*! + \obsolete \property QLCDNumber::numDigits \brief the current number of digits displayed + \sa setDigitCount +*/ + +void QLCDNumber::setNumDigits(int numDigits) +{ + setDigitCount(numDigits); +} + +/*! + \since 4.6 + \property QLCDNumber::digitCount + \brief the current number of digits displayed Corresponds to the current number of digits. If \l QLCDNumber::smallDecimalPoint is false, the decimal point occupies @@ -453,7 +466,7 @@ QLCDNumber::~QLCDNumber() \sa smallDecimalPoint */ -void QLCDNumber::setNumDigits(int numDigits) +void QLCDNumber::setDigitCount(int numDigits) { Q_D(QLCDNumber); if (numDigits > 99) { @@ -508,13 +521,19 @@ int QLCDNumber::numDigits() const return d->ndigits; } +int QLCDNumber::digitCount() const +{ + Q_D(const QLCDNumber); + return d->ndigits; +} + /*! \overload Returns true if \a num is too big to be displayed in its entirety; otherwise returns false. - \sa display(), numDigits(), smallDecimalPoint() + \sa display(), digitCount(), smallDecimalPoint() */ bool QLCDNumber::checkOverflow(int num) const @@ -530,7 +549,7 @@ bool QLCDNumber::checkOverflow(int num) const Returns true if \a num is too big to be displayed in its entirety; otherwise returns false. - \sa display(), numDigits(), smallDecimalPoint() + \sa display(), digitCount(), smallDecimalPoint() */ bool QLCDNumber::checkOverflow(double num) const @@ -1256,7 +1275,7 @@ QLCDNumber::SegmentStyle QLCDNumber::segmentStyle() const */ QSize QLCDNumber::sizeHint() const { - return QSize(10 + 9 * (numDigits() + (smallDecimalPoint() ? 0 : 1)), 23); + return QSize(10 + 9 * (digitCount() + (smallDecimalPoint() ? 0 : 1)), 23); } /*! \reimp */ diff --git a/src/gui/widgets/qlcdnumber.h b/src/gui/widgets/qlcdnumber.h index 9753f31..e65637d 100644 --- a/src/gui/widgets/qlcdnumber.h +++ b/src/gui/widgets/qlcdnumber.h @@ -60,6 +60,7 @@ class Q_GUI_EXPORT QLCDNumber : public QFrame // LCD number widget Q_ENUMS(Mode SegmentStyle) Q_PROPERTY(bool smallDecimalPoint READ smallDecimalPoint WRITE setSmallDecimalPoint) Q_PROPERTY(int numDigits READ numDigits WRITE setNumDigits) + Q_PROPERTY(int digitCount READ digitCount WRITE setDigitCount) Q_PROPERTY(Mode mode READ mode WRITE setMode) Q_PROPERTY(SegmentStyle segmentStyle READ segmentStyle WRITE setSegmentStyle) Q_PROPERTY(double value READ value WRITE display) @@ -82,8 +83,10 @@ public: bool smallDecimalPoint() const; - int numDigits() const; - void setNumDigits(int nDigits); + QT_DEPRECATED int numDigits() const; + QT_DEPRECATED void setNumDigits(int nDigits); + int digitCount() const; + void setDigitCount(int nDigits); bool checkOverflow(double num) const; bool checkOverflow(int num) const; diff --git a/src/plugins/accessible/widgets/simplewidgets.cpp b/src/plugins/accessible/widgets/simplewidgets.cpp index 1d801e4..014d487 100644 --- a/src/plugins/accessible/widgets/simplewidgets.cpp +++ b/src/plugins/accessible/widgets/simplewidgets.cpp @@ -528,7 +528,7 @@ QString QAccessibleDisplay::text(Text t, int child) const #ifndef QT_NO_LCDNUMBER } else if (qobject_cast<QLCDNumber*>(object())) { QLCDNumber *l = qobject_cast<QLCDNumber*>(object()); - if (l->numDigits()) + if (l->digitCount()) str = QString::number(l->value()); else str = QString::number(l->intValue()); |