kwave  18.07.70
Kwave::InvertableSpinBox Class Reference

#include <InvertableSpinBox.h>

Inheritance diagram for Kwave::InvertableSpinBox:
Inheritance graph
Collaboration diagram for Kwave::InvertableSpinBox:
Collaboration graph

Public Slots

virtual void stepUp ()
 
virtual void stepDown ()
 

Public Member Functions

 InvertableSpinBox (QWidget *parent)
 
virtual ~InvertableSpinBox ()
 
virtual void setInverse (bool inverse)
 
virtual bool inverse () const
 

Protected Slots

void checkValueChange (int value)
 

Private Attributes

bool m_inverse
 

Detailed Description

Definition at line 31 of file InvertableSpinBox.h.

Constructor & Destructor Documentation

◆ InvertableSpinBox()

Kwave::InvertableSpinBox::InvertableSpinBox ( QWidget *  parent)
explicit

Constructor

Definition at line 26 of file InvertableSpinBox.cpp.

References checkValueChange(), and Kwave::connect().

27  :QSpinBox(parent), m_inverse(false)
28 {
29  connect(this, SIGNAL(valueChanged(int)),
30  this, SLOT(checkValueChange(int)));
31 }
void checkValueChange(int value)
bool connect(Kwave::StreamObject &source, const char *output, Kwave::StreamObject &sink, const char *input)
Definition: Connect.cpp:48
Here is the call graph for this function:

◆ ~InvertableSpinBox()

virtual Kwave::InvertableSpinBox::~InvertableSpinBox ( )
inlinevirtual

Destructor

Definition at line 40 of file InvertableSpinBox.h.

41  {
42  }

Member Function Documentation

◆ checkValueChange

void Kwave::InvertableSpinBox::checkValueChange ( int  value)
protectedslot

checks for range in inverse mode

Definition at line 51 of file InvertableSpinBox.cpp.

References m_inverse.

Referenced by InvertableSpinBox().

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 }
Here is the caller graph for this function:

◆ inverse()

virtual bool Kwave::InvertableSpinBox::inverse ( ) const
inlinevirtual

returns the current inversion state

Definition at line 48 of file InvertableSpinBox.h.

Referenced by setInverse().

48 { return m_inverse; }
Here is the caller graph for this function:

◆ setInverse()

void Kwave::InvertableSpinBox::setInverse ( bool  inverse)
virtual

enable/disable inverse mode

Definition at line 34 of file InvertableSpinBox.cpp.

References inverse(), and m_inverse.

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 }
virtual bool inverse() const
Here is the call graph for this function:

◆ stepDown

void Kwave::InvertableSpinBox::stepDown ( )
virtualslot

calls QSpinBox::stepDown() in normal mode and QSpinBox::stepUp() in inverse mode

Definition at line 71 of file InvertableSpinBox.cpp.

References m_inverse.

72 {
73  if (m_inverse) {
74  if (value() + 1 < maximum()) QSpinBox::stepUp();
75  } else {
76  QSpinBox::stepDown();
77  }
78 }

◆ stepUp

void Kwave::InvertableSpinBox::stepUp ( )
virtualslot

calls QSpinBox::stepUp() in normal mode and QSpinBox::stepDown() in inverse mode

Definition at line 61 of file InvertableSpinBox.cpp.

References m_inverse.

62 {
63  if (m_inverse) {
64  if (value() > minimum() + 1) QSpinBox::stepDown();
65  } else {
66  QSpinBox::stepUp();
67  }
68 }

Member Data Documentation

◆ m_inverse

bool Kwave::InvertableSpinBox::m_inverse
private

if true, spin buttons work in inverse mode

Definition at line 72 of file InvertableSpinBox.h.

Referenced by checkValueChange(), setInverse(), stepDown(), and stepUp().


The documentation for this class was generated from the following files: