1 // qsamplerInstrumentList.h 2 // 3 /**************************************************************************** 4 Copyright (C) 2003-2019, 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 Q_OBJECT 39 40 public: 41 42 // Constructor. 43 InstrumentListModel(QObject *pParent = nullptr); 44 45 // Destructor. 46 ~InstrumentListModel(); 47 48 // Overridden methods from subclass(es) 49 int rowCount(const QModelIndex& parent) const; 50 int columnCount(const QModelIndex& parent) const; 51 52 QVariant data(const QModelIndex& index, int role) const; 53 QVariant headerData(int section, Qt::Orientation orientation, 54 int role = Qt::DisplayRole) const; 55 56 // Map selector. 57 void setMidiMap(int iMidiMap); 58 int midiMap() const; 59 60 // Own methods 61 const Instrument *addInstrument(int iMap, int iBank, int iProg); 62 void removeInstrument(Instrument *pInstrument); 63 void updateInstrument(Instrument *pInstrument); 64 void resortInstrument(Instrument *pInstrument); 65 66 // General reloader. 67 void refresh(); 68 69 // Make the following method public 70 void beginReset(); 71 void endReset(); 72 73 // Map clear. 74 void clear(); 75 76 protected: 77 78 QModelIndex index(int row, int col, const QModelIndex& parent) const; 79 QModelIndex parent(const QModelIndex& child) const; 80 81 private: 82 83 typedef QList<Instrument *> InstrumentList; 84 typedef QMap<int, InstrumentList> InstrumentMap; 85 86 InstrumentMap m_instruments; 87 88 // Current map selection. 89 int m_iMidiMap; 90 }; 91 92 93 //------------------------------------------------------------------------- 94 // QSampler::InstrumentListView - list view for MIDI prog mappings 95 // 96 97 class InstrumentListView : public QTreeView 98 { 99 Q_OBJECT 100 101 public: 102 103 // Constructor. 104 InstrumentListView(QWidget *pParent = nullptr); 105 106 // Destructor. 107 ~InstrumentListView(); 108 109 // Map selector. 110 void setMidiMap(int iMidiMap); 111 int midiMap() const; 112 113 // Own methods 114 const Instrument *addInstrument(int iMap, int iBank, int iProg); 115 void removeInstrument(Instrument *pInstrument); 116 void updateInstrument(Instrument *pInstrument); 117 void resortInstrument(Instrument *pInstrument); 118 119 // General reloader. 120 void refresh(); 121 122 private: 123 124 // Instance variables. 125 InstrumentListModel *m_pListModel; 126 }; 127 128 129 } // namespace QSampler 130 131 #endif // __qsamplerInstrumentList_h 132 133 134 // end of qsamplerInstrumentList.h 135