~ubuntu-branches/ubuntu/vivid/qgo/vivid-proposed

« back to all changes in this revision

Viewing changes to src/komispinbox.h

  • Committer: Package Import Robot
  • Author(s): Yann Dirson
  • Date: 2012-05-19 19:05:05 UTC
  • mfrom: (1.1.12)
  • Revision ID: package-import@ubuntu.com-20120519190505-b23f5tzx7y8cu946
Tags: 2~svn764-1
* The "Raise dead" release (Closes: #673520), new maintainer.
* New upstream snapshot with Qt4 support (Closes: #604589), adjusted
  build-deps.
* Switched to source format "3.0 (quilt)", adjusted build-deps.
* Switched to dh and debhelper compat level 9, adjusted build-deps.
* Build with -fpermissive.
* New build-dep libasound2-dev, remove obsolete build-dep on libxinerama-dev.
* Refreshed patches 01_gnugo and 04_desktop, leaving 20_kfreebsd away
  for this release, and removing the remaining ones, now obsolete.
* Added patch 02_usrgames for FHS-correct install location.
* Adjusted icon names in menu file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
* komispinbox.h
3
 
*/
4
 
 
5
 
#ifndef KOMISPINBOX_H
6
 
#define KOMISPINBOX_H
7
 
 
8
 
#include <qspinbox.h>
9
 
#include <qvalidator.h>
10
 
#include <stdlib.h>
11
 
 
12
 
class KomiSpinBox : public QSpinBox
13
 
{
14
 
public:
15
 
        KomiSpinBox(QWidget *parent=0, const char *name=0) : QSpinBox(parent, name)
16
 
        {
17
 
                val = new QDoubleValidator(0.0, 10.0, 1, this);
18
 
                setValidator(val);
19
 
                setMinValue(-5000); // Min -500
20
 
                setMaxValue(5000);  // Max 500
21
 
                setValue(55);       // default 5.5
22
 
                setLineStep(10);    // step 1.0
23
 
        }
24
 
        
25
 
        ~KomiSpinBox()
26
 
        {
27
 
                delete val;
28
 
        }
29
 
        
30
 
        QString mapValueToText(int value)
31
 
        {
32
 
                if (value < 0 && value > -10)
33
 
                        return QString("-%1.%2").arg(value/10).arg(abs(value%10));
34
 
                else
35
 
                        return QString("%1.%2").arg(value/10).arg(abs(value%10));
36
 
        }
37
 
        
38
 
        int mapTextToValue(bool *ok)
39
 
        {
40
 
                if (!ok)
41
 
                        qWarning("   *** Bad text value in Komi spinbox! ***");
42
 
                return int(text().toFloat()*10);
43
 
        }
44
 
        
45
 
private:
46
 
        QDoubleValidator *val;
47
 
};
48
 
 
49
 
#endif