2001-08-29 02:08:04 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file lengthcombo.C
|
2002-09-24 13:57:09 +00:00
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
2001-08-29 02:08:04 +00:00
|
|
|
|
*
|
|
|
|
|
* \author John Levon
|
2003-09-07 01:45:40 +00:00
|
|
|
|
* \author Herbert Vo<EFBFBD>
|
2002-09-24 13:57:09 +00:00
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* Full author contact details are available in file CREDITS.
|
2001-08-29 02:08:04 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <config.h>
|
2002-09-24 13:57:09 +00:00
|
|
|
|
|
2001-08-29 02:08:04 +00:00
|
|
|
|
#include "lengthcombo.h"
|
|
|
|
|
|
2002-11-17 11:24:08 +00:00
|
|
|
|
#include "lengthcommon.h"
|
|
|
|
|
|
2002-10-20 01:48:28 +00:00
|
|
|
|
|
2001-08-29 02:08:04 +00:00
|
|
|
|
LengthCombo::LengthCombo(QWidget * parent, char * name)
|
|
|
|
|
: QComboBox(parent, name)
|
|
|
|
|
{
|
2004-11-22 12:22:19 +00:00
|
|
|
|
for (int i = 0; i < num_units; i++)
|
2002-11-17 11:24:08 +00:00
|
|
|
|
insertItem(unit_name_gui[i]);
|
2001-08-29 02:08:04 +00:00
|
|
|
|
|
|
|
|
|
connect(this, SIGNAL(activated(int)),
|
|
|
|
|
this, SLOT(has_activated(int)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LyXLength::UNIT LengthCombo::currentLengthItem() const
|
2002-03-21 21:21:28 +00:00
|
|
|
|
{
|
2002-11-17 11:24:08 +00:00
|
|
|
|
return static_cast<LyXLength::UNIT>(currentItem());
|
2002-03-21 21:21:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-08-29 02:08:04 +00:00
|
|
|
|
|
|
|
|
|
void LengthCombo::has_activated(int)
|
|
|
|
|
{
|
|
|
|
|
emit selectionChanged(currentLengthItem());
|
|
|
|
|
}
|
|
|
|
|
|
2002-03-21 21:21:28 +00:00
|
|
|
|
|
2001-08-29 02:08:04 +00:00
|
|
|
|
void LengthCombo::setCurrentItem(LyXLength::UNIT unit)
|
|
|
|
|
{
|
2002-11-17 11:24:08 +00:00
|
|
|
|
QComboBox::setCurrentItem(int(unit));
|
2001-08-29 02:08:04 +00:00
|
|
|
|
}
|
2002-11-17 11:24:08 +00:00
|
|
|
|
|
|
|
|
|
|
2003-12-05 16:22:36 +00:00
|
|
|
|
void LengthCombo::setCurrentItem(int item)
|
|
|
|
|
{
|
|
|
|
|
QComboBox::setCurrentItem(item);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-11-17 11:24:08 +00:00
|
|
|
|
void LengthCombo::setEnabled(bool b)
|
|
|
|
|
{
|
|
|
|
|
QComboBox::setEnabled(b);
|
|
|
|
|
}
|
2003-12-01 07:54:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void LengthCombo::noPercents()
|
|
|
|
|
{
|
|
|
|
|
int num = QComboBox::count();
|
|
|
|
|
for (int i = 0; i < num; i++) {
|
2004-02-01 12:46:14 +00:00
|
|
|
|
if (QComboBox::text(i).contains('%') > 0) {
|
2003-12-01 07:54:02 +00:00
|
|
|
|
QComboBox::removeItem(i);
|
|
|
|
|
i -= 1;
|
|
|
|
|
num -= 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|