prepare splitting out c&p code

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@35696 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Peter Kümmel 2010-10-18 08:18:56 +00:00
parent 9229f495eb
commit 40d2aed83a

View File

@ -2825,6 +2825,7 @@ docstring GuiView::GuiViewPrivate::previewAndDestroy(Buffer const * orig, Buffer
#endif #endif
void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr) void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
{ {
BufferView * bv = currentBufferView(); BufferView * bv = currentBufferView();
@ -2874,81 +2875,104 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
case LFUN_BUFFER_UPDATE: { case LFUN_BUFFER_UPDATE: {
if (!doc_buffer) if (!doc_buffer)
break; break;
docstring msg = _("Exporting ...");
Buffer const * used_buffer = doc_buffer;
string format = argument; string format = argument;
if (argument.empty()) if (format.empty())
format = doc_buffer->getDefaultOutputFormat(); format = used_buffer->getDefaultOutputFormat();
#if EXPORT_in_THREAD && (QT_VERSION >= 0x040400) #if EXPORT_in_THREAD && (QT_VERSION >= 0x040400)
if (!msg.empty()) {
d.progress_->clearMessages(); d.progress_->clearMessages();
message(_("Exporting ...")); message(msg);
GuiViewPrivate::busyBuffers.insert(doc_buffer); }
QFuture<docstring> f = QtConcurrent::run(GuiViewPrivate::exportAndDestroy, GuiViewPrivate::busyBuffers.insert(used_buffer);
doc_buffer, doc_buffer->clone(), format); QFuture<docstring> f = QtConcurrent::run(
GuiViewPrivate::exportAndDestroy,
used_buffer,
used_buffer->clone(),
format);
d.setPreviewFuture(f); d.setPreviewFuture(f);
d.last_export_format = doc_buffer->bufferFormat(); d.last_export_format = used_buffer->bufferFormat();
#else #else
bool const update_unincluded = bool const update_unincluded =
doc_buffer->params().maintain_unincluded_children used_buffer->params().maintain_unincluded_children &&
&& !doc_buffer->params().getIncludedChildren().empty(); !used_buffer->params().getIncludedChildren().empty();
doc_buffer->doExport(format, true, update_unincluded); used_buffer->doExport(format, true, update_unincluded);
#endif #endif
break; break;
} }
case LFUN_BUFFER_VIEW: { case LFUN_BUFFER_VIEW: {
if (!doc_buffer) if (!doc_buffer)
break; break;
docstring msg = _("Previewing ...");
Buffer const * used_buffer = doc_buffer;
string format = argument; string format = argument;
if (argument.empty()) if (format.empty())
format = doc_buffer->getDefaultOutputFormat(); format = used_buffer->getDefaultOutputFormat();
#if EXPORT_in_THREAD && (QT_VERSION >= 0x040400) #if EXPORT_in_THREAD && (QT_VERSION >= 0x040400)
if (!msg.empty()) {
d.progress_->clearMessages(); d.progress_->clearMessages();
message(_("Previewing ...")); message(msg);
GuiViewPrivate::busyBuffers.insert(doc_buffer); }
QFuture<docstring> f = QtConcurrent::run(GuiViewPrivate::previewAndDestroy, GuiViewPrivate::busyBuffers.insert(used_buffer);
doc_buffer, doc_buffer->clone(), format); QFuture<docstring> f = QtConcurrent::run(
GuiViewPrivate::previewAndDestroy,
used_buffer,
used_buffer->clone(),
format);
d.setPreviewFuture(f); d.setPreviewFuture(f);
d.last_export_format = doc_buffer->bufferFormat(); d.last_export_format = used_buffer->bufferFormat();
#else #else
bool const update_unincluded = bool const update_unincluded =
doc_buffer->params().maintain_unincluded_children used_buffer->params().maintain_unincluded_children &&
&& !doc_buffer->params().getIncludedChildren().empty(); !used_buffer->params().getIncludedChildren().empty();
doc_buffer->preview(format, update_unincluded); used_buffer->preview(format, update_unincluded);
#endif #endif
break; break;
} }
case LFUN_MASTER_BUFFER_UPDATE: { case LFUN_MASTER_BUFFER_UPDATE: {
if (!doc_buffer) if (!doc_buffer)
break; break;
Buffer const * used_buffer = doc_buffer->masterBuffer();
string format = argument; string format = argument;
Buffer const * master = doc_buffer->masterBuffer(); if (format.empty())
if (argument.empty()) format = used_buffer->getDefaultOutputFormat();
format = master->getDefaultOutputFormat();
#if EXPORT_in_THREAD && (QT_VERSION >= 0x040400) #if EXPORT_in_THREAD && (QT_VERSION >= 0x040400)
GuiViewPrivate::busyBuffers.insert(master); GuiViewPrivate::busyBuffers.insert(used_buffer);
QFuture<docstring> f = QtConcurrent::run(GuiViewPrivate::exportAndDestroy, QFuture<docstring> f = QtConcurrent::run(
master, master->clone(), format); GuiViewPrivate::exportAndDestroy,
used_buffer,
used_buffer->clone(),
format);
d.setPreviewFuture(f); d.setPreviewFuture(f);
d.last_export_format = doc_buffer->bufferFormat(); d.last_export_format = used_buffer->bufferFormat();
#else #else
bool const update_unincluded = bool const update_unincluded =
master->params().maintain_unincluded_children used_buffer->params().maintain_unincluded_children &&
&& !master->params().getIncludedChildren().empty(); !used_buffer->params().getIncludedChildren().empty();
master->doExport(format, true); used_buffer->doExport(format, true);
#endif #endif
break; break;
} }
case LFUN_MASTER_BUFFER_VIEW: { case LFUN_MASTER_BUFFER_VIEW: {
if (!doc_buffer)
break;
Buffer const * used_buffer = doc_buffer->masterBuffer();
string format = argument; string format = argument;
Buffer const * master = doc_buffer->masterBuffer(); if (format.empty())
if (argument.empty()) format = used_buffer->getDefaultOutputFormat();
format = master->getDefaultOutputFormat();
#if EXPORT_in_THREAD && (QT_VERSION >= 0x040400) #if EXPORT_in_THREAD && (QT_VERSION >= 0x040400)
GuiViewPrivate::busyBuffers.insert(master); GuiViewPrivate::busyBuffers.insert(used_buffer);
QFuture<docstring> f = QtConcurrent::run(GuiViewPrivate::previewAndDestroy, QFuture<docstring> f = QtConcurrent::run(
master, master->clone(), format); GuiViewPrivate::previewAndDestroy,
used_buffer,
used_buffer->clone(),
format);
d.setPreviewFuture(f); d.setPreviewFuture(f);
d.last_export_format = doc_buffer->bufferFormat(); // TODO doc_buffer was used used? Was this this a copy & paste error?
d.last_export_format = used_buffer->bufferFormat();
#else #else
master->preview(format); used_buffer->preview(format);
#endif #endif
break; break;
} }