LMMS
Loading...
Searching...
No Matches
AutomatableModelView.h
Go to the documentation of this file.
1/*
2 * AutomatableModelView.h - provides AutomatableModelView base class and
3 * provides BoolModelView, FloatModelView, IntModelView subclasses.
4 *
5 * Copyright (c) 2008-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
6 *
7 * This file is part of LMMS - https://lmms.io
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public
11 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public
20 * License along with this program (see COPYING); if not, write to the
21 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 * Boston, MA 02110-1301 USA.
23 *
24 */
25
26#ifndef LMMS_GUI_AUTOMATABLE_MODEL_VIEW_H
27#define LMMS_GUI_AUTOMATABLE_MODEL_VIEW_H
28
29#include "ModelView.h"
30#include "AutomatableModel.h"
31
32class QMenu;
33class QMouseEvent;
34
35namespace lmms::gui
36{
37
38class LMMS_EXPORT AutomatableModelView : public ModelView
39{
40public:
41 AutomatableModelView( Model* model, QWidget* _this );
42 ~AutomatableModelView() override = default;
43
44 // some basic functions for convenience
49
51 {
53 }
54
55 void setModel( Model* model, bool isOldModelValid = true ) override;
56 void unsetModel() override;
57
58 template<typename T>
59 inline T value() const
60 {
61 return modelUntyped() ? modelUntyped()->value<T>() : 0;
62 }
63
64 inline void setDescription( const QString& desc )
65 {
66 m_description = desc;
67 }
68
69 inline void setUnit( const QString& unit )
70 {
71 m_unit = unit;
72 }
73
74 void addDefaultActions( QMenu* menu );
75
76 void setConversionFactor( float factor );
77 float getConversionFactor();
78
79
80protected:
81 virtual void mousePressEvent( QMouseEvent* event );
82
84 QString m_unit;
85 float m_conversionFactor; // Factor to be applied when the m_model->value is displayed
86} ;
87
88
89
90
91class AutomatableModelViewSlots : public QObject
92{
93 Q_OBJECT
94public:
96
97public slots:
99 void removeConnection();
100
101private slots:
103 void copyToClipboard();
105 void pasteFromClipboard();
106
107protected:
109
110} ;
111
112
113
114template <typename ModelType> class LMMS_EXPORT TypedModelView : public AutomatableModelView
115{
116public:
117 TypedModelView( Model* model, QWidget* _this) :
119 {}
120
121 ModelType* model()
122 {
123 return castModel<ModelType>();
124 }
125 const ModelType* model() const
126 {
127 return castModel<ModelType>();
128 }
129};
130
134
135} // namespace lmms::gui
136
137#endif // LMMS_GUI_AUTOMATABLE_MODEL_VIEW_H
Definition AutomatableModel.h:77
Definition Model.h:37
Definition AutomatableModelView.h:39
~AutomatableModelView() override=default
const AutomatableModel * modelUntyped() const
Definition AutomatableModelView.h:50
QString m_description
Definition AutomatableModelView.h:83
void setUnit(const QString &unit)
Definition AutomatableModelView.h:69
AutomatableModel * modelUntyped()
Definition AutomatableModelView.h:45
void setDescription(const QString &desc)
Definition AutomatableModelView.h:64
AutomatableModelView(Model *model, QWidget *_this)
Definition AutomatableModelView.cpp:47
float m_conversionFactor
Definition AutomatableModelView.h:85
T value() const
Definition AutomatableModelView.h:59
QString m_unit
Definition AutomatableModelView.h:84
void execConnectionDialog()
Definition AutomatableModelView.cpp:200
AutomatableModelViewSlots(AutomatableModelView *amv, QObject *parent)
Definition AutomatableModelView.cpp:190
void copyToClipboard()
Copy the model's value to the clipboard.
Definition AutomatableModelView.cpp:252
void removeConnection()
Definition AutomatableModelView.cpp:238
void pasteFromClipboard()
Paste the model's value from the clipboard.
Definition AutomatableModelView.cpp:260
AutomatableModelView * m_amv
Definition AutomatableModelView.h:108
Model * model()
Definition ModelView.h:43
ModelView(Model *model, QWidget *widget)
Definition ModelView.cpp:33
T * castModel()
Definition ModelView.h:54
Definition AutomatableModelView.h:115
TypedModelView(Model *model, QWidget *_this)
Definition AutomatableModelView.h:117
FloatModel * model()
Definition AutomatableModelView.h:121
const ModelType * model() const
Definition AutomatableModelView.h:125
static uintptr_t parent
Definition pugl.h:1644
Definition AudioPortAudio.cpp:223
TypedModelView< BoolModel > BoolModelView
Definition AutomatableModelView.h:133
TypedModelView< IntModel > IntModelView
Definition AutomatableModelView.h:132
TypedModelView< FloatModel > FloatModelView
Definition AutomatableModelView.h:131
png_const_structrp png_const_inforp int * unit
Definition png.h:2161