| 52 | } |
| 53 | |
| 54 | void ccColorScaleSelector::init() |
| 55 | { |
| 56 | //fill combox box |
| 57 | if (m_comboBox) |
| 58 | { |
| 59 | m_comboBox->disconnect(this); |
| 60 | |
| 61 | m_comboBox->clear(); |
| 62 | //add all available color scales |
| 63 | assert(m_manager); |
| 64 | |
| 65 | //sort the scales by their name |
| 66 | //DGM: See doc about qSort --> "An alternative to using qSort() is to put the items to sort in a QMap, using the sort key as the QMap key." |
| 67 | QMap<QString, QString> scales; |
| 68 | for (ccColorScalesManager::ScalesMap::const_iterator it = m_manager->map().constBegin(); it != m_manager->map().constEnd(); ++it) |
| 69 | { |
| 70 | scales.insert((*it)->getName(), (*it)->getUuid()); |
| 71 | } |
| 72 | |
| 73 | for (QMap<QString, QString>::const_iterator scale = scales.constBegin(); scale != scales.constEnd(); ++scale) |
| 74 | { |
| 75 | m_comboBox->addItem(scale.key(), scale.value()); |
| 76 | } |
| 77 | |
| 78 | connect(m_comboBox, qOverload<int>(&QComboBox::activated), this, &ccColorScaleSelector::colorScaleSelected); |
| 79 | } |
| 80 | //advanced tool button |
| 81 | if (m_button) |
| 82 | { |
| 83 | m_button->disconnect(this); |
| 84 | connect(m_button, &QAbstractButton::clicked, this, &ccColorScaleSelector::colorScaleEditorSummoned); |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | ccColorScale::Shared ccColorScaleSelector::getSelectedScale() const |
| 89 | { |