• 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
  • gui
  • io
  • streamencoder
  • sourcecode
bytearraysourcecodestreamencoderconfigeditor.cpp
Go to the documentation of this file.
1 /*
2  This file is part of the Kasten Framework, made within the KDE community.
3 
4  Copyright 2008 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 "bytearraysourcecodestreamencoderconfigeditor.h"
24 
25 // lib
26 #include "bytearraytextstreamencoderpreview.h"
27 // KDE
28 #include <KLocale>
29 #include <KLineEdit>
30 #include <KIntNumInput>
31 #include <KComboBox>
32 // Qt
33 #include <QtGui/QFormLayout>
34 #include <QtGui/QCheckBox>
35 
36 
37 namespace Kasten2
38 {
39 
40 ByteArraySourceCodeStreamEncoderConfigEditor::ByteArraySourceCodeStreamEncoderConfigEditor( ByteArraySourceCodeStreamEncoder* encoder, QWidget* parent )
41  : AbstractModelStreamEncoderConfigEditor( parent ),
42  mEncoder( encoder )
43 {
44  mSettings = mEncoder->settings();
45 
46  QFormLayout* pageLayout = new QFormLayout( this );
47  pageLayout->setMargin( 0 );
48 
49  // variable name
50  const QString variableNameLabel =
51  i18nc( "@label:textbox name of the created variable",
52  "Name of variable:" );
53 
54  mVariableNameEdit = new KLineEdit( this );
55  mVariableNameEdit->setText( mSettings.variableName );
56  connect( mVariableNameEdit, SIGNAL(textChanged(QString)), SLOT(onSettingsChanged()) );
57  pageLayout->addRow( variableNameLabel, mVariableNameEdit );
58 
59  // items per line
60  const QString itemsPerLineLabel =
61  i18nc( "@label:textbox to define after how many items the list is wrapped",
62  "Items per line:" );
63 
64  mItemsPerLineEdit = new KIntNumInput( this );
65  mItemsPerLineEdit->setMinimum( 1 );
66  mItemsPerLineEdit->setValue( mSettings.elementsPerLine );
67  connect( mItemsPerLineEdit, SIGNAL(valueChanged(int)), SLOT(onSettingsChanged()) );
68  pageLayout->addRow( itemsPerLineLabel, mItemsPerLineEdit );
69 
70  // data type
71  const QString dataTypeLabel =
72  i18nc( "@label:listbox the type of the data: char, integer, etc.",
73  "Data type:" );
74 
75  mDataTypeSelect = new KComboBox( this );
76  const char* const* dataTypeNames = mEncoder->dataTypeNames();
77  const int dataTypesCount = mEncoder->dataTypesCount();
78  QStringList dataTypeNameStrings;
79  for( int i=0; i<dataTypesCount; ++i )
80  dataTypeNameStrings << QLatin1String(dataTypeNames[i]);
81  mDataTypeSelect->addItems( dataTypeNameStrings );
82  mDataTypeSelect->setCurrentIndex( mSettings.dataType );
83  connect( mDataTypeSelect, SIGNAL(activated(int)), SLOT(onSettingsChanged()) );
84  pageLayout->addRow( dataTypeLabel, mDataTypeSelect );
85 
86  // unsigned as hexadezimal
87  const QString unsignedAsHexadecimalLabel =
88  i18nc( "@option:check Encode the values in hexadecimal instead of decimal, "
89  "if the datatype has the property Unsigned",
90  "Unsigned as hexadecimal:" );
91 
92  mUnsignedAsHexadecimalCheck = new QCheckBox( this );
93  mUnsignedAsHexadecimalCheck->setChecked( mSettings.unsignedAsHexadecimal );
94  connect( mUnsignedAsHexadecimalCheck, SIGNAL(toggled(bool)), SLOT(onSettingsChanged()) );
95  pageLayout->addRow( unsignedAsHexadecimalLabel, mUnsignedAsHexadecimalCheck );
96 }
97 
98 bool ByteArraySourceCodeStreamEncoderConfigEditor::isValid() const
99 {
100  return true; // TODO: warn if not all selected bytes are used due to the data type length
101 }
102 
103 AbstractSelectionView* ByteArraySourceCodeStreamEncoderConfigEditor::createPreviewView() const
104 {
105  return new ByteArrayTextStreamEncoderPreview( mEncoder );
106 }
107 
108 void ByteArraySourceCodeStreamEncoderConfigEditor::onSettingsChanged()
109 {
110  mSettings.variableName = mVariableNameEdit->text();
111  mSettings.elementsPerLine = mItemsPerLineEdit->value();
112  mSettings.dataType = mDataTypeSelect->currentIndex();
113  mSettings.unsignedAsHexadecimal = mUnsignedAsHexadecimalCheck->isChecked();
114  mEncoder->setSettings( mSettings );
115 }
116 
117 ByteArraySourceCodeStreamEncoderConfigEditor::~ByteArraySourceCodeStreamEncoderConfigEditor()
118 {
119 }
120 
121 }
Kasten2::AbstractSelectionView
Definition: abstractselectionview.h:41
Kasten2::ByteArraySourceCodeStreamEncoderConfigEditor::ByteArraySourceCodeStreamEncoderConfigEditor
ByteArraySourceCodeStreamEncoderConfigEditor(ByteArraySourceCodeStreamEncoder *encoder, QWidget *parent=0)
Definition: bytearraysourcecodestreamencoderconfigeditor.cpp:40
QWidget
Kasten2::AbstractModelStreamEncoderConfigEditor
Definition: abstractmodelstreamencoderconfigeditor.h:38
Kasten2::SourceCodeStreamEncoderSettings::dataType
int dataType
Definition: bytearraysourcecodestreamencoder.h:55
Kasten2::ByteArraySourceCodeStreamEncoder::dataTypesCount
int dataTypesCount() const
Definition: bytearraysourcecodestreamencoder.cpp:73
Kasten2::ByteArraySourceCodeStreamEncoderConfigEditor::mVariableNameEdit
KLineEdit * mVariableNameEdit
Definition: bytearraysourcecodestreamencoderconfigeditor.h:59
Kasten2::SourceCodeStreamEncoderSettings::elementsPerLine
int elementsPerLine
Definition: bytearraysourcecodestreamencoder.h:56
Kasten2::ByteArraySourceCodeStreamEncoderConfigEditor::isValid
virtual bool isValid() const
default returns true
Definition: bytearraysourcecodestreamencoderconfigeditor.cpp:98
bytearraytextstreamencoderpreview.h
Kasten2::ByteArrayTextStreamEncoderPreview
Definition: bytearraytextstreamencoderpreview.h:42
Kasten2::ByteArraySourceCodeStreamEncoderConfigEditor::createPreviewView
virtual AbstractSelectionView * createPreviewView() const
default returns none
Definition: bytearraysourcecodestreamencoderconfigeditor.cpp:103
Kasten2::ByteArraySourceCodeStreamEncoderConfigEditor::mItemsPerLineEdit
KIntNumInput * mItemsPerLineEdit
Definition: bytearraysourcecodestreamencoderconfigeditor.h:60
Kasten2::ByteArraySourceCodeStreamEncoderConfigEditor::mDataTypeSelect
KComboBox * mDataTypeSelect
Definition: bytearraysourcecodestreamencoderconfigeditor.h:61
bytearraysourcecodestreamencoderconfigeditor.h
Kasten2::ByteArraySourceCodeStreamEncoderConfigEditor::mUnsignedAsHexadecimalCheck
QCheckBox * mUnsignedAsHexadecimalCheck
Definition: bytearraysourcecodestreamencoderconfigeditor.h:62
Kasten2::ByteArraySourceCodeStreamEncoderConfigEditor::mEncoder
ByteArraySourceCodeStreamEncoder * mEncoder
Definition: bytearraysourcecodestreamencoderconfigeditor.h:56
Kasten2::ByteArraySourceCodeStreamEncoderConfigEditor::onSettingsChanged
void onSettingsChanged()
Definition: bytearraysourcecodestreamencoderconfigeditor.cpp:108
Kasten2::SourceCodeStreamEncoderSettings::unsignedAsHexadecimal
bool unsignedAsHexadecimal
Definition: bytearraysourcecodestreamencoder.h:57
KLineEdit
Kasten2::ByteArraySourceCodeStreamEncoder::setSettings
void setSettings(const SourceCodeStreamEncoderSettings &settings)
Definition: bytearraysourcecodestreamencoder.h:94
Kasten2::ByteArraySourceCodeStreamEncoderConfigEditor::~ByteArraySourceCodeStreamEncoderConfigEditor
virtual ~ByteArraySourceCodeStreamEncoderConfigEditor()
Definition: bytearraysourcecodestreamencoderconfigeditor.cpp:117
Kasten2::SourceCodeStreamEncoderSettings::variableName
QString variableName
Definition: bytearraysourcecodestreamencoder.h:54
Kasten2::ByteArraySourceCodeStreamEncoderConfigEditor::mSettings
SourceCodeStreamEncoderSettings mSettings
Definition: bytearraysourcecodestreamencoderconfigeditor.h:57
Kasten2::ByteArraySourceCodeStreamEncoder::dataTypeNames
const char *const * dataTypeNames() const
Definition: bytearraysourcecodestreamencoder.cpp:72
Kasten2::ByteArraySourceCodeStreamEncoder::settings
SourceCodeStreamEncoderSettings settings() const
Definition: bytearraysourcecodestreamencoder.h:93
Kasten2::ByteArraySourceCodeStreamEncoder
Definition: bytearraysourcecodestreamencoder.h:63
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:04:07 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