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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1492 by schoenebeck, Mon Nov 19 21:08:18 2007 UTC revision 2828 by capela, Wed Jul 22 21:28:27 2015 UTC
# Line 1  Line 1 
1  // qsamplerInstrumentList.h  // qsamplerInstrumentList.h
2  //  //
3  /****************************************************************************  /****************************************************************************
4     Copyright (C) 2003-2007, rncbc aka Rui Nuno Capela. All rights reserved.     Copyright (C) 2003-2015, rncbc aka Rui Nuno Capela. All rights reserved.
5     Copyright (C) 2007, Christian Schoenebeck     Copyright (C) 2007, Christian Schoenebeck
6    
7     This program is free software; you can redistribute it and/or     This program is free software; you can redistribute it and/or
# Line 23  Line 23 
23  #ifndef __qsamplerInstrumentList_h  #ifndef __qsamplerInstrumentList_h
24  #define __qsamplerInstrumentList_h  #define __qsamplerInstrumentList_h
25    
26  #include <QListWidget>  #include <QTreeView>
 #include <QListWidgetItem>  
 #include <QAbstractTableModel>  
 #include <QItemDelegate>  
27    
28  #include <lscp/client.h>  namespace QSampler {
   
 #include <string.h>  
   
 #include "qsamplerInstrument.h"  
29    
30    class Instrument;
31    
32  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
33  // MidiInstrumentsModel - data model for MIDI prog mappings (used for QTableView)  // QSampler:InstrumentListModel - data model for MIDI prog mappings
34  //  //
35    
36  class MidiInstrumentsModel : public QAbstractTableModel {  class InstrumentListModel : public QAbstractItemModel
37  Q_OBJECT  {
38            Q_OBJECT
39    
40  public:  public:
     MidiInstrumentsModel(QObject* parent = 0);  
41    
42      // overridden methods from subclass(es)          // Constructor.
43      int rowCount(const QModelIndex &parent) const;          InstrumentListModel(QObject *pParent = NULL);
44      int columnCount(const QModelIndex &parent) const;  
45      QVariant data(const QModelIndex &index, int role) const;          // Destructor.
46      QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;          ~InstrumentListModel();
47    
48      // make the following method public          // Overridden methods from subclass(es)
49      QAbstractTableModel::reset;          int rowCount(const QModelIndex& parent) const;
50            int columnCount(const QModelIndex& parent) const;
51      // own methods  
52      qsamplerInstrument* addInstrument(int iMap = 0, int iBank = -1, int iProg = -1);          QVariant data(const QModelIndex& index, int role) const;
53      void removeInstrument(const qsamplerInstrument& instrument);          QVariant headerData(int section, Qt::Orientation orientation,
54      void resort(const qsamplerInstrument instrument);                  int role = Qt::DisplayRole) const;
55    
56      // Map selector.          // Map selector.
57      void setMidiMap(int iMidiMap);          void setMidiMap(int iMidiMap);
58      int midiMap() const;          int midiMap() const;
59    
60  signals:          // Own methods
61      // Instrument map/session change signal.          const Instrument *addInstrument(int iMap, int iBank, int iProg);
62      void instrumentsChanged();          void removeInstrument(Instrument *pInstrument);
63            void updateInstrument(Instrument *pInstrument);
64  public slots:          void resortInstrument(Instrument *pInstrument);
65      // General reloader.  
66      void refresh();          // 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:  private:
     typedef QMap<int, QList<qsamplerInstrument> > InstrumentsMap;  
82    
83      // Current map selection.          typedef QList<Instrument *> InstrumentList;
84      int m_iMidiMap;          typedef QMap<int, InstrumentList> InstrumentMap;
85    
86      InstrumentsMap instruments;          InstrumentMap m_instruments;
87    
88            // Current map selection.
89            int m_iMidiMap;
90  };  };
91    
92    
93  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
94  // MidiInstrumentsDelegate - table cell renderer for MIDI prog mappings  // QSampler::InstrumentListView - list view for MIDI prog mappings
95  // (doesn't actually do anything ATM, but is already there for a future  //
 // cell editor widget implementation)  
96    
97  class MidiInstrumentsDelegate : public QItemDelegate {  class InstrumentListView : public QTreeView
98  Q_OBJECT  {
99  public:  public:
     MidiInstrumentsDelegate(QObject* parent = 0);  
100    
101      QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option,          // Constructor.
102                            const QModelIndex& index) const;          InstrumentListView(QWidget *pParent = NULL);
103    
104      void setEditorData(QWidget* editor, const QModelIndex& index) const;          // Destructor.
105      void setModelData(QWidget* editor, QAbstractItemModel* model,          ~InstrumentListView();
                       const QModelIndex& index) const;  
106    
107      void updateEditorGeometry(QWidget* editor,          // Map selector.
108          const QStyleOptionViewItem& option, const QModelIndex& index) const;          void setMidiMap(int iMidiMap);
109            int midiMap() const;
110    
111            // Own methods
112            const Instrument *addInstrument(int iMap, int iBank, int iProg);
113            void removeInstrument(Instrument *pInstrument);
114            void updateInstrument(Instrument *pInstrument);
115            void resortInstrument(Instrument *pInstrument);
116    
117            // General reloader.
118            void refresh();
119    
120    private:
121    
122            // Instance variables.
123            InstrumentListModel *m_pListModel;
124  };  };
125    
126    
127    } // namespace QSampler
128    
129  #endif  // __qsamplerInstrumentList_h  #endif  // __qsamplerInstrumentList_h
130    
131    

Legend:
Removed from v.1492  
changed lines
  Added in v.2828

  ViewVC Help
Powered by ViewVC