]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/QDocumentDialog.C
rename LFUN enum values according to their command (as used in th minibuffer/bind...
[lyx.git] / src / frontends / qt4 / QDocumentDialog.C
index 93ee2bf08b558e811968459f4ff98272fbefba18..55d34bd011a7c087fa02fc84529daaac0e3eeaa2 100644 (file)
 #include "controllers/frnt_lang.h"
 
 
-#include <QLabel>
-#include <QLineEdit>
-#include <QPushButton>
-#include <QRadioButton>
-#include <QCheckBox>
-#include <QSlider>
-#include <QPixmap>
-#include <QColor>
-#include <QColorDialog>
-#include <QValidator>
-
 using lyx::support::token;
 using lyx::support::bformat;
 using lyx::support::getVectorFromString;
 
-using std::string;
-
-
 using std::distance;
 using std::vector;
 using std::string;
@@ -80,15 +66,8 @@ char const * encodings[] = { "LaTeX default", "latin1", "latin2",
 
 }
 
-/*
-QDocumentDialog::getTextClass()
-{
-       return latexModule->classCO->currentItem();
-}
-*/
-
 QDocumentDialog::QDocumentDialog(QDocument * form)
-       : form_(form), 
+       : form_(form),
        lang_(getSecond(getLanguageData(false)))
 {
        setupUi(this);
@@ -101,10 +80,12 @@ QDocumentDialog::QDocumentDialog(QDocument * form)
                form, SLOT(slotClose()));
        connect(restorePB, SIGNAL(clicked()),
                form, SLOT(slotRestore()));
-       
 
-    connect( savePB, SIGNAL( clicked() ), this, SLOT( saveDefaultClicked() ) );
-    connect( defaultPB, SIGNAL( clicked() ), this, SLOT( useDefaultsClicked() ) );
+
+       connect(savePB, SIGNAL( clicked() ), 
+               this, SLOT( saveDefaultClicked() ) );
+       connect(defaultPB, SIGNAL( clicked() ), 
+               this, SLOT( useDefaultsClicked() ) );
 
        // Manage the restore, ok, apply, restore and cancel/close buttons
        form_->bcview().setOK(okPB);
@@ -157,13 +138,13 @@ QDocumentDialog::QDocumentDialog(QDocument * form)
                qt_("Double"), Spacing::Double);
        textLayoutModule->lspacingCO->insertItem(
                qt_("Custom"), Spacing::Other);
-       
+
        // initialize the length validator
        addCheckedLineEdit(form_->bcview(), textLayoutModule->skipLE);
-       
 
 
-       
+
+
        pageLayoutModule = new UiWidget<Ui::PageLayoutUi>;
        // page layout
        connect(pageLayoutModule->papersizeCO, SIGNAL(activated(int)), this, SLOT(setCustomPapersize(int)));
@@ -187,7 +168,7 @@ QDocumentDialog::QDocumentDialog(QDocument * form)
                pageLayoutModule->paperheightL);
        addCheckedLineEdit(form_->bcview(), pageLayoutModule->paperwidthLE,
                pageLayoutModule->paperwidthL);
-       
+
        // paper
        QComboBox * cb = pageLayoutModule->papersizeCO;
        cb->insertItem(qt_("Default"));
