/[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 1499 by capela, Tue Nov 20 16:48:04 2007 UTC revision 2066 by capela, Sat Mar 13 19:15:24 2010 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-2010, 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 <QItemDelegate>  
27    
28  #include <lscp/client.h>  namespace QSampler {
   
 #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  public:  public:
     MidiInstrumentsModel(QObject* parent = 0);  
39    
40      // overridden methods from subclass(es)          // Constructor.
41      int rowCount(const QModelIndex &parent) const;          InstrumentListModel(QObject *pParent = NULL);
42      int columnCount(const QModelIndex &parent) const;  
43      QVariant data(const QModelIndex &index, int role) const;          // Destructor.
44      QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;          ~InstrumentListModel();
45    
46      // make the following method public          // Overridden methods from subclass(es)
47      QAbstractTableModel::reset;          int rowCount(const QModelIndex& parent) const;
48            int columnCount(const QModelIndex& parent) const;
49      // own methods  
50      qsamplerInstrument* addInstrument(int iMap = 0, int iBank = -1, int iProg = -1);          QVariant data(const QModelIndex& index, int role) const;
51      void removeInstrument(const qsamplerInstrument& instrument);          QVariant headerData(int section, Qt::Orientation orientation,
52      void resort(const qsamplerInstrument instrument);                  int role = Qt::DisplayRole) const;
53    
54      // Map selector.          // Map selector.
55      void setMidiMap(int iMidiMap);          void setMidiMap(int iMidiMap);
56      int midiMap() const;          int midiMap() const;
57    
58  signals:          // Own methods
59      // Instrument map/session change signal.          const Instrument *addInstrument(int iMap, int iBank, int iProg);
60      void instrumentsChanged();          void removeInstrument(const Instrument *pInstrument);
61            void updateInstrument(const Instrument *pInstrument);
62  public slots:  
63      // General reloader.          // General reloader.
64      void refresh();          void refresh();
65    
66            // Make the following method public
67            void beginReset();
68            void endReset();
69    
70            // Map clear.
71            void clear();
72    
73    protected:
74    
75            QModelIndex index(int row, int col, const QModelIndex& parent) const;
76            QModelIndex parent(const QModelIndex& child) const;
77    
78  private:  private:
     typedef QMap<int, QList<qsamplerInstrument> > InstrumentsMap;  
79    
80      // Current map selection.          typedef QList<Instrument *> InstrumentList;
81      int m_iMidiMap;          typedef QMap<int, InstrumentList> InstrumentMap;
82    
83            InstrumentMap m_instruments;
84    
85      InstrumentsMap instruments;          // Current map selection.
86            int m_iMidiMap;
87  };  };
88    
89    
90  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
91  // MidiInstrumentsDelegate - table cell renderer for MIDI prog mappings  // QSampler::InstrumentListView - list view for MIDI prog mappings
92  // (doesn't actually do anything ATM, but is already there for a future  //
 // cell editor widget implementation)  
93    
94  class MidiInstrumentsDelegate : public QItemDelegate {  class InstrumentListView : public QTreeView
95  Q_OBJECT  {
96  public:  public:
     MidiInstrumentsDelegate(QObject* parent = 0);  
97    
98      QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option,          // Constructor.
99                            const QModelIndex& index) const;          InstrumentListView(QWidget *pParent = NULL);
100    
101            // Destructor.
102            ~InstrumentListView();
103    
104      void setEditorData(QWidget* editor, const QModelIndex& index) const;          // Map selector.
105      void setModelData(QWidget* editor, QAbstractItemModel* model,          void setMidiMap(int iMidiMap);
106                        const QModelIndex& index) const;          int midiMap() const;
107    
108            // Own methods
109            const Instrument *addInstrument(int iMap, int iBank, int iProg);
110            void removeInstrument(const Instrument *pInstrument);
111            void updateInstrument(const Instrument *pInstrument);
112    
113      void updateEditorGeometry(QWidget* editor,          // General reloader.
114          const QStyleOptionViewItem& option, const QModelIndex& index) const;          void refresh();
115    
116    private:
117    
118            // Instance variables.
119            InstrumentListModel *m_pListModel;
120  };  };
121    
122    
123    } // namespace QSampler
124    
125  #endif  // __qsamplerInstrumentList_h  #endif  // __qsamplerInstrumentList_h
126    
127    

Legend:
Removed from v.1499  
changed lines
  Added in v.2066

  ViewVC Help
Powered by ViewVC