~ubuntu-branches/ubuntu/karmic/qsampler/karmic

« back to all changes in this revision

Viewing changes to src/qsamplerInstrumentList.h

  • Committer: Bazaar Package Importer
  • Author(s): Free Ekanayaka
  • Date: 2008-08-28 08:43:21 UTC
  • mfrom: (1.1.1 upstream) (2.1.2 hardy)
  • Revision ID: james.westby@ubuntu.com-20080828084321-guq8v04yg31co9gm
Tags: 0.2.1-1
* New upstream release
* Uploaded to Debian (Closes: #280576)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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 <QItemDelegate>
 
28
 
 
29
#include <lscp/client.h>
 
30
 
 
31
#include "qsamplerInstrument.h"
 
32
 
 
33
namespace QSampler {
 
34
 
 
35
//-------------------------------------------------------------------------
 
36
// QSampler::MidiInstrumentsModel - data model for MIDI prog mappings
 
37
//                                  (used for QTableView)
 
38
 
 
39
class MidiInstrumentsModel : public QAbstractTableModel
 
40
{
 
41
        Q_OBJECT
 
42
 
 
43
public:
 
44
 
 
45
        MidiInstrumentsModel(QObject* pParent = NULL);
 
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
        QVariant headerData(int section, Qt::Orientation orientation,
 
53
                int role = Qt::DisplayRole) const;
 
54
 
 
55
        // Make the following method public
 
56
        QAbstractTableModel::reset;
 
57
 
 
58
        // Own methods
 
59
        Instrument* addInstrument(int iMap = 0,
 
60
                int iBank = -1, int iProg = -1);
 
61
        void removeInstrument(const Instrument& instrument);
 
62
 
 
63
        void resort(const Instrument& instrument);
 
64
 
 
65
        // Map selector.
 
66
        void setMidiMap(int iMidiMap);
 
67
        int midiMap() const;
 
68
 
 
69
signals:
 
70
 
 
71
        // Instrument map/session change signal.
 
72
        void instrumentsChanged();
 
73
 
 
74
public slots:
 
75
 
 
76
        // General reloader.
 
77
        void refresh();
 
78
 
 
79
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
 
 
89
 
 
90
//-------------------------------------------------------------------------
 
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
class MidiInstrumentsDelegate : public QItemDelegate
 
96
{
 
97
        Q_OBJECT
 
98
 
 
99
public:
 
100
        MidiInstrumentsDelegate(QObject *pParent = NULL);
 
101
 
 
102
        QWidget* createEditor(QWidget *pParent,
 
103
                const QStyleOptionViewItem& option, const QModelIndex& index) const;
 
104
 
 
105
        void setEditorData(QWidget *pEditor,
 
106
                const QModelIndex& index) const;
 
107
        void setModelData(QWidget *pEditor,
 
108
                QAbstractItemModel* model, const QModelIndex& index) const;
 
109
 
 
110
        void updateEditorGeometry(QWidget* pEditor,
 
111
                const QStyleOptionViewItem& option, const QModelIndex& index) const;
 
112
};
 
113
 
 
114
} // namespace QSampler
 
115
 
 
116
#endif  // __qsamplerInstrumentList_h
 
117
 
 
118
 
 
119
// end of qsamplerInstrumentList.h