• 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
abstractvalue8editor.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 "abstractvalue8editor.h"
24 
25 // Okteta core
26 #include <valuecodec.h>
27 // C++
28 #include <limits>
29 
30 
31 AbstractValue8Editor::AbstractValue8Editor( Okteta::ValueCoding valueCoding, QWidget* parent )
32  : QSpinBox( parent )
33 {
34  const quint8 int8Max = std::numeric_limits<quint8>::max();
35  const quint8 int8Min = std::numeric_limits<quint8>::min();
36 
37  setRange( int8Min, int8Max );
38 
39  mValueCodec = Okteta::ValueCodec::createCodec( valueCoding );
40 }
41 
42 QString AbstractValue8Editor::textFromValue( int value ) const
43 {
44  QString result;
45 
46  mValueCodec->encodeShort( result, 0, (Okteta::Byte)value );
47 
48  return result;
49 }
50 
51 int AbstractValue8Editor::valueFromText( const QString& text ) const
52 {
53  Okteta::Byte byte;
54  mValueCodec->decode( &byte, text );
55 
56  return byte;
57 }
58 
59 QValidator::State AbstractValue8Editor::validate( QString& text, int& pos ) const
60 {
61  Q_UNUSED( pos );
62 
63  Okteta::Byte byte;
64  const int textLength = text.length();
65  const int usedChars = mValueCodec->decode( &byte, text );
66 
67  const bool isCompleteTextUsed = ( textLength == usedChars );
68 
69  return isCompleteTextUsed ? QValidator::Acceptable : QValidator::Invalid;
70 }
71 
72 AbstractValue8Editor::~AbstractValue8Editor()
73 {
74  delete mValueCodec;
75 }
Okteta::ValueCodec::createCodec
static ValueCodec * createCodec(ValueCoding valueCoding)
Definition: valuecodec.cpp:36
Okteta::ValueCodec::decode
unsigned int decode(Byte *byte, const QString &text, unsigned int pos=0) const
Tries to decode the digits in the text into a byte.
Definition: valuecodec.cpp:50
abstractvalue8editor.h
AbstractValue8Editor::textFromValue
virtual QString textFromValue(int value) const
Definition: abstractvalue8editor.cpp:42
QWidget
AbstractValue8Editor::mValueCodec
Okteta::ValueCodec * mValueCodec
Definition: abstractvalue8editor.h:54
Okteta::Byte
unsigned char Byte
Definition: byte.h:29
AbstractValue8Editor::validate
virtual QValidator::State validate(QString &text, int &pos) const
Definition: abstractvalue8editor.cpp:59
Okteta::ValueCodec::encodeShort
virtual void encodeShort(QString &digits, unsigned int pos, Byte byte) const =0
Encodes the byte and writes the result to digits, no leading 0s.
valuecodec.h
Okteta::ValueCoding
ValueCoding
Definition: oktetacore.h:34
QSpinBox
AbstractValue8Editor::valueFromText
virtual int valueFromText(const QString &text) const
Definition: abstractvalue8editor.cpp:51
AbstractValue8Editor::~AbstractValue8Editor
virtual ~AbstractValue8Editor()
Definition: abstractvalue8editor.cpp:72
AbstractValue8Editor::AbstractValue8Editor
AbstractValue8Editor(Okteta::ValueCoding valueCoding, QWidget *parent=0)
Definition: abstractvalue8editor.cpp:31
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:04:06 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