2006-03-05 17:24:44 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file lengthcombo.C
|
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
|
*
|
|
|
|
|
* \author John Levon
|
|
|
|
|
* \author Herbert Vo<EFBFBD>
|
|
|
|
|
*
|
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
|
|
#include "lengthcombo.h"
|
|
|
|
|
|
|
|
|
|
#include "lengthcommon.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LengthCombo::LengthCombo(QWidget * parent)
|
|
|
|
|
: QComboBox(parent)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < num_units; i++)
|
2006-08-17 08:49:57 +00:00
|
|
|
|
addItem(unit_name_gui[i]);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
|
|
connect(this, SIGNAL(activated(int)),
|
|
|
|
|
this, SLOT(has_activated(int)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LyXLength::UNIT LengthCombo::currentLengthItem() const
|
|
|
|
|
{
|
2006-08-17 08:49:57 +00:00
|
|
|
|
return static_cast<LyXLength::UNIT>(currentIndex());
|
2006-03-05 17:24:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void LengthCombo::has_activated(int)
|
|
|
|
|
{
|
2006-06-30 14:11:50 +00:00
|
|
|
|
// emit signal
|
|
|
|
|
selectionChanged(currentLengthItem());
|
2006-03-05 17:24:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void LengthCombo::setCurrentItem(LyXLength::UNIT unit)
|
|
|
|
|
{
|
2006-08-17 08:49:57 +00:00
|
|
|
|
QComboBox::setCurrentIndex(int(unit));
|
2006-03-05 17:24:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void LengthCombo::setCurrentItem(int item)
|
|
|
|
|
{
|
2006-08-17 08:49:57 +00:00
|
|
|
|
QComboBox::setCurrentIndex(item);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void LengthCombo::setEnabled(bool b)
|
|
|
|
|
{
|
|
|
|
|
QComboBox::setEnabled(b);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void LengthCombo::noPercents()
|
|
|
|
|
{
|
|
|
|
|
int num = QComboBox::count();
|
|
|
|
|
for (int i = 0; i < num; i++) {
|
2006-08-17 08:49:57 +00:00
|
|
|
|
if (QComboBox::itemText(i).contains('%') > 0) {
|
2006-03-05 17:24:44 +00:00
|
|
|
|
QComboBox::removeItem(i);
|
|
|
|
|
i -= 1;
|
|
|
|
|
num -= 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2006-05-18 08:51:12 +00:00
|
|
|
|
|
|
|
|
|
#include "lengthcombo_moc.cpp"
|