• 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
  • structures
  • datatypes
  • primitive
enumdatainformation.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of the Okteta Kasten Framework, made within the KDE community.
3  *
4  * Copyright 2009, 2010, 2011, 2012 Alex Richardson <alex.richardson@gmx.de>
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 "enumdatainformation.h"
24 #include "../topleveldatainformation.h"
25 
26 #include <KLocalizedString>
27 #include <QScriptValue>
28 
29 #include "../../script/classes/enumscriptclass.h"
30 #include "../../script/scriptlogger.h"
31 
32 EnumDataInformation::EnumDataInformation(const QString& name, PrimitiveDataInformation* type,
33  EnumDefinition::Ptr enumDef, DataInformation* parent)
34  : PrimitiveDataInformationWrapper(name, type, parent), mEnum(enumDef)
35 {
36  Q_CHECK_PTR(type);
37  if (enumDef->type() != type->type())
38  logWarn() << "incompatible types in definition and value: "
39  << enumDef->type() << "and " << type->type();
40  mValue->setParent(this);
41 }
42 
43 EnumDataInformation::~EnumDataInformation() {}
44 
45 QString EnumDataInformation::valueStringImpl() const
46 {
47  Q_ASSERT(mWasAbleToRead);
48  QString enumVal = mEnum->value(mValue->value());
49  if (!enumVal.isEmpty())
50  {
51  return i18n("%1 (%2)", enumVal, mValue->valueString());
52  }
53  else
54  return i18n("%1 (value not in enum)", mValue->valueString());
55 }
56 
57 QString EnumDataInformation::typeNameImpl() const
58 {
59  return i18nc("Displayed in the type column. first comes the name "
60  "of the enum, then the underlying type (e.g. uint32)",
61  "enum %1 (%2)", mEnum->name(), mValue->typeName());
62 }
63 
64 QScriptClass* EnumDataInformation::scriptClass(ScriptHandlerInfo* handlerInfo) const
65 {
66  return handlerInfo->mEnumClass.data();
67 }
DataInformation
Interface that must be implemented by all datatypes.
Definition: datainformation.h:67
enumdatainformation.h
QScriptClass
PrimitiveDataInformation::type
virtual PrimitiveDataType type() const =0
EnumDefinition::Ptr
QSharedDataPointer< EnumDefinition > Ptr
Definition: enumdefinition.h:40
DataInformation::mWasAbleToRead
bool mWasAbleToRead
Definition: datainformation.h:243
PrimitiveDataInformationWrapper::mValue
QScopedPointer< PrimitiveDataInformation > mValue
Definition: primitivedatainformation.h:116
EnumDataInformation::~EnumDataInformation
virtual ~EnumDataInformation()
Definition: enumdatainformation.cpp:43
PrimitiveDataInformationWrapper
A base class for data types which just wrap an underlying primitive data type.
Definition: primitivedatainformation.h:76
ScriptHandlerInfo::mEnumClass
QScopedPointer< EnumScriptClass > mEnumClass
Definition: scripthandlerinfo.h:52
ScriptHandlerInfo
Definition: scripthandlerinfo.h:39
EnumDataInformation::mEnum
EnumDefinition::Ptr mEnum
Definition: enumdatainformation.h:47
PrimitiveDataInformation
A base class for all primitive data elements (e.g.
Definition: primitivedatainformation.h:34
DataInformation::logWarn
QDebug logWarn() const
just a shorthand for logger->warn(this)
Definition: datainformation.h:319
EnumDataInformation::EnumDataInformation
EnumDataInformation(const QString &name, PrimitiveDataInformation *type, EnumDefinition::Ptr enumDef, DataInformation *parent=0)
this object takes ownership of type
Definition: enumdatainformation.cpp:32
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:04:08 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