LMMS
Loading...
Searching...
No Matches
ModelView.h
Go to the documentation of this file.
1/*
2 * ModelView.h - declaration of ModelView base class
3 *
4 * Copyright (c) 2007-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
5 *
6 * This file is part of LMMS - https://lmms.io
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public
19 * License along with this program (see COPYING); if not, write to the
20 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301 USA.
22 *
23 */
24
25#ifndef LMMS_GUI_MODEL_VIEW_H
26#define LMMS_GUI_MODEL_VIEW_H
27
28#include <QPointer>
29#include "Model.h"
30
31namespace lmms::gui
32{
33
34class LMMS_EXPORT ModelView
35{
36public:
37 ModelView( Model* model, QWidget* widget );
38 virtual ~ModelView();
39
40 virtual void setModel( Model* model, bool isOldModelValid = true );
41 virtual void unsetModel();
42
44 {
45 return m_model;
46 }
47
48 const Model* model() const
49 {
50 return m_model;
51 }
52
53 template<class T>
55 {
56 return dynamic_cast<T*>( model() );
57 }
58
59 template<class T>
60 const T* castModel() const
61 {
62 return dynamic_cast<const T*>( model() );
63 }
64
65
66protected:
67 // sub-classes can re-implement this to track model-changes
68 virtual void modelChanged()
69 {
70 }
71
72 QWidget* widget()
73 {
74 return m_widget;
75 }
76
77 virtual void doConnections();
78
79
80private:
81 QWidget* m_widget;
82 QPointer<Model> m_model;
83
84} ;
85
86} // namespace lmms::gui
87
88#endif // LMMS_GUI_MODEL_VIEW_H
Definition Model.h:37
QWidget * widget()
Definition ModelView.h:72
Model * model()
Definition ModelView.h:43
QPointer< Model > m_model
Definition ModelView.h:82
const Model * model() const
Definition ModelView.h:48
ModelView(Model *model, QWidget *widget)
Definition ModelView.cpp:33
virtual void unsetModel()
Definition ModelView.cpp:81
const T * castModel() const
Definition ModelView.h:60
QWidget * m_widget
Definition ModelView.h:81
virtual void modelChanged()
Definition ModelView.h:68
virtual void setModel(Model *model, bool isOldModelValid=true)
Definition ModelView.cpp:53
T * castModel()
Definition ModelView.h:54
Definition AudioPortAudio.cpp:223