[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-doc-english
Subject: [kde-doc-english] branches/KDE/4.2/kdeutils/kcalc
From: David Johnson <david () usermode ! org>
Date: 2009-02-01 6:26:47
Message-ID: 1233469607.952599.18541.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 919488 by brandybuck:
GUI:
FEATURE:
backport from trunk
M +64 -13 general.ui
M +9 -0 kcalc.kcfg
M +25 -8 kcalcdisplay.cpp
M +2 -0 kcalcdisplay.h
--- branches/KDE/4.2/kdeutils/kcalc/general.ui #919487:919488
@@ -5,8 +5,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>300</width>
- <height>268</height>
+ <width>293</width>
+ <height>319</height>
</rect>
</property>
<property name="windowTitle" >
@@ -35,10 +35,20 @@
</widget>
</item>
<item row="0" column="1" >
- <widget class="QSpinBox" name="kcfg_Precision" />
+ <widget class="QSpinBox" name="kcfg_Precision" >
+ <property name="toolTip" >
+ <string>Maximum number of digits displayed</string>
+ </property>
+ <property name="whatsThis" >
+ <string>KCalc can compute with many more digits than the number that fits \
on the display. This setting gives the maximum number of digits displayed, before \
KCalc starts using scientific notation, i.e. notation of the type 2.34e12.</string> + \
</property> + </widget>
</item>
<item row="1" column="0" >
<widget class="QCheckBox" name="kcfg_Fixed" >
+ <property name="toolTip" >
+ <string>Whether to use fixed decimal places</string>
+ </property>
<property name="text" >
<string>Set &decimal precision</string>
</property>
@@ -49,6 +59,9 @@
<property name="enabled" >
<bool>false</bool>
</property>
+ <property name="toolTip" >
+ <string>Number of fixed decimal digits</string>
+ </property>
</widget>
</item>
</layout>
@@ -58,7 +71,7 @@
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
- <property name="sizeHint" >
+ <property name="sizeHint" stdset="0" >
<size>
<width>40</width>
<height>20</height>
@@ -70,6 +83,44 @@
</widget>
</item>
<item>
+ <widget class="QGroupBox" name="groupBox" >
+ <property name="title" >
+ <string>Numbers</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout" >
+ <item>
+ <widget class="QCheckBox" name="kcfg_GroupDigits" >
+ <property name="toolTip" >
+ <string>Whether to group digits</string>
+ </property>
+ <property name="text" >
+ <string>Group digits</string>
+ </property>
+ <property name="checked" >
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="kcfg_TwosComplement" >
+ <property name="toolTip" >
+ <string>Whether to use Two's Complement for non-decimal numbers</string>
+ </property>
+ <property name="whatsThis" >
+ <string>Select to use Two's Complement notation for Binary, Octal and \
Hexidecimal numbers. This is a common notation to represent negative numbers for \
non-decimal numbers in computers.</string> + </property>
+ <property name="text" >
+ <string>Two's Complement</string>
+ </property>
+ <property name="checked" >
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
<widget class="QGroupBox" name="miscGroupBox" >
<property name="title" >
<string>Misc</string>
@@ -77,6 +128,9 @@
<layout class="QVBoxLayout" >
<item>
<widget class="QCheckBox" name="kcfg_Beep" >
+ <property name="toolTip" >
+ <string>Whether to beep on error</string>
+ </property>
<property name="text" >
<string>&Beep on error</string>
</property>
@@ -87,18 +141,14 @@
</item>
<item>
<widget class="QCheckBox" name="kcfg_CaptionResult" >
+ <property name="toolTip" >
+ <string>Whether to show the result in the window title</string>
+ </property>
<property name="text" >
<string>Show &result in window title</string>
</property>
</widget>
</item>
- <item>
- <widget class="QCheckBox" name="kcfg_GroupDigits" >
- <property name="text" >
- <string>Group digits</string>
- </property>
- </widget>
- </item>
</layout>
</widget>
</item>
@@ -110,7 +160,7 @@
<property name="sizeType" >
<enum>QSizePolicy::Expanding</enum>
</property>
- <property name="sizeHint" >
+ <property name="sizeHint" stdset="0" >
<size>
<width>282</width>
<height>31</height>
@@ -126,9 +176,10 @@
<tabstop>kcfg_Precision</tabstop>
<tabstop>kcfg_Fixed</tabstop>
<tabstop>kcfg_FixedPrecision</tabstop>
+ <tabstop>kcfg_GroupDigits</tabstop>
+ <tabstop>kcfg_TwosComplement</tabstop>
<tabstop>kcfg_Beep</tabstop>
<tabstop>kcfg_CaptionResult</tabstop>
- <tabstop>kcfg_GroupDigits</tabstop>
</tabstops>
<resources/>
<connections>
--- branches/KDE/4.2/kdeutils/kcalc/kcalc.kcfg #919487:919488
@@ -91,6 +91,15 @@
<label>Whether to group digits.</label>
<default>true</default>
</entry>
+ <entry name="TwosComplement" type="Bool" key="twoscomplement">
+ <label>Whether to use Two's Complement for non-decimal numbers.</label>
+ <whatsthis>
+ Select to use Two's Complement notation for Binary, Octal
+ and Hexidecimal numbers. This is a common notation to represent
+ negative numbers in computers.
+ </whatsthis>
+ <default>true</default>
+ </entry>
<entry name="ShowBitset" type="Bool">
<label>Whether to show the bit edit widget.</label>
<default>false</default>
--- branches/KDE/4.2/kdeutils/kcalc/kcalcdisplay.cpp #919487:919488
@@ -45,9 +45,10 @@
#include "kcalcdisplay.moc"
KCalcDisplay::KCalcDisplay(QWidget *parent)
- :QFrame(parent), _beep(false), _groupdigits(false), _button(0),
- _lit(false), _num_base(NB_DECIMAL), _precision(9), _fixed_precision(-1),
- _display_amount(0), _history_index(0), _selection_timer(new QTimer)
+ :QFrame(parent), _beep(false), _groupdigits(true), _twoscomplement(true),
+ _button(0), _lit(false), _num_base(NB_DECIMAL), _precision(9),
+ _fixed_precision(-1), _display_amount(0), _history_index(0),
+ _selection_timer(new QTimer)
{
setFocusPolicy(Qt::StrongFocus);
@@ -91,9 +92,10 @@
else
setFixedPrecision(KCalcSettings::fixedPrecision());
- setBeep(KCalcSettings::beep());
- setGroupDigits(KCalcSettings::groupDigits());
- updateDisplay();
+ setBeep(KCalcSettings::beep());
+ setGroupDigits(KCalcSettings::groupDigits());
+ setTwosComplement(KCalcSettings::twosComplement());
+ updateDisplay();
}
void KCalcDisplay::updateFromCore(CalcEngine const &core,
@@ -351,6 +353,11 @@
_groupdigits = flag;
}
+void KCalcDisplay::setTwosComplement(bool flag)
+{
+ _twoscomplement = flag;
+}
+
KNumber const & KCalcDisplay::getAmount(void) const
{
return _display_amount;
@@ -369,8 +376,18 @@
if ((_num_base != NB_DECIMAL) &&
(new_amount.type() != KNumber::SpecialType)) {
_display_amount = new_amount.integerPart();
- quint64 tmp_workaround = static_cast<quint64>(_display_amount);
- display_str = QString::number(tmp_workaround, _num_base).toUpper();
+ if (_twoscomplement) {
+ // treat number as 64-bit unsigned
+ quint64 tmp_workaround = static_cast<quint64>(_display_amount);
+ display_str = QString::number(tmp_workaround, _num_base).toUpper();
+ } else {
+ // QString::number treats non-decimal as unsigned
+ qint64 tmp_workaround = static_cast<qint64>(_display_amount);
+ bool neg = tmp_workaround < 0;
+ if (neg) tmp_workaround = qAbs(tmp_workaround);
+ display_str = QString::number(tmp_workaround, _num_base).toUpper();
+ if (neg) display_str.prepend(KGlobal::locale()->negativeSign());
+ }
} else {
// _num_base == NB_DECIMAL || new_amount.type() == KNumber::SpecialType
_display_amount = new_amount;
--- branches/KDE/4.2/kdeutils/kcalc/kcalcdisplay.h #919487:919488
@@ -86,6 +86,7 @@
int setBase(NumBase new_base);
void setBeep(bool flag);
void setGroupDigits(bool flag);
+ void setTwosComplement(bool flag);
void setFixedPrecision(int precision);
void setPrecision(int precision);
void setText(QString const &string);
@@ -128,6 +129,7 @@
QString _text;
bool _beep;
bool _groupdigits;
+ bool _twoscomplement;
int _button;
bool _lit;
NumBase _num_base;
_______________________________________________
kde-doc-english mailing list
kde-doc-english@kde.org
https://mail.kde.org/mailman/listinfo/kde-doc-english
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic