From f8e81095eabc1594cb4f1b47c8abc31a03ae9462 Mon Sep 17 00:00:00 2001 From: Volker Lanz Date: Tue, 27 Apr 2010 11:41:35 +0000 Subject: [PATCH] add a formatted spin box svn path=/trunk/extragear/sysadmin/partitionmanager/; revision=1119557 --- src/gui/formattedspinbox.cpp | 33 +++++++++++++++++++++++++++++ src/gui/formattedspinbox.h | 36 ++++++++++++++++++++++++++++++++ src/gui/sizedetailswidgetbase.ui | 11 ++++++++-- src/gui/sizedialogwidgetbase.ui | 11 +++++++--- 4 files changed, 86 insertions(+), 5 deletions(-) create mode 100644 src/gui/formattedspinbox.cpp create mode 100644 src/gui/formattedspinbox.h diff --git a/src/gui/formattedspinbox.cpp b/src/gui/formattedspinbox.cpp new file mode 100644 index 0000000..aa99d01 --- /dev/null +++ b/src/gui/formattedspinbox.cpp @@ -0,0 +1,33 @@ +/*************************************************************************** + * Copyright (C) 2010 by Volker Lanz * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * + ***************************************************************************/ + +#include "gui/formattedspinbox.h" + +#include +#include + +QString FormattedSpinBox::textFromValue(double value) const +{ + return KGlobal::locale()->formatNumber(value, decimals()); +} + +double FormattedSpinBox::valueFromText(const QString& text) const +{ + return KGlobal::locale()->readNumber(text); +} diff --git a/src/gui/formattedspinbox.h b/src/gui/formattedspinbox.h new file mode 100644 index 0000000..9850aa2 --- /dev/null +++ b/src/gui/formattedspinbox.h @@ -0,0 +1,36 @@ +/*************************************************************************** + * Copyright (C) 2010 by Volker Lanz * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * + ***************************************************************************/ + +#if !defined(FORMATTEDSPINBOX__H) + +#define FORMATTEDSPINBOX__H + +#include + +class FormattedSpinBox : public QDoubleSpinBox +{ + public: + FormattedSpinBox(QWidget* parent = NULL) : QDoubleSpinBox(parent) {} + + public: + virtual QString textFromValue(double value) const; + virtual double valueFromText(const QString& text) const; +}; + +#endif diff --git a/src/gui/sizedetailswidgetbase.ui b/src/gui/sizedetailswidgetbase.ui index c59a923..64e9f66 100644 --- a/src/gui/sizedetailswidgetbase.ui +++ b/src/gui/sizedetailswidgetbase.ui @@ -70,7 +70,7 @@ - + 3 @@ -108,7 +108,7 @@ - + 3 @@ -177,6 +177,13 @@ + + + FormattedSpinBox + QDoubleSpinBox +
gui/formattedspinbox.h
+
+
diff --git a/src/gui/sizedialogwidgetbase.ui b/src/gui/sizedialogwidgetbase.ui index ce301c2..93e3f30 100644 --- a/src/gui/sizedialogwidgetbase.ui +++ b/src/gui/sizedialogwidgetbase.ui @@ -216,7 +216,7 @@ - + 3 @@ -251,7 +251,7 @@ - + 3 @@ -286,7 +286,7 @@ - + 3 @@ -336,6 +336,11 @@
gui/partresizerwidget.h
1 + + FormattedSpinBox + QDoubleSpinBox +
gui/formattedspinbox.h
+
m_RadioPrimary