/[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 969 by capela, Wed Dec 6 19:38:02 2006 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-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  //----------------------------------------------------------------------  public:
39  // class qsamplerInstrumentGroup -- custom group list view item.  
40  //          // Constructor.
41            InstrumentListModel(QObject *pParent = NULL);
42  class qsamplerInstrumentGroup : public QListViewItem  
43  {          // Destructor.
44  public:          ~InstrumentListModel();
45    
46          // Constructors.          // Overridden methods from subclass(es)
47          qsamplerInstrumentGroup(qsamplerInstrumentList *pListView,          int rowCount(const QModelIndex& parent) const;
48                  const QString& sName, QListViewItem *pItemAfter = NULL);          int columnCount(const QModelIndex& parent) const;
49          qsamplerInstrumentGroup(qsamplerInstrumentGroup *pGroupItem,  
50                  const QString& sName);          QVariant data(const QModelIndex& index, int role) const;
51          // Default destructor.          QVariant headerData(int section, Qt::Orientation orientation,
52          virtual ~qsamplerInstrumentGroup();                  int role = Qt::DisplayRole) const;
53    
54          // Instance accessors.          // Map selector.
55          void setName(const QString& sName);          void setMidiMap(int iMidiMap);
56          QString name() const;          int midiMap() const;
57    
58          qsamplerInstrumentList  *listView() const;          // Own methods
59          qsamplerInstrumentGroup *groupItem() const;          const Instrument *addInstrument(int iMap, int iBank, int iProg);
60            void removeInstrument(const Instrument *pInstrument);
61          // To show up whether its open or not.          void updateInstrument(const Instrument *pInstrument);
62          virtual void setOpen(bool bOpen);  
63            // General reloader.
64          // To virtually distinguish between list view items.          void refresh();
65          virtual int rtti() const;  
66  };          // Make the following method public
67            void beginReset();
68            void endReset();
69  //----------------------------------------------------------------------  
70  // class qsamplerInstrumentItem -- custom file list view item.          // Map clear.
71  //          void clear();
72    
73  class qsamplerInstrumentItem : public qsamplerInstrumentGroup  protected:
74  {  
75  public:          QModelIndex index(int row, int col, const QModelIndex& parent) const;
76            QModelIndex parent(const QModelIndex& child) const;
77          // Constructors.  
78          qsamplerInstrumentItem(qsamplerInstrumentList *pListView,  private:
79                  qsamplerInstrument *pInstrument,  
80                  QListViewItem *pItemAfter = NULL);          typedef QList<Instrument *> InstrumentList;
81          qsamplerInstrumentItem(qsamplerInstrumentGroup *pGroupItem,          typedef QMap<int, InstrumentList> InstrumentMap;
82                  qsamplerInstrument *pInstrument);  
83          // Default destructor.          InstrumentMap m_instruments;
84          virtual ~qsamplerInstrumentItem();  
85            // Current map selection.
86          // To virtually distinguish between list view items.          int m_iMidiMap;
87          virtual int rtti() const;  };
88    
89          // Payload accessor.  
90          qsamplerInstrument *instrument() const;  //-------------------------------------------------------------------------
91    // QSampler::InstrumentListView - list view for MIDI prog mappings
92          // View refreshment.  //
93          void update();  
94    class InstrumentListView : public QTreeView
95  private:  {
96    public:
97          // File item full path.  
98          qsamplerInstrument *m_pInstrument;          // Constructor.
99  };          InstrumentListView(QWidget *pParent = NULL);
100    
101            // Destructor.
102  //----------------------------------------------------------------------------          ~InstrumentListView();
103  // qsamplerInstrumentList -- MIDI instrument list view.  
104  //          // Map selector.
105            void setMidiMap(int iMidiMap);
106  class qsamplerInstrumentList : public QListView          int midiMap() const;
107  {  
108          Q_OBJECT          // Own methods
109            const Instrument *addInstrument(int iMap, int iBank, int iProg);
110  public:          void removeInstrument(const Instrument *pInstrument);
111            void updateInstrument(const Instrument *pInstrument);
112          // Constructor.  
113          qsamplerInstrumentList(QWidget *pParent, const char *pszName = NULL);          // General reloader.
114          // Default destructor.          void refresh();
115          ~qsamplerInstrumentList();  
116    private:
117          // QListViewItem::rtti() return values.  
118          enum ItemType { Group = 1001, Item = 1002 };          // Instance variables.
119            InstrumentListModel *m_pListModel;
120          // Add a new group/file item, optionally under a given group.  };
121          qsamplerInstrumentGroup *addGroup(const QString& sName,  
122                  qsamplerInstrumentGroup *pParentGroup = NULL);  
123          qsamplerInstrumentItem *addItem(  } // namespace QSampler
124                  qsamplerInstrument *pInstrument,  
125                  qsamplerInstrumentGroup *pParentGroup = NULL);  #endif  // __qsamplerInstrumentList_h
126    
127          // Find a group/file item, given its name.  
128          qsamplerInstrumentGroup *findGroup(const QString& sName) const;  // end of qsamplerInstrumentList.h
         qsamplerInstrumentItem  *findItem(  
                 qsamplerInstrument *pInstrument) const;  
   
 signals:  
   
         // 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.969  
changed lines
  Added in v.2066

  ViewVC Help
Powered by ViewVC