/[svn]/qsampler/trunk/src/qsamplerInstrumentList.h
ViewVC logotype

Annotation of /qsampler/trunk/src/qsamplerInstrumentList.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1461 - (hide annotations) (download) (as text)
Sun Oct 28 23:30:36 2007 UTC (16 years, 6 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 6893 byte(s)
* started to port QSampler to Qt4 (NOTE: this version is yet broken, use
  the latest tarball release 0.1.5 until the Qt4 port is completed)

1 capela 1013 // qsamplerInstrumentList.h
2     //
3     /****************************************************************************
4     Copyright (C) 2003-2007, rncbc aka Rui Nuno Capela. All rights reserved.
5    
6     This program is free software; you can redistribute it and/or
7     modify it under the terms of the GNU General Public License
8     as published by the Free Software Foundation; either version 2
9     of the License, or (at your option) any later version.
10    
11     This program is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14     GNU General Public License for more details.
15    
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
18     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19    
20     *****************************************************************************/
21    
22     #ifndef __qsamplerInstrumentList_h
23     #define __qsamplerInstrumentList_h
24    
25 schoenebeck 1461 #include <QListWidget>
26     #include <QListWidgetItem>
27     //#include <qheader.h>
28     #include <QAbstractTableModel>
29     #include <QItemDelegate>
30 capela 1013
31     #include <lscp/client.h>
32    
33 schoenebeck 1461 #include <string.h>
34 capela 1013
35 schoenebeck 1461 #include "qsamplerInstrument.h"
36    
37 capela 1013 // Forward declarations.
38 schoenebeck 1461 //class qsamplerInstrument;
39     //class qsamplerInstrumentList;
40 capela 1013
41     class QAction;
42    
43    
44     //----------------------------------------------------------------------
45     // class qsamplerInstrumentGroup -- custom group list view item.
46     //
47    
48 schoenebeck 1461 class qsamplerInstrumentGroup : public QListWidgetItem
49 capela 1013 {
50     public:
51    
52     // Constructors.
53 schoenebeck 1461 qsamplerInstrumentGroup(QListWidget *pListView,
54     const QString& sName, QListWidgetItem *pItemAfter = NULL);
55 capela 1013 qsamplerInstrumentGroup(qsamplerInstrumentGroup *pGroupItem,
56     const QString& sName);
57     // Default destructor.
58     virtual ~qsamplerInstrumentGroup();
59    
60     // Instance accessors.
61     void setName(const QString& sName);
62     QString name() const;
63    
64 schoenebeck 1461 QListWidget *listView() const;
65 capela 1013 qsamplerInstrumentGroup *groupItem() const;
66    
67     // To show up whether its open or not.
68     virtual void setOpen(bool bOpen);
69    
70     // To virtually distinguish between list view items.
71     virtual int rtti() const;
72     };
73    
74    
75     //----------------------------------------------------------------------
76     // class qsamplerInstrumentItem -- custom file list view item.
77     //
78    
79     class qsamplerInstrumentItem : public qsamplerInstrumentGroup
80     {
81     public:
82    
83     // Constructors.
84 schoenebeck 1461 qsamplerInstrumentItem(QListWidget *pListView,
85 capela 1013 qsamplerInstrument *pInstrument,
86 schoenebeck 1461 QListWidgetItem *pItemAfter = NULL);
87 capela 1013 qsamplerInstrumentItem(qsamplerInstrumentGroup *pGroupItem,
88     qsamplerInstrument *pInstrument);
89     // Default destructor.
90     virtual ~qsamplerInstrumentItem();
91    
92     // To virtually distinguish between list view items.
93     virtual int rtti() const;
94    
95     // Payload accessor.
96     qsamplerInstrument *instrument() const;
97    
98     // View refreshment.
99     void update();
100    
101     private:
102    
103     // File item full path.
104     qsamplerInstrument *m_pInstrument;
105     };
106    
107    
108     //----------------------------------------------------------------------------
109     // qsamplerInstrumentList -- MIDI instrument list view.
110     //
111    
112 schoenebeck 1461 #if 0
113 capela 1013 class qsamplerInstrumentList : public QListView
114     {
115     Q_OBJECT
116    
117     public:
118    
119     // Constructor.
120     qsamplerInstrumentList(QWidget *pParent, const char *pszName = NULL);
121     // Default destructor.
122     ~qsamplerInstrumentList();
123    
124     // QListViewItem::rtti() return values.
125     enum ItemType { Group = 1001, Item = 1002 };
126    
127     // Add a new group/file item, optionally under a given group.
128     qsamplerInstrumentGroup *addGroup(const QString& sName,
129     qsamplerInstrumentGroup *pParentGroup = NULL);
130     qsamplerInstrumentItem *addItem(
131     qsamplerInstrument *pInstrument,
132     qsamplerInstrumentGroup *pParentGroup = NULL);
133    
134     // Find a group/file item, given its name.
135     qsamplerInstrumentGroup *findGroup(const QString& sName) const;
136     qsamplerInstrumentItem *findItem(
137     qsamplerInstrument *pInstrument) const;
138    
139     // Map selector.
140     void setMidiMap(int iMidiMap);
141     int midiMap() const;
142    
143     // List actions accessors.
144     QAction *newGroupAction() const;
145     QAction *newItemAction() const;
146     QAction *editItemAction() const;
147     QAction *renameAction() const;
148     QAction *deleteAction() const;
149     QAction *refreshAction() const;
150    
151     signals:
152    
153     // Instrument map/session change signal.
154     void instrumentsChanged();
155    
156     public slots:
157    
158     // General reloader.
159     void refresh();
160    
161     protected slots:
162    
163     // Add a new group item below the current one.
164     void newGroupSlot();
165     // Add a instrument item below the current one.
166     void newItemSlot();
167     // Change current instrument item.
168     void editItemSlot();
169     // Rename current group/item.
170     void renameSlot();
171     // Remove current group/item.
172     void deleteSlot();
173    
174     // In-place selection slot.
175     void selectionChangedSlot();
176    
177     // In-place activation slot.
178 schoenebeck 1461 void activatedSlot(QListWidgetItem *pListItem);
179 capela 1013
180     // In-place aliasing slot.
181 schoenebeck 1461 void renamedSlot(QListWidgetItem *pItem);
182 capela 1013
183     protected:
184    
185     // Find and return the nearest group item...
186 schoenebeck 1461 qsamplerInstrumentGroup *groupItem(QListWidgetItem *pListItem) const;
187 capela 1013
188     // Context menu request event handler.
189     void contextMenuEvent(QContextMenuEvent *pContextMenuEvent);
190    
191     private:
192    
193     // List view actions.
194     QAction *m_pNewGroupAction;
195     QAction *m_pNewItemAction;
196     QAction *m_pEditItemAction;
197     QAction *m_pRenameAction;
198     QAction *m_pDeleteAction;
199     QAction *m_pRefreshAction;
200    
201     // Current map selection.
202     int m_iMidiMap;
203     };
204 schoenebeck 1461 #endif
205 capela 1013
206 schoenebeck 1461 class MidiInstrumentsModel : public QAbstractTableModel {
207     Q_OBJECT
208     public:
209     MidiInstrumentsModel(QObject* parent = 0);
210 capela 1013
211 schoenebeck 1461 // overridden methods from subclass(es)
212     int rowCount(const QModelIndex &parent) const;
213     int columnCount(const QModelIndex &parent) const;
214     QVariant data(const QModelIndex &index, int role) const;
215     QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
216    
217     qsamplerInstrument* addInstrument(int iMap = 0, int iBank = -1, int iProg = -1);
218    
219     // Map selector.
220     void setMidiMap(int iMidiMap);
221     int midiMap() const;
222    
223     signals:
224     // Instrument map/session change signal.
225     void instrumentsChanged();
226    
227     public slots:
228     // General reloader.
229     void refresh();
230    
231     private:
232     typedef QMap<int, QList<qsamplerInstrument> > InstrumentsMap;
233    
234     // Current map selection.
235     int m_iMidiMap;
236    
237     InstrumentsMap instruments;
238     };
239    
240     class MidiInstrumentsDelegate : public QItemDelegate {
241     Q_OBJECT
242     public:
243     MidiInstrumentsDelegate(QObject* parent = 0);
244    
245     QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option,
246     const QModelIndex& index) const;
247    
248     void setEditorData(QWidget* editor, const QModelIndex& index) const;
249     void setModelData(QWidget* editor, QAbstractItemModel* model,
250     const QModelIndex& index) const;
251    
252     void updateEditorGeometry(QWidget* editor,
253     const QStyleOptionViewItem& option, const QModelIndex& index) const;
254     };
255    
256    
257 capela 1013 #endif // __qsamplerInstrumentList_h
258    
259     // end of qsamplerInstrumentList.h

  ViewVC Help
Powered by ViewVC