kwave  18.07.70
Kwave::HMSTimeWidget Class Reference

#include <HMSTimeWidget.h>

Inheritance diagram for Kwave::HMSTimeWidget:
Inheritance graph
Collaboration diagram for Kwave::HMSTimeWidget:
Collaboration graph

Public Slots

virtual void setValue (int value)
 
virtual void setLimit (unsigned int limit)
 

Signals

void valueChanged (int value)
 

Public Member Functions

 HMSTimeWidget (QWidget *parent)
 
virtual ~HMSTimeWidget ()
 
virtual int value ()
 

Protected Slots

void timeChanged (int)
 

Private Member Functions

void connect ()
 
void disconnect ()
 

Private Attributes

unsigned int m_time
 
unsigned int m_limit
 

Detailed Description

Definition at line 31 of file HMSTimeWidget.h.

Constructor & Destructor Documentation

◆ HMSTimeWidget()

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

Constructor

Definition at line 27 of file HMSTimeWidget.cpp.

References connect(), m_time, and setValue().

28  :QWidget(parent), Ui::HMSTimeWidgetBase(),
29  m_time(0), m_limit(INT_MAX)
30 {
31  setupUi(this);
33  connect();
34 }
virtual void setValue(int value)
unsigned int m_limit
Definition: HMSTimeWidget.h:78
unsigned int m_time
Definition: HMSTimeWidget.h:75
Here is the call graph for this function:

◆ ~HMSTimeWidget()

Kwave::HMSTimeWidget::~HMSTimeWidget ( )
virtual

Destructor

Definition at line 37 of file HMSTimeWidget.cpp.

38 {
39 }

Member Function Documentation

◆ connect()

void Kwave::HMSTimeWidget::connect ( )
private

connect all signals to avoid loops

Definition at line 111 of file HMSTimeWidget.cpp.

References Kwave::connect(), timeChanged(), and valueChanged().

Referenced by HMSTimeWidget(), and timeChanged().

112 {
113  QObject::connect(sbSeconds, SIGNAL(valueChanged(int)),
114  this, SLOT(timeChanged(int)));
115  QObject::connect(sbMinutes, SIGNAL(valueChanged(int)),
116  this, SLOT(timeChanged(int)));
117  QObject::connect(sbHours, SIGNAL(valueChanged(int)),
118  this, SLOT(timeChanged(int)));
119 }
bool connect(Kwave::StreamObject &source, const char *output, Kwave::StreamObject &sink, const char *input)
Definition: Connect.cpp:48
void valueChanged(int value)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ disconnect()

void Kwave::HMSTimeWidget::disconnect ( )
private

disconnect all signals to avoid loops

Definition at line 122 of file HMSTimeWidget.cpp.

References timeChanged(), and valueChanged().

Referenced by timeChanged().

123 {
124  // disconnect the time controls
125  QObject::disconnect(sbSeconds, SIGNAL(valueChanged(int)),
126  this, SLOT(timeChanged(int)));
127  QObject::disconnect(sbMinutes, SIGNAL(valueChanged(int)),
128  this, SLOT(timeChanged(int)));
129  QObject::disconnect(sbHours, SIGNAL(valueChanged(int)),
130  this, SLOT(timeChanged(int)));
131 }
void valueChanged(int value)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setLimit

void Kwave::HMSTimeWidget::setLimit ( unsigned int  limit)
virtualslot

sets the maximum time in seconds

Definition at line 64 of file HMSTimeWidget.cpp.

References m_limit, and setValue().

65 {
66  Q_ASSERT(limit <= INT_MAX);
67  if (limit > INT_MAX) limit = INT_MAX;
68  if (limit < m_limit) {
69  m_limit = limit;
71  } else {
72  m_limit = limit;
73  }
74 }
virtual void setValue(int value)
unsigned int m_limit
Definition: HMSTimeWidget.h:78
Here is the call graph for this function:

◆ setValue

void Kwave::HMSTimeWidget::setValue ( int  value)
virtualslot

set the time, given as a number in seconds

Definition at line 48 of file HMSTimeWidget.cpp.

References m_limit, m_time, Kwave::toUint(), and value().

Referenced by HMSTimeWidget(), setLimit(), and timeChanged().

49 {
50  if (value < 0) value = 0;
52  m_time = value;
53 
54  const int seconds = (m_time % 60);
55  const int minutes = (m_time / 60) % 60;
56  const int hours = (m_time / (60*60));
57 
58  sbHours->setValue(hours);
59  sbMinutes->setValue(minutes);
60  sbSeconds->setValue(seconds);
61 }
unsigned int m_limit
Definition: HMSTimeWidget.h:78
unsigned int m_time
Definition: HMSTimeWidget.h:75
unsigned int toUint(T x)
Definition: Utils.h:109
Here is the call graph for this function:
Here is the caller graph for this function:

◆ timeChanged

void Kwave::HMSTimeWidget::timeChanged ( int  )
protectedslot

called whenever one of the time controls has changed

Definition at line 77 of file HMSTimeWidget.cpp.

References connect(), disconnect(), m_time, setValue(), and valueChanged().

Referenced by connect(), and disconnect().

78 {
79  // get current time and correct wrap-overs
80  int seconds = sbSeconds->value();
81  int minutes = sbMinutes->value();
82  int hours = sbHours->value();
83 
84  if (seconds < 0) {
85  seconds = 59;
86  minutes--;
87  }
88  if (minutes < 0) {
89  minutes = 59;
90  hours--;
91  }
92  if (hours < 0) {
93  hours = 0;
94  minutes = 0;
95  seconds = 0;
96  }
97 
98  Q_ASSERT((hours >= 0) && (minutes >= 0) && (seconds >= 0));
99  unsigned int time = seconds + (minutes + (hours * 60L)) * 60L;
100 
101  bool changed = (time != m_time);
102 
103  disconnect();
104  setValue(time);
105  connect();
106 
107  if (changed) emit valueChanged(m_time); // emit the change
108 }
virtual void setValue(int value)
unsigned int m_time
Definition: HMSTimeWidget.h:75
void valueChanged(int value)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ value()

int Kwave::HMSTimeWidget::value ( )
virtual

get the time as a number of seconds

Definition at line 42 of file HMSTimeWidget.cpp.

References m_time.

Referenced by setValue().

43 {
44  return m_time;
45 }
unsigned int m_time
Definition: HMSTimeWidget.h:75
Here is the caller graph for this function:

◆ valueChanged

void Kwave::HMSTimeWidget::valueChanged ( int  value)
signal

emitted when the time value has changed

Referenced by connect(), disconnect(), and timeChanged().

Here is the caller graph for this function:

Member Data Documentation

◆ m_limit

unsigned int Kwave::HMSTimeWidget::m_limit
private

the maximum time in seconds, for limiting m_time

Definition at line 78 of file HMSTimeWidget.h.

Referenced by setLimit(), and setValue().

◆ m_time

unsigned int Kwave::HMSTimeWidget::m_time
private

the currently selected time in seconds

Definition at line 75 of file HMSTimeWidget.h.

Referenced by HMSTimeWidget(), setValue(), timeChanged(), and value().


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