]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/LengthCombo.cpp
QDialogButtonBox for the remaining dialogs.
[lyx.git] / src / frontends / qt4 / LengthCombo.cpp
index 448737c3d76172d08714622c9f5f1643d0ef99d5..6eacfbfb36d715d5ae2a2586cde557d7232f3084 100644 (file)
 #include <string>
 
 
+namespace lyx {
+namespace frontend {
+
 LengthCombo::LengthCombo(QWidget * parent)
        : QComboBox(parent)
 {
        for (int i = 0; i < lyx::num_units; i++) {
                // mu does not make sense usually
                // so it must be added manually, if needed
-               if (lyx::unit_name[i] == "mu")
+               if (QLatin1String(lyx::unit_name[i]) == "mu")
                        continue;
                QComboBox::addItem(lyx::qt_(lyx::unit_name_gui[i]),
                        lyx::toqstr(lyx::unit_name[i]));
        }
 
        connect(this, SIGNAL(activated(int)),
-               this, SLOT(has_activated(int)));
+               this, SLOT(hasActivated(int)));
 }
 
 
@@ -45,7 +48,7 @@ lyx::Length::UNIT LengthCombo::currentLengthItem() const
 }
 
 
-void LengthCombo::has_activated(int)
+void LengthCombo::hasActivated(int)
 {
   // emit signal
        selectionChanged(currentLengthItem());
@@ -54,10 +57,15 @@ void LengthCombo::has_activated(int)
 
 void LengthCombo::setCurrentItem(lyx::Length::UNIT unit)
 {
-       QString const val = lyx::toqstr(lyx::stringFromUnit(unit));
+       setCurrentItem(lyx::toqstr(lyx::stringFromUnit(unit)));
+}
+
+
+void LengthCombo::setCurrentItem(QString const & item)
+{
        int num = QComboBox::count();
        for (int i = 0; i < num; i++) {
-               if (QComboBox::itemData(i).toString() == val) {
+               if (QComboBox::itemData(i).toString() == item) {
                        QComboBox::setCurrentIndex(i);
                        break;
                }
@@ -90,7 +98,15 @@ void LengthCombo::noPercents()
 }
 
 
-void LengthCombo::removeItem(lyx::Length::UNIT unit)
+void LengthCombo::removeFontDependent()
+{
+       removeUnit(Length::EM);
+       removeUnit(Length::EX);
+       removeUnit(Length::MU);
+}
+
+
+void LengthCombo::removeUnit(lyx::Length::UNIT unit)
 {
        QString const val = lyx::toqstr(lyx::stringFromUnit(unit));
        int num = QComboBox::count();
@@ -103,13 +119,7 @@ void LengthCombo::removeItem(lyx::Length::UNIT unit)
 }
 
 
-void LengthCombo::removeItem(int item)
-{
-       QComboBox::removeItem(item);
-}
-
-
-void LengthCombo::addItem(lyx::Length::UNIT unit)
+void LengthCombo::addUnit(lyx::Length::UNIT unit)
 {
        QString const val = lyx::toqstr(lyx::stringFromUnit(unit));
        int num = QComboBox::count();
@@ -123,10 +133,7 @@ void LengthCombo::addItem(lyx::Length::UNIT unit)
                   lyx::toqstr(lyx::unit_name[int(unit)]));
 }
 
-
-void LengthCombo::addItem(QString const item)
-{
-       QComboBox::addItem(item);
-}
+} // namespace frontend
+} // namespace lyx
 
 #include "moc_LengthCombo.cpp"