File indexing completed on 2022-11-29 18:12:00

0001 /*
0002     SPDX-FileCopyrightText: 2011 Rebetez Etienne <etienne.rebetez@oberwallis.ch>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #include "kalziumunitcombobox.h"
0008 
0009 #include "kalziumutils.h"
0010 
0011 KalziumUnitCombobox::KalziumUnitCombobox(QWidget *parent)
0012     : QComboBox(parent)
0013 {
0014 }
0015 
0016 KalziumUnitCombobox::KalziumUnitCombobox(const QList<int> &unitList, QWidget *parent)
0017     : QComboBox(parent)
0018 {
0019     setUnitList(unitList);
0020 }
0021 
0022 void KalziumUnitCombobox::setUnitList(const QList<int> &unitList)
0023 {
0024     KalziumUtils::populateUnitCombobox(this, unitList);
0025 }
0026 
0027 int KalziumUnitCombobox::getCurrentUnitId() const
0028 {
0029     return itemData(currentIndex()).toInt();
0030 }
0031 
0032 void KalziumUnitCombobox::setIndexWithUnitId(int unit)
0033 {
0034     setCurrentIndex(findData(unit));
0035 }