| 1 |
/* |
| 2 |
* Audacity: A Digital Audio Editor |
| 3 |
*/ |
| 4 |
#pragma once |
| 5 |
|
| 6 |
#include <QQuickItem> |
| 7 |
|
| 8 |
#include "timecodeformatter.h" |
| 9 |
|
| 10 |
namespace au::playback { |
| 11 |
class FieldsInteractionController : public QObject |
| 12 |
{ |
| 13 |
Q_OBJECT |
| 14 |
|
| 15 |
public: |
| 16 |
explicit FieldsInteractionController(QObject* parent = nullptr); |
| 17 |
|
| 18 |
void setFormatter(const std::shared_ptr<TimecodeFormatter>& formatter); |
| 19 |
|
| 20 |
QString valueString() const; |
| 21 |
void setValueString(const QString& valueString); |
| 22 |
|
| 23 |
int currentEditedFieldIndex() const; |
| 24 |
void setCurrentEditedFieldIndex(int index); |
| 25 |
|
| 26 |
QQuickItem* visualItem() const; |
| 27 |
void setVisualItem(QQuickItem* newVisualItem); |
| 28 |
|
| 29 |
int rowCount() const; |
| 30 |
|
| 31 |
signals: |
| 32 |
void currentEditedFieldIndexChanged(); |
| 33 |
void visualItemChanged(); |
| 34 |
|
| 35 |
void valueChanged(double value); |
| 36 |
|
| 37 |
private: |
| 38 |
bool eventFilter(QObject* watched, QEvent* event) override; |
| 39 |
bool needOverrideShortcut(QEvent* event) const; |
| 40 |
|
| 41 |
bool isMouseWithinBoundaries(const QPoint& mousePos) const; |
| 42 |
|
| 43 |
void moveCurrentEditedField(int moveKey); |
| 44 |
void adjustCurrentEditedField(int adjustKey); |
| 45 |
void scrollCurrentEditedField(int pixelsYScrolled, int stepsYScrolled); |
| 46 |
|
| 47 |
void finishEditing(); |
| 48 |
|
| 49 |
QString m_valueString; |
| 50 |
|
| 51 |
int m_currentEditedFieldIndex = -1; |
| 52 |
|
| 53 |
QQuickItem* m_visualItem = nullptr; |
| 54 |
|
| 55 |
std::shared_ptr<TimecodeFormatter> m_formatter; |
| 56 |
|
| 57 |
int m_scrolled = 0; |
| 58 |
}; |
| 59 |
} |