static docstring autosaveAndDestroy(Buffer const * orig, Buffer * buffer);
template<class T>
- static Buffer::ExportStatus runAndDestroy(const T& func, Buffer const * orig, Buffer * buffer, string const & format, string const & msg);
+ static Buffer::ExportStatus runAndDestroy(const T& func, Buffer const * orig, Buffer * buffer, string const & format);
// TODO syncFunc/previewFunc: use bind
bool asyncBufferProcessing(string const & argument,
return areas;
}
-
-#if QT_VERSION >= 0x040400
-
-void GuiView::processingThreadStarted()
-{
-}
-
-
-void GuiView::processingThreadFinished(bool show_errors)
+static void handleExportStatus(GuiView * view, Buffer::ExportStatus status,
+ string const & format)
{
- QFutureWatcher<Buffer::ExportStatus> const * watcher =
- static_cast<QFutureWatcher<Buffer::ExportStatus> const *>(sender());
-
- Buffer::ExportStatus const status = watcher->result();
+ docstring const fmt = formats.prettyName(format);
docstring msg;
switch (status) {
case Buffer::ExportSuccess:
- msg = _("Successful export to format: %1$s");
+ msg = bformat(_("Successful export to format: %1$s"), fmt);
+ break;
+ case Buffer::ExportCancel:
+ msg = _("Document export cancelled.");
break;
case Buffer::ExportError:
case Buffer::ExportNoPathToFormat:
case Buffer::ExportTexPathHasSpaces:
case Buffer::ExportConverterError:
- msg = _("Error while exporting format: %1$s");
+ msg = bformat(_("Error while exporting format: %1$s"), fmt);
break;
case Buffer::PreviewSuccess:
- msg = _("Successful preview of format: %1$s");
+ msg = bformat(_("Successful preview of format: %1$s"), fmt);
break;
case Buffer::PreviewError:
- msg = _("Error while previewing format: %1$s");
+ msg = bformat(_("Error while previewing format: %1$s"), fmt);
break;
}
- message(bformat(msg, from_utf8(d.processing_format)));
-
- updateToolbars();
- if (show_errors) {
- BufferView const * const bv = currentBufferView();
- if (bv && !bv->buffer().errorList("Export").empty()) {
- errors("Export");
- return;
- }
- errors(d.last_export_format);
- }
+ view->message(msg);
}
-void GuiView::processingThreadFinished()
+#if QT_VERSION >= 0x040400
+
+void GuiView::processingThreadStarted()
{
- processingThreadFinished(true);
}
-void GuiView::autoSaveThreadFinished()
+void GuiView::processingThreadFinished()
{
- processingThreadFinished(false);
-}
+ QFutureWatcher<Buffer::ExportStatus> const * watcher =
+ static_cast<QFutureWatcher<Buffer::ExportStatus> const *>(sender());
-#else
+ Buffer::ExportStatus const status = watcher->result();
+ handleExportStatus(this, status, d.processing_format);
+
+ updateToolbars();
+ BufferView const * const bv = currentBufferView();
+ if (bv && !bv->buffer().errorList("Export").empty()) {
+ errors("Export");
+ return;
+ }
+ errors(d.last_export_format);
+}
-void GuiView::processingThreadStarted()
+void GuiView::autoSaveThreadFinished()
{
+ QFutureWatcher<docstring> const * watcher =
+ static_cast<QFutureWatcher<docstring> const *>(sender());
+ message(watcher->result());
+ updateToolbars();
}
+#else
-void GuiView::processingThreadFinished(bool)
+void GuiView::processingThreadStarted()
{
}
#if (QT_VERSION >= 0x040400)
docstring GuiView::GuiViewPrivate::autosaveAndDestroy(
- Buffer const * orig, Buffer * buffer)
+ Buffer const * orig, Buffer * clone)
{
- bool const success = buffer->autoSave();
- delete buffer;
+ bool const success = clone->autoSave();
+ delete clone;
busyBuffers.remove(orig);
return success
? _("Automatic save done.")
#if (QT_VERSION >= 0x040400)
template<class T>
-Buffer::ExportStatus GuiView::GuiViewPrivate::runAndDestroy(const T& func, Buffer const * orig, Buffer * buffer, string const & format, string const & msg)
+Buffer::ExportStatus GuiView::GuiViewPrivate::runAndDestroy(const T& func, Buffer const * orig, Buffer * clone, string const & format)
{
Buffer::ExportStatus const status = func(format);
// the cloning operation will have produced a clone of the entire set of
// documents, starting from the master. so we must delete those.
- Buffer * mbuf = const_cast<Buffer *>(buffer->masterBuffer());
+ Buffer * mbuf = const_cast<Buffer *>(clone->masterBuffer());
delete mbuf;
busyBuffers.remove(orig);
return status;
}
-Buffer::ExportStatus GuiView::GuiViewPrivate::compileAndDestroy(Buffer const * orig, Buffer * buffer, string const & format)
+Buffer::ExportStatus GuiView::GuiViewPrivate::compileAndDestroy(Buffer const * orig, Buffer * clone, string const & format)
{
Buffer::ExportStatus (Buffer::* mem_func)(std::string const &, bool) const = &Buffer::doExport;
- return runAndDestroy(bind(mem_func, buffer, _1, true), orig, buffer, format, "export");
+ return runAndDestroy(bind(mem_func, clone, _1, true), orig, clone, format);
}
-Buffer::ExportStatus GuiView::GuiViewPrivate::exportAndDestroy(Buffer const * orig, Buffer * buffer, string const & format)
+Buffer::ExportStatus GuiView::GuiViewPrivate::exportAndDestroy(Buffer const * orig, Buffer * clone, string const & format)
{
Buffer::ExportStatus (Buffer::* mem_func)(std::string const &, bool) const = &Buffer::doExport;
- return runAndDestroy(bind(mem_func, buffer, _1, false), orig, buffer, format, "export");
+ return runAndDestroy(bind(mem_func, clone, _1, false), orig, clone, format);
}
-Buffer::ExportStatus GuiView::GuiViewPrivate::previewAndDestroy(Buffer const * orig, Buffer * buffer, string const & format)
+Buffer::ExportStatus GuiView::GuiViewPrivate::previewAndDestroy(Buffer const * orig, Buffer * clone, string const & format)
{
Buffer::ExportStatus (Buffer::* mem_func)(std::string const &) const = &Buffer::preview;
- return runAndDestroy(bind(mem_func, buffer, _1), orig, buffer, format, "preview");
+ return runAndDestroy(bind(mem_func, clone, _1), orig, clone, format);
}
#else
string format = argument;
if (format.empty())
format = used_buffer->params().getDefaultOutputFormat();
-
+ processing_format = format;
#if EXPORT_in_THREAD && (QT_VERSION >= 0x040400)
if (!msg.empty()) {
progress_->clearMessages();
used_buffer->clone(),
format);
setPreviewFuture(f);
- processing_format = format;
last_export_format = used_buffer->params().bufferFormat();
(void) syncFunc;
(void) previewFunc;
// We are asynchronous, so we don't know here anything about the success
return true;
#else
+ Buffer::ExportStatus status;
if (syncFunc) {
// TODO check here if it breaks exporting with Qt < 4.4
- return (used_buffer->*syncFunc)(format, true);
+ status = (used_buffer->*syncFunc)(format, true);
} else if (previewFunc) {
- return (used_buffer->*previewFunc)(format, false);
- }
+ status = (used_buffer->*previewFunc)(format);
+ } else
+ return false;
+ handleExportStatus(gv_, status, format);
(void) asyncFunc;
- return false;
+ return (status == Buffer::ExportSuccess
+ || status == Buffer::PreviewSuccess);
#endif
}