PacMaster 2.0(r200)
Controls digital PAC measurements and collects the results

QScienceSpinBox.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2008-2010 by Matthias Pospiech & Matthias Nagl          *
00003  *   mnagl@uni-goettingen.de                                               *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 
00021 #ifndef QSCIENCESPINBOX_H
00022 #define QSCIENCESPINBOX_H
00023 
00024 #include <QtGui/QDoubleSpinBox>
00025 #include <QtGui/QDoubleValidator>
00026 #include <QtGui/QLineEdit>
00027 #include <QtCore/QVariant>
00028 #include <QtCore/QDebug>
00029 #include <QtCore/QString>
00030 
00037 class QScienceSpinBox : public QDoubleSpinBox
00038 {
00039     Q_OBJECT
00040   public:
00041     QScienceSpinBox(QWidget * parent = 0);
00042 
00043     int decimals() const;
00044     void setDecimals(int value);
00045 
00046     QString textFromValue ( double value ) const;
00047     double valueFromText ( const QString & text ) const;
00048 
00049   private:
00050     int dispDecimals;
00051     QChar delimiter, thousand;
00052     QDoubleValidator * v;
00053 
00054   private:
00055     void initLocalValues(QWidget *parent);
00056     bool isIntermediateValue(const QString &str) const;
00057     QVariant validateAndInterpret(QString &input, int &pos, QValidator::State &state) const;
00058     QValidator::State validate(QString &text, int &pos) const;
00059     void fixup(QString &input) const;
00060     QString stripped(const QString &t, int *pos) const;
00061     double round(double value) const;
00062     void stepBy(int steps);
00063 
00064   public slots:
00065     void stepDown();
00066     void stepUp();
00067 };
00068 
00069 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Friends Defines