2006-03-05 17:24:44 +00:00
|
|
|
|
/**
|
2007-04-26 03:53:02 +00:00
|
|
|
|
* \file LengthCombo.cpp
|
2006-03-05 17:24:44 +00:00
|
|
|
|
* 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>
|
|
|
|
|
|
2007-04-26 03:53:02 +00:00
|
|
|
|
#include "LengthCombo.h"
|
2006-03-05 17:24:44 +00:00
|
|
|
|
#include "lengthcommon.h"
|
2006-12-03 01:11:37 +00:00
|
|
|
|
#include "qt_helpers.h"
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LengthCombo::LengthCombo(QWidget * parent)
|
|
|
|
|
: QComboBox(parent)
|
|
|
|
|
{
|
2006-10-21 00:16:43 +00:00
|
|
|
|
for (int i = 0; i < lyx::num_units; i++)
|
2006-12-03 01:11:37 +00:00
|
|
|
|
addItem(lyx::qt_(lyx::unit_name_gui[i]));
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
|
|
connect(this, SIGNAL(activated(int)),
|
|
|
|
|
this, SLOT(has_activated(int)));
|
|
|
|
|
}
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
2007-04-28 12:58:49 +00:00
|
|
|
|
lyx::Length::UNIT LengthCombo::currentLengthItem() const
|
2006-03-05 17:24:44 +00:00
|
|
|
|
{
|
2007-04-28 12:58:49 +00:00
|
|
|
|
return static_cast<lyx::Length::UNIT>(currentIndex());
|
2006-03-05 17:24:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void LengthCombo::has_activated(int)
|
|
|
|
|
{
|
2006-10-21 00:16:43 +00:00
|
|
|
|
// emit signal
|
2006-06-30 14:11:50 +00:00
|
|
|
|
selectionChanged(currentLengthItem());
|
2006-03-05 17:24:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-04-28 12:58:49 +00:00
|
|
|
|
void LengthCombo::setCurrentItem(lyx::Length::UNIT unit)
|
2006-03-05 17:24:44 +00:00
|
|
|
|
{
|
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);
|
2006-10-21 00:16:43 +00:00
|
|
|
|
--i;
|
|
|
|
|
--num;
|
2006-03-05 17:24:44 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2006-05-18 08:51:12 +00:00
|
|
|
|
|
2007-04-26 03:53:02 +00:00
|
|
|
|
#include "LengthCombo_moc.cpp"
|