@@ -229,7 +210,7 @@ QDocumentDialog::QDocumentDialog(QDocument * form)
        connect(marginsModule->headsepLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
        connect(marginsModule->headsepUnit, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
        connect(marginsModule->footskipLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
-       connect(marginsModule->footskipUnit, SIGNAL(activated(int)), this, SLOT(change_adaptor()));     
+       connect(marginsModule->footskipUnit, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
        marginsModule->topLE->setValidator(unsignedLengthValidator(
                marginsModule->topLE));
        marginsModule->bottomLE->setValidator(unsignedLengthValidator(
@@ -261,7 +242,7 @@ QDocumentDialog::QDocumentDialog(QDocument * form)
                marginsModule->footskipL);
 
 
-       
+
 
 
        langModule = new UiWidget<Ui::LanguageUi>;
@@ -301,13 +282,15 @@ QDocumentDialog::QDocumentDialog(QDocument * form)
        connect(numberingModule->tocSL, SIGNAL(valueChanged(int)), this, SLOT(change_adaptor()));
        connect(numberingModule->depthSL, SIGNAL(valueChanged(int)), this, SLOT(updateNumbering()));
        connect(numberingModule->tocSL, SIGNAL(valueChanged(int)), this, SLOT(updateNumbering()));
-       numberingModule->tocLV->setSorting(-1);
-
+       numberingModule->tocTW->setColumnCount(3);
+       numberingModule->tocTW->headerItem()->setText(0, qt_("Example"));
+       numberingModule->tocTW->headerItem()->setText(1, qt_("Numbered"));
+       numberingModule->tocTW->headerItem()->setText(2, qt_("Appears in TOC"));
 
 
        biblioModule = new UiWidget<Ui::BiblioUi>;
-    connect( biblioModule->citeNatbibRB, SIGNAL( toggled(bool) ), biblioModule->citationStyleL, SLOT( setEnabled(bool) ) );
-    connect( biblioModule->citeNatbibRB, SIGNAL( toggled(bool) ), biblioModule->citeStyleCO, SLOT( setEnabled(bool) ) );
+       connect( biblioModule->citeNatbibRB, SIGNAL( toggled(bool) ), biblioModule->citationStyleL, SLOT( setEnabled(bool) ) );
+       connect( biblioModule->citeNatbibRB, SIGNAL( toggled(bool) ), biblioModule->citeStyleCO, SLOT( setEnabled(bool) ) );
        // biblio
        connect(biblioModule->citeDefaultRB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor()));
        connect(biblioModule->citeNatbibRB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor()));
@@ -319,15 +302,15 @@ QDocumentDialog::QDocumentDialog(QDocument * form)
        biblioModule->citeStyleCO->insertItem(qt_("Numerical"));
        biblioModule->citeStyleCO->setCurrentItem(0);
 
-       
-       
+
+
        mathsModule = new UiWidget<Ui::MathsUi>;
     connect( mathsModule->amsautoCB, SIGNAL( toggled(bool) ), mathsModule->amsCB, SLOT( setDisabled(bool) ) );
        // maths
        connect(mathsModule->amsCB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor()));
        connect(mathsModule->amsautoCB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor()));
 
-       
+
        latexModule = new UiWidget<Ui::LaTeXUi>;
        // latex class
        connect(latexModule->classCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
@@ -350,23 +333,24 @@ QDocumentDialog::QDocumentDialog(QDocument * form)
                        latexModule->classCO->insertItem(toqstr(item));
                }
        }
-       
 
-       
+
+
        branchesModule = new QBranches;
-       
+       connect(branchesModule, SIGNAL(changed()), this, SLOT(change_adaptor()));
+
 
        preambleModule = new UiWidget<Ui::PreambleUi>;
        // preamble
-       connect(preambleModule->preambleMLE, SIGNAL(textChanged()), this, SLOT(change_adaptor()));
+       connect(preambleModule->preambleTE, SIGNAL(textChanged()), this, SLOT(change_adaptor()));
 
 
        bulletsModule = new BulletsModule;
        // bullets
        connect(bulletsModule, SIGNAL(changed()), this, SLOT(change_adaptor()));
 
-       
-       floatModule = new FloatPlacement(this);
+
+       floatModule = new FloatPlacement;
        // float
        connect(floatModule, SIGNAL(changed()), this, SLOT(change_adaptor()));
 
@@ -383,7 +367,7 @@ QDocumentDialog::QDocumentDialog(QDocument * form)
        docPS->addPanel(branchesModule, _("Branches"));
        docPS->addPanel(preambleModule, _("LaTeX Preamble"));
        docPS->setCurrentPanel(_("Document Class"));
-}                              
+}
 
 
 QDocumentDialog::~QDocumentDialog()
@@ -562,36 +546,35 @@ void QDocumentDialog::updateNumbering()
        LyXTextClass const & tclass =
                form_->controller().params().getLyXTextClass();
 
-       //numberingModule->tocLV->setUpdatesEnabled(false);
+       numberingModule->tocTW->setUpdatesEnabled(false);
+       numberingModule->tocTW->clear();
 
