Subversion Repositories svn1

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
183 - 1
#include "twinspinbox.h"
2
#include "ui_twinspinbox.h"
3
 
4
TwinSpinBox::TwinSpinBox(QWidget *parent) :
5
    QWidget(parent),
6
    ui(new Ui::TwinSpinBox),
7
    populating(false)
8
{
9
    ui->setupUi(this);
10
 
184 - 11
    connect(ui->spinBoxL,SIGNAL(valueChanged(int)), this, SLOT(adjustL(void)));
12
    connect(ui->spinBoxU,SIGNAL(valueChanged(int)), this, SLOT(adjustU(void)));
183 - 13
 
14
}
15
 
16
TwinSpinBox::~TwinSpinBox()
17
{
18
    delete ui;
19
}
20
 
184 - 21
void TwinSpinBox::adjustL(void)
183 - 22
{
23
    if ( ! populating )
24
    {
25
        qDebug("Changed");
26
        emit changed();
27
 
28
        populating = true;
29
        if (ui->spinBoxL->value() > ui->spinBoxU->value())
30
        {
31
            ui->spinBoxU->setValue(ui->spinBoxL->value());
32
        }
184 - 33
        populating = false;
34
    }
35
}
183 - 36
 
184 - 37
void TwinSpinBox::adjustU(void)
38
{
39
    if ( ! populating )
40
    {
41
        qDebug("Changed");
42
        emit changed();
43
 
44
        populating = true;
183 - 45
        if (ui->spinBoxU->value() < ui->spinBoxL->value())
46
        {
47
            qDebug("SetL");
48
            ui->spinBoxL->setValue(ui->spinBoxU->value());
49
        }
50
        populating = false;
51
    }
52
}
53
 
54
void TwinSpinBox::setLimits( int lower, int upper)
55
{
56
    populating = true;
57
    ui->spinBoxL->setMinimum(lower);
58
    ui->spinBoxL->setMaximum(upper);
59
 
60
    ui->spinBoxU->setMinimum(lower);
61
    ui->spinBoxU->setMaximum(upper);
62
    populating = false;
63
}
64
 
65
void TwinSpinBox::setData( int lower, int upper)
66
{
67
    populating = true;
68
    ui->spinBoxL->setValue(lower);
69
    ui->spinBoxU->setValue(upper);
70
    populating = false;
71
}
72
 
73
void TwinSpinBox::getData( short int *lptr, short int *uptr)
74
{
75
    if ( lptr )
76
        *lptr = ui->spinBoxL->value();
77
    if (uptr)
78
        *uptr = ui->spinBoxU->value();
79
}