/[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 1013 by capela, Mon Jan 8 16:52:48 2007 UTC revision 1558 by capela, Thu Dec 6 09:35:33 2007 UTC
# Line 2  Line 2 
2  //  //
3  /****************************************************************************  /****************************************************************************
4     Copyright (C) 2003-2007, 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    
7     This program is free software; you can redistribute it and/or     This program is free software; you can redistribute it and/or
8     modify it under the terms of the GNU General Public License     modify it under the terms of the GNU General Public License
# Line 22  Line 23 
23  #ifndef __qsamplerInstrumentList_h  #ifndef __qsamplerInstrumentList_h
24  #define __qsamplerInstrumentList_h  #define __qsamplerInstrumentList_h
25    
26  #include <qlistview.h>  #include <QListWidget>
27  #include <qheader.h>  #include <QItemDelegate>
28    
29  #include <lscp/client.h>  #include <lscp/client.h>
30    
31    #include "qsamplerInstrument.h"
32    
33  // Forward declarations.  namespace QSampler {
 class qsamplerInstrument;  
 class qsamplerInstrumentList;  
34    
35  class QAction;  //-------------------------------------------------------------------------
36    // QSampler::MidiInstrumentsModel - data model for MIDI prog mappings
37    //                                  (used for QTableView)
38    
39    class MidiInstrumentsModel : public QAbstractTableModel
 //----------------------------------------------------------------------  
 // class qsamplerInstrumentGroup -- custom group list view item.  
 //  
   
 class qsamplerInstrumentGroup : public QListViewItem  
40  {  {
41  public:          Q_OBJECT
   
         // Constructors.  
         qsamplerInstrumentGroup(qsamplerInstrumentList *pListView,  
                 const QString& sName, QListViewItem *pItemAfter = NULL);  
         qsamplerInstrumentGroup(qsamplerInstrumentGroup *pGroupItem,  
                 const QString& sName);  
         // Default destructor.  
         virtual ~qsamplerInstrumentGroup();  
   
         // Instance accessors.  
         void setName(const QString& sName);  
         QString name() const;  
   
         qsamplerInstrumentList  *listView() const;  
         qsamplerInstrumentGroup *groupItem() const;  
   
         // To show up whether its open or not.  
         virtual void setOpen(bool bOpen);  
   
         // To virtually distinguish between list view items.  
         virtual int rtti() const;  
 };  
   
   
 //----------------------------------------------------------------------  
 // class qsamplerInstrumentItem -- custom file list view item.  
 //  
42    
 class qsamplerInstrumentItem : public qsamplerInstrumentGroup  
 {  
43  public:  public:
44    
45          // Constructors.          MidiInstrumentsModel(QObject* pParent = NULL);
         qsamplerInstrumentItem(qsamplerInstrumentList *pListView,  
                 qsamplerInstrument *pInstrument,  
                 QListViewItem *pItemAfter = NULL);  
         qsamplerInstrumentItem(qsamplerInstrumentGroup *pGroupItem,  
                 qsamplerInstrument *pInstrument);  
         // Default destructor.  
         virtual ~qsamplerInstrumentItem();  
   
         // To virtually distinguish between list view items.  
         virtual int rtti() const;  
   
         // Payload accessor.  
         qsamplerInstrument *instrument() const;  
   
         // View refreshment.  
         void update();  
   
 private:  
   
         // File item full path.  
         qsamplerInstrument *m_pInstrument;  
 };  
46    
47            // Overridden methods from subclass(es)
48            int rowCount(const QModelIndex& parent) const;
49            int columnCount(const QModelIndex& parent) const;
50    
51  //----------------------------------------------------------------------------          QVariant data(const QModelIndex& index, int role) const;
52  // qsamplerInstrumentList -- MIDI instrument list view.          QVariant headerData(int section, Qt::Orientation orientation,
53  //                  int role = Qt::DisplayRole) const;
54    
55  class qsamplerInstrumentList : public QListView          // Make the following method public
56  {          QAbstractTableModel::reset;
         Q_OBJECT  
57    
58  public:          // Own methods
59            Instrument* addInstrument(int iMap = 0,
60                    int iBank = -1, int iProg = -1);
61            void removeInstrument(const Instrument& instrument);
62    
63          // Constructor.          void resort(const Instrument& instrument);
         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;  
64    
65          // Map selector.          // Map selector.
66          void setMidiMap(int iMidiMap);          void setMidiMap(int iMidiMap);
67          int midiMap() const;          int midiMap() const;
68    
         // List actions accessors.  
         QAction *newGroupAction() const;  
         QAction *newItemAction() const;  
         QAction *editItemAction() const;  
         QAction *renameAction() const;  
         QAction *deleteAction() const;  
         QAction *refreshAction() const;  
   
69  signals:  signals:
70    
71          // Instrument map/session change signal.          // Instrument map/session change signal.
# Line 151  public slots: Line 76  public slots:
76          // General reloader.          // General reloader.
77          void refresh();          void refresh();
78    
79  protected slots:  private:
80    
81            typedef QMap<int, QList<Instrument> > InstrumentsMap;
82    
83            InstrumentsMap m_instruments;
84    
85            // Current map selection.
86            int m_iMidiMap;
87    };
88    
         // 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);  
89    
90  protected:  //-------------------------------------------------------------------------
91    // QSampler::MidiInstrumentsDelegate - table cell renderer for MIDI prog
92    // mappings (doesn't actually do anything ATM, but is already there for
93    // a future cell editor widget implementation)
94    
95          // Find and return the nearest group item...  class MidiInstrumentsDelegate : public QItemDelegate
96          qsamplerInstrumentGroup *groupItem(QListViewItem *pListItem) const;  {
97            Q_OBJECT
98    
99          // Context menu request event handler.  public:
100          void contextMenuEvent(QContextMenuEvent *pContextMenuEvent);          MidiInstrumentsDelegate(QObject *pParent = NULL);
101    
102  private:          QWidget* createEditor(QWidget *pParent,
103                    const QStyleOptionViewItem& option, const QModelIndex& index) const;
104    
105          // List view actions.          void setEditorData(QWidget *pEditor,
106          QAction *m_pNewGroupAction;                  const QModelIndex& index) const;
107          QAction *m_pNewItemAction;          void setModelData(QWidget *pEditor,
108          QAction *m_pEditItemAction;                  QAbstractItemModel* model, const QModelIndex& index) const;
         QAction *m_pRenameAction;  
         QAction *m_pDeleteAction;  
         QAction *m_pRefreshAction;  
109    
110          // Current map selection.          void updateEditorGeometry(QWidget* pEditor,
111          int m_iMidiMap;                  const QStyleOptionViewItem& option, const QModelIndex& index) const;
112  };  };
113    
114    } // namespace QSampler
115    
116  #endif  // __qsamplerInstrumentList_h  #endif  // __qsamplerInstrumentList_h
117    
118    
119  // end of qsamplerInstrumentList.h  // end of qsamplerInstrumentList.h

Legend:
Removed from v.1013  
changed lines
  Added in v.1558

  ViewVC Help
Powered by ViewVC