]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt2/QDocument.C
better selection and scrolling behaviour
[lyx.git] / src / frontends / qt2 / QDocument.C
index b052c397afa2d589357a4b5572cffabdf0f0d18b..e40c10ebf76c2b6cfefb10b13f991f5b3c652756 100644 (file)
@@ -85,10 +85,10 @@ void QDocument::build_dialog()
        dialog_->langModule->quoteStyleCO->insertItem(_("»text«"));
 
        // packages
-       char const * items[] = {"default","auto","latin1","latin2",
-                            "latin3","latin4","latin5","latin9",
-                            "koi8-r","koi8-u","cp866","cp1251",
-                            "iso88595","pt154",0};
+       char const * items[] = {"default", "auto", "latin1", "latin2",
+                            "latin3", "latin4", "latin5", "latin9",
+                            "koi8-r", "koi8-u", "cp866", "cp1251",
+                            "iso88595", "pt154", 0};
        dialog_->packagesModule->encodingCO->insertStrList(items);
 
        dialog_->packagesModule->lspacingCO->insertItem(
@@ -106,11 +106,11 @@ void QDocument::build_dialog()
        }
 
        // paper
-       QStringList papersize_;
-       papersize_ << _("Default") << _("Custom") << _("US letter") << _("US legal")
-                  << _("US executive") << _("A3") << _("A4") << _("A5")
-                  << _("B3") << _("B4") << _("B5");
-       dialog_->paperModule->papersizeCO->insertStringList(papersize_);
+       char const * sizes[] = {
+               _("Default") , _("Custom") , _("US letter") , _("US legal")
+                  , _("US executive") , _("A3") , _("A4") , _("A5")
+                  , _("B3") , _("B4") , _("B5"), 0 };
+       dialog_->paperModule->papersizeCO->insertStrList(sizes);
 
        // layout
        for (LyXTextClassList::const_iterator cit = textclasslist.begin();
@@ -208,7 +208,7 @@ void QDocument::apply()
        params.user_defined_bullets[1].setText(dialog_->bulletsModule->bullet2LE->text().latin1());
        params.user_defined_bullets[2].setText(dialog_->bulletsModule->bullet3LE->text().latin1());
        params.user_defined_bullets[3].setText(dialog_->bulletsModule->bullet4LE->text().latin1());
-       
+
        params.user_defined_bullets[0].setSize(dialog_->bulletsModule->bulletsize1CO->currentItem()-1);
        params.user_defined_bullets[1].setSize(dialog_->bulletsModule->bulletsize2CO->currentItem()-1);
        params.user_defined_bullets[2].setSize(dialog_->bulletsModule->bulletsize3CO->currentItem()-1);
@@ -336,7 +336,7 @@ void QDocument::apply()
        params.paperpackage = char(margin);
 
        MarginsModuleBase const * m(dialog_->marginsModule);
+
        params.leftmargin =
                LyXLength(m->innerLE->text().toDouble(),
                          m->innerUnit->currentLengthItem()
@@ -439,7 +439,7 @@ void QDocument::update_contents()
        dialog_->bulletsModule->bullet3LE->setText(s);
        s = params.user_defined_bullets[3].getText().c_str();
        dialog_->bulletsModule->bullet4LE->setText(s);
-       
+
        dialog_->bulletsModule->bulletsize1CO->setCurrentItem(
                params.user_defined_bullets[0].getSize() + 1);
        dialog_->bulletsModule->bulletsize2CO->setCurrentItem(
@@ -448,22 +448,17 @@ void QDocument::update_contents()
                params.user_defined_bullets[2].getSize() + 1);
        dialog_->bulletsModule->bulletsize4CO->setCurrentItem(
                params.user_defined_bullets[3].getSize() + 1);
-       
+
        // packages
-       QStringList enc;
-       enc <<  "default" << "auto" << "latin1" << "latin2" << "latin3" <<
-               "latin4" << "latin5" << "latin9" << "koi8-r" << "koi8-u" <<
-               "cp866" << "cp1251" << "iso88595" << "pt154";
-       int pos2 = 0;
-       for (QStringList::Iterator it = enc.begin();
-            it!=enc.end(); ++it) {
-               if (*it == params.inputenc.c_str()) {
-                       dialog_->packagesModule->encodingCO->setCurrentItem(pos2);
-               }
-               ++pos2;
+       char const * enc[] = {
+               "default" , "auto" , "latin1" , "latin2" , "latin3" ,
+               "latin4" , "latin5" , "latin9" , "koi8-r" , "koi8-u" ,
+               "cp866" , "cp1251" , "iso88595" , "pt154" };
+       for (size_t i = 0; i < sizeof(enc)/sizeof(char *); ++i) {
+               if (params.inputenc == enc[i])
+                       dialog_->packagesModule->encodingCO->setCurrentItem(i);
        }
 
-
        QString text = params.graphicsDriver.c_str();
        int nitem = dialog_->packagesModule->psdriverCO->count();
        for (int n = 0; n < nitem ; ++n) {
@@ -477,11 +472,14 @@ void QDocument::update_contents()
        dialog_->packagesModule->amsCB->setChecked(
                params.use_amsmath);
 
-       // FIXME: this is wrong
-       // QComboBox::setCurrentItem: (lspacingCO) Index 4 out of range
-       dialog_->packagesModule->lspacingCO->
-               setCurrentItem(params.spacing.getSpace());
+       switch (params.spacing.getSpace()) {
+               case Spacing::Other: nitem = 3; break;
+               case Spacing::Double: nitem = 2; break;
+               case Spacing::Onehalf: nitem = 1; break;
+               case Spacing::Default: case Spacing::Single: nitem = 0; break;
+       }
+
+       dialog_->packagesModule->lspacingCO->setCurrentItem(nitem);
        if (params.spacing.getSpace() == Spacing::Other) {
                dialog_->packagesModule->lspacingLE->setText(
                        tostr(params.spacing.getValue()).c_str());
@@ -580,9 +578,9 @@ void QDocument::update_contents()
                tostr(LyXLength(params.paperheight).value()).c_str());
 
        // margins
+
        MarginsModuleBase * m(dialog_->marginsModule);
+
        int item = params.paperpackage;
        if (params.use_geometry) {
                item = 1;