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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1464 - (show annotations) (download) (as text)
Thu Nov 1 17:14:21 2007 UTC (16 years, 5 months ago) by capela
File MIME type: text/x-c++hdr
File size: 6939 byte(s)
- Qt4 migration: missing copyright headers update.

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

  ViewVC Help
Powered by ViewVC