kwave  18.07.70
Kwave::LabelPropertiesWidget Class Reference

#include <LabelPropertiesWidget.h>

Inheritance diagram for Kwave::LabelPropertiesWidget:
Inheritance graph
Collaboration diagram for Kwave::LabelPropertiesWidget:
Collaboration graph

Public Member Functions

 LabelPropertiesWidget (QWidget *parent)
 
virtual ~LabelPropertiesWidget ()
 
virtual void setLabelIndex (unsigned int index)
 
virtual void setLabelPosition (sample_index_t pos, sample_index_t length, double rate)
 
virtual void setLabelName (const QString &name)
 
virtual sample_index_t labelPosition ()
 
virtual QString labelName ()
 
void saveSettings ()
 

Private Attributes

sample_index_t m_length
 
double m_sample_rate
 

Detailed Description

Definition at line 36 of file LabelPropertiesWidget.h.

Constructor & Destructor Documentation

◆ LabelPropertiesWidget()

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

Constructor

Definition at line 38 of file LabelPropertiesWidget.cpp.

39  :QDialog(parent), LabelPropertiesWidgetBase(),
40  m_length(0), m_sample_rate(0)
41 {
42  setupUi(this);
43  Q_ASSERT(time);
44  if (time) time->setTitle(QString());
45  setFixedSize(sizeHint());
46 
47  // set the focus onto the "OK" button
48  buttonBox->button(QDialogButtonBox::Ok)->setFocus();
49 }

◆ ~LabelPropertiesWidget()

Kwave::LabelPropertiesWidget::~LabelPropertiesWidget ( )
virtual

Destructor

Definition at line 52 of file LabelPropertiesWidget.cpp.

53 {
54 }

Member Function Documentation

◆ labelName()

QString Kwave::LabelPropertiesWidget::labelName ( )
virtual

returns the label's name

Definition at line 115 of file LabelPropertiesWidget.cpp.

References _.

Referenced by Kwave::MainWidget::labelProperties().

116 {
117  Q_ASSERT(edDescription);
118  return (edDescription) ? edDescription->text() : _("");
119 }
#define _(m)
Definition: memcpy.c:66
Here is the caller graph for this function:

◆ labelPosition()

sample_index_t Kwave::LabelPropertiesWidget::labelPosition ( )
virtual

returns the label position in samples

Definition at line 108 of file LabelPropertiesWidget.cpp.

Referenced by Kwave::MainWidget::labelProperties().

109 {
110  Q_ASSERT(time);
111  return (time) ? time->samples() : 0;
112 }
Here is the caller graph for this function:

◆ saveSettings()

void Kwave::LabelPropertiesWidget::saveSettings ( )

save the dialog's settings. currently only the mode of the time selection.

Definition at line 122 of file LabelPropertiesWidget.cpp.

References CONFIG_SECTION.

Referenced by Kwave::MainWidget::labelProperties().

123 {
124  // restore the previous selection mode and set it
125  KConfigGroup cfg = KSharedConfig::openConfig()->group(CONFIG_SECTION);
126  QString str;
127  str.setNum(static_cast<int>(time->mode()));
128  cfg.writeEntry("mode", str);
129  cfg.sync();
130 }
#define CONFIG_SECTION
Here is the caller graph for this function:

◆ setLabelIndex()

void Kwave::LabelPropertiesWidget::setLabelIndex ( unsigned int  index)
virtual

sets the index of the label (read-only property)

Parameters
indexlabel index [0...N-1]

Definition at line 57 of file LabelPropertiesWidget.cpp.

Referenced by Kwave::MainWidget::labelProperties().

58 {
59  Q_ASSERT(lblIndex);
60  if (lblIndex) lblIndex->setText(QString::number(index));
61 }
Here is the caller graph for this function:

◆ setLabelName()

void Kwave::LabelPropertiesWidget::setLabelName ( const QString &  name)
virtual

sets the name/description of the label

Parameters
namethe name (string) of the label

Definition at line 101 of file LabelPropertiesWidget.cpp.

Referenced by Kwave::MainWidget::labelProperties().

102 {
103  Q_ASSERT(edDescription);
104  if (edDescription) edDescription->setText(name);
105 }
const char name[16]
Definition: memcpy.c:510
Here is the caller graph for this function:

◆ setLabelPosition()

void Kwave::LabelPropertiesWidget::setLabelPosition ( sample_index_t  pos,
sample_index_t  length,
double  rate 
)
virtual

sets the position of the label

Parameters
posthe position of the label [samples]
lengthlength of the complete signal [samples]
ratesample rate of the signal

Definition at line 64 of file LabelPropertiesWidget.cpp.

References Kwave::SelectTimeWidget::byPercents, Kwave::SelectTimeWidget::bySamples, CONFIG_SECTION, m_length, and m_sample_rate.

Referenced by Kwave::MainWidget::labelProperties().

66 {
67  Q_ASSERT(time);
68  if (!time) return;
69 
70  // store the length and rate, for calls to labelPosition()
71  m_length = length;
72  m_sample_rate = rate;
73 
74  // set the current position, always by samples
75  time->init(Kwave::SelectTimeWidget::bySamples, pos, rate, 0, length);
76 
77  // restore the previous selection mode and set it
78  const KConfigGroup cfg = KSharedConfig::openConfig()->group(CONFIG_SECTION);
79  bool ok;
80  QString str = cfg.readEntry("mode");
81  unsigned int m = str.toUInt(&ok);
82  if (!ok) return;
84  static_cast<Kwave::SelectTimeWidget::Mode>(m);
85 
86  // check if we stay on the requested location when switching to percent
87  // mode. If the position would change, give the position precedence and
88  // switch the mode back to "samples"
90  quint64 p = time->samplesToTime(
91  Kwave::SelectTimeWidget::bySamples, pos, rate, length);
92  sample_index_t s = time->timeToSamples(mode, p, rate, length);
93  if (s != pos) return;
94  }
95 
96  // else: precise enough, use the previous mode
97  time->setMode(mode);
98 }
quint64 sample_index_t
Definition: Sample.h:28
#define CONFIG_SECTION
Here is the caller graph for this function:

Member Data Documentation

◆ m_length

sample_index_t Kwave::LabelPropertiesWidget::m_length
private

length of the signal, for transforming percentage -> samples

Definition at line 86 of file LabelPropertiesWidget.h.

Referenced by setLabelPosition().

◆ m_sample_rate

double Kwave::LabelPropertiesWidget::m_sample_rate
private

sample rate, for transforming time -> samples

Definition at line 89 of file LabelPropertiesWidget.h.

Referenced by setLabelPosition().


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