]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt2/QCharacter.C
Some string(widget->text()) fixes. Weirdness
[lyx.git] / src / frontends / qt2 / QCharacter.C
index 83afefacd79be2fcdce6fd486ed5634730ab6e99..b6ebdf7b1d69ba5e6f32f9c96987baa97fc5ef5c 100644 (file)
@@ -1,34 +1,42 @@
 /**
  * \file QCharacter.C
- * Copyright 2001 the LyX Team
- * Read the file COPYING
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
  *
- * \author Edwin Leuven, leuven@fee.uva.nl
- * \author John Levon <moz@compsoc.man.ac.uk>
+ * \author Edwin Leuven
+ * \author John Levon
+ *
+ * Full author contact details are available in file CREDITS
  */
 
 #include <config.h>
 
-#include <vector>
-
-#include "gettext.h"
-#include "support/lstrings.h"
+#ifdef __GNUG__
+#pragma implementation
+#endif
 
 #include "ControlCharacter.h"
 #include "QCharacterDialog.h"
 #include "QCharacter.h"
 #include "Qt2BC.h"
+
+#include "gettext.h"
+#include "support/lstrings.h"
+
 #include <qcombobox.h>
 #include <qcheckbox.h>
 #include <qpushbutton.h>
 
-using namespace character;
+#include <vector>
+
+using namespace frnt;
 using std::vector;
+
 typedef Qt2CB<ControlCharacter, Qt2DB<QCharacterDialog> > base_class;
-QCharacter::QCharacter(ControlCharacter & c)
-       : base_class(c, _("Character"))
+
+
+QCharacter::QCharacter()
+       : base_class(_("Character"))
 {
 }
 
@@ -43,12 +51,13 @@ void QCharacter::build_dialog()
        size   = getSizeData();
        bar    = getBarData();
        color  = getColorData();
-       language = getLanguageData();
+       language = getLanguageData(true);
 
        for (vector<FamilyPair>::const_iterator cit = family.begin();
                cit != family.end(); ++cit) {
                dialog_->familyCO->insertItem(cit->first.c_str(), -1);
        }
+
        for (vector<SeriesPair>::const_iterator cit = series.begin();
                cit != series.end(); ++cit) {
                dialog_->seriesCO->insertItem(cit->first.c_str(), -1);
@@ -69,11 +78,11 @@ void QCharacter::build_dialog()
                cit != color.end(); ++cit) {
                dialog_->colorCO->insertItem(cit->first.c_str(), -1);
        }
-       for (vector<string>::const_iterator cit = language.begin();
+       for (vector<LanguagePair>::const_iterator cit = language.begin();
                cit != language.end(); ++cit) {
-               dialog_->langCO->insertItem(cit->c_str(), -1);
+               dialog_->langCO->insertItem(cit->first.c_str(), -1);
        }
+
        bc().setOK(dialog_->okPB);
        bc().setApply(dialog_->applyPB);
        bc().setCancel(dialog_->closePB);
@@ -90,54 +99,54 @@ void QCharacter::build_dialog()
 
 
 namespace {
+
 template<class A, class B>
 int findPos2nd(vector<std::pair<A,B> > const & vec, B const & val)
 {
-       vector<std::pair<A,B> >::const_iterator cit = vec.begin();
+       typedef typename vector<std::pair<A, B> >::const_iterator
+               const_iterator;
+
+       const_iterator cit = vec.begin();
        for (; cit != vec.end(); ++cit) {
                if (cit->second == val)
-                       return int(cit - vec.begin()); 
+                       return int(cit - vec.begin());
        }
        return 0;
 }
+
 } // namespace anon
+
+
 void QCharacter::update_contents()
 {
-       dialog_->familyCO->setCurrentItem(findPos2nd(family, controller().getFamily()));
-       dialog_->seriesCO->setCurrentItem(findPos2nd(series, controller().getSeries()));
-       dialog_->shapeCO->setCurrentItem(findPos2nd(shape, controller().getShape()));
-       dialog_->sizeCO->setCurrentItem(findPos2nd(size, controller().getSize()));
-       dialog_->miscCO->setCurrentItem(findPos2nd(bar, controller().getBar()));
-       dialog_->colorCO->setCurrentItem(findPos2nd(color, controller().getColor()));
-
-       dialog_->toggleallCB->setChecked(controller().getToggleAll());
-       string const thelanguage(controller().getLanguage());
-       int i = 0; 
-       for (vector<string>::const_iterator cit = language.begin();
-               cit != language.end(); ++i, ++cit) {
-               if (*cit == thelanguage) {
-                       dialog_->langCO->setCurrentItem(i);
-                       break;
-               }
-       }
+       ControlCharacter const & ctrl = controller();
+
+       dialog_->familyCO->setCurrentItem(findPos2nd(family,
+                                                    ctrl.getFamily()));
+       dialog_->seriesCO->setCurrentItem(findPos2nd(series,
+                                                    ctrl.getSeries()));
+       dialog_->shapeCO->setCurrentItem(findPos2nd(shape, ctrl.getShape()));
+       dialog_->sizeCO->setCurrentItem(findPos2nd(size, ctrl.getSize()));
+       dialog_->miscCO->setCurrentItem(findPos2nd(bar, ctrl.getBar()));
+       dialog_->colorCO->setCurrentItem(findPos2nd(color, ctrl.getColor()));
+       dialog_->langCO->setCurrentItem(findPos2nd(language,
+                                                  ctrl.getLanguage()));
+
+       dialog_->toggleallCB->setChecked(ctrl.getToggleAll());
 }
 
+
 void QCharacter::apply()
 {
-       controller().setFamily(family[dialog_->familyCO->currentItem()].second);
-       controller().setSeries(series[dialog_->seriesCO->currentItem()].second);
-       controller().setShape(shape[dialog_->shapeCO->currentItem()].second);
-       controller().setSize(size[dialog_->sizeCO->currentItem()].second);
-       controller().setBar(bar[dialog_->miscCO->currentItem()].second);
-       controller().setColor(color[dialog_->colorCO->currentItem()].second);
-       controller().setLanguage(dialog_->langCO->currentText().latin1());
-   
-       controller().setToggleAll(dialog_->toggleallCB->isChecked());
+       ControlCharacter & ctrl = controller();
+
+       ctrl.setFamily(family[dialog_->familyCO->currentItem()].second);
+       ctrl.setSeries(series[dialog_->seriesCO->currentItem()].second);
+       ctrl.setShape(shape[dialog_->shapeCO->currentItem()].second);
+       ctrl.setSize(size[dialog_->sizeCO->currentItem()].second);
+       ctrl.setBar(bar[dialog_->miscCO->currentItem()].second);
+       ctrl.setColor(color[dialog_->colorCO->currentItem()].second);
+       ctrl.setLanguage(language[dialog_->langCO->currentItem()].second);
+
+       ctrl.setToggleAll(dialog_->toggleallCB->isChecked());
 }