1 |
// qsamplerInstrumentList.h |
// qsamplerInstrumentList.h |
2 |
// |
// |
3 |
/**************************************************************************** |
/**************************************************************************** |
4 |
Copyright (C) 2003-2007, rncbc aka Rui Nuno Capela. All rights reserved. |
Copyright (C) 2003-2015, 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 |
23 |
#ifndef __qsamplerInstrumentList_h |
#ifndef __qsamplerInstrumentList_h |
24 |
#define __qsamplerInstrumentList_h |
#define __qsamplerInstrumentList_h |
25 |
|
|
26 |
#include <qlistview.h> |
#include <QTreeView> |
|
#include <qheader.h> |
|
27 |
|
|
28 |
#include <lscp/client.h> |
namespace QSampler { |
29 |
|
|
30 |
|
class Instrument; |
31 |
|
|
32 |
// Forward declarations. |
//------------------------------------------------------------------------- |
33 |
class qsamplerInstrument; |
// QSampler:InstrumentListModel - data model for MIDI prog mappings |
|
class qsamplerInstrumentList; |
|
|
|
|
|
class QAction; |
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------- |
|
|
// class qsamplerInstrumentGroup -- custom group list view item. |
|
34 |
// |
// |
35 |
|
|
36 |
class qsamplerInstrumentGroup : public QListViewItem |
class InstrumentListModel : public QAbstractItemModel |
37 |
{ |
{ |
38 |
|
Q_OBJECT |
39 |
|
|
40 |
public: |
public: |
41 |
|
|
42 |
// Constructors. |
// Constructor. |
43 |
qsamplerInstrumentGroup(qsamplerInstrumentList *pListView, |
InstrumentListModel(QObject *pParent = NULL); |
|
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; |
|
44 |
|
|
45 |
qsamplerInstrumentList *listView() const; |
// Destructor. |
46 |
qsamplerInstrumentGroup *groupItem() const; |
~InstrumentListModel(); |
47 |
|
|
48 |
// To show up whether its open or not. |
// Overridden methods from subclass(es) |
49 |
virtual void setOpen(bool bOpen); |
int rowCount(const QModelIndex& parent) const; |
50 |
|
int columnCount(const QModelIndex& parent) const; |
51 |
|
|
52 |
|
QVariant data(const QModelIndex& index, int role) const; |
53 |
|
QVariant headerData(int section, Qt::Orientation orientation, |
54 |
|
int role = Qt::DisplayRole) const; |
55 |
|
|
56 |
// To virtually distinguish between list view items. |
// Map selector. |
57 |
virtual int rtti() const; |
void setMidiMap(int iMidiMap); |
58 |
}; |
int midiMap() const; |
59 |
|
|
60 |
|
// Own methods |
61 |
|
const Instrument *addInstrument(int iMap, int iBank, int iProg); |
62 |
|
void removeInstrument(Instrument *pInstrument); |
63 |
|
void updateInstrument(Instrument *pInstrument); |
64 |
|
void resortInstrument(Instrument *pInstrument); |
65 |
|
|
66 |
//---------------------------------------------------------------------- |
// General reloader. |
67 |
// class qsamplerInstrumentItem -- custom file list view item. |
void refresh(); |
|
// |
|
|
|
|
|
class qsamplerInstrumentItem : public qsamplerInstrumentGroup |
|
|
{ |
|
|
public: |
|
68 |
|
|
69 |
// Constructors. |
// Make the following method public |
70 |
qsamplerInstrumentItem(qsamplerInstrumentList *pListView, |
void beginReset(); |
71 |
qsamplerInstrument *pInstrument, |
void endReset(); |
|
QListViewItem *pItemAfter = NULL); |
|
|
qsamplerInstrumentItem(qsamplerInstrumentGroup *pGroupItem, |
|
|
qsamplerInstrument *pInstrument); |
|
|
// Default destructor. |
|
|
virtual ~qsamplerInstrumentItem(); |
|
72 |
|
|
73 |
// To virtually distinguish between list view items. |
// Map clear. |
74 |
virtual int rtti() const; |
void clear(); |
75 |
|
|
76 |
// Payload accessor. |
protected: |
|
qsamplerInstrument *instrument() const; |
|
77 |
|
|
78 |
// View refreshment. |
QModelIndex index(int row, int col, const QModelIndex& parent) const; |
79 |
void update(); |
QModelIndex parent(const QModelIndex& child) const; |
80 |
|
|
81 |
private: |
private: |
82 |
|
|
83 |
// File item full path. |
typedef QList<Instrument *> InstrumentList; |
84 |
qsamplerInstrument *m_pInstrument; |
typedef QMap<int, InstrumentList> InstrumentMap; |
85 |
|
|
86 |
|
InstrumentMap m_instruments; |
87 |
|
|
88 |
|
// Current map selection. |
89 |
|
int m_iMidiMap; |
90 |
}; |
}; |
91 |
|
|
92 |
|
|
93 |
//---------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
94 |
// qsamplerInstrumentList -- MIDI instrument list view. |
// QSampler::InstrumentListView - list view for MIDI prog mappings |
95 |
// |
// |
96 |
|
|
97 |
class qsamplerInstrumentList : public QListView |
class InstrumentListView : public QTreeView |
98 |
{ |
{ |
|
Q_OBJECT |
|
|
|
|
99 |
public: |
public: |
100 |
|
|
101 |
// Constructor. |
// Constructor. |
102 |
qsamplerInstrumentList(QWidget *pParent, const char *pszName = NULL); |
InstrumentListView(QWidget *pParent = NULL); |
103 |
// Default destructor. |
|
104 |
~qsamplerInstrumentList(); |
// Destructor. |
105 |
|
~InstrumentListView(); |
|
// 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; |
|
106 |
|
|
107 |
// Map selector. |
// Map selector. |
108 |
void setMidiMap(int iMidiMap); |
void setMidiMap(int iMidiMap); |
109 |
int midiMap() const; |
int midiMap() const; |
110 |
|
|
111 |
// List actions accessors. |
// Own methods |
112 |
QAction *newGroupAction() const; |
const Instrument *addInstrument(int iMap, int iBank, int iProg); |
113 |
QAction *newItemAction() const; |
void removeInstrument(Instrument *pInstrument); |
114 |
QAction *editItemAction() const; |
void updateInstrument(Instrument *pInstrument); |
115 |
QAction *renameAction() const; |
void resortInstrument(Instrument *pInstrument); |
|
QAction *deleteAction() const; |
|
|
QAction *refreshAction() const; |
|
|
|
|
|
signals: |
|
|
|
|
|
// Instrument map/session change signal. |
|
|
void instrumentsChanged(); |
|
|
|
|
|
public slots: |
|
116 |
|
|
117 |
// General reloader. |
// General reloader. |
118 |
void refresh(); |
void refresh(); |
119 |
|
|
|
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); |
|
|
|
|
120 |
private: |
private: |
121 |
|
|
122 |
// List view actions. |
// Instance variables. |
123 |
QAction *m_pNewGroupAction; |
InstrumentListModel *m_pListModel; |
|
QAction *m_pNewItemAction; |
|
|
QAction *m_pEditItemAction; |
|
|
QAction *m_pRenameAction; |
|
|
QAction *m_pDeleteAction; |
|
|
QAction *m_pRefreshAction; |
|
|
|
|
|
// Current map selection. |
|
|
int m_iMidiMap; |
|
124 |
}; |
}; |
125 |
|
|
126 |
|
|
127 |
|
} // namespace QSampler |
128 |
|
|
129 |
#endif // __qsamplerInstrumentList_h |
#endif // __qsamplerInstrumentList_h |
130 |
|
|
131 |
|
|
132 |
// end of qsamplerInstrumentList.h |
// end of qsamplerInstrumentList.h |