]> 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 b1b7b2ff1d0ceec15a47f1c1a2a43b4edb1aa1fb..e40c10ebf76c2b6cfefb10b13f991f5b3c652756 100644 (file)
@@ -42,6 +42,8 @@
 #include <qstringlist.h>
 #include "lengthcombo.h"
 
+#include "QBrowseBox.h"
+
 #include <vector>
 
 using std::vector;
@@ -83,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(
@@ -104,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();
@@ -140,13 +142,10 @@ void QDocument::build_dialog()
        // margins
        dialog_->setMargins(0);
 
-       string const bmtablefile = LibFileSearch("images", "standard", "xpm");
-       QString s = bmtablefile.c_str();
-
        // Manage the restore, ok, apply, restore and cancel/close buttons
        bc().setOK(dialog_->okPB);
        bc().setApply(dialog_->applyPB);
-       bc().setCancel(dialog_->cancelPB);
+       bc().setCancel(dialog_->closePB);
        bc().setRestore(dialog_->restorePB);
 }
 
@@ -204,6 +203,17 @@ void QDocument::apply()
        params.tocdepth =
                dialog_->numberingModule->sectionnrDepthSB->value();
 
+       // bullets
+       params.user_defined_bullets[0].setText(dialog_->bulletsModule->bullet1LE->text().latin1());
+       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);
+       params.user_defined_bullets[3].setSize(dialog_->bulletsModule->bulletsize4CO->currentItem()-1);
+
        // packages
        switch (dialog_->packagesModule->lspacingCO->currentItem()) {
        case 0:
@@ -275,6 +285,7 @@ void QDocument::apply()
        }
        default:
                // DocumentDefskipCB assures that this never happens
+               // so Assert then !!!  - jbl
                params.setDefSkip(VSpace(VSpace::MEDSKIP));
                break;
        }
@@ -324,46 +335,42 @@ void QDocument::apply()
        }
        params.paperpackage = char(margin);
 
+       MarginsModuleBase const * m(dialog_->marginsModule);
+
        params.leftmargin =
