]> git.lyx.org Git - features.git/commitdiff
Bug fixes from Ugras Baran:
authorAbdelrazak Younes <younes@lyx.org>
Thu, 16 Nov 2006 12:37:55 +0000 (12:37 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Thu, 16 Nov 2006 12:37:55 +0000 (12:37 +0000)
Following patch corrects some misbehavior in TOC dialog:

- When clicking on Toc insets, dialog switches to correct list.
- cursor goes to correct entry when clicked..
- some other fixes..

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15949 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/QToc.C
src/frontends/qt4/QToc.h
src/frontends/qt4/QTocDialog.C
src/frontends/qt4/QTocDialog.h

index 22a3990c194a55b9a395c18cd6fb164d547f61de..039d3980ce1c0b4bd41f926afc0d1b5868fe2a7c 100644 (file)
@@ -112,13 +112,23 @@ void QToc::goTo(QModelIndex const & index)
 }
 
 
+int QToc::getType()
+{
+       return type_;
+}
+
+
 void QToc::update()
 {
-       toc_models_.clear();
+       updateType();
+       updateToc();
+}
 
-       QStringList type_list;
 
-       type_ = 0;
+void QToc::updateType()
+{
+
+       QStringList type_list;
 
        vector<string> const & types = getTypes();
        if (types.empty()) {
@@ -127,8 +137,11 @@ void QToc::update()
                return;
        }
 
-       string const & selected_type = params().getCmdName();
-       lyxerr[Debug::GUI] << "selected_type " << selected_type << endl;
+       string selected_type ;
+       if(params()["type"].empty()) //Then plain toc...
+               selected_type = params().getCmdName();
+       else
+               selected_type = to_ascii(params()["type"]);
 
        QString gui_names_;
        for (size_t i = 0; i != types.size(); ++i) {
@@ -142,15 +155,21 @@ void QToc::update()
                        << "\ttoc_models_.size() " << toc_models_.size()
                        << endl;
 
-               toc_models_.push_back(new TocModel(getContents(types[i])));
        }
        type_model_.setStringList(type_list);
 }
 
 
-void QToc::updateToc(int type)
+void QToc::updateToc()
 {
-       toc_models_[type] = new TocModel(getContents(getTypes()[type]));
+       toc_models_.clear();
+       vector<string> const & types = getTypes();
+
+       for (size_t i = 0; i != types.size(); ++i) {
+
+               toc_models_.push_back(new TocModel(getContents(types[i])));
+       }
+       
 }
 
 
index abee279bfb79874e5ed0117e513783e49c31455c..15d65d590aa13c419b884b60b9645b11437d8290 100644 (file)
@@ -32,8 +32,10 @@ public:
        QToc(Dialog &);
 
        void update();
-
-       void updateToc(int type);
+       ///
+       void updateToc();
+       ///
+       void updateType();
 
        bool canOutline();
        
@@ -47,6 +49,8 @@ public:
        QModelIndex const getCurrentIndex();
        ///
        void goTo(QModelIndex const & index);
+       ///
+       int getType();
 
 private:
 
index 64e752f19890fcd80d515611df0726aa758b5682..be1160752e22693defbb2703a10b59214937f96d 100644 (file)
@@ -79,7 +79,7 @@ void QTocDialog::on_closePB_clicked()
 
 void QTocDialog::on_updatePB_clicked()
 {
-       update();
+       form_->update();
 }
 
 
@@ -105,6 +105,7 @@ void QTocDialog::on_typeCO_activated(int value)
 {
        form_->setTocModel(value);
        tocTV->setModel(form_->tocModel());
+       reconnectSelectionModel();
        enableButtons();
 }
 
@@ -180,7 +181,7 @@ void QTocDialog::enableButtons(bool enable)
 
 void QTocDialog::update()
 {
-       form_->update();
+       form_->updateToc();
        updateGui();
 }
 
@@ -197,6 +198,7 @@ void QTocDialog::updateGui()
        }
 
        typeCO->setModel(type_model);
+       typeCO->setCurrentIndex(form_->getType());
 
        if (form_->tocModel())
                tocTV->setModel(form_->tocModel());
@@ -208,12 +210,7 @@ void QTocDialog::updateGui()
        tocTV->header()->setVisible(false);
        enableButtons();
 
-       connect(tocTV->selectionModel(),
-               SIGNAL(currentChanged(const QModelIndex &,
-                       const QModelIndex &)),
-               this, SLOT(selectionChanged(const QModelIndex &,
-                       const QModelIndex &)));
-
+       reconnectSelectionModel();
        select(form_->getCurrentIndex());
 
        lyxerr[Debug::GUI]
@@ -224,6 +221,16 @@ void QTocDialog::updateGui()
 }
 
 
+void QTocDialog::reconnectSelectionModel()
+{
+       connect(tocTV->selectionModel(),
+               SIGNAL(currentChanged(const QModelIndex &,
+                       const QModelIndex &)),
+               this, SLOT(selectionChanged(const QModelIndex &,
+                       const QModelIndex &)));
+}
+
+
 void QTocDialog::apply()
 {
        // Nothing to do here... for now.
@@ -239,7 +246,7 @@ void QTocDialog::hide()
 
 void QTocDialog::show()
 {
-       update();
+       form_->update();
        QDialog::show();
 }
 
index df86647ebfd933388a257df00124c01aed2ac2e0..a006c3b4ad0de69a8ca70fda0916dab77c9194b3 100644 (file)
@@ -71,6 +71,8 @@ protected Q_SLOTS:
 protected:
        ///
        void enableButtons(bool enable = true);
+       /// Reconnects the selection model change signal when TOC changed.
+       void reconnectSelectionModel();
 
 private: