lmms
Cross-platform music production software
Toggle main menu visibility
Loading...
Searching...
No Matches
include
ComboBoxModel.h
Go to the documentation of this file.
1
/*
2
* ComboBoxModel.h - declaration of class ComboBoxModel
3
*
4
* Copyright (c) 2008-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_COMBOBOX_MODEL_H
26
#define LMMS_COMBOBOX_MODEL_H
27
28
#include <memory>
29
#include <utility>
30
#include <vector>
31
32
#include "
AutomatableModel.h
"
33
#include "
embed.h
"
34
35
namespace
lmms
36
{
37
38
class
LMMS_EXPORT
ComboBoxModel
:
public
IntModel
39
{
40
Q_OBJECT
41
MODEL_IS_VISITABLE
42
public
:
43
ComboBoxModel
(
Model
* parent =
nullptr
,
44
const
QString&
displayName
= QString(),
45
bool
isDefaultConstructed
=
false
) :
46
IntModel
( 0, 0, 0, parent,
displayName
,
isDefaultConstructed
)
47
{
48
setJournalling
(
false
);
49
}
50
51
void
addItem( QString item, std::unique_ptr<PixmapLoader> loader =
nullptr
);
52
53
void
replaceItem(std::size_t index, QString item, std::unique_ptr<PixmapLoader> loader =
nullptr
);
54
55
void
clear();
56
57
int
findText(
const
QString& txt )
const
;
58
59
QString
currentText
()
const
60
{
61
return
(
size
() > 0 &&
value
() <
size
() ) ?
m_items
[
value
()].first : QString();
62
}
63
64
const
PixmapLoader
*
currentData
()
const
65
{
66
return
m_items
[
value
()].second.get();
67
}
68
69
const
QString &
itemText
(
int
i )
const
70
{
71
return
m_items
[std::clamp(i,
minValue
(),
maxValue
())].first;
72
}
73
74
const
PixmapLoader
*
itemPixmap
(
int
i )
const
75
{
76
return
m_items
[std::clamp(i,
minValue
(),
maxValue
())].second.get();
77
}
78
79
int
size
()
const
80
{
81
return
m_items
.size();
82
}
83
84
85
private
:
86
using
Item
= std::pair<QString, std::unique_ptr<PixmapLoader>>;
87
88
std::vector<Item>
m_items
;
89
90
} ;
91
92
}
// namespace lmms
93
94
#endif
// LMMS_COMBOBOX_MODEL_H
AutomatableModel.h
MODEL_IS_VISITABLE
#define MODEL_IS_VISITABLE
Definition
AutomatableModel.h:68
lmms::ComboBoxModel::itemText
const QString & itemText(int i) const
Definition
ComboBoxModel.h:69
lmms::ComboBoxModel::Item
std::pair< QString, std::unique_ptr< PixmapLoader > > Item
Definition
ComboBoxModel.h:86
lmms::ComboBoxModel::size
int size() const
Definition
ComboBoxModel.h:79
lmms::ComboBoxModel::ComboBoxModel
ComboBoxModel(Model *parent=nullptr, const QString &displayName=QString(), bool isDefaultConstructed=false)
Definition
ComboBoxModel.h:43
lmms::ComboBoxModel::m_items
std::vector< Item > m_items
Definition
ComboBoxModel.h:88
lmms::ComboBoxModel::itemPixmap
const PixmapLoader * itemPixmap(int i) const
Definition
ComboBoxModel.h:74
lmms::ComboBoxModel::currentData
const PixmapLoader * currentData() const
Definition
ComboBoxModel.h:64
lmms::ComboBoxModel::currentText
QString currentText() const
Definition
ComboBoxModel.h:59
lmms::IntModel::IntModel
IntModel(int val=0, int min=0, int max=0, Model *parent=nullptr, const QString &displayName=QString(), bool defaultConstructed=false)
Definition
AutomatableModel.h:490
lmms::JournallingObject::setJournalling
void setJournalling(const bool _sr)
Definition
JournallingObject.h:73
lmms::Model
Definition
Model.h:37
lmms::Model::displayName
virtual QString displayName() const
Definition
Model.cpp:47
lmms::Model::isDefaultConstructed
bool isDefaultConstructed() const
Definition
Model.cpp:37
lmms::PixmapLoader
Definition
embed.h:73
lmms::TypedAutomatableModel< int >::minValue
int minValue() const
Definition
AutomatableModel.h:453
lmms::TypedAutomatableModel< int >::maxValue
int maxValue() const
Definition
AutomatableModel.h:458
lmms::TypedAutomatableModel< int >::value
int value(int frameOffset=0) const
Definition
AutomatableModel.h:443
embed.h
lmms
Definition
RemotePluginBase.cpp:34
Generated on
for lmms by
1.18.0