• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeutils API Reference
  • KDE Home
  • Contact Us
 

kcalc

  • sources
  • kde-4.12
  • kdeutils
  • kcalc
kcalc.cpp
Go to the documentation of this file.
1 /*
2 Copyright (C) 2001 - 2013 Evan Teran
3  evan.teran@gmail.com
4 
5 Copyright (C) 2006 Michel Marti
6  mma@objectxp.com
7 
8 Copyright (C) 1996 - 2000 Bernd Johannes Wuebben
9  wuebben@kde.org
10 
11 This program is free software; you can redistribute it and/or
12 modify it under the terms of the GNU General Public License as
13 published by the Free Software Foundation; either version 2 of
14 the License, or (at your option) any later version.
15 
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
20 
21 You should have received a copy of the GNU General Public License
22 along with this program. If not, see <http://www.gnu.org/licenses/>.
23 */
24 
25 #include "kcalc.h"
26 
27 #include <clocale>
28 
29 #include <QApplication>
30 #include <QCursor>
31 #include <QKeyEvent>
32 #include <QShortcut>
33 #include <QStyle>
34 
35 #include <kaboutdata.h>
36 #include <kacceleratormanager.h>
37 #include <kaction.h>
38 #include <kactioncollection.h>
39 #include <kapplication.h>
40 #include <kbuttongroup.h>
41 #include <kcmdlineargs.h>
42 #include <kcolorbutton.h>
43 #include <kcolormimedata.h>
44 #include <kconfig.h>
45 #include <kconfigdialog.h>
46 #include <kdialog.h>
47 #include <kglobal.h>
48 #include <kglobalsettings.h>
49 #include <kmenu.h>
50 #include <kmenubar.h>
51 #include <knumvalidator.h>
52 #include <kpushbutton.h>
53 #include <kstandardaction.h>
54 #include <kstatusbar.h>
55 #include <ktoggleaction.h>
56 #include <ktoolbar.h>
57 #include <kxmlguifactory.h>
58 
59 #include "kcalc_bitset.h"
60 #include "kcalc_const_menu.h"
61 #include "kcalc_settings.h"
62 #include "kcalcdisplay.h"
63 #include "version.h"
64 
65 namespace {
66 const char description[] = I18N_NOOP("KDE Calculator");
67 const char version[] = KCALCVERSION;
68 const int maxprecision = 1000;
69 }
70 
71 
72 //------------------------------------------------------------------------------
73 // Name: KCalculator
74 // Desc: constructor
75 //------------------------------------------------------------------------------
76 KCalculator::KCalculator(QWidget *parent) :
77  KXmlGuiWindow(parent),
78  shift_mode_(false),
79  hyp_mode_(false),
80  memory_num_(0.0),
81  constants_menu_(0),
82  constants_(0),
83  core() {
84 
85  // central widget to contain all the elements
86  QWidget *const central = new QWidget(this);
87  central->setLayoutDirection(Qt::LeftToRight);
88  setCentralWidget(central);
89  KAcceleratorManager::setNoAccel(central);
90 
91  // load science constants_ from xml-file
92  KCalcConstMenu::init_consts();
93 
94  // setup interface (order is critical)
95  setupUi(central);
96  setupMainActions();
97  setupStatusbar();
98  createGUI();
99  setupKeys();
100 
101  toolBar()->hide(); // hide by default
102 
103  // create button groups
104  base_choose_group_ = new QButtonGroup(this);
105  base_choose_group_->setExclusive(true);
106  base_choose_group_->addButton(hexRadio, HexMode);
107  base_choose_group_->addButton(decRadio, DecMode);
108  base_choose_group_->addButton(octRadio, OctMode);
109  base_choose_group_->addButton(binRadio, BinMode);
110  connect(base_choose_group_, SIGNAL(buttonClicked(int)),
111  SLOT(slotBaseSelected(int)));
112 
113  angle_choose_group_ = new QButtonGroup(this);
114  angle_choose_group_->setExclusive(true);
115  angle_choose_group_->addButton(degRadio, DegMode);
116  angle_choose_group_->addButton(radRadio, RadMode);
117  angle_choose_group_->addButton(gradRadio, GradMode);
118  connect(angle_choose_group_, SIGNAL(buttonClicked(int)),
119  SLOT(slotAngleSelected(int)));
120 
121  // additional menu setup
122  constants_menu_ = createConstantsMenu();
123  menuBar()->insertMenu((menuBar()->actions)()[2], constants_menu_);
124 
125  // misc setup
126  setColors();
127  setFonts();
128 
129  // Show the result in the app's caption in taskbar (wishlist - bug #52858)
130  if (KCalcSettings::captionResult() == true) {
131  connect(calc_display, SIGNAL(changedText(QString)), SLOT(setCaption(QString)));
132  }
133 
134  calc_display->changeSettings();
135  setPrecision();
136 
137  updateGeometry();
138 
139  setFixedSize(minimumSize());
140 
141  updateDisplay(UPDATE_FROM_CORE);
142 
143  // misc settings
144  KCalcSettings::EnumCalculatorMode::type calculatorMode = KCalcSettings::calculatorMode();
145 
146  switch (calculatorMode) {
147  case KCalcSettings::EnumCalculatorMode::science:
148  action_mode_science_->setChecked(true);
149  break;
150  case KCalcSettings::EnumCalculatorMode::statistics:
151  action_mode_statistic_->setChecked(true);
152  break;
153  case KCalcSettings::EnumCalculatorMode::numeral:
154  action_mode_numeral_->setChecked(true);
155  break;
156  case KCalcSettings::EnumCalculatorMode::simple:
157  default:
158  action_mode_simple_->setChecked(true);
159  }
160 
161  setAngle();
162  setBase();
163 
164  // connections
165  connect(KGlobalSettings::self(), SIGNAL(kdisplayPaletteChanged()), SLOT(setColors()));
166  connect(KGlobalSettings::self(), SIGNAL(kdisplayFontChanged()), SLOT(setFonts()));
167 
168  calc_display->setFocus();
169 }
170 
171 //------------------------------------------------------------------------------
172 // Name: ~KCalculator
173 // Desc: deconstructor
174 //------------------------------------------------------------------------------
175 KCalculator::~KCalculator() {
176 
177  KCalcSettings::self()->writeConfig();
178 }
179 
180 //------------------------------------------------------------------------------
181 // Name: setupMainActions
182 // Desc: connects all of the basic actions
183 //------------------------------------------------------------------------------
184 void KCalculator::setupMainActions() {
185 
186  // file menu
187  KStandardAction::quit(this, SLOT(close()), actionCollection());
188 
189  // edit menu
190  KStandardAction::undo(calc_display, SLOT(slotHistoryBack()), actionCollection());
191  KStandardAction::redo(calc_display, SLOT(slotHistoryForward()), actionCollection());
192  KStandardAction::cut(calc_display, SLOT(slotCut()), actionCollection());
193  KStandardAction::copy(calc_display, SLOT(slotCopy()), actionCollection());
194  KStandardAction::paste(calc_display, SLOT(slotPaste()), actionCollection());
195 
196  // mode menu
197  QActionGroup *modeGroup = new QActionGroup(this);
198 
199  action_mode_simple_ = actionCollection()->add<KToggleAction>(QLatin1String("mode_simple"));
200  action_mode_simple_->setActionGroup(modeGroup);
201  action_mode_simple_->setText(i18n("Simple Mode"));
202  connect(action_mode_simple_, SIGNAL(toggled(bool)), SLOT(slotSetSimpleMode()));
203 
204  action_mode_science_ = actionCollection()->add<KToggleAction>(QLatin1String("mode_science"));
205  action_mode_science_->setActionGroup(modeGroup);
206  action_mode_science_->setText(i18n("Science Mode"));
207  connect(action_mode_science_, SIGNAL(toggled(bool)), SLOT(slotSetScienceMode()));
208 
209  action_mode_statistic_ = actionCollection()->add<KToggleAction>(QLatin1String("mode_statistics"));
210  action_mode_statistic_->setActionGroup(modeGroup);
211  action_mode_statistic_->setText(i18n("Statistic Mode"));
212  connect(action_mode_statistic_, SIGNAL(toggled(bool)), SLOT(slotSetStatisticMode()));
213 
214  action_mode_numeral_ = actionCollection()->add<KToggleAction>(QLatin1String("mode_numeral"));
215  action_mode_numeral_->setActionGroup(modeGroup);
216  action_mode_numeral_->setText(i18n("Numeral System Mode"));
217  connect(action_mode_numeral_, SIGNAL(toggled(bool)), SLOT(slotSetNumeralMode()));
218 
219  // settings menu
220  action_constants_show_ = actionCollection()->add<KToggleAction>(QLatin1String("show_constants"));
221  action_constants_show_->setText(i18n("Constants &Buttons"));
222  action_constants_show_->setChecked(true);
223  connect(action_constants_show_, SIGNAL(toggled(bool)), SLOT(slotConstantsShow(bool)));
224 
225  action_bitset_show_ = actionCollection()->add<KToggleAction>(QLatin1String("show_bitset"));
226  action_bitset_show_->setText(i18n("Show B&it Edit"));
227  action_bitset_show_->setChecked(true);
228  connect(action_bitset_show_, SIGNAL(toggled(bool)), SLOT(slotBitsetshow(bool)));
229 
230  KStandardAction::preferences(this, SLOT(showSettings()), actionCollection());
231  KStandardAction::keyBindings(guiFactory(), SLOT(configureShortcuts()), actionCollection());
232 }
233 
234 //------------------------------------------------------------------------------
235 // Name: createConstantsMenu
236 // Desc: creates and returns a pointer to the constant menu
237 //------------------------------------------------------------------------------
238 KCalcConstMenu *KCalculator::createConstantsMenu() {
239 
240  KCalcConstMenu *const menu = new KCalcConstMenu(i18n("&Constants"), this);
241  connect(menu, SIGNAL(triggeredConstant(science_constant)), this, SLOT(slotConstantToDisplay(science_constant)));
242  return menu;
243 }
244 
245 //------------------------------------------------------------------------------
246 // Name: setupStatusbar
247 // Desc: sets up the status bar with default text
248 //------------------------------------------------------------------------------
249 void KCalculator::setupStatusbar() {
250 
251  // Status bar contents
252  statusBar()->insertPermanentFixedItem(QLatin1String(" NORM "), ShiftField);
253  statusBar()->setItemAlignment(ShiftField, Qt::AlignCenter);
254 
255  statusBar()->insertPermanentFixedItem(QLatin1String(" HEX "), BaseField);
256  statusBar()->setItemAlignment(BaseField, Qt::AlignCenter);
257 
258  statusBar()->insertPermanentFixedItem(QLatin1String(" DEG "), AngleField);
259  statusBar()->setItemAlignment(AngleField, Qt::AlignCenter);
260 
261  statusBar()->insertPermanentFixedItem(QLatin1String(" \xa0\xa0 "), MemField); // nbsp
262  statusBar()->setItemAlignment(MemField, Qt::AlignCenter);
263 }
264 
265 //------------------------------------------------------------------------------
266 // Name: setupNumberKeys
267 // Desc: sets up number keys and related shortcuts
268 //------------------------------------------------------------------------------
269 void KCalculator::setupNumberKeys() {
270 
271  num_button_group_ = new QButtonGroup(this);
272  connect(num_button_group_, SIGNAL(buttonClicked(int)), SLOT(slotNumberclicked(int)));
273 
274  num_button_group_->addButton(pb0, 0);
275  num_button_group_->addButton(pb1, 1);
276  num_button_group_->addButton(pb2, 2);
277  num_button_group_->addButton(pb3, 3);
278  num_button_group_->addButton(pb4, 4);
279  num_button_group_->addButton(pb5, 5);
280  num_button_group_->addButton(pb6, 6);
281  num_button_group_->addButton(pb7, 7);
282  num_button_group_->addButton(pb8, 8);
283  num_button_group_->addButton(pb9, 9);
284  num_button_group_->addButton(pbA, 0xA);
285  num_button_group_->addButton(pbB, 0xB);
286  num_button_group_->addButton(pbC, 0xC);
287  num_button_group_->addButton(pbD, 0xD);
288  num_button_group_->addButton(pbE, 0xE);
289  num_button_group_->addButton(pbF, 0xF);
290  connect(this, SIGNAL(switchShowAccels(bool)), pb0, SLOT(slotSetAccelDisplayMode(bool)));
291  connect(this, SIGNAL(switchShowAccels(bool)), pb1, SLOT(slotSetAccelDisplayMode(bool)));
292  connect(this, SIGNAL(switchShowAccels(bool)), pb2, SLOT(slotSetAccelDisplayMode(bool)));
293  connect(this, SIGNAL(switchShowAccels(bool)), pb3, SLOT(slotSetAccelDisplayMode(bool)));
294  connect(this, SIGNAL(switchShowAccels(bool)), pb4, SLOT(slotSetAccelDisplayMode(bool)));
295  connect(this, SIGNAL(switchShowAccels(bool)), pb5, SLOT(slotSetAccelDisplayMode(bool)));
296  connect(this, SIGNAL(switchShowAccels(bool)), pb6, SLOT(slotSetAccelDisplayMode(bool)));
297  connect(this, SIGNAL(switchShowAccels(bool)), pb7, SLOT(slotSetAccelDisplayMode(bool)));
298  connect(this, SIGNAL(switchShowAccels(bool)), pb8, SLOT(slotSetAccelDisplayMode(bool)));
299  connect(this, SIGNAL(switchShowAccels(bool)), pb9, SLOT(slotSetAccelDisplayMode(bool)));
300  connect(this, SIGNAL(switchShowAccels(bool)), pbA, SLOT(slotSetAccelDisplayMode(bool)));
301  connect(this, SIGNAL(switchShowAccels(bool)), pbB, SLOT(slotSetAccelDisplayMode(bool)));
302  connect(this, SIGNAL(switchShowAccels(bool)), pbC, SLOT(slotSetAccelDisplayMode(bool)));
303  connect(this, SIGNAL(switchShowAccels(bool)), pbD, SLOT(slotSetAccelDisplayMode(bool)));
304  connect(this, SIGNAL(switchShowAccels(bool)), pbE, SLOT(slotSetAccelDisplayMode(bool)));
305  connect(this, SIGNAL(switchShowAccels(bool)), pbF, SLOT(slotSetAccelDisplayMode(bool)));
306 }
307 
308 //------------------------------------------------------------------------------
309 // Name: setupRightKeypad
310 // Desc: sets up right keypad keys and related shortcuts
311 //------------------------------------------------------------------------------
312 void KCalculator::setupRightKeypad() {
313 
314  connect(pbShift, SIGNAL(toggled(bool)), SLOT(slotShifttoggled(bool)));
315  connect(this, SIGNAL(switchShowAccels(bool)), pbShift, SLOT(slotSetAccelDisplayMode(bool)));
316 
317  pbBackspace->setShortcut(QKeySequence(Qt::Key_Backspace));
318  new QShortcut(Qt::Key_PageUp, pbBackspace, SLOT(animateClick()));
319  connect(pbBackspace, SIGNAL(clicked()), SLOT(slotBackspaceclicked()));
320  connect(this, SIGNAL(switchShowAccels(bool)), pbBackspace, SLOT(slotSetAccelDisplayMode(bool)));
321 
322  pbClear->setShortcut(QKeySequence(Qt::Key_Escape));
323  new QShortcut(Qt::Key_PageUp, pbClear, SLOT(animateClick()));
324  connect(pbClear, SIGNAL(clicked()), SLOT(slotClearclicked()));
325  connect(this, SIGNAL(switchShowAccels(bool)), pbClear, SLOT(slotSetAccelDisplayMode(bool)));
326 
327  pbAllClear->setShortcut(QKeySequence(Qt::Key_Delete));
328  new QShortcut(Qt::Key_PageDown, pbAllClear, SLOT(animateClick()));
329  connect(pbAllClear, SIGNAL(clicked()), SLOT(slotAllClearclicked()));
330  connect(this, SIGNAL(switchShowAccels(bool)), pbAllClear, SLOT(slotSetAccelDisplayMode(bool)));
331 
332  pbParenOpen->setShortcut(QKeySequence(Qt::Key_ParenLeft));
333  connect(pbParenOpen, SIGNAL(clicked()), SLOT(slotParenOpenclicked()));
334  connect(this, SIGNAL(switchShowAccels(bool)), pbParenOpen, SLOT(slotSetAccelDisplayMode(bool)));
335 
336  pbParenClose->setShortcut(QKeySequence(Qt::Key_ParenRight));
337  connect(pbParenClose, SIGNAL(clicked()), SLOT(slotParenCloseclicked()));
338  connect(this, SIGNAL(switchShowAccels(bool)), pbParenClose, SLOT(slotSetAccelDisplayMode(bool)));
339 
340  pbMemRecall->setDisabled(true); // nothing in memory at start
341  connect(pbMemRecall, SIGNAL(clicked()), SLOT(slotMemRecallclicked()));
342  connect(this, SIGNAL(switchShowAccels(bool)), pbMemRecall, SLOT(slotSetAccelDisplayMode(bool)));
343 
344  connect(pbMemClear, SIGNAL(clicked()), SLOT(slotMemClearclicked()));
345  connect(this, SIGNAL(switchShowAccels(bool)), pbMemClear, SLOT(slotSetAccelDisplayMode(bool)));
346 
347  pbMemPlusMinus->addMode(ModeNormal, i18nc("Add display to memory", "M+"), i18n("Add display to memory"));
348  pbMemPlusMinus->addMode(ModeShift, i18nc("Subtract from memory", "M\xe2\x88\x92"), i18n("Subtract from memory"));
349  connect(pbMemPlusMinus, SIGNAL(clicked()), SLOT(slotMemPlusMinusclicked()));
350  connect(this, SIGNAL(switchShowAccels(bool)), pbMemPlusMinus, SLOT(slotSetAccelDisplayMode(bool)));
351  connect(this, SIGNAL(switchMode(ButtonModeFlags,bool)), pbMemPlusMinus, SLOT(slotSetMode(ButtonModeFlags,bool)));
352 
353  connect(pbMemStore, SIGNAL(clicked()), SLOT(slotMemStoreclicked()));
354  connect(this, SIGNAL(switchShowAccels(bool)), pbMemStore, SLOT(slotSetAccelDisplayMode(bool)));
355 
356  pbPercent->setShortcut(QKeySequence(Qt::Key_Percent));
357  connect(pbPercent, SIGNAL(clicked()), SLOT(slotPercentclicked()));
358  connect(this, SIGNAL(switchShowAccels(bool)), pbPercent, SLOT(slotSetAccelDisplayMode(bool)));
359 
360  pbPlusMinus->setShortcut(QKeySequence(Qt::Key_Backslash));
361  connect(pbPlusMinus, SIGNAL(clicked()), SLOT(slotPlusMinusclicked()));
362  connect(this, SIGNAL(switchShowAccels(bool)), pbPlusMinus, SLOT(slotSetAccelDisplayMode(bool)));
363 }
364 
365 //------------------------------------------------------------------------------
366 // Name: setupNumericKeypad
367 // Desc: sets up numeric keys and related shortcuts
368 //------------------------------------------------------------------------------
369 void KCalculator::setupNumericKeypad() {
370 
371  pbCube->addMode(ModeNormal, i18nc("Third power", "x<sup>3</sup>"), i18n("Third power"));
372  pbCube->addMode(ModeShift, QLatin1String("<sup>3</sup>&radic;x"), i18n("Cube root"));
373  connect(pbCube, SIGNAL(clicked()), SLOT(slotCubeclicked()));
374  connect(this, SIGNAL(switchShowAccels(bool)), pbCube, SLOT(slotSetAccelDisplayMode(bool)));
375  connect(this, SIGNAL(switchMode(ButtonModeFlags,bool)), pbCube, SLOT(slotSetMode(ButtonModeFlags,bool)));
376 
377  pbDivision->setShortcut(QKeySequence(Qt::Key_Slash));
378  new QShortcut(Qt::Key_division, pbDivision, SLOT(animateClick()));
379  connect(pbDivision, SIGNAL(clicked()), SLOT(slotDivisionclicked()));
380  connect(this, SIGNAL(switchShowAccels(bool)), pbDivision, SLOT(slotSetAccelDisplayMode(bool)));
381 
382  pbMultiplication->setShortcut(QKeySequence(Qt::Key_Asterisk));
383  new QShortcut(Qt::Key_X, pbMultiplication, SLOT(animateClick()));
384  new QShortcut(Qt::Key_multiply, pbMultiplication, SLOT(animateClick()));
385  connect(pbMultiplication, SIGNAL(clicked()), SLOT(slotMultiplicationclicked()));
386  connect(this, SIGNAL(switchShowAccels(bool)), pbMultiplication, SLOT(slotSetAccelDisplayMode(bool)));
387 
388  pbMinus->setShortcut(QKeySequence(Qt::Key_Minus));
389  connect(pbMinus, SIGNAL(clicked()), SLOT(slotMinusclicked()));
390  connect(this, SIGNAL(switchShowAccels(bool)), pbMinus, SLOT(slotSetAccelDisplayMode(bool)));
391 
392  pbPlus->setShortcut(QKeySequence(Qt::Key_Plus));
393  connect(pbPlus, SIGNAL(clicked()), SLOT(slotPlusclicked()));
394  connect(this, SIGNAL(switchShowAccels(bool)), pbPlus, SLOT(slotSetAccelDisplayMode(bool)));
395 
396  pbPeriod->setText(KGlobal::locale()->decimalSymbol());
397  pbPeriod->setShortcut(KGlobal::locale()->decimalSymbol());
398 
399  // TODO: is this needed? the above line look slike it should do the right thing?
400  /*
401  if (KGlobal::locale()->decimalSymbol() == QLatin1String(".")) {
402  new QShortcut(Qt::Key_Comma, pbPeriod, SLOT(animateClick()));
403  } else if (KGlobal::locale()->decimalSymbol() == QLatin1String(",")) {
404  new QShortcut(Qt::Key_Period, pbPeriod, SLOT(animateClick()));
405  }
406  */
407 
408  connect(pbPeriod, SIGNAL(clicked()), SLOT(slotPeriodclicked()));
409  connect(this, SIGNAL(switchShowAccels(bool)), pbPeriod, SLOT(slotSetAccelDisplayMode(bool)));
410 
411  pbEqual->setShortcut(QKeySequence(Qt::Key_Enter));
412  new QShortcut(Qt::Key_Equal, pbEqual, SLOT(animateClick()));
413  new QShortcut(Qt::Key_Return, pbEqual, SLOT(animateClick()));
414  connect(pbEqual, SIGNAL(clicked()), SLOT(slotEqualclicked()));
415  connect(this, SIGNAL(switchShowAccels(bool)), pbEqual, SLOT(slotSetAccelDisplayMode(bool)));
416 }
417 
418 //------------------------------------------------------------------------------
419 // Name: setupLogicKeys
420 // Desc: sets up logic keys and related shortcuts
421 //------------------------------------------------------------------------------
422 void KCalculator::setupLogicKeys() {
423 
424  logic_buttons_.append(pbAND);
425  logic_buttons_.append(pbOR);
426  logic_buttons_.append(pbXOR);
427  logic_buttons_.append(pbLsh);
428  logic_buttons_.append(pbRsh);
429  logic_buttons_.append(pbCmp);
430 
431  pbAND->setShortcut(QKeySequence(Qt::Key_Ampersand));
432  connect(this, SIGNAL(switchShowAccels(bool)), pbAND, SLOT(slotSetAccelDisplayMode(bool)));
433  connect(pbAND, SIGNAL(clicked()), SLOT(slotANDclicked()));
434 
435  pbOR->setShortcut(QKeySequence(Qt::Key_Bar));
436  connect(this, SIGNAL(switchShowAccels(bool)), pbOR, SLOT(slotSetAccelDisplayMode(bool)));
437  connect(pbOR, SIGNAL(clicked()), SLOT(slotORclicked()));
438 
439  connect(this, SIGNAL(switchShowAccels(bool)), pbXOR, SLOT(slotSetAccelDisplayMode(bool)));
440  connect(pbXOR, SIGNAL(clicked()), SLOT(slotXORclicked()));
441 
442  pbLsh->setShortcut(QKeySequence(Qt::Key_Less));
443  connect(this, SIGNAL(switchShowAccels(bool)), pbLsh, SLOT(slotSetAccelDisplayMode(bool)));
444  connect(pbLsh, SIGNAL(clicked()), SLOT(slotLeftShiftclicked()));
445 
446  pbRsh->setShortcut(QKeySequence(Qt::Key_Greater));
447  connect(this, SIGNAL(switchShowAccels(bool)), pbRsh, SLOT(slotSetAccelDisplayMode(bool)));
448  connect(pbRsh, SIGNAL(clicked()), SLOT(slotRightShiftclicked()));
449 
450  pbCmp->setShortcut(QKeySequence(Qt::Key_AsciiTilde));
451  connect(this, SIGNAL(switchShowAccels(bool)), pbCmp, SLOT(slotSetAccelDisplayMode(bool)));
452  connect(pbCmp, SIGNAL(clicked()), SLOT(slotNegateclicked()));
453 }
454 
455 //------------------------------------------------------------------------------
456 // Name: setupLogicKeys
457 // Desc: sets up scientific keys and related shortcuts
458 //------------------------------------------------------------------------------
459 void KCalculator::setupScientificKeys() {
460 
461  scientific_buttons_.append(pbHyp);
462  scientific_buttons_.append(pbSin);
463  scientific_buttons_.append(pbCos);
464  scientific_buttons_.append(pbTan);
465  scientific_buttons_.append(pbLog);
466  scientific_buttons_.append(pbLn);
467 
468  connect(this, SIGNAL(switchShowAccels(bool)), pbHyp, SLOT(slotSetAccelDisplayMode(bool)));
469  connect(pbHyp, SIGNAL(toggled(bool)), SLOT(slotHyptoggled(bool)));
470 
471  pbSin->addMode(ModeNormal, i18nc("Sine", "Sin"), i18n("Sine"));
472  pbSin->addMode(ModeShift, i18nc("Arc sine", "Asin"), i18n("Arc sine"));
473  pbSin->addMode(ModeHyperbolic, i18nc("Hyperbolic sine", "Sinh"), i18n("Hyperbolic sine"));
474  pbSin->addMode(ButtonModeFlags(ModeShift | ModeHyperbolic), i18nc("Inverse hyperbolic sine", "Asinh"), i18n("Inverse hyperbolic sine"));
475  connect(this, SIGNAL(switchShowAccels(bool)), pbSin, SLOT(slotSetAccelDisplayMode(bool)));
476  connect(this, SIGNAL(switchMode(ButtonModeFlags,bool)), pbSin, SLOT(slotSetMode(ButtonModeFlags,bool)));
477  connect(pbSin, SIGNAL(clicked()), SLOT(slotSinclicked()));
478 
479  pbCos->addMode(ModeNormal, i18nc("Cosine", "Cos"), i18n("Cosine"));
480  pbCos->addMode(ModeShift, i18nc("Arc cosine", "Acos"), i18n("Arc cosine"));
481  pbCos->addMode(ModeHyperbolic, i18nc("Hyperbolic cosine", "Cosh"), i18n("Hyperbolic cosine"));
482  pbCos->addMode(ButtonModeFlags(ModeShift | ModeHyperbolic), i18nc("Inverse hyperbolic cosine", "Acosh"), i18n("Inverse hyperbolic cosine"));
483  connect(this, SIGNAL(switchShowAccels(bool)), pbCos, SLOT(slotSetAccelDisplayMode(bool)));
484  connect(this, SIGNAL(switchMode(ButtonModeFlags,bool)), pbCos, SLOT(slotSetMode(ButtonModeFlags,bool)));
485  connect(pbCos, SIGNAL(clicked()), SLOT(slotCosclicked()));
486 
487  pbTan->addMode(ModeNormal, i18nc("Tangent", "Tan"), i18n("Tangent"));
488  pbTan->addMode(ModeShift, i18nc("Arc tangent", "Atan"), i18n("Arc tangent"));
489  pbTan->addMode(ModeHyperbolic, i18nc("Hyperbolic tangent", "Tanh"), i18n("Hyperbolic tangent"));
490  pbTan->addMode(ButtonModeFlags(ModeShift | ModeHyperbolic), i18nc("Inverse hyperbolic tangent", "Atanh"), i18n("Inverse hyperbolic tangent"));
491  connect(this, SIGNAL(switchShowAccels(bool)), pbTan, SLOT(slotSetAccelDisplayMode(bool)));
492  connect(this, SIGNAL(switchMode(ButtonModeFlags,bool)), pbTan, SLOT(slotSetMode(ButtonModeFlags,bool)));
493  connect(pbTan, SIGNAL(clicked()), SLOT(slotTanclicked()));
494 
495  pbLog->addMode(ModeNormal, i18nc("Logarithm to base 10", "Log"), i18n("Logarithm to base 10"));
496  pbLog->addMode(ModeShift, i18nc("10 to the power of x", "10<sup>x</sup>"), i18n("10 to the power of x"));
497  connect(this, SIGNAL(switchShowAccels(bool)), pbLog, SLOT(slotSetAccelDisplayMode(bool)));
498  connect(this, SIGNAL(switchMode(ButtonModeFlags,bool)), pbLog, SLOT(slotSetMode(ButtonModeFlags,bool)));
499  connect(pbLog, SIGNAL(clicked()), SLOT(slotLogclicked()));
500  pbLn->addMode(ModeNormal, i18nc("Natural log", "Ln"), i18n("Natural log"));
501  pbLn->addMode(ModeShift, i18nc("Exponential function", "e<sup>x</sup>"), i18n("Exponential function"));
502  connect(this, SIGNAL(switchShowAccels(bool)), pbLn, SLOT(slotSetAccelDisplayMode(bool)));
503  connect(this, SIGNAL(switchMode(ButtonModeFlags,bool)), pbLn, SLOT(slotSetMode(ButtonModeFlags,bool)));
504  connect(pbLn, SIGNAL(clicked()), SLOT(slotLnclicked()));
505 }
506 
507 //------------------------------------------------------------------------------
508 // Name: setupStatisticKeys
509 // Desc: sets up statistical keys and related shortcuts
510 //------------------------------------------------------------------------------
511 void KCalculator::setupStatisticKeys() {
512 
513  stat_buttons_.append(pbNData);
514  stat_buttons_.append(pbMean);
515  stat_buttons_.append(pbSd);
516  stat_buttons_.append(pbMed);
517  stat_buttons_.append(pbDat);
518  stat_buttons_.append(pbCSt);
519 
520  pbNData->addMode(ModeNormal, i18nc("Number of data entered", "N"), i18n("Number of data entered"));
521  pbNData->addMode(ModeShift, QString::fromUtf8("\xce\xa3") + QLatin1Char('x'), i18n("Sum of all data items"));
522  connect(this, SIGNAL(switchShowAccels(bool)), pbNData, SLOT(slotSetAccelDisplayMode(bool)));
523  connect(this, SIGNAL(switchMode(ButtonModeFlags,bool)), pbNData, SLOT(slotSetMode(ButtonModeFlags,bool)));
524  connect(pbNData, SIGNAL(clicked()), SLOT(slotStatNumclicked()));
525 
526  pbMean->addMode(ModeNormal, i18nc("Mean", "Mea"), i18n("Mean"));
527  pbMean->addMode(ModeShift, QString::fromUtf8("\xce\xa3") + QLatin1String("x<sup>2</sup>"), i18n("Sum of all data items squared"));
528  connect(this, SIGNAL(switchShowAccels(bool)), pbMean, SLOT(slotSetAccelDisplayMode(bool)));
529  connect(this, SIGNAL(switchMode(ButtonModeFlags,bool)), pbMean, SLOT(slotSetMode(ButtonModeFlags,bool)));
530  connect(pbMean, SIGNAL(clicked()), SLOT(slotStatMeanclicked()));
531 
532  pbSd->addMode(ModeNormal, QString::fromUtf8("\xcf\x83") + QLatin1String("<sub>N</sub>"), i18n("Standard deviation"));
533  pbSd->addMode(ModeShift, QString::fromUtf8("\xcf\x83") + QLatin1String("<sub>N-1</sub>"), i18n("Sample standard deviation"));
534  connect(this, SIGNAL(switchShowAccels(bool)), pbSd, SLOT(slotSetAccelDisplayMode(bool)));
535  connect(this, SIGNAL(switchMode(ButtonModeFlags,bool)), pbSd, SLOT(slotSetMode(ButtonModeFlags,bool)));
536  connect(pbSd, SIGNAL(clicked()), SLOT(slotStatStdDevclicked()));
537 
538  connect(this, SIGNAL(switchShowAccels(bool)), pbMed, SLOT(slotSetAccelDisplayMode(bool)));
539  connect(pbMed, SIGNAL(clicked()), SLOT(slotStatMedianclicked()));
540 
541  pbDat->addMode(ModeNormal, i18nc("Enter data", "Dat"), i18n("Enter data"));
542  pbDat->addMode(ModeShift, i18nc("Delete last data item", "CDat"), i18n("Delete last data item"));
543  connect(this, SIGNAL(switchShowAccels(bool)), pbDat, SLOT(slotSetAccelDisplayMode(bool)));
544  connect(this, SIGNAL(switchMode(ButtonModeFlags,bool)), pbDat, SLOT(slotSetMode(ButtonModeFlags,bool)));
545  connect(pbDat, SIGNAL(clicked()), SLOT(slotStatDataInputclicked()));
546 
547  connect(this, SIGNAL(switchShowAccels(bool)), pbCSt, SLOT(slotSetAccelDisplayMode(bool)));
548  connect(pbCSt, SIGNAL(clicked()), SLOT(slotStatClearDataclicked()));
549 }
550 
551 //------------------------------------------------------------------------------
552 // Name: setupConstantsKeys
553 // Desc: sets up constants keys and related shortcuts
554 //------------------------------------------------------------------------------
555 void KCalculator::setupConstantsKeys() {
556 
557  const_buttons_.append(pbC1);
558  const_buttons_.append(pbC2);
559  const_buttons_.append(pbC3);
560  const_buttons_.append(pbC4);
561  const_buttons_.append(pbC5);
562  const_buttons_.append(pbC6);
563 
564  pbC1->setButtonNumber(0);
565  connect(this, SIGNAL(switchShowAccels(bool)), pbC1, SLOT(slotSetAccelDisplayMode(bool)));
566  connect(this, SIGNAL(switchMode(ButtonModeFlags,bool)), pbC1, SLOT(slotSetMode(ButtonModeFlags,bool)));
567  connect(pbC1, SIGNAL(clicked(int)), this, SLOT(slotConstclicked(int)));
568 
569  pbC2->setButtonNumber(1);
570  connect(this, SIGNAL(switchShowAccels(bool)), pbC2, SLOT(slotSetAccelDisplayMode(bool)));
571  connect(this, SIGNAL(switchMode(ButtonModeFlags,bool)), pbC2, SLOT(slotSetMode(ButtonModeFlags,bool)));
572  connect(pbC2, SIGNAL(clicked(int)), this, SLOT(slotConstclicked(int)));
573 
574  pbC3->setButtonNumber(2);
575  connect(this, SIGNAL(switchShowAccels(bool)), pbC3, SLOT(slotSetAccelDisplayMode(bool)));
576  connect(this, SIGNAL(switchMode(ButtonModeFlags,bool)), pbC3, SLOT(slotSetMode(ButtonModeFlags,bool)));
577  connect(pbC3, SIGNAL(clicked(int)), this, SLOT(slotConstclicked(int)));
578 
579  pbC4->setButtonNumber(3);
580  connect(this, SIGNAL(switchShowAccels(bool)), pbC4, SLOT(slotSetAccelDisplayMode(bool)));
581  connect(this, SIGNAL(switchMode(ButtonModeFlags,bool)), pbC4, SLOT(slotSetMode(ButtonModeFlags,bool)));
582  connect(pbC4, SIGNAL(clicked(int)), this, SLOT(slotConstclicked(int)));
583 
584  pbC5->setButtonNumber(4);
585  connect(this, SIGNAL(switchShowAccels(bool)), pbC5, SLOT(slotSetAccelDisplayMode(bool)));
586  connect(this, SIGNAL(switchMode(ButtonModeFlags,bool)), pbC5, SLOT(slotSetMode(ButtonModeFlags,bool)));
587  connect(pbC5, SIGNAL(clicked(int)), this, SLOT(slotConstclicked(int)));
588 
589  pbC6->setButtonNumber(5);
590  connect(this, SIGNAL(switchShowAccels(bool)), pbC6, SLOT(slotSetAccelDisplayMode(bool)));
591  connect(this, SIGNAL(switchMode(ButtonModeFlags,bool)), pbC6, SLOT(slotSetMode(ButtonModeFlags,bool)));
592  connect(pbC6, SIGNAL(clicked(int)), this, SLOT(slotConstclicked(int)));
593 
594  changeButtonNames();
595 }
596 
597 //------------------------------------------------------------------------------
598 // Name: setupMiscKeys
599 // Desc: sets up misc keys and related shortcuts
600 //------------------------------------------------------------------------------
601 void KCalculator::setupMiscKeys() {
602 
603  pbMod->addMode(ModeNormal, i18nc("Modulo", "Mod"), i18n("Modulo"));
604  pbMod->addMode(ModeShift, i18nc("Integer division", "IntDiv"), i18n("Integer division"));
605  connect(this, SIGNAL(switchMode(ButtonModeFlags,bool)), pbMod, SLOT(slotSetMode(ButtonModeFlags,bool)));
606  connect(this, SIGNAL(switchShowAccels(bool)), pbMod, SLOT(slotSetAccelDisplayMode(bool)));
607  pbMod->setShortcut(QKeySequence(Qt::Key_Colon));
608  connect(pbMod, SIGNAL(clicked()), SLOT(slotModclicked()));
609 
610  pbReci->addMode(ModeNormal, i18nc("Reciprocal", "1/x"), i18n("Reciprocal"));
611  pbReci->addMode(ModeShift, i18nc("n Choose m", "nCm"), i18n("n Choose m"));
612  connect(this, SIGNAL(switchMode(ButtonModeFlags,bool)), pbReci, SLOT(slotSetMode(ButtonModeFlags,bool)));
613  connect(this, SIGNAL(switchShowAccels(bool)), pbReci, SLOT(slotSetAccelDisplayMode(bool)));
614  connect(pbReci, SIGNAL(clicked()), SLOT(slotReciclicked()));
615 
616  pbFactorial->addMode(ModeNormal, i18nc("Factorial", "x!"), i18n("Factorial"));
617  pbFactorial->setShortcut(QKeySequence(Qt::Key_Exclam));
618  connect(this, SIGNAL(switchShowAccels(bool)), pbFactorial, SLOT(slotSetAccelDisplayMode(bool)));
619  connect(pbFactorial, SIGNAL(clicked()), SLOT(slotFactorialclicked()));
620 
621  pbSquare->addMode(ModeNormal, i18nc("Square", "x<sup>2</sup>"), i18n("Square"));
622  pbSquare->addMode(ModeShift, QLatin1String("&radic;x"), i18n("Square root"));
623  pbSquare->setShortcut(QKeySequence(Qt::Key_BracketLeft));
624  new QShortcut(Qt::Key_twosuperior, pbSquare, SLOT(animateClick()));
625  connect(this, SIGNAL(switchShowAccels(bool)), pbSquare, SLOT(slotSetAccelDisplayMode(bool)));
626  connect(this, SIGNAL(switchMode(ButtonModeFlags,bool)), pbSquare, SLOT(slotSetMode(ButtonModeFlags,bool)));
627  connect(pbSquare, SIGNAL(clicked()), SLOT(slotSquareclicked()));
628 
629  pbPower->addMode(ModeNormal, i18nc("x to the power of y", "x<sup>y</sup>"), i18n("x to the power of y"));
630  pbPower->addMode(ModeShift, i18nc("x to the power of 1/y", "x<sup>1/y</sup>"), i18n("x to the power of 1/y"));
631  connect(this, SIGNAL(switchShowAccels(bool)), pbPower, SLOT(slotSetAccelDisplayMode(bool)));
632  connect(this, SIGNAL(switchMode(ButtonModeFlags,bool)), pbPower, SLOT(slotSetMode(ButtonModeFlags,bool)));
633  pbPower->setShortcut(QKeySequence(Qt::Key_AsciiCircum));
634  connect(pbPower, SIGNAL(clicked()), SLOT(slotPowerclicked()));
635 
636  pbEE->addMode(ModeNormal, QLatin1String("x<small>" "\xb7" "10</small><sup>y</sup>"), i18n("Exponent"));
637  connect(this, SIGNAL(switchShowAccels(bool)), pbEE, SLOT(slotSetAccelDisplayMode(bool)));
638  connect(pbEE, SIGNAL(clicked()), SLOT(slotEEclicked()));
639 }
640 
641 //------------------------------------------------------------------------------
642 // Name: createConstantsMenu
643 // Desc: additional setup for button keys
644 // NOTE: all alphanumeric shorts set in ui file
645 //------------------------------------------------------------------------------
646 void KCalculator::setupKeys() {
647 
648  setupNumberKeys();
649  setupRightKeypad();
650  setupNumericKeypad();
651  setupLogicKeys();
652  setupScientificKeys();
653  setupStatisticKeys();
654  setupConstantsKeys();
655  setupMiscKeys();
656 
657  // other button lists
658 
659  function_button_list_.append(pbHyp);
660  function_button_list_.append(pbShift);
661  function_button_list_.append(pbEE);
662  function_button_list_.append(pbSin);
663  function_button_list_.append(pbPlusMinus);
664  function_button_list_.append(pbCos);
665  function_button_list_.append(pbReci);
666  function_button_list_.append(pbTan);
667  function_button_list_.append(pbFactorial);
668  function_button_list_.append(pbLog);
669  function_button_list_.append(pbSquare);
670  function_button_list_.append(pbLn);
671  function_button_list_.append(pbPower);
672  function_button_list_.append(pbCube);
673 
674  mem_button_list_.append(pbMemRecall);
675  mem_button_list_.append(pbMemPlusMinus);
676  mem_button_list_.append(pbMemStore);
677  mem_button_list_.append(pbMemClear);
678  mem_button_list_.append(pbClear);
679  mem_button_list_.append(pbAllClear);
680 
681  operation_button_list_.append(pbMultiplication);
682  operation_button_list_.append(pbParenOpen);
683  operation_button_list_.append(pbParenClose);
684  operation_button_list_.append(pbAND);
685  operation_button_list_.append(pbDivision);
686  operation_button_list_.append(pbOR);
687  operation_button_list_.append(pbXOR);
688  operation_button_list_.append(pbPlus);
689  operation_button_list_.append(pbMinus);
690  operation_button_list_.append(pbLsh);
691  operation_button_list_.append(pbRsh);
692  operation_button_list_.append(pbPeriod);
693  operation_button_list_.append(pbEqual);
694  operation_button_list_.append(pbPercent);
695  operation_button_list_.append(pbCmp);
696  operation_button_list_.append(pbMod);
697 }
698 
699 //------------------------------------------------------------------------------
700 // Name: updateGeometry
701 // Desc: makes all the buttons have reasonable sizes
702 //------------------------------------------------------------------------------
703 void KCalculator::updateGeometry() {
704 
705  const QSize em = pbAND->fontMetrics().size(0, QLatin1String("M"));
706  int margin = QApplication::style()->pixelMetric(QStyle::PM_ButtonMargin, 0, 0);
707  margin = qMax(qMin(margin / 2, 3), 3);
708 
709  // left pad
710  foreach(QObject *obj, leftPad->children()) {
711  if (KCalcButton *const button = qobject_cast<KCalcButton *>(obj)) {
712  button->setFixedWidth(em.width() * 4 + margin * 2);
713  button->installEventFilter(this);
714  }
715  }
716 
717  // right pad
718  foreach(QObject *obj, rightPad->children()) {
719  KCalcButton *const button = qobject_cast<KCalcButton *>(obj);
720  // let Shift expand freely
721  if (button && button != pbShift) {
722  button->setFixedWidth(em.width() * 3 + margin * 2);
723  button->installEventFilter(this);
724  }
725  }
726 
727  // numeric pad
728  foreach(QObject *obj, numericPad->children()) {
729  if (KCalcButton *const button = qobject_cast<KCalcButton *>(obj)) {
730  // let pb0 expand freely
731  if (button != pb0) {
732  button->setFixedWidth(em.width() * 3 + margin * 2);
733  }
734  button->installEventFilter(this);
735  }
736  }
737 }
738 
739 //------------------------------------------------------------------------------
740 // Name: slotConstantToDisplay
741 // Desc: inserts a constant
742 //------------------------------------------------------------------------------
743 void KCalculator::slotConstantToDisplay(const science_constant &const_chosen) {
744 
745  QString val = const_chosen.value;
746  val.replace(QLatin1Char('.'), KNumber::decimalSeparator());
747  calc_display->setAmount(KNumber(val));
748  updateDisplay(0);
749 }
750 
751 //------------------------------------------------------------------------------
752 // Name: slotBaseSelected
753 // Desc: changes the selected numeric base
754 //------------------------------------------------------------------------------
755 void KCalculator::slotBaseSelected(int base) {
756 
757  int current_base;
758 
759  // set display & statusbar (if item exist in statusbar)
760  switch (base) {
761  case BinMode:
762  current_base = calc_display->setBase(NumBase(2));
763  statusBar()->changeItem(QLatin1String("BIN"), BaseField);
764  calc_display->setStatusText(BaseField, QLatin1String("Bin"));
765  break;
766  case OctMode:
767  current_base = calc_display->setBase(NumBase(8));
768  statusBar()->changeItem(QLatin1String("OCT"), BaseField);
769  calc_display->setStatusText(BaseField, QLatin1String("Oct"));
770  break;
771  case DecMode:
772  current_base = calc_display->setBase(NumBase(10));
773  statusBar()->changeItem(QLatin1String("DEC"), BaseField);
774  calc_display->setStatusText(BaseField, QLatin1String("Dec"));
775  break;
776  case HexMode:
777  current_base = calc_display->setBase(NumBase(16));
778  statusBar()->changeItem(QLatin1String("HEX"), BaseField);
779  calc_display->setStatusText(BaseField, QLatin1String("Hex"));
780  break;
781  default:
782  statusBar()->changeItem(QLatin1String("Error"), BaseField);
783  calc_display->setStatusText(BaseField, QLatin1String("Error"));
784  return;
785  }
786 
787  // Enable the buttons available in this base
788  for (int i = 0; i < current_base; ++i) {
789  (num_button_group_->buttons()[i])->setEnabled(true);
790  }
791 
792  // Disable the buttons not available in this base
793  for (int i = current_base; i < 16; ++i) {
794  (num_button_group_->buttons()[i])->setEnabled(false);
795  }
796 
797  // Only enable the decimal point in decimal
798  pbPeriod->setEnabled(current_base == NB_DECIMAL);
799 
800  // Only enable the x*10^y button in decimal
801  pbEE->setEnabled(current_base == NB_DECIMAL);
802 
803  // Disable buttons that make only sense with floating point numbers
804  if (current_base != NB_DECIMAL) {
805  foreach(QAbstractButton *btn, scientific_buttons_) {
806  btn->setEnabled(false);
807  }
808  } else {
809  foreach(QAbstractButton *btn, scientific_buttons_) {
810  btn->setEnabled(true);
811  }
812  }
813 
814  KCalcSettings::setBaseMode(base);
815 }
816 
817 //------------------------------------------------------------------------------
818 // Name: keyPressEvent
819 // Desc: handles keypress events
820 //------------------------------------------------------------------------------
821 void KCalculator::keyPressEvent(QKeyEvent *e) {
822 
823  // Fix for bug #314586
824  // Basically, on some keyboards such as French, even though the decimal separator
825  // is "," the numeric keypad has a "." key. So we fake it so people can more seemlessly
826  // enter numbers using the keypad
827  if(KNumber::decimalSeparator() != ".") {
828  if(e->key() == Qt::Key_Period && e->modifiers() & Qt::KeypadModifier) {
829  pbPeriod->animateClick();
830  }
831  }
832 
833 
834  if (((e->modifiers() & Qt::NoModifier) == 0) || (e->modifiers() & Qt::ShiftModifier)) {
835  switch (e->key()) {
836  case Qt::Key_Backspace:
837  calc_display->deleteLastDigit();
838  break;
839  }
840  }
841 
842  if (e->key() == Qt::Key_Control) {
843  emit switchShowAccels(true);
844  }
845 }
846 
847 //------------------------------------------------------------------------------
848 // Name: keyReleaseEvent
849 // Desc: handles keyrelease events
850 //------------------------------------------------------------------------------
851 void KCalculator::keyReleaseEvent(QKeyEvent *e) {
852 
853  if (e->key() == Qt::Key_Control) {
854  emit switchShowAccels(false);
855  }
856 }
857 
858 //------------------------------------------------------------------------------
859 // Name: slotAngleSelected
860 // Desc: changes the selected angle system
861 //------------------------------------------------------------------------------
862 void KCalculator::slotAngleSelected(int mode) {
863 
864  angle_mode_ = mode;
865 
866  switch (mode) {
867  case DegMode:
868  statusBar()->changeItem(QLatin1String("DEG"), AngleField);
869  calc_display->setStatusText(AngleField, QLatin1String("Deg"));
870  break;
871  case RadMode:
872  statusBar()->changeItem(QLatin1String("RAD"), AngleField);
873  calc_display->setStatusText(AngleField, QLatin1String("Rad"));
874  break;
875  case GradMode:
876  statusBar()->changeItem(QLatin1String("GRA"), AngleField);
877  calc_display->setStatusText(AngleField, QLatin1String("Gra"));
878  break;
879  default: // we shouldn't ever end up here
880  angle_mode_ = RadMode;
881  }
882 
883  KCalcSettings::setAngleMode(angle_mode_);
884 }
885 
886 //------------------------------------------------------------------------------
887 // Name: slotEEclicked
888 // Desc: starts the entering of numers using scientific notation
889 //------------------------------------------------------------------------------
890 void KCalculator::slotEEclicked() {
891  calc_display->newCharacter(QLatin1Char('e'));
892 }
893 
894 //------------------------------------------------------------------------------
895 // Name: slotShifttoggled
896 // Desc: updates the shift state for alternate button functionality
897 //------------------------------------------------------------------------------
898 void KCalculator::slotShifttoggled(bool flag) {
899 
900  shift_mode_ = flag;
901 
902  emit switchMode(ModeShift, flag);
903 
904  if (shift_mode_) {
905  statusBar()->changeItem(i18nc("Second button functions are active", "SHIFT"), ShiftField);
906  calc_display->setStatusText(ShiftField, i18n("Shift"));
907  } else {
908  statusBar()->changeItem(i18nc("Normal button functions are active", "NORM"), ShiftField);
909  calc_display->setStatusText(ShiftField, QString());
910  }
911 }
912 
913 //------------------------------------------------------------------------------
914 // Name: slotHyptoggled
915 // Desc: updates the Hyp state for alternate trig button functionality
916 //------------------------------------------------------------------------------
917 void KCalculator::slotHyptoggled(bool flag) {
918 
919  // toggle between hyperbolic and standart trig functions
920  hyp_mode_ = flag;
921 
922  emit switchMode(ModeHyperbolic, flag);
923 }
924 
925 //------------------------------------------------------------------------------
926 // Name: slotMemRecallclicked
927 // Desc: recalls a value from memory
928 //------------------------------------------------------------------------------
929 void KCalculator::slotMemRecallclicked() {
930 
931  // temp. work-around
932  calc_display->sendEvent(KCalcDisplay::EventReset);
933 
934  calc_display->setAmount(memory_num_);
935  updateDisplay(0);
936 }
937 
938 //------------------------------------------------------------------------------
939 // Name: slotMemStoreclicked
940 // Desc: stores a value into memory
941 //------------------------------------------------------------------------------
942 void KCalculator::slotMemStoreclicked() {
943 
944  EnterEqual();
945 
946  memory_num_ = calc_display->getAmount();
947  calc_display->setStatusText(MemField, QLatin1String("M"));
948  statusBar()->changeItem(QLatin1String("M"), MemField);
949  pbMemRecall->setEnabled(true);
950 }
951 
952 //------------------------------------------------------------------------------
953 // Name: slotNumberclicked
954 // Desc: user has entered a digit
955 //------------------------------------------------------------------------------
956 void KCalculator::slotNumberclicked(int number_clicked) {
957 
958  calc_display->enterDigit(number_clicked);
959 }
960 
961 //------------------------------------------------------------------------------
962 // Name: slotSinclicked
963 // Desc: executes the sine function
964 //------------------------------------------------------------------------------
965 void KCalculator::slotSinclicked() {
966 
967  if (hyp_mode_) {
968  // sinh or arsinh
969  if (!shift_mode_) {
970  core.SinHyp(calc_display->getAmount());
971  } else {
972  core.AreaSinHyp(calc_display->getAmount());
973  }
974  } else {
975  // sine or arcsine
976  if (!shift_mode_) {
977  switch (angle_mode_) {
978  case DegMode:
979  core.SinDeg(calc_display->getAmount());
980  break;
981  case RadMode:
982  core.SinRad(calc_display->getAmount());
983  break;
984  case GradMode:
985  core.SinGrad(calc_display->getAmount());
986  break;
987  }
988  } else {
989  switch (angle_mode_) {
990  case DegMode:
991  core.ArcSinDeg(calc_display->getAmount());
992  break;
993  case RadMode:
994  core.ArcSinRad(calc_display->getAmount());
995  break;
996  case GradMode:
997  core.ArcSinGrad(calc_display->getAmount());
998  break;
999  }
1000  }
1001  }
1002 
1003  updateDisplay(UPDATE_FROM_CORE);
1004 }
1005 
1006 //------------------------------------------------------------------------------
1007 // Name: slotPlusMinusclicked
1008 // Desc: changes sign of number being displayed
1009 //------------------------------------------------------------------------------
1010 void KCalculator::slotPlusMinusclicked() {
1011 
1012  // display can only change sign, when in input mode, otherwise we
1013  // need the core to do this.
1014  if (!calc_display->sendEvent(KCalcDisplay::EventChangeSign)) {
1015  core.InvertSign(calc_display->getAmount());
1016  updateDisplay(UPDATE_FROM_CORE);
1017  }
1018 }
1019 
1020 //------------------------------------------------------------------------------
1021 // Name: slotMemPlusMinusclicked
1022 // Desc: handles arithmetic on values stored in memory
1023 //------------------------------------------------------------------------------
1024 void KCalculator::slotMemPlusMinusclicked() {
1025 
1026  bool tmp_shift_mode = shift_mode_; // store this, because next command deletes shift_mode_
1027  EnterEqual(); // finish calculation so far, to store result into MEM
1028 
1029  if (!tmp_shift_mode) {
1030  memory_num_ += calc_display->getAmount();
1031  } else {
1032  memory_num_ -= calc_display->getAmount();
1033  }
1034 
1035  pbShift->setChecked(false);
1036  statusBar()->changeItem(i18n("M"), MemField);
1037  calc_display->setStatusText(MemField, i18n("M"));
1038  pbMemRecall->setEnabled(true);
1039 }
1040 
1041 //------------------------------------------------------------------------------
1042 // Name: slotSinclicked
1043 // Desc: executes the cosine function
1044 //------------------------------------------------------------------------------
1045 void KCalculator::slotCosclicked() {
1046 
1047  if (hyp_mode_) {
1048  // cosh or arcosh
1049  if (!shift_mode_) {
1050  core.CosHyp(calc_display->getAmount());
1051  } else {
1052  core.AreaCosHyp(calc_display->getAmount());
1053  }
1054  } else {
1055  // cosine or arccosine
1056  if (!shift_mode_) {
1057  switch (angle_mode_) {
1058  case DegMode:
1059  core.CosDeg(calc_display->getAmount());
1060  break;
1061  case RadMode:
1062  core.CosRad(calc_display->getAmount());
1063  break;
1064  case GradMode:
1065  core.CosGrad(calc_display->getAmount());
1066  break;
1067  }
1068  } else {
1069  switch (angle_mode_) {
1070  case DegMode:
1071  core.ArcCosDeg(calc_display->getAmount());
1072  break;
1073  case RadMode:
1074  core.ArcCosRad(calc_display->getAmount());
1075  break;
1076  case GradMode:
1077  core.ArcCosGrad(calc_display->getAmount());
1078  break;
1079  }
1080  }
1081  }
1082 
1083  updateDisplay(UPDATE_FROM_CORE);
1084 }
1085 
1086 //------------------------------------------------------------------------------
1087 // Name: slotSinclicked
1088 // Desc: executes the recipricol function
1089 //------------------------------------------------------------------------------
1090 void KCalculator::slotReciclicked() {
1091 
1092  if (shift_mode_) {
1093  core.enterOperation(calc_display->getAmount(), CalcEngine::FUNC_BINOM);
1094  } else {
1095  core.Reciprocal(calc_display->getAmount());
1096  updateDisplay(UPDATE_FROM_CORE);
1097  return;
1098  }
1099 
1100  // temp. work-around
1101  KNumber tmp_num = calc_display->getAmount();
1102  calc_display->sendEvent(KCalcDisplay::EventReset);
1103  calc_display->setAmount(tmp_num);
1104  updateDisplay(0);
1105 }
1106 
1107 //------------------------------------------------------------------------------
1108 // Name: slotSinclicked
1109 // Desc: executes the tangent function
1110 //------------------------------------------------------------------------------
1111 void KCalculator::slotTanclicked() {
1112 
1113  if (hyp_mode_) {
1114  // tanh or artanh
1115  if (!shift_mode_) {
1116  core.TangensHyp(calc_display->getAmount());
1117  } else {
1118  core.AreaTangensHyp(calc_display->getAmount());
1119  }
1120  } else {
1121  // tan or arctan
1122  if (!shift_mode_) {
1123  switch (angle_mode_) {
1124  case DegMode:
1125  core.TangensDeg(calc_display->getAmount());
1126  break;
1127  case RadMode:
1128  core.TangensRad(calc_display->getAmount());
1129  break;
1130  case GradMode:
1131  core.TangensGrad(calc_display->getAmount());
1132  break;
1133  }
1134  } else {
1135  switch (angle_mode_) {
1136  case DegMode:
1137  core.ArcTangensDeg(calc_display->getAmount());
1138  break;
1139  case RadMode:
1140  core.ArcTangensRad(calc_display->getAmount());
1141  break;
1142  case GradMode:
1143  core.ArcTangensGrad(calc_display->getAmount());
1144  break;
1145  }
1146  }
1147  }
1148 
1149  updateDisplay(UPDATE_FROM_CORE);
1150 }
1151 
1152 //------------------------------------------------------------------------------
1153 // Name: slotFactorialclicked
1154 // Desc: executes the factorial function
1155 //------------------------------------------------------------------------------
1156 void KCalculator::slotFactorialclicked() {
1157 
1158  // Set WaitCursor, as this operation may take looooong
1159  // time and UI frezes with large numbers. User needs some
1160  // visual feedback.
1161  QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
1162  core.Factorial(calc_display->getAmount());
1163  QApplication::restoreOverrideCursor();
1164  updateDisplay(UPDATE_FROM_CORE);
1165 }
1166 
1167 //------------------------------------------------------------------------------
1168 // Name: slotLogclicked
1169 // Desc: executes the Log function
1170 //------------------------------------------------------------------------------
1171 void KCalculator::slotLogclicked() {
1172 
1173  if (!shift_mode_) {
1174  core.Log10(calc_display->getAmount());
1175  } else {
1176  core.Exp10(calc_display->getAmount());
1177  }
1178 
1179  updateDisplay(UPDATE_FROM_CORE);
1180 }
1181 
1182 //------------------------------------------------------------------------------
1183 // Name: slotSquareclicked
1184 // Desc: executes the x^2 function
1185 //------------------------------------------------------------------------------
1186 void KCalculator::slotSquareclicked() {
1187 
1188  if (!shift_mode_) {
1189  core.Square(calc_display->getAmount());
1190  } else {
1191  core.SquareRoot(calc_display->getAmount());
1192  }
1193 
1194  updateDisplay(UPDATE_FROM_CORE);
1195 }
1196 
1197 //------------------------------------------------------------------------------
1198 // Name: slotCubeclicked
1199 // Desc: executes the x^3 function
1200 //------------------------------------------------------------------------------
1201 void KCalculator::slotCubeclicked() {
1202 
1203  if (!shift_mode_) {
1204  core.Cube(calc_display->getAmount());
1205  } else {
1206  core.CubeRoot(calc_display->getAmount());
1207  }
1208 
1209  updateDisplay(UPDATE_FROM_CORE);
1210 }
1211 
1212 //------------------------------------------------------------------------------
1213 // Name: slotCubeclicked
1214 // Desc: executes the ln function
1215 //------------------------------------------------------------------------------
1216 void KCalculator::slotLnclicked() {
1217 
1218  if (!shift_mode_) {
1219  core.Ln(calc_display->getAmount());
1220  } else {
1221  core.Exp(calc_display->getAmount());
1222  }
1223 
1224  updateDisplay(UPDATE_FROM_CORE);
1225 }
1226 
1227 //------------------------------------------------------------------------------
1228 // Name: slotPowerclicked
1229 // Desc: executes the x^y function
1230 //------------------------------------------------------------------------------
1231 void KCalculator::slotPowerclicked() {
1232 
1233  if (shift_mode_) {
1234  core.enterOperation(calc_display->getAmount(), CalcEngine::FUNC_PWR_ROOT);
1235  pbShift->setChecked(false);
1236  } else {
1237  core.enterOperation(calc_display->getAmount(), CalcEngine::FUNC_POWER);
1238  }
1239 
1240  // temp. work-around
1241  KNumber tmp_num = calc_display->getAmount();
1242  calc_display->sendEvent(KCalcDisplay::EventReset);
1243  calc_display->setAmount(tmp_num);
1244  updateDisplay(0);
1245 }
1246 
1247 //------------------------------------------------------------------------------
1248 // Name: slotMemClearclicked
1249 // Desc: executes the MC function
1250 //------------------------------------------------------------------------------
1251 void KCalculator::slotMemClearclicked() {
1252 
1253  memory_num_ = KNumber::Zero;
1254  statusBar()->changeItem(QLatin1String(" \xa0\xa0 "), MemField); // nbsp
1255  calc_display->setStatusText(MemField, QString());
1256  pbMemRecall->setDisabled(true);
1257 }
1258 
1259 //------------------------------------------------------------------------------
1260 // Name: slotBackspaceclicked
1261 // Desc: removes the last input digit
1262 //------------------------------------------------------------------------------
1263 void KCalculator::slotBackspaceclicked() {
1264 
1265  calc_display->deleteLastDigit();
1266 }
1267 
1268 //------------------------------------------------------------------------------
1269 // Name: slotClearclicked
1270 // Desc: clears the display
1271 //------------------------------------------------------------------------------
1272 void KCalculator::slotClearclicked() {
1273 
1274  calc_display->sendEvent(KCalcDisplay::EventClear);
1275 }
1276 
1277 //------------------------------------------------------------------------------
1278 // Name: slotAllClearclicked
1279 // Desc: clears everything
1280 //------------------------------------------------------------------------------
1281 void KCalculator::slotAllClearclicked() {
1282 
1283  core.Reset();
1284  calc_display->sendEvent(KCalcDisplay::EventReset);
1285  updateDisplay(UPDATE_FROM_CORE);
1286 }
1287 
1288 //------------------------------------------------------------------------------
1289 // Name: slotParenOpenclicked
1290 // Desc: starts a sub-expression
1291 //------------------------------------------------------------------------------
1292 void KCalculator::slotParenOpenclicked() {
1293 
1294  core.ParenOpen(calc_display->getAmount());
1295 }
1296 
1297 //------------------------------------------------------------------------------
1298 // Name: slotParenCloseclicked
1299 // Desc: ends a sub-expression
1300 //------------------------------------------------------------------------------
1301 void KCalculator::slotParenCloseclicked() {
1302 
1303  core.ParenClose(calc_display->getAmount());
1304  updateDisplay(UPDATE_FROM_CORE);
1305 }
1306 
1307 //------------------------------------------------------------------------------
1308 // Name: slotANDclicked
1309 // Desc: executes a bitwise AND
1310 //------------------------------------------------------------------------------
1311 void KCalculator::slotANDclicked() {
1312 
1313  core.enterOperation(calc_display->getAmount(), CalcEngine::FUNC_AND);
1314  updateDisplay(UPDATE_FROM_CORE);
1315 }
1316 
1317 //------------------------------------------------------------------------------
1318 // Name: slotMultiplicationclicked
1319 // Desc: executes multiplication
1320 //------------------------------------------------------------------------------
1321 void KCalculator::slotMultiplicationclicked() {
1322 
1323  core.enterOperation(calc_display->getAmount(), CalcEngine::FUNC_MULTIPLY);
1324  updateDisplay(UPDATE_FROM_CORE);
1325 }
1326 
1327 //------------------------------------------------------------------------------
1328 // Name: slotDivisionclicked
1329 // Desc: executes division
1330 //------------------------------------------------------------------------------
1331 void KCalculator::slotDivisionclicked() {
1332 
1333  core.enterOperation(calc_display->getAmount(), CalcEngine::FUNC_DIVIDE);
1334  updateDisplay(UPDATE_FROM_CORE);
1335 }
1336 
1337 //------------------------------------------------------------------------------
1338 // Name: slotORclicked
1339 // Desc: executes a bitwise OR
1340 //------------------------------------------------------------------------------
1341 void KCalculator::slotORclicked() {
1342 
1343  core.enterOperation(calc_display->getAmount(), CalcEngine::FUNC_OR);
1344  updateDisplay(UPDATE_FROM_CORE);
1345 }
1346 
1347 //------------------------------------------------------------------------------
1348 // Name: slotXORclicked
1349 // Desc: executes a bitwise XOR
1350 //------------------------------------------------------------------------------
1351 void KCalculator::slotXORclicked() {
1352 
1353  core.enterOperation(calc_display->getAmount(), CalcEngine::FUNC_XOR);
1354  updateDisplay(UPDATE_FROM_CORE);
1355 }
1356 
1357 //------------------------------------------------------------------------------
1358 // Name: slotPlusclicked
1359 // Desc: executes addition
1360 //------------------------------------------------------------------------------
1361 void KCalculator::slotPlusclicked() {
1362 
1363  core.enterOperation(calc_display->getAmount(), CalcEngine::FUNC_ADD);
1364  updateDisplay(UPDATE_FROM_CORE);
1365 }
1366 
1367 //------------------------------------------------------------------------------
1368 // Name: slotPlusclicked
1369 // Desc: executes subtraction
1370 //------------------------------------------------------------------------------
1371 void KCalculator::slotMinusclicked() {
1372 
1373  core.enterOperation(calc_display->getAmount(), CalcEngine::FUNC_SUBTRACT);
1374  updateDisplay(UPDATE_FROM_CORE);
1375 }
1376 
1377 //------------------------------------------------------------------------------
1378 // Name: slotLeftShiftclicked
1379 // Desc: executes a bitwise left shift
1380 //------------------------------------------------------------------------------
1381 void KCalculator::slotLeftShiftclicked() {
1382 
1383  core.enterOperation(calc_display->getAmount(), CalcEngine::FUNC_LSH);
1384  updateDisplay(UPDATE_FROM_CORE);
1385 }
1386 
1387 //------------------------------------------------------------------------------
1388 // Name: slotLeftShiftclicked
1389 // Desc: executes a bitwise right shift
1390 //------------------------------------------------------------------------------
1391 void KCalculator::slotRightShiftclicked() {
1392 
1393  core.enterOperation(calc_display->getAmount(), CalcEngine::FUNC_RSH);
1394  updateDisplay(UPDATE_FROM_CORE);
1395 }
1396 
1397 //------------------------------------------------------------------------------
1398 // Name: slotPeriodclicked
1399 // Desc: enters a decimal into the input stream
1400 //------------------------------------------------------------------------------
1401 void KCalculator::slotPeriodclicked() {
1402 
1403  // i know this isn't locale friendly, should be converted to appropriate
1404  // value at lower levels
1405  calc_display->newCharacter(KGlobal::locale()->decimalSymbol()[0]);
1406 }
1407 
1408 //------------------------------------------------------------------------------
1409 // Name: EnterEqual
1410 // Desc: calculates and displays the result of the pending operations
1411 //------------------------------------------------------------------------------
1412 void KCalculator::EnterEqual() {
1413 
1414  core.enterOperation(calc_display->getAmount(), CalcEngine::FUNC_EQUAL);
1415  updateDisplay(UPDATE_FROM_CORE | UPDATE_STORE_RESULT);
1416 }
1417 
1418 //------------------------------------------------------------------------------
1419 // Name: slotEqualclicked
1420 // Desc: calculates and displays the result of the pending operations
1421 //------------------------------------------------------------------------------
1422 void KCalculator::slotEqualclicked() {
1423 
1424  EnterEqual();
1425 }
1426 
1427 //------------------------------------------------------------------------------
1428 // Name: slotPercentclicked
1429 // Desc: calculates and displays the result of the pending operations as a percent
1430 //------------------------------------------------------------------------------
1431 void KCalculator::slotPercentclicked() {
1432 
1433  core.enterOperation(calc_display->getAmount(), CalcEngine::FUNC_PERCENT);
1434  updateDisplay(UPDATE_FROM_CORE);
1435 }
1436 
1437 //------------------------------------------------------------------------------
1438 // Name: slotNegateclicked
1439 // Desc: executes a bitwise 2's compliment
1440 // NOTE: implicitly converts the value to an unsigned quantity
1441 //------------------------------------------------------------------------------
1442 void KCalculator::slotNegateclicked() {
1443 
1444  core.Complement(calc_display->getAmount());
1445  updateDisplay(UPDATE_FROM_CORE);
1446 }
1447 
1448 //------------------------------------------------------------------------------
1449 // Name: slotModclicked
1450 // Desc: executes modulous (remainder division)
1451 //------------------------------------------------------------------------------
1452 void KCalculator::slotModclicked(){
1453 
1454  if (shift_mode_) {
1455  core.enterOperation(calc_display->getAmount(), CalcEngine::FUNC_INTDIV);
1456  } else {
1457  core.enterOperation(calc_display->getAmount(), CalcEngine::FUNC_MOD);
1458  }
1459 
1460  updateDisplay(UPDATE_FROM_CORE);
1461 }
1462 
1463 //------------------------------------------------------------------------------
1464 // Name: slotStatNumclicked
1465 // Desc: executes Sum function
1466 //------------------------------------------------------------------------------
1467 void KCalculator::slotStatNumclicked() {
1468 
1469  if (!shift_mode_) {
1470  core.StatCount(KNumber::Zero);
1471  } else {
1472  pbShift->setChecked(false);
1473  core.StatSum(KNumber::Zero);
1474  }
1475 
1476  updateDisplay(UPDATE_FROM_CORE);
1477 }
1478 
1479 //------------------------------------------------------------------------------
1480 // Name: slotStatMeanclicked
1481 // Desc: executes Mean function
1482 //------------------------------------------------------------------------------
1483 void KCalculator::slotStatMeanclicked() {
1484 
1485  if (!shift_mode_) {
1486  core.StatMean(KNumber::Zero);
1487  } else {
1488  pbShift->setChecked(false);
1489  core.StatSumSquares(KNumber::Zero);
1490  }
1491 
1492  updateDisplay(UPDATE_FROM_CORE);
1493 }
1494 
1495 //------------------------------------------------------------------------------
1496 // Name: slotStatStdDevclicked
1497 // Desc: executes STD function
1498 //------------------------------------------------------------------------------
1499 void KCalculator::slotStatStdDevclicked() {
1500 
1501  if (shift_mode_) {
1502  // std (n-1)
1503  core.StatStdDeviation(KNumber::Zero);
1504  pbShift->setChecked(false);
1505  } else {
1506  // std (n)
1507  core.StatStdSample(KNumber::Zero);
1508  }
1509 
1510  updateDisplay(UPDATE_FROM_CORE);
1511 }
1512 
1513 //------------------------------------------------------------------------------
1514 // Name: slotStatMedianclicked
1515 // Desc: executes Median function
1516 //------------------------------------------------------------------------------
1517 void KCalculator::slotStatMedianclicked() {
1518 
1519  if (!shift_mode_) {
1520  // std (n-1)
1521  core.StatMedian(KNumber::Zero);
1522  } else {
1523  // std (n)
1524  core.StatMedian(KNumber::Zero);
1525  pbShift->setChecked(false);
1526  }
1527 
1528  // TODO: it seems two different modes should be implemented, but...?
1529  updateDisplay(UPDATE_FROM_CORE);
1530 }
1531 
1532 //------------------------------------------------------------------------------
1533 // Name: slotStatDataInputclicked
1534 // Desc: enters a value for statistical functions
1535 //------------------------------------------------------------------------------
1536 void KCalculator::slotStatDataInputclicked() {
1537 
1538  if (!shift_mode_) {
1539  core.StatDataNew(calc_display->getAmount());
1540  } else {
1541  pbShift->setChecked(false);
1542  core.StatDataDel(KNumber::Zero);
1543  statusBar()->showMessage(i18n("Last stat item erased"), 3000);
1544  }
1545 
1546  updateDisplay(UPDATE_FROM_CORE);
1547 }
1548 
1549 //------------------------------------------------------------------------------
1550 // Name: slotStatClearDataclicked
1551 // Desc: clears memory for statical functions
1552 //------------------------------------------------------------------------------
1553 void KCalculator::slotStatClearDataclicked() {
1554 
1555  if (!shift_mode_) {
1556  core.StatClearAll(KNumber::Zero);
1557  statusBar()->showMessage(i18n("Stat mem cleared"), 3000);
1558  } else {
1559  pbShift->setChecked(false);
1560  updateDisplay(0);
1561  }
1562 }
1563 
1564 //------------------------------------------------------------------------------
1565 // Name: slotConstclicked
1566 // Desc: enters a constant
1567 //------------------------------------------------------------------------------
1568 void KCalculator::slotConstclicked(int button) {
1569 
1570  if(KCalcConstButton *btn = qobject_cast<KCalcConstButton*>(const_buttons_[button])) {
1571  if (!shift_mode_) {
1572  // set the display to the configured value of constant button
1573  // internally, we deal with C locale style numbers, we need to convert
1574  QString val = btn->constant();
1575  val.replace(QLatin1Char('.'), KNumber::decimalSeparator());
1576  calc_display->setAmount(KNumber(val));
1577 
1578  } else {
1579  pbShift->setChecked(false);
1580 
1581  // internally, we deal with C locale style numbers, we need to convert
1582  QString val = calc_display->text();
1583  val.replace(KNumber::decimalSeparator(), QLatin1String("."));
1584  KCalcSettings::setValueConstant(button, val);
1585 
1586  // below set new tooltip
1587  btn->setLabelAndTooltip();
1588 
1589  // work around: after storing a number, pressing a digit should start
1590  // a new number
1591  calc_display->setAmount(calc_display->getAmount());
1592  }
1593 
1594  updateDisplay(0);
1595  }
1596 }
1597 
1598 //------------------------------------------------------------------------------
1599 // Name: showSettings
1600 // Desc: opens the shows the settings dialog
1601 //------------------------------------------------------------------------------
1602 void KCalculator::showSettings() {
1603 
1604  // Check if there is already a dialog and if so bring
1605  // it to the foreground.
1606  if (KConfigDialog::showDialog(QLatin1String("settings"))) {
1607  return;
1608  }
1609 
1610  // Create a new dialog with the same name as the above checking code.
1611  KConfigDialog *const dialog = new KConfigDialog(this, QLatin1String("settings"), KCalcSettings::self());
1612  dialog->showButtonSeparator(true);
1613 
1614  // general settings
1615  General *const general = new General(0);
1616  general->kcfg_Precision->setMaximum(maxprecision);
1617  dialog->addPage(general, i18n("General"), QLatin1String("accessories-calculator"), i18n("General Settings"));
1618 
1619  // font settings
1620  Fonts *const fonts = new Fonts(0);
1621  dialog->addPage(fonts, i18n("Font"), QLatin1String("preferences-desktop-font"), i18n("Select Display Font"));
1622 
1623  // color settings
1624  Colors *const color = new Colors(0);
1625  dialog->addPage(color, i18n("Colors"), QLatin1String("format-fill-color"), i18n("Button & Display Colors"));
1626 
1627  // constant settings
1628  if (!constants_) {
1629  constants_ = new Constants(0);
1630  }
1631 
1632  KCalcConstMenu *tmp_menu;
1633  tmp_menu = new KCalcConstMenu(this);
1634  connect(tmp_menu, SIGNAL(triggeredConstant(science_constant)), this, SLOT(slotChooseScientificConst0(science_constant)));
1635  constants_->pushButton0->setMenu(tmp_menu);
1636 
1637  tmp_menu = new KCalcConstMenu(this);
1638  connect(tmp_menu, SIGNAL(triggeredConstant(science_constant)), this, SLOT(slotChooseScientificConst1(science_constant)));
1639  constants_->pushButton1->setMenu(tmp_menu);
1640 
1641  tmp_menu = new KCalcConstMenu(this);
1642  connect(tmp_menu, SIGNAL(triggeredConstant(science_constant)), this, SLOT(slotChooseScientificConst2(science_constant)));
1643  constants_->pushButton2->setMenu(tmp_menu);
1644 
1645  tmp_menu = new KCalcConstMenu(this);
1646  connect(tmp_menu, SIGNAL(triggeredConstant(science_constant)), this, SLOT(slotChooseScientificConst3(science_constant)));
1647  constants_->pushButton3->setMenu(tmp_menu);
1648 
1649  tmp_menu = new KCalcConstMenu(this);
1650  connect(tmp_menu, SIGNAL(triggeredConstant(science_constant)), this, SLOT(slotChooseScientificConst4(science_constant)));
1651  constants_->pushButton4->setMenu(tmp_menu);
1652 
1653  tmp_menu = new KCalcConstMenu(this);
1654  connect(tmp_menu, SIGNAL(triggeredConstant(science_constant)), this, SLOT(slotChooseScientificConst5(science_constant)));
1655  constants_->pushButton5->setMenu(tmp_menu);
1656 
1657  dialog->addPage(constants_, i18n("Constants"), QLatin1String("preferences-kcalc-constants"), i18n("Define Constants"));
1658 
1659  // When the user clicks OK or Apply we want to update our settings.
1660  connect(dialog, SIGNAL(settingsChanged(QString)), SLOT(updateSettings()));
1661 
1662  // Display the dialog.
1663  dialog->show();
1664 }
1665 
1666 
1667 // these 6 slots are just a quick hack, instead of setting the
1668 // TextEdit fields in the configuration dialog, we are setting the
1669 // Settingvalues themselves!!
1670 
1671 //------------------------------------------------------------------------------
1672 // Name: slotChooseScientificConst0
1673 // Desc: updates constants value
1674 //------------------------------------------------------------------------------
1675 void KCalculator::slotChooseScientificConst0(const science_constant &chosen_const) {
1676  constants_->kcfg_valueConstant0->setText(chosen_const.value);
1677  constants_->kcfg_nameConstant0->setText(chosen_const.label);
1678 }
1679 
1680 //------------------------------------------------------------------------------
1681 // Name: slotChooseScientificConst1
1682 // Desc: updates constants value
1683 //------------------------------------------------------------------------------
1684 void KCalculator::slotChooseScientificConst1(const science_constant &chosen_const) {
1685  constants_->kcfg_valueConstant1->setText(chosen_const.value);
1686  constants_->kcfg_nameConstant1->setText(chosen_const.label);
1687 }
1688 
1689 //------------------------------------------------------------------------------
1690 // Name: slotChooseScientificConst2
1691 // Desc: updates constants value
1692 //------------------------------------------------------------------------------
1693 void KCalculator::slotChooseScientificConst2(const science_constant &chosen_const) {
1694  constants_->kcfg_valueConstant2->setText(chosen_const.value);
1695  constants_->kcfg_nameConstant2->setText(chosen_const.label);
1696 }
1697 
1698 //------------------------------------------------------------------------------
1699 // Name: slotChooseScientificConst3
1700 // Desc: updates constants value
1701 //------------------------------------------------------------------------------
1702 void KCalculator::slotChooseScientificConst3(const science_constant &chosen_const) {
1703  constants_->kcfg_valueConstant3->setText(chosen_const.value);
1704  constants_->kcfg_nameConstant3->setText(chosen_const.label);
1705 }
1706 
1707 //------------------------------------------------------------------------------
1708 // Name: slotChooseScientificConst4
1709 // Desc: updates constants value
1710 //------------------------------------------------------------------------------
1711 void KCalculator::slotChooseScientificConst4(const science_constant &chosen_const) {
1712  constants_->kcfg_valueConstant4->setText(chosen_const.value);
1713  constants_->kcfg_nameConstant4->setText(chosen_const.label);
1714 }
1715 
1716 //------------------------------------------------------------------------------
1717 // Name: slotChooseScientificConst5
1718 // Desc: updates constants value
1719 //------------------------------------------------------------------------------
1720 void KCalculator::slotChooseScientificConst5(const science_constant &chosen_const) {
1721  constants_->kcfg_valueConstant5->setText(chosen_const.value);
1722  constants_->kcfg_nameConstant5->setText(chosen_const.label);
1723 }
1724 
1725 //------------------------------------------------------------------------------
1726 // Name: slotSetSimpleMode
1727 // Desc: sets the calculator to have a simple layout
1728 //------------------------------------------------------------------------------
1729 void KCalculator::slotSetSimpleMode() {
1730 
1731  action_constants_show_->setChecked(false);
1732  action_constants_show_->setEnabled(false);
1733  action_bitset_show_->setChecked(false);
1734  action_bitset_show_->setEnabled(false);
1735  showMemButtons(false);
1736  showScienceButtons(false);
1737  showStatButtons(false);
1738  showLogicButtons(false);
1739 
1740  // hide some individual buttons, which are not in one of the above groups
1741  pbShift->hide();
1742  pbMod->hide();
1743  pbReci->hide();
1744  pbFactorial->hide();
1745  pbSquare->hide();
1746  pbPower->hide();
1747  pbCube->hide();
1748  pbBackspace->hide();
1749  pbEE->hide();
1750 
1751  // delete the constant menu since it doesn't fit
1752  delete constants_menu_;
1753  constants_menu_ = 0;
1754 
1755  KCalcSettings::setCalculatorMode(KCalcSettings::EnumCalculatorMode::simple);
1756 }
1757 
1758 //------------------------------------------------------------------------------
1759 // Name: slotSetScienceMode
1760 // Desc: sets the calculator to science mode
1761 //------------------------------------------------------------------------------
1762 void KCalculator::slotSetScienceMode() {
1763 
1764  action_constants_show_->setEnabled(true);
1765  action_constants_show_->setChecked(KCalcSettings::showConstants());
1766  action_bitset_show_->setChecked(false);
1767  action_bitset_show_->setEnabled(false);
1768 
1769  // show some individual buttons
1770  pbShift->show();
1771  pbMod->show();
1772  pbReci->show();
1773  pbFactorial->show();
1774  pbSquare->show();
1775  pbPower->show();
1776  pbCube->show();
1777  pbBackspace->show();
1778  pbEE->show();
1779 
1780  // show or hide some groups of buttons
1781  showMemButtons(true);
1782  showScienceButtons(true);
1783  showStatButtons(false);
1784  showLogicButtons(false);
1785 
1786  if(!constants_menu_) {
1787  constants_menu_ = createConstantsMenu();
1788  menuBar()->insertMenu((menuBar()->actions)()[2], constants_menu_);
1789  }
1790 
1791  KCalcSettings::setCalculatorMode(KCalcSettings::EnumCalculatorMode::science);
1792 }
1793 
1794 //------------------------------------------------------------------------------
1795 // Name: slotSetStatisticMode
1796 // Desc: sets the calculator to stats mode
1797 //------------------------------------------------------------------------------
1798 void KCalculator::slotSetStatisticMode() {
1799 
1800  action_constants_show_->setEnabled(true);
1801  action_constants_show_->setChecked(KCalcSettings::showConstants());
1802  action_bitset_show_->setChecked(false);
1803  action_bitset_show_->setEnabled(false);
1804 
1805  // show some individual buttons
1806  pbShift->show();
1807  pbMod->show();
1808  pbReci->show();
1809  pbFactorial->show();
1810  pbSquare->show();
1811  pbPower->show();
1812  pbCube->show();
1813  pbBackspace->show();
1814  pbEE->show();
1815 
1816  // show or hide some groups of buttons
1817  showMemButtons(true);
1818  showScienceButtons(true);
1819  showStatButtons(true);
1820  showLogicButtons(false);
1821 
1822  if(!constants_menu_) {
1823  constants_menu_ = createConstantsMenu();
1824  menuBar()->insertMenu((menuBar()->actions)()[2], constants_menu_);
1825  }
1826 
1827  KCalcSettings::setCalculatorMode(KCalcSettings::EnumCalculatorMode::statistics);
1828 }
1829 
1830 //------------------------------------------------------------------------------
1831 // Name: slotSetNumeralMode
1832 // Desc: sets the calculator to numerical ("programmers") mode
1833 //------------------------------------------------------------------------------
1834 void KCalculator::slotSetNumeralMode() {
1835 
1836  action_constants_show_->setChecked(false);
1837  action_constants_show_->setEnabled(false);
1838  action_bitset_show_->setEnabled(true);
1839  action_bitset_show_->setChecked(KCalcSettings::showBitset());
1840 
1841  // show some individual buttons
1842  pbShift->show();
1843  pbMod->show();
1844  pbReci->show();
1845  pbFactorial->show();
1846  pbSquare->show();
1847  pbPower->show();
1848  pbCube->show();
1849  pbBackspace->show();
1850  pbEE->show();
1851 
1852  // show or hide some groups of buttons
1853  showMemButtons(true);
1854  showScienceButtons(false);
1855  showStatButtons(false);
1856  showLogicButtons(true);
1857 
1858  if(!constants_menu_) {
1859  constants_menu_ = createConstantsMenu();
1860  menuBar()->insertMenu((menuBar()->actions)()[2], constants_menu_);
1861  }
1862 
1863  KCalcSettings::setCalculatorMode(KCalcSettings::EnumCalculatorMode::numeral);
1864 }
1865 
1866 //------------------------------------------------------------------------------
1867 // Name: showMemButtons
1868 // Desc: hides or shows the memory buttons
1869 //------------------------------------------------------------------------------
1870 void KCalculator::showMemButtons(bool toggled) {
1871 
1872  if (toggled) {
1873  foreach(QAbstractButton *btn, mem_button_list_) {
1874  btn->show();
1875  }
1876  } else {
1877  foreach(QAbstractButton *btn, mem_button_list_) {
1878  btn->hide();
1879  }
1880 
1881  // these are in the mem_button_list_ but should not be hidden
1882  pbClear->show();
1883  pbAllClear->show();
1884  }
1885 }
1886 
1887 //------------------------------------------------------------------------------
1888 // Name: showStatButtons
1889 // Desc: hides or shows the stat buttons
1890 //------------------------------------------------------------------------------
1891 void KCalculator::showStatButtons(bool toggled) {
1892 
1893  if (toggled) {
1894  foreach(QAbstractButton *btn, stat_buttons_) {
1895  btn->show();
1896  }
1897  } else {
1898  foreach(QAbstractButton *btn, stat_buttons_) {
1899  btn->hide();
1900  }
1901  }
1902 }
1903 
1904 //------------------------------------------------------------------------------
1905 // Name: showScienceButtons
1906 // Desc: hides or shows the science buttons
1907 //------------------------------------------------------------------------------
1908 void KCalculator::showScienceButtons(bool toggled) {
1909 
1910  if (toggled) {
1911  foreach(QAbstractButton* btn, scientific_buttons_) {
1912  btn->show();
1913  }
1914 
1915  foreach(QAbstractButton* btn, angle_choose_group_->buttons()) {
1916  btn->show();
1917  }
1918 
1919  setAngle();
1920  statusBar()->setItemFixed(AngleField, -1);
1921  } else {
1922  foreach(QAbstractButton* btn, scientific_buttons_) {
1923  btn->hide();
1924  }
1925 
1926  foreach(QAbstractButton* btn, angle_choose_group_->buttons()) {
1927  btn->hide();
1928  }
1929 
1930  statusBar()->changeItem(QString(), AngleField);
1931  statusBar()->setItemFixed(AngleField, 0);
1932  calc_display->setStatusText(AngleField, QString());
1933  }
1934 }
1935 
1936 //------------------------------------------------------------------------------
1937 // Name: showLogicButtons
1938 // Desc: hides or shows the logic buttons
1939 //------------------------------------------------------------------------------
1940 void KCalculator::showLogicButtons(bool toggled) {
1941 
1942  if (toggled) {
1943  mBitset->setEnabled(true);
1944  connect(mBitset, SIGNAL(valueChanged(quint64)), this, SLOT(slotBitsetChanged(quint64)));
1945  connect(calc_display, SIGNAL(changedAmount(KNumber)), SLOT(slotUpdateBitset(KNumber)));
1946 
1947  foreach(QAbstractButton* btn, logic_buttons_) {
1948  btn->show();
1949  }
1950 
1951  setBase();
1952  statusBar()->setItemFixed(BaseField, -1);
1953 
1954  foreach(QAbstractButton *btn, base_choose_group_->buttons()) {
1955  btn->show();
1956  }
1957 
1958  for (int i = 10; i < 16; ++i) {
1959  (num_button_group_->button(i))->show();
1960  }
1961  } else {
1962  mBitset->setEnabled(false);
1963  disconnect(mBitset, SIGNAL(valueChanged(quint64)), this, SLOT(slotBitsetChanged(quint64)));
1964  disconnect(calc_display, SIGNAL(changedAmount(KNumber)), this, SLOT(slotUpdateBitset(KNumber)));
1965 
1966  foreach(QAbstractButton* btn, logic_buttons_) {
1967  btn->hide();
1968  }
1969 
1970  // Hide Hex-Buttons, but first switch back to decimal
1971  decRadio->animateClick(0);
1972 
1973  foreach(QAbstractButton *btn, base_choose_group_->buttons()) {
1974  btn->hide();
1975  }
1976 
1977  statusBar()->changeItem(QString(), BaseField);
1978  statusBar()->setItemFixed(BaseField, 0);
1979  calc_display->setStatusText(BaseField, QString());
1980  for (int i = 10; i < 16; ++i) {
1981  (num_button_group_->button(i))->hide();
1982  }
1983  }
1984 }
1985 
1986 //------------------------------------------------------------------------------
1987 // Name: slotConstantsShow
1988 // Desc: hides or shows the constants buttons
1989 //------------------------------------------------------------------------------
1990 void KCalculator::slotConstantsShow(bool toggled) {
1991 
1992  if (toggled) {
1993  foreach(QAbstractButton *btn, const_buttons_) {
1994  btn->show();
1995  }
1996  } else {
1997  foreach(QAbstractButton *btn, const_buttons_) {
1998  btn->hide();
1999  }
2000  }
2001 
2002  KCalcSettings::setShowConstants(toggled);
2003 }
2004 
2005 //------------------------------------------------------------------------------
2006 // Name: slotBitsetshow
2007 // Desc: hides or shows the bitset buttons
2008 //------------------------------------------------------------------------------
2009 void KCalculator::slotBitsetshow(bool toggled) {
2010 
2011  mBitset->setVisible(toggled);
2012  KCalcSettings::setShowBitset(toggled);
2013 }
2014 
2015 //------------------------------------------------------------------------------
2016 // Name: slotBitsetshow
2017 // Desc: This function is for setting the constant names configured in the
2018 // kcalc settings menu. If the user doesn't enter a name for the
2019 // constant C1 to C6 is used.
2020 //------------------------------------------------------------------------------
2021 void KCalculator::changeButtonNames() {
2022 
2023  foreach(QAbstractButton *btn, const_buttons_) {
2024  if (KCalcConstButton *const constbtn = qobject_cast<KCalcConstButton*>(btn)) {
2025  constbtn->setLabelAndTooltip();
2026  }
2027  }
2028 }
2029 
2030 //------------------------------------------------------------------------------
2031 // Name: slotBitsetChanged
2032 // Desc: updates the bitset display
2033 // NOTE: sets display to *unsigned* value
2034 //------------------------------------------------------------------------------
2035 void KCalculator::slotBitsetChanged(quint64 value) {
2036 
2037  calc_display->setAmount(KNumber(value));
2038  updateDisplay(0);
2039 }
2040 
2041 //------------------------------------------------------------------------------
2042 // Name: slotUpdateBitset
2043 // Desc: updates the bitset itself
2044 //------------------------------------------------------------------------------
2045 void KCalculator::slotUpdateBitset(const KNumber &nr) {
2046 
2047  mBitset->setValue(nr.toUint64());
2048 }
2049 
2050 //------------------------------------------------------------------------------
2051 // Name: updateSettings
2052 // Desc: updates the persistent settings
2053 //------------------------------------------------------------------------------
2054 void KCalculator::updateSettings() {
2055 
2056  changeButtonNames();
2057  setColors();
2058  setFonts();
2059  setPrecision();
2060 
2061  // Show the result in the app's caption in taskbar (wishlist - bug #52858)
2062  disconnect(calc_display, SIGNAL(changedText(QString)), this, 0);
2063 
2064  if (KCalcSettings::captionResult()) {
2065  connect(calc_display, SIGNAL(changedText(QString)), SLOT(setCaption(QString)));
2066  } else {
2067  setCaption(QString());
2068  }
2069 
2070  calc_display->changeSettings();
2071  updateGeometry();
2072 }
2073 
2074 //------------------------------------------------------------------------------
2075 // Name: updateDisplay
2076 // Desc: updates the display
2077 //------------------------------------------------------------------------------
2078 void KCalculator::updateDisplay(UpdateFlags flags) {
2079 
2080  if(flags & UPDATE_FROM_CORE) {
2081  calc_display->updateFromCore(core, (flags & UPDATE_STORE_RESULT) != 0);
2082  } else {
2083  calc_display->update();
2084  }
2085 
2086  pbShift->setChecked(false);
2087 
2088 }
2089 
2090 //------------------------------------------------------------------------------
2091 // Name: setColors
2092 // Desc: set the various colours
2093 //------------------------------------------------------------------------------
2094 void KCalculator::setColors() {
2095 
2096  calc_display->changeSettings();
2097 
2098  KColorScheme schemeButtons(QPalette::Active, KColorScheme::Button);
2099  const QColor defaultColor = schemeButtons.background().color();
2100 
2101  if (KCalcSettings::numberButtonsColor() == defaultColor
2102  && KCalcSettings::functionButtonsColor() == defaultColor
2103  && KCalcSettings::statButtonsColor() == defaultColor
2104  && KCalcSettings::hexButtonsColor() == defaultColor
2105  && KCalcSettings::memoryButtonsColor() == defaultColor
2106  && KCalcSettings::operationButtonsColor() == defaultColor) {
2107  return;
2108  }
2109 
2110  const QString sheet = QLatin1String("KPushButton { background-color: %1 }");
2111 
2112  const QColor numPal(KCalcSettings::numberButtonsColor());
2113  for (int i = 0; i < 10; ++i) {
2114  (num_button_group_->button(i))->setStyleSheet(sheet.arg(numPal.name()));
2115  }
2116 
2117  const QColor funcPal(KCalcSettings::functionButtonsColor());
2118  foreach(QAbstractButton *btn, function_button_list_) {
2119  btn->setStyleSheet(sheet.arg(funcPal.name()));
2120  }
2121 
2122  const QColor statPal(KCalcSettings::statButtonsColor());
2123  foreach(QAbstractButton *btn, stat_buttons_) {
2124  btn->setStyleSheet(sheet.arg(statPal.name()));
2125  }
2126 
2127  const QColor hexPal(KCalcSettings::hexButtonsColor());
2128  for (int i = 10; i < 16; ++i) {
2129  (num_button_group_->button(i))->setStyleSheet(sheet.arg(hexPal.name()));
2130  }
2131 
2132  const QColor memPal(KCalcSettings::memoryButtonsColor());
2133  foreach(QAbstractButton *btn, mem_button_list_) {
2134  btn->setStyleSheet(sheet.arg(memPal.name()));
2135  }
2136 
2137  const QColor opPal(KCalcSettings::operationButtonsColor());
2138  foreach(QAbstractButton *btn, operation_button_list_) {
2139  btn->setStyleSheet(sheet.arg(opPal.name()));
2140  }
2141 }
2142 
2143 //------------------------------------------------------------------------------
2144 // Name: setFonts
2145 // Desc: set the various fonts
2146 //------------------------------------------------------------------------------
2147 void KCalculator::setFonts() {
2148 
2149  foreach(QObject *obj, leftPad->children()) {
2150  if (KCalcButton *const button = qobject_cast<KCalcButton*>(obj)) {
2151  button->setFont(KCalcSettings::buttonFont());
2152  }
2153  }
2154 
2155  foreach(QObject *obj, numericPad->children()) {
2156  if (KCalcButton *const button = qobject_cast<KCalcButton*>(obj)) {
2157  button->setFont(KCalcSettings::buttonFont());
2158  }
2159  }
2160 
2161  foreach(QObject *obj, rightPad->children()) {
2162  if (KCalcButton *const button = qobject_cast<KCalcButton*>(obj)) {
2163  button->setFont(KCalcSettings::buttonFont());
2164  }
2165  }
2166 
2167  updateGeometry();
2168 }
2169 
2170 //------------------------------------------------------------------------------
2171 // Name: setPrecision
2172 // Desc: set the precision of the display
2173 //------------------------------------------------------------------------------
2174 void KCalculator::setPrecision() {
2175 
2176  KNumber::setDefaultFloatPrecision(KCalcSettings::precision());
2177  updateDisplay(0);
2178 }
2179 
2180 //------------------------------------------------------------------------------
2181 // Name: setAngle
2182 // Desc: sets the angle mode
2183 //------------------------------------------------------------------------------
2184 void KCalculator::setAngle() {
2185 
2186  if (QAbstractButton *const btn = angle_choose_group_->button(KCalcSettings::angleMode())) {
2187  btn->animateClick(0);
2188  }
2189 }
2190 
2191 //------------------------------------------------------------------------------
2192 // Name: setBase
2193 // Desc: sets the numeric base
2194 //------------------------------------------------------------------------------
2195 void KCalculator::setBase() {
2196  if (QAbstractButton *const btn = base_choose_group_->button(KCalcSettings::baseMode())) {
2197  btn->animateClick(0);
2198  }
2199 }
2200 
2201 //------------------------------------------------------------------------------
2202 // Name: eventFilter
2203 // Desc: general event filter used to track events like drag/drop
2204 //------------------------------------------------------------------------------
2205 bool KCalculator::eventFilter(QObject *o, QEvent *e) {
2206 
2207  switch (e->type()) {
2208  case QEvent::DragEnter: {
2209  QDragEnterEvent *const ev = reinterpret_cast<QDragEnterEvent *>(e);
2210  ev->setAccepted(KColorMimeData::canDecode(ev->mimeData()));
2211  return true;
2212  }
2213  case QEvent::DragLeave: {
2214  return true;
2215  }
2216  case QEvent::Drop: {
2217  KCalcButton *const calcButton = qobject_cast<KCalcButton *>(o);
2218  if (!calcButton) {
2219  return false;
2220  }
2221 
2222  QDropEvent *const ev = reinterpret_cast<QDropEvent *>(e);
2223  QColor c = KColorMimeData::fromMimeData(ev->mimeData());
2224 
2225  if (c.isValid()) {
2226  QString cn = c.name();
2227  QString sheet = QLatin1String("background-color: %1");
2228 
2229  QList<QAbstractButton*> *list;
2230  const int num_but = num_button_group_->buttons().indexOf(calcButton);
2231  if (num_but != -1) {
2232  // Was it hex-button or normal digit??
2233  if (num_but < 10) {
2234  for (int i = 0; i < 10; ++i) {
2235  (num_button_group_->buttons()[i])->setStyleSheet(sheet.arg(cn));
2236  }
2237  } else {
2238  for (int i = 10; i < 16; ++i) {
2239  (num_button_group_->buttons()[i])->setStyleSheet(sheet.arg(cn));
2240  }
2241  }
2242  return true;
2243  } else if (function_button_list_.contains(calcButton)) {
2244  list = &function_button_list_;
2245  } else if (stat_button_list_.contains(calcButton)) {
2246  list = &stat_button_list_;
2247  } else if (mem_button_list_.contains(calcButton)) {
2248  list = &mem_button_list_;
2249  } else if (operation_button_list_.contains(calcButton)) {
2250  list = &operation_button_list_;
2251  } else {
2252  return false;
2253  }
2254 
2255  for (int i = 0; i < list->size(); ++i) {
2256  list->at(i)->setStyleSheet(sheet.arg(cn));
2257  }
2258  }
2259  return true;
2260  }
2261  // FALL THROUGH
2262  default:
2263  return KXmlGuiWindow::eventFilter(o, e);
2264  }
2265 }
2266 
2268 // Include the meta-object code for classes in this file
2269 //
2270 #include "kcalc.moc"
2271 
2272 //------------------------------------------------------------------------------
2273 // Name: kdemain
2274 // Desc: entry point of the application
2275 //------------------------------------------------------------------------------
2276 extern "C" KDE_EXPORT int kdemain(int argc, char *argv[]) {
2277 
2278  KAboutData aboutData("kcalc",
2279  0,
2280  ki18n("KCalc"),
2281  version,
2282  ki18n(description),
2283  KAboutData::License_GPL,
2284  ki18n(
2285  "&copy; 2008-2013, Evan Teran\n"
2286  "&copy; 2000-2008, The KDE Team\n"
2287  "&copy; 2003-2005, Klaus Niederkr" "\xc3\xbc" "ger\n"
2288  "&copy; 1996-2000, Bernd Johannes Wuebben"),
2289  KLocalizedString(),
2290  "http://utils.kde.org/projects/kcalc");
2291 
2292  // Klaus Niederkrueger
2293  aboutData.addAuthor(ki18n("Klaus Niederkr" "\xc3\xbc" "ger"), KLocalizedString(), "kniederk@math.uni-koeln.de");
2294  aboutData.addAuthor(ki18n("Bernd Johannes Wuebben"), KLocalizedString(), "wuebben@kde.org");
2295  aboutData.addAuthor(ki18n("Evan Teran"), ki18n("Maintainer"), "eteran@alum.rit.edu");
2296  aboutData.addAuthor(ki18n("Espen Sand"), KLocalizedString(), "espen@kde.org");
2297  aboutData.addAuthor(ki18n("Chris Howells"), KLocalizedString(), "howells@kde.org");
2298  aboutData.addAuthor(ki18n("Aaron J. Seigo"), KLocalizedString(), "aseigo@olympusproject.org");
2299  aboutData.addAuthor(ki18n("Charles Samuels"), KLocalizedString(), "charles@altair.dhs.org");
2300  // Rene Merou
2301  aboutData.addAuthor(ki18n("Ren" "\xc3\xa9" " M" "\xc3\xa9" "rou"), KLocalizedString(), "ochominutosdearco@yahoo.es");
2302  aboutData.addAuthor(ki18n("Michel Marti"), KLocalizedString(), "mma@objectxp.com");
2303  aboutData.addAuthor(ki18n("David Johnson"), KLocalizedString(), "david@usermode.org");
2304 
2305  aboutData.setProgramIconName(QLatin1String("accessories-calculator"));
2306 
2307  KCmdLineArgs::init(argc, argv, &aboutData);
2308 
2309  KApplication app;
2310 
2311  // force system locale to "C" internally [bug 159168]
2312  setlocale(LC_NUMERIC, "C");
2313 
2314  KNumber::setGroupSeparator(KGlobal::locale()->thousandsSeparator());
2315  KNumber::setDecimalSeparator(KGlobal::locale()->decimalSymbol());
2316 
2317  KCalculator *calc = new KCalculator(0);
2318  app.setTopWidget(calc);
2319 
2320  calc->show();
2321  return app.exec();
2322 }
CalcEngine::CosGrad
void CosGrad(const KNumber &input)
Definition: kcalc_core.cpp:443
QAbstractButton
KCalcDisplay::EventReset
Definition: kcalcdisplay.h:68
CalcEngine::Square
void Square(const KNumber &input)
Definition: kcalc_core.cpp:665
CalcEngine::Complement
void Complement(const KNumber &input)
Definition: kcalc_core.cpp:394
KCalcSettings::operationButtonsColor
static QColor operationButtonsColor()
Get The color of operation buttons.
Definition: kcalc_settings.h:172
KCalculator::slotSetStatisticMode
void slotSetStatisticMode()
Definition: kcalc.cpp:1798
KCalcSettings::statButtonsColor
static QColor statButtonsColor()
Get The color of statistical buttons.
Definition: kcalc_settings.h:115
KCalcSettings::setBaseMode
static void setBaseMode(uint v)
Set Numeric base.
Definition: kcalc_settings.h:440
KCalculator::slotNegateclicked
void slotNegateclicked()
Definition: kcalc.cpp:1442
CalcEngine::SquareRoot
void SquareRoot(const KNumber &input)
Definition: kcalc_core.cpp:670
KCalculator::slotChooseScientificConst4
void slotChooseScientificConst4(const science_constant &)
Definition: kcalc.cpp:1711
CalcEngine::AreaSinHyp
void AreaSinHyp(const KNumber &input)
Definition: kcalc_core.cpp:356
KCalcSettings::setShowConstants
static void setShowConstants(bool v)
Set Whether to show constant buttons.
Definition: kcalc_settings.h:402
CalcEngine::CosDeg
void CosDeg(const KNumber &input)
Definition: kcalc_core.cpp:404
KCalcSettings::memoryButtonsColor
static QColor memoryButtonsColor()
Get The color of memory buttons.
Definition: kcalc_settings.h:153
CalcEngine::enterOperation
void enterOperation(const KNumber &num, Operation func)
Definition: kcalc_core.cpp:810
General
Definition: kcalc.h:62
Colors
Definition: kcalc.h:86
CalcEngine::StatSumSquares
void StatSumSquares(const KNumber &input)
Definition: kcalc_core.cpp:738
KCalculator::slotBitsetChanged
void slotBitsetChanged(quint64)
Definition: kcalc.cpp:2035
KCalculator::slotRightShiftclicked
void slotRightShiftclicked()
Definition: kcalc.cpp:1391
KCalcSettings::showBitset
static bool showBitset()
Get Whether to show the bit edit widget.
Definition: kcalc_settings.h:393
CalcEngine::TangensDeg
void TangensDeg(const KNumber &input)
Definition: kcalc_core.cpp:746
KCalculator::slotORclicked
void slotORclicked()
Definition: kcalc.cpp:1341
CalcEngine::Reset
void Reset()
Definition: kcalc_core.cpp:863
KNumber::decimalSeparator
static QString decimalSeparator()
Definition: knumber.cpp:203
KCALCVERSION
#define KCALCVERSION
Definition: version.h:20
KCalculator::slotStatStdDevclicked
void slotStatStdDevclicked()
Definition: kcalc.cpp:1499
KNumber::setGroupSeparator
static void setGroupSeparator(const QString &ch)
Definition: knumber.cpp:182
CalcEngine::FUNC_INTDIV
Definition: kcalc_core.h:46
KNumber::Zero
static const KNumber Zero
Definition: knumber.h:50
KCalculator::slotConstantsShow
void slotConstantsShow(bool toggled)
Definition: kcalc.cpp:1990
CalcEngine::Reciprocal
void Reciprocal(const KNumber &input)
Definition: kcalc_core.cpp:580
CalcEngine::TangensHyp
void TangensHyp(const KNumber &input)
Definition: kcalc_core.cpp:788
KCalculator::showSettings
void showSettings()
Definition: kcalc.cpp:1602
QWidget
CalcEngine::CubeRoot
void CubeRoot(const KNumber &input)
Definition: kcalc_core.cpp:491
KCalculator::slotPercentclicked
void slotPercentclicked()
Definition: kcalc.cpp:1431
KCalcSettings::hexButtonsColor
static QColor hexButtonsColor()
Get The color of hex buttons.
Definition: kcalc_settings.h:134
KCalcSettings::EnumCalculatorMode::simple
Definition: kcalc_settings.h:19
CalcEngine::ParenOpen
void ParenOpen(const KNumber &input)
Definition: kcalc_core.cpp:575
CalcEngine::FUNC_SUBTRACT
Definition: kcalc_core.h:42
CalcEngine::Exp
void Exp(const KNumber &input)
Definition: kcalc_core.cpp:496
KCalcSettings::EnumCalculatorMode::science
Definition: kcalc_settings.h:19
KCalculator::slotConstantToDisplay
void slotConstantToDisplay(const science_constant &const_chosen)
Definition: kcalc.cpp:743
KCalculator::slotLogclicked
void slotLogclicked()
Definition: kcalc.cpp:1171
KCalcSettings::functionButtonsColor
static QColor functionButtonsColor()
Get The color of function buttons.
Definition: kcalc_settings.h:96
KCalculator::slotBackspaceclicked
void slotBackspaceclicked()
Definition: kcalc.cpp:1263
CalcEngine::SinRad
void SinRad(const KNumber &input)
Definition: kcalc_core.cpp:614
CalcEngine::StatMedian
void StatMedian(const KNumber &input)
Definition: kcalc_core.cpp:708
CalcEngine::FUNC_RSH
Definition: kcalc_core.h:40
KCalculator::slotStatClearDataclicked
void slotStatClearDataclicked()
Definition: kcalc.cpp:1553
kcalcdisplay.h
KCalculator::~KCalculator
~KCalculator()
Definition: kcalc.cpp:175
KCalculator::slotStatDataInputclicked
void slotStatDataInputclicked()
Definition: kcalc.cpp:1536
CalcEngine::TangensRad
void TangensRad(const KNumber &input)
Definition: kcalc_core.cpp:760
kcalc_const_menu.h
KCalculator::slotModclicked
void slotModclicked()
Definition: kcalc.cpp:1452
KCalculator::slotStatNumclicked
void slotStatNumclicked()
Definition: kcalc.cpp:1467
KCalculator::slotFactorialclicked
void slotFactorialclicked()
Definition: kcalc.cpp:1156
KCalculator::slotDivisionclicked
void slotDivisionclicked()
Definition: kcalc.cpp:1331
CalcEngine::StatMean
void StatMean(const KNumber &input)
Definition: kcalc_core.cpp:700
ButtonModeFlags
ButtonModeFlags
Definition: kcalc_button.h:36
KCalculator::slotMultiplicationclicked
void slotMultiplicationclicked()
Definition: kcalc.cpp:1321
CalcEngine::FUNC_DIVIDE
Definition: kcalc_core.h:44
CalcEngine::FUNC_PERCENT
Definition: kcalc_core.h:34
KCalcConstMenu::init_consts
static void init_consts()
Definition: kcalc_const_menu.cpp:61
ModeNormal
Definition: kcalc_button.h:37
CalcEngine::FUNC_MULTIPLY
Definition: kcalc_core.h:43
KCalculator::slotStatMedianclicked
void slotStatMedianclicked()
Definition: kcalc.cpp:1517
KNumber::setDefaultFloatPrecision
static void setDefaultFloatPrecision(int precision)
Definition: knumber.cpp:210
NumBase
NumBase
Definition: kcalcdisplay.h:52
CalcEngine::Cube
void Cube(const KNumber &input)
Definition: kcalc_core.cpp:486
CalcEngine::SinHyp
void SinHyp(const KNumber &input)
Definition: kcalc_core.cpp:653
KCalculator::slotANDclicked
void slotANDclicked()
Definition: kcalc.cpp:1311
CalcEngine::StatStdSample
void StatStdSample(const KNumber &input)
Definition: kcalc_core.cpp:724
KCalculator::slotPlusclicked
void slotPlusclicked()
Definition: kcalc.cpp:1361
CalcEngine::SinDeg
void SinDeg(const KNumber &input)
Definition: kcalc_core.cpp:586
science_constant
Definition: kcalc_const_menu.h:36
CalcEngine::ArcCosGrad
void ArcCosGrad(const KNumber &input)
Definition: kcalc_core.cpp:217
CalcEngine::ArcSinDeg
void ArcSinDeg(const KNumber &input)
Definition: kcalc_core.cpp:240
KXmlGuiWindow
CalcEngine::ArcTangensDeg
void ArcTangensDeg(const KNumber &input)
Definition: kcalc_core.cpp:298
KCalcSettings::setAngleMode
static void setAngleMode(uint v)
Set Degrees, radians or grads.
Definition: kcalc_settings.h:421
KCalcSettings::EnumCalculatorMode::statistics
Definition: kcalc_settings.h:19
CalcEngine::ArcCosDeg
void ArcCosDeg(const KNumber &input)
Definition: kcalc_core.cpp:184
CalcEngine::SinGrad
void SinGrad(const KNumber &input)
Definition: kcalc_core.cpp:624
CalcEngine::FUNC_BINOM
Definition: kcalc_core.h:47
CalcEngine::FUNC_AND
Definition: kcalc_core.h:38
KCalculator::slotSinclicked
void slotSinclicked()
Definition: kcalc.cpp:965
KCalculator::slotChooseScientificConst5
void slotChooseScientificConst5(const science_constant &)
Definition: kcalc.cpp:1720
science_constant::label
QString label
Definition: kcalc_const_menu.h:37
KCalcSettings::EnumCalculatorMode::type
type
Definition: kcalc_settings.h:19
KCalcSettings::setShowBitset
static void setShowBitset(bool v)
Set Whether to show the bit edit widget.
Definition: kcalc_settings.h:383
Constants
Definition: kcalc.h:78
CalcEngine::CosHyp
void CosHyp(const KNumber &input)
Definition: kcalc_core.cpp:470
KCalculator::slotMemStoreclicked
void slotMemStoreclicked()
Definition: kcalc.cpp:942
KCalculator::switchShowAccels
void switchShowAccels(bool)
CalcEngine::FUNC_LSH
Definition: kcalc_core.h:39
KCalculator::slotParenCloseclicked
void slotParenCloseclicked()
Definition: kcalc.cpp:1301
NB_DECIMAL
Definition: kcalcdisplay.h:55
KCalculator::slotConstclicked
void slotConstclicked(int)
Definition: kcalc.cpp:1568
KCalculator::slotMinusclicked
void slotMinusclicked()
Definition: kcalc.cpp:1371
KCalculator::slotLeftShiftclicked
void slotLeftShiftclicked()
Definition: kcalc.cpp:1381
KCalculator::slotSetNumeralMode
void slotSetNumeralMode()
Definition: kcalc.cpp:1834
KCalculator::slotAngleSelected
void slotAngleSelected(int mode)
Definition: kcalc.cpp:862
CalcEngine::AreaTangensHyp
void AreaTangensHyp(const KNumber &input)
Definition: kcalc_core.cpp:372
CalcEngine::FUNC_XOR
Definition: kcalc_core.h:37
KCalcSettings::numberButtonsColor
static QColor numberButtonsColor()
Get The color of number buttons.
Definition: kcalc_settings.h:77
ModeHyperbolic
Definition: kcalc_button.h:39
CalcEngine::CosRad
void CosRad(const KNumber &input)
Definition: kcalc_core.cpp:433
CalcEngine::Log10
void Log10(const KNumber &input)
Definition: kcalc_core.cpp:549
CalcEngine::StatSum
void StatSum(const KNumber &input)
Definition: kcalc_core.cpp:732
CalcEngine::Factorial
void Factorial(const KNumber &input)
Definition: kcalc_core.cpp:519
KCalculator::slotChooseScientificConst0
void slotChooseScientificConst0(const science_constant &)
Definition: kcalc.cpp:1675
KCalcConstMenu
Definition: kcalc_const_menu.h:44
ModeShift
Definition: kcalc_button.h:38
KCalculator::changeButtonNames
void changeButtonNames()
Definition: kcalc.cpp:2021
CalcEngine::ArcSinGrad
void ArcSinGrad(const KNumber &input)
Definition: kcalc_core.cpp:274
KCalculator::slotCubeclicked
void slotCubeclicked()
Definition: kcalc.cpp:1201
CalcEngine::ArcSinRad
void ArcSinRad(const KNumber &input)
Definition: kcalc_core.cpp:264
CalcEngine::StatClearAll
void StatClearAll(const KNumber &input)
Definition: kcalc_core.cpp:675
KCalculator::slotTanclicked
void slotTanclicked()
Definition: kcalc.cpp:1111
KCalcSettings::EnumCalculatorMode::numeral
Definition: kcalc_settings.h:19
KCalcSettings::buttonFont
static QFont buttonFont()
Get The font to use for the buttons.
Definition: kcalc_settings.h:191
KNumber
Definition: knumber.h:31
CalcEngine::AreaCosHyp
void AreaCosHyp(const KNumber &input)
Definition: kcalc_core.cpp:336
Fonts
Definition: kcalc.h:70
kcalc_settings.h
KCalculator::KCalculator
KCalculator(QWidget *parent=0)
Definition: kcalc.cpp:76
CalcEngine::FUNC_PWR_ROOT
Definition: kcalc_core.h:49
KCalculator::slotEEclicked
void slotEEclicked()
Definition: kcalc.cpp:890
CalcEngine::TangensGrad
void TangensGrad(const KNumber &input)
Definition: kcalc_core.cpp:774
KCalculator::slotAllClearclicked
void slotAllClearclicked()
Definition: kcalc.cpp:1281
KCalculator::slotMemClearclicked
void slotMemClearclicked()
Definition: kcalc.cpp:1251
version.h
KCalculator::slotLnclicked
void slotLnclicked()
Definition: kcalc.cpp:1216
CalcEngine::FUNC_EQUAL
Definition: kcalc_core.h:33
KCalcSettings::setCalculatorMode
static void setCalculatorMode(EnumCalculatorMode::type v)
Set CalculatorMode.
Definition: kcalc_settings.h:364
KNumber::toUint64
quint64 toUint64() const
Definition: knumber.cpp:630
kdemain
KDE_EXPORT int kdemain(int argc, char *argv[])
Definition: kcalc.cpp:2276
KCalculator::slotPowerclicked
void slotPowerclicked()
Definition: kcalc.cpp:1231
KNumber::setDecimalSeparator
static void setDecimalSeparator(const QString &ch)
Definition: knumber.cpp:189
KCalcSettings::calculatorMode
static EnumCalculatorMode::type calculatorMode()
Get CalculatorMode.
Definition: kcalc_settings.h:374
KCalcSettings::setValueConstant
static void setValueConstant(int i, const QString &v)
Set List of user programmable constants.
Definition: kcalc_settings.h:535
CalcEngine::FUNC_ADD
Definition: kcalc_core.h:41
kcalc.h
KCalcSettings::showConstants
static bool showConstants()
Get Whether to show constant buttons.
Definition: kcalc_settings.h:412
KCalculator::EnterEqual
void EnterEqual()
Definition: kcalc.cpp:1412
CalcEngine::StatDataDel
void StatDataDel(const KNumber &input)
Definition: kcalc_core.cpp:693
KCalcDisplay::EventClear
Definition: kcalcdisplay.h:69
CalcEngine::ParenClose
void ParenClose(KNumber input)
Definition: kcalc_core.cpp:562
KCalculator::slotEqualclicked
void slotEqualclicked()
Definition: kcalc.cpp:1422
KCalculator::slotBaseSelected
void slotBaseSelected(int base)
Definition: kcalc.cpp:755
KCalculator::slotSetScienceMode
void slotSetScienceMode()
Definition: kcalc.cpp:1762
CalcEngine::FUNC_OR
Definition: kcalc_core.h:36
KCalculator::setFonts
void setFonts()
Definition: kcalc.cpp:2147
KCalculator::slotStatMeanclicked
void slotStatMeanclicked()
Definition: kcalc.cpp:1483
KCalcSettings::precision
static uint precision()
Get Maximum number of digits displayed.
Definition: kcalc_settings.h:241
CalcEngine::ArcCosRad
void ArcCosRad(const KNumber &input)
Definition: kcalc_core.cpp:208
KCalculator::slotChooseScientificConst1
void slotChooseScientificConst1(const science_constant &)
Definition: kcalc.cpp:1684
KCalcButton::setFont
void setFont(const QFont &fnt)
Definition: kcalc_button.cpp:215
CalcEngine::ArcTangensRad
void ArcTangensRad(const KNumber &input)
Definition: kcalc_core.cpp:310
KCalculator::slotSquareclicked
void slotSquareclicked()
Definition: kcalc.cpp:1186
KCalculator::setColors
void setColors()
Definition: kcalc.cpp:2094
KCalculator::switchMode
void switchMode(ButtonModeFlags, bool)
KCalcSettings::baseMode
static uint baseMode()
Get Numeric base.
Definition: kcalc_settings.h:450
KCalculator::UPDATE_FROM_CORE
Definition: kcalc.h:110
KCalculator::slotClearclicked
void slotClearclicked()
Definition: kcalc.cpp:1272
science_constant::value
QString value
Definition: kcalc_const_menu.h:40
KCalculator::slotParenOpenclicked
void slotParenOpenclicked()
Definition: kcalc.cpp:1292
KCalcDisplay::EventChangeSign
Definition: kcalcdisplay.h:71
KCalcSettings::angleMode
static uint angleMode()
Get Degrees, radians or grads.
Definition: kcalc_settings.h:431
KCalculator::slotChooseScientificConst2
void slotChooseScientificConst2(const science_constant &)
Definition: kcalc.cpp:1693
KCalculator::slotPeriodclicked
void slotPeriodclicked()
Definition: kcalc.cpp:1401
CalcEngine::FUNC_POWER
Definition: kcalc_core.h:48
KCalculator::slotChooseScientificConst3
void slotChooseScientificConst3(const science_constant &)
Definition: kcalc.cpp:1702
KCalculator::updateSettings
void updateSettings()
Definition: kcalc.cpp:2054
KCalcConstButton
Definition: kcalc_const_button.h:30
KCalculator::slotCosclicked
void slotCosclicked()
Definition: kcalc.cpp:1045
KCalculator::slotBitsetshow
void slotBitsetshow(bool toggled)
Definition: kcalc.cpp:2009
KCalculator::slotPlusMinusclicked
void slotPlusMinusclicked()
Definition: kcalc.cpp:1010
KCalculator::slotUpdateBitset
void slotUpdateBitset(const KNumber &)
Definition: kcalc.cpp:2045
CalcEngine::InvertSign
void InvertSign(const KNumber &input)
Definition: kcalc_core.cpp:531
CalcEngine::StatStdDeviation
void StatStdDeviation(const KNumber &input)
Definition: kcalc_core.cpp:716
CalcEngine::StatDataNew
void StatDataNew(const KNumber &input)
Definition: kcalc_core.cpp:687
KCalculator::slotReciclicked
void slotReciclicked()
Definition: kcalc.cpp:1090
KCalculator::slotMemRecallclicked
void slotMemRecallclicked()
Definition: kcalc.cpp:929
KCalculator::slotMemPlusMinusclicked
void slotMemPlusMinusclicked()
Definition: kcalc.cpp:1024
KCalcSettings::captionResult
static bool captionResult()
Get Whether to show the result in the window title.
Definition: kcalc_settings.h:317
KCalculator::slotHyptoggled
void slotHyptoggled(bool flag)
Definition: kcalc.cpp:917
KCalcSettings::self
static KCalcSettings * self()
Definition: kcalc_settings.cpp:17
kcalc_bitset.h
KCalculator::slotNumberclicked
void slotNumberclicked(int number_clicked)
Definition: kcalc.cpp:956
KCalculator
Definition: kcalc.h:95
CalcEngine::Exp10
void Exp10(const KNumber &input)
Definition: kcalc_core.cpp:507
CalcEngine::StatCount
void StatCount(const KNumber &input)
Definition: kcalc_core.cpp:681
KCalculator::slotXORclicked
void slotXORclicked()
Definition: kcalc.cpp:1351
CalcEngine::FUNC_MOD
Definition: kcalc_core.h:45
KCalculator::slotShifttoggled
void slotShifttoggled(bool myboolean)
Definition: kcalc.cpp:898
CalcEngine::ArcTangensGrad
void ArcTangensGrad(const KNumber &input)
Definition: kcalc_core.cpp:324
KCalcButton
Definition: kcalc_button.h:58
KCalculator::slotSetSimpleMode
void slotSetSimpleMode()
Definition: kcalc.cpp:1729
KCalculator::UPDATE_STORE_RESULT
Definition: kcalc.h:111
CalcEngine::Ln
void Ln(const KNumber &input)
Definition: kcalc_core.cpp:536
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:08:05 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kcalc

Skip menu "kcalc"
  • Main Page
  • Namespace List
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdeutils API Reference

Skip menu "kdeutils API Reference"
  • ark
  • filelight
  • kcalc
  • kcharselect
  • kdf
  • kfloppy
  • kgpg
  • kremotecontrol
  • ktimer
  • kwallet
  • superkaramba
  • sweeper

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