~ubuntu-branches/ubuntu/quantal/muse/quantal

« back to all changes in this revision

Viewing changes to widgets/doublelabel.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Kobras
  • Date: 2002-04-23 17:28:23 UTC
  • Revision ID: james.westby@ubuntu.com-20020423172823-w8yplzr81a759xa3
Tags: upstream-0.5.2
ImportĀ upstreamĀ versionĀ 0.5.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//=========================================================
 
2
//  MusE
 
3
//  Linux Music Editor
 
4
//    $Id: doublelabel.cpp,v 1.1 2002/01/30 14:54:03 muse Exp $
 
5
//  (C) Copyright 1999 Werner Schweer (ws@seh.de)
 
6
//=========================================================
 
7
 
 
8
#include <stdio.h>
 
9
 
 
10
#include "doublelabel.h"
 
11
#include <qvalidator.h>
 
12
#include <qpalette.h>
 
13
#include <stdio.h>
 
14
#include <values.h>
 
15
 
 
16
#include "utils.h"
 
17
 
 
18
//---------------------------------------------------------
 
19
//   DoubleLabel
 
20
//---------------------------------------------------------
 
21
 
 
22
DoubleLabel::DoubleLabel(double _val, double m, double mx, QWidget* parent)
 
23
   : Dentry(parent), _specialText("---")
 
24
      {
 
25
      min = m;
 
26
      max = mx;
 
27
      _precision = 3;
 
28
      setValue(_val);
 
29
      }
 
30
 
 
31
//---------------------------------------------------------
 
32
//   setString
 
33
//---------------------------------------------------------
 
34
 
 
35
bool DoubleLabel::setString(double v)
 
36
      {
 
37
      QString s;
 
38
      if (v < min || v > max) {
 
39
            setText(_specialText);
 
40
            return true;
 
41
            }
 
42
      s.setNum(v, 'f', _precision);
 
43
      setText(s);
 
44
      return false;
 
45
      }
 
46
 
 
47
//---------------------------------------------------------
 
48
//   setSValue
 
49
//---------------------------------------------------------
 
50
 
 
51
bool DoubleLabel::setSValue(const QString& s)
 
52
      {
 
53
      int v = s.toInt();
 
54
      if (v != val) {
 
55
            setValue(v);
 
56
            emit valueChanged(val);
 
57
            }
 
58
      return false;
 
59
      }
 
60
 
 
61
//---------------------------------------------------------
 
62
//   incValue
 
63
//---------------------------------------------------------
 
64
 
 
65
void DoubleLabel::incValue(double)
 
66
      {
 
67
      if (val+1 < max) {
 
68
            setValue(val+1);
 
69
            emit valueChanged(val);
 
70
            }
 
71
      }
 
72
 
 
73
//---------------------------------------------------------
 
74
//   decValue
 
75
//---------------------------------------------------------
 
76
 
 
77
void DoubleLabel::decValue(double)
 
78
      {
 
79
      if (val-1 > min) {
 
80
            setValue(val-1);
 
81
            emit valueChanged(val);
 
82
            }
 
83
      }
 
84
 
 
85
//---------------------------------------------------------
 
86
//   setPrecision
 
87
//---------------------------------------------------------
 
88
 
 
89
void DoubleLabel::setPrecision(int v)
 
90
      {
 
91
      _precision = v;
 
92
      setString(val);
 
93
      }
 
94