mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-27 03:36:39 +00:00
Create a new EmbeddedWorkArea for dialog embedding purpose and use that in FindAndReplace.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@27663 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
6b64fc8ca6
commit
5b02eaa5e8
@ -18,7 +18,6 @@
|
||||
#include "qt_helpers.h"
|
||||
|
||||
#include "Application.h"
|
||||
#include "BufferList.h"
|
||||
#include "buffer_funcs.h"
|
||||
#include "BufferParams.h"
|
||||
#include "Cursor.h"
|
||||
@ -51,26 +50,9 @@ FindAndReplace::FindAndReplace(GuiView & parent)
|
||||
parent_view_(parent),
|
||||
delayedFocusTimer_(this)
|
||||
{
|
||||
searchBuffer_ = theBufferList().newBuffer(
|
||||
support::FileName::tempName().absFilename() + "_searchadv.internal");
|
||||
LASSERT(searchBuffer_ != 0, /* */);
|
||||
searchBufferView_ = new BufferView(*searchBuffer_);
|
||||
searchBuffer_->setUnnamed(true);
|
||||
searchBuffer_->setFullyLoaded(true);
|
||||
|
||||
setupUi(this);
|
||||
find_work_area_->setGuiView(parent_view_);
|
||||
find_work_area_->setBuffer(*searchBuffer_);
|
||||
find_work_area_->setUpdatesEnabled(false);
|
||||
find_work_area_->setDialogMode(true);
|
||||
}
|
||||
|
||||
|
||||
FindAndReplace::~FindAndReplace()
|
||||
{
|
||||
// No need to destroy buffer and bufferview here, because it is done
|
||||
// in theBuffeerList() destruction loop at application exit
|
||||
LYXERR(Debug::DEBUG, "FindAndReplace::~FindAndReplace()");
|
||||
find_work_area_->init();
|
||||
}
|
||||
|
||||
|
||||
@ -120,31 +102,32 @@ void FindAndReplace::findAdv(bool casesensitive,
|
||||
bool matchword, bool backwards,
|
||||
bool expandmacros, bool ignoreformat)
|
||||
{
|
||||
Buffer & buffer = find_work_area_->bufferView().buffer();
|
||||
docstring searchString;
|
||||
if (! ignoreformat) {
|
||||
OutputParams runparams(&searchBuffer_->params().encoding());
|
||||
OutputParams runparams(&buffer.params().encoding());
|
||||
odocstringstream os;
|
||||
runparams.nice = true;
|
||||
runparams.flavor = OutputParams::LATEX;
|
||||
runparams.linelen = 80; //lyxrc.plaintext_linelen;
|
||||
// No side effect of file copying and image conversion
|
||||
runparams.dryrun = true;
|
||||
searchBuffer_->texrow().reset();
|
||||
// latexParagraphs(searchBuffer_, searchBuffer_.paragraphs(), os, searchBuffer_.texrow(), runparams);
|
||||
for (ParagraphList::const_iterator pit = searchBuffer_->paragraphs().begin(); pit != searchBuffer_->paragraphs().end(); ++pit) {
|
||||
TeXOnePar(*searchBuffer_, searchBuffer_->text(), pit, os, searchBuffer_->texrow(), runparams);
|
||||
buffer.texrow().reset();
|
||||
// latexParagraphs(buffer, buffer.paragraphs(), os, buffer.texrow(), runparams);
|
||||
for (ParagraphList::const_iterator pit = buffer.paragraphs().begin(); pit != buffer.paragraphs().end(); ++pit) {
|
||||
TeXOnePar(buffer, buffer.text(), pit, os, buffer.texrow(), runparams);
|
||||
lyxerr << "searchString up to here: " << to_utf8(os.str()) << std::endl;
|
||||
}
|
||||
searchString = os.str();
|
||||
} else {
|
||||
for (ParIterator it = searchBuffer_->par_iterator_begin(); it != searchBuffer_->par_iterator_end(); ++it) {
|
||||
for (ParIterator it = buffer.par_iterator_begin(); it != buffer.par_iterator_end(); ++it) {
|
||||
lyxerr << "Adding to search string: '" << to_utf8(it->asString(false)) << "'" << std::endl;
|
||||
searchString += it->asString(AS_STR_INSETS);
|
||||
}
|
||||
}
|
||||
// lyxerr << "Searching for '" << to_utf8(searchString) << "'" << std::endl;
|
||||
if (to_utf8(searchString).empty()) {
|
||||
searchBufferView_->message(_("Nothing to search"));
|
||||
buffer.message(_("Nothing to search"));
|
||||
return;
|
||||
}
|
||||
bool regexp = (to_utf8(searchString).find("\\regexp") != std::string::npos);
|
||||
|
@ -36,8 +36,6 @@ class FindAndReplace : public DockView, public Ui::FindAndReplaceUi
|
||||
public:
|
||||
FindAndReplace(GuiView & parent);
|
||||
|
||||
~FindAndReplace();
|
||||
|
||||
bool initialiseParams(std::string const &) { return true; }
|
||||
void clearParams() {}
|
||||
void dispatchParams() {}
|
||||
@ -72,9 +70,6 @@ private:
|
||||
|
||||
GuiView & parent_view_;
|
||||
|
||||
Buffer *searchBuffer_;
|
||||
BufferView *searchBufferView_;
|
||||
|
||||
GuiWorkArea * searchWorkArea_; // The work area defining what to search
|
||||
|
||||
/// @TODO: Investigate on focus issue and remove this ugly hack, please !
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "Menus.h"
|
||||
|
||||
#include "Buffer.h"
|
||||
#include "BufferList.h"
|
||||
#include "BufferParams.h"
|
||||
#include "BufferView.h"
|
||||
#include "CoordCache.h"
|
||||
@ -250,6 +251,7 @@ GuiWorkArea::GuiWorkArea(Buffer & buffer, GuiView & gv)
|
||||
{
|
||||
setGuiView(gv);
|
||||
setBuffer(buffer);
|
||||
init();
|
||||
}
|
||||
|
||||
|
||||
@ -342,7 +344,6 @@ void GuiWorkArea::setBuffer(Buffer & buffer)
|
||||
if (buffer.text().paragraphs().size() > 4)
|
||||
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
|
||||
QTimer::singleShot(50, this, SLOT(fixVerticalScrollBar()));
|
||||
init();
|
||||
}
|
||||
|
||||
|
||||
@ -1215,6 +1216,36 @@ bool GuiWorkArea::isFullScreen()
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// EmbeddedWorkArea
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
EmbeddedWorkArea::EmbeddedWorkArea(QWidget * w): GuiWorkArea(w)
|
||||
{
|
||||
buffer_ = theBufferList().newBuffer(
|
||||
support::FileName::tempName().absFilename() + "_embedded.internal");
|
||||
LASSERT(buffer_ != 0, /* */);
|
||||
|
||||
buffer_->setUnnamed(true);
|
||||
buffer_->setFullyLoaded(true);
|
||||
setBuffer(*buffer_);
|
||||
setUpdatesEnabled(false);
|
||||
setDialogMode(true);
|
||||
}
|
||||
|
||||
EmbeddedWorkArea::~EmbeddedWorkArea()
|
||||
{
|
||||
// No need to destroy buffer and bufferview here, because it is done
|
||||
// in theBuffeerList() destruction loop at application exit
|
||||
LYXERR(Debug::DEBUG, "FindAndReplace::~FindAndReplace()");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TabWorkArea
|
||||
|
@ -107,13 +107,12 @@ public:
|
||||
///
|
||||
~GuiWorkArea();
|
||||
|
||||
///
|
||||
void init();
|
||||
///
|
||||
void setBuffer(Buffer &);
|
||||
///
|
||||
void setGuiView(GuiView &);
|
||||
/// Dummy methods for Designer.
|
||||
void setWidgetResizable(bool) {}
|
||||
void setWidget(QWidget *) {}
|
||||
///
|
||||
void setFullScreen(bool full_screen);
|
||||
/// is LyXView in fullscreen mode?
|
||||
@ -170,8 +169,6 @@ private Q_SLOTS:
|
||||
|
||||
private:
|
||||
friend class GuiCompleter;
|
||||
///
|
||||
void init();
|
||||
|
||||
/// update the passed area.
|
||||
void update(int x, int y, int w, int h);
|
||||
@ -264,6 +261,24 @@ private:
|
||||
}; // GuiWorkArea
|
||||
|
||||
|
||||
class EmbeddedWorkArea : public GuiWorkArea
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
///
|
||||
EmbeddedWorkArea(QWidget *);
|
||||
~EmbeddedWorkArea();
|
||||
|
||||
/// Dummy methods for Designer.
|
||||
void setWidgetResizable(bool) {}
|
||||
void setWidget(QWidget *) {}
|
||||
|
||||
private:
|
||||
/// Embedded Buffer.
|
||||
Buffer * buffer_;
|
||||
}; // EmbeddedWorkArea
|
||||
|
||||
|
||||
/// A tabbed set of GuiWorkAreas.
|
||||
class TabWorkArea : public QTabWidget
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user