-       // Update the example QListView
        int const depth = numberingModule->depthSL->value();
        int const toc = numberingModule->tocSL->value();
        QString const no = qt_("No");
        QString const yes = qt_("Yes");
        LyXTextClass::const_iterator end = tclass.end();
        LyXTextClass::const_iterator cit = tclass.begin();
-       numberingModule->tocLV->clear();
-       Q3ListViewItem * item = 0;
+       QTreeWidgetItem * item = 0;
        for ( ; cit != end ; ++cit) {
                int const toclevel = (*cit)->toclevel;
                if (toclevel != LyXLayout::NOT_IN_TOC) {
-                       item = new Q3ListViewItem(numberingModule->tocLV,
-                                                item, qt_((*cit)->name()));
+                       item = new QTreeWidgetItem(numberingModule->tocTW);
+                       item->setText(0, qt_((*cit)->name()));
                        item->setText(1, (toclevel <= depth) ? yes : no);
                        item->setText(2, (toclevel <= toc) ? yes : no);
                }
        }
 
-       //numberingModule->tocLV->setUpdatesEnabled(true);
-       //numberingModule->tocLV->update();
+       numberingModule->tocTW->setUpdatesEnabled(true);
+       numberingModule->tocTW->update();
 }
 
 void QDocumentDialog::apply(BufferParams & params)
 {
        // preamble
        params.preamble =
-               fromqstr(preambleModule->preambleMLE->text());
+               fromqstr(preambleModule->preambleTE->document()->toPlainText());
 
        // biblio
        params.cite_engine = biblio::ENGINE_BASIC;
@@ -649,8 +632,10 @@ void QDocumentDialog::apply(BufferParams & params)
        params.language = languages.getLanguage(lang_[pos]);
 
        // numbering
-       params.tocdepth = numberingModule->tocSL->value();
-       params.secnumdepth = numberingModule->depthSL->value();
+       if (params.getLyXTextClass().hasTocLevels()) {
+               params.tocdepth = numberingModule->tocSL->value();
+               params.secnumdepth = numberingModule->depthSL->value();
+       }
 
        // bullets
        params.user_defined_bullet(0) = bulletsModule->getBullet(0);
@@ -836,7 +821,7 @@ void QDocumentDialog::update(BufferParams const & params)
 
        // preamble
        QString preamble = toqstr(params.preamble);
-       preambleModule->preambleMLE->setText(preamble);
+       preambleModule->preambleTE->document()->setPlainText(preamble);
 
        // biblio
        biblioModule->citeDefaultRB->setChecked(
@@ -882,19 +867,19 @@ void QDocumentDialog::update(BufferParams const & params)
        // numbering
        int const min_toclevel = form_->controller().textClass().min_toclevel();
        int const max_toclevel = form_->controller().textClass().max_toclevel();
-       if (min_toclevel != LyXLayout::NOT_IN_TOC)
+       if (form_->controller().textClass().hasTocLevels()) {
                numberingModule->setEnabled(true);
-       else {
+               numberingModule->depthSL->setMinValue(min_toclevel - 1);
+               numberingModule->depthSL->setMaxValue(max_toclevel);
+               numberingModule->depthSL->setValue(params.secnumdepth);
+               numberingModule->tocSL->setMinValue(min_toclevel - 1);
+               numberingModule->tocSL->setMaxValue(max_toclevel);
+               numberingModule->tocSL->setValue(params.tocdepth);
+               updateNumbering();
+       } else {
                numberingModule->setEnabled(false);
-               numberingModule->tocLV->clear();
+               numberingModule->tocTW->clear();
        }
-       numberingModule->depthSL->setMinValue(min_toclevel - 1);
-       numberingModule->depthSL->setMaxValue(max_toclevel);
-       numberingModule->depthSL->setValue(params.secnumdepth);
-       numberingModule->tocSL->setMinValue(min_toclevel - 1);
-       numberingModule->tocSL->setMaxValue(max_toclevel);
-       numberingModule->tocSL->setValue(params.tocdepth);
-       updateNumbering();
 
        // bullets
        bulletsModule->setBullet(0,params.user_defined_bullet(0));