1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
|
/***************************************************************************
LabelItem.h - label item within a SignalView
-------------------
begin : Sat Mar 26 2011
copyright : (C) 2011 by Thomas Eschenbacher
email : Thomas.Eschenbacher@gmx.de
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef LABEL_ITEM_H
#define LABEL_ITEM_H
#include "config.h"
#include "libkwavegui_export.h"
#include <QtGlobal>
#include <QCursor>
#include <QObject>
#include <QString>
#include "libgui/ViewItem.h"
class QMenu;
namespace Kwave
{
class Label;
class SignalView;
class UndoTransactionGuard;
class LIBKWAVEGUI_EXPORT LabelItem: public Kwave::ViewItem
{
Q_OBJECT
public:
/**
* Constructor
* @param view the owner (SignalView)
* @param signal_manager the corresponding SignalManager
* @param index the one-based index of the label
* @param label reference to the label
*/
LabelItem(Kwave::SignalView &view,
Kwave::SignalManager &signal_manager,
unsigned int index,
const Kwave::Label &label);
/** Destructor */
~LabelItem() override;
/**
* Returns flags describing the possible interactions with this object
* @see Kwave::ViewItem::Flags
*/
Kwave::ViewItem::Flags flags() const override;
/**
* Can be overwritten to return a tooltip.
*
* @param ofs sample index the tooltip should refer to (unused)
* @return an already localized tooltip
*/
QString toolTip(sample_index_t &ofs) override;
/**
* Called to append entries to a context menu.
* @param parent context menu to add items
*/
void appendContextMenu(QMenu *parent) override;
/**
* Returns a mouse cursor used when moving the item
*/
QCursor mouseCursor() const override;
/**
* handles updates when being moved with the mouse
* @param mouse_pos position of the mouse, in pixel coordinates
* relative to the parent widget
*/
void moveTo(const QPoint &mouse_pos) override;
/**
* Called when leaving the move mode, when the mouse button
* has been released.
*/
void done() override;
private slots:
/** context menu: "label / delete" */
void contextMenuLabelDelete();
/** context menu: "label / properties..." */
void contextMenuLabelProperties();
private:
/** index of the label */
unsigned int m_index;
/** initial position of the label, in samples */
sample_index_t m_initial_pos;
/** current position of the label, in samples */
sample_index_t m_current_pos;
/** description of the label */
QString m_description;
/** used when we are within a undo transaction (we started) */
Kwave::UndoTransactionGuard *m_undo_transaction;
};
}
#endif /* LABEL_ITEM_H */
//***************************************************************************
//***************************************************************************
|