/[svn]/qsampler/trunk/src/qsamplerInstrumentList.h
ViewVC logotype

Contents of /qsampler/trunk/src/qsamplerInstrumentList.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2070 - (show annotations) (download) (as text)
Mon Mar 15 17:06:46 2010 UTC (14 years ago) by capela
File MIME type: text/x-c++hdr
File size: 3374 byte(s)
- Still trying to fix instrument list view/model for Qt >= 4.6. (part 4/n)

1 // qsamplerInstrumentList.h
2 //
3 /****************************************************************************
4 Copyright (C) 2003-2010, rncbc aka Rui Nuno Capela. All rights reserved.
5 Copyright (C) 2007, Christian Schoenebeck
6
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 as published by the Free Software Foundation; either version 2
10 of the License, or (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20
21 *****************************************************************************/
22
23 #ifndef __qsamplerInstrumentList_h
24 #define __qsamplerInstrumentList_h
25
26 #include <QTreeView>
27
28 namespace QSampler {
29
30 class Instrument;
31
32 //-------------------------------------------------------------------------
33 // QSampler:InstrumentListModel - data model for MIDI prog mappings
34 //
35
36 class InstrumentListModel : public QAbstractItemModel
37 {
38 public:
39
40 // Constructor.
41 InstrumentListModel(QObject *pParent = NULL);
42
43 // Destructor.
44 ~InstrumentListModel();
45
46 // Overridden methods from subclass(es)
47 int rowCount(const QModelIndex& parent) const;
48 int columnCount(const QModelIndex& parent) const;
49
50 QVariant data(const QModelIndex& index, int role) const;
51 QVariant headerData(int section, Qt::Orientation orientation,
52 int role = Qt::DisplayRole) const;
53
54 // Map selector.
55 void setMidiMap(int iMidiMap);
56 int midiMap() const;
57
58 // Own methods
59 const Instrument *addInstrument(int iMap, int iBank, int iProg);
60 void removeInstrument(Instrument *pInstrument);
61 void updateInstrument(Instrument *pInstrument);
62 void resortInstrument(Instrument *pInstrument);
63
64 // General reloader.
65 void refresh();
66
67 // Make the following method public
68 void beginReset();
69 void endReset();
70
71 // Map clear.
72 void clear();
73
74 protected:
75
76 QModelIndex index(int row, int col, const QModelIndex& parent) const;
77 QModelIndex parent(const QModelIndex& child) const;
78
79 private:
80
81 typedef QList<Instrument *> InstrumentList;
82 typedef QMap<int, InstrumentList> InstrumentMap;
83
84 InstrumentMap m_instruments;
85
86 // Current map selection.
87 int m_iMidiMap;
88 };
89
90
91 //-------------------------------------------------------------------------
92 // QSampler::InstrumentListView - list view for MIDI prog mappings
93 //
94
95 class InstrumentListView : public QTreeView
96 {
97 public:
98
99 // Constructor.
100 InstrumentListView(QWidget *pParent = NULL);
101
102 // Destructor.
103 ~InstrumentListView();
104
105 // Map selector.
106 void setMidiMap(int iMidiMap);
107 int midiMap() const;
108
109 // Own methods
110 const Instrument *addInstrument(int iMap, int iBank, int iProg);
111 void removeInstrument(Instrument *pInstrument);
112 void updateInstrument(Instrument *pInstrument);
113 void resortInstrument(Instrument *pInstrument);
114
115 // General reloader.
116 void refresh();
117
118 private:
119
120 // Instance variables.
121 InstrumentListModel *m_pListModel;
122 };
123
124
125 } // namespace QSampler
126
127 #endif // __qsamplerInstrumentList_h
128
129
130 // end of qsamplerInstrumentList.h

  ViewVC Help
Powered by ViewVC