kwave  18.07.70
Kwave::SelectionBorderItem Class Reference

#include <SelectionBorderItem.h>

Inheritance diagram for Kwave::SelectionBorderItem:
Inheritance graph
Collaboration diagram for Kwave::SelectionBorderItem:
Collaboration graph

Public Member Functions

 SelectionBorderItem (SignalView &view, Kwave::SignalManager &signal_manager, sample_index_t pos)
 
virtual ~SelectionBorderItem () Q_DECL_OVERRIDE
 
virtual Kwave::ViewItem::Flags flags () const Q_DECL_OVERRIDE
 
virtual QString toolTip (sample_index_t &ofs) Q_DECL_OVERRIDE
 
virtual QCursor mouseCursor () const Q_DECL_OVERRIDE
 
virtual void moveTo (const QPoint &mouse_pos) Q_DECL_OVERRIDE
 
- Public Member Functions inherited from Kwave::ViewItem
 ViewItem (Kwave::SignalView &view, Kwave::SignalManager &signal_manager)
 
virtual ~ViewItem ()
 
virtual void appendContextMenu (QMenu *parent)
 
virtual void startDragging ()
 
virtual void done ()
 

Private Attributes

Kwave::MouseMark m_selection
 

Additional Inherited Members

- Public Types inherited from Kwave::ViewItem
enum  Flag { None = 0, CanGrabAndMove = 1, CanDragAndDrop = 2 }
 
- Signals inherited from Kwave::ViewItem
void sigCommand (const QString &command)
 
- Protected Attributes inherited from Kwave::ViewItem
Kwave::SignalViewm_view
 
Kwave::SignalManagerm_signal_manager
 

Detailed Description

Definition at line 39 of file SelectionBorderItem.h.

Constructor & Destructor Documentation

◆ SelectionBorderItem()

Kwave::SelectionBorderItem::SelectionBorderItem ( Kwave::SignalView view,
Kwave::SignalManager signal_manager,
sample_index_t  pos 
)

Constructor

Parameters
viewthe owner (SignalView)
signal_managerthe corresponding SignalManager
posstart position, either left or right border

Definition at line 28 of file SelectionBorderItem.cpp.

References Kwave::Selection::first(), Kwave::MouseMark::grep(), Kwave::Selection::last(), m_selection, Kwave::SignalManager::selection(), and Kwave::MouseMark::set().

33  :Kwave::ViewItem(view, signal_manager),
34  m_selection()
35 {
37  signal_manager.selection().first(),
38  signal_manager.selection().last()
39  );
40  m_selection.grep(pos);
41 }
sample_index_t first() const
Definition: Selection.h:71
void set(sample_index_t l, sample_index_t r)
Definition: MouseMark.cpp:36
sample_index_t last() const
Definition: Selection.h:76
Kwave::Selection & selection()
void grep(sample_index_t x)
Definition: MouseMark.cpp:55
Here is the call graph for this function:

◆ ~SelectionBorderItem()

Kwave::SelectionBorderItem::~SelectionBorderItem ( )
virtual

Destructor

Definition at line 44 of file SelectionBorderItem.cpp.

45 {
46 }

Member Function Documentation

◆ flags()

Kwave::ViewItem::Flags Kwave::SelectionBorderItem::flags ( ) const
virtual

Returns flags describing the possible interactions with this object

See also
Kwave::ViewItem::Flags

Reimplemented from Kwave::ViewItem.

Definition at line 49 of file SelectionBorderItem.cpp.

References Kwave::ViewItem::CanGrabAndMove.

◆ mouseCursor()

QCursor Kwave::SelectionBorderItem::mouseCursor ( ) const
virtual

Returns a mouse cursor used when moving the item

Reimplemented from Kwave::ViewItem.

Definition at line 78 of file SelectionBorderItem.cpp.

79 {
80  return Qt::SizeHorCursor;
81 }

◆ moveTo()

void Kwave::SelectionBorderItem::moveTo ( const QPoint &  mouse_pos)
virtual

handles updates when being moved with the mouse

Parameters
mouse_posposition of the mouse, in pixel coordinates relative to the parent widget

Reimplemented from Kwave::ViewItem.

Definition at line 84 of file SelectionBorderItem.cpp.

References Kwave::MouseMark::left(), Kwave::MouseMark::length(), m_selection, Kwave::ViewItem::m_signal_manager, Kwave::ViewItem::m_view, Kwave::SignalView::offset(), Kwave::SignalView::pixels2samples(), Kwave::SignalManager::selectRange(), and Kwave::MouseMark::update().

85 {
86  const sample_index_t new_pos = m_view.offset() +
87  m_view.pixels2samples(mouse_pos.x());
88  m_selection.update(new_pos);
90 }
void selectRange(sample_index_t offset, sample_index_t length)
quint64 sample_index_t
Definition: Sample.h:28
sample_index_t offset() const
Definition: SignalView.h:110
Kwave::SignalManager & m_signal_manager
Definition: ViewItem.h:119
Kwave::SignalView & m_view
Definition: ViewItem.h:116
void update(sample_index_t x)
Definition: MouseMark.cpp:67
sample_index_t pixels2samples(int pixels) const
Definition: SignalView.cpp:155
sample_index_t length() const
Definition: MouseMark.h:77
sample_index_t left() const
Definition: MouseMark.cpp:43
Here is the call graph for this function:

◆ toolTip()

QString Kwave::SelectionBorderItem::toolTip ( sample_index_t ofs)
virtual

Can be overwritten to return a tooltip. The default implementation returns an empty string.

Parameters
ofssample index the tooltip should refer to (unused)
Returns
an already localized tooltip

Reimplemented from Kwave::ViewItem.

Definition at line 55 of file SelectionBorderItem.cpp.

References _, Kwave::MouseMark::left(), m_selection, Kwave::ViewItem::m_view, Kwave::ms2hms(), Kwave::MouseMark::right(), and Kwave::SignalView::samples2ms().

56 {
59  if (first == last) return QString(); // empty selection
60 
61  sample_index_t d_left = (first < ofs) ? (ofs - first) : (first - ofs);
62  sample_index_t d_right = (last < ofs) ? (ofs - last) : (last - ofs);
63 
64  QString which;
65  if (d_left <= d_right) {
66  which = i18n("Selection, left border");
67  ofs = first;
68  } else {
69  which = i18n("Selection, right border");
70  ofs = last;
71  }
72 
73  QString hms = Kwave::ms2hms(m_view.samples2ms(ofs));
74  return _("%1\n%2\n%3").arg(which).arg(ofs).arg(hms);
75 }
sample_index_t right() const
Definition: MouseMark.cpp:49
QString Q_DECL_EXPORT ms2hms(double ms)
Definition: Utils.cpp:104
quint64 sample_index_t
Definition: Sample.h:28
Kwave::SignalView & m_view
Definition: ViewItem.h:116
double samples2ms(sample_index_t samples)
Definition: SignalView.cpp:162
#define _(m)
Definition: memcpy.c:66
sample_index_t left() const
Definition: MouseMark.cpp:43
Here is the call graph for this function:

Member Data Documentation

◆ m_selection

Kwave::MouseMark Kwave::SelectionBorderItem::m_selection
private

selection handler

Definition at line 85 of file SelectionBorderItem.h.

Referenced by moveTo(), SelectionBorderItem(), and toolTip().


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