~ubuntu-branches/ubuntu/oneiric/kdesdk/oneiric-updates

« back to all changes in this revision

Viewing changes to okteta/kasten/controllers/view/viewprofiles/viewprofileedit.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Debian Qt/KDE Maintainers, Modestas Vainius, George Kiagiadakis, José Manuel Santamaría Lema, Pino Toscano
  • Date: 2011-04-27 12:23:44 UTC
  • mfrom: (1.1.58 upstream) (0.5.7 squeeze)
  • mto: (0.5.8 sid)
  • mto: This revision was merged to the branch mainline in revision 120.
  • Revision ID: james.westby@ubuntu.com-20110427122344-t9d1jf4lfnrl6hyv
Tags: 4:4.6.2-1
* New upstream release:
  - fixes plugin loading in kate sessions (Closes: #525853)
  - updates kate man page with respect to instance creation defaults
    (Closes: #598443)
  - fixes cursor position with static word-wrap in Kate (Closes: #570409)
  - xml2pot creates .pot files with the correct mimetype (Closes: #326060)
* Update installed files.
* Update lintian overrides.

[ Modestas Vainius ]
* Point debian/control Vcs fields to the new Git repository.
* Strip sequence numbers from debian/patches.
* Strip trailing whitespace in debian/copyright.
* Add kdeutils-dbg (<< 4:4.6) to kdesdk-dbg Breaks/Replaces (due to moved
  okteta).
* Add ${perl:Depends} to Depends of cervisia and kdesdk-kio-plugins.

[ George Kiagiadakis ]
* Add myself to uploaders.
* Refresh patch 02_append_kde.diff.
* Drop patch 03_kmtrace_compile.diff; fixed upstream in a better way.
* Add libkonq5-dev, libantlr-dev and antlr to build depends.
  (Closes: #505425)
* Bump kdepimlibs5-dev build dependency to version 4:4.6.
* Add new package: kdesdk-dolphin-plugins.

[ José Manuel Santamaría Lema ]
* Remove package kbugbuster.
* Enable DebianABIManager:
  - include DebianABIManager.cmake at the bottom of the main CMakeLists.txt
    (patch enable_debianabimanager.diff).
  - debian/control: managing all non-local unstable-BC libraries.
* Add packages for okteta:
  - okteta
  - okteta-dev
  - libkastencontrollers4
  - libkastencore4
  - libkastengui4
  - liboktetacore4
  - liboktetagui4
  - liboktetakastencontrollers4
  - liboktetakastencore4
  - liboktetakastengui4
* Add symbols files for new library packages.
* Bump kde-sc-dev-latest build dependency to 4:4.6.2.
* Bump pkg-kde-tools build dependency to 0.12.
* Switch debian/rules engine to dhmk based qt-kde-team/2/*
  - and remove cdbs from Build-Depends.
* Bump S-V to 3.9.1; update Replaces/Breaks/Conflicts.
* Add myself to Uploaders.

[ Pino Toscano ]
* Add build dependency on libqca2-dev.
* Do not ship kdesrc-build with kdesdk-scripts, it is packaged separately.
* Small updates to descriptions.
* Clean up Replaces/Breaks from the pre-squeeze era whenever possible.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    This file is part of the Okteta Kasten module, part of the KDE project.
 
3
 
 
4
    Copyright 2010 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 "viewprofileedit.h"
 
24
 
 
25
// Okteta Gui Kasten
 
26
#include <bytearrayviewprofile.h>
 
27
// Okteta core
 
28
#include <charcodec.h>
 
29
// KDE
 
30
#include <KLocale>
 
31
#include <KIntNumInput>
 
32
#include <KComboBox>
 
33
// Qt
 
34
#include <QtGui/QVBoxLayout>
 
35
#include <QtGui/QGroupBox>
 
36
#include <QtGui/QFormLayout>
 
37
#include <QtGui/QCheckBox>
 
38
#include <KLineEdit>
 
39
 
 
40
namespace Kasten
 
41
{
 
42
 
 
43
static int
 
44
listIndexFromByteArrayCodingsFlags( int byteArrayCodingsFlags )
 
45
{
 
46
    return byteArrayCodingsFlags - 1;
 
47
}
 
48
 
 
49
static int
 
50
byteArrayCodingsFlagsFromListIndex( int listIndex )
 
51
{
 
52
    return listIndex + 1;
 
53
}
 
54
 
 
55
 
 
56
ViewProfileEdit::ViewProfileEdit( QWidget* parent )
 
57
  : QWidget( parent )
 
58
{
 
59
    QVBoxLayout* layout = new QVBoxLayout( this );
 
60
 
 
61
    // titel
 
62
    QFormLayout* titleFormLayout = new QFormLayout;
 
63
    // char for non-printable bytes
 
64
    mTitleEdit = new KLineEdit( this );
 
65
    titleFormLayout->addRow( i18n("Title:"), mTitleEdit );
 
66
 
 
67
    // display settings
 
68
    QGroupBox* displayBox = new QGroupBox( this );
 
69
    displayBox->setTitle( i18n("Display") );
 
70
    QFormLayout* displayBoxFormLayout = new QFormLayout( displayBox );
 
71
    // line offset shown
 
72
    mLineOffsetShownCheckBox = new QCheckBox( displayBox );
 
73
    displayBoxFormLayout->addRow( i18n("Show Line Offset:"), mLineOffsetShownCheckBox );
 
74
    // values or char shown
 
75
    mValuesCharsShownComboBox = new KComboBox( displayBox );
 
76
    QStringList valuesCharsList;
 
77
    valuesCharsList.append( i18nc("@item:","Values") );
 
78
    valuesCharsList.append( i18nc("@item:","Chars") );
 
79
    valuesCharsList.append( i18nc("@item:","Values & Chars") );
 
80
    mValuesCharsShownComboBox->addItems( valuesCharsList );
 
81
    displayBoxFormLayout->addRow( i18n("Show Values or Chars:"), mValuesCharsShownComboBox );
 
82
    // display mode
 
83
    const QString displayModeLabel =
 
84
        i18nc( "@label:listbox ",
 
85
               "Show with Rows or Columns::" );
 
86
    mDisplayModeComboBox = new KComboBox( displayBox );
 
87
    QStringList displayModeList;
 
88
    displayModeList.append( i18nc("@item:","Columns") );
 
89
    displayModeList.append( i18nc("@item:","Rows") );
 
90
    mDisplayModeComboBox->addItems( displayModeList );
 
91
    displayBoxFormLayout->addRow( displayModeLabel, mDisplayModeComboBox );
 
92
 
 
93
    // layout settings
 
94
    QGroupBox* layoutBox = new QGroupBox( this );
 
95
    layoutBox->setTitle( i18n("Layout") );
 
96
    QFormLayout* layoutBoxFormLayout = new QFormLayout( layoutBox );
 
97
    // line break
 
98
    mLineBreakComboBox = new KComboBox( layoutBox );
 
99
    QStringList lineBreakList;
 
100
    lineBreakList.append( i18nc("@item:inmenu  The layout will not change on size changes.",
 
101
                                "Off") );
 
102
    lineBreakList.append( i18nc("@item:inmenu  The layout will adapt to the size, but only with complete groups of bytes.",
 
103
                                "Wrap Only Complete Byte Groups") );
 
104
    lineBreakList.append( i18nc("@item:inmenu  The layout will adapt to the size and fit in as much bytes per line as possible.",
 
105
                                "On") );
 
106
    mLineBreakComboBox->addItems( lineBreakList );
 
107
    connect( mLineBreakComboBox, SIGNAL(currentIndexChanged(int)),
 
108
             SLOT(onLineBreakIndexChanged(int)) );
 
109
    layoutBoxFormLayout->addRow( i18n("Break lines:"), mLineBreakComboBox );
 
110
    // bytes per group
 
111
    mGroupedBytesCountEdit = new KIntNumInput( this );
 
112
    mGroupedBytesCountEdit->setRange( 0, INT_MAX );
 
113
    mGroupedBytesCountEdit->setSuffix( ki18np(" byte"," bytes") );
 
114
    const QString noGroupingText = i18nc( "@label",
 
115
                                          "No grouping." );
 
116
    mGroupedBytesCountEdit->setSpecialValueText( noGroupingText );
 
117
    const QString groupedBytesCountLabel =
 
118
        i18nc( "@label:spinbox number of bytes which are grouped",
 
119
               "Bytes per Group:" );
 
120
    layoutBoxFormLayout->addRow( groupedBytesCountLabel, mGroupedBytesCountEdit );
 
121
    // bytes per group
 
122
    mBytesPerLineEdit = new KIntNumInput( this );
 
123
    mBytesPerLineEdit->setRange( 1, INT_MAX );
 
124
    mBytesPerLineEdit->setSuffix( ki18np(" byte"," bytes") );
 
125
    const QString bytesPerLineLabel =
 
126
        i18nc( "@label:spinbox number of bytes which are shown per line",
 
127
                "Bytes per Line:" );
 
128
    layoutBoxFormLayout->addRow( bytesPerLineLabel, mBytesPerLineEdit );
 
129
 
 
130
    // value settings
 
131
    QGroupBox* valuesBox = new QGroupBox( this );
 
132
    valuesBox->setTitle( i18n("Values") );
 
133
    QFormLayout* valuesBoxFormLayout = new QFormLayout( valuesBox );
 
134
    // coding
 
135
    mValueCodingComboBox = new KComboBox( valuesBox );
 
136
    QStringList valueCodingList;
 
137
    valueCodingList.append( i18nc("@item:inmenu encoding of the bytes as values in the hexadecimal format","Hexadecimal") );
 
138
    valueCodingList.append( i18nc("@item:inmenu encoding of the bytes as values in the decimal format",    "Decimal")     );
 
139
    valueCodingList.append( i18nc("@item:inmenu encoding of the bytes as values in the octal format",      "Octal")       );
 
140
    valueCodingList.append( i18nc("@item:inmenu encoding of the bytes as values in the binary format",     "Binary")      );
 
141
    mValueCodingComboBox->addItems( valueCodingList );
 
142
    valuesBoxFormLayout->addRow( i18n("Coding:"), mValueCodingComboBox );
 
143
 
 
144
    // char settings
 
145
    QGroupBox* charsBox = new QGroupBox( this );
 
146
    charsBox->setTitle( i18n("Chars") );
 
147
    QFormLayout* charsBoxFormLayout = new QFormLayout( charsBox );
 
148
    // coding
 
149
    mCharCodingComboBox = new KComboBox( charsBox );
 
150
    mCharCodingComboBox->addItems( Okteta::CharCodec::codecNames() );
 
151
    charsBoxFormLayout->addRow( i18n("Coding:"), mCharCodingComboBox );
 
152
    // line offset shown
 
153
    mNonPrintableShownCheckBox = new QCheckBox( charsBox );
 
154
    charsBoxFormLayout->addRow( i18n("Show Non-printable:"), mNonPrintableShownCheckBox );
 
155
    // char for non-printable bytes
 
156
    mNonPrintableCharEdit = new KLineEdit( charsBox ); // TODO: use a validator to ensure always one char
 
157
    mNonPrintableCharEdit->setMaxLength( 1 );
 
158
    charsBoxFormLayout->addRow( i18n("Char for non-printable bytes:"), mNonPrintableCharEdit );
 
159
    // char for undefined bytes
 
160
    mUndefinedCharEdit = new KLineEdit( charsBox ); // TODO: use a validator to ensure always one char
 
161
    mUndefinedCharEdit->setMaxLength( 1 );
 
162
    charsBoxFormLayout->addRow( i18n("Char for undefined bytes:"), mUndefinedCharEdit );
 
163
 
 
164
    layout->addLayout( titleFormLayout );
 
165
    layout->addWidget( displayBox );
 
166
    layout->addWidget( layoutBox );
 
167
    layout->addWidget( valuesBox );
 
168
    layout->addWidget( charsBox );
 
169
}
 
170
 
 
171
ByteArrayViewProfile ViewProfileEdit::viewProfile() const
 
172
{
 
173
    ByteArrayViewProfile viewProfile;
 
174
    viewProfile.setViewProfileTitle( mTitleEdit->text() );
 
175
 
 
176
    viewProfile.toggleOffsetColumn( mLineOffsetShownCheckBox->isChecked() );
 
177
    const int visibleByteArrayCodings =
 
178
        byteArrayCodingsFlagsFromListIndex( mValuesCharsShownComboBox->currentIndex() );
 
179
    viewProfile.setVisibleByteArrayCodings( visibleByteArrayCodings );
 
180
    viewProfile.setViewModus( mDisplayModeComboBox->currentIndex() );
 
181
 
 
182
    viewProfile.setLayoutStyle( mLineBreakComboBox->currentIndex() );
 
183
    viewProfile.setNoOfGroupedBytes( mGroupedBytesCountEdit->value() );
 
184
    viewProfile.setNoOfBytesPerLine( mBytesPerLineEdit->value() );
 
185
 
 
186
    viewProfile.setValueCoding( mValueCodingComboBox->currentIndex() );
 
187
 
 
188
    viewProfile.setCharCoding( mCharCodingComboBox->currentText() );
 
189
    viewProfile.setShowsNonprinting( mNonPrintableShownCheckBox->isChecked() );
 
190
    viewProfile.setSubstituteChar( mNonPrintableCharEdit->text()[0] ); // TODO: need make sure is one char
 
191
    viewProfile.setUndefinedChar( mUndefinedCharEdit->text()[0] ); // TODO: need make sure is one char
 
192
 
 
193
    return viewProfile;
 
194
}
 
195
 
 
196
void ViewProfileEdit::setViewProfile( const ByteArrayViewProfile& viewProfile )
 
197
{
 
198
    mTitleEdit->setText( viewProfile.viewProfileTitle() );
 
199
 
 
200
    mLineOffsetShownCheckBox->setChecked( viewProfile.offsetColumnVisible() );
 
201
    const int valuesCharsShownListIndex =
 
202
        listIndexFromByteArrayCodingsFlags( viewProfile.visibleByteArrayCodings() );
 
203
    mValuesCharsShownComboBox->setCurrentIndex( valuesCharsShownListIndex );
 
204
    mDisplayModeComboBox->setCurrentIndex( viewProfile.viewModus() );
 
205
 
 
206
    mLineBreakComboBox->setCurrentIndex( viewProfile.layoutStyle() );
 
207
    mGroupedBytesCountEdit->setValue( viewProfile.noOfGroupedBytes() );
 
208
    mBytesPerLineEdit->setValue( viewProfile.noOfBytesPerLine() );
 
209
 
 
210
    mValueCodingComboBox->setCurrentIndex( viewProfile.valueCoding() );
 
211
 
 
212
    mCharCodingComboBox->setCurrentItem( viewProfile.charCodingName() );
 
213
    mNonPrintableShownCheckBox->setChecked( viewProfile.showsNonprinting() );
 
214
    mNonPrintableCharEdit->setText( viewProfile.substituteChar() );
 
215
    mUndefinedCharEdit->setText( viewProfile.undefinedChar() );
 
216
}
 
217
 
 
218
void ViewProfileEdit::onLineBreakIndexChanged( int lineBreakIndex )
 
219
{
 
220
    const bool isLineBreakByByte = ( lineBreakIndex == 0 );
 
221
 
 
222
    mBytesPerLineEdit->setEnabled( isLineBreakByByte );
 
223
}
 
224
 
 
225
ViewProfileEdit::~ViewProfileEdit()
 
226
{
 
227
}
 
228
 
 
229
}