/[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 1499 by capela, Tue Nov 20 16:48:04 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.  Q_OBJECT
40  //  public:
41        MidiInstrumentsModel(QObject* parent = 0);
42  class qsamplerInstrumentGroup : public QListViewItem  
43  {      // overridden methods from subclass(es)
44  public:      int rowCount(const QModelIndex &parent) const;
45        int columnCount(const QModelIndex &parent) const;
46          // Constructors.      QVariant data(const QModelIndex &index, int role) const;
47          qsamplerInstrumentGroup(qsamplerInstrumentList *pListView,      QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
48                  const QString& sName, QListViewItem *pItemAfter = NULL);  
49          qsamplerInstrumentGroup(qsamplerInstrumentGroup *pGroupItem,      // make the following method public
50                  const QString& sName);      QAbstractTableModel::reset;
51          // Default destructor.  
52          virtual ~qsamplerInstrumentGroup();      // own methods
53        qsamplerInstrument* addInstrument(int iMap = 0, int iBank = -1, int iProg = -1);
54          // Instance accessors.      void removeInstrument(const qsamplerInstrument& instrument);
55          void setName(const QString& sName);      void resort(const qsamplerInstrument instrument);
56          QString name() const;  
57        // Map selector.
58          qsamplerInstrumentList  *listView() const;      void setMidiMap(int iMidiMap);
59          qsamplerInstrumentGroup *groupItem() const;      int midiMap() const;
60    
61          // To show up whether its open or not.  signals:
62          virtual void setOpen(bool bOpen);      // Instrument map/session change signal.
63        void instrumentsChanged();
64          // To virtually distinguish between list view items.  
65          virtual int rtti() const;  public slots:
66  };      // General reloader.
67        void refresh();
68    
69  //----------------------------------------------------------------------  private:
70  // class qsamplerInstrumentItem -- custom file list view item.      typedef QMap<int, QList<qsamplerInstrument> > InstrumentsMap;
71  //  
72        // Current map selection.
73  class qsamplerInstrumentItem : public qsamplerInstrumentGroup      int m_iMidiMap;
74  {  
75  public:      InstrumentsMap instruments;
76    };
77          // Constructors.  
78          qsamplerInstrumentItem(qsamplerInstrumentList *pListView,  
79                  qsamplerInstrument *pInstrument,  //-------------------------------------------------------------------------
80                  QListViewItem *pItemAfter = NULL);  // MidiInstrumentsDelegate - table cell renderer for MIDI prog mappings
81          qsamplerInstrumentItem(qsamplerInstrumentGroup *pGroupItem,  // (doesn't actually do anything ATM, but is already there for a future
82                  qsamplerInstrument *pInstrument);  // cell editor widget implementation)
83          // Default destructor.  
84          virtual ~qsamplerInstrumentItem();  class MidiInstrumentsDelegate : public QItemDelegate {
85    Q_OBJECT
86          // To virtually distinguish between list view items.  public:
87          virtual int rtti() const;      MidiInstrumentsDelegate(QObject* parent = 0);
88    
89          // Payload accessor.      QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option,
90          qsamplerInstrument *instrument() const;                            const QModelIndex& index) const;
91    
92          // View refreshment.      void setEditorData(QWidget* editor, const QModelIndex& index) const;
93          void update();      void setModelData(QWidget* editor, QAbstractItemModel* model,
94                          const QModelIndex& index) const;
95  private:  
96        void updateEditorGeometry(QWidget* editor,
97          // File item full path.          const QStyleOptionViewItem& option, const QModelIndex& index) const;
98          qsamplerInstrument *m_pInstrument;  };
99  };  
100    
101    #endif  // __qsamplerInstrumentList_h
102  //----------------------------------------------------------------------------  
103  // qsamplerInstrumentList -- MIDI instrument list view.  
104  //  // end of qsamplerInstrumentList.h
   
 class qsamplerInstrumentList : public QListView  
 {  
         Q_OBJECT  
   
 public:  
   
         // Constructor.  
         qsamplerInstrumentList(QWidget *pParent, const char *pszName = NULL);  
         // Default destructor.  
         ~qsamplerInstrumentList();  
   
         // QListViewItem::rtti() return values.  
         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.969  
changed lines
  Added in v.1499

  ViewVC Help
Powered by ViewVC