Subversion Repositories svn1

Rev

Rev 184 | Details | Compare with Previous | 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
        emit changed();
26
 
27
        populating = true;
28
        if (ui->spinBoxL->value() > ui->spinBoxU->value())
29
        {
30
            ui->spinBoxU->setValue(ui->spinBoxL->value());
31
        }
184 - 32
        populating = false;
33
    }
34
}
183 - 35
 
184 - 36
void TwinSpinBox::adjustU(void)
37
{
38
    if ( ! populating )
39
    {
40
        qDebug("Changed");
41
        emit changed();
42
 
43
        populating = true;
183 - 44
        if (ui->spinBoxU->value() < ui->spinBoxL->value())
45
        {
46
            ui->spinBoxL->setValue(ui->spinBoxU->value());
47
        }
48
        populating = false;
49
    }
50
}
51
 
52
void TwinSpinBox::setLimits( int lower, int upper)
53
{
54
    populating = true;
55
    ui->spinBoxL->setMinimum(lower);
56
    ui->spinBoxL->setMaximum(upper);
57
 
58
    ui->spinBoxU->setMinimum(lower);
59
    ui->spinBoxU->setMaximum(upper);
60
    populating = false;
61
}
62
 
63
void TwinSpinBox::setData( int lower, int upper)
64
{
65
    populating = true;
66
    ui->spinBoxL->setValue(lower);
67
    ui->spinBoxU->setValue(upper);
68
    populating = false;
69
}
70
 
71
void TwinSpinBox::getData( short int *lptr, short int *uptr)
72
{
73
    if ( lptr )
74
        *lptr = ui->spinBoxL->value();
75
    if (uptr)
76
        *uptr = ui->spinBoxU->value();
77
}