/[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 1509 by capela, Thu Nov 22 11:10:44 2007 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-2007, 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 <QListWidget>
27    #include <QItemDelegate>
28  #include <lscp/client.h>  
29    #include <lscp/client.h>
30    
31  // Forward declarations.  #include "qsamplerInstrument.h"
32  class qsamplerInstrument;  
33  class qsamplerInstrumentList;  
34    //-------------------------------------------------------------------------
35  class QAction;  // MidiInstrumentsModel - data model for MIDI prog mappings (used for QTableView)
36    //
37    
38  //----------------------------------------------------------------------  class MidiInstrumentsModel : public QAbstractTableModel
39  // class qsamplerInstrumentGroup -- custom group list view item.  {
40  //          Q_OBJECT
41    
42  class qsamplerInstrumentGroup : public QListViewItem  public:
43  {  
44  public:          MidiInstrumentsModel(QObject* pParent = NULL);
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.          // Make the following method public
55          void setName(const QString& sName);          QAbstractTableModel::reset;
56          QString name() const;  
57            // Own methods
58          qsamplerInstrumentList  *listView() const;          qsamplerInstrument* addInstrument(int iMap = 0,
59          qsamplerInstrumentGroup *groupItem() const;                  int iBank = -1, int iProg = -1);
60            void removeInstrument(const qsamplerInstrument& instrument);
61          // To show up whether its open or not.  
62          virtual void setOpen(bool bOpen);          void resort(const qsamplerInstrument instrument);
63    
64          // To virtually distinguish between list view items.          // Map selector.
65          virtual int rtti() const;          void setMidiMap(int iMidiMap);
66  };          int midiMap() const;
67    
68    signals:
69  //----------------------------------------------------------------------  
70  // class qsamplerInstrumentItem -- custom file list view item.          // Instrument map/session change signal.
71  //          void instrumentsChanged();
72    
73  class qsamplerInstrumentItem : public qsamplerInstrumentGroup  public slots:
74  {  
75  public:          // General reloader.
76            void refresh();
77          // Constructors.  
78          qsamplerInstrumentItem(qsamplerInstrumentList *pListView,  private:
79                  qsamplerInstrument *pInstrument,  
80                  QListViewItem *pItemAfter = NULL);          typedef QMap<int, QList<qsamplerInstrument> > InstrumentsMap;
81          qsamplerInstrumentItem(qsamplerInstrumentGroup *pGroupItem,  
82                  qsamplerInstrument *pInstrument);          // Current map selection.
83          // Default destructor.          int m_iMidiMap;
84          virtual ~qsamplerInstrumentItem();  
85            InstrumentsMap m_instruments;
86          // To virtually distinguish between list view items.  };
87          virtual int rtti() const;  
88    
89          // Payload accessor.  //-------------------------------------------------------------------------
90          qsamplerInstrument *Instrument() const;  // MidiInstrumentsDelegate - table cell renderer for MIDI prog mappings
91    // (doesn't actually do anything ATM, but is already there for a future
92          // View refreshment.  // cell editor widget implementation)
93          void update();  
94    class MidiInstrumentsDelegate : public QItemDelegate
95  private:  {
96            Q_OBJECT
97          // File item full path.  
98          qsamplerInstrument *m_pInstrument;  public:
99  };          MidiInstrumentsDelegate(QObject *pParent = NULL);
100    
101            QWidget* createEditor(QWidget *pParent,
102  //----------------------------------------------------------------------------                  const QStyleOptionViewItem& option, const QModelIndex& index) const;
103  // qsamplerInstrumentList -- MIDI instrument list view.  
104  //          void setEditorData(QWidget *pEditor,
105                    const QModelIndex& index) const;
106  class qsamplerInstrumentList : public QListView          void setModelData(QWidget *pEditor,
107  {                  QAbstractItemModel* model, const QModelIndex& index) const;
108          Q_OBJECT  
109            void updateEditorGeometry(QWidget* pEditor,
110  public:                  const QStyleOptionViewItem& option, const QModelIndex& index) const;
111    };
112          // Constructor.  
113          qsamplerInstrumentList(QWidget *pParent, const char *pszName = NULL);  
114          // Default destructor.  #endif  // __qsamplerInstrumentList_h
115          ~qsamplerInstrumentList();  
116    
117          // QListViewItem::rtti() return values.  // end of qsamplerInstrumentList.h
         enum ItemType { Group = 1001, Item = 1002 };  
   
         // Add a new group/file item, optionally under a given group.  
         qsamplerInstrumentGroup *addGroup(const QString& sName,  
                 qsamplerInstrumentGroup *pParentGroup = NULL);  
         qsamplerInstrumentItem *addItem(  
                 qsamplerInstrument *pInstrument,  
                 qsamplerInstrumentGroup *pParentGroup = NULL);  
   
         // Find a group/file item, given its name.  
         qsamplerInstrumentGroup *findGroup(const QString& sName) const;  
         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.962  
changed lines
  Added in v.1509

  ViewVC Help
Powered by ViewVC