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