/[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 1509 by capela, Thu Nov 22 11:10:44 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    
 // Forward declarations.  
 class qsamplerInstrument;  
 class qsamplerInstrumentList;  
33    
34  class QAction;  //-------------------------------------------------------------------------
35    // MidiInstrumentsModel - data model for MIDI prog mappings (used for QTableView)
   
 //----------------------------------------------------------------------  
 // class qsamplerInstrumentGroup -- custom group list view item.  
36  //  //
37    
38  class qsamplerInstrumentGroup : public QListViewItem  class MidiInstrumentsModel : public QAbstractTableModel
39  {  {
40  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.  
 //  
41    
 class qsamplerInstrumentItem : public qsamplerInstrumentGroup  
 {  
42  public:  public:
43    
44          // 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;  
45    
46          // View refreshment.          // Overridden methods from subclass(es)
47          void update();          int rowCount(const QModelIndex& parent) const;
48            int columnCount(const QModelIndex& parent) const;
49    
50  private:          QVariant data(const QModelIndex& index, int role) const;
51            QVariant headerData(int section, Qt::Orientation orientation,
52                    int role = Qt::DisplayRole) const;
53    
54          // File item full path.          // Make the following method public
55          qsamplerInstrument *m_pInstrument;          QAbstractTableModel::reset;
 };  
56    
57            // Own methods
58            qsamplerInstrument* addInstrument(int iMap = 0,
59                    int iBank = -1, int iProg = -1);
60            void removeInstrument(const qsamplerInstrument& instrument);
61    
62  //----------------------------------------------------------------------------          void resort(const qsamplerInstrument instrument);
 // qsamplerInstrumentList -- MIDI instrument list view.  
 //  
   
 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;  
63    
64          // Map selector.          // Map selector.
65          void setMidiMap(int iMidiMap);          void setMidiMap(int iMidiMap);
66          int midiMap() const;          int midiMap() const;
67    
         // List actions accessors.  
         QAction *newGroupAction() const;  
         QAction *newItemAction() const;  
         QAction *editItemAction() const;  
         QAction *renameAction() const;  
         QAction *deleteAction() const;  
         QAction *refreshAction() const;  
   
68  signals:  signals:
69    
70          // Instrument map/session change signal.          // Instrument map/session change signal.
# Line 151  public slots: Line 75  public slots:
75          // General reloader.          // General reloader.
76          void refresh();          void refresh();
77    
78  protected slots:  private:
79    
80          // Add a new group item below the current one.          typedef QMap<int, QList<qsamplerInstrument> > InstrumentsMap;
         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);  
81    
82  protected:          // Current map selection.
83            int m_iMidiMap;
84    
85          // Find and return the nearest group item...          InstrumentsMap m_instruments;
86          qsamplerInstrumentGroup *groupItem(QListViewItem *pListItem) const;  };
87    
         // Context menu request event handler.  
         void contextMenuEvent(QContextMenuEvent *pContextMenuEvent);  
88    
89  private:  //-------------------------------------------------------------------------
90    // MidiInstrumentsDelegate - table cell renderer for MIDI prog mappings
91    // (doesn't actually do anything ATM, but is already there for a future
92    // cell editor widget implementation)
93    
94          // List view actions.  class MidiInstrumentsDelegate : public QItemDelegate
95          QAction *m_pNewGroupAction;  {
96          QAction *m_pNewItemAction;          Q_OBJECT
         QAction *m_pEditItemAction;  
         QAction *m_pRenameAction;  
         QAction *m_pDeleteAction;  
         QAction *m_pRefreshAction;  
97    
98          // Current map selection.  public:
99          int m_iMidiMap;          MidiInstrumentsDelegate(QObject *pParent = NULL);
100    
101            QWidget* createEditor(QWidget *pParent,
102                    const QStyleOptionViewItem& option, const QModelIndex& index) const;
103    
104            void setEditorData(QWidget *pEditor,
105                    const QModelIndex& index) const;
106            void setModelData(QWidget *pEditor,
107                    QAbstractItemModel* model, const QModelIndex& index) const;
108    
109            void updateEditorGeometry(QWidget* pEditor,
110                    const QStyleOptionViewItem& option, const QModelIndex& index) const;
111  };  };
112    
113    
114  #endif  // __qsamplerInstrumentList_h  #endif  // __qsamplerInstrumentList_h
115    
116    
117  // end of qsamplerInstrumentList.h  // end of qsamplerInstrumentList.h

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

  ViewVC Help
Powered by ViewVC