]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/lengthcombo.C
enable Font cache only for MacOSX and inline width() for other platform.
[lyx.git] / src / frontends / qt4 / lengthcombo.C
1 /**
2  * \file lengthcombo.C
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 "lengthcommon.h"
17
18
19 LengthCombo::LengthCombo(QWidget * parent)
20         : QComboBox(parent)
21 {
22         for (int i = 0; i < num_units; i++)
23                 addItem(unit_name_gui[i]);
24
25         connect(this, SIGNAL(activated(int)),
26                 this, SLOT(has_activated(int)));
27 }
28
29 LyXLength::UNIT LengthCombo::currentLengthItem() const
30 {
31         return static_cast<LyXLength::UNIT>(currentIndex());
32 }
33
34
35 void LengthCombo::has_activated(int)
36 {
37         // emit signal
38         selectionChanged(currentLengthItem());
39 }
40
41
42 void LengthCombo::setCurrentItem(LyXLength::UNIT unit)
43 {
44         QComboBox::setCurrentIndex(int(unit));
45 }
46
47
48 void LengthCombo::setCurrentItem(int item)
49 {
50         QComboBox::setCurrentIndex(item);
51 }
52
53
54 void LengthCombo::setEnabled(bool b)
55 {
56         QComboBox::setEnabled(b);
57 }
58
59
60 void LengthCombo::noPercents()
61 {
62         int num = QComboBox::count();
63         for (int i = 0; i < num; i++) {
64                 if (QComboBox::itemText(i).contains('%') > 0) {
65                         QComboBox::removeItem(i);
66                         i -= 1;
67                         num -= 1;
68                 }
69         }
70 }
71
72 #include "lengthcombo_moc.cpp"