]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/FindAndReplace.cpp
On Linux show in crash message box the backtrace
[lyx.git] / src / frontends / qt4 / FindAndReplace.cpp
index a4e973ba79781ea42a3d5a8c96cd14874156bbd8..33098038ca7643235bb4f6e0d0c5ae030ce51f82 100644 (file)
 #include "qt_helpers.h"
 #include "Language.h"
 
+#include "Buffer.h"
 #include "BufferParams.h"
 #include "BufferList.h"
+#include "BufferView.h"
+#include "Text.h"
 #include "TextClass.h"
 #include "Cursor.h"
 #include "FuncRequest.h"
+#include "LyX.h"
 #include "lyxfind.h"
 
 #include "frontends/alert.h"
@@ -65,6 +69,18 @@ FindAndReplaceWidget::FindAndReplaceWidget(GuiView & view)
 }
 
 
+void FindAndReplaceWidget::dockLocationChanged(Qt::DockWidgetArea area)
+{
+       if (area == Qt::RightDockWidgetArea || area == Qt::LeftDockWidgetArea) {
+               dynamicLayoutBasic_->setDirection(QBoxLayout::TopToBottom);
+               dynamicLayoutAdvanced_->setDirection(QBoxLayout::TopToBottom);
+       } else {
+               dynamicLayoutBasic_->setDirection(QBoxLayout::LeftToRight);
+               dynamicLayoutAdvanced_->setDirection(QBoxLayout::LeftToRight);
+       }
+}
+
+
 bool FindAndReplaceWidget::eventFilter(QObject * obj, QEvent * event)
 {
        if (event->type() != QEvent::KeyPress
@@ -94,8 +110,8 @@ bool FindAndReplaceWidget::eventFilter(QObject * obj, QEvent * event)
                // back to how it was
                searchbackCB->setChecked(searchback);
                return true;
-               break;
-               }
+       }
+
        case Qt::Key_Tab:
                if (e->modifiers() == Qt::NoModifier) {
                        if (obj == find_work_area_){
@@ -130,12 +146,13 @@ bool FindAndReplaceWidget::eventFilter(QObject * obj, QEvent * event)
 
 static vector<string> const & allManualsFiles() 
 {
-       static vector<string> v;
        static const char * files[] = {
                "Intro", "UserGuide", "Tutorial", "Additional",
                "EmbeddedObjects", "Math", "Customization", "Shortcuts",
                "LFUNs", "LaTeXConfig"
        };
+
+       static vector<string> v;
        if (v.empty()) {
                FileName fname;
                for (size_t i = 0; i < sizeof(files) / sizeof(files[0]); ++i) {
@@ -143,11 +160,12 @@ static vector<string> const & allManualsFiles()
                        v.push_back(fname.absFileName());
                }
        }
+
        return v;
 }
 
 
-/** Switch p_buf to point to next document buffer.
+/** Switch buf to point to next document buffer.
  **
  ** Return true if restarted from master-document buffer.
  **/
@@ -157,7 +175,7 @@ static bool nextDocumentBuffer(Buffer * & buf)
        LYXERR(Debug::FIND, "children.size()=" << children.size());
        ListOfBuffers::const_iterator it =
                find(children.begin(), children.end(), buf);
-       LASSERT(it != children.end(), /**/);
+       LASSERT(it != children.end(), return false);
        ++it;
        if (it == children.end()) {
                buf = *children.begin();
@@ -178,7 +196,7 @@ static bool prevDocumentBuffer(Buffer * & buf)
        LYXERR(Debug::FIND, "children.size()=" << children.size());
        ListOfBuffers::const_iterator it =
                find(children.begin(), children.end(), buf);
-       LASSERT(it != children.end(), /**/)
+       LASSERT(it != children.end(), return false)
        if (it == children.begin()) {
                it = children.end();
                --it;
@@ -422,7 +440,13 @@ bool FindAndReplaceWidget::findAndReplace(
        else if (AllManualsRB->isChecked())
                scope = FindAndReplaceOptions::S_ALL_MANUALS;
        else
-               LASSERT(false, /**/);
+               LATTEST(false);
+
+       FindAndReplaceOptions::SearchRestriction restr =
+               OnlyMaths->isChecked()
+                       ? FindAndReplaceOptions::R_ONLY_MATHS
+                       : FindAndReplaceOptions::R_EVERYTHING;
+
        LYXERR(Debug::FIND, "FindAndReplaceOptions: "
               << "find_buf_name=" << find_buf_name
               << ", casesensitiv=" << casesensitive
@@ -432,10 +456,12 @@ bool FindAndReplaceWidget::findAndReplace(
               << ", ignoreformat=" << ignoreformat
               << ", repl_buf_name" << repl_buf_name
               << ", keep_case=" << keep_case
-              << ", scope=" << scope);
+              << ", scope=" << scope
+              << ", restr=" << restr);
+
        FindAndReplaceOptions opt(find_buf_name, casesensitive, matchword,
                                  !backwards, expandmacros, ignoreformat,
-                                 repl_buf_name, keep_case, scope);
+                                 repl_buf_name, keep_case, scope, restr);
        return findAndReplaceScope(opt, replace_all);
 }
 
@@ -503,7 +529,7 @@ static void copy_params(BufferView const & bv, BufferView & dest_bv) {
        Buffer & dest_buf = dest_bv.buffer();
        dest_buf.params().setLanguage(lang);
        dest_buf.params().setBaseClass(doc_class);
-       dest_buf.params().makeDocumentClass();
+       dest_bv.makeDocumentClass();
        dest_bv.cursor().current_font.setLanguage(doc_bp.language);
 }
 
@@ -555,6 +581,9 @@ FindAndReplace::FindAndReplace(GuiView & parent,
        widget_ = new FindAndReplaceWidget(parent);
        setWidget(widget_);
        setFocusProxy(widget_);
+
+       connect(this, SIGNAL(dockLocationChanged(Qt::DockWidgetArea)),
+               widget_, SLOT(dockLocationChanged(Qt::DockWidgetArea)));
 }