-               LyXLength(dialog_->marginsModule->innerLE->text().toDouble(),
-                         dialog_->marginsModule->innerUnit->currentLengthItem()
+               LyXLength(m->innerLE->text().toDouble(),
+                         m->innerUnit->currentLengthItem()
                          ).asString();
 
        params.topmargin =
-               LyXLength(dialog_->marginsModule->topLE->text().toDouble(),
-                         dialog_->marginsModule->topUnit->currentLengthItem()
+               LyXLength(m->topLE->text().toDouble(),
+                         m->topUnit->currentLengthItem()
                          ).asString();
 
-
        params.rightmargin =
-               LyXLength(dialog_->marginsModule->outerLE->text().toDouble(),
-                         dialog_->marginsModule->outerUnit->currentLengthItem()
+               LyXLength(m->outerLE->text().toDouble(),
+                         m->outerUnit->currentLengthItem()
                          ).asString();
 
-
        params.bottommargin =
-               LyXLength(dialog_->marginsModule->bottomLE->text().toDouble(),
-                         dialog_->marginsModule->bottomUnit->currentLengthItem()
+               LyXLength(m->bottomLE->text().toDouble(),
+                         m->bottomUnit->currentLengthItem()
                          ).asString();
 
-
        params.headheight =
-               LyXLength(dialog_->marginsModule->headheightLE->text().toDouble(),
-                         dialog_->marginsModule->headheightUnit->currentLengthItem()
+               LyXLength(m->headheightLE->text().toDouble(),
+                         m->headheightUnit->currentLengthItem()
                          ).asString();
 
-
        params.headsep =
-               LyXLength(dialog_->marginsModule->headsepLE->text().toDouble(),
-                         dialog_->marginsModule->headsepUnit->currentLengthItem()
+               LyXLength(m->headsepLE->text().toDouble(),
+                         m->headsepUnit->currentLengthItem()
                          ).asString();
 
-
        params.footskip =
-               LyXLength(dialog_->marginsModule->footskipLE->text().toDouble(),
-                         dialog_->marginsModule->footskipUnit->currentLengthItem()
+               LyXLength(m->footskipLE->text().toDouble(),
+                         m->footskipUnit->currentLengthItem()
                          ).asString();
-
 }
 
 
@@ -422,21 +429,36 @@ void QDocument::update_contents()
        dialog_->numberingModule->sectionnrDepthSB->setValue(
                params.tocdepth);
 
+       // bullets
+       QString s;
+       s = params.user_defined_bullets[0].getText().c_str();
+       dialog_->bulletsModule->bullet1LE->setText(s);
+       s = params.user_defined_bullets[1].getText().c_str();
+       dialog_->bulletsModule->bullet2LE->setText(s);
+       s = params.user_defined_bullets[2].getText().c_str();
+       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(
+               params.user_defined_bullets[1].getSize() + 1);
+       dialog_->bulletsModule->bulletsize3CO->setCurrentItem(
+               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) {
@@ -450,8 +472,14 @@ void QDocument::update_contents()
        dialog_->packagesModule->amsCB->setChecked(
                params.use_amsmath);
 
-       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());
@@ -550,47 +578,54 @@ 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;
        } else if (item > 0) {
                item = item + 1;
        }
-       dialog_->marginsModule->marginCO->setCurrentItem(item);
+       m->marginCO->setCurrentItem(item);
        dialog_->setCustomMargins(item);
 
-       dialog_->marginsModule->topUnit->setCurrentItem(
-               LyXLength(params.topmargin).unit());
-       dialog_->marginsModule->topLE->setText(
-               tostr(LyXLength(params.topmargin).value()).c_str());
-
-       dialog_->marginsModule->bottomUnit->setCurrentItem(
-               LyXLength(params.bottommargin).unit());
-       dialog_->marginsModule->bottomLE->setText(
-               tostr(LyXLength(params.bottommargin).value()).c_str());
-
-       dialog_->marginsModule->innerUnit->setCurrentItem(
-               LyXLength(params.leftmargin).unit());
-       dialog_->marginsModule->innerLE->setText(
-               tostr(LyXLength(params.leftmargin).value()).c_str());
-
-       dialog_->marginsModule->outerUnit->setCurrentItem(
-               LyXLength(params.rightmargin).unit());
-       dialog_->marginsModule->outerLE->setText(
-               tostr(LyXLength(params.rightmargin).value()).c_str());
-
-       dialog_->marginsModule->headheightUnit->setCurrentItem(
-               LyXLength(params.headheight).unit());
-       dialog_->marginsModule->headheightLE->setText(
-               tostr(LyXLength(params.headheight).value()).c_str());
-
-       dialog_->marginsModule->headsepUnit->setCurrentItem(
-               LyXLength(params.headsep).unit());
-       dialog_->marginsModule->headsepLE->setText(
-               tostr(LyXLength(params.headsep).value()).c_str());
-
-       dialog_->marginsModule->footskipUnit->setCurrentItem(
-               LyXLength(params.footskip).unit());
-       dialog_->marginsModule->footskipLE->setText(
-               tostr(LyXLength(params.footskip).value()).c_str());
+       m->topUnit->setCurrentItem(LyXLength(params.topmargin).unit());
+       m->topLE->setText(tostr(LyXLength(params.topmargin).value()).c_str());
+
+       m->bottomUnit->setCurrentItem(LyXLength(params.bottommargin).unit());
+       m->bottomLE->setText(tostr(LyXLength(params.bottommargin).value()).c_str());
+
+       m->innerUnit->setCurrentItem(LyXLength(params.leftmargin).unit());
+       m->innerLE->setText(tostr(LyXLength(params.leftmargin).value()).c_str());
+
+       m->outerUnit->setCurrentItem(LyXLength(params.rightmargin).unit());
+       m->outerLE->setText(tostr(LyXLength(params.rightmargin).value()).c_str());
+
+       m->headheightUnit->setCurrentItem(LyXLength(params.headheight).unit());
+       m->headheightLE->setText(tostr(LyXLength(params.headheight).value()).c_str());
+
+       m->headsepUnit->setCurrentItem(LyXLength(params.headsep).unit());
+       m->headsepLE->setText(tostr(LyXLength(params.headsep).value()).c_str());
+
+       m->footskipUnit->setCurrentItem(LyXLength(params.footskip).unit());
+       m->footskipLE->setText(tostr(LyXLength(params.footskip).value()).c_str());
+}
+
+
+void QDocument::saveDocDefault()
+{
+       // we have to apply the params first
+       apply();
+       controller().saveAsDefault();
+}
+
+
+void QDocument::useClassDefaults()
+{
+       BufferParams & params = controller().params();
+
+       params.textclass = dialog_->layoutModule->classCO->currentItem();
+       params.useClassDefaults();
+       update_contents();
 }