kwave  18.07.70
Kwave::GotoPluginBase Class Referenceabstract

#include <GotoPluginBase.h>

Inheritance diagram for Kwave::GotoPluginBase:
Inheritance graph
Collaboration diagram for Kwave::GotoPluginBase:
Collaboration graph

Public Member Functions

 GotoPluginBase (QObject *parent, const QVariantList &args)
 
virtual ~GotoPluginBase () Q_DECL_OVERRIDE
 
virtual QStringList * setup (QStringList &previous_params) Q_DECL_OVERRIDE
 
virtual int start (QStringList &params) Q_DECL_OVERRIDE
 
- Public Member Functions inherited from Kwave::Plugin
 Plugin (QObject *parent, const QVariantList &args)
 
virtual ~Plugin () Q_DECL_OVERRIDE
 
virtual QString name () const
 
virtual QString description () const
 
virtual QString progressText ()
 
virtual bool canClose () const
 
bool isRunning () const
 
bool shouldStop () const
 
virtual void load (QStringList &params)
 
virtual void unload ()
 
virtual int stop ()
 
virtual void run (QStringList params)
 
Kwave::PluginManagermanager () const
 
Kwave::SignalManagersignalManager ()
 
QWidget * parentWidget () const
 
QString signalName ()
 
virtual sample_index_t signalLength ()
 
virtual double signalRate ()
 
virtual const QList< unsigned int > selectedTracks ()
 
virtual sample_index_t selection (QList< unsigned int > *tracks=Q_NULLPTR, sample_index_t *left=Q_NULLPTR, sample_index_t *right=Q_NULLPTR, bool expand_if_empty=false)
 
virtual void selectRange (sample_index_t offset, sample_index_t length)
 
virtual void migrateToActiveContext ()
 
- Public Member Functions inherited from Kwave::Runnable
virtual ~Runnable ()
 

Protected Member Functions

virtual QString command () const =0
 
virtual QString title () const =0
 
int interpreteParameters (QStringList &params)
 
- Protected Member Functions inherited from Kwave::Plugin
int execute (QStringList &params)
 
void emitCommand (const QString &command)
 
void use ()
 
void setPluginManager (Kwave::PluginManager *new_plugin_manager)
 
virtual void run_wrapper (const QVariant &params) Q_DECL_OVERRIDE
 

Private Attributes

Kwave::SelectTimeWidget::Mode m_mode
 
unsigned int m_position
 

Additional Inherited Members

- Public Slots inherited from Kwave::Plugin
virtual void setProgressDialogEnabled (bool enable)
 
virtual void updateProgress (qreal progress)
 
virtual void cancel ()
 
virtual void close ()
 
void release ()
 
- Signals inherited from Kwave::Plugin
void sigRunning (Kwave::Plugin *plugin)
 
void sigDone (Kwave::Plugin *plugin)
 
void sigClosed (Kwave::Plugin *p)
 
void sigCommand (const QString &command)
 
void setProgressText (const QString &text)
 

Detailed Description

Definition at line 35 of file GotoPluginBase.h.

Constructor & Destructor Documentation

◆ GotoPluginBase()

Kwave::GotoPluginBase::GotoPluginBase ( QObject *  parent,
const QVariantList &  args 
)

Constructor

Parameters
parentreference to our plugin manager
argsargument list [unused]

Definition at line 35 of file GotoPluginBase.cpp.

◆ ~GotoPluginBase()

Kwave::GotoPluginBase::~GotoPluginBase ( )
virtual

Destructor

Definition at line 43 of file GotoPluginBase.cpp.

44 {
45 }

Member Function Documentation

◆ command()

virtual QString Kwave::GotoPluginBase::command ( ) const
protectedpure virtual

Returns the command to be emitted

Implemented in Kwave::GotoPlugin, and Kwave::InsertAtPlugin.

Referenced by setup(), and start().

Here is the caller graph for this function:

◆ interpreteParameters()

int Kwave::GotoPluginBase::interpreteParameters ( QStringList &  params)
protected

Reads values from the parameter list

Definition at line 109 of file GotoPluginBase.cpp.

References Kwave::SelectTimeWidget::byPercents, Kwave::SelectTimeWidget::bySamples, Kwave::SelectTimeWidget::byTime, m_mode, and m_position.

Referenced by setup(), and start().

110 {
111  bool ok;
112  QString param;
113  int mode;
114 
115  // evaluate the parameter list
116  if (params.count() != 2)
117  return -EINVAL;
118 
119  // selection mode for start
120  param = params[0];
121  mode = param.toInt(&ok);
122  Q_ASSERT(ok);
123  if (!ok) return -EINVAL;
124  Q_ASSERT(
125  (mode == static_cast<int>(Kwave::SelectTimeWidget::byTime)) ||
126  (mode == static_cast<int>(Kwave::SelectTimeWidget::bySamples)) ||
127  (mode == static_cast<int>(Kwave::SelectTimeWidget::byPercents))
128  );
129  if ((mode != static_cast<int>(Kwave::SelectTimeWidget::byTime)) &&
130  (mode != static_cast<int>(Kwave::SelectTimeWidget::bySamples)) &&
131  (mode != static_cast<int>(Kwave::SelectTimeWidget::byPercents)))
132  {
133  return -EINVAL;
134  }
135  m_mode = static_cast<Kwave::SelectTimeWidget::Mode>(mode);
136 
137  // position in ms, samples or percent
138  param = params[1];
139  m_position = param.toUInt(&ok);
140  if (!ok) return -EINVAL;
141 
142  return 0;
143 }
Kwave::SelectTimeWidget::Mode m_mode
unsigned int m_position
Here is the caller graph for this function:

◆ setup()

QStringList * Kwave::GotoPluginBase::setup ( QStringList &  previous_params)
virtual

Shows a dialog for selecting the range and emits a command for applying the selection if OK has been pressed.

See also
Kwave::Plugin::setup

Reimplemented from Kwave::Plugin.

Definition at line 48 of file GotoPluginBase.cpp.

References _, command(), Kwave::Plugin::emitCommand(), interpreteParameters(), m_mode, m_position, Kwave::GotoDialog::mode(), Kwave::Plugin::parentWidget(), Kwave::GotoDialog::pos(), Kwave::Plugin::signalLength(), Kwave::Plugin::signalRate(), and title().

49 {
50  // try to interpret the previous parameters
51  interpreteParameters(previous_params);
52 
53  // create the setup dialog
54  double rate = signalRate();
55  sample_index_t length = signalLength();
56 
57  // get the name of the help section
58  QString help_section = _("plugin_sect_") + command();
59 
61  m_mode, m_position, rate, length, help_section);
62  Q_ASSERT(dialog);
63  if (!dialog) return Q_NULLPTR;
64 
65  // set the title of the dialog, depending on the derived class
66  dialog->setWindowTitle(title());
67 
68  QStringList *list = new QStringList();
69  Q_ASSERT(list);
70  if (list && dialog->exec()) {
71  // user has pressed "OK"
72  *list << QString::number(dialog->mode());
73  *list << QString::number(dialog->pos());
74 
75  emitCommand(_("plugin:execute(") + command() +
76  _(",") + QString::number(dialog->mode()) +
77  _(",") + QString::number(dialog->pos()) +
78  _(")")
79  );
80  } else {
81  // user pressed "Cancel"
82  if (list) delete list;
83  list = Q_NULLPTR;
84  }
85 
86  if (dialog) delete dialog;
87  return list;
88 }
void emitCommand(const QString &command)
Definition: Plugin.cpp:510
Kwave::SelectTimeWidget::Mode m_mode
QWidget * parentWidget() const
Definition: Plugin.cpp:450
quint64 sample_index_t
Definition: Sample.h:28
virtual sample_index_t signalLength()
Definition: Plugin.cpp:462
int interpreteParameters(QStringList &params)
unsigned int m_position
virtual double signalRate()
Definition: Plugin.cpp:468
virtual QString command() const =0
#define _(m)
Definition: memcpy.c:66
quint64 pos() const
Definition: GotoDialog.h:75
virtual QString title() const =0
Here is the call graph for this function:

◆ start()

int Kwave::GotoPluginBase::start ( QStringList &  params)
virtual

selects the position

See also
Kwave::Plugin::start()

Reimplemented from Kwave::Plugin.

Definition at line 91 of file GotoPluginBase.cpp.

References _, command(), Kwave::Plugin::emitCommand(), interpreteParameters(), m_mode, m_position, Kwave::Plugin::signalLength(), Kwave::Plugin::signalRate(), and Kwave::SelectTimeWidget::timeToSamples().

92 {
93  // interprete the parameters
94  int result = interpreteParameters(params);
95  if (result) return result;
96 
97  // get current offset of the signal
100 
101  // change the selection through the signal manager
102  QString cmd = _("nomacro:") + command() + _("(%1)");
103  emitCommand(cmd.arg(offset));
104 
105  return result;
106 }
void emitCommand(const QString &command)
Definition: Plugin.cpp:510
Kwave::SelectTimeWidget::Mode m_mode
quint64 sample_index_t
Definition: Sample.h:28
static sample_index_t timeToSamples(Mode mode, quint64 time, double rate, sample_index_t length)
virtual sample_index_t signalLength()
Definition: Plugin.cpp:462
int interpreteParameters(QStringList &params)
unsigned int m_position
virtual double signalRate()
Definition: Plugin.cpp:468
virtual QString command() const =0
#define _(m)
Definition: memcpy.c:66
Here is the call graph for this function:

◆ title()

virtual QString Kwave::GotoPluginBase::title ( ) const
protectedpure virtual

Returns the title of the dialog

Implemented in Kwave::GotoPlugin, and Kwave::InsertAtPlugin.

Referenced by setup().

Here is the caller graph for this function:

Member Data Documentation

◆ m_mode

Kwave::SelectTimeWidget::Mode Kwave::GotoPluginBase::m_mode
private

selected mode for position: by time, samples, percentage

Definition at line 77 of file GotoPluginBase.h.

Referenced by interpreteParameters(), setup(), and start().

◆ m_position

unsigned int Kwave::GotoPluginBase::m_position
private

position in milliseconds, samples or percents

Definition at line 80 of file GotoPluginBase.h.

Referenced by interpreteParameters(), setup(), and start().


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