• 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
  • settings
structviewdisplaysettingswidget.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 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 #include "structviewdisplaysettingswidget.h"
23 #include "structviewpreferences.h"
24 
25 StructViewDisplaySettingsWidget::StructViewDisplaySettingsWidget() :
26  QWidget(NULL)
27 {
28  ui.setupUi(this);
29  ui.combo_CharDisplayBase->setEnabled(ui.kcfg_ShowCharNumericalValue->isChecked());
30 
31  //no need for a hidden spinbox with byteOrder, since it is a simple sequential enum
32 
33  //setup the hidden spin boxes for the display bases
34  //these are needed since KConfigXT always uses the combo box index as the value
35  //we want the UserData of the current index instead
36  //maybe there is a nicer solution, but this works
37  ui.kcfg_CharDisplayBase->setValue(Kasten2::StructViewPreferences::charDisplayBase());
38  ui.kcfg_CharDisplayBase->setHidden(true);
39  ui.kcfg_SignedDisplayBase->setValue(Kasten2::StructViewPreferences::signedDisplayBase());
40  ui.kcfg_SignedDisplayBase->setHidden(true);
41  ui.kcfg_UnsignedDisplayBase->setValue(Kasten2::StructViewPreferences::unsignedDisplayBase());
42  ui.kcfg_UnsignedDisplayBase->setHidden(true);
43  setupBasesCombo(ui.combo_SignedDisplayBase, Kasten2::StructViewPreferences::self()->signedDisplayBaseItem(),
44  Kasten2::StructViewPreferences::signedDisplayBase(), SLOT(setSignedDisplay(int)));
45  setupBasesCombo(ui.combo_UnsignedDisplayBase, Kasten2::StructViewPreferences::self()->unsignedDisplayBaseItem(),
46  Kasten2::StructViewPreferences::unsignedDisplayBase(), SLOT(setUnsignedDisplay(int)));
47  setupBasesCombo(ui.combo_CharDisplayBase, Kasten2::StructViewPreferences::self()->charDisplayBaseItem(),
48  Kasten2::StructViewPreferences::charDisplayBase(), SLOT(setCharDisplay(int)));
49 }
50 
51 StructViewDisplaySettingsWidget::~StructViewDisplaySettingsWidget()
52 {
53 }
54 
55 void StructViewDisplaySettingsWidget::setupBasesCombo(QComboBox* box, KConfigSkeletonItem* configItem,
56  int currentValue, const char* slot)
57 {
58  Q_ASSERT(box->count() == 0);
59  Q_ASSERT(currentValue == 2 || currentValue == 8 || currentValue == 10 || currentValue == 16);
60  qDebug() << "current value:" << configItem->property() << "vs" << currentValue;
61  box->addItem(i18nc("@item:inlistbox", "Binary"), 2);
62  box->addItem(i18nc("@item:inlistbox", "Octal"), 8);
63  box->addItem(i18nc("@item:inlistbox", "Decimal"), 10);
64  box->addItem(i18nc("@item:inlistbox", "Hexadecimal"), 16);
65 
66  box->setCurrentIndex(currentValue == 2 ? 0 : (currentValue == 8 ? 1 : (currentValue == 16 ? 3 : 2)));
67 
68  box->setToolTip(configItem->toolTip());
69  connect(box, SIGNAL(activated(int)), this, slot);
70 }
71 
72 void StructViewDisplaySettingsWidget::handleMapping(int index, QComboBox* box, QSpinBox* spin)
73 {
74  QVariant currentValue = box->itemData(index);
75  qDebug() << "box changed to " << index << "value = " << currentValue;
76  if (spin->value() != currentValue.toInt())
77  spin->setValue(currentValue.toInt());
78 }
79 
80 void StructViewDisplaySettingsWidget::setCharDisplay(int index)
81 {
82  qDebug() << "byteOrder changed to " << index;
83  handleMapping(index, ui.combo_CharDisplayBase, ui.kcfg_CharDisplayBase);
84 }
85 
86 void StructViewDisplaySettingsWidget::setSignedDisplay(int index)
87 {
88  qDebug() << "byteOrder changed to " << index;
89  handleMapping(index, ui.combo_SignedDisplayBase, ui.kcfg_SignedDisplayBase);
90 }
91 
92 void StructViewDisplaySettingsWidget::setUnsignedDisplay(int index)
93 {
94  qDebug() << "byteOrder changed to " << index;
95  handleMapping(index, ui.combo_UnsignedDisplayBase, ui.kcfg_UnsignedDisplayBase);
96 }
Kasten2::StructViewPreferences::unsignedDisplayBaseItem
ItemInt * unsignedDisplayBaseItem()
Get Item object corresponding to UnsignedDisplayBase()
Definition: structviewpreferences.h:42
Kasten2::StructViewPreferences::charDisplayBase
static int charDisplayBase()
Get CharDisplayBase.
Definition: structviewpreferences.h:88
QWidget
structviewpreferences.h
Kasten2::StructViewPreferences::signedDisplayBaseItem
ItemInt * signedDisplayBaseItem()
Get Item object corresponding to SignedDisplayBase()
Definition: structviewpreferences.h:69
StructViewDisplaySettingsWidget::StructViewDisplaySettingsWidget
StructViewDisplaySettingsWidget()
Definition: structviewdisplaysettingswidget.cpp:25
Kasten2::StructViewPreferences::signedDisplayBase
static int signedDisplayBase()
Get SignedDisplayBase.
Definition: structviewpreferences.h:61
Kasten2::StructViewPreferences::self
static StructViewPreferences * self()
Definition: structviewpreferences.cpp:25
QSpinBox
Kasten2::StructViewPreferences::charDisplayBaseItem
ItemInt * charDisplayBaseItem()
Get Item object corresponding to CharDisplayBase()
Definition: structviewpreferences.h:96
structviewdisplaysettingswidget.h
StructViewDisplaySettingsWidget::~StructViewDisplaySettingsWidget
~StructViewDisplaySettingsWidget()
Definition: structviewdisplaysettingswidget.cpp:51
Kasten2::StructViewPreferences::unsignedDisplayBase
static int unsignedDisplayBase()
Get UnsignedDisplayBase.
Definition: structviewpreferences.h:34
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