]> git.lyx.org Git - features.git/commitdiff
Copy modules into the Advanced F&R pane as well.
authorRichard Kimberly Heck <rikiheck@lyx.org>
Fri, 4 May 2018 16:37:52 +0000 (12:37 -0400)
committerRichard Kimberly Heck <rikiheck@lyx.org>
Tue, 11 Dec 2018 23:05:53 +0000 (18:05 -0500)
(cherry picked from commit 5064c09e9f57a7ffb6082a7f8ec06c03ee9a0cef)

Update the Advanced F&R document class when switching buffers.

(cherry picked from commit 944b0ae55dd89e48bf8845c6d5e08a73bd1c4917)

src/BufferParams.cpp
src/BufferParams.h
src/frontends/qt4/FindAndReplace.cpp
src/frontends/qt4/FindAndReplace.h
status.23x

index fc436e1f9ca69f1b889544ff6391a1bd8389399b..acf95207d1676905ae572bf817aa06d623666cf0 100644 (file)
@@ -3566,4 +3566,16 @@ void BufferParams::invalidateConverterCache() const
        pimpl_->isViewCacheValid = false;
 }
 
+
+// We shouldn't need to reset the params here, since anything
+// we need will be recopied.
+void BufferParams::copyForAdvFR(const BufferParams & bp)
+{
+       string const & lang = bp.language->lang();
+       setLanguage(lang);
+       layout_modules_ = bp.layout_modules_;
+       string const & doc_class = bp.documentClass().name();
+       setBaseClass(doc_class);
+}
+
 } // namespace lyx
index 9236d5b3875adda18d8961adef9f3d33aa23f773..23cd43546a08f168dc142bd96b7ba28bd4621dd7 100644 (file)
@@ -553,6 +553,10 @@ public:
        bool setLanguage(std::string const & lang);
        ///
        void invalidateConverterCache() const;
+       /// Copies over some of the settings from \param bp,
+       /// namely the ones need by Advanced F&R. We don't want
+       /// to copy them all, e.g., not the default master.
+       void copyForAdvFR(BufferParams const & bp);
 
 private:
        ///
@@ -616,7 +620,6 @@ private:
                static void destroy(Impl *);
        };
        support::copied_ptr<Impl, MemoryTraits> pimpl_;
-
 };
 
 } // namespace lyx
index 607f1653aac7afd1d43235497d9884355d47649e..96fcd588bdc77c896c3fec78139c0ed4f396b63a 100644 (file)
@@ -67,6 +67,8 @@ FindAndReplaceWidget::FindAndReplaceWidget(GuiView & view)
        // We don't want two cursors blinking.
        find_work_area_->stopBlinkingCaret();
        replace_work_area_->stopBlinkingCaret();
+       old_buffer_ = view_.documentBufferView() ? 
+           &(view_.documentBufferView()->buffer()) : 0;
 }
 
 
@@ -526,16 +528,12 @@ void FindAndReplaceWidget::on_replaceallPB_clicked()
 }
 
 
-/** Copy selected elements from bv's BufferParams to the dest_bv's one
- ** We don't want to copy'em all, e.g., not the default master **/
+// Copy selected elements from bv's BufferParams to the dest_bv's
 static void copy_params(BufferView const & bv, BufferView & dest_bv) {
        Buffer const & doc_buf = bv.buffer();
        BufferParams const & doc_bp = doc_buf.params();
-       string const & lang = doc_bp.language->lang();
-       string const & doc_class = doc_bp.documentClass().name();
        Buffer & dest_buf = dest_bv.buffer();
-       dest_buf.params().setLanguage(lang);
-       dest_buf.params().setBaseClass(doc_class);
+       dest_buf.params().copyForAdvFR(doc_bp);
        dest_bv.makeDocumentClass();
        dest_bv.cursor().current_font.setLanguage(doc_bp.language);
 }
@@ -609,8 +607,17 @@ bool FindAndReplace::initialiseParams(std::string const & params)
 
 void FindAndReplaceWidget::updateGUI()
 {
-       bool replace_enabled = view_.documentBufferView()
-               && !view_.documentBufferView()->buffer().isReadonly();
+       BufferView * bv = view_.documentBufferView();
+       if (bv) {
+               if (old_buffer_ != &bv->buffer()) {
+                               copy_params(*bv, find_work_area_->bufferView());
+                               copy_params(*bv, replace_work_area_->bufferView());
+                               old_buffer_ = &bv->buffer();
+               }
+       } else
+               old_buffer_ = 0;
+
+       bool const replace_enabled = bv && !bv->buffer().isReadonly();
        replace_work_area_->setEnabled(replace_enabled);
        replacePB->setEnabled(replace_enabled);
        replaceallPB->setEnabled(replace_enabled);
index 93af5357029f7107a5ebc74ac0e23cc6f029dd73..da854da7b73a79de46be1f6758fefd724efeb23d 100644 (file)
@@ -40,6 +40,8 @@ public Q_SLOTS:
 private:
        ///
        GuiView & view_;
+       ///
+       Buffer * old_buffer_;
 
        /// add a string to the combo if needed
        void remember(std::string const & find, QComboBox & combo);
index 36335aba2cecb6f41b275043e0abf6016f372d02..8f0ea4aa6ca047b27ff64d67752a356ae72f0065 100644 (file)
@@ -74,6 +74,7 @@ What's new
 
 * ADVANCED FIND AND REPLACE
 
+- Pay attention to layout modules in Advanced F&R (bug 11138).
 
 
 * BUILD/INSTALLATION