1 #pragma once 2 3 #include <QAbstractTableModel> 4 #include <QVariant> 5 #include <QModelIndex> 6 #include <QAbstractItemDelegate> 7 8 #include "controllers/controllermappingtablemodel.h" 9 #include "controllers/midi/midimessage.h" 10 11 /// Table Model for the "Outputs" table view in the preferences dialog. 12 /// 13 /// This allows editing the output mappings for a MIDI preset. 14 class ControllerOutputMappingTableModel : public ControllerMappingTableModel { 15 Q_OBJECT 16 public: 17 ControllerOutputMappingTableModel(QObject* pParent); 18 ~ControllerOutputMappingTableModel() override; 19 20 // Apply the changes to the loaded preset. 21 void apply(); 22 23 // Clears all output mappings in the preset. 24 void clear(); 25 26 // Adds an empty output mapping. 27 void addEmptyMapping(); 28 29 // Removes the provided output mappings. 30 void removeMappings(QModelIndexList mappings); 31 32 // Returns a delegate for the provided column or NULL if the column does not 33 // need a delegate. 34 QAbstractItemDelegate* delegateForColumn(int column, QWidget* pParent); 35 36 //////////////////////////////////////////////////////////////////////////// 37 // QAbstractItemModel methods 38 //////////////////////////////////////////////////////////////////////////// 39 int rowCount(const QModelIndex& parent = QModelIndex()) const override; 40 int columnCount(const QModelIndex& parent = QModelIndex()) const override; 41 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; 42 bool setData(const QModelIndex& index, const QVariant& value, 43 int role = Qt::EditRole) override; 44 45 protected: 46 void onPresetLoaded() override; 47 48 private: 49 enum MidiColumn { 50 MIDI_COLUMN_CHANNEL = 0, 51 MIDI_COLUMN_OPCODE, 52 MIDI_COLUMN_CONTROL, 53 MIDI_COLUMN_ON, 54 MIDI_COLUMN_OFF, 55 MIDI_COLUMN_ACTION, 56 MIDI_COLUMN_MIN, 57 MIDI_COLUMN_MAX, 58 MIDI_COLUMN_COMMENT 59 }; 60 61 QList<MidiOutputMapping> m_midiOutputMappings; 62 }; 63