]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/lengthcombo.C
Minipage is no more (long live the box inset)
[lyx.git] / src / frontends / qt2 / 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
15 #include "lengthcombo.h"
16
17 #include "lengthcommon.h"
18
19
20 LengthCombo::LengthCombo(QWidget * parent, char * name)
21         : QComboBox(parent, name)
22 {
23         for (int i=0; i < num_units; i++)
24                 insertItem(unit_name_gui[i]);
25
26         connect(this, SIGNAL(activated(int)),
27                 this, SLOT(has_activated(int)));
28 }
29
30
31 LyXLength::UNIT LengthCombo::currentLengthItem() const
32 {
33         return static_cast<LyXLength::UNIT>(currentItem());
34 }
35
36
37 void LengthCombo::has_activated(int)
38 {
39         emit selectionChanged(currentLengthItem());
40 }
41
42
43 void LengthCombo::setCurrentItem(LyXLength::UNIT unit)
44 {
45         QComboBox::setCurrentItem(int(unit));
46 }
47
48
49 void LengthCombo::setCurrentItem(int item)
50 {
51         QComboBox::setCurrentItem(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::text(i).contains("%") > 0) {
66                         QComboBox::removeItem(i);
67                         i -= 1;
68                         num -= 1;
69                 }
70         }
71 }