-rw-r--r-- | noncore/settings/networksettings/ppp/general.cpp | 53 | ||||
-rw-r--r-- | noncore/settings/networksettings/ppp/general.h | 26 | ||||
-rw-r--r-- | noncore/settings/networksettings/ppp/knuminput.cpp | 1103 | ||||
-rw-r--r-- | noncore/settings/networksettings/ppp/knuminput.h | 947 | ||||
-rw-r--r-- | noncore/settings/networksettings/ppp/knumvalidator.cpp | 376 | ||||
-rw-r--r-- | noncore/settings/networksettings/ppp/knumvalidator.h | 211 | ||||
-rw-r--r-- | noncore/settings/networksettings/ppp/ppp.pro | 6 |
7 files changed, 51 insertions, 2671 deletions
diff --git a/noncore/settings/networksettings/ppp/general.cpp b/noncore/settings/networksettings/ppp/general.cpp index a02ee35..98e035b 100644 --- a/noncore/settings/networksettings/ppp/general.cpp +++ b/noncore/settings/networksettings/ppp/general.cpp @@ -26,11 +26,18 @@ #include <termios.h> #include <string.h> -#include <qwhatsthis.h> -#include "knuminput.h" -#include <qslider.h> +#include <qcheckbox.h> +#include <qcombobox.h> +#include <qlabel.h> #include <qlayout.h> +#include <qpushbutton.h> +#include <qslider.h> +#include <qspinbox.h> +#include <qwhatsthis.h> + +// #include <qgroupbox.h> + #include "general.h" //#include "version.h" //#include "miniterm.h" @@ -50,6 +57,7 @@ ModemWidget::ModemWidget( QWidget *parent, const char *name) QGridLayout *tl = new QGridLayout(this, 8, 2, 0 );//, KDialog::spacingHint()); + QLabel *label1; label1 = new QLabel(i18n("Modem de&vice:"), this); tl->addWidget(label1, 0, 0); @@ -74,11 +82,11 @@ ModemWidget::ModemWidget( QWidget *parent, const char *name) QWhatsThis::add(modemdevice,tmp); - label2 = new QLabel(i18n("&Flow control:"), this); - tl->addWidget(label2, 1, 0); + label1 = new QLabel(i18n("&Flow control:"), this); + tl->addWidget(label1, 1, 0); flowcontrol = new QComboBox(false, this); - label2->setBuddy(flowcontrol); + label1->setBuddy(flowcontrol); flowcontrol->insertItem(i18n("Hardware [CRTSCTS]")); flowcontrol->insertItem(i18n("Software [XON/XOFF]")); flowcontrol->insertItem(i18n("None")); @@ -92,10 +100,10 @@ ModemWidget::ModemWidget( QWidget *parent, const char *name) "\n" "<b>Default</b>: CRTSCTS"); - QWhatsThis::add(label2,tmp); + QWhatsThis::add(label1,tmp); QWhatsThis::add(flowcontrol,tmp); - labelenter = new QLabel(i18n("&Line termination:"), this); + QLabel *labelenter = new QLabel(i18n("&Line termination:"), this); tl->addWidget(labelenter, 2, 0); enter = new QComboBox(false, this); @@ -116,7 +124,7 @@ ModemWidget::ModemWidget( QWidget *parent, const char *name) QWhatsThis::add(labelenter,tmp); QWhatsThis::add(enter, tmp); - baud_label = new QLabel(i18n("Co&nnection speed:"), this); + QLabel *baud_label = new QLabel(i18n("Co&nnection speed:"), this); tl->addWidget(baud_label, 3, 0); baud_c = new QComboBox(this); baud_label->setBuddy(baud_c); @@ -190,14 +198,18 @@ ModemWidget::ModemWidget( QWidget *parent, const char *name) "<b>Default</b>: On")); // Modem Timeout Line Edit Box - - modemtimeout = new KIntNumInput(PPPData::data()->modemTimeout(), this); - modemtimeout->setLabel(i18n("Modem &timeout:")); - modemtimeout->setRange(1, 120, 1); + QHBoxLayout *timeoutLayout = new QHBoxLayout( this ); + QLabel *timeoutlabel = new QLabel( tr("Modem timeout:") ,this, "timeout" ); + modemtimeout = new QSpinBox( 1, 120, 1, this, "modemTimeout" ); +// modemtimeout = new KIntNumInput(PPPData::data()->modemTimeout(), this); +// modemtimeout->setLabel(i18n("Modem &timeout:")); +// modemtimeout->setRange(1, 120, 1); modemtimeout->setSuffix(i18n(" sec")); connect(modemtimeout, SIGNAL(valueChanged(int)), SLOT(modemtimeoutchanged(int))); - tl->addMultiCellWidget(modemtimeout, 6, 6, 0, 1); + timeoutLayout->addWidget(timeoutlabel); + timeoutLayout->addWidget(modemtimeout); + tl->addMultiCellLayout(timeoutLayout, 6, 6, 0, 1); QWhatsThis::add(modemtimeout, i18n("This specifies how long <i>kppp</i> waits for a\n" @@ -278,12 +290,17 @@ ModemWidget2::ModemWidget2( QWidget *parent, const char *name) "\n" "<b>Default:</b>: On")); - busywait = new KIntNumInput(PPPData::data()->busyWait(), this); - busywait->setLabel(i18n("B&usy wait:")); - busywait->setRange(0, 300, 5, true); + QHBoxLayout *waitLayout = new QHBoxLayout( this ); + QLabel *waitLabel = new QLabel( tr("Busy wait:"), this, "busyWait" ); + busywait = new QSpinBox( 0, 300, 5, this, "busyWait" ); +// busywait = new KIntNumInput(PPPData::data()->busyWait(), this); +// busywait->setLabel(i18n("B&usy wait:")); +// busywait->setRange(0, 300, 5, true); busywait->setSuffix(i18n(" sec")); connect(busywait, SIGNAL(valueChanged(int)), SLOT(busywaitchanged(int))); - l1->addWidget(busywait); + waitLayout->addWidget(waitLabel); + waitLayout->addWidget(busywait); + l1->addLayout( waitLayout ); QWhatsThis::add(busywait, i18n("Specifies the number of seconds to wait before\n" diff --git a/noncore/settings/networksettings/ppp/general.h b/noncore/settings/networksettings/ppp/general.h index 66a9eec..4869f6c 100644 --- a/noncore/settings/networksettings/ppp/general.h +++ b/noncore/settings/networksettings/ppp/general.h @@ -27,15 +27,13 @@ #define _GENERAL_H_ #include <qwidget.h> -#include <qcombobox.h> -#include <qlabel.h> -#include <qcheckbox.h> -#include <qgroupbox.h> -#include <qpushbutton.h> -//#include <kcolorbutton.h> class QSlider; -class KIntNumInput; +class QSpinBox; +class QCombobox; +class QLabel; +class QCheckBox; +class QComboBox; @@ -54,17 +52,17 @@ private slots: private: QComboBox *enter; - QLabel *label1; - QLabel *label2; - QLabel *labeltmp; - QLabel *labelenter; +/* QLabel *label1; */ +/* QLabel *label2; */ +/* QLabel *labeltmp; */ +/* QLabel *labelenter; */ QComboBox *modemdevice; QComboBox *flowcontrol; QComboBox *baud_c; QLabel *baud_label; - KIntNumInput *modemtimeout; + QSpinBox *modemtimeout; QCheckBox *modemlockfile; }; @@ -88,9 +86,9 @@ private: QPushButton *modemcmds; QPushButton *modeminfo_button; // QPushButton *terminal_button; - QFrame *fline; + // QFrame *fline; QCheckBox *waitfordt; - KIntNumInput *busywait; + QSpinBox *busywait; QCheckBox *chkbox1; QSlider *volume; }; diff --git a/noncore/settings/networksettings/ppp/knuminput.cpp b/noncore/settings/networksettings/ppp/knuminput.cpp deleted file mode 100644 index afaa581..0000000 --- a/noncore/settings/networksettings/ppp/knuminput.cpp +++ b/dev/null @@ -1,1103 +0,0 @@ -// -*- c-basic-offset: 4 -*- -/* - * knuminput.cpp - * - * Initial implementation: - * Copyright (c) 1997 Patrick Dowler <dowler@morgul.fsh.uvic.ca> - * Rewritten and maintained by: - * Copyright (c) 2000 Dirk A. Mueller <mueller@kde.org> - * KDoubleSpinBox: - * Copyright (c) 2002 Marc Mutz <mutz@kde.org> - * - * Requires the Qt widget libraries, available at no cost at - * http://www.troll.no/ - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -//#include <config.h> -#ifdef HAVE_LIMITS_H -#include <limits.h> -#endif -#include <assert.h> -#include <math.h> -#include <algorithm> - -#include <qlabel.h> -#include <qlineedit.h> -#include <qsize.h> -#include <qslider.h> -#include <qspinbox.h> -#include <qstyle.h> - -//#include <kglobal.h> - -template<class T> -inline const T& kMin (const T& a, const T& b) { return a < b ? a : b; } - -template<class T> -inline const T& kMax (const T& a, const T& b) { return b < a ? a : b; } - -//#include <klocale.h> -#define i18n QObject::tr -//#include <kdebug.h> - -#include "knumvalidator.h" -#include "knuminput.h" - -static inline int calcDiffByTen( int x, int y ) { - // calculate ( x - y ) / 10 without overflowing ints: - return ( x / 10 ) - ( y / 10 ) + ( x % 10 - y % 10 ) / 10; -}; - -// ---------------------------------------------------------------------------- - -KNumInput::KNumInput(QWidget* parent, const char* name) - : QWidget(parent, name) -{ - init(); -} - -KNumInput::KNumInput(KNumInput* below, QWidget* parent, const char* name) - : QWidget(parent, name) -{ - init(); - - if(below) { - m_next = below->m_next; - m_prev = below; - below->m_next = this; - if(m_next) - m_next->m_prev = this; - } -} - -void KNumInput::init() -{ - m_prev = m_next = 0; - m_colw1 = m_colw2 = 0; - - m_label = 0; - m_slider = 0; - m_alignment = 0; -} - -KNumInput::~KNumInput() -{ - if(m_prev) - m_prev->m_next = m_next; - - if(m_next) - m_next->m_prev = m_prev; -} - -void KNumInput::setLabel(const QString & label, int a) -{ - if(label.isEmpty()) { - delete m_label; - m_label = 0; - m_alignment = 0; - } - else { - if (m_label) m_label->setText(label); - else m_label = new QLabel(label, this, "KNumInput::QLabel"); - m_label->setAlignment((a & (~(AlignTop|AlignBottom|AlignVCenter))) - | AlignVCenter); - // if no vertical alignment set, use Top alignment - if(!(a & (AlignTop|AlignBottom|AlignVCenter))) - a |= AlignTop; - m_alignment = a; - } - - layout(true); -} - -QString KNumInput::label() const -{ - if (m_label) return m_label->text(); - return QString::null; -} - -void KNumInput::layout(bool deep) -{ - int w1 = m_colw1; - int w2 = m_colw2; - - // label sizeHint - m_sizeLabel = (m_label ? m_label->sizeHint() : QSize(0,0)); - - if(m_label && (m_alignment & AlignVCenter)) - m_colw1 = m_sizeLabel.width() + 4; - else - m_colw1 = 0; - - // slider sizeHint - m_sizeSlider = (m_slider ? m_slider->sizeHint() : QSize(0, 0)); - - doLayout(); - - if(!deep) { - m_colw1 = w1; - m_colw2 = w2; - return; - } - - KNumInput* p = this; - while(p) { - p->doLayout(); - w1 = QMAX(w1, p->m_colw1); - w2 = QMAX(w2, p->m_colw2); - p = p->m_prev; - } - - p = m_next; - while(p) { - p->doLayout(); - w1 = QMAX(w1, p->m_colw1); - w2 = QMAX(w2, p->m_colw2); - p = p->m_next; - } - - p = this; - while(p) { - p->m_colw1 = w1; - p->m_colw2 = w2; - p = p->m_prev; - } - - p = m_next; - while(p) { - p->m_colw1 = w1; - p->m_colw2 = w2; - p = p->m_next; - } - -// kdDebug() << "w1 " << w1 << " w2 " << w2 << endl; -} - -QSizePolicy KNumInput::sizePolicy() const -{ - return QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Fixed ); -} - -QSize KNumInput::sizeHint() const -{ - return minimumSizeHint(); -} - -void KNumInput::setSteps(int minor, int major) -{ - if(m_slider) - m_slider->setSteps( minor, major ); -} - - -// ---------------------------------------------------------------------------- - -KIntSpinBox::KIntSpinBox(QWidget *parent, const char *name) - : QSpinBox(0, 99, 1, parent, name) -{ - editor()->setAlignment(AlignRight); - val_base = 10; - setValue(0); -} - -KIntSpinBox::~KIntSpinBox() -{ -} - -KIntSpinBox::KIntSpinBox(int lower, int upper, int step, int value, int base, - QWidget* parent, const char* name) - : QSpinBox(lower, upper, step, parent, name) -{ - editor()->setAlignment(AlignRight); - val_base = base; - setValue(value); -} - -void KIntSpinBox::setBase(int base) -{ - val_base = base; -} - - -int KIntSpinBox::base() const -{ - return val_base; -} - -QString KIntSpinBox::mapValueToText(int v) -{ - return QString::number(v, val_base); -} - -int KIntSpinBox::mapTextToValue(bool* ok) -{ - return cleanText().toInt(ok, val_base); -} - -void KIntSpinBox::setEditFocus(bool mark) -{ - editor()->setFocus(); - if(mark) - editor()->selectAll(); -} - - -// ---------------------------------------------------------------------------- - -class KIntNumInput::KIntNumInputPrivate { -public: - int referencePoint; - short blockRelative; - KIntNumInputPrivate( int r ) - : referencePoint( r ), - blockRelative( 0 ) {} -}; - - -KIntNumInput::KIntNumInput(KNumInput* below, int val, QWidget* parent, - int _base, const char* name) - : KNumInput(below, parent, name) -{ - init(val, _base); -} - -KIntNumInput::KIntNumInput(QWidget *parent, const char *name) - : KNumInput(parent, name) -{ - init(0, 10); -} - -KIntNumInput::KIntNumInput(int val, QWidget *parent, int _base, const char *name) - : KNumInput(parent, name) -{ - init(val, _base); - -} - -void KIntNumInput::init(int val, int _base) -{ - d = new KIntNumInputPrivate( val ); - m_spin = new KIntSpinBox(INT_MIN, INT_MAX, 1, val, _base, this, "KIntNumInput::KIntSpinBox"); - m_spin->setValidator(new KIntValidator(this, _base, "KNumInput::KIntValidtr")); - connect(m_spin, SIGNAL(valueChanged(int)), SLOT(spinValueChanged(int))); - connect(this, SIGNAL(valueChanged(int)), - SLOT(slotEmitRelativeValueChanged(int))); - - setFocusProxy(m_spin); - layout(true); -} - -void KIntNumInput::setReferencePoint( int ref ) { - // clip to valid range: - ref = kMin( maxValue(), kMax( minValue(), ref ) ); - d->referencePoint = ref; -} - -int KIntNumInput::referencePoint() const { - return d->referencePoint; -} - -void KIntNumInput::spinValueChanged(int val) -{ - if(m_slider) - m_slider->setValue(val); - - emit valueChanged(val); -} - -void KIntNumInput::slotEmitRelativeValueChanged( int value ) { - if ( d->blockRelative || !d->referencePoint ) return; - emit relativeValueChanged( double( value ) / double( d->referencePoint ) ); -} - -void KIntNumInput::setRange(int lower, int upper, int step, bool slider) -{ - upper = kMax(upper, lower); - lower = kMin(upper, lower); - m_spin->setMinValue(lower); - m_spin->setMaxValue(upper); - m_spin->setLineStep(step); - - step = m_spin->lineStep(); // maybe QRangeControl didn't like out lineStep? - - if(slider) { - if (m_slider) - m_slider->setRange(lower, upper); - else { - m_slider = new QSlider(lower, upper, step, m_spin->value(), - QSlider::Horizontal, this); - m_slider->setTickmarks(QSlider::Below); - connect(m_slider, SIGNAL(valueChanged(int)), - m_spin, SLOT(setValue(int))); - } - - // calculate (upper-lower)/10 without overflowing int's: - int major = calcDiffByTen( upper, lower ); - if ( major==0 ) major = step; // #### workaround Qt bug in 2.1-beta4 - - m_slider->setSteps(step, major); - m_slider->setTickInterval(major); - } - else { - delete m_slider; - m_slider = 0; - } - - // check that reference point is still inside valid range: - setReferencePoint( referencePoint() ); - - layout(true); -} - -void KIntNumInput::setMinValue(int min) -{ - setRange(min, m_spin->maxValue(), m_spin->lineStep(), m_slider); -} - -int KIntNumInput::minValue() const -{ - return m_spin->minValue(); -} - -void KIntNumInput::setMaxValue(int max) -{ - setRange(m_spin->minValue(), max, m_spin->lineStep(), m_slider); -} - -int KIntNumInput::maxValue() const -{ - return m_spin->maxValue(); -} - -void KIntNumInput::setSuffix(const QString &suffix) -{ - m_spin->setSuffix(suffix); - - layout(true); -} - -QString KIntNumInput::suffix() const -{ - return m_spin->suffix(); -} - -void KIntNumInput::setPrefix(const QString &prefix) -{ - m_spin->setPrefix(prefix); - - layout(true); -} - -QString KIntNumInput::prefix() const -{ - return m_spin->prefix(); -} - -void KIntNumInput::setEditFocus(bool mark) -{ - m_spin->setEditFocus(mark); -} - -QSize KIntNumInput::minimumSizeHint() const -{ - constPolish(); - - int w; - int h; - - h = 2 + QMAX(m_sizeSpin.height(), m_sizeSlider.height()); - - // if in extra row, then count it here - if(m_label && (m_alignment & (AlignBottom|AlignTop))) - h += 4 + m_sizeLabel.height(); - else - // label is in the same row as the other widgets - h = QMAX(h, m_sizeLabel.height() + 2); - - w = m_slider ? m_slider->sizeHint().width() + 8 : 0; - w += m_colw1 + m_colw2; - - if(m_alignment & (AlignTop|AlignBottom)) - w = QMAX(w, m_sizeLabel.width() + 4); - - return QSize(w, h); -} - -void KIntNumInput::doLayout() -{ - m_sizeSpin = m_spin->sizeHint(); - m_colw2 = m_sizeSpin.width(); - - if (m_label) - m_label->setBuddy(m_spin); -} - -void KIntNumInput::resizeEvent(QResizeEvent* e) -{ - int w = m_colw1; - int h = 0; - - if(m_label && (m_alignment & AlignTop)) { - m_label->setGeometry(0, 0, e->size().width(), m_sizeLabel.height()); - h += m_sizeLabel.height() + 4; - } - - if(m_label && (m_alignment & AlignVCenter)) - m_label->setGeometry(0, 0, w, m_sizeSpin.height()); - - m_spin->setGeometry(w, h, m_slider ? m_colw2 : QMAX(m_colw2, e->size().width() - w), m_sizeSpin.height()); - w += m_colw2 + 8; - - if(m_slider) - m_slider->setGeometry(w, h, e->size().width() - w, m_sizeSpin.height()); - - h += m_sizeSpin.height() + 2; - - if(m_label && (m_alignment & AlignBottom)) - m_label->setGeometry(0, h, m_sizeLabel.width(), m_sizeLabel.height()); -} - -KIntNumInput::~KIntNumInput() -{ - delete d; -} - -void KIntNumInput::setValue(int val) -{ - m_spin->setValue(val); - // slider value is changed by spinValueChanged -} - -void KIntNumInput::setRelativeValue( double r ) { - if ( !d->referencePoint ) return; - ++d->blockRelative; - setValue( int( d->referencePoint * r + 0.5 ) ); - --d->blockRelative; -} - -double KIntNumInput::relativeValue() const { - if ( !d->referencePoint ) return 0; - return double( value() ) / double ( d->referencePoint ); -} - -int KIntNumInput::value() const -{ - return m_spin->value(); -} - -void KIntNumInput::setSpecialValueText(const QString& text) -{ - m_spin->setSpecialValueText(text); - layout(true); -}; - -QString KIntNumInput::specialValueText() const -{ - return m_spin->specialValueText(); -} - -void KIntNumInput::setLabel(const QString & label, int a) -{ - KNumInput::setLabel(label, a); - - if(m_label) - m_label->setBuddy(m_spin); -} - -// ---------------------------------------------------------------------------- - -class KDoubleNumInput::KDoubleNumInputPrivate { -public: - KDoubleNumInputPrivate( double r ) - : spin( 0 ), - referencePoint( r ), - blockRelative ( 0 ) {} - KDoubleSpinBox * spin; - double referencePoint; - short blockRelative; -}; - -KDoubleNumInput::KDoubleNumInput(QWidget *parent, const char *name) - : KNumInput(parent, name) -{ - init(0.0, 0.0, 9999.0, 0.01, 2); -} - -KDoubleNumInput::KDoubleNumInput(double lower, double upper, double value, - double step, int precision, QWidget* parent, - const char *name) - : KNumInput(parent, name) -{ - init(value, lower, upper, step, precision); -} - -KDoubleNumInput::KDoubleNumInput(KNumInput *below, - double lower, double upper, double value, - double step, int precision, QWidget* parent, - const char *name) - : KNumInput(below, parent, name) -{ - init(value, lower, upper, step, precision); -} - -KDoubleNumInput::KDoubleNumInput(double value, QWidget *parent, const char *name) - : KNumInput(parent, name) -{ - init(value, kMin(0.0, value), kMax(0.0, value), 0.01, 2 ); -} - -KDoubleNumInput::KDoubleNumInput(KNumInput* below, double value, QWidget* parent, - const char* name) - : KNumInput(below, parent, name) -{ - init( value, kMin(0.0, value), kMax(0.0, value), 0.01, 2 ); -} - -KDoubleNumInput::~KDoubleNumInput() -{ - delete d; -} - -// ### remove when BIC changes are allowed again: - -bool KDoubleNumInput::eventFilter( QObject * o, QEvent * e ) { - return KNumInput::eventFilter( o, e ); -} - -void KDoubleNumInput::resetEditBox() { - -} - -// ### end stuff to remove when BIC changes are allowed again - - - -void KDoubleNumInput::init(double value, double lower, double upper, - double step, int precision ) -{ - // ### init no longer used members: - edit = 0; - m_range = true; - m_value = 0.0; - m_precision = 2; - // ### end - - d = new KDoubleNumInputPrivate( value ); - - d->spin = new KDoubleSpinBox( lower, upper, step, value, precision, - this, "KDoubleNumInput::d->spin" ); - setFocusProxy(d->spin); - connect( d->spin, SIGNAL(valueChanged(double)), - this, SIGNAL(valueChanged(double)) ); - connect( this, SIGNAL(valueChanged(double)), - this, SLOT(slotEmitRelativeValueChanged(double)) ); - - updateLegacyMembers(); - - layout(true); -} - -void KDoubleNumInput::updateLegacyMembers() { - // ### update legacy members that are either not private or for - // which an inlined getter exists: - m_lower = minValue(); - m_upper = maxValue(); - m_step = d->spin->lineStep(); - m_specialvalue = specialValueText(); -} - - -double KDoubleNumInput::mapSliderToSpin( int val ) const -{ - // map [slidemin,slidemax] to [spinmin,spinmax] - double spinmin = d->spin->minValue(); - double spinmax = d->spin->maxValue(); - double slidemin = m_slider->minValue(); // cast int to double to avoid - double slidemax = m_slider->maxValue(); // overflow in rel denominator - double rel = ( double(val) - slidemin ) / ( slidemax - slidemin ); - return spinmin + rel * ( spinmax - spinmin ); -} - -void KDoubleNumInput::sliderMoved(int val) -{ - d->spin->setValue( mapSliderToSpin( val ) ); -} - -void KDoubleNumInput::slotEmitRelativeValueChanged( double value ) -{ - if ( !d->referencePoint ) return; - emit relativeValueChanged( value / d->referencePoint ); -} - -QSize KDoubleNumInput::minimumSizeHint() const -{ - constPolish(); - - int w; - int h; - - h = 2 + QMAX(m_sizeEdit.height(), m_sizeSlider.height()); - - // if in extra row, then count it here - if(m_label && (m_alignment & (AlignBottom|AlignTop))) - h += 4 + m_sizeLabel.height(); - else - // label is in the same row as the other widgets - h = QMAX(h, m_sizeLabel.height() + 2); - - w = m_slider ? m_slider->sizeHint().width() + 8 : 0; - w += m_colw1 + m_colw2; - - if(m_alignment & (AlignTop|AlignBottom)) - w = QMAX(w, m_sizeLabel.width() + 4); - - return QSize(w, h); -} - -void KDoubleNumInput::resizeEvent(QResizeEvent* e) -{ - int w = m_colw1; - int h = 0; - - if(m_label && (m_alignment & AlignTop)) { - m_label->setGeometry(0, 0, e->size().width(), m_sizeLabel.height()); - h += m_sizeLabel.height() + 4; - } - - if(m_label && (m_alignment & AlignVCenter)) - m_label->setGeometry(0, 0, w, m_sizeEdit.height()); - - d->spin->setGeometry(w, h, m_slider ? m_colw2 - : e->size().width() - w, m_sizeEdit.height()); - w += m_colw2 + 8; - - if(m_slider) - m_slider->setGeometry(w, h, e->size().width() - w, m_sizeEdit.height()); - - h += m_sizeEdit.height() + 2; - - if(m_label && (m_alignment & AlignBottom)) - m_label->setGeometry(0, h, m_sizeLabel.width(), m_sizeLabel.height()); -} - -void KDoubleNumInput::doLayout() -{ - m_sizeEdit = d->spin->sizeHint(); - m_colw2 = m_sizeEdit.width(); -} - -void KDoubleNumInput::setValue(double val) -{ - d->spin->setValue( val ); -} - -void KDoubleNumInput::setRelativeValue( double r ) -{ - if ( !d->referencePoint ) return; - ++d->blockRelative; - setValue( r * d->referencePoint ); - --d->blockRelative; -} - -void KDoubleNumInput::setReferencePoint( double ref ) -{ - // clip to valid range: - ref = kMin( maxValue(), kMax( minValue(), ref ) ); - d->referencePoint = ref; -} - -void KDoubleNumInput::setRange(double lower, double upper, double step, - bool slider) -{ - if( m_slider ) { - // don't update the slider to avoid an endless recursion - QSpinBox * spin = d->spin; - disconnect(spin, SIGNAL(valueChanged(int)), - m_slider, SLOT(setValue(int)) ); - } - d->spin->setRange( lower, upper, step, d->spin->precision() ); - - if(slider) { - // upcast to base type to get the min/maxValue in int form: - QSpinBox * spin = d->spin; - int slmax = spin->maxValue(); - int slmin = spin->minValue(); - int slvalue = spin->value(); - int slstep = spin->lineStep(); - if (m_slider) { - m_slider->setRange(slmin, slmax); - m_slider->setLineStep(slstep); - m_slider->setValue(slvalue); - } else { - m_slider = new QSlider(slmin, slmax, slstep, slvalue, - QSlider::Horizontal, this); - m_slider->setTickmarks(QSlider::Below); - // feedback line: when one moves, the other moves, too: - connect(m_slider, SIGNAL(valueChanged(int)), - SLOT(sliderMoved(int)) ); - } - connect(spin, SIGNAL(valueChanged(int)), - m_slider, SLOT(setValue(int)) ); - // calculate ( slmax - slmin ) / 10 without overflowing ints: - int major = calcDiffByTen( slmax, slmin ); - if ( !major ) major = slstep; // ### needed? - m_slider->setTickInterval(major); - } else { - delete m_slider; - m_slider = 0; - } - - setReferencePoint( referencePoint() ); - - layout(true); - updateLegacyMembers(); -} - -void KDoubleNumInput::setMinValue(double min) -{ - setRange(min, maxValue(), d->spin->lineStep(), m_slider); -} - -double KDoubleNumInput::minValue() const -{ - return d->spin->minValue(); -} - -void KDoubleNumInput::setMaxValue(double max) -{ - setRange(minValue(), max, d->spin->lineStep(), m_slider); -} - -double KDoubleNumInput::maxValue() const -{ - return d->spin->maxValue(); -} - -double KDoubleNumInput::value() const -{ - return d->spin->value(); -} - -double KDoubleNumInput::relativeValue() const -{ - if ( !d->referencePoint ) return 0; - return value() / d->referencePoint; -} - -double KDoubleNumInput::referencePoint() const -{ - return d->referencePoint; -} - -QString KDoubleNumInput::suffix() const -{ - return d->spin->suffix(); -} - -QString KDoubleNumInput::prefix() const -{ - return d->spin->prefix(); -} - -void KDoubleNumInput::setSuffix(const QString &suffix) -{ - d->spin->setSuffix( suffix ); - - layout(true); -} - -void KDoubleNumInput::setPrefix(const QString &prefix) -{ - d->spin->setPrefix( prefix ); - - layout(true); -} - -void KDoubleNumInput::setPrecision(int precision) -{ - d->spin->setPrecision( precision ); - - layout(true); -} - -int KDoubleNumInput::precision() const -{ - return d->spin->precision(); -} - -void KDoubleNumInput::setSpecialValueText(const QString& text) -{ - d->spin->setSpecialValueText( text ); - - layout(true); - updateLegacyMembers(); -}; - -void KDoubleNumInput::setLabel(const QString & label, int a) -{ - KNumInput::setLabel(label, a); - - if(m_label) - m_label->setBuddy(d->spin); - -} - -// ---------------------------------------------------------------------------- - - -// We use a kind of fixed-point arithmetic to represent the range of -// doubles [mLower,mUpper] in steps of 10^(-mPrecision). Thus, the -// following relations hold: -// -// 1. factor = 10^mPrecision -// 2. basicStep = 1/factor = 10^(-mPrecision); -// 3. lowerInt = lower * factor; -// 4. upperInt = upper * factor; -// 5. lower = lowerInt * basicStep; -// 6. upper = upperInt * basicStep; -class KDoubleSpinBox::Private { -public: - Private( int precision=1 ) - : mPrecision( precision ), - mValidator( 0 ) - { - } - - int factor() const { - int f = 1; - for ( int i = 0 ; i < mPrecision ; ++i ) f *= 10; - return f; - } - - double basicStep() const { - return 1.0/double(factor()); - } - - int mapToInt( double value, bool * ok ) const { - assert( ok ); - const double f = factor(); - if ( value > double(INT_MAX) / f ) { -// kdWarning() << "KDoubleSpinBox: can't represent value " << value -// << "in terms of fixed-point numbers with precision " -// << mPrecision << endl; - *ok = false; - return INT_MAX; - } else if ( value < double(INT_MIN) / f ) { -// kdWarning() << "KDoubleSpinBox: can't represent value " << value -// << "in terms of fixed-point numbers with precision " -// << mPrecision << endl; - *ok = false; - return INT_MIN; - } else { - *ok = true; - return int( value * f + ( value < 0 ? -0.5 : 0.5 ) ); - } - } - - double mapToDouble( int value ) const { - return double(value) * basicStep(); - } - - int mPrecision; - KDoubleValidator * mValidator; -}; - -KDoubleSpinBox::KDoubleSpinBox( QWidget * parent, const char * name ) - : QSpinBox( parent, name ) -{ - editor()->setAlignment( Qt::AlignRight ); - d = new Private(); - updateValidator(); -} - -KDoubleSpinBox::KDoubleSpinBox( double lower, double upper, double step, - double value, int precision, - QWidget * parent, const char * name ) - : QSpinBox( parent, name ) -{ - editor()->setAlignment( Qt::AlignRight ); - d = new Private(); - setRange( lower, upper, step, precision ); - setValue( value ); - connect( this, SIGNAL(valueChanged(int)), SLOT(slotValueChanged(int)) ); -} - -KDoubleSpinBox::~KDoubleSpinBox() { - delete d; d = 0; -} - -bool KDoubleSpinBox::acceptLocalizedNumbers() const { - if ( !d->mValidator ) return true; // we'll set one that does; - // can't do it now, since we're const - return d->mValidator->acceptLocalizedNumbers(); -} - -void KDoubleSpinBox::setAcceptLocalizedNumbers( bool accept ) { - if ( !d->mValidator ) updateValidator(); - d->mValidator->setAcceptLocalizedNumbers( accept ); -} - -void KDoubleSpinBox::setRange( double lower, double upper, double step, - int precision ) { - lower = kMin(upper, lower); - upper = kMax(upper, lower); - setPrecision( precision, true ); // disable bounds checking, since - setMinValue( lower ); // it's done in set{Min,Max}Value - setMaxValue( upper ); // anyway and we want lower, upper - setLineStep( step ); // and step to have the right precision -} - -int KDoubleSpinBox::precision() const { - return d->mPrecision; -} - -void KDoubleSpinBox::setPrecision( int precision ) { - setPrecision( precision, false ); -} - -void KDoubleSpinBox::setPrecision( int precision, bool force ) { - if ( precision < 1 ) return; - if ( !force ) { - int maxPrec = maxPrecision(); - if ( precision > maxPrec ) - precision = maxPrec; - } - d->mPrecision = precision; - updateValidator(); -} - -int KDoubleSpinBox::maxPrecision() const { - // INT_MAX must be > maxAbsValue * 10^precision - // ==> 10^precision < INT_MAX / maxAbsValue - // ==> precision < log10 ( INT_MAX / maxAbsValue ) - // ==> maxPrecision = floor( log10 ( INT_MAX / maxAbsValue ) ); - double maxAbsValue = kMax( fabs(minValue()), fabs(maxValue()) ); - if ( maxAbsValue == 0 ) return 6; // return arbitrary value to avoid dbz... - - return int( floor( log10( double(INT_MAX) / maxAbsValue ) ) ); -} - -double KDoubleSpinBox::value() const { - return d->mapToDouble( base::value() ); -} - -void KDoubleSpinBox::setValue( double value ) { - if ( value == this->value() ) return; - if ( value < minValue() ) - base::setValue( base::minValue() ); - else if ( value > maxValue() ) - base::setValue( base::maxValue() ); - else { - bool ok = false; - base::setValue( d->mapToInt( value, &ok ) ); - assert( ok ); - } -} - -double KDoubleSpinBox::minValue() const { - return d->mapToDouble( base::minValue() ); -} - -void KDoubleSpinBox::setMinValue( double value ) { - bool ok = false; - int min = d->mapToInt( value, &ok ); - if ( !ok ) return; - base::setMinValue( min ); - updateValidator(); -} - - -double KDoubleSpinBox::maxValue() const { - return d->mapToDouble( base::maxValue() ); -} - -void KDoubleSpinBox::setMaxValue( double value ) { - bool ok = false; - int max = d->mapToInt( value, &ok ); - if ( !ok ) return; - base::setMaxValue( max ); - updateValidator(); -} - -double KDoubleSpinBox::lineStep() const { - return d->mapToDouble( base::lineStep() ); -} - -void KDoubleSpinBox::setLineStep( double step ) { - bool ok = false; - if ( step > maxValue() - minValue() ) - base::setLineStep( 1 ); - else - base::setLineStep( kMax( d->mapToInt( step, &ok ), 1 ) ); -} - -QString KDoubleSpinBox::mapValueToText( int value ) { -// if ( acceptLocalizedNumbers() ) -// return KGlobal::locale() -// ->formatNumber( d->mapToDouble( value ), d->mPrecision ); -// else - return QString().setNum( d->mapToDouble( value ), 'f', d->mPrecision ); -} - -int KDoubleSpinBox::mapTextToValue( bool * ok ) { - double value; -// if ( acceptLocalizedNumbers() ) -// value = KGlobal::locale()->readNumber( cleanText(), ok ); -// else - value = cleanText().toDouble( ok ); - if ( !*ok ) return 0; - if ( value > maxValue() ) - value = maxValue(); - else if ( value < minValue() ) - value = minValue(); - return d->mapToInt( value, ok ); -} - -void KDoubleSpinBox::setValidator( const QValidator * ) { - // silently discard the new validator. We don't want another one ;-) -} - -void KDoubleSpinBox::slotValueChanged( int value ) { - emit valueChanged( d->mapToDouble( value ) ); -} - -void KDoubleSpinBox::updateValidator() { - if ( !d->mValidator ) { - d->mValidator = new KDoubleValidator( minValue(), maxValue(), precision(), - this, "d->mValidator" ); - base::setValidator( d->mValidator ); - } else - d->mValidator->setRange( minValue(), maxValue(), precision() ); -} - -void KNumInput::virtual_hook( int, void* ) -{ /*BASE::virtual_hook( id, data );*/ } - -void KIntNumInput::virtual_hook( int id, void* data ) -{ KNumInput::virtual_hook( id, data ); } - -void KDoubleNumInput::virtual_hook( int id, void* data ) -{ KNumInput::virtual_hook( id, data ); } - -void KIntSpinBox::virtual_hook( int, void* ) -{ /*BASE::virtual_hook( id, data );*/ } - -void KDoubleSpinBox::virtual_hook( int, void* ) -{ /*BASE::virtual_hook( id, data );*/ } - -//#include "knuminput.moc" diff --git a/noncore/settings/networksettings/ppp/knuminput.h b/noncore/settings/networksettings/ppp/knuminput.h deleted file mode 100644 index 67f3b44..0000000 --- a/noncore/settings/networksettings/ppp/knuminput.h +++ b/dev/null @@ -1,947 +0,0 @@ -/* - * knuminput.h - * - * Copyright (c) 1997 Patrick Dowler <dowler@morgul.fsh.uvic.ca> - * Copyright (c) 2000 Dirk A. Mueller <mueller@kde.org> - * Copyright (c) 2002 Marc Mutz <mutz@kde.org> - * - * Requires the Qt widget libraries, available at no cost at - * http://www.troll.no/ - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef K_NUMINPUT_H -#define K_NUMINPUT_H - -#include <qwidget.h> -#include <qspinbox.h> - -class QLabel; -class QSlider; -class QLineEdit; -class QLayout; -class QValidator; - -class KIntSpinBox; - -/* ------------------------------------------------------------------------ */ - -/** - * You need to inherit from this class if you want to implement K*NumInput - * for a different variable type - * - */ -class KNumInput : public QWidget -{ - Q_OBJECT - Q_PROPERTY( QString label READ label WRITE setLabel ) -public: - /** - * Default constructor - * - */ - KNumInput(QWidget* parent=0, const char* name=0); - - /** - * @param below A pointer to another KNumInput. - * - */ - KNumInput(KNumInput* below, QWidget* parent=0, const char* name=0); - ~KNumInput(); - - /** - * Sets the text and alignment of the main description label. - * - * @param label The text of the label. - * Use QString::null to remove an existing one. - * - * @param a one of @p AlignLeft, @p AlignHCenter, YAlignRight and - * @p AlignTop, @p AlignVCenter, @p AlignBottom. - * default is @p AlignLeft | @p AlignTop. - * - * The vertical alignment flags have special meaning with this - * widget: - * - * @li @p AlignTop The label is placed above the edit/slider - * @li @p AlignVCenter The label is placed left beside the edit - * @li @p AlignBottom The label is placed below the edit/slider - * - */ - virtual void setLabel(const QString & label, int a = AlignLeft | AlignTop); - - /** - * @return the text of the label. - */ - QString label() const; - - /** - * @return if the num input has a slider. - * @since 3.1 - */ - bool showSlider() const { return m_slider; } - - /** - * Sets the spacing of tickmarks for the slider. - * - * @param minor Minor tickmark separation. - * @param major Major tickmark separation. - */ - void setSteps(int minor, int major); - - /** - * Specifies that this widget may stretch horizontally, but is - * fixed vertically (like @ref QSpinBox itself). - */ - QSizePolicy sizePolicy() const; - - /** - * Returns a size which fits the contents of the control. - * - * @return the preferred size necessary to show the control - */ - virtual QSize sizeHint() const; - -protected: - /** - * Call this function whenever you change something in the geometry - * of your KNumInput child. - * - */ - void layout(bool deep); - - /** - * You need to overwrite this method and implement your layout - * calculations there. - * - * See KIntNumInput::doLayout and KDoubleNumInput::doLayout implementation - * for details. - * - */ - virtual void doLayout() = 0; - - KNumInput* m_prev, *m_next; - int m_colw1, m_colw2; - - QLabel* m_label; - QSlider* m_slider; - QSize m_sizeSlider, m_sizeLabel; - - int m_alignment; - -private: - void init(); - -protected: - virtual void virtual_hook( int id, void* data ); -private: - class KNumInputPrivate; - KNumInputPrivate *d; -}; - -/* ------------------------------------------------------------------------ */ - -/** - * KIntNumInput combines a @ref QSpinBox and optionally a @ref QSlider - * with a label to make an easy to use control for setting some integer - * parameter. This is especially nice for configuration dialogs, - * which can have many such combinated controls. - * - * The slider is created only when the user specifies a range - * for the control using the setRange function with the slider - * parameter set to "true". - * - * A special feature of KIntNumInput, designed specifically for - * the situation when there are several KIntNumInputs in a column, - * is that you can specify what portion of the control is taken by the - * QSpinBox (the remaining portion is used by the slider). This makes - * it very simple to have all the sliders in a column be the same size. - * - * It uses @ref KIntValidator validator class. KIntNumInput enforces the - * value to be in the given range, and can display it in any base - * between 2 and 36. - * - * @short An input widget for integer numbers, consisting of a spinbox and a slider. - * @version $Id$ - */ - -class KIntNumInput : public KNumInput -{ - Q_OBJECT - Q_PROPERTY( int value READ value WRITE setValue ) - Q_PROPERTY( int minValue READ minValue WRITE setMinValue ) - Q_PROPERTY( int maxValue READ maxValue WRITE setMaxValue ) - Q_PROPERTY( int referencePoint READ referencePoint WRITE setReferencePoint ) - Q_PROPERTY( QString suffix READ suffix WRITE setSuffix ) - Q_PROPERTY( QString prefix READ prefix WRITE setPrefix ) - Q_PROPERTY( QString specialValueText READ specialValueText WRITE setSpecialValueText ) - -public: - /** - * Constructs an input control for integer values - * with base 10 and initial value 0. - */ - KIntNumInput(QWidget *parent=0, const char *name=0); - /** - * Constructor - * It constructs a QSpinBox that allows the input of integer numbers - * in the range of -INT_MAX to +INT_MAX. To set a descriptive label, - * use setLabel(). To enforce the value being in a range and optionally to - * attach a slider to it, use setRange(). - * - * @param value initial value for the control - * @param base numeric base used for display - * @param parent parent QWidget - * @param name internal name for this widget - */ - KIntNumInput(int value, QWidget* parent=0, int base = 10, const char *name=0); - - /** - * Constructor - * - * the difference to the one above is the "below" parameter. It tells - * this instance that it is visually put below some other KNumInput widget. - * Note that these two KNumInput's need not to have the same parent widget - * or be in the same layout group. - * The effect is that it'll adjust it's layout in correspondence - * with the layout of the other KNumInput's (you can build an arbitary long - * chain). - * - * @param below append KIntNumInput to the KNumInput chain - * @param value initial value for the control - * @param base numeric base used for display - * @param parent parent QWidget - * @param name internal name for this widget - */ - KIntNumInput(KNumInput* below, int value, QWidget* parent=0, int base = 10, const char *name=0); - - /** - * Destructor - * - * - */ - virtual ~KIntNumInput(); - - /** - * @return the current value. - */ - int value() const; - - /** - * @return the curent value in units of the @ref referencePoint. - * @since 3.1 - */ - double relativeValue() const; - - /** - * @return the current reference point - * @since 3.1 - */ - int referencePoint() const; - - /** - * @return the suffix displayed behind the value. - * @see #setSuffix() - */ - QString suffix() const; - /** - * @return the prefix displayed in front of the value. - * @see #setPrefix() - */ - QString prefix() const; - /** - * @return the string displayed for a special value. - * @see #setSpecialValueText() - */ - QString specialValueText() const; - - /** - * @param min minimum value - * @param max maximum value - * @param step step size for the QSlider - */ - void setRange(int min, int max, int step=1, bool slider=true); - /** - * Sets the minimum value. - */ - void setMinValue(int min); - /** - * @return the minimum value. - */ - int minValue() const; - /** - * Sets the maximum value. - */ - void setMaxValue(int max); - /** - * @return the maximum value. - */ - int maxValue() const; - - /** - * Sets the special value text. If set, the SpinBox will display - * this text instead of the numeric value whenever the current - * value is equal to minVal(). Typically this is used for indicating - * that the choice has a special (default) meaning. - */ - void setSpecialValueText(const QString& text); - - /** - * @reimplemented - */ - virtual void setLabel(const QString & label, int a = AlignLeft | AlignTop); - - /** - * This method returns the minimum size necessary to display the - * control. The minimum size is enough to show all the labels - * in the current font (font change may invalidate the return value). - * - * @return the minimum size necessary to show the control - */ - virtual QSize minimumSizeHint() const; - -public slots: - /** - * Sets the value of the control. - */ - void setValue(int); - - /** - * Sets the value in units of the @ref referencePoint - * @since 3.1 - */ - void setRelativeValue(double); - - /** - * Sets the reference point for @ref relativeValue. - * @since 3.1 - */ - void setReferencePoint(int); - - /** - * Sets the suffix to @p suffix. - * Use QString::null to disable this feature. - * Formatting has to be provided (e.g. a space separator between the - * prepended @p value and the suffix's text has to be provided - * as the first character in the suffix). - * - * @see QSpinBox::setSuffix(), #setPrefix() - */ - void setSuffix(const QString &suffix); - - /** - * Sets the prefix to @p prefix. - * Use QString::null to disable this feature. - * Formatting has to be provided (see above). - * - * @see QSpinBox::setPrefix(), #setSuffix() - */ - void setPrefix(const QString &prefix); - - /** - * sets focus to the edit widget and marks all text in if mark == true - * - */ - void setEditFocus( bool mark = true ); - -signals: - /** - * Emitted every time the value changes (by calling @ref setValue() or - * by user interaction). - */ - void valueChanged(int); - - /** - * Emitted whenever @ref #valueChanged is. Contains the change - * relative to the @ref referencePoint. - * @since 3.1 - */ - void relativeValueChanged(double); - -private slots: - void spinValueChanged(int); - void slotEmitRelativeValueChanged(int); - -protected: - /** - * @reimplemented - */ - virtual void doLayout(); - /** - * @reimplemented - */ - void resizeEvent ( QResizeEvent * ); - - KIntSpinBox* m_spin; - QSize m_sizeSpin; - -private: - void init(int value, int _base); - -protected: - virtual void virtual_hook( int id, void* data ); -private: - class KIntNumInputPrivate; - KIntNumInputPrivate *d; -}; - - -/* ------------------------------------------------------------------------ */ - -class KDoubleLine; - -/** - * KDoubleNumInput combines a @ref QSpinBox and optionally a @ref QSlider - * with a label to make an easy to use control for setting some float - * parameter. This is especially nice for configuration dialogs, - * which can have many such combinated controls. - * - * The slider is created only when the user specifies a range - * for the control using the setRange function with the slider - * parameter set to "true". - * - * A special feature of KDoubleNumInput, designed specifically for - * the situation when there are several instances in a column, - * is that you can specify what portion of the control is taken by the - * QSpinBox (the remaining portion is used by the slider). This makes - * it very simple to have all the sliders in a column be the same size. - * - * It uses the @ref KDoubleValidator validator class. KDoubleNumInput - * enforces the value to be in the given range, but see the class - * documentation of @ref KDoubleSpinBox for the tricky - * interrelationship of precision and values. All of what is said - * there applies here, too. - * - * @see KIntNumInput, KDoubleSpinBox - * @short An input control for real numbers, consisting of a spinbox and a slider. - */ - -class KDoubleNumInput : public KNumInput -{ - Q_OBJECT - Q_PROPERTY( double value READ value WRITE setValue ) - Q_PROPERTY( double minValue READ minValue WRITE setMinValue ) - Q_PROPERTY( double maxValue READ maxValue WRITE setMaxValue ) - Q_PROPERTY( QString suffix READ suffix WRITE setSuffix ) - Q_PROPERTY( QString prefix READ prefix WRITE setPrefix ) - Q_PROPERTY( QString specialValueText READ specialValueText WRITE setSpecialValueText ) - -public: - /** - * Constructs an input control for double values - * with initial value 0.00. - */ - KDoubleNumInput(QWidget *parent=0, const char *name=0); - - /** - * @deprecated (value is rounded to a multiple of 1/100) - * Constructor - * - * @param value initial value for the control - * @param parent parent QWidget - * @param name internal name for this widget - */ - KDoubleNumInput(double value, QWidget *parent=0, const char *name=0); - - /** - * Constructor - * - * @param lower lower boundary value - * @param upper upper boundary value - * @param value initial value for the control - * @param step step size to use for up/down arrow clicks - * @param precision number of digits after the decimal point - * @param parent parent QWidget - * @param name internal name for this widget - * @since 3.1 - */ - KDoubleNumInput(double lower, double upper, double value, double step=0.01, - int precision=2, QWidget *parent=0, const char *name=0); - - /** - * destructor - */ - virtual ~KDoubleNumInput(); - - /** - * @deprecated (rounds @p value to a mulitple of 1/100) - * Constructor - * - * puts it below other KNumInput - * - * @param below - * @param value initial value for the control - * @param parent parent QWidget - * @param name internal name for this widget - **/ - KDoubleNumInput(KNumInput* below, double value, QWidget* parent=0, const char* name=0); - - /** - * Constructor - * - * puts it below other KNumInput - * - * @param lower lower boundary value - * @param upper upper boundary value - * @param value initial value for the control - * @param step step size to use for up/down arrow clicks - * @param precision number of digits after the decimal point - * @param parent parent QWidget - * @param name internal name for this widget - * @since 3.1 - */ - KDoubleNumInput(KNumInput* below, - double lower, double upper, double value, double step=0.02, - int precision=2, QWidget *parent=0, const char *name=0); - - /** - * @return the current value. - */ - double value() const; - - /** - * @return the suffix. - * @see #setSuffix() - */ - QString suffix() const; - - /** - * @return the prefix. - * @see #setPrefix() - */ - QString prefix() const; - - /** - * @return the precision. - * @see #setPrecision() - */ - int precision() const; - - /** - * @return the string displayed for a special value. - * @see #setSpecialValueText() - */ - QString specialValueText() const { return m_specialvalue; } - - /** - * @param min minimum value - * @param max maximum value - * @param step step size for the QSlider - */ - void setRange(double min, double max, double step=1, bool slider=true); - /** - * Sets the minimum value. - */ - void setMinValue(double min); - /** - * @return the minimum value. - */ - double minValue() const; - /** - * Sets the maximum value. - */ - void setMaxValue(double max); - /** - * @return the maximum value. - */ - double maxValue() const; - - /** - * Specifies the number of digits to use. - */ - void setPrecision(int precision); - - /** - * @return the reference point for @ref #relativeValue calculation - * @since 3.1 - */ - double referencePoint() const; - - /** - * @return the current value in units of @ref #referencePoint. - * @since 3.1 - */ - double relativeValue() const; - - /** - * Sets the special value text. If set, the spin box will display - * this text instead of the numeric value whenever the current - * value is equal to @ref #minVal(). Typically this is used for indicating - * that the choice has a special (default) meaning. - */ - void setSpecialValueText(const QString& text); - - /** - * @reimplemented - */ - virtual void setLabel(const QString & label, int a = AlignLeft | AlignTop); - /** - * @reimplemented - */ - virtual QSize minimumSizeHint() const; - /** - * @reimplemented - */ - virtual bool eventFilter(QObject*, QEvent*); - -public slots: - /** - * Sets the value of the control. - */ - void setValue(double); - - /** - * Sets the value in units of @ref #referencePoint. - * @since 3.1 - */ - void setRelativeValue(double); - - /** - * Sets the reference Point to @p ref. It @p ref == 0, emitting of - * @ref #relativeValueChanged is blocked and @ref #relativeValue - * just returns 0. - * @since 3.1 - */ - void setReferencePoint(double ref); - - /** - * Sets the suffix to be displayed to @p suffix. Use QString::null to disable - * this feature. Note that the suffix is attached to the value without any - * spacing. So if you prefer to display a space separator, set suffix - * to something like " cm". - * @see #setSuffix() - */ - void setSuffix(const QString &suffix); - - /** - * Sets the prefix to be displayed to @p prefix. Use QString::null to disable - * this feature. Note that the prefix is attached to the value without any - * spacing. - * @see #setPrefix() - */ - void setPrefix(const QString &prefix); - -signals: - /** - * Emitted every time the value changes (by calling @ref setValue() or - * by user interaction). - */ - void valueChanged(double); - /** - * This is an overloaded member function, provided for - * convenience. It essentially behaves like the above function. - * - * Contains the value in units of @ref #referencePoint. - * @since 3.1 - */ - void relativeValueChanged(double); - -private slots: - void sliderMoved(int); - void slotEmitRelativeValueChanged(double); - -protected: - - /** - * @reimplemented - */ - virtual void doLayout(); - /** - * @reimplemented - */ - void resizeEvent ( QResizeEvent * ); - virtual void resetEditBox(); - - // ### no longer used, remove when BIC allowed - KDoubleLine* edit; - - bool m_range; - double m_lower, m_upper, m_step; - // ### end no longer used - - QSize m_sizeEdit; - - friend class KDoubleLine; -private: - void init(double value, double lower, double upper, - double step, int precision); - double mapSliderToSpin(int) const; - void updateLegacyMembers(); - // ### no longer used, remove when BIC allowed: - QString m_specialvalue, m_prefix, m_suffix; - double m_value; - short m_precision; - // ### end remove when BIC allowed - -protected: - virtual void virtual_hook( int id, void* data ); -private: - class KDoubleNumInputPrivate; - KDoubleNumInputPrivate *d; -}; - - -/* ------------------------------------------------------------------------ */ - -/** - * A @ref QSpinBox with support for arbitrary base numbers - * (e.g. hexadecimal). - * - * The class provides an easy interface to use other - * numeric systems then the decimal. - * - * @short A @ref QSpinBox with support for arbitrary base numbers. - */ -class KIntSpinBox : public QSpinBox -{ - Q_OBJECT - Q_PROPERTY( int base READ base WRITE setBase ) - -public: - - /** - * Constructor. - * - * Constructs a widget with an integer inputline with a little scrollbar - * and a slider, with minimal value 0, maximal value 99, step 1, base 10 - * and initial value 0. - */ - KIntSpinBox( QWidget *parent=0, const char *name=0); - - /** - * Constructor. - * - * Constructs a widget with an integer inputline with a little scrollbar - * and a slider. - * - * @param lower The lowest valid value. - * @param upper The greatest valid value. - * @param step The step size of the scrollbar. - * @param value The actual value. - * @param base The base of the used number system. - * @param parent The parent of the widget. - * @param name The Name of the widget. - */ - KIntSpinBox(int lower, int upper, int step, int value, int base = 10, - QWidget* parent = 0, const char* name = 0); - - /** - * Destructor. - */ - virtual ~KIntSpinBox(); - - /** - * Sets the base in which the numbers in the spin box are represented. - */ - void setBase(int base); - /** - * @return the base in which numbers in the spin box are represented. - */ - int base() const; - /** - * sets focus and optionally marks all text - * - */ - void setEditFocus(bool mark); - -protected: - - /** - * Overloaded the method in QSpinBox - * to make use of the base given in the constructor. - */ - virtual QString mapValueToText(int); - - /** - * Overloaded the method in QSpinBox - * to make use of the base given in the constructor. - */ - virtual int mapTextToValue(bool*); - -private: - int val_base; -protected: - virtual void virtual_hook( int id, void* data ); -private: - class KIntSpinBoxPrivate; - KIntSpinBoxPrivate *d; -}; - - -/* --------------------------------------------------------------------------- */ - -/** - This class provides a spin box for fractional numbers. - - @sect Parameters - - There are a number of interdependent parameters whose relation to - each other you need to understand in order to make successful use - of the spin box. - - @li precision: The number of decimals after the decimal point. - @li maxValue/minValue: upper and lower bound of the valid range - @li lineStep: the size of the step that is taken when the user hits - the up or down buttons - - Since we work with fixed-point numbers internally, the maximum - precision is a function of the valid range and vice versa. More - precisely, the following relations hold: - <pre> - max( abs(minValue()), abs(maxValue() ) <= INT_MAX/10^precision - maxPrecision = floor( log10( INT_MAX/max(abs(minValue()),abs(maxValue())) ) ) - </pre> - - Since the value, bounds and step are rounded to the current - precision, you may experience that the order of setting above - parameters matters. E.g. the following are @em not equivalent (try - it!): - - <pre> - // sets precision, - // then min/max value (rounded to precison and clipped to obtainable range if needed) - // then value and lineStep - KDoubleSpinBox * spin = new KDoubleSpinBox( 0, 9.999, 0.001, 4.321, 3, this ); - - // sets minValue to 0; maxValue to 10.00(!); value to 4.32(!) and only then - // increases the precision - too late, since e.g. value has already been rounded... - KDpubleSpinBox * spin = new KDoubleSpinBox( this ); - spin->setMinValue( 0 ); - spin->setMaxValue( 9.999 ); - spin->setValue( 4.321 ); - spin->setPrecision( 3 ); - </pre> - - @short A spin box for fractional numbers. - @author Marc Mutz <mutz@kde.org> - @version $Id$ - @since 3.1 -**/ - -class KDoubleSpinBox : public QSpinBox { - Q_OBJECT - Q_PROPERTY( bool acceptLocalizedNumbers READ acceptLocalizedNumbers WRITE setAcceptLocalizedNumbers ) - Q_OVERRIDE( double maxValue READ maxValue WRITE setMaxValue ) - Q_OVERRIDE( double minValue READ minValue WRITE setMinValue ) - Q_OVERRIDE( double lineStep READ lineStep WRITE setLineStep ) - Q_OVERRIDE( double value READ value WRITE setValue ) - Q_PROPERTY( int precision READ precision WRITE setPrecision ) - -public: - /** Constructs a @ref KDoubleSpinBox with parent @p parent and - default values for range and value (whatever @ref QRangeControl - uses) and precision (2). */ - KDoubleSpinBox( QWidget * parent=0, const char * name=0 ); - /** Constructs a @ref KDoubleSpinBox with parent @p parent, range - [@p lower,@p upper], @ref lineStep @p step, @ref precision @p - precision and initial value @p value. */ - KDoubleSpinBox( double lower, double upper, double step, double value, - int precision=2, QWidget * parent=0, const char * name=0 ); - - virtual ~KDoubleSpinBox(); - - /** @return whether the spinbox uses localized numbers */ - bool acceptLocalizedNumbers() const; - /** Sets whether to use and accept localized numbers as returned by - @ref KLocale::formatNumber() */ - virtual void setAcceptLocalizedNumbers( bool accept ); - - /** Sets a new range for the spin box values. Note that @p lower, @p - upper and @p step are rounded to @p precision decimal points - first. */ - void setRange( double lower, double upper, double step=0.01, int precision=2 ); - - /** @return the current number of decimal points displayed. */ - int precision() const; - /** Equivalent to @ref setPrecsion( @p precison, @p false ); Needed - since Qt's moc doesn't ignore trailing parameters with default - args when searching for a property setter method. */ - void setPrecision( int precision ); - /** Sets the number of decimal points to use. Note that there is a - tradeoff between the precision used and the available range of - values. See the class docs for more. - @param precision the new number of decimal points to use - - @param force disables checking of bound violations that can - arise if you increase the precision so much that the - minimum and maximum values can't be represented - anymore. Disabling is useful if you don't want to keep - the current min and max values anyway. This is what - e.g. @ref setRange() does. - **/ - virtual void setPrecision( int precision, bool force ); - - /** @return the current value */ - double value() const; - /** @return the current lower bound */ - double minValue() const; - /** Sets the lower bound of the range to @p value, subject to the - contraints that @p value is first rounded to the current - precision and then clipped to the maximum representable - interval. - @see maxValue, minValue, setMaxValue, setRange - */ - void setMinValue( double value ); - /** @return the current upper bound */ - double maxValue() const; - /** Sets the upper bound of the range to @p value, subject to the - contraints that @p value is first rounded to the current - precision and then clipped to the maximum representable - interval. - @see minValue, maxValue, setMinValue, setRange - */ - void setMaxValue( double value ); - - /** @return the current step size */ - double lineStep() const; - /** Sets the step size for clicking the up/down buttons to @p step, - subject to the constraints that @p step is first rounded to the - current precision and then clipped to the meaningful interval - [1, @p maxValue - @p minValue]. */ - void setLineStep( double step ); - - /** Overridden to ignore any setValidator() calls. */ - void setValidator( const QValidator * ); - -signals: - /** Emitted whenever @ref QSpinBox::valueChanged( int ) is emitted. */ - void valueChanged( double value ); - -public slots: - /** Sets the current value to @p value, cubject to the constraints - that @p value is frist rounded to the current precision and then - clipped to the interval [@p minvalue(),@p maxValue()]. */ - virtual void setValue( double value ); - -protected: - virtual QString mapValueToText(int); - virtual int mapTextToValue(bool*); - -protected slots: - void slotValueChanged( int value ); - -protected: - virtual void virtual_hook( int id, void* data ); -private: - typedef QSpinBox base; - void updateValidator(); - int maxPrecision() const; - - class Private; - Private * d; -}; - -#endif // K_NUMINPUT_H diff --git a/noncore/settings/networksettings/ppp/knumvalidator.cpp b/noncore/settings/networksettings/ppp/knumvalidator.cpp deleted file mode 100644 index 44f7a60..0000000 --- a/noncore/settings/networksettings/ppp/knumvalidator.cpp +++ b/dev/null @@ -1,376 +0,0 @@ -/********************************************************************** -** -** $Id$ -** -** KIntValidator, KFloatValidator: -** Copyright (C) 1999 Glen Parker <glenebob@nwlink.com> -** KDoubleValidator: -** Copyright (c) 2002 Marc Mutz <mutz@kde.org> -** -** This library is free software; you can redistribute it and/or -** modify it under the terms of the GNU Library General Public -** License as published by the Free Software Foundation; either -** version 2 of the License, or (at your option) any later version. -** -** This library 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 -** Library General Public License for more details. -** -** You should have received a copy of the GNU Library General Public -** License along with this library; if not, write to the Free -** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -** -*****************************************************************************/ - -#include <qwidget.h> -#include <qstring.h> - -#include "knumvalidator.h" -//#include <klocale.h> -#define i18n QObject::tr -//#include <kglobal.h> -//#include <kdebug.h> - -/////////////////////////////////////////////////////////////// -// Implementation of KIntValidator -// - -KIntValidator::KIntValidator ( QWidget * parent, int base, const char * name ) - : QValidator(parent, name) -{ - _base = base; - if (_base < 2) _base = 2; - if (_base > 36) _base = 36; - - _min = _max = 0; -} - -KIntValidator::KIntValidator ( int bottom, int top, QWidget * parent, int base, const char * name ) - : QValidator(parent, name) -{ - _base = base; - if (_base > 36) _base = 36; - - _min = bottom; - _max = top; -} - -KIntValidator::~KIntValidator () -{} - -QValidator::State KIntValidator::validate ( QString &str, int & ) const -{ - bool ok; - int val = 0; - QString newStr; - - newStr = str.stripWhiteSpace(); - if (_base > 10) - newStr = newStr.upper(); - - if (newStr == QString::fromLatin1("-")) // a special case - if ((_min || _max) && _min >= 0) - ok = false; - else - return QValidator::Acceptable; - else if (newStr.length()) - val = newStr.toInt(&ok, _base); - else { - val = 0; - ok = true; - } - - if (! ok) - return QValidator::Invalid; - - if ((! _min && ! _max) || (val >= _min && val <= _max)) - return QValidator::Acceptable; - - if (_max && _min >= 0 && val < 0) - return QValidator::Invalid; - - return QValidator::Valid; -} - -void KIntValidator::fixup ( QString &str ) const -{ - int dummy; - int val; - QValidator::State state; - - state = validate(str, dummy); - - if (state == QValidator::Invalid || state == QValidator::Acceptable) - return; - - if (! _min && ! _max) - return; - - val = str.toInt(0, _base); - - if (val < _min) val = _min; - if (val > _max) val = _max; - - str.setNum(val, _base); -} - -void KIntValidator::setRange ( int bottom, int top ) -{ - _min = bottom; - _max = top; - - if (_max < _min) - _max = _min; -} - -void KIntValidator::setBase ( int base ) -{ - _base = base; - if (_base < 2) _base = 2; -} - -int KIntValidator::bottom () const -{ - return _min; -} - -int KIntValidator::top () const -{ - return _max; -} - -int KIntValidator::base () const -{ - return _base; -} - - -/////////////////////////////////////////////////////////////// -// Implementation of KFloatValidator -// - -class KFloatValidatorPrivate -{ -public: - KFloatValidatorPrivate() - { - } - ~KFloatValidatorPrivate() - { - } - bool acceptLocalizedNumbers; -}; - - -KFloatValidator::KFloatValidator ( QWidget * parent, const char * name ) - : QValidator(parent, name) -{ - d = new KFloatValidatorPrivate; - d->acceptLocalizedNumbers=false; - _min = _max = 0; -} - -KFloatValidator::KFloatValidator ( double bottom, double top, QWidget * parent, const char * name ) - : QValidator(parent, name) -{ - d = new KFloatValidatorPrivate; - d->acceptLocalizedNumbers=false; - _min = bottom; - _max = top; -} - -KFloatValidator::KFloatValidator ( double bottom, double top, bool localeAware, QWidget * parent, const char * name ) - : QValidator(parent, name) -{ - d = new KFloatValidatorPrivate; - d->acceptLocalizedNumbers = localeAware; - _min = bottom; - _max = top; -} - -KFloatValidator::~KFloatValidator () -{ - delete d; -} - -void KFloatValidator::setAcceptLocalizedNumbers(bool _b) -{ - d->acceptLocalizedNumbers=_b; -} - -bool KFloatValidator::acceptLocalizedNumbers() const -{ - return d->acceptLocalizedNumbers; -} - -//#include <kdebug.h> -QValidator::State KFloatValidator::validate ( QString &str, int & ) const -{ - bool ok; - double val = 0; - QString newStr; - newStr = str.stripWhiteSpace(); - - if (newStr == QString::fromLatin1("-")) // a special case - if ((_min || _max) && _min >= 0) - ok = false; - else - return QValidator::Acceptable; - else if (newStr == QString::fromLatin1(".") ) // FIXME :|| (d->acceptLocalizedNumbers && newStr==KGlobal::locale()->decimalSymbol())) // another special case - return QValidator::Acceptable; - else if (newStr.length()) - { - val = newStr.toDouble(&ok); -// if(!ok && d->acceptLocalizedNumbers) -// val= KGlobal::locale()->readNumber(newStr,&ok); - } - else { - val = 0; - ok = true; - } - - if (! ok) - return QValidator::Invalid; - - if (( !_min && !_max) || (val >= _min && val <= _max)) - return QValidator::Acceptable; - - if (_max && _min >= 0 && val < 0) - return QValidator::Invalid; - - if ( (_min || _max) && (val < _min || val > _max)) - return QValidator::Invalid; - - return QValidator::Valid; -} - -void KFloatValidator::fixup ( QString &str ) const -{ - int dummy; - double val; - QValidator::State state; - - state = validate(str, dummy); - - if (state == QValidator::Invalid || state == QValidator::Acceptable) - return; - - if (! _min && ! _max) - return; - - val = str.toDouble(); - - if (val < _min) val = _min; - if (val > _max) val = _max; - - str.setNum(val); -} - -void KFloatValidator::setRange ( double bottom, double top ) -{ - _min = bottom; - _max = top; - - if (_max < _min) - _max = _min; -} - -double KFloatValidator::bottom () const -{ - return _min; -} - -double KFloatValidator::top () const -{ - return _max; -} - - - - -/////////////////////////////////////////////////////////////// -// Implementation of KDoubleValidator -// - -class KDoubleValidator::Private { -public: - Private( bool accept=false ) : acceptLocalizedNumbers( accept ) {} - - bool acceptLocalizedNumbers; -}; - -//KDoubleValidator::KDoubleValidator( QObject * parent, const char * name ) -KDoubleValidator::KDoubleValidator( QWidget * parent, const char * name ) - : QDoubleValidator( parent, name ), d( 0 ) -{ - d = new Private(); -} - -KDoubleValidator::KDoubleValidator( double bottom, double top, int decimals, -// QObject * parent, const char * name ) - QWidget * parent, const char * name ) - : QDoubleValidator( bottom, top, decimals, parent, name ), d( 0 ) -{ - d = new Private(); -} - -KDoubleValidator::~KDoubleValidator() -{ - delete d; -} - -bool KDoubleValidator::acceptLocalizedNumbers() const { - return d->acceptLocalizedNumbers; -} - -void KDoubleValidator::setAcceptLocalizedNumbers( bool accept ) { - d->acceptLocalizedNumbers = accept; -} - -QValidator::State KDoubleValidator::validate( QString & input, int & p ) const { - QString s = input; - if ( acceptLocalizedNumbers() ) { - // KLocale * l = KGlobal::locale(); - // ok, we have to re-format the number to have: - // 1. decimalSymbol == '.' - // 2. negativeSign == '-' - // 3. positiveSign == <empty> - // 4. thousandsSeparator() == <empty> (we don't check that there - // are exactly three decimals between each separator): - QString d = ".",//l->decimalSymbol(), - n = "-",//l->negativeSign(), - p = "", //l->positiveSign(), - t = "";//l->thousandsSeparator(); - // first, delete p's and t's: - if ( !p.isEmpty() ) - for ( int idx = s.find( p ) ; idx >= 0 ; idx = s.find( p, idx ) ) - s.remove( idx, p.length() ); - - - if ( !t.isEmpty() ) - for ( int idx = s.find( t ) ; idx >= 0 ; idx = s.find( t, idx ) ) - s.remove( idx, t.length() ); - - // then, replace the d's and n's - if ( ( !n.isEmpty() && n.find('.') != -1 ) || - ( !d.isEmpty() && d.find('-') != -1 ) ) { - // make sure we don't replace something twice: - // kdWarning() << "KDoubleValidator: decimal symbol contains '-' or " -// "negative sign contains '.' -> improve algorithm" << endl; - return Invalid; - } - - if ( !d.isEmpty() && d != "." ) - for ( int idx = s.find( d ) ; idx >= 0 ; idx = s.find( d, idx + 1 ) ) - s.replace( idx, d.length(), "."); - - if ( !n.isEmpty() && n != "-" ) - for ( int idx = s.find( n ) ; idx >= 0 ; idx = s.find( n, idx + 1 ) ) - s.replace( idx, n.length(), "-" ); - } - - return base::validate( s, p ); -} - -//#include "knumvalidator.moc" diff --git a/noncore/settings/networksettings/ppp/knumvalidator.h b/noncore/settings/networksettings/ppp/knumvalidator.h deleted file mode 100644 index c95293a..0000000 --- a/noncore/settings/networksettings/ppp/knumvalidator.h +++ b/dev/null @@ -1,211 +0,0 @@ -/********************************************************************** -** -** $Id$ -** -** Copyright (C) 1999 Glen Parker <glenebob@nwlink.com> -** Copyright (C) 2002 Marc Mutz <mutz@kde.org> -** -** This library is free software; you can redistribute it and/or -** modify it under the terms of the GNU Library General Public -** License as published by the Free Software Foundation; either -** version 2 of the License, or (at your option) any later version. -** -** This library 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 -** Library General Public License for more details. -** -** You should have received a copy of the GNU Library General Public -** License along with this library; if not, write to the Free -** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -** -*****************************************************************************/ - -#ifndef __KNUMVALIDATOR_H -#define __KNUMVALIDATOR_H - -#include <qvalidator.h> - -class QWidget; -class QString; - -/** - * @ref QValidator for integers. - - This can be used by @ref QLineEdit or subclass to provide validated - text entry. Can be provided with a base value (default is 10), to allow - the proper entry of hexadecimal, octal, or any other base numeric data. - - @author Glen Parker <glenebob@nwlink.com> - @version 0.0.1 -*/ -class KIntValidator : public QValidator { - - public: - /** - Constuctor. Also sets the base value. - */ - KIntValidator ( QWidget * parent, int base = 10, const char * name = 0 ); - /** - * Constructor. Also sets the minimum, maximum, and numeric base values. - */ - KIntValidator ( int bottom, int top, QWidget * parent, int base = 10, const char * name = 0 ); - /** - * Destructs the validator. - */ - virtual ~KIntValidator (); - /** - * Validates the text, and return the result. Does not modify the parameters. - */ - virtual State validate ( QString &, int & ) const; - /** - * Fixes the text if possible, providing a valid string. The parameter may be modified. - */ - virtual void fixup ( QString & ) const; - /** - * Sets the minimum and maximum values allowed. - */ - virtual void setRange ( int bottom, int top ); - /** - * Sets the numeric base value. - */ - virtual void setBase ( int base ); - /** - * Returns the current minimum value allowed. - */ - virtual int bottom () const; - /** - * Returns the current maximum value allowed. - */ - virtual int top () const; - /** - * Returns the current numeric base. - */ - virtual int base () const; - - private: - int _base; - int _min; - int _max; - -}; - -class KFloatValidatorPrivate; - -/** - @obsolete Use @ref KDoubleValidator - - @ref QValidator for floating point entry. - Extends the QValidator class to properly validate double numeric data. - This can be used by @ref QLineEdit or subclass to provide validated - text entry. - - @author Glen Parker <glenebob@nwlink.com> - @version 0.0.1 -*/ -class KFloatValidator : public QValidator { - - public: - /** - * Constructor. - */ - KFloatValidator ( QWidget * parent, const char * name = 0 ); - /** - * Constructor. Also sets the minimum and maximum values. - */ - KFloatValidator ( double bottom, double top, QWidget * parent, const char * name = 0 ); - /** - * Constructor. Sets the validator to be locale aware if @p localeAware is true. - */ - KFloatValidator ( double bottom, double top, bool localeAware, QWidget * parent, const char * name = 0 ); - /** - * Destructs the validator. - */ - virtual ~KFloatValidator (); - /** - * Validates the text, and return the result. Does not modify the parameters. - */ - virtual State validate ( QString &, int & ) const; - /** - * Fixes the text if possible, providing a valid string. The parameter may be modified. - */ - virtual void fixup ( QString & ) const; - /** - * Sets the minimum and maximum value allowed. - */ - virtual void setRange ( double bottom, double top ); - /** - * Returns the current minimum value allowed. - */ - virtual double bottom () const; - /** - * Returns the current maximum value allowed. - */ - virtual double top () const; - /** - * Sets the validator to be locale aware if @p is true. In this case, the - * character KLocale::decimalSymbol() from the global locale is recognized - * as decimal separator. - */ - void setAcceptLocalizedNumbers(bool b); - /** - * Returns true if the validator is locale aware. - * @see setAcceptLocalizedNumbers(). - */ - bool acceptLocalizedNumbers() const; - - private: - double _min; - double _max; - - KFloatValidatorPrivate *d; -}; - -/** - KDoubleValidator extends @ref QDoubleValidator to be - locale-aware. That means that - subject to not being disabled - - @ref KLocale::decimalPoint(), @ref KLocale::thousandsSeparator() - and @ref KLocale::positiveSign() and @ref KLocale::negativeSign() - are respected. - - @short A locale-aware @ref QDoubleValidator - @author Marc Mutz <mutz@kde.org> - @version $Id$ - @see KIntValidator - @since 3.1 -**/ - -class KDoubleValidator : public QDoubleValidator { - Q_OBJECT - Q_PROPERTY( bool acceptLocalizedNumbers READ acceptLocalizedNumbers WRITE setAcceptLocalizedNumbers ) -public: - /** Constuct a locale-aware KDoubleValidator with default range - (whatever @ref QDoubleValidator uses for that) and parent @p - parent */ - // KDoubleValidator( QObject * parent, const char * name=0 ); - KDoubleValidator( QWidget * parent, const char * name=0 ); - /** Constuct a locale-aware KDoubleValidator for range [@p bottom,@p - top] and a precision of @p decimals decimals after the decimal - point. */ - KDoubleValidator( double bottom, double top, int decimals, - QWidget * parent, const char * name=0 ); - // QObject * parent, const char * name=0 ); - /** Destructs the validator. - */ - virtual ~KDoubleValidator(); - - /** Overloaded for internal reasons. The API is not affected. */ - virtual QValidator::State validate( QString & input, int & pos ) const; - - /** @return whether localized numbers are accepted (default: true) */ - bool acceptLocalizedNumbers() const; - /** Sets whether to accept localized numbers (default: true) */ - void setAcceptLocalizedNumbers( bool accept ); - -private: - typedef QDoubleValidator base; - class Private; - Private * d; -}; - -#endif diff --git a/noncore/settings/networksettings/ppp/ppp.pro b/noncore/settings/networksettings/ppp/ppp.pro index a2e0118..e3c58d6 100644 --- a/noncore/settings/networksettings/ppp/ppp.pro +++ b/noncore/settings/networksettings/ppp/ppp.pro @@ -4,8 +4,10 @@ TEMPLATE = lib #CONFIG += qt warn_on release CONFIG += qt warn_on debug DESTDIR = $(OPIEDIR)/plugins/networksettings -HEADERS = pppmodule.h devices.h modem.h modeminfo.h pppdata.h kpppconfig.h pppdata.h runtests.h general.h modemcmds.h knuminput.h knumvalidator.h kpppwidget.h conwindow.h accounts.h connect.h edit.h scriptedit.h pppdargs.h iplined.h pwentry.h pppconfig.h -SOURCES = pppmodule.cpp modem.cpp modeminfo.cpp pppdata.cpp runtests.cpp general.cpp modemcmds.cpp knuminput.cpp knumvalidator.cpp kpppwidget.cpp conwindow.cpp accounts.cpp connect.cpp edit.cpp scriptedit.cpp pppdargs.cpp iplined.cpp pwentry.cpp pppconfig.cpp +HEADERS = pppmodule.h devices.h modem.h modeminfo.h pppdata.h kpppconfig.h pppdata.h runtests.h general.h modemcmds.h kpppwidget.h conwindow.h accounts.h connect.h edit.h scriptedit.h pppdargs.h iplined.h pwentry.h pppconfig.h +# knuminput.h knumvalidator.h +SOURCES = pppmodule.cpp modem.cpp modeminfo.cpp pppdata.cpp runtests.cpp general.cpp modemcmds.cpp kpppwidget.cpp conwindow.cpp accounts.cpp connect.cpp edit.cpp scriptedit.cpp pppdargs.cpp iplined.cpp pwentry.cpp pppconfig.cpp +#knuminput.cpp knumvalidator.cpp INCLUDEPATH += $(OPIEDIR)/include ../ ../interfaces/ DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe -L../interfaces/ -linterfaces |