kwave  18.07.70
InvertableSpinBox.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  InvertableSpinBox.cpp - a spinbox with invertable spin buttons
3  -------------------
4  begin : Sun Jan 12 2003
5  copyright : (C) 2003 by Thomas Eschenbacher
6  email : Thomas.Eschenbacher@gmx.de
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #include "config.h"
19 
20 #include <QObject>
21 #include <QWidget>
22 
24 
25 //***************************************************************************
27  :QSpinBox(parent), m_inverse(false)
28 {
29  connect(this, SIGNAL(valueChanged(int)),
30  this, SLOT(checkValueChange(int)));
31 }
32 
33 //***************************************************************************
35 {
36  if (m_inverse == inverse) return; // nothing to do
38 
39  if (/* now */ inverse) {
40  // relax limits by 1
41  setMinimum(minimum() - 1);
42  setMaximum(maximum() + 1);
43  } else {
44  // reduce limits by 1
45  setMinimum(minimum() + 1);
46  setMaximum(maximum() - 1);
47  }
48 }
49 
50 //***************************************************************************
52 {
53  if (m_inverse) {
54  // in this case the real limits are tighter by 1
55  if (value <= minimum()) setValue(minimum() + 1);
56  if (value >= maximum()) setValue(maximum() - 1);
57  }
58 }
59 
60 //***************************************************************************
62 {
63  if (m_inverse) {
64  if (value() > minimum() + 1) QSpinBox::stepDown();
65  } else {
66  QSpinBox::stepUp();
67  }
68 }
69 
70 //***************************************************************************
72 {
73  if (m_inverse) {
74  if (value() + 1 < maximum()) QSpinBox::stepUp();
75  } else {
76  QSpinBox::stepDown();
77  }
78 }
79 
80 //***************************************************************************
81 //***************************************************************************
InvertableSpinBox(QWidget *parent)
void checkValueChange(int value)
bool connect(Kwave::StreamObject &source, const char *output, Kwave::StreamObject &sink, const char *input)
Definition: Connect.cpp:48
virtual bool inverse() const
virtual void setInverse(bool inverse)