mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-11 03:03:06 +00:00
Added ALL_MANUALS scope to Advanced Find & Replace.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@32925 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
389f85c038
commit
33e123a5cd
@ -32,6 +32,7 @@
|
|||||||
#include "support/FileName.h"
|
#include "support/FileName.h"
|
||||||
#include "support/gettext.h"
|
#include "support/gettext.h"
|
||||||
#include "support/lassert.h"
|
#include "support/lassert.h"
|
||||||
|
#include "support/filetools.h"
|
||||||
|
|
||||||
#include <QCloseEvent>
|
#include <QCloseEvent>
|
||||||
#include <QLineEdit>
|
#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.
|
/** Switch p_buf to point to next document buffer.
|
||||||
**
|
**
|
||||||
** Return true if restarted from master-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);
|
restarted = buf == *(theBufferList().end() - 1);
|
||||||
}
|
}
|
||||||
break;
|
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;
|
return restarted;
|
||||||
}
|
}
|
||||||
@ -241,6 +282,9 @@ docstring question_string(FindAndReplaceOptions const & opt)
|
|||||||
case FindAndReplaceOptions::S_OPEN_BUFFERS:
|
case FindAndReplaceOptions::S_OPEN_BUFFERS:
|
||||||
scope = _("open files");
|
scope = _("open files");
|
||||||
break;
|
break;
|
||||||
|
case FindAndReplaceOptions::S_ALL_MANUALS:
|
||||||
|
scope = _("manuals");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
docstring dir = opt.forward ? _("forward") : _("backwards");
|
docstring dir = opt.forward ? _("forward") : _("backwards");
|
||||||
return cur_pos + _(" of ") + scope
|
return cur_pos + _(" of ") + scope
|
||||||
@ -261,6 +305,21 @@ void FindAndReplaceWidget::findAndReplaceScope(FindAndReplaceOptions & opt) {
|
|||||||
Buffer * buf_orig = &bv->buffer();
|
Buffer * buf_orig = &bv->buffer();
|
||||||
Cursor cur_orig(bv->cursor());
|
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 {
|
do {
|
||||||
LYXERR(Debug::FIND, "Dispatching LFUN_WORD_FINDADV");
|
LYXERR(Debug::FIND, "Dispatching LFUN_WORD_FINDADV");
|
||||||
dispatch(cmd);
|
dispatch(cmd);
|
||||||
@ -346,6 +405,8 @@ void FindAndReplaceWidget::findAndReplace(
|
|||||||
scope = FindAndReplaceOptions::S_DOCUMENT;
|
scope = FindAndReplaceOptions::S_DOCUMENT;
|
||||||
else if (OpenDocuments->isChecked())
|
else if (OpenDocuments->isChecked())
|
||||||
scope = FindAndReplaceOptions::S_OPEN_BUFFERS;
|
scope = FindAndReplaceOptions::S_OPEN_BUFFERS;
|
||||||
|
else if (AllManualsRB->isChecked())
|
||||||
|
scope = FindAndReplaceOptions::S_ALL_MANUALS;
|
||||||
else
|
else
|
||||||
LASSERT(false, /**/);
|
LASSERT(false, /**/);
|
||||||
LYXERR(Debug::FIND, "FindAndReplaceOptions: "
|
LYXERR(Debug::FIND, "FindAndReplaceOptions: "
|
||||||
|
@ -1277,6 +1277,9 @@ void EmbeddedWorkArea::disable()
|
|||||||
stopBlinkingCursor();
|
stopBlinkingCursor();
|
||||||
if (view().currentWorkArea() != this)
|
if (view().currentWorkArea() != this)
|
||||||
return;
|
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());
|
view().setCurrentWorkArea(view().currentMainWorkArea());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -697,7 +697,7 @@
|
|||||||
<item row="4" column="0">
|
<item row="4" column="0">
|
||||||
<widget class="QRadioButton" name="AllManualsRB">
|
<widget class="QRadioButton" name="AllManualsRB">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>false</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy>
|
<sizepolicy>
|
||||||
|
@ -82,7 +82,7 @@ public:
|
|||||||
S_BUFFER,
|
S_BUFFER,
|
||||||
S_DOCUMENT,
|
S_DOCUMENT,
|
||||||
S_OPEN_BUFFERS,
|
S_OPEN_BUFFERS,
|
||||||
/*S_ALL_MANUALS*/
|
S_ALL_MANUALS
|
||||||
} SearchScope;
|
} SearchScope;
|
||||||
FindAndReplaceOptions(
|
FindAndReplaceOptions(
|
||||||
docstring const & search,
|
docstring const & search,
|
||||||
|
Loading…
Reference in New Issue
Block a user