3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
9 * Full author contact details are available in file CREDITS.
15 #include "lengthcombo.h"
17 #include "lengthcommon.h"
20 LengthCombo::LengthCombo(QWidget * parent, char * name)
21 : QComboBox(parent, name)
23 for (int i=0; i < num_units; i++)
24 insertItem(unit_name_gui[i]);
26 connect(this, SIGNAL(activated(int)),
27 this, SLOT(has_activated(int)));
31 LyXLength::UNIT LengthCombo::currentLengthItem() const
33 return static_cast<LyXLength::UNIT>(currentItem());
37 void LengthCombo::has_activated(int)
39 emit selectionChanged(currentLengthItem());
43 void LengthCombo::setCurrentItem(LyXLength::UNIT unit)
45 QComboBox::setCurrentItem(int(unit));
49 void LengthCombo::setCurrentItem(int item)
51 QComboBox::setCurrentItem(item);
55 void LengthCombo::setEnabled(bool b)
57 QComboBox::setEnabled(b);
61 void LengthCombo::noPercents()
63 int num = QComboBox::count();
64 for (int i = 0; i < num; i++) {
65 if (QComboBox::text(i).contains("%") > 0) {
66 QComboBox::removeItem(i);