Diffstat (limited to 'microkde/kdeui/knuminput.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | microkde/kdeui/knuminput.cpp | 61 |
1 files changed, 32 insertions, 29 deletions
diff --git a/microkde/kdeui/knuminput.cpp b/microkde/kdeui/knuminput.cpp index 335d6f4..da01a20 100644 --- a/microkde/kdeui/knuminput.cpp +++ b/microkde/kdeui/knuminput.cpp | |||
@@ -37,16 +37,19 @@ | |||
37 | #include <algorithm> | 37 | #include <algorithm> |
38 | 38 | ||
39 | #include <qlabel.h> | 39 | #include <qlabel.h> |
40 | #include <qlineedit.h> | 40 | #include <qlineedit.h> |
41 | #include <qsize.h> | 41 | #include <qsize.h> |
42 | #include <qslider.h> | 42 | #include <qslider.h> |
43 | #include <qspinbox.h> | 43 | #include <qspinbox.h> |
44 | #include <qstyle.h> | 44 | #include <qstyle.h> |
45 | //Added by qt3to4: | ||
46 | #include <QResizeEvent> | ||
47 | #include <QEvent> | ||
45 | 48 | ||
46 | #include <kglobal.h> | 49 | #include <kglobal.h> |
47 | #include <klocale.h> | 50 | #include <klocale.h> |
48 | #include <kdebug.h> | 51 | #include <kdebug.h> |
49 | 52 | ||
50 | #include "knumvalidator.h" | 53 | #include "knumvalidator.h" |
51 | #include "knuminput.h" | 54 | #include "knuminput.h" |
52 | 55 | ||
@@ -101,21 +104,21 @@ void KNumInput::setLabel(const QString & label, int a) | |||
101 | if(label.isEmpty()) { | 104 | if(label.isEmpty()) { |
102 | delete m_label; | 105 | delete m_label; |
103 | m_label = 0; | 106 | m_label = 0; |
104 | m_alignment = 0; | 107 | m_alignment = 0; |
105 | } | 108 | } |
106 | else { | 109 | else { |
107 | if (m_label) m_label->setText(label); | 110 | if (m_label) m_label->setText(label); |
108 | else m_label = new QLabel(label, this, "KNumInput::QLabel"); | 111 | else m_label = new QLabel(label, this, "KNumInput::QLabel"); |
109 | m_label->setAlignment((a & (~(AlignTop|AlignBottom|AlignVCenter))) | 112 | m_label->setAlignment((a & (~(Qt::AlignTop|Qt::AlignBottom|Qt::AlignVCenter))) |
110 | | AlignVCenter); | 113 | | Qt::AlignVCenter); |
111 | // if no vertical alignment set, use Top alignment | 114 | // if no vertical alignment set, use Top alignment |
112 | if(!(a & (AlignTop|AlignBottom|AlignVCenter))) | 115 | if(!(a & (Qt::AlignTop|Qt::AlignBottom|Qt::AlignVCenter))) |
113 | a |= AlignTop; | 116 | a |= Qt::AlignTop; |
114 | m_alignment = a; | 117 | m_alignment = a; |
115 | } | 118 | } |
116 | 119 | ||
117 | layout(true); | 120 | layout(true); |
118 | } | 121 | } |
119 | 122 | ||
120 | QString KNumInput::label() const | 123 | QString KNumInput::label() const |
121 | { | 124 | { |
@@ -126,17 +129,17 @@ QString KNumInput::label() const | |||
126 | void KNumInput::layout(bool deep) | 129 | void KNumInput::layout(bool deep) |
127 | { | 130 | { |
128 | int w1 = m_colw1; | 131 | int w1 = m_colw1; |
129 | int w2 = m_colw2; | 132 | int w2 = m_colw2; |
130 | 133 | ||
131 | // label sizeHint | 134 | // label sizeHint |
132 | m_sizeLabel = (m_label ? m_label->sizeHint() : QSize(0,0)); | 135 | m_sizeLabel = (m_label ? m_label->sizeHint() : QSize(0,0)); |
133 | 136 | ||
134 | if(m_label && (m_alignment & AlignVCenter)) | 137 | if(m_label && (m_alignment & Qt::AlignVCenter)) |
135 | m_colw1 = m_sizeLabel.width() + 4; | 138 | m_colw1 = m_sizeLabel.width() + 4; |
136 | else | 139 | else |
137 | m_colw1 = 0; | 140 | m_colw1 = 0; |
138 | 141 | ||
139 | // slider sizeHint | 142 | // slider sizeHint |
140 | m_sizeSlider = (m_slider ? m_slider->sizeHint() : QSize(0, 0)); | 143 | m_sizeSlider = (m_slider ? m_slider->sizeHint() : QSize(0, 0)); |
141 | 144 | ||
142 | doLayout(); | 145 | doLayout(); |
@@ -197,30 +200,30 @@ void KNumInput::setSteps(int minor, int major) | |||
197 | } | 200 | } |
198 | 201 | ||
199 | 202 | ||
200 | // ---------------------------------------------------------------------------- | 203 | // ---------------------------------------------------------------------------- |
201 | 204 | ||
202 | KIntSpinBox::KIntSpinBox(QWidget *parent, const char *name) | 205 | KIntSpinBox::KIntSpinBox(QWidget *parent, const char *name) |
203 | : QSpinBox(0, 99, 1, parent, name) | 206 | : QSpinBox(0, 99, 1, parent, name) |
204 | { | 207 | { |
205 | editor()->setAlignment(AlignRight); | 208 | setAlignment(Qt::AlignRight); |
206 | val_base = 10; | 209 | val_base = 10; |
207 | setValue(0); | 210 | setValue(0); |
208 | } | 211 | } |
209 | 212 | ||
210 | KIntSpinBox::~KIntSpinBox() | 213 | KIntSpinBox::~KIntSpinBox() |
211 | { | 214 | { |
212 | } | 215 | } |
213 | 216 | ||
214 | KIntSpinBox::KIntSpinBox(int lower, int upper, int step, int value, int base, | 217 | KIntSpinBox::KIntSpinBox(int lower, int upper, int step, int value, int base, |
215 | QWidget* parent, const char* name) | 218 | QWidget* parent, const char* name) |
216 | : QSpinBox(lower, upper, step, parent, name) | 219 | : QSpinBox(lower, upper, step, parent, name) |
217 | { | 220 | { |
218 | editor()->setAlignment(AlignRight); | 221 | setAlignment(Qt::AlignRight); |
219 | val_base = base; | 222 | val_base = base; |
220 | setValue(value); | 223 | setValue(value); |
221 | } | 224 | } |
222 | 225 | ||
223 | void KIntSpinBox::setBase(int base) | 226 | void KIntSpinBox::setBase(int base) |
224 | { | 227 | { |
225 | val_base = base; | 228 | val_base = base; |
226 | } | 229 | } |
@@ -238,19 +241,19 @@ QString KIntSpinBox::mapValueToText(int v) | |||
238 | 241 | ||
239 | int KIntSpinBox::mapTextToValue(bool* ok) | 242 | int KIntSpinBox::mapTextToValue(bool* ok) |
240 | { | 243 | { |
241 | return cleanText().toInt(ok, val_base); | 244 | return cleanText().toInt(ok, val_base); |
242 | } | 245 | } |
243 | 246 | ||
244 | void KIntSpinBox::setEditFocus(bool mark) | 247 | void KIntSpinBox::setEditFocus(bool mark) |
245 | { | 248 | { |
246 | editor()->setFocus(); | 249 | setFocus(); |
247 | if(mark) | 250 | if(mark) |
248 | editor()->selectAll(); | 251 | selectAll(); |
249 | } | 252 | } |
250 | 253 | ||
251 | 254 | ||
252 | // ---------------------------------------------------------------------------- | 255 | // ---------------------------------------------------------------------------- |
253 | 256 | ||
254 | class KIntNumInput::KIntNumInputPrivate { | 257 | class KIntNumInput::KIntNumInputPrivate { |
255 | public: | 258 | public: |
256 | int referencePoint; | 259 | int referencePoint; |
@@ -320,24 +323,24 @@ void KIntNumInput::slotEmitRelativeValueChanged( int value ) { | |||
320 | void KIntNumInput::setRange(int lower, int upper, int step, bool slider) | 323 | void KIntNumInput::setRange(int lower, int upper, int step, bool slider) |
321 | { | 324 | { |
322 | upper = kMax(upper, lower); | 325 | upper = kMax(upper, lower); |
323 | lower = kMin(upper, lower); | 326 | lower = kMin(upper, lower); |
324 | m_spin->setMinValue(lower); | 327 | m_spin->setMinValue(lower); |
325 | m_spin->setMaxValue(upper); | 328 | m_spin->setMaxValue(upper); |
326 | m_spin->setLineStep(step); | 329 | m_spin->setLineStep(step); |
327 | 330 | ||
328 | step = m_spin->lineStep(); // maybe QRangeControl didn't like out lineStep? | 331 | step = m_spin->singleStep(); // maybe QRangeControl didn't like out lineStep? |
329 | 332 | ||
330 | if(slider) { | 333 | if(slider) { |
331 | if (m_slider) | 334 | if (m_slider) |
332 | m_slider->setRange(lower, upper); | 335 | m_slider->setRange(lower, upper); |
333 | else { | 336 | else { |
334 | m_slider = new QSlider(lower, upper, step, m_spin->value(), | 337 | m_slider = new QSlider(lower, upper, step, m_spin->value(), |
335 | QSlider::Horizontal, this); | 338 | Qt::Horizontal, this); |
336 | m_slider->setTickmarks(QSlider::Below); | 339 | m_slider->setTickmarks(QSlider::Below); |
337 | connect(m_slider, SIGNAL(valueChanged(int)), | 340 | connect(m_slider, SIGNAL(valueChanged(int)), |
338 | m_spin, SLOT(setValue(int))); | 341 | m_spin, SLOT(setValue(int))); |
339 | } | 342 | } |
340 | 343 | ||
341 | // calculate (upper-lower)/10 without overflowing int's: | 344 | // calculate (upper-lower)/10 without overflowing int's: |
342 | int major = calcDiffByTen( upper, lower ); | 345 | int major = calcDiffByTen( upper, lower ); |
343 | if ( major==0 ) major = step; // #### workaround Qt bug in 2.1-beta4 | 346 | if ( major==0 ) major = step; // #### workaround Qt bug in 2.1-beta4 |
@@ -353,27 +356,27 @@ void KIntNumInput::setRange(int lower, int upper, int step, bool slider) | |||
353 | // check that reference point is still inside valid range: | 356 | // check that reference point is still inside valid range: |
354 | setReferencePoint( referencePoint() ); | 357 | setReferencePoint( referencePoint() ); |
355 | 358 | ||
356 | layout(true); | 359 | layout(true); |
357 | } | 360 | } |
358 | 361 | ||
359 | void KIntNumInput::setMinValue(int min) | 362 | void KIntNumInput::setMinValue(int min) |
360 | { | 363 | { |
361 | setRange(min, m_spin->maxValue(), m_spin->lineStep(), m_slider); | 364 | setRange(min, m_spin->maxValue(), m_spin->singleStep(), m_slider); |
362 | } | 365 | } |
363 | 366 | ||
364 | int KIntNumInput::minValue() const | 367 | int KIntNumInput::minValue() const |
365 | { | 368 | { |
366 | return m_spin->minValue(); | 369 | return m_spin->minValue(); |
367 | } | 370 | } |
368 | 371 | ||
369 | void KIntNumInput::setMaxValue(int max) | 372 | void KIntNumInput::setMaxValue(int max) |
370 | { | 373 | { |
371 | setRange(m_spin->minValue(), max, m_spin->lineStep(), m_slider); | 374 | setRange(m_spin->minValue(), max, m_spin->singleStep(), m_slider); |
372 | } | 375 | } |
373 | 376 | ||
374 | int KIntNumInput::maxValue() const | 377 | int KIntNumInput::maxValue() const |
375 | { | 378 | { |
376 | return m_spin->maxValue(); | 379 | return m_spin->maxValue(); |
377 | } | 380 | } |
378 | 381 | ||
379 | void KIntNumInput::setSuffix(const QString &suffix) | 382 | void KIntNumInput::setSuffix(const QString &suffix) |
@@ -410,26 +413,26 @@ QSize KIntNumInput::minimumSizeHint() const | |||
410 | constPolish(); | 413 | constPolish(); |
411 | 414 | ||
412 | int w; | 415 | int w; |
413 | int h; | 416 | int h; |
414 | 417 | ||
415 | h = 2 + QMAX(m_sizeSpin.height(), m_sizeSlider.height()); | 418 | h = 2 + QMAX(m_sizeSpin.height(), m_sizeSlider.height()); |
416 | 419 | ||
417 | // if in extra row, then count it here | 420 | // if in extra row, then count it here |
418 | if(m_label && (m_alignment & (AlignBottom|AlignTop))) | 421 | if(m_label && (m_alignment & (Qt::AlignBottom|Qt::AlignTop))) |
419 | h += 4 + m_sizeLabel.height(); | 422 | h += 4 + m_sizeLabel.height(); |
420 | else | 423 | else |
421 | // label is in the same row as the other widgets | 424 | // label is in the same row as the other widgets |
422 | h = QMAX(h, m_sizeLabel.height() + 2); | 425 | h = QMAX(h, m_sizeLabel.height() + 2); |
423 | 426 | ||
424 | w = m_slider ? m_slider->sizeHint().width() + 8 : 0; | 427 | w = m_slider ? m_slider->sizeHint().width() + 8 : 0; |
425 | w += m_colw1 + m_colw2; | 428 | w += m_colw1 + m_colw2; |
426 | 429 | ||
427 | if(m_alignment & (AlignTop|AlignBottom)) | 430 | if(m_alignment & (Qt::AlignTop|Qt::AlignBottom)) |
428 | w = QMAX(w, m_sizeLabel.width() + 4); | 431 | w = QMAX(w, m_sizeLabel.width() + 4); |
429 | 432 | ||
430 | return QSize(w, h); | 433 | return QSize(w, h); |
431 | } | 434 | } |
432 | 435 | ||
433 | void KIntNumInput::doLayout() | 436 | void KIntNumInput::doLayout() |
434 | { | 437 | { |
435 | m_sizeSpin = m_spin->sizeHint(); | 438 | m_sizeSpin = m_spin->sizeHint(); |
@@ -439,33 +442,33 @@ void KIntNumInput::doLayout() | |||
439 | m_label->setBuddy(m_spin); | 442 | m_label->setBuddy(m_spin); |
440 | } | 443 | } |
441 | 444 | ||
442 | void KIntNumInput::resizeEvent(QResizeEvent* e) | 445 | void KIntNumInput::resizeEvent(QResizeEvent* e) |
443 | { | 446 | { |
444 | int w = m_colw1; | 447 | int w = m_colw1; |
445 | int h = 0; | 448 | int h = 0; |
446 | 449 | ||
447 | if(m_label && (m_alignment & AlignTop)) { | 450 | if(m_label && (m_alignment & Qt::AlignTop)) { |
448 | m_label->setGeometry(0, 0, e->size().width(), m_sizeLabel.height()); | 451 | m_label->setGeometry(0, 0, e->size().width(), m_sizeLabel.height()); |
449 | h += m_sizeLabel.height() + 4; | 452 | h += m_sizeLabel.height() + 4; |
450 | } | 453 | } |
451 | 454 | ||
452 | if(m_label && (m_alignment & AlignVCenter)) | 455 | if(m_label && (m_alignment & Qt::AlignVCenter)) |
453 | m_label->setGeometry(0, 0, w, m_sizeSpin.height()); | 456 | m_label->setGeometry(0, 0, w, m_sizeSpin.height()); |
454 | 457 | ||
455 | m_spin->setGeometry(w, h, m_slider ? m_colw2 : QMAX(m_colw2, e->size().width() - w), m_sizeSpin.height()); | 458 | m_spin->setGeometry(w, h, m_slider ? m_colw2 : QMAX(m_colw2, e->size().width() - w), m_sizeSpin.height()); |
456 | w += m_colw2 + 8; | 459 | w += m_colw2 + 8; |
457 | 460 | ||
458 | if(m_slider) | 461 | if(m_slider) |
459 | m_slider->setGeometry(w, h, e->size().width() - w, m_sizeSpin.height()); | 462 | m_slider->setGeometry(w, h, e->size().width() - w, m_sizeSpin.height()); |
460 | 463 | ||
461 | h += m_sizeSpin.height() + 2; | 464 | h += m_sizeSpin.height() + 2; |
462 | 465 | ||
463 | if(m_label && (m_alignment & AlignBottom)) | 466 | if(m_label && (m_alignment & Qt::AlignBottom)) |
464 | m_label->setGeometry(0, h, m_sizeLabel.width(), m_sizeLabel.height()); | 467 | m_label->setGeometry(0, h, m_sizeLabel.width(), m_sizeLabel.height()); |
465 | } | 468 | } |
466 | 469 | ||
467 | KIntNumInput::~KIntNumInput() | 470 | KIntNumInput::~KIntNumInput() |
468 | { | 471 | { |
469 | delete d; | 472 | delete d; |
470 | } | 473 | } |
471 | 474 | ||
@@ -641,54 +644,54 @@ QSize KDoubleNumInput::minimumSizeHint() const | |||
641 | constPolish(); | 644 | constPolish(); |
642 | 645 | ||
643 | int w; | 646 | int w; |
644 | int h; | 647 | int h; |
645 | 648 | ||
646 | h = 2 + QMAX(m_sizeEdit.height(), m_sizeSlider.height()); | 649 | h = 2 + QMAX(m_sizeEdit.height(), m_sizeSlider.height()); |
647 | 650 | ||
648 | // if in extra row, then count it here | 651 | // if in extra row, then count it here |
649 | if(m_label && (m_alignment & (AlignBottom|AlignTop))) | 652 | if(m_label && (m_alignment & (Qt::AlignBottom|Qt::AlignTop))) |
650 | h += 4 + m_sizeLabel.height(); | 653 | h += 4 + m_sizeLabel.height(); |
651 | else | 654 | else |
652 | // label is in the same row as the other widgets | 655 | // label is in the same row as the other widgets |
653 | h = QMAX(h, m_sizeLabel.height() + 2); | 656 | h = QMAX(h, m_sizeLabel.height() + 2); |
654 | 657 | ||
655 | w = m_slider ? m_slider->sizeHint().width() + 8 : 0; | 658 | w = m_slider ? m_slider->sizeHint().width() + 8 : 0; |
656 | w += m_colw1 + m_colw2; | 659 | w += m_colw1 + m_colw2; |
657 | 660 | ||
658 | if(m_alignment & (AlignTop|AlignBottom)) | 661 | if(m_alignment & (Qt::AlignTop|Qt::AlignBottom)) |
659 | w = QMAX(w, m_sizeLabel.width() + 4); | 662 | w = QMAX(w, m_sizeLabel.width() + 4); |
660 | 663 | ||
661 | return QSize(w, h); | 664 | return QSize(w, h); |
662 | } | 665 | } |
663 | 666 | ||
664 | void KDoubleNumInput::resizeEvent(QResizeEvent* e) | 667 | void KDoubleNumInput::resizeEvent(QResizeEvent* e) |
665 | { | 668 | { |
666 | int w = m_colw1; | 669 | int w = m_colw1; |
667 | int h = 0; | 670 | int h = 0; |
668 | 671 | ||
669 | if(m_label && (m_alignment & AlignTop)) { | 672 | if(m_label && (m_alignment & Qt::AlignTop)) { |
670 | m_label->setGeometry(0, 0, e->size().width(), m_sizeLabel.height()); | 673 | m_label->setGeometry(0, 0, e->size().width(), m_sizeLabel.height()); |
671 | h += m_sizeLabel.height() + 4; | 674 | h += m_sizeLabel.height() + 4; |
672 | } | 675 | } |
673 | 676 | ||
674 | if(m_label && (m_alignment & AlignVCenter)) | 677 | if(m_label && (m_alignment & Qt::AlignVCenter)) |
675 | m_label->setGeometry(0, 0, w, m_sizeEdit.height()); | 678 | m_label->setGeometry(0, 0, w, m_sizeEdit.height()); |
676 | 679 | ||
677 | d->spin->setGeometry(w, h, m_slider ? m_colw2 | 680 | d->spin->setGeometry(w, h, m_slider ? m_colw2 |
678 | : e->size().width() - w, m_sizeEdit.height()); | 681 | : e->size().width() - w, m_sizeEdit.height()); |
679 | w += m_colw2 + 8; | 682 | w += m_colw2 + 8; |
680 | 683 | ||
681 | if(m_slider) | 684 | if(m_slider) |
682 | m_slider->setGeometry(w, h, e->size().width() - w, m_sizeEdit.height()); | 685 | m_slider->setGeometry(w, h, e->size().width() - w, m_sizeEdit.height()); |
683 | 686 | ||
684 | h += m_sizeEdit.height() + 2; | 687 | h += m_sizeEdit.height() + 2; |
685 | 688 | ||
686 | if(m_label && (m_alignment & AlignBottom)) | 689 | if(m_label && (m_alignment & Qt::AlignBottom)) |
687 | m_label->setGeometry(0, h, m_sizeLabel.width(), m_sizeLabel.height()); | 690 | m_label->setGeometry(0, h, m_sizeLabel.width(), m_sizeLabel.height()); |
688 | } | 691 | } |
689 | 692 | ||
690 | void KDoubleNumInput::doLayout() | 693 | void KDoubleNumInput::doLayout() |
691 | { | 694 | { |
692 | m_sizeEdit = d->spin->sizeHint(); | 695 | m_sizeEdit = d->spin->sizeHint(); |
693 | m_colw2 = m_sizeEdit.width(); | 696 | m_colw2 = m_sizeEdit.width(); |
694 | } | 697 | } |
@@ -725,24 +728,24 @@ void KDoubleNumInput::setRange(double lower, double upper, double step, | |||
725 | d->spin->setRange( lower, upper, step, d->spin->precision() ); | 728 | d->spin->setRange( lower, upper, step, d->spin->precision() ); |
726 | 729 | ||
727 | if(slider) { | 730 | if(slider) { |
728 | // upcast to base type to get the min/maxValue in int form: | 731 | // upcast to base type to get the min/maxValue in int form: |
729 | QSpinBox * spin = d->spin; | 732 | QSpinBox * spin = d->spin; |
730 | int slmax = spin->maxValue(); | 733 | int slmax = spin->maxValue(); |
731 | int slmin = spin->minValue(); | 734 | int slmin = spin->minValue(); |
732 | int slvalue = spin->value(); | 735 | int slvalue = spin->value(); |
733 | int slstep = spin->lineStep(); | 736 | int slstep = spin->singleStep(); |
734 | if (m_slider) { | 737 | if (m_slider) { |
735 | m_slider->setRange(slmin, slmax); | 738 | m_slider->setRange(slmin, slmax); |
736 | m_slider->setLineStep(slstep); | 739 | m_slider->setLineStep(slstep); |
737 | m_slider->setValue(slvalue); | 740 | m_slider->setValue(slvalue); |
738 | } else { | 741 | } else { |
739 | m_slider = new QSlider(slmin, slmax, slstep, slvalue, | 742 | m_slider = new QSlider(slmin, slmax, slstep, slvalue, |
740 | QSlider::Horizontal, this); | 743 | Qt::Horizontal, this); |
741 | m_slider->setTickmarks(QSlider::Below); | 744 | m_slider->setTickmarks(QSlider::Below); |
742 | // feedback line: when one moves, the other moves, too: | 745 | // feedback line: when one moves, the other moves, too: |
743 | connect(m_slider, SIGNAL(valueChanged(int)), | 746 | connect(m_slider, SIGNAL(valueChanged(int)), |
744 | SLOT(sliderMoved(int)) ); | 747 | SLOT(sliderMoved(int)) ); |
745 | } | 748 | } |
746 | connect(spin, SIGNAL(valueChanged(int)), | 749 | connect(spin, SIGNAL(valueChanged(int)), |
747 | m_slider, SLOT(setValue(int)) ); | 750 | m_slider, SLOT(setValue(int)) ); |
748 | // calculate ( slmax - slmin ) / 10 without overflowing ints: | 751 | // calculate ( slmax - slmin ) / 10 without overflowing ints: |
@@ -907,27 +910,27 @@ public: | |||
907 | 910 | ||
908 | int mPrecision; | 911 | int mPrecision; |
909 | KDoubleValidator * mValidator; | 912 | KDoubleValidator * mValidator; |
910 | }; | 913 | }; |
911 | 914 | ||
912 | KDoubleSpinBox::KDoubleSpinBox( QWidget * parent, const char * name ) | 915 | KDoubleSpinBox::KDoubleSpinBox( QWidget * parent, const char * name ) |
913 | : QSpinBox( parent, name ) | 916 | : QSpinBox( parent, name ) |
914 | { | 917 | { |
915 | editor()->setAlignment( Qt::AlignRight ); | 918 | setAlignment( Qt::AlignRight ); |
916 | d = new Private(); | 919 | d = new Private(); |
917 | updateValidator(); | 920 | updateValidator(); |
918 | } | 921 | } |
919 | 922 | ||
920 | KDoubleSpinBox::KDoubleSpinBox( double lower, double upper, double step, | 923 | KDoubleSpinBox::KDoubleSpinBox( double lower, double upper, double step, |
921 | double value, int precision, | 924 | double value, int precision, |
922 | QWidget * parent, const char * name ) | 925 | QWidget * parent, const char * name ) |
923 | : QSpinBox( parent, name ) | 926 | : QSpinBox( parent, name ) |
924 | { | 927 | { |
925 | editor()->setAlignment( Qt::AlignRight ); | 928 | setAlignment( Qt::AlignRight ); |
926 | d = new Private(); | 929 | d = new Private(); |
927 | setRange( lower, upper, step, precision ); | 930 | setRange( lower, upper, step, precision ); |
928 | setValue( value ); | 931 | setValue( value ); |
929 | connect( this, SIGNAL(valueChanged(int)), SLOT(slotValueChanged(int)) ); | 932 | connect( this, SIGNAL(valueChanged(int)), SLOT(slotValueChanged(int)) ); |
930 | } | 933 | } |
931 | 934 | ||
932 | KDoubleSpinBox::~KDoubleSpinBox() { | 935 | KDoubleSpinBox::~KDoubleSpinBox() { |
933 | delete d; d = 0; | 936 | delete d; d = 0; |
@@ -1022,17 +1025,17 @@ void KDoubleSpinBox::setMaxValue( double value ) { | |||
1022 | bool ok = false; | 1025 | bool ok = false; |
1023 | int max = d->mapToInt( value, &ok ); | 1026 | int max = d->mapToInt( value, &ok ); |
1024 | if ( !ok ) return; | 1027 | if ( !ok ) return; |
1025 | base::setMaxValue( max ); | 1028 | base::setMaxValue( max ); |
1026 | updateValidator(); | 1029 | updateValidator(); |
1027 | } | 1030 | } |
1028 | 1031 | ||
1029 | double KDoubleSpinBox::lineStep() const { | 1032 | double KDoubleSpinBox::lineStep() const { |
1030 | return d->mapToDouble( base::lineStep() ); | 1033 | return d->mapToDouble( base::singleStep() ); |
1031 | } | 1034 | } |
1032 | 1035 | ||
1033 | void KDoubleSpinBox::setLineStep( double step ) { | 1036 | void KDoubleSpinBox::setLineStep( double step ) { |
1034 | bool ok = false; | 1037 | bool ok = false; |
1035 | if ( step > maxValue() - minValue() ) | 1038 | if ( step > maxValue() - minValue() ) |
1036 | base::setLineStep( 1 ); | 1039 | base::setLineStep( 1 ); |
1037 | else | 1040 | else |
1038 | base::setLineStep( kMax( d->mapToInt( step, &ok ), 1 ) ); | 1041 | base::setLineStep( kMax( d->mapToInt( step, &ok ), 1 ) ); |
@@ -1067,17 +1070,17 @@ void KDoubleSpinBox::setValidator( const QValidator * ) { | |||
1067 | void KDoubleSpinBox::slotValueChanged( int value ) { | 1070 | void KDoubleSpinBox::slotValueChanged( int value ) { |
1068 | emit valueChanged( d->mapToDouble( value ) ); | 1071 | emit valueChanged( d->mapToDouble( value ) ); |
1069 | } | 1072 | } |
1070 | 1073 | ||
1071 | void KDoubleSpinBox::updateValidator() { | 1074 | void KDoubleSpinBox::updateValidator() { |
1072 | if ( !d->mValidator ) { | 1075 | if ( !d->mValidator ) { |
1073 | d->mValidator = new KDoubleValidator( minValue(), maxValue(), precision(), | 1076 | d->mValidator = new KDoubleValidator( minValue(), maxValue(), precision(), |
1074 | this, "d->mValidator" ); | 1077 | this, "d->mValidator" ); |
1075 | base::setValidator( d->mValidator ); | 1078 | lineEdit()->setValidator( d->mValidator ); |
1076 | } else | 1079 | } else |
1077 | d->mValidator->setRange( minValue(), maxValue(), precision() ); | 1080 | d->mValidator->setRange( minValue(), maxValue(), precision() ); |
1078 | } | 1081 | } |
1079 | 1082 | ||
1080 | void KNumInput::virtual_hook( int, void* ) | 1083 | void KNumInput::virtual_hook( int, void* ) |
1081 | { /*BASE::virtual_hook( id, data );*/ } | 1084 | { /*BASE::virtual_hook( id, data );*/ } |
1082 | 1085 | ||
1083 | void KIntNumInput::virtual_hook( int id, void* data ) | 1086 | void KIntNumInput::virtual_hook( int id, void* data ) |