• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdesdk API Reference
  • KDE Home
  • Contact Us
 

okteta

  • sources
  • kde-4.12
  • kdesdk
  • okteta
  • kasten
  • controllers
  • view
  • poddecoder
  • typeeditors
sintspinbox.cpp
Go to the documentation of this file.
1 /*
2  This file is part of the Okteta Kasten module, made within the KDE community.
3 
4  Copyright 2009 Friedrich W. H. Kossebau <kossebau@kde.org>
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Lesser General Public
8  License as published by the Free Software Foundation; either
9  version 2.1 of the License, or (at your option) version 3, or any
10  later version accepted by the membership of KDE e.V. (or its
11  successor approved by the membership of KDE e.V.), which shall
12  act as a proxy defined in Section 6 of version 3 of the license.
13 
14  This library is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  Lesser General Public License for more details.
18 
19  You should have received a copy of the GNU Lesser General Public
20  License along with this library. If not, see <http://www.gnu.org/licenses/>.
21 */
22 
23 #include "sintspinbox.h"
24 
25 // Qt
26 #include <QtGui/QLineEdit>
27 
28 
29 QValidator::State SIntSpinBox::validate( QString& input, int& pos ) const
30 {
31  Q_UNUSED( pos );
32 
33  QValidator::State result;
34 
35  if( input.isEmpty()
36  || (mMinimum < 0 && input == QLatin1String("-")) )
37  {
38  mValue = 0;
39  result = QValidator::Intermediate;
40  }
41  else
42  {
43  bool ok;
44  qint64 newValue = input.toLongLong( &ok );
45  if( !ok
46  || (newValue > mMaximum)
47  || (newValue < mMinimum) )
48  result = QValidator::Invalid;
49  else
50  {
51  mValue = newValue;
52  result = QValidator::Acceptable;
53  }
54  }
55 
56  return result;
57 }
58 
59 
60 void SIntSpinBox::fixup( QString& input ) const
61 {
62  Q_UNUSED( input );
63 
64  // TODO: what can be done here? remove localized stuff?
65 }
66 
67 void SIntSpinBox::stepBy( int steps )
68 {
69  if( steps == 0 )
70  return;
71 
72  if( steps > 0 )
73  {
74  const qint64 left = mMaximum - mValue;
75  mValue = ( static_cast<qint64>(steps) > left ) ? mMaximum : mValue + steps;
76  }
77  else
78  {
79  const qint64 left = mValue - mMinimum;
80  mValue = ( static_cast<qint64>(-steps) > left ) ? mMinimum : mValue + steps;
81  }
82 
83  updateEditLine();
84 }
85 
86 QAbstractSpinBox::StepEnabled SIntSpinBox::stepEnabled() const
87 {
88  StepEnabled result;
89 
90  if( mValue > mMinimum )
91  result |= StepDownEnabled;
92  if( mValue < mMaximum )
93  result |= StepUpEnabled;
94 
95  return result;
96 }
97 
98 
99 void SIntSpinBox::updateEditLine() const
100 {
101  const QString text = QString::number( mValue, mBase );
102  lineEdit()->setText( text );
103 }
SIntSpinBox::stepBy
virtual void stepBy(int steps)
Definition: sintspinbox.cpp:67
SIntSpinBox::validate
virtual QValidator::State validate(QString &input, int &pos) const
Definition: sintspinbox.cpp:29
sintspinbox.h
SIntSpinBox::fixup
virtual void fixup(QString &input) const
Definition: sintspinbox.cpp:60
SIntSpinBox::mValue
qint64 mValue
Definition: sintspinbox.h:58
SIntSpinBox::stepEnabled
virtual StepEnabled stepEnabled() const
Definition: sintspinbox.cpp:86
SIntSpinBox::mBase
int mBase
Definition: sintspinbox.h:62
SIntSpinBox::updateEditLine
void updateEditLine() const
Definition: sintspinbox.cpp:99
SIntSpinBox::mMaximum
qint64 mMaximum
Definition: sintspinbox.h:61
SIntSpinBox::mMinimum
qint64 mMinimum
Definition: sintspinbox.h:60
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:04:09 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

okteta

Skip menu "okteta"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdesdk API Reference

Skip menu "kdesdk API Reference"
  • kapptemplate
  • kcachegrind
  • kompare
  • lokalize
  • okteta
  • umbrello
  •   umbrello

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal