]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/LengthCombo.cpp
Complete the removal of the embedding stuff. Maybe. It's hard to be sure we got every...
[lyx.git] / src / frontends / qt4 / LengthCombo.cpp
1 /**
2  * \file LengthCombo.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author John Levon
7  * \author Herbert Voß
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #include <config.h>
13
14 #include "LengthCombo.h"
15
16 #include "qt_helpers.h"
17
18
19 LengthCombo::LengthCombo(QWidget * parent)
20         : QComboBox(parent)
21 {
22         for (int i = 0; i < lyx::num_units; i++)
23                 addItem(lyx::qt_(lyx::unit_name_gui[i]));
24
25         connect(this, SIGNAL(activated(int)),
26                 this, SLOT(has_activated(int)));
27 }
28
29
30 lyx::Length::UNIT LengthCombo::currentLengthItem() const
31 {
32         return static_cast<lyx::Length::UNIT>(currentIndex());
33 }
34
35
36 void LengthCombo::has_activated(int)
37 {
38   // emit signal
39         selectionChanged(currentLengthItem());
40 }
41
42
43 void LengthCombo::setCurrentItem(lyx::Length::UNIT unit)
44 {
45         QComboBox::setCurrentIndex(int(unit));
46 }
47
48
49 void LengthCombo::setCurrentItem(int item)
50 {
51         QComboBox::setCurrentIndex(item);
52 }
53
54
55 void LengthCombo::setEnabled(bool b)
56 {
57         QComboBox::setEnabled(b);
58 }
59
60
61 void LengthCombo::noPercents()
62 {
63         int num = QComboBox::count();
64         for (int i = 0; i < num; i++) {
65                 if (QComboBox::itemText(i).contains('%') > 0) {
66                         QComboBox::removeItem(i);
67                         --i;
68                         --num;
69                 }
70         }
71 }
72
73 #include "LengthCombo_moc.cpp"