• 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.h
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 #ifndef SINTSPINBOX_H
24 #define SINTSPINBOX_H
25 
26 // Qt
27 #include <QtGui/QAbstractSpinBox>
28 // C++
29 #include <limits>
30 
31 
32 class SIntSpinBox : public QAbstractSpinBox
33 {
34  public:
35  explicit SIntSpinBox( QWidget* parent = 0, int base = 10 );
36 
37  virtual ~SIntSpinBox();
38 
39  public:
40  qint64 value() const;
41 
42  public:
43  void setValue( qint64 value );
44 
45  void setRange( qint64 minimum, qint64 maximum );
46  void setBase( int base );
47 
48  protected: // QAbstractSpinBox API
49  virtual QValidator::State validate( QString& input, int& pos ) const;
50  virtual void stepBy( int steps );
51  virtual void fixup( QString& input ) const;
52  virtual StepEnabled stepEnabled () const;
53 
54  protected:
55  void updateEditLine() const;
56 
57  protected:
58  mutable qint64 mValue;
59 
60  qint64 mMinimum;
61  qint64 mMaximum;
62  int mBase;
63 
64  QString mPrefix;
65 };
66 
67 
68 inline SIntSpinBox::SIntSpinBox( QWidget *parent, int base)
69  : QAbstractSpinBox( parent ),
70  mValue( 0 ),
71  mMinimum( std::numeric_limits<qint64>::min() ),
72  mMaximum( std::numeric_limits<qint64>::max() ),
73  mBase(0)
74 {
75  setBase( base );
76 }
77 
78 inline qint64 SIntSpinBox::value() const { return mValue; }
79 
80 inline void SIntSpinBox::setValue( qint64 value )
81 {
82  if( value > mMaximum )
83  value = mMaximum;
84  else if( value < mMinimum )
85  value = mMinimum;
86 
87  if( mValue == value )
88  return;
89 
90  mValue = value;
91 
92  updateEditLine();
93 }
94 
95 inline void SIntSpinBox::setRange( qint64 minimum, qint64 maximum )
96 {
97  mMinimum = minimum;
98  mMaximum = (maximum>minimum) ? maximum : minimum;
99 
100  if( mValue > mMaximum )
101  {
102  mValue = mMaximum;
103 
104  updateEditLine();
105  }
106  else if( mValue < mMinimum )
107  {
108  mValue = mMinimum;
109 
110  updateEditLine();
111  }
112 }
113 
114 inline void SIntSpinBox::setBase( int base )
115 {
116  base = qBound( 2, base, 36 );
117 
118  if( mBase == base )
119  return;
120 
121  mBase = base;
122  mPrefix = QString::fromLatin1(
123  (base == 16) ? "0x" :
124  (base == 8) ? "0o" :
125  (base == 2) ? "0b" :
126  /* else */ 0 );
127 }
128 
129 inline SIntSpinBox::~SIntSpinBox() {}
130 
131 #endif
SIntSpinBox::value
qint64 value() const
Definition: sintspinbox.h:78
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::setRange
void setRange(qint64 minimum, qint64 maximum)
Definition: sintspinbox.h:95
QWidget
SIntSpinBox::~SIntSpinBox
virtual ~SIntSpinBox()
Definition: sintspinbox.h:129
SIntSpinBox::fixup
virtual void fixup(QString &input) const
Definition: sintspinbox.cpp:60
SIntSpinBox
Definition: sintspinbox.h:32
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::mPrefix
QString mPrefix
Definition: sintspinbox.h:64
SIntSpinBox::setBase
void setBase(int base)
Definition: sintspinbox.h:114
QAbstractSpinBox
SIntSpinBox::SIntSpinBox
SIntSpinBox(QWidget *parent=0, int base=10)
Definition: sintspinbox.h:68
SIntSpinBox::setValue
void setValue(qint64 value)
Definition: sintspinbox.h:80
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