]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/lengthcombo.C
better selection and scrolling behaviour
[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 Voss
8  *
9  * Full author contact details are available in file CREDITS
10  */
11
12 #include <config.h>
13
14 #ifdef __GNUG__
15 #pragma implementation
16 #endif
17
18 #include "lengthcombo.h"
19 #include <qwhatsthis.h>
20
21 #include "lengthcommon.h"
22 #include "gettext.h"
23
24
25 LengthCombo::LengthCombo(QWidget * parent, char * name)
26         : QComboBox(parent, name)
27 {
28         for (int i=0; i < num_units; i++)
29                 insertItem(unit_name_gui[i]);
30
31         connect(this, SIGNAL(activated(int)),
32                 this, SLOT(has_activated(int)));
33
34         QWhatsThis::add(this, _("Choose one of the units or relative lengths"));
35 }
36
37
38 LyXLength::UNIT LengthCombo::currentLengthItem() const
39 {
40         return static_cast<LyXLength::UNIT>(currentItem());
41 }
42
43
44 void LengthCombo::has_activated(int)
45 {
46         emit selectionChanged(currentLengthItem());
47 }
48
49
50 void LengthCombo::setCurrentItem(LyXLength::UNIT unit)
51 {
52         QComboBox::setCurrentItem(int(unit));
53 }
54
55
56 void LengthCombo::setEnabled(bool b)
57 {
58         QComboBox::setEnabled(b);
59 }