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.
14 #include "lengthcombo.h"
16 #include "lengthcommon.h"
19 LengthCombo::LengthCombo(QWidget * parent, char * name)
20 : QComboBox(parent, name)
22 for (int i = 0; i < num_units; i++)
23 insertItem(unit_name_gui[i]);
25 connect(this, SIGNAL(activated(int)),
26 this, SLOT(has_activated(int)));
29 LengthCombo::LengthCombo(QWidget * parent)
32 for (int i = 0; i < num_units; i++)
33 insertItem(unit_name_gui[i]);
35 connect(this, SIGNAL(activated(int)),
36 this, SLOT(has_activated(int)));
39 LyXLength::UNIT LengthCombo::currentLengthItem() const
41 return static_cast<LyXLength::UNIT>(currentItem());
45 void LengthCombo::has_activated(int)
47 emit selectionChanged(currentLengthItem());
51 void LengthCombo::setCurrentItem(LyXLength::UNIT unit)
53 QComboBox::setCurrentItem(int(unit));
57 void LengthCombo::setCurrentItem(int item)
59 QComboBox::setCurrentItem(item);
63 void LengthCombo::setEnabled(bool b)
65 QComboBox::setEnabled(b);
69 void LengthCombo::noPercents()
71 int num = QComboBox::count();
72 for (int i = 0; i < num; i++) {
73 if (QComboBox::text(i).contains('%') > 0) {
74 QComboBox::removeItem(i);