Chris@1196: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ Chris@1196: Chris@1196: /* Chris@1196: Sonic Visualiser Chris@1196: An audio file viewer and annotation editor. Chris@1196: Centre for Digital Music, Queen Mary, University of London. Chris@1196: This file copyright 2007-2016 QMUL. Chris@1196: Chris@1196: This program is free software; you can redistribute it and/or Chris@1196: modify it under the terms of the GNU General Public License as Chris@1196: published by the Free Software Foundation; either version 2 of the Chris@1196: License, or (at your option) any later version. See the file Chris@1196: COPYING included with this distribution for more information. Chris@1196: */ Chris@1196: Chris@1198: #include "ColourMapComboBox.h" Chris@1196: Chris@1198: #include "layer/ColourMapper.h" Chris@1196: Chris@1196: #include "base/Debug.h" Chris@1196: Chris@1196: #include Chris@1196: Chris@1196: #include Chris@1196: Chris@1196: using namespace std; Chris@1196: Chris@1198: ColourMapComboBox::ColourMapComboBox(QWidget *parent) : Chris@1198: NotifyingComboBox(parent) Chris@1196: { Chris@1196: setEditable(false); Chris@1196: rebuild(); Chris@1196: Chris@1196: connect(this, SIGNAL(activated(int)), this, SLOT(comboActivated(int))); Chris@1196: Chris@1196: if (count() < 20 && count() > maxVisibleItems()) { Chris@1196: setMaxVisibleItems(count()); Chris@1196: } Chris@1196: } Chris@1196: Chris@1196: void Chris@1198: ColourMapComboBox::comboActivated(int index) Chris@1196: { Chris@1198: emit colourMapChanged(index); Chris@1196: } Chris@1196: Chris@1196: void Chris@1198: ColourMapComboBox::rebuild() Chris@1196: { Chris@1196: blockSignals(true); Chris@1196: Chris@1196: int ix = currentIndex(); Chris@1196: Chris@1196: clear(); Chris@1196: Chris@1196: int size = (QFontMetrics(QFont()).height() * 2) / 3; Chris@1196: if (size < 12) size = 12; Chris@1196: Chris@1198: for (int i = 0; i < ColourMapper::getColourMapCount(); ++i) { Chris@1198: QString name = ColourMapper::getColourMapName(i); Chris@1198: // addItem(db->getExamplePixmap(i, QSize(size, size)), name); Chris@1198: addItem(name); Chris@1196: } Chris@1196: Chris@1196: setCurrentIndex(ix); Chris@1196: Chris@1196: blockSignals(false); Chris@1196: } Chris@1196: