add a formatted spin box

svn path=/trunk/extragear/sysadmin/partitionmanager/; revision=1119557
This commit is contained in:
Volker Lanz 2010-04-27 11:41:35 +00:00
parent 004e83447b
commit f8e81095ea
4 changed files with 86 additions and 5 deletions

View File

@ -0,0 +1,33 @@
/***************************************************************************
* Copyright (C) 2010 by Volker Lanz <vl@fidra.de> *
* *
* 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 <kglobal.h>
#include <klocale.h>
QString FormattedSpinBox::textFromValue(double value) const
{
return KGlobal::locale()->formatNumber(value, decimals());
}
double FormattedSpinBox::valueFromText(const QString& text) const
{
return KGlobal::locale()->readNumber(text);
}

View File

@ -0,0 +1,36 @@
/***************************************************************************
* Copyright (C) 2010 by Volker Lanz <vl@fidra.de> *
* *
* 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 <QDoubleSpinBox>
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

View File

@ -70,7 +70,7 @@
</widget>
</item>
<item row="3" column="1">
<widget class="QDoubleSpinBox" name="m_SpinFirstSector">
<widget class="FormattedSpinBox" name="m_SpinFirstSector">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>3</horstretch>
@ -108,7 +108,7 @@
</widget>
</item>
<item row="4" column="1">
<widget class="QDoubleSpinBox" name="m_SpinLastSector">
<widget class="FormattedSpinBox" name="m_SpinLastSector">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>3</horstretch>
@ -177,6 +177,13 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>FormattedSpinBox</class>
<extends>QDoubleSpinBox</extends>
<header>gui/formattedspinbox.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@ -216,7 +216,7 @@
</widget>
</item>
<item row="7" column="1" colspan="2">
<widget class="QDoubleSpinBox" name="m_SpinFreeBefore">
<widget class="FormattedSpinBox" name="m_SpinFreeBefore">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>3</horstretch>
@ -251,7 +251,7 @@
</widget>
</item>
<item row="8" column="1" colspan="2">
<widget class="QDoubleSpinBox" name="m_SpinCapacity">
<widget class="FormattedSpinBox" name="m_SpinCapacity">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>3</horstretch>
@ -286,7 +286,7 @@
</widget>
</item>
<item row="9" column="1" colspan="2">
<widget class="QDoubleSpinBox" name="m_SpinFreeAfter">
<widget class="FormattedSpinBox" name="m_SpinFreeAfter">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>3</horstretch>
@ -336,6 +336,11 @@
<header>gui/partresizerwidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>FormattedSpinBox</class>
<extends>QDoubleSpinBox</extends>
<header>gui/formattedspinbox.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>m_RadioPrimary</tabstop>