/[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 962 by capela, Sun Dec 3 18:27:23 2006 UTC revision 2064 by capela, Fri Mar 12 16:02:32 2010 UTC
# Line 1  Line 1 
1  // qsamplerInstrumentList.h  // qsamplerInstrumentList.h
2  //  //
3  /****************************************************************************  /****************************************************************************
4     Copyright (C) 2003-2005, 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
6     This program is free software; you can redistribute it and/or  
7     modify it under the terms of the GNU General Public License     This program is free software; you can redistribute it and/or
8     as published by the Free Software Foundation; either version 2     modify it under the terms of the GNU General Public License
9     of the License, or (at your option) any later version.     as published by the Free Software Foundation; either version 2
10       of the License, or (at your option) any later version.
11     This program is distributed in the hope that it will be useful,  
12     but WITHOUT ANY WARRANTY; without even the implied warranty of     This program is distributed in the hope that it will be useful,
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the     but WITHOUT ANY WARRANTY; without even the implied warranty of
14     GNU General Public License for more details.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15       GNU General Public License for more details.
16     You should have received a copy of the GNU General Public License  
17     along with this program; if not, write to the Free Software     You should have received a copy of the GNU General Public License
18     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.     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  #ifndef __qsamplerInstrumentList_h  
23  #define __qsamplerInstrumentList_h  #ifndef __qsamplerInstrumentList_h
24    #define __qsamplerInstrumentList_h
25  #include <qlistview.h>  
26  #include <qheader.h>  #include <QTreeView>
27    
28  #include <lscp/client.h>  namespace QSampler {
29    
30    class Instrument;
31  // Forward declarations.  
32  class qsamplerInstrument;  //-------------------------------------------------------------------------
33  class qsamplerInstrumentList;  // QSampler:InstrumentListModel - data model for MIDI prog mappings
34    //
35  class QAction;  
36    class InstrumentListModel : public QAbstractItemModel
37    {
38  //----------------------------------------------------------------------          Q_OBJECT
39  // class qsamplerInstrumentGroup -- custom group list view item.  
40  //  public:
41    
42  class qsamplerInstrumentGroup : public QListViewItem          // Constructor.
43  {          InstrumentListModel(QObject *pParent = NULL);
44  public:  
45            // Destructor.
46          // Constructors.          ~InstrumentListModel();
47          qsamplerInstrumentGroup(qsamplerInstrumentList *pListView,  
48                  const QString& sName, QListViewItem *pItemAfter = NULL);          // Overridden methods from subclass(es)
49          qsamplerInstrumentGroup(qsamplerInstrumentGroup *pGroupItem,          int rowCount(const QModelIndex& parent) const;
50                  const QString& sName);          int columnCount(const QModelIndex& parent) const;
51          // Default destructor.  
52          virtual ~qsamplerInstrumentGroup();          QVariant data(const QModelIndex& index, int role) const;
53            QVariant headerData(int section, Qt::Orientation orientation,
54          // Instance accessors.                  int role = Qt::DisplayRole) const;
55          void setName(const QString& sName);  
56          QString name() const;          // Map selector.
57            void setMidiMap(int iMidiMap);
58          qsamplerInstrumentList  *listView() const;          int midiMap() const;
59          qsamplerInstrumentGroup *groupItem() const;  
60            // Own methods
61          // To show up whether its open or not.          const Instrument *addInstrument(int iMap, int iBank, int iProg);
62          virtual void setOpen(bool bOpen);          void removeInstrument(const Instrument *pInstrument);
63            void updateInstrument(const Instrument *pInstrument);
64          // To virtually distinguish between list view items.  
65          virtual int rtti() const;          // General reloader.
66  };          void refresh();
67    
68            // Make the following method public
69  //----------------------------------------------------------------------          void beginReset();
70  // class qsamplerInstrumentItem -- custom file list view item.          void endReset();
71  //  
72            // Map clear.
73  class qsamplerInstrumentItem : public qsamplerInstrumentGroup          void clear();
74  {  
75  public:  protected:
76    
77          // Constructors.          QModelIndex index(int row, int col, const QModelIndex& parent) const;
78          qsamplerInstrumentItem(qsamplerInstrumentList *pListView,          QModelIndex parent(const QModelIndex& child) const;
79                  qsamplerInstrument *pInstrument,  
80                  QListViewItem *pItemAfter = NULL);  private:
81          qsamplerInstrumentItem(qsamplerInstrumentGroup *pGroupItem,  
82                  qsamplerInstrument *pInstrument);          typedef QList<Instrument *> InstrumentList;
83          // Default destructor.          typedef QMap<int, InstrumentList> InstrumentMap;
84          virtual ~qsamplerInstrumentItem();  
85            InstrumentMap m_instruments;
86          // To virtually distinguish between list view items.  
87          virtual int rtti() const;          // Current map selection.
88            int m_iMidiMap;
89          // Payload accessor.  };
90          qsamplerInstrument *Instrument() const;  
91    
92          // View refreshment.  //-------------------------------------------------------------------------
93          void update();  // QSampler::InstrumentListView - list view for MIDI prog mappings
94    //
95  private:  
96    class InstrumentListView : public QTreeView
97          // File item full path.  {
98          qsamplerInstrument *m_pInstrument;          Q_OBJECT
99  };  
100    public:
101    
102  //----------------------------------------------------------------------------          // Constructor.
103  // qsamplerInstrumentList -- MIDI instrument list view.          InstrumentListView(QWidget *pParent = 0);
104  //  
105            // Destructor.
106  class qsamplerInstrumentList : public QListView          ~InstrumentListView();
107  {  
108          Q_OBJECT          // Map selector.
109            void setMidiMap(int iMidiMap);
110  public:          int midiMap() const;
111    
112          // Constructor.          // Own methods
113          qsamplerInstrumentList(QWidget *pParent, const char *pszName = NULL);          const Instrument *addInstrument(int iMap, int iBank, int iProg);
114          // Default destructor.          void removeInstrument(const Instrument *pInstrument);
115          ~qsamplerInstrumentList();          void updateInstrument(const Instrument *pInstrument);
116    
117          // QListViewItem::rtti() return values.          // General reloader.
118          enum ItemType { Group = 1001, Item = 1002 };          void refresh();
119    
120          // Add a new group/file item, optionally under a given group.  private:
121          qsamplerInstrumentGroup *addGroup(const QString& sName,  
122                  qsamplerInstrumentGroup *pParentGroup = NULL);          // Instance variables.
123          qsamplerInstrumentItem *addItem(          InstrumentListModel *m_pListModel;
124                  qsamplerInstrument *pInstrument,  };
125                  qsamplerInstrumentGroup *pParentGroup = NULL);  
126    
127          // Find a group/file item, given its name.  } // namespace QSampler
128          qsamplerInstrumentGroup *findGroup(const QString& sName) const;  
129          qsamplerInstrumentItem  *findItem(  #endif  // __qsamplerInstrumentList_h
130                  qsamplerInstrument *pInstrument) const;  
131    
132  signals:  // end of qsamplerInstrumentList.h
   
         // Instrument map/session change signal.  
         void instrumentsChanged();  
   
 public slots:  
   
         // General reloader.  
         void refresh();  
   
 protected slots:  
   
         // Add a new group item below the current one.  
         void newGroupSlot();  
         // Add a instrument item below the current one.  
         void newItemSlot();  
         // Change current instrument item.  
         void editItemSlot();  
         // Rename current group/item.  
         void renameSlot();  
         // Remove current group/item.  
         void deleteSlot();  
   
         // In-place selection slot.  
         void selectionChangedSlot();  
   
         // In-place activation slot.  
         void activatedSlot(QListViewItem *pListItem);  
   
         // In-place aliasing slot.  
         void renamedSlot(QListViewItem *pItem);  
   
 protected:  
   
         // Find and return the nearest group item...  
         qsamplerInstrumentGroup *groupItem(QListViewItem *pListItem) const;  
   
         // Context menu request event handler.  
         void contextMenuEvent(QContextMenuEvent *pContextMenuEvent);  
   
 private:  
   
         // List view actions.  
         QAction *m_pNewGroupAction;  
         QAction *m_pNewItemAction;  
         QAction *m_pEditItemAction;  
         QAction *m_pRenameAction;  
         QAction *m_pDeleteAction;  
         QAction *m_pRefreshAction;  
 };  
   
   
 #endif  // __qsamplerInstrumentList_h  
   
 // end of qsamplerInstrumentList.h  

Legend:
Removed from v.962  
changed lines
  Added in v.2064

  ViewVC Help
Powered by ViewVC