2 * \file LengthCombo.cpp
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"
15 #include "lengthcommon.h"
16 #include "qt_helpers.h"
19 LengthCombo::LengthCombo(QWidget * parent)
22 for (int i = 0; i < lyx::num_units; i++)
23 addItem(lyx::qt_(lyx::unit_name_gui[i]));
25 connect(this, SIGNAL(activated(int)),
26 this, SLOT(has_activated(int)));
30 lyx::LyXLength::UNIT LengthCombo::currentLengthItem() const
32 return static_cast<lyx::LyXLength::UNIT>(currentIndex());
36 void LengthCombo::has_activated(int)
39 selectionChanged(currentLengthItem());
43 void LengthCombo::setCurrentItem(lyx::LyXLength::UNIT unit)
45 QComboBox::setCurrentIndex(int(unit));
49 void LengthCombo::setCurrentItem(int item)
51 QComboBox::setCurrentIndex(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::itemText(i).contains('%') > 0) {
66 QComboBox::removeItem(i);
73 #include "LengthCombo_moc.cpp"