]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/lengthcombo.C
This new citation dialog follows a new design similar to lyx-1.3:
[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, char * name)
20         : QComboBox(parent, name)
21 {
22         for (int i = 0; i < num_units; i++)
23                 insertItem(unit_name_gui[i]);
24
25         connect(this, SIGNAL(activated(int)),
26                 this, SLOT(has_activated(int)));
27 }
28
29 LengthCombo::LengthCombo(QWidget * parent)
30         : QComboBox(parent)
31 {
32         for (int i = 0; i < num_units; i++)
33                 insertItem(unit_name_gui[i]);
34
35         connect(this, SIGNAL(activated(int)),
36                 this, SLOT(has_activated(int)));
37 }
38
39 LyXLength::UNIT LengthCombo::currentLengthItem() const
40 {
41         return static_cast<LyXLength::UNIT>(currentItem());
42 }
43
44
45 void LengthCombo::has_activated(int)
46 {
47         emit selectionChanged(currentLengthItem());
48 }
49
50
51 void LengthCombo::setCurrentItem(LyXLength::UNIT unit)
52 {
53         QComboBox::setCurrentItem(int(unit));
54 }
55
56
57 void LengthCombo::setCurrentItem(int item)
58 {
59         QComboBox::setCurrentItem(item);
60 }
61
62
63 void LengthCombo::setEnabled(bool b)
64 {
65         QComboBox::setEnabled(b);
66 }
67
68
69 void LengthCombo::noPercents()
70 {
71         int num = QComboBox::count();
72         for (int i = 0; i < num; i++) {
73                 if (QComboBox::text(i).contains('%') > 0) {
74                         QComboBox::removeItem(i);
75                         i -= 1;
76                         num -= 1;
77                 }
78         }
79 }