]> git.lyx.org Git - features.git/commitdiff
Added ALL_MANUALS scope to Advanced Find & Replace.
authorTommaso Cucinotta <tommaso@lyx.org>
Sat, 9 Jan 2010 22:49:35 +0000 (22:49 +0000)
committerTommaso Cucinotta <tommaso@lyx.org>
Sat, 9 Jan 2010 22:49:35 +0000 (22:49 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@32925 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/FindAndReplace.cpp
src/frontends/qt4/GuiWorkArea.cpp
src/frontends/qt4/ui/FindAndReplaceUi.ui
src/lyxfind.h

index 2eadfcd2d38afcdbd6c88a74808abc46e4740375..53a19b56b0dc39ec17bdf2be2e3276913db69ffb 100644 (file)
@@ -32,6 +32,7 @@
 #include "support/FileName.h"
 #include "support/gettext.h"
 #include "support/lassert.h"
+#include "support/filetools.h"
 
 #include <QCloseEvent>
 #include <QLineEdit>
@@ -125,6 +126,23 @@ static docstring buffer_to_latex(Buffer & buffer) {
 }
 
 
+static vector<string> const & allManualsFiles() {
+       static vector<string> v;
+       static const char * files[] = {
+               "Intro", "UserGuide", "Tutorial", "Additional", "EmbeddedObjects",
+               "Math", "Customization", "Shortcuts", "LFUNs", "LaTeXConfig"
+       };
+       if (v.empty()) {
+               FileName fname;
+               for (size_t i = 0; i < sizeof(files) / sizeof(files[0]); ++i) {
+                       fname = i18nLibFileSearch("doc", files[i], "lyx");
+                       v.push_back(fname.absFilename());
+               }
+       }
+       return v;
+}
+
+
 /** Switch p_buf to point to next document buffer.
  **
  ** Return true if restarted from master-document buffer.
@@ -220,6 +238,29 @@ static bool next_prev_buffer(Buffer * & buf, FindAndReplaceOptions const & opt)
                        restarted = buf == *(theBufferList().end() - 1);
                }
                break;
+       case FindAndReplaceOptions::S_ALL_MANUALS:
+               vector<string> const & v = allManualsFiles();
+               vector<string>::const_iterator it = find(v.begin(), v.end(), buf->absFileName());
+               if (it == v.end()) {
+                       it = v.begin();
+               } else if (opt.forward) {
+                       ++it;
+                       if (it == v.end()) {
+                               it = v.begin();
+                               restarted = true;
+                       }
+               } else {
+                       if (it == v.begin()) {
+                               it = v.end();
+                               restarted = true;
+                       }
+                       --it;
+               }
+               FileName const & fname = FileName(*it);
+               if (!theBufferList().exists(fname))
+                       guiApp->currentView()->loadDocument(fname, false);
+               buf = theBufferList().getBuffer(fname);
+               break;
        }
        return restarted;
 }
@@ -241,6 +282,9 @@ docstring question_string(FindAndReplaceOptions const & opt)
        case FindAndReplaceOptions::S_OPEN_BUFFERS:
                scope = _("open files");
                break;
+       case FindAndReplaceOptions::S_ALL_MANUALS:
+               scope = _("manuals");
+               break;
        }
        docstring dir = opt.forward ? _("forward") : _("backwards");
        return cur_pos + _(" of ") + scope
@@ -261,6 +305,21 @@ void FindAndReplaceWidget::findAndReplaceScope(FindAndReplaceOptions & opt) {
        Buffer * buf_orig = &bv->buffer();
        Cursor cur_orig(bv->cursor());
 
+       if (opt.scope == FindAndReplaceOptions::S_ALL_MANUALS) {
+               vector<string> const & v = allManualsFiles();
+               if (std::find(v.begin(), v.end(), buf->absFileName()) == v.end()) {
+                       FileName const & fname = FileName(*v.begin());
+                       if (!theBufferList().exists(fname))
+                               guiApp->currentView()->loadDocument(fname, false);
+                       buf = theBufferList().getBuffer(fname);
+                       lyx::dispatch(FuncRequest(LFUN_BUFFER_SWITCH,
+                                                 buf->absFileName()));
+                       bv = view_.documentBufferView();
+                       bv->cursor().clear();
+                       bv->cursor().push_back(CursorSlice(buf->inset()));
+               }
+       }
+
        do {
                LYXERR(Debug::FIND, "Dispatching LFUN_WORD_FINDADV");
                dispatch(cmd);
@@ -346,6 +405,8 @@ void FindAndReplaceWidget::findAndReplace(
                scope = FindAndReplaceOptions::S_DOCUMENT;
        else if (OpenDocuments->isChecked())
                scope = FindAndReplaceOptions::S_OPEN_BUFFERS;
+       else if (AllManualsRB->isChecked())
+               scope = FindAndReplaceOptions::S_ALL_MANUALS;
        else
                LASSERT(false, /**/);
        LYXERR(Debug::FIND, "FindAndReplaceOptions: "
index 08b935d9da43e5c562cf7dfeef41b156994e6672..fce8cf87e35ff8ac28d26a03825ee9d135b8c402 100644 (file)
@@ -1277,6 +1277,9 @@ void EmbeddedWorkArea::disable()
        stopBlinkingCursor();
        if (view().currentWorkArea() != this)
                return;
+       // No problem if currentMainWorkArea() is 0 (setCurrentWorkArea()
+       // tolerates it and shows the background logo), what happens if
+       // an EmbeddedWorkArea is closed after closing all document WAs
        view().setCurrentWorkArea(view().currentMainWorkArea());
 }
 
index 9fd9bed0cce38e32daf33f9dd6a9ed1f0998e019..cb84079ad84ae35e30f57c4f2e9b8ca48bf461ff 100644 (file)
                 <item row="4" column="0">
                  <widget class="QRadioButton" name="AllManualsRB">
                   <property name="enabled">
-                   <bool>false</bool>
+                   <bool>true</bool>
                   </property>
                   <property name="sizePolicy">
                    <sizepolicy>
index 7d660eed1180cc18959b6302c3f9d4c4a3806990..711bf8ee25aeae8ffc84ed7b336f096c1b61f8fd 100644 (file)
@@ -82,7 +82,7 @@ public:
                S_BUFFER,
                S_DOCUMENT,
                S_OPEN_BUFFERS,
-               /*S_ALL_MANUALS*/
+               S_ALL_MANUALS
        } SearchScope;
        FindAndReplaceOptions(
                docstring const & search,