Chris@1196
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
Chris@1196
|
2
|
Chris@1196
|
3 /*
|
Chris@1196
|
4 Sonic Visualiser
|
Chris@1196
|
5 An audio file viewer and annotation editor.
|
Chris@1196
|
6 Centre for Digital Music, Queen Mary, University of London.
|
Chris@1196
|
7 This file copyright 2007-2016 QMUL.
|
Chris@1196
|
8
|
Chris@1196
|
9 This program is free software; you can redistribute it and/or
|
Chris@1196
|
10 modify it under the terms of the GNU General Public License as
|
Chris@1196
|
11 published by the Free Software Foundation; either version 2 of the
|
Chris@1196
|
12 License, or (at your option) any later version. See the file
|
Chris@1196
|
13 COPYING included with this distribution for more information.
|
Chris@1196
|
14 */
|
Chris@1196
|
15
|
Chris@1198
|
16 #include "ColourMapComboBox.h"
|
Chris@1196
|
17
|
Chris@1198
|
18 #include "layer/ColourMapper.h"
|
Chris@1196
|
19
|
Chris@1196
|
20 #include "base/Debug.h"
|
Chris@1196
|
21
|
Chris@1196
|
22 #include <QFontMetrics>
|
Chris@1196
|
23
|
Chris@1196
|
24 #include <iostream>
|
Chris@1196
|
25
|
Chris@1196
|
26 using namespace std;
|
Chris@1196
|
27
|
Chris@1198
|
28 ColourMapComboBox::ColourMapComboBox(QWidget *parent) :
|
Chris@1198
|
29 NotifyingComboBox(parent)
|
Chris@1196
|
30 {
|
Chris@1196
|
31 setEditable(false);
|
Chris@1196
|
32 rebuild();
|
Chris@1196
|
33
|
Chris@1196
|
34 connect(this, SIGNAL(activated(int)), this, SLOT(comboActivated(int)));
|
Chris@1196
|
35
|
Chris@1196
|
36 if (count() < 20 && count() > maxVisibleItems()) {
|
Chris@1196
|
37 setMaxVisibleItems(count());
|
Chris@1196
|
38 }
|
Chris@1196
|
39 }
|
Chris@1196
|
40
|
Chris@1196
|
41 void
|
Chris@1198
|
42 ColourMapComboBox::comboActivated(int index)
|
Chris@1196
|
43 {
|
Chris@1198
|
44 emit colourMapChanged(index);
|
Chris@1196
|
45 }
|
Chris@1196
|
46
|
Chris@1196
|
47 void
|
Chris@1198
|
48 ColourMapComboBox::rebuild()
|
Chris@1196
|
49 {
|
Chris@1196
|
50 blockSignals(true);
|
Chris@1196
|
51
|
Chris@1196
|
52 int ix = currentIndex();
|
Chris@1196
|
53
|
Chris@1196
|
54 clear();
|
Chris@1196
|
55
|
Chris@1196
|
56 int size = (QFontMetrics(QFont()).height() * 2) / 3;
|
Chris@1196
|
57 if (size < 12) size = 12;
|
Chris@1196
|
58
|
Chris@1198
|
59 for (int i = 0; i < ColourMapper::getColourMapCount(); ++i) {
|
Chris@1198
|
60 QString name = ColourMapper::getColourMapName(i);
|
Chris@1198
|
61 // addItem(db->getExamplePixmap(i, QSize(size, size)), name);
|
Chris@1198
|
62 addItem(name);
|
Chris@1196
|
63 }
|
Chris@1196
|
64
|
Chris@1196
|
65 setCurrentIndex(ix);
|
Chris@1196
|
66
|
Chris@1196
|
67 blockSignals(false);
|
Chris@1196
|
68 }
|
Chris@1196
|
69
|