3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Lars Gullik Bjønnes
8 * \author Abdelrazak Younes
11 * Full author contact details are available in file CREDITS.
19 #include "DispatchResult.h"
20 #include "FileDialog.h"
21 #include "FontLoader.h"
22 #include "GuiApplication.h"
23 #include "GuiCommandBuffer.h"
24 #include "GuiCompleter.h"
25 #include "GuiKeySymbol.h"
27 #include "GuiToolbar.h"
28 #include "GuiWorkArea.h"
29 #include "LayoutBox.h"
33 #include "qt_helpers.h"
35 #include "frontends/alert.h"
37 #include "buffer_funcs.h"
39 #include "BufferList.h"
40 #include "BufferParams.h"
41 #include "BufferView.h"
43 #include "Converter.h"
45 #include "CutAndPaste.h"
47 #include "ErrorList.h"
49 #include "FuncStatus.h"
50 #include "FuncRequest.h"
54 #include "LyXAction.h"
58 #include "Paragraph.h"
59 #include "SpellChecker.h"
60 #include "TextClass.h"
65 #include "support/convert.h"
66 #include "support/debug.h"
67 #include "support/ExceptionMessage.h"
68 #include "support/FileName.h"
69 #include "support/filetools.h"
70 #include "support/gettext.h"
71 #include "support/filetools.h"
72 #include "support/ForkedCalls.h"
73 #include "support/lassert.h"
74 #include "support/lstrings.h"
75 #include "support/os.h"
76 #include "support/Package.h"
77 #include "support/Path.h"
78 #include "support/Systemcall.h"
79 #include "support/Timeout.h"
80 #include "support/ProgressInterface.h"
81 #include "GuiProgress.h"
84 #include <QApplication>
85 #include <QCloseEvent>
87 #include <QDesktopWidget>
88 #include <QDragEnterEvent>
95 #include <QPixmapCache>
97 #include <QPushButton>
101 #include <QStackedWidget>
102 #include <QStatusBar>
107 #include <QScrollBar>
109 #define EXPORT_in_THREAD 1
112 // QtConcurrent was introduced in Qt 4.4
113 #if (QT_VERSION >= 0x040400)
115 #include <QFutureWatcher>
116 #include <QtConcurrentRun>
119 #include <boost/bind.hpp>
123 #ifdef HAVE_SYS_TIME_H
124 # include <sys/time.h>
131 using namespace lyx::support;
138 class BackgroundWidget : public QWidget
143 LYXERR(Debug::GUI, "show banner: " << lyxrc.show_banner);
144 /// The text to be written on top of the pixmap
145 QString const text = lyx_version ?
146 qt_("version ") + lyx_version : qt_("unknown version");
147 splash_ = getPixmap("images/", "banner", "png");
149 QPainter pain(&splash_);
150 pain.setPen(QColor(0, 0, 0));
152 // The font used to display the version info
153 font.setStyleHint(QFont::SansSerif);
154 font.setWeight(QFont::Bold);
155 font.setPointSize(int(toqstr(lyxrc.font_sizes[FONT_SIZE_LARGE]).toDouble()));
157 pain.drawText(260, 15, text);
158 setFocusPolicy(Qt::StrongFocus);
161 void paintEvent(QPaintEvent *)
163 int x = (width() - splash_.width()) / 2;
164 int y = (height() - splash_.height()) / 2;
166 pain.drawPixmap(x, y, splash_);
169 void keyPressEvent(QKeyEvent * ev)
172 setKeySymbol(&sym, ev);
174 guiApp->processKeySym(sym, q_key_state(ev->modifiers()));
186 /// Toolbar store providing access to individual toolbars by name.
187 typedef map<string, GuiToolbar *> ToolbarMap;
189 typedef boost::shared_ptr<Dialog> DialogPtr;
194 struct GuiView::GuiViewPrivate
196 GuiViewPrivate(GuiView * gv)
197 : gv_(gv), current_work_area_(0), current_main_work_area_(0),
198 layout_(0), autosave_timeout_(5000),
201 // hardcode here the platform specific icon size
202 smallIconSize = 14; // scaling problems
203 normalIconSize = 20; // ok, default
204 bigIconSize = 26; // better for some math icons
206 splitter_ = new QSplitter;
207 bg_widget_ = new BackgroundWidget;
208 stack_widget_ = new QStackedWidget;
209 stack_widget_->addWidget(bg_widget_);
210 stack_widget_->addWidget(splitter_);
212 progress_ = new GuiProgress(gv);
219 delete stack_widget_;
223 QMenu * toolBarPopup(GuiView * parent)
225 // FIXME: translation
226 QMenu * menu = new QMenu(parent);
227 QActionGroup * iconSizeGroup = new QActionGroup(parent);
229 QAction * smallIcons = new QAction(iconSizeGroup);
230 smallIcons->setText(qt_("Small-sized icons"));
231 smallIcons->setCheckable(true);
232 QObject::connect(smallIcons, SIGNAL(triggered()),
233 parent, SLOT(smallSizedIcons()));
234 menu->addAction(smallIcons);
236 QAction * normalIcons = new QAction(iconSizeGroup);
237 normalIcons->setText(qt_("Normal-sized icons"));
238 normalIcons->setCheckable(true);
239 QObject::connect(normalIcons, SIGNAL(triggered()),
240 parent, SLOT(normalSizedIcons()));
241 menu->addAction(normalIcons);
243 QAction * bigIcons = new QAction(iconSizeGroup);
244 bigIcons->setText(qt_("Big-sized icons"));
245 bigIcons->setCheckable(true);
246 QObject::connect(bigIcons, SIGNAL(triggered()),
247 parent, SLOT(bigSizedIcons()));
248 menu->addAction(bigIcons);
250 unsigned int cur = parent->iconSize().width();
251 if ( cur == parent->d.smallIconSize)
252 smallIcons->setChecked(true);
253 else if (cur == parent->d.normalIconSize)
254 normalIcons->setChecked(true);
255 else if (cur == parent->d.bigIconSize)
256 bigIcons->setChecked(true);
263 stack_widget_->setCurrentWidget(bg_widget_);
264 bg_widget_->setUpdatesEnabled(true);
265 bg_widget_->setFocus();
268 TabWorkArea * tabWorkArea(int i)
270 return dynamic_cast<TabWorkArea *>(splitter_->widget(i));
273 TabWorkArea * currentTabWorkArea()
275 if (splitter_->count() == 1)
276 // The first TabWorkArea is always the first one, if any.
277 return tabWorkArea(0);
279 for (int i = 0; i != splitter_->count(); ++i) {
280 TabWorkArea * twa = tabWorkArea(i);
281 if (current_main_work_area_ == twa->currentWorkArea())
285 // None has the focus so we just take the first one.
286 return tabWorkArea(0);
289 #if (QT_VERSION >= 0x040400)
290 void setPreviewFuture(QFuture<docstring> const & f)
292 if (preview_watcher_.isRunning()) {
293 // we prefer to cancel this preview in order to keep a snappy
297 preview_watcher_.setFuture(f);
303 GuiWorkArea * current_work_area_;
304 GuiWorkArea * current_main_work_area_;
305 QSplitter * splitter_;
306 QStackedWidget * stack_widget_;
307 BackgroundWidget * bg_widget_;
309 ToolbarMap toolbars_;
310 ProgressInterface* progress_;
311 /// The main layout box.
313 * \warning Don't Delete! The layout box is actually owned by
314 * whichever toolbar contains it. All the GuiView class needs is a
315 * means of accessing it.
317 * FIXME: replace that with a proper model so that we are not limited
318 * to only one dialog.
323 map<string, DialogPtr> dialogs_;
325 unsigned int smallIconSize;
326 unsigned int normalIconSize;
327 unsigned int bigIconSize;
329 QTimer statusbar_timer_;
330 /// auto-saving of buffers
331 Timeout autosave_timeout_;
332 /// flag against a race condition due to multiclicks, see bug #1119
336 TocModels toc_models_;
338 #if (QT_VERSION >= 0x040400)
340 QFutureWatcher<docstring> autosave_watcher_;
341 QFutureWatcher<docstring> preview_watcher_;
343 struct DummyWatcher { bool isRunning(){return false;} };
344 DummyWatcher preview_watcher_;
349 GuiView::GuiView(int id)
350 : d(*new GuiViewPrivate(this)), id_(id), closing_(false)
352 // GuiToolbars *must* be initialised before the menu bar.
353 normalSizedIcons(); // at least on Mac the default is 32 otherwise, which is huge
356 // set ourself as the current view. This is needed for the menu bar
357 // filling, at least for the static special menu item on Mac. Otherwise
358 // they are greyed out.
359 guiApp->setCurrentView(this);
361 // Fill up the menu bar.
362 guiApp->menus().fillMenuBar(menuBar(), this, true);
364 setCentralWidget(d.stack_widget_);
366 // Start autosave timer
367 if (lyxrc.autosave) {
368 d.autosave_timeout_.timeout.connect(boost::bind(&GuiView::autoSave, this));
369 d.autosave_timeout_.setTimeout(lyxrc.autosave * 1000);
370 d.autosave_timeout_.start();
372 connect(&d.statusbar_timer_, SIGNAL(timeout()),
373 this, SLOT(clearMessage()));
375 // We don't want to keep the window in memory if it is closed.
376 setAttribute(Qt::WA_DeleteOnClose, true);
378 #if (!defined(Q_WS_WIN) && !defined(Q_WS_MACX))
379 // assign an icon to main form. We do not do it under Qt/Win or Qt/Mac,
380 // since the icon is provided in the application bundle.
381 setWindowIcon(getPixmap("images/", "lyx", "png"));
384 #if (QT_VERSION >= 0x040300)
385 // use tabbed dock area for multiple docks
386 // (such as "source" and "messages")
387 setDockOptions(QMainWindow::ForceTabbedDocks);
391 setAcceptDrops(true);
393 statusBar()->setSizeGripEnabled(true);
396 #if (QT_VERSION >= 0x040400)
397 connect(&d.autosave_watcher_, SIGNAL(finished()), this,
398 SLOT(threadFinished()));
399 connect(&d.preview_watcher_, SIGNAL(finished()), this,
400 SLOT(threadFinished()));
403 connect(this, SIGNAL(triggerShowDialog(QString const &, QString const &, Inset *)),
404 SLOT(doShowDialog(QString const &, QString const &, Inset *)));
406 // Forbid too small unresizable window because it can happen
407 // with some window manager under X11.
408 setMinimumSize(300, 200);
410 if (lyxrc.allow_geometry_session) {
411 // Now take care of session management.
416 // no session handling, default to a sane size.
417 setGeometry(50, 50, 690, 510);
420 // clear session data if any.
422 settings.remove("views");
432 void GuiView::threadFinished()
434 #if (QT_VERSION >= 0x040400)
435 QFutureWatcher<docstring> const * watcher =
436 static_cast<QFutureWatcher<docstring> const *>(sender());
437 message(watcher->result());
442 void GuiView::saveLayout() const
445 settings.beginGroup("views");
446 settings.beginGroup(QString::number(id_));
448 settings.setValue("pos", pos());
449 settings.setValue("size", size());
451 settings.setValue("geometry", saveGeometry());
453 settings.setValue("layout", saveState(0));
454 settings.setValue("icon_size", iconSize());
458 bool GuiView::restoreLayout()
461 settings.beginGroup("views");
462 settings.beginGroup(QString::number(id_));
463 QString const icon_key = "icon_size";
464 if (!settings.contains(icon_key))
467 //code below is skipped when when ~/.config/LyX is (re)created
468 setIconSize(settings.value(icon_key).toSize());
470 QPoint pos = settings.value("pos", QPoint(50, 50)).toPoint();
471 QSize size = settings.value("size", QSize(690, 510)).toSize();
475 // Work-around for bug #6034: the window ends up in an undetermined
476 // state when trying to restore a maximized window when it is
477 // already maximized.
478 if (!(windowState() & Qt::WindowMaximized))
479 if (!restoreGeometry(settings.value("geometry").toByteArray()))
480 setGeometry(50, 50, 690, 510);
482 // Make sure layout is correctly oriented.
483 setLayoutDirection(qApp->layoutDirection());
485 // Allow the toc and view-source dock widget to be restored if needed.
487 if ((dialog = findOrBuild("toc", true)))
488 // see bug 5082. At least setup title and enabled state.
489 // Visibility will be adjusted by restoreState below.
490 dialog->prepareView();
491 if ((dialog = findOrBuild("view-source", true)))
492 dialog->prepareView();
493 if ((dialog = findOrBuild("progress", true)))
494 dialog->prepareView();
496 if (!restoreState(settings.value("layout").toByteArray(), 0))
503 GuiToolbar * GuiView::toolbar(string const & name)
505 ToolbarMap::iterator it = d.toolbars_.find(name);
506 if (it != d.toolbars_.end())
509 LYXERR(Debug::GUI, "Toolbar::display: no toolbar named " << name);
514 void GuiView::constructToolbars()
516 ToolbarMap::iterator it = d.toolbars_.begin();
517 for (; it != d.toolbars_.end(); ++it)
521 // I don't like doing this here, but the standard toolbar
522 // destroys this object when it's destroyed itself (vfr)
523 d.layout_ = new LayoutBox(*this);
524 d.stack_widget_->addWidget(d.layout_);
525 d.layout_->move(0,0);
527 // extracts the toolbars from the backend
528 Toolbars::Infos::iterator cit = guiApp->toolbars().begin();
529 Toolbars::Infos::iterator end = guiApp->toolbars().end();
530 for (; cit != end; ++cit)
531 d.toolbars_[cit->name] = new GuiToolbar(*cit, *this);
535 void GuiView::initToolbars()
537 // extracts the toolbars from the backend
538 Toolbars::Infos::iterator cit = guiApp->toolbars().begin();
539 Toolbars::Infos::iterator end = guiApp->toolbars().end();
540 for (; cit != end; ++cit) {
541 GuiToolbar * tb = toolbar(cit->name);
544 int const visibility = guiApp->toolbars().defaultVisibility(cit->name);
545 bool newline = !(visibility & Toolbars::SAMEROW);
546 tb->setVisible(false);
547 tb->setVisibility(visibility);
549 if (visibility & Toolbars::TOP) {
551 addToolBarBreak(Qt::TopToolBarArea);
552 addToolBar(Qt::TopToolBarArea, tb);
555 if (visibility & Toolbars::BOTTOM) {
556 // Qt < 4.2.2 cannot handle ToolBarBreak on non-TOP dock.
557 #if (QT_VERSION >= 0x040202)
559 addToolBarBreak(Qt::BottomToolBarArea);
561 addToolBar(Qt::BottomToolBarArea, tb);
564 if (visibility & Toolbars::LEFT) {
565 // Qt < 4.2.2 cannot handle ToolBarBreak on non-TOP dock.
566 #if (QT_VERSION >= 0x040202)
568 addToolBarBreak(Qt::LeftToolBarArea);
570 addToolBar(Qt::LeftToolBarArea, tb);
573 if (visibility & Toolbars::RIGHT) {
574 // Qt < 4.2.2 cannot handle ToolBarBreak on non-TOP dock.
575 #if (QT_VERSION >= 0x040202)
577 addToolBarBreak(Qt::RightToolBarArea);
579 addToolBar(Qt::RightToolBarArea, tb);
582 if (visibility & Toolbars::ON)
583 tb->setVisible(true);
588 TocModels & GuiView::tocModels()
590 return d.toc_models_;
594 void GuiView::setFocus()
596 LYXERR(Debug::DEBUG, "GuiView::setFocus()" << this);
597 QMainWindow::setFocus();
601 void GuiView::focusInEvent(QFocusEvent * e)
603 LYXERR(Debug::DEBUG, "GuiView::focusInEvent()" << this);
604 QMainWindow::focusInEvent(e);
605 // Make sure guiApp points to the correct view.
606 guiApp->setCurrentView(this);
607 if (currentMainWorkArea())
608 currentMainWorkArea()->setFocus();
609 else if (currentWorkArea())
610 currentWorkArea()->setFocus();
612 d.bg_widget_->setFocus();
616 QMenu * GuiView::createPopupMenu()
618 return d.toolBarPopup(this);
622 void GuiView::showEvent(QShowEvent * e)
624 LYXERR(Debug::GUI, "Passed Geometry "
625 << size().height() << "x" << size().width()
626 << "+" << pos().x() << "+" << pos().y());
628 if (d.splitter_->count() == 0)
629 // No work area, switch to the background widget.
632 QMainWindow::showEvent(e);
636 /** Destroy only all tabbed WorkAreas. Destruction of other WorkAreas
637 ** is responsibility of the container (e.g., dialog)
639 void GuiView::closeEvent(QCloseEvent * close_event)
641 LYXERR(Debug::DEBUG, "GuiView::closeEvent()");
646 // it can happen that this event arrives without selecting the view,
647 // e.g. when clicking the close button on a background window.
649 if (!closeWorkAreaAll()) {
651 close_event->ignore();
655 // Make sure that nothing will use this to be closed View.
656 guiApp->unregisterView(this);
658 if (isFullScreen()) {
659 // Switch off fullscreen before closing.
664 // Make sure the timer time out will not trigger a statusbar update.
665 d.statusbar_timer_.stop();
667 // Saving fullscreen requires additional tweaks in the toolbar code.
668 // It wouldn't also work under linux natively.
669 if (lyxrc.allow_geometry_session) {
670 // Save this window geometry and layout.
672 // Then the toolbar private states.
673 ToolbarMap::iterator end = d.toolbars_.end();
674 for (ToolbarMap::iterator it = d.toolbars_.begin(); it != end; ++it)
675 it->second->saveSession();
676 // Now take care of all other dialogs:
677 map<string, DialogPtr>::const_iterator it = d.dialogs_.begin();
678 for (; it!= d.dialogs_.end(); ++it)
679 it->second->saveSession();
682 close_event->accept();
686 void GuiView::dragEnterEvent(QDragEnterEvent * event)
688 if (event->mimeData()->hasUrls())
690 /// \todo Ask lyx-devel is this is enough:
691 /// if (event->mimeData()->hasFormat("text/plain"))
692 /// event->acceptProposedAction();
696 void GuiView::dropEvent(QDropEvent * event)
698 QList<QUrl> files = event->mimeData()->urls();
702 LYXERR(Debug::GUI, "GuiView::dropEvent: got URLs!");
703 for (int i = 0; i != files.size(); ++i) {
704 string const file = os::internal_path(fromqstr(
705 files.at(i).toLocalFile()));
709 string const ext = support::getExtension(file);
710 vector<const Format *> found_formats;
712 // Find all formats that have the correct extension.
713 vector<const Format *> const & import_formats
714 = theConverters().importableFormats();
715 vector<const Format *>::const_iterator it = import_formats.begin();
716 for (; it != import_formats.end(); ++it)
717 if ((*it)->extension() == ext)
718 found_formats.push_back(*it);
721 if (found_formats.size() >= 1) {
722 if (found_formats.size() > 1) {
723 //FIXME: show a dialog to choose the correct importable format
725 "Multiple importable formats found, selecting first");
727 string const arg = found_formats[0]->name() + " " + file;
728 cmd = FuncRequest(LFUN_BUFFER_IMPORT, arg);
731 //FIXME: do we have to explicitly check whether it's a lyx file?
733 "No formats found, trying to open it as a lyx file");
734 cmd = FuncRequest(LFUN_FILE_OPEN, file);
737 // Asynchronously post the event. DropEvent usually comes
738 // from the BufferView. But reloading a file might close
739 // the BufferView from within its own event handler.
740 guiApp->dispatchDelayed(cmd);
746 void GuiView::message(docstring const & str)
748 if (ForkedProcess::iAmAChild())
751 // call is moved to GUI-thread by GuiProgress
752 d.progress_->appendMessage(toqstr(str));
756 void GuiView::updateMessage(QString const & str)
758 statusBar()->showMessage(str);
759 d.statusbar_timer_.stop();
760 d.statusbar_timer_.start(3000);
764 void GuiView::smallSizedIcons()
766 setIconSize(QSize(d.smallIconSize, d.smallIconSize));
770 void GuiView::normalSizedIcons()
772 setIconSize(QSize(d.normalIconSize, d.normalIconSize));
776 void GuiView::bigSizedIcons()
778 setIconSize(QSize(d.bigIconSize, d.bigIconSize));
782 void GuiView::clearMessage()
784 // FIXME: This code was introduced in r19643 to fix bug #4123. However,
785 // the hasFocus function mostly returns false, even if the focus is on
786 // a workarea in this view.
790 d.statusbar_timer_.stop();
794 void GuiView::updateWindowTitle(GuiWorkArea * wa)
796 if (wa != d.current_work_area_
797 || wa->bufferView().buffer().isInternal())
799 setWindowTitle(qt_("LyX: ") + wa->windowTitle());
800 setWindowIconText(wa->windowIconText());
804 void GuiView::on_currentWorkAreaChanged(GuiWorkArea * wa)
807 disconnectBufferView();
808 connectBufferView(wa->bufferView());
809 connectBuffer(wa->bufferView().buffer());
810 d.current_work_area_ = wa;
811 QObject::connect(wa, SIGNAL(titleChanged(GuiWorkArea *)),
812 this, SLOT(updateWindowTitle(GuiWorkArea *)));
813 updateWindowTitle(wa);
817 // The document settings needs to be reinitialised.
818 updateDialog("document", "");
820 // Buffer-dependent dialogs must be updated. This is done here because
821 // some dialogs require buffer()->text.
826 void GuiView::on_lastWorkAreaRemoved()
829 // We already are in a close event. Nothing more to do.
832 if (d.splitter_->count() > 1)
833 // We have a splitter so don't close anything.
836 // Reset and updates the dialogs.
837 d.toc_models_.reset(0);
838 updateDialog("document", "");
841 resetWindowTitleAndIconText();
844 if (lyxrc.open_buffers_in_tabs)
845 // Nothing more to do, the window should stay open.
848 if (guiApp->viewIds().size() > 1) {
854 // On Mac we also close the last window because the application stay
855 // resident in memory. On other platforms we don't close the last
856 // window because this would quit the application.
862 void GuiView::updateStatusBar()
864 // let the user see the explicit message
865 if (d.statusbar_timer_.isActive())
872 void GuiView::showMessage()
874 QString msg = toqstr(theGuiApp()->viewStatusMessage());
876 BufferView const * bv = currentBufferView();
878 msg = toqstr(bv->cursor().currentState());
880 msg = qt_("Welcome to LyX!");
882 statusBar()->showMessage(msg);
886 bool GuiView::event(QEvent * e)
890 // Useful debug code:
891 //case QEvent::ActivationChange:
892 //case QEvent::WindowDeactivate:
893 //case QEvent::Paint:
894 //case QEvent::Enter:
895 //case QEvent::Leave:
896 //case QEvent::HoverEnter:
897 //case QEvent::HoverLeave:
898 //case QEvent::HoverMove:
899 //case QEvent::StatusTip:
900 //case QEvent::DragEnter:
901 //case QEvent::DragLeave:
905 case QEvent::WindowActivate: {
906 GuiView * old_view = guiApp->currentView();
907 if (this == old_view) {
909 return QMainWindow::event(e);
911 if (old_view && old_view->currentBufferView()) {
912 // save current selection to the selection buffer to allow
913 // middle-button paste in this window.
914 cap::saveSelection(old_view->currentBufferView()->cursor());
916 guiApp->setCurrentView(this);
917 if (d.current_work_area_) {
918 BufferView & bv = d.current_work_area_->bufferView();
919 connectBufferView(bv);
920 connectBuffer(bv.buffer());
921 // The document structure, name and dialogs might have
922 // changed in another view.
924 // The document settings needs to be reinitialised.
925 updateDialog("document", "");
928 resetWindowTitleAndIconText();
931 return QMainWindow::event(e);
934 case QEvent::ShortcutOverride: {
937 #if (!defined Q_WS_X11) || (QT_VERSION >= 0x040500)
938 if (isFullScreen() && menuBar()->isHidden()) {
939 QKeyEvent * ke = static_cast<QKeyEvent*>(e);
940 // FIXME: we should also try to detect special LyX shortcut such as
941 // Alt-P and Alt-M. Right now there is a hack in
942 // GuiWorkArea::processKeySym() that hides again the menubar for
944 if (ke->modifiers() & Qt::AltModifier && ke->key() != Qt::Key_Alt) {
946 return QMainWindow::event(e);
950 return QMainWindow::event(e);
954 return QMainWindow::event(e);
958 void GuiView::resetWindowTitleAndIconText()
960 setWindowTitle(qt_("LyX"));
961 setWindowIconText(qt_("LyX"));
964 bool GuiView::focusNextPrevChild(bool /*next*/)
971 void GuiView::setBusy(bool busy)
973 if (d.current_work_area_) {
974 d.current_work_area_->setUpdatesEnabled(!busy);
976 d.current_work_area_->stopBlinkingCursor();
978 d.current_work_area_->startBlinkingCursor();
982 QApplication::setOverrideCursor(Qt::WaitCursor);
984 QApplication::restoreOverrideCursor();
988 GuiWorkArea * GuiView::workArea(Buffer & buffer)
990 if (currentWorkArea()
991 && ¤tWorkArea()->bufferView().buffer() == &buffer)
992 return (GuiWorkArea *) currentWorkArea();
993 if (TabWorkArea * twa = d.currentTabWorkArea())
994 return twa->workArea(buffer);
999 GuiWorkArea * GuiView::addWorkArea(Buffer & buffer)
1001 // Automatically create a TabWorkArea if there are none yet.
1002 TabWorkArea * tab_widget = d.splitter_->count()
1003 ? d.currentTabWorkArea() : addTabWorkArea();
1004 return tab_widget->addWorkArea(buffer, *this);
1008 TabWorkArea * GuiView::addTabWorkArea()
1010 TabWorkArea * twa = new TabWorkArea;
1011 QObject::connect(twa, SIGNAL(currentWorkAreaChanged(GuiWorkArea *)),
1012 this, SLOT(on_currentWorkAreaChanged(GuiWorkArea *)));
1013 QObject::connect(twa, SIGNAL(lastWorkAreaRemoved()),
1014 this, SLOT(on_lastWorkAreaRemoved()));
1016 d.splitter_->addWidget(twa);
1017 d.stack_widget_->setCurrentWidget(d.splitter_);
1022 GuiWorkArea const * GuiView::currentWorkArea() const
1024 return d.current_work_area_;
1028 GuiWorkArea * GuiView::currentWorkArea()
1030 return d.current_work_area_;
1034 GuiWorkArea const * GuiView::currentMainWorkArea() const
1036 if (d.currentTabWorkArea() == NULL)
1038 return d.currentTabWorkArea()->currentWorkArea();
1042 GuiWorkArea * GuiView::currentMainWorkArea()
1044 if (d.currentTabWorkArea() == NULL)
1046 return d.currentTabWorkArea()->currentWorkArea();
1050 void GuiView::setCurrentWorkArea(GuiWorkArea * wa)
1052 LYXERR(Debug::DEBUG, "Setting current wa: " << wa << endl);
1054 d.current_work_area_ = NULL;
1058 GuiWorkArea * old_gwa = theGuiApp()->currentView()->currentWorkArea();
1062 if (currentBufferView())
1063 cap::saveSelection(currentBufferView()->cursor());
1065 theGuiApp()->setCurrentView(this);
1066 d.current_work_area_ = wa;
1067 for (int i = 0; i != d.splitter_->count(); ++i) {
1068 if (d.tabWorkArea(i)->setCurrentWorkArea(wa)) {
1069 //if (d.current_main_work_area_)
1070 // d.current_main_work_area_->setFrameStyle(QFrame::NoFrame);
1071 d.current_main_work_area_ = wa;
1072 //d.current_main_work_area_->setFrameStyle(QFrame::Box | QFrame::Plain);
1073 //d.current_main_work_area_->setLineWidth(2);
1074 LYXERR(Debug::DEBUG, "Current wa: " << currentWorkArea() << ", Current main wa: " << currentMainWorkArea());
1078 LYXERR(Debug::DEBUG, "This is not a tabbed wa");
1079 on_currentWorkAreaChanged(wa);
1080 BufferView & bv = wa->bufferView();
1081 bv.cursor().fixIfBroken();
1083 wa->setUpdatesEnabled(true);
1084 LYXERR(Debug::DEBUG, "Current wa: " << currentWorkArea() << ", Current main wa: " << currentMainWorkArea());
1088 void GuiView::removeWorkArea(GuiWorkArea * wa)
1090 LASSERT(wa, return);
1091 if (wa == d.current_work_area_) {
1093 disconnectBufferView();
1094 d.current_work_area_ = 0;
1095 d.current_main_work_area_ = 0;
1098 bool found_twa = false;
1099 for (int i = 0; i != d.splitter_->count(); ++i) {
1100 TabWorkArea * twa = d.tabWorkArea(i);
1101 if (twa->removeWorkArea(wa)) {
1102 // Found in this tab group, and deleted the GuiWorkArea.
1104 if (twa->count() != 0) {
1105 if (d.current_work_area_ == 0)
1106 // This means that we are closing the current GuiWorkArea, so
1107 // switch to the next GuiWorkArea in the found TabWorkArea.
1108 setCurrentWorkArea(twa->currentWorkArea());
1110 // No more WorkAreas in this tab group, so delete it.
1117 // It is not a tabbed work area (i.e., the search work area), so it
1118 // should be deleted by other means.
1119 LASSERT(found_twa, /* */);
1121 if (d.current_work_area_ == 0) {
1122 if (d.splitter_->count() != 0) {
1123 TabWorkArea * twa = d.currentTabWorkArea();
1124 setCurrentWorkArea(twa->currentWorkArea());
1126 // No more work areas, switch to the background widget.
1127 setCurrentWorkArea(0);
1133 LayoutBox * GuiView::getLayoutDialog() const
1139 void GuiView::updateLayoutList()
1142 d.layout_->updateContents(false);
1146 void GuiView::updateToolbars()
1148 ToolbarMap::iterator end = d.toolbars_.end();
1149 if (d.current_work_area_) {
1151 d.current_work_area_->bufferView().cursor().inMathed();
1153 lyx::getStatus(FuncRequest(LFUN_LAYOUT_TABULAR)).enabled();
1155 lyx::getStatus(FuncRequest(LFUN_CHANGES_TRACK)).enabled() &&
1156 lyx::getStatus(FuncRequest(LFUN_CHANGES_TRACK)).onoff(true);
1157 bool const mathmacrotemplate =
1158 lyx::getStatus(FuncRequest(LFUN_IN_MATHMACROTEMPLATE)).enabled();
1160 for (ToolbarMap::iterator it = d.toolbars_.begin(); it != end; ++it)
1161 it->second->update(math, table, review, mathmacrotemplate);
1163 for (ToolbarMap::iterator it = d.toolbars_.begin(); it != end; ++it)
1164 it->second->update(false, false, false, false);
1168 void GuiView::setBuffer(Buffer * newBuffer)
1170 LYXERR(Debug::DEBUG, "Setting buffer: " << newBuffer << endl);
1171 LASSERT(newBuffer, return);
1174 GuiWorkArea * wa = workArea(*newBuffer);
1176 newBuffer->masterBuffer()->updateLabels();
1177 wa = addWorkArea(*newBuffer);
1179 //Disconnect the old buffer...there's no new one.
1182 connectBuffer(*newBuffer);
1183 connectBufferView(wa->bufferView());
1184 setCurrentWorkArea(wa);
1190 void GuiView::connectBuffer(Buffer & buf)
1192 buf.setGuiDelegate(this);
1196 void GuiView::disconnectBuffer()
1198 if (d.current_work_area_)
1199 d.current_work_area_->bufferView().buffer().setGuiDelegate(0);
1203 void GuiView::connectBufferView(BufferView & bv)
1205 bv.setGuiDelegate(this);
1209 void GuiView::disconnectBufferView()
1211 if (d.current_work_area_)
1212 d.current_work_area_->bufferView().setGuiDelegate(0);
1216 void GuiView::errors(string const & error_type, bool from_master)
1218 ErrorList & el = from_master ?
1219 documentBufferView()->buffer().masterBuffer()->errorList(error_type)
1220 : documentBufferView()->buffer().errorList(error_type);
1221 string data = error_type;
1223 data = "from_master|" + error_type;
1225 showDialog("errorlist", data);
1229 void GuiView::updateTocItem(string const & type, DocIterator const & dit)
1231 d.toc_models_.updateItem(toqstr(type), dit);
1235 void GuiView::structureChanged()
1237 d.toc_models_.reset(documentBufferView());
1238 // Navigator needs more than a simple update in this case. It needs to be
1240 updateDialog("toc", "");
1244 void GuiView::updateDialog(string const & name, string const & data)
1246 if (!isDialogVisible(name))
1249 map<string, DialogPtr>::const_iterator it = d.dialogs_.find(name);
1250 if (it == d.dialogs_.end())
1253 Dialog * const dialog = it->second.get();
1254 if (dialog->isVisibleView())
1255 dialog->initialiseParams(data);
1259 BufferView * GuiView::documentBufferView()
1261 return currentMainWorkArea()
1262 ? ¤tMainWorkArea()->bufferView()
1267 BufferView const * GuiView::documentBufferView() const
1269 return currentMainWorkArea()
1270 ? ¤tMainWorkArea()->bufferView()
1275 BufferView * GuiView::currentBufferView()
1277 return d.current_work_area_ ? &d.current_work_area_->bufferView() : 0;
1281 BufferView const * GuiView::currentBufferView() const
1283 return d.current_work_area_ ? &d.current_work_area_->bufferView() : 0;
1287 #if (QT_VERSION >= 0x040400)
1288 static docstring saveAndDestroyBuffer(Buffer * buffer, FileName const & fname)
1291 FileName const tmp_ret = FileName::tempName("lyxauto");
1292 if (!tmp_ret.empty()) {
1293 if (buffer->writeFile(tmp_ret))
1294 failed = !tmp_ret.moveTo(fname);
1297 // failed to write/rename tmp_ret so try writing direct
1298 failed = buffer->writeFile(fname);
1302 ? _("Automatic save failed!")
1303 : _("Automatic save done.");
1308 void GuiView::autoSave()
1310 LYXERR(Debug::INFO, "Running autoSave()");
1312 Buffer * buffer = documentBufferView()
1313 ? &documentBufferView()->buffer() : 0;
1317 #if (QT_VERSION >= 0x040400)
1318 QFuture<docstring> f = QtConcurrent::run(saveAndDestroyBuffer, buffer->clone(),
1319 buffer->getAutosaveFilename());
1320 d.autosave_watcher_.setFuture(f);
1327 void GuiView::resetAutosaveTimers()
1330 d.autosave_timeout_.restart();
1334 bool GuiView::getStatus(FuncRequest const & cmd, FuncStatus & flag)
1337 Buffer * buf = currentBufferView()
1338 ? ¤tBufferView()->buffer() : 0;
1339 Buffer * doc_buffer = documentBufferView()
1340 ? &(documentBufferView()->buffer()) : 0;
1342 // Check whether we need a buffer
1343 if (!lyxaction.funcHasFlag(cmd.action, LyXAction::NoBuffer) && !buf) {
1344 // no, exit directly
1345 flag.message(from_utf8(N_("Command not allowed with"
1346 "out any document open")));
1347 flag.setEnabled(false);
1351 if (cmd.origin == FuncRequest::TOC) {
1352 GuiToc * toc = static_cast<GuiToc*>(findOrBuild("toc", false));
1354 if (toc->getStatus(documentBufferView()->cursor(), cmd, fs))
1357 flag.setEnabled(false);
1361 switch(cmd.action) {
1362 case LFUN_BUFFER_IMPORT:
1365 case LFUN_MASTER_BUFFER_UPDATE:
1366 case LFUN_MASTER_BUFFER_VIEW:
1367 enable = doc_buffer && doc_buffer->parent() != 0
1368 && !d.preview_watcher_.isRunning();
1371 case LFUN_BUFFER_UPDATE:
1372 case LFUN_BUFFER_VIEW: {
1373 if (!doc_buffer || d.preview_watcher_.isRunning()) {
1377 string format = to_utf8(cmd.argument());
1378 if (cmd.argument().empty())
1379 format = doc_buffer->getDefaultOutputFormat();
1380 enable = doc_buffer->isExportableFormat(format);
1384 case LFUN_BUFFER_RELOAD:
1385 enable = doc_buffer && !doc_buffer->isUnnamed()
1386 && doc_buffer->fileName().exists()
1387 && (!doc_buffer->isClean()
1388 || doc_buffer->isExternallyModified(Buffer::timestamp_method));
1391 case LFUN_BUFFER_CHILD_OPEN:
1392 enable = doc_buffer;
1395 case LFUN_BUFFER_WRITE:
1396 enable = doc_buffer && (doc_buffer->isUnnamed() || !doc_buffer->isClean());
1399 //FIXME: This LFUN should be moved to GuiApplication.
1400 case LFUN_BUFFER_WRITE_ALL: {
1401 // We enable the command only if there are some modified buffers
1402 Buffer * first = theBufferList().first();
1407 // We cannot use a for loop as the buffer list is a cycle.
1409 if (!b->isClean()) {
1413 b = theBufferList().next(b);
1414 } while (b != first);
1418 case LFUN_BUFFER_WRITE_AS:
1419 enable = doc_buffer;
1422 case LFUN_BUFFER_CLOSE:
1423 enable = doc_buffer;
1426 case LFUN_BUFFER_CLOSE_ALL:
1427 enable = theBufferList().last() != theBufferList().first();
1430 case LFUN_SPLIT_VIEW:
1431 if (cmd.getArg(0) == "vertical")
1432 enable = doc_buffer && (d.splitter_->count() == 1 ||
1433 d.splitter_->orientation() == Qt::Vertical);
1435 enable = doc_buffer && (d.splitter_->count() == 1 ||
1436 d.splitter_->orientation() == Qt::Horizontal);
1439 case LFUN_CLOSE_TAB_GROUP:
1440 enable = d.currentTabWorkArea();
1443 case LFUN_TOOLBAR_TOGGLE: {
1444 string const name = cmd.getArg(0);
1445 if (GuiToolbar * t = toolbar(name))
1446 flag.setOnOff(t->isVisible());
1449 docstring const msg =
1450 bformat(_("Unknown toolbar \"%1$s\""), from_utf8(name));
1456 case LFUN_DROP_LAYOUTS_CHOICE:
1460 case LFUN_UI_TOGGLE:
1461 flag.setOnOff(isFullScreen());
1464 case LFUN_DIALOG_DISCONNECT_INSET:
1467 case LFUN_DIALOG_HIDE:
1468 // FIXME: should we check if the dialog is shown?
1471 case LFUN_DIALOG_TOGGLE:
1472 flag.setOnOff(isDialogVisible(cmd.getArg(0)));
1473 // fall through to set "enable"
1474 case LFUN_DIALOG_SHOW: {
1475 string const name = cmd.getArg(0);
1477 enable = name == "aboutlyx"
1478 || name == "file" //FIXME: should be removed.
1480 || name == "texinfo"
1481 || name == "progress"
1482 || name == "compare";
1483 else if (name == "print")
1484 enable = doc_buffer->isExportable("dvi")
1485 && lyxrc.print_command != "none";
1486 else if (name == "character" || name == "symbols") {
1487 if (!buf || buf->isReadonly()
1488 || !currentBufferView()->cursor().inTexted())
1491 // FIXME we should consider passthru
1493 Inset const & in = currentBufferView()->cursor().inset();
1494 enable = !in.getLayout().isPassThru();
1497 else if (name == "latexlog")
1498 enable = FileName(doc_buffer->logName()).isReadableFile();
1499 else if (name == "spellchecker")
1500 enable = theSpellChecker() && !doc_buffer->isReadonly();
1501 else if (name == "vclog")
1502 enable = doc_buffer->lyxvc().inUse();
1506 case LFUN_DIALOG_UPDATE: {
1507 string const name = cmd.getArg(0);
1509 enable = name == "prefs";
1513 case LFUN_COMMAND_EXECUTE:
1515 case LFUN_MENU_OPEN:
1516 // Nothing to check.
1519 case LFUN_COMPLETION_INLINE:
1520 if (!d.current_work_area_
1521 || !d.current_work_area_->completer().inlinePossible(
1522 currentBufferView()->cursor()))
1526 case LFUN_COMPLETION_POPUP:
1527 if (!d.current_work_area_
1528 || !d.current_work_area_->completer().popupPossible(
1529 currentBufferView()->cursor()))
1533 case LFUN_COMPLETION_COMPLETE:
1534 if (!d.current_work_area_
1535 || !d.current_work_area_->completer().inlinePossible(
1536 currentBufferView()->cursor()))
1540 case LFUN_COMPLETION_ACCEPT:
1541 if (!d.current_work_area_
1542 || (!d.current_work_area_->completer().popupVisible()
1543 && !d.current_work_area_->completer().inlineVisible()
1544 && !d.current_work_area_->completer().completionAvailable()))
1548 case LFUN_COMPLETION_CANCEL:
1549 if (!d.current_work_area_
1550 || (!d.current_work_area_->completer().popupVisible()
1551 && !d.current_work_area_->completer().inlineVisible()))
1555 case LFUN_BUFFER_ZOOM_OUT:
1556 enable = doc_buffer && lyxrc.zoom > 10;
1559 case LFUN_BUFFER_ZOOM_IN:
1560 enable = doc_buffer;
1563 case LFUN_BUFFER_NEXT:
1564 case LFUN_BUFFER_PREVIOUS:
1565 // FIXME: should we check is there is an previous or next buffer?
1567 case LFUN_BUFFER_SWITCH:
1568 // toggle on the current buffer, but do not toggle off
1569 // the other ones (is that a good idea?)
1571 && to_utf8(cmd.argument()) == doc_buffer->absFileName())
1572 flag.setOnOff(true);
1575 case LFUN_VC_REGISTER:
1576 enable = doc_buffer && !doc_buffer->lyxvc().inUse();
1578 case LFUN_VC_CHECK_IN:
1579 enable = doc_buffer && doc_buffer->lyxvc().checkInEnabled();
1581 case LFUN_VC_CHECK_OUT:
1582 enable = doc_buffer && doc_buffer->lyxvc().checkOutEnabled();
1584 case LFUN_VC_LOCKING_TOGGLE:
1585 enable = doc_buffer && !doc_buffer->isReadonly()
1586 && doc_buffer->lyxvc().lockingToggleEnabled();
1587 flag.setOnOff(enable && doc_buffer->lyxvc().locking());
1589 case LFUN_VC_REVERT:
1590 enable = doc_buffer && doc_buffer->lyxvc().inUse();
1592 case LFUN_VC_UNDO_LAST:
1593 enable = doc_buffer && doc_buffer->lyxvc().undoLastEnabled();
1595 case LFUN_VC_REPO_UPDATE:
1596 enable = doc_buffer && doc_buffer->lyxvc().inUse();
1598 case LFUN_VC_COMMAND: {
1599 if (cmd.argument().empty())
1601 if (!doc_buffer && contains(cmd.getArg(0), 'D'))
1605 case LFUN_VC_COMPARE:
1606 enable = doc_buffer && !cmd.argument().empty()
1607 && doc_buffer->lyxvc().prepareFileRevisionEnabled();
1610 case LFUN_SERVER_GOTO_FILE_ROW:
1618 flag.setEnabled(false);
1624 static FileName selectTemplateFile()
1626 FileDialog dlg(qt_("Select template file"));
1627 dlg.setButton1(qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
1628 dlg.setButton1(qt_("Templates|#T#t"), toqstr(lyxrc.template_path));
1630 FileDialog::Result result = dlg.open(toqstr(lyxrc.template_path),
1631 QStringList(qt_("LyX Documents (*.lyx)")));
1633 if (result.first == FileDialog::Later)
1635 if (result.second.isEmpty())
1637 return FileName(fromqstr(result.second));
1641 Buffer * GuiView::loadDocument(FileName const & filename, bool tolastfiles)
1645 Buffer * newBuffer = checkAndLoadLyXFile(filename);
1648 message(_("Document not loaded."));
1653 setBuffer(newBuffer);
1655 // scroll to the position when the file was last closed
1656 if (lyxrc.use_lastfilepos) {
1657 LastFilePosSection::FilePos filepos =
1658 theSession().lastFilePos().load(filename);
1659 documentBufferView()->moveToPosition(filepos.pit, filepos.pos, 0, 0);
1663 theSession().lastFiles().add(filename);
1670 void GuiView::openDocument(string const & fname)
1672 string initpath = lyxrc.document_path;
1674 if (documentBufferView()) {
1675 string const trypath = documentBufferView()->buffer().filePath();
1676 // If directory is writeable, use this as default.
1677 if (FileName(trypath).isDirWritable())
1683 if (fname.empty()) {
1684 FileDialog dlg(qt_("Select document to open"), LFUN_FILE_OPEN);
1685 dlg.setButton1(qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
1686 dlg.setButton2(qt_("Examples|#E#e"),
1687 toqstr(addPath(package().system_support().absFilename(), "examples")));
1689 QStringList filter(qt_("LyX Documents (*.lyx)"));
1690 filter << qt_("LyX-1.3.x Documents (*.lyx13)")
1691 << qt_("LyX-1.4.x Documents (*.lyx14)")
1692 << qt_("LyX-1.5.x Documents (*.lyx15)")
1693 << qt_("LyX-1.6.x Documents (*.lyx16)");
1694 FileDialog::Result result =
1695 dlg.open(toqstr(initpath), filter);
1697 if (result.first == FileDialog::Later)
1700 filename = fromqstr(result.second);
1702 // check selected filename
1703 if (filename.empty()) {
1704 message(_("Canceled."));
1710 // get absolute path of file and add ".lyx" to the filename if
1712 FileName const fullname =
1713 fileSearch(string(), filename, "lyx", support::may_not_exist);
1714 if (!fullname.empty())
1715 filename = fullname.absFilename();
1717 if (!fullname.onlyPath().isDirectory()) {
1718 Alert::warning(_("Invalid filename"),
1719 bformat(_("The directory in the given path\n%1$s\ndoes not exist."),
1720 from_utf8(fullname.absFilename())));
1723 // if the file doesn't exist, let the user create one
1724 if (!fullname.exists()) {
1725 // the user specifically chose this name. Believe him.
1726 Buffer * const b = newFile(filename, string(), true);
1732 docstring const disp_fn = makeDisplayPath(filename);
1733 message(bformat(_("Opening document %1$s..."), disp_fn));
1736 Buffer * buf = loadDocument(fullname);
1738 buf->updateLabels();
1740 buf->errors("Parse");
1741 str2 = bformat(_("Document %1$s opened."), disp_fn);
1742 if (buf->lyxvc().inUse())
1743 str2 += " " + from_utf8(buf->lyxvc().versionString()) +
1744 " " + _("Version control detected.");
1746 str2 = bformat(_("Could not open document %1$s"), disp_fn);
1751 // FIXME: clean that
1752 static bool import(GuiView * lv, FileName const & filename,
1753 string const & format, ErrorList & errorList)
1755 FileName const lyxfile(support::changeExtension(filename.absFilename(), ".lyx"));
1757 string loader_format;
1758 vector<string> loaders = theConverters().loaders();
1759 if (find(loaders.begin(), loaders.end(), format) == loaders.end()) {
1760 for (vector<string>::const_iterator it = loaders.begin();
1761 it != loaders.end(); ++it) {
1762 if (!theConverters().isReachable(format, *it))
1765 string const tofile =
1766 support::changeExtension(filename.absFilename(),
1767 formats.extension(*it));
1768 if (!theConverters().convert(0, filename, FileName(tofile),
1769 filename, format, *it, errorList))
1771 loader_format = *it;
1774 if (loader_format.empty()) {
1775 frontend::Alert::error(_("Couldn't import file"),
1776 bformat(_("No information for importing the format %1$s."),
1777 formats.prettyName(format)));
1781 loader_format = format;
1783 if (loader_format == "lyx") {
1784 Buffer * buf = lv->loadDocument(lyxfile);
1787 buf->updateLabels();
1789 buf->errors("Parse");
1791 Buffer * const b = newFile(lyxfile.absFilename(), string(), true);
1795 bool as_paragraphs = loader_format == "textparagraph";
1796 string filename2 = (loader_format == format) ? filename.absFilename()
1797 : support::changeExtension(filename.absFilename(),
1798 formats.extension(loader_format));
1799 lv->currentBufferView()->insertPlaintextFile(FileName(filename2),
1801 guiApp->setCurrentView(lv);
1802 lyx::dispatch(FuncRequest(LFUN_MARK_OFF));
1809 void GuiView::importDocument(string const & argument)
1812 string filename = split(argument, format, ' ');
1814 LYXERR(Debug::INFO, format << " file: " << filename);
1816 // need user interaction
1817 if (filename.empty()) {
1818 string initpath = lyxrc.document_path;
1819 if (documentBufferView()) {
1820 string const trypath = documentBufferView()->buffer().filePath();
1821 // If directory is writeable, use this as default.
1822 if (FileName(trypath).isDirWritable())
1826 docstring const text = bformat(_("Select %1$s file to import"),
1827 formats.prettyName(format));
1829 FileDialog dlg(toqstr(text), LFUN_BUFFER_IMPORT);
1830 dlg.setButton1(qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
1831 dlg.setButton2(qt_("Examples|#E#e"),
1832 toqstr(addPath(package().system_support().absFilename(), "examples")));
1834 docstring filter = formats.prettyName(format);
1837 filter += from_utf8(formats.extension(format));
1840 FileDialog::Result result =
1841 dlg.open(toqstr(initpath), fileFilters(toqstr(filter)));
1843 if (result.first == FileDialog::Later)
1846 filename = fromqstr(result.second);
1848 // check selected filename
1849 if (filename.empty())
1850 message(_("Canceled."));
1853 if (filename.empty())
1856 // get absolute path of file
1857 FileName const fullname(support::makeAbsPath(filename));
1859 FileName const lyxfile(support::changeExtension(fullname.absFilename(), ".lyx"));
1861 // Check if the document already is open
1862 Buffer * buf = theBufferList().getBuffer(lyxfile);
1865 if (!closeBuffer()) {
1866 message(_("Canceled."));
1871 docstring const displaypath = makeDisplayPath(lyxfile.absFilename(), 30);
1873 // if the file exists already, and we didn't do
1874 // -i lyx thefile.lyx, warn
1875 if (lyxfile.exists() && fullname != lyxfile) {
1877 docstring text = bformat(_("The document %1$s already exists.\n\n"
1878 "Do you want to overwrite that document?"), displaypath);
1879 int const ret = Alert::prompt(_("Overwrite document?"),
1880 text, 0, 1, _("&Overwrite"), _("&Cancel"));
1883 message(_("Canceled."));
1888 message(bformat(_("Importing %1$s..."), displaypath));
1889 ErrorList errorList;
1890 if (import(this, fullname, format, errorList))
1891 message(_("imported."));
1893 message(_("file not imported!"));
1895 // FIXME (Abdel 12/08/06): Is there a need to display the error list here?
1899 void GuiView::newDocument(string const & filename, bool from_template)
1901 FileName initpath(lyxrc.document_path);
1902 if (documentBufferView()) {
1903 FileName const trypath(documentBufferView()->buffer().filePath());
1904 // If directory is writeable, use this as default.
1905 if (trypath.isDirWritable())
1909 string templatefile;
1910 if (from_template) {
1911 templatefile = selectTemplateFile().absFilename();
1912 if (templatefile.empty())
1917 if (filename.empty())
1918 b = newUnnamedFile(initpath, to_utf8(_("newfile")), templatefile);
1920 b = newFile(filename, templatefile, true);
1925 // If no new document could be created, it is unsure
1926 // whether there is a valid BufferView.
1927 if (currentBufferView())
1928 // Ensure the cursor is correctly positioned on screen.
1929 currentBufferView()->showCursor();
1933 void GuiView::insertLyXFile(docstring const & fname)
1935 BufferView * bv = documentBufferView();
1940 FileName filename(to_utf8(fname));
1942 if (!filename.empty()) {
1943 bv->insertLyXFile(filename);
1947 // Launch a file browser
1949 string initpath = lyxrc.document_path;
1950 string const trypath = bv->buffer().filePath();
1951 // If directory is writeable, use this as default.
1952 if (FileName(trypath).isDirWritable())
1956 FileDialog dlg(qt_("Select LyX document to insert"), LFUN_FILE_INSERT);
1957 dlg.setButton1(qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
1958 dlg.setButton2(qt_("Examples|#E#e"),
1959 toqstr(addPath(package().system_support().absFilename(),
1962 FileDialog::Result result = dlg.open(toqstr(initpath),
1963 QStringList(qt_("LyX Documents (*.lyx)")));
1965 if (result.first == FileDialog::Later)
1969 filename.set(fromqstr(result.second));
1971 // check selected filename
1972 if (filename.empty()) {
1973 // emit message signal.
1974 message(_("Canceled."));
1978 bv->insertLyXFile(filename);
1982 void GuiView::insertPlaintextFile(docstring const & fname,
1985 BufferView * bv = documentBufferView();
1989 if (!fname.empty() && !FileName::isAbsolute(to_utf8(fname))) {
1990 message(_("Absolute filename expected."));
1995 FileName filename(to_utf8(fname));
1997 if (!filename.empty()) {
1998 bv->insertPlaintextFile(filename, asParagraph);
2002 FileDialog dlg(qt_("Select file to insert"), (asParagraph ?
2003 LFUN_FILE_INSERT_PLAINTEXT_PARA : LFUN_FILE_INSERT_PLAINTEXT));
2005 FileDialog::Result result = dlg.open(toqstr(bv->buffer().filePath()),
2006 QStringList(qt_("All Files (*)")));
2008 if (result.first == FileDialog::Later)
2012 filename.set(fromqstr(result.second));
2014 // check selected filename
2015 if (filename.empty()) {
2016 // emit message signal.
2017 message(_("Canceled."));
2021 bv->insertPlaintextFile(filename, asParagraph);
2025 bool GuiView::renameBuffer(Buffer & b, docstring const & newname)
2027 FileName fname = b.fileName();
2028 FileName const oldname = fname;
2030 if (!newname.empty()) {
2032 fname = support::makeAbsPath(to_utf8(newname), oldname.onlyPath().absFilename());
2034 // Switch to this Buffer.
2037 // No argument? Ask user through dialog.
2039 FileDialog dlg(qt_("Choose a filename to save document as"),
2040 LFUN_BUFFER_WRITE_AS);
2041 dlg.setButton1(qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
2042 dlg.setButton2(qt_("Templates|#T#t"), toqstr(lyxrc.template_path));
2044 if (!isLyXFilename(fname.absFilename()))
2045 fname.changeExtension(".lyx");
2047 FileDialog::Result result =
2048 dlg.save(toqstr(fname.onlyPath().absFilename()),
2049 QStringList(qt_("LyX Documents (*.lyx)")),
2050 toqstr(fname.onlyFileName()));
2052 if (result.first == FileDialog::Later)
2055 fname.set(fromqstr(result.second));
2060 if (!isLyXFilename(fname.absFilename()))
2061 fname.changeExtension(".lyx");
2064 if (FileName(fname).exists()) {
2065 docstring const file = makeDisplayPath(fname.absFilename(), 30);
2066 docstring text = bformat(_("The document %1$s already "
2067 "exists.\n\nDo you want to "
2068 "overwrite that document?"),
2070 int const ret = Alert::prompt(_("Overwrite document?"),
2071 text, 0, 2, _("&Overwrite"), _("&Rename"), _("&Cancel"));
2074 case 1: return renameBuffer(b, docstring());
2075 case 2: return false;
2079 FileName oldauto = b.getAutosaveFilename();
2081 // Ok, change the name of the buffer
2082 b.setFileName(fname.absFilename());
2084 bool unnamed = b.isUnnamed();
2085 b.setUnnamed(false);
2086 b.saveCheckSum(fname);
2088 // bring the autosave file with us, just in case.
2089 b.moveAutosaveFile(oldauto);
2091 if (!saveBuffer(b)) {
2092 oldauto = b.getAutosaveFilename();
2093 b.setFileName(oldname.absFilename());
2094 b.setUnnamed(unnamed);
2095 b.saveCheckSum(oldname);
2096 b.moveAutosaveFile(oldauto);
2104 bool GuiView::saveBuffer(Buffer & b)
2106 if (workArea(b) && workArea(b)->inDialogMode())
2110 return renameBuffer(b, docstring());
2113 theSession().lastFiles().add(b.fileName());
2117 // Switch to this Buffer.
2120 // FIXME: we don't tell the user *WHY* the save failed !!
2121 docstring const file = makeDisplayPath(b.absFileName(), 30);
2122 docstring text = bformat(_("The document %1$s could not be saved.\n\n"
2123 "Do you want to rename the document and "
2124 "try again?"), file);
2125 int const ret = Alert::prompt(_("Rename and save?"),
2126 text, 0, 2, _("&Rename"), _("&Retry"), _("&Cancel"));
2129 if (!renameBuffer(b, docstring()))
2138 return saveBuffer(b);
2142 bool GuiView::hideWorkArea(GuiWorkArea * wa)
2144 return closeWorkArea(wa, false);
2148 bool GuiView::closeWorkArea(GuiWorkArea * wa)
2150 Buffer & buf = wa->bufferView().buffer();
2151 return closeWorkArea(wa, !buf.parent());
2155 bool GuiView::closeBuffer()
2157 GuiWorkArea * wa = currentMainWorkArea();
2158 setCurrentWorkArea(wa);
2159 Buffer & buf = wa->bufferView().buffer();
2160 return wa && closeWorkArea(wa, !buf.parent());
2164 void GuiView::writeSession() const {
2165 GuiWorkArea const * active_wa = currentMainWorkArea();
2166 for (int i = 0; i < d.splitter_->count(); ++i) {
2167 TabWorkArea * twa = d.tabWorkArea(i);
2168 for (int j = 0; j < twa->count(); ++j) {
2169 GuiWorkArea * wa = static_cast<GuiWorkArea *>(twa->widget(j));
2170 Buffer & buf = wa->bufferView().buffer();
2171 theSession().lastOpened().add(buf.fileName(), wa == active_wa);
2177 bool GuiView::closeBufferAll()
2179 // Close the workareas in all other views
2180 QList<int> const ids = guiApp->viewIds();
2181 for (int i = 0; i != ids.size(); ++i) {
2182 if (id_ != ids[i] && !guiApp->view(ids[i]).closeWorkAreaAll())
2186 // Close our own workareas
2187 if (!closeWorkAreaAll())
2190 // Now close the hidden buffers. We prevent hidden buffers from being
2191 // dirty, so we can just close them.
2192 theBufferList().closeAll();
2197 bool GuiView::closeWorkAreaAll()
2199 setCurrentWorkArea(currentMainWorkArea());
2201 // We might be in a situation that there is still a tabWorkArea, but
2202 // there are no tabs anymore. This can happen when we get here after a
2203 // TabWorkArea::lastWorkAreaRemoved() signal. Therefore we count how
2204 // many TabWorkArea's have no documents anymore.
2207 // We have to call count() each time, because it can happen that
2208 // more than one splitter will disappear in one iteration (bug 5998).
2209 for (; d.splitter_->count() > empty_twa; ) {
2210 TabWorkArea * twa = d.tabWorkArea(empty_twa);
2212 if (twa->count() == 0)
2215 setCurrentWorkArea(twa->currentWorkArea());
2216 if (!closeTabWorkArea(twa))
2224 bool GuiView::closeWorkArea(GuiWorkArea * wa, bool close_buffer)
2229 Buffer & buf = wa->bufferView().buffer();
2232 return closeBuffer(buf);
2234 if (!inMultiTabs(wa))
2235 if (!saveBufferIfNeeded(buf, true))
2243 bool GuiView::closeBuffer(Buffer & buf)
2245 // If we are in a close_event all children will be closed in some time,
2246 // so no need to do it here. This will ensure that the children end up
2247 // in the session file in the correct order. If we close the master
2248 // buffer, we can close or release the child buffers here too.
2250 vector<Buffer *> clist = buf.getChildren(false);
2251 for (vector<Buffer *>::const_iterator it = clist.begin();
2252 it != clist.end(); ++it) {
2253 // If a child is dirty, do not close
2254 // without user intervention
2255 //FIXME: should we look in other tabworkareas?
2256 Buffer * child_buf = *it;
2257 GuiWorkArea * child_wa = workArea(*child_buf);
2259 if (!closeWorkArea(child_wa, true))
2262 theBufferList().releaseChild(&buf, child_buf);
2265 // goto bookmark to update bookmark pit.
2266 //FIXME: we should update only the bookmarks related to this buffer!
2267 LYXERR(Debug::DEBUG, "GuiView::closeBuffer()");
2268 for (size_t i = 0; i < theSession().bookmarks().size(); ++i)
2269 guiApp->gotoBookmark(i+1, false, false);
2271 if (saveBufferIfNeeded(buf, false)) {
2272 theBufferList().release(&buf);
2279 bool GuiView::closeTabWorkArea(TabWorkArea * twa)
2281 while (twa == d.currentTabWorkArea()) {
2282 twa->setCurrentIndex(twa->count()-1);
2284 GuiWorkArea * wa = twa->currentWorkArea();
2285 Buffer & b = wa->bufferView().buffer();
2287 // We only want to close the buffer if the same buffer is not visible
2288 // in another view, and if this is not a child and if we are closing
2289 // a view (not a tabgroup).
2290 bool const close_buffer =
2291 !inMultiViews(wa) && !b.parent() && closing_;
2293 if (!closeWorkArea(wa, close_buffer))
2300 bool GuiView::saveBufferIfNeeded(Buffer & buf, bool hiding)
2302 if (buf.isClean() || buf.paragraphs().empty())
2305 // Switch to this Buffer.
2310 if (buf.isUnnamed())
2311 file = from_utf8(buf.fileName().onlyFileName());
2313 file = buf.fileName().displayName(30);
2315 // Bring this window to top before asking questions.
2320 if (hiding && buf.isUnnamed()) {
2321 docstring const text = bformat(_("The document %1$s has not been "
2322 "saved yet.\n\nDo you want to save "
2323 "the document?"), file);
2324 ret = Alert::prompt(_("Save new document?"),
2325 text, 0, 1, _("&Save"), _("&Cancel"));
2329 docstring const text = bformat(_("The document %1$s has unsaved changes."
2330 "\n\nDo you want to save the document or discard the changes?"), file);
2331 ret = Alert::prompt(_("Save changed document?"),
2332 text, 0, 2, _("&Save"), _("&Discard"), _("&Cancel"));
2337 if (!saveBuffer(buf))
2341 // if we crash after this we could
2342 // have no autosave file but I guess
2343 // this is really improbable (Jug)
2344 buf.removeAutosaveFile();
2346 // revert all changes
2357 bool GuiView::inMultiTabs(GuiWorkArea * wa)
2359 Buffer & buf = wa->bufferView().buffer();
2361 for (int i = 0; i != d.splitter_->count(); ++i) {
2362 GuiWorkArea * wa_ = d.tabWorkArea(i)->workArea(buf);
2363 if (wa_ && wa_ != wa)
2366 return inMultiViews(wa);
2370 bool GuiView::inMultiViews(GuiWorkArea * wa)
2372 QList<int> const ids = guiApp->viewIds();
2373 Buffer & buf = wa->bufferView().buffer();
2376 for (int i = 0; i != ids.size() && found_twa <= 1; ++i) {
2380 if (guiApp->view(ids[i]).workArea(buf))
2387 void GuiView::gotoNextOrPreviousBuffer(NextOrPrevious np)
2389 Buffer * const curbuf = documentBufferView()
2390 ? &documentBufferView()->buffer() : 0;
2391 Buffer * nextbuf = curbuf;
2393 if (np == NEXTBUFFER)
2394 nextbuf = theBufferList().next(nextbuf);
2396 nextbuf = theBufferList().previous(nextbuf);
2397 if (nextbuf == curbuf)
2403 if (workArea(*nextbuf))
2410 /// make sure the document is saved
2411 static bool ensureBufferClean(Buffer * buffer)
2413 LASSERT(buffer, return false);
2414 if (buffer->isClean() && !buffer->isUnnamed())
2417 docstring const file = buffer->fileName().displayName(30);
2420 if (!buffer->isUnnamed()) {
2421 text = bformat(_("The document %1$s has unsaved "
2422 "changes.\n\nDo you want to save "
2423 "the document?"), file);
2424 title = _("Save changed document?");
2427 text = bformat(_("The document %1$s has not been "
2428 "saved yet.\n\nDo you want to save "
2429 "the document?"), file);
2430 title = _("Save new document?");
2432 int const ret = Alert::prompt(title, text, 0, 1, _("&Save"), _("&Cancel"));
2435 dispatch(FuncRequest(LFUN_BUFFER_WRITE));
2437 return buffer->isClean() && !buffer->isUnnamed();
2441 void GuiView::reloadBuffer()
2443 Buffer * buf = &documentBufferView()->buffer();
2448 void GuiView::checkExternallyModifiedBuffers()
2450 BufferList::iterator bit = theBufferList().begin();
2451 BufferList::iterator const bend = theBufferList().end();
2452 for (; bit != bend; ++bit) {
2453 if ((*bit)->fileName().exists()
2454 && (*bit)->isExternallyModified(Buffer::checksum_method)) {
2455 docstring text = bformat(_("Document \n%1$s\n has been externally modified."
2456 " Reload now? Any local changes will be lost."),
2457 from_utf8((*bit)->absFileName()));
2458 int const ret = Alert::prompt(_("Reload externally changed document?"),
2459 text, 0, 1, _("&Reload"), _("&Cancel"));
2467 //FIXME use a DispatchResult object to transmit messages
2468 void GuiView::dispatchVC(FuncRequest const & cmd)
2470 // message for statusbar
2472 Buffer * buffer = documentBufferView()
2473 ? &(documentBufferView()->buffer()) : 0;
2475 switch (cmd.action) {
2476 case LFUN_VC_REGISTER:
2477 if (!buffer || !ensureBufferClean(buffer))
2479 if (!buffer->lyxvc().inUse()) {
2480 if (buffer->lyxvc().registrer())
2485 case LFUN_VC_CHECK_IN:
2486 if (!buffer || !ensureBufferClean(buffer))
2488 if (buffer->lyxvc().inUse() && !buffer->isReadonly()) {
2489 msg = buffer->lyxvc().checkIn();
2495 case LFUN_VC_CHECK_OUT:
2496 if (!buffer || !ensureBufferClean(buffer))
2498 if (buffer->lyxvc().inUse()) {
2499 msg = buffer->lyxvc().checkOut();
2504 case LFUN_VC_LOCKING_TOGGLE:
2505 LASSERT(buffer, return);
2506 if (!ensureBufferClean(buffer) || buffer->isReadonly())
2508 if (buffer->lyxvc().inUse()) {
2509 string res = buffer->lyxvc().lockingToggle();
2511 frontend::Alert::error(_("Revision control error."),
2512 _("Error when setting the locking property."));
2520 case LFUN_VC_REVERT:
2521 LASSERT(buffer, return);
2522 buffer->lyxvc().revert();
2526 case LFUN_VC_UNDO_LAST:
2527 LASSERT(buffer, return);
2528 buffer->lyxvc().undoLast();
2532 case LFUN_VC_REPO_UPDATE:
2533 LASSERT(buffer, return);
2534 if (ensureBufferClean(buffer)) {
2535 msg = buffer->lyxvc().repoUpdate();
2536 checkExternallyModifiedBuffers();
2540 case LFUN_VC_COMMAND: {
2541 string flag = cmd.getArg(0);
2542 if (buffer && contains(flag, 'R') && !ensureBufferClean(buffer))
2545 if (contains(flag, 'M')) {
2546 if (!Alert::askForText(message, _("LyX VC: Log Message")))
2549 string path = cmd.getArg(1);
2550 if (contains(path, "$$p") && buffer)
2551 path = subst(path, "$$p", buffer->filePath());
2552 LYXERR(Debug::LYXVC, "Directory: " << path);
2554 if (!pp.isReadableDirectory()) {
2555 lyxerr << _("Directory is not accessible.") << endl;
2558 support::PathChanger p(pp);
2560 string command = cmd.getArg(2);
2561 if (command.empty())
2564 command = subst(command, "$$i", buffer->absFileName());
2565 command = subst(command, "$$p", buffer->filePath());
2567 command = subst(command, "$$m", to_utf8(message));
2568 LYXERR(Debug::LYXVC, "Command: " << command);
2570 one.startscript(Systemcall::Wait, command);
2574 if (contains(flag, 'I'))
2575 buffer->markDirty();
2576 if (contains(flag, 'R'))
2582 case LFUN_VC_COMPARE: {
2584 string rev1 = cmd.getArg(0);
2588 if (!buffer->lyxvc().prepareFileRevision(rev1, f1))
2591 if (isStrInt(rev1) && convert<int>(rev1) <= 0) {
2592 f2 = buffer->absFileName();
2594 string rev2 = cmd.getArg(1);
2598 if (!buffer->lyxvc().prepareFileRevision(rev2, f2))
2601 // FIXME We need to call comparison feature here.
2602 // This is quick and dirty code for testing VC.
2603 // We need that comparison feature has some LFUN_COMPARE <FLAG> file1 file1
2604 FileName initpath(lyxrc.document_path);
2605 Buffer * dest = newUnnamedFile(initpath, to_utf8(_("differences")));
2606 CompareOptions options;
2607 Compare * compare = new Compare(loadIfNeeded(FileName(f1)), loadIfNeeded(FileName(f2)), dest, options);
2608 compare->start(QThread::LowPriority);
2610 lyx::dispatch(FuncRequest(LFUN_BUFFER_SWITCH, dest->absFileName()));
2619 message(from_utf8(msg));
2623 void GuiView::openChildDocument(string const & fname)
2625 LASSERT(documentBufferView(), return);
2626 Buffer & buffer = documentBufferView()->buffer();
2627 FileName const filename = support::makeAbsPath(fname, buffer.filePath());
2628 documentBufferView()->saveBookmark(false);
2630 bool parsed = false;
2631 if (theBufferList().exists(filename)) {
2632 child = theBufferList().getBuffer(filename);
2634 message(bformat(_("Opening child document %1$s..."),
2635 makeDisplayPath(filename.absFilename())));
2636 child = loadDocument(filename, false);
2642 // Set the parent name of the child document.
2643 // This makes insertion of citations and references in the child work,
2644 // when the target is in the parent or another child document.
2645 child->setParent(&buffer);
2646 child->masterBuffer()->updateLabels();
2649 child->errors("Parse");
2653 bool GuiView::goToFileRow(string const & argument)
2657 size_t i = argument.find_last_of(' ');
2658 if (i != string::npos) {
2659 file_name = os::internal_path(trim(argument.substr(0, i)));
2660 istringstream is(argument.substr(i + 1));
2665 if (i == string::npos) {
2666 LYXERR0("Wrong argument: " << argument);
2670 string const abstmp = package().temp_dir().absFilename();
2671 string const realtmp = package().temp_dir().realPath();
2672 // We have to use os::path_prefix_is() here, instead of
2673 // simply prefixIs(), because the file name comes from
2674 // an external application and may need case adjustment.
2675 if (os::path_prefix_is(file_name, abstmp, os::CASE_ADJUSTED)
2676 || os::path_prefix_is(file_name, realtmp, os::CASE_ADJUSTED)) {
2677 // Needed by inverse dvi search. If it is a file
2678 // in tmpdir, call the apropriated function.
2679 // If tmpdir is a symlink, we may have the real
2680 // path passed back, so we correct for that.
2681 if (!prefixIs(file_name, abstmp))
2682 file_name = subst(file_name, realtmp, abstmp);
2683 buf = theBufferList().getBufferFromTmp(file_name);
2685 // Must replace extension of the file to be .lyx
2686 // and get full path
2687 FileName const s = fileSearch(string(),
2688 support::changeExtension(file_name, ".lyx"), "lyx");
2689 // Either change buffer or load the file
2690 if (theBufferList().exists(s))
2691 buf = theBufferList().getBuffer(s);
2692 else if (s.exists()) {
2693 buf = loadDocument(s);
2694 buf->updateLabels();
2695 buf->errors("Parse");
2698 _("File does not exist: %1$s"),
2699 makeDisplayPath(file_name)));
2704 documentBufferView()->setCursorFromRow(row);
2709 #if (QT_VERSION >= 0x040400)
2710 static docstring exportAndDestroy(Buffer * buffer, string const & format)
2712 bool const update_unincluded =
2713 buffer->params().maintain_unincluded_children
2714 && !buffer->params().getIncludedChildren().empty();
2715 bool const success = buffer->doExport(format, true, update_unincluded);
2718 ? bformat(_("Successful export to format: %1$s"), from_utf8(format))
2719 : bformat(_("Error exporting to format: %1$s"), from_utf8(format));
2723 static docstring previewAndDestroy(Buffer * buffer, string const & format)
2725 bool const update_unincluded =
2726 buffer->params().maintain_unincluded_children
2727 && !buffer->params().getIncludedChildren().empty();
2728 bool const success = buffer->preview(format, update_unincluded);
2731 ? bformat(_("Successful preview of format: %1$s"), from_utf8(format))
2732 : bformat(_("Error previewing format: %1$s"), from_utf8(format));
2737 void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
2739 BufferView * bv = currentBufferView();
2740 // By default we won't need any update.
2741 dr.update(Update::None);
2742 // assume cmd will be dispatched
2743 dr.dispatched(true);
2745 Buffer * doc_buffer = documentBufferView()
2746 ? &(documentBufferView()->buffer()) : 0;
2748 if (cmd.origin == FuncRequest::TOC) {
2749 GuiToc * toc = static_cast<GuiToc*>(findOrBuild("toc", false));
2750 // FIXME: do we need to pass a DispatchResult object here?
2751 toc->doDispatch(bv->cursor(), cmd);
2755 string const argument = to_utf8(cmd.argument());
2757 switch(cmd.action) {
2758 case LFUN_BUFFER_CHILD_OPEN:
2759 openChildDocument(to_utf8(cmd.argument()));
2762 case LFUN_BUFFER_IMPORT:
2763 importDocument(to_utf8(cmd.argument()));
2766 case LFUN_BUFFER_EXPORT: {
2769 // GCC only sees strfwd.h when building merged
2770 if (::lyx::operator==(cmd.argument(), "custom")) {
2771 dispatch(FuncRequest(LFUN_DIALOG_SHOW, "sendto"),
2775 if (doc_buffer->doExport(argument, false)) {
2777 dr.setMessage(bformat(_("Error exporting to format: %1$s."),
2783 case LFUN_BUFFER_UPDATE: {
2786 string format = argument;
2787 if (argument.empty())
2788 format = doc_buffer->getDefaultOutputFormat();
2789 #if EXPORT_in_THREAD && (QT_VERSION >= 0x040400)
2790 d.progress_->clearMessages();
2791 message(_("Exporting ..."));
2792 QFuture<docstring> f = QtConcurrent::run(exportAndDestroy,
2793 doc_buffer->clone(), format);
2794 d.setPreviewFuture(f);
2796 bool const update_unincluded =
2797 doc_buffer->params().maintain_unincluded_children
2798 && !doc_buffer->params().getIncludedChildren().empty();
2799 doc_buffer->doExport(format, true, update_unincluded);
2803 case LFUN_BUFFER_VIEW: {
2806 string format = argument;
2807 if (argument.empty())
2808 format = doc_buffer->getDefaultOutputFormat();
2809 #if EXPORT_in_THREAD && (QT_VERSION >= 0x040400)
2810 d.progress_->clearMessages();
2811 message(_("Previewing ..."));
2812 QFuture<docstring> f = QtConcurrent::run(previewAndDestroy,
2813 doc_buffer->clone(), format);
2814 d.setPreviewFuture(f);
2816 bool const update_unincluded =
2817 doc_buffer->params().maintain_unincluded_children
2818 && !doc_buffer->params().getIncludedChildren().empty();
2819 doc_buffer->preview(format, update_unincluded);
2823 case LFUN_MASTER_BUFFER_UPDATE: {
2826 string format = argument;
2827 Buffer const * master = doc_buffer->masterBuffer();
2828 if (argument.empty())
2829 format = master->getDefaultOutputFormat();
2830 #if EXPORT_in_THREAD && (QT_VERSION >= 0x040400)
2831 QFuture<docstring> f = QtConcurrent::run(exportAndDestroy,
2832 master->clone(), format);
2833 d.setPreviewFuture(f);
2835 bool const update_unincluded =
2836 master->params().maintain_unincluded_children
2837 && !master->params().getIncludedChildren().empty();
2838 master->doExport(format, true);
2842 case LFUN_MASTER_BUFFER_VIEW: {
2843 string format = argument;
2844 Buffer const * master = doc_buffer->masterBuffer();
2845 if (argument.empty())
2846 format = master->getDefaultOutputFormat();
2847 #if EXPORT_in_THREAD && (QT_VERSION >= 0x040400)
2848 QFuture<docstring> f = QtConcurrent::run(previewAndDestroy,
2849 master->clone(), format);
2850 d.setPreviewFuture(f);
2852 master->preview(format);
2856 case LFUN_BUFFER_SWITCH:
2857 if (FileName::isAbsolute(to_utf8(cmd.argument()))) {
2859 theBufferList().getBuffer(FileName(to_utf8(cmd.argument())));
2864 dr.setMessage(_("Document not loaded"));
2869 case LFUN_BUFFER_NEXT:
2870 gotoNextOrPreviousBuffer(NEXTBUFFER);
2873 case LFUN_BUFFER_PREVIOUS:
2874 gotoNextOrPreviousBuffer(PREVBUFFER);
2877 case LFUN_COMMAND_EXECUTE: {
2878 bool const show_it = cmd.argument() != "off";
2879 // FIXME: this is a hack, "minibuffer" should not be
2881 if (GuiToolbar * t = toolbar("minibuffer")) {
2882 t->setVisible(show_it);
2883 if (show_it && t->commandBuffer())
2884 t->commandBuffer()->setFocus();
2888 case LFUN_DROP_LAYOUTS_CHOICE:
2889 d.layout_->showPopup();
2892 case LFUN_MENU_OPEN:
2893 if (QMenu * menu = guiApp->menus().menu(toqstr(cmd.argument()), *this))
2894 menu->exec(QCursor::pos());
2897 case LFUN_FILE_INSERT:
2898 insertLyXFile(cmd.argument());
2900 case LFUN_FILE_INSERT_PLAINTEXT_PARA:
2901 insertPlaintextFile(cmd.argument(), true);
2904 case LFUN_FILE_INSERT_PLAINTEXT:
2905 insertPlaintextFile(cmd.argument(), false);
2908 case LFUN_BUFFER_RELOAD: {
2909 LASSERT(doc_buffer, break);
2910 docstring const file = makeDisplayPath(doc_buffer->absFileName(), 20);
2911 docstring text = bformat(_("Any changes will be lost. Are you sure "
2912 "you want to revert to the saved version of the document %1$s?"), file);
2913 int const ret = Alert::prompt(_("Revert to saved document?"),
2914 text, 1, 1, _("&Revert"), _("&Cancel"));
2917 doc_buffer->markClean();
2923 case LFUN_BUFFER_WRITE:
2924 LASSERT(doc_buffer, break);
2925 saveBuffer(*doc_buffer);
2928 case LFUN_BUFFER_WRITE_AS:
2929 LASSERT(doc_buffer, break);
2930 renameBuffer(*doc_buffer, cmd.argument());
2933 case LFUN_BUFFER_WRITE_ALL: {
2934 Buffer * first = theBufferList().first();
2937 message(_("Saving all documents..."));
2938 // We cannot use a for loop as the buffer list cycles.
2941 if (!b->isClean()) {
2943 LYXERR(Debug::ACTION, "Saved " << b->absFileName());
2945 b = theBufferList().next(b);
2946 } while (b != first);
2947 dr.setMessage(_("All documents saved."));
2951 case LFUN_BUFFER_CLOSE:
2955 case LFUN_BUFFER_CLOSE_ALL:
2959 case LFUN_TOOLBAR_TOGGLE: {
2960 string const name = cmd.getArg(0);
2961 if (GuiToolbar * t = toolbar(name))
2966 case LFUN_DIALOG_UPDATE: {
2967 string const name = to_utf8(cmd.argument());
2968 if (currentBufferView()) {
2969 Inset * inset = currentBufferView()->editedInset(name);
2970 // Can only update a dialog connected to an existing inset
2973 // FIXME: get rid of this indirection; GuiView ask the inset
2974 // if he is kind enough to update itself...
2975 FuncRequest fr(LFUN_INSET_DIALOG_UPDATE, cmd.argument());
2976 //FIXME: pass DispatchResult here?
2977 inset->dispatch(currentBufferView()->cursor(), fr);
2978 } else if (name == "paragraph") {
2979 lyx::dispatch(FuncRequest(LFUN_PARAGRAPH_UPDATE));
2980 } else if (name == "prefs" || name == "document") {
2981 updateDialog(name, string());
2986 case LFUN_DIALOG_TOGGLE: {
2987 if (isDialogVisible(cmd.getArg(0)))
2988 dispatch(FuncRequest(LFUN_DIALOG_HIDE, cmd.argument()), dr);
2990 dispatch(FuncRequest(LFUN_DIALOG_SHOW, cmd.argument()), dr);
2994 case LFUN_DIALOG_DISCONNECT_INSET:
2995 disconnectDialog(to_utf8(cmd.argument()));
2998 case LFUN_DIALOG_HIDE: {
2999 guiApp->hideDialogs(to_utf8(cmd.argument()), 0);
3003 case LFUN_DIALOG_SHOW: {
3004 string const name = cmd.getArg(0);
3005 string data = trim(to_utf8(cmd.argument()).substr(name.size()));
3007 if (name == "character") {
3008 data = freefont2string();
3010 showDialog("character", data);
3011 } else if (name == "latexlog") {
3012 Buffer::LogType type;
3013 string const logfile = doc_buffer->logName(&type);
3015 case Buffer::latexlog:
3018 case Buffer::buildlog:
3022 data += Lexer::quoteString(logfile);
3023 showDialog("log", data);
3024 } else if (name == "vclog") {
3025 string const data = "vc " +
3026 Lexer::quoteString(doc_buffer->lyxvc().getLogFile());
3027 showDialog("log", data);
3028 } else if (name == "symbols") {
3029 data = bv->cursor().getEncoding()->name();
3031 showDialog("symbols", data);
3033 } else if (name == "prefs" && isFullScreen()) {
3034 lfunUiToggle("fullscreen");
3035 showDialog("prefs", data);
3037 showDialog(name, data);
3042 dr.setMessage(cmd.argument());
3045 case LFUN_UI_TOGGLE: {
3046 string arg = cmd.getArg(0);
3047 if (!lfunUiToggle(arg)) {
3048 docstring const msg = "ui-toggle " + _("%1$s unknown command!");
3049 dr.setMessage(bformat(msg, from_utf8(arg)));
3051 // Make sure the keyboard focus stays in the work area.
3056 case LFUN_SPLIT_VIEW: {
3057 LASSERT(doc_buffer, break);
3058 string const orientation = cmd.getArg(0);
3059 d.splitter_->setOrientation(orientation == "vertical"
3060 ? Qt::Vertical : Qt::Horizontal);
3061 TabWorkArea * twa = addTabWorkArea();
3062 GuiWorkArea * wa = twa->addWorkArea(*doc_buffer, *this);
3063 setCurrentWorkArea(wa);
3066 case LFUN_CLOSE_TAB_GROUP:
3067 if (TabWorkArea * twa = d.currentTabWorkArea()) {
3068 closeTabWorkArea(twa);
3069 d.current_work_area_ = 0;
3070 twa = d.currentTabWorkArea();
3071 // Switch to the next GuiWorkArea in the found TabWorkArea.
3073 // Make sure the work area is up to date.
3074 setCurrentWorkArea(twa->currentWorkArea());
3076 setCurrentWorkArea(0);
3081 case LFUN_COMPLETION_INLINE:
3082 if (d.current_work_area_)
3083 d.current_work_area_->completer().showInline();
3086 case LFUN_COMPLETION_POPUP:
3087 if (d.current_work_area_)
3088 d.current_work_area_->completer().showPopup();
3092 case LFUN_COMPLETION_COMPLETE:
3093 if (d.current_work_area_)
3094 d.current_work_area_->completer().tab();
3097 case LFUN_COMPLETION_CANCEL:
3098 if (d.current_work_area_) {
3099 if (d.current_work_area_->completer().popupVisible())
3100 d.current_work_area_->completer().hidePopup();
3102 d.current_work_area_->completer().hideInline();
3106 case LFUN_COMPLETION_ACCEPT:
3107 if (d.current_work_area_)
3108 d.current_work_area_->completer().activate();
3111 case LFUN_BUFFER_ZOOM_IN:
3112 case LFUN_BUFFER_ZOOM_OUT:
3113 if (cmd.argument().empty()) {
3114 if (cmd.action == LFUN_BUFFER_ZOOM_IN)
3119 lyxrc.zoom += convert<int>(cmd.argument());
3121 if (lyxrc.zoom < 10)
3124 // The global QPixmapCache is used in GuiPainter to cache text
3125 // painting so we must reset it.
3126 QPixmapCache::clear();
3127 guiApp->fontLoader().update();
3128 lyx::dispatch(FuncRequest(LFUN_SCREEN_FONT_UPDATE));
3131 case LFUN_VC_REGISTER:
3132 case LFUN_VC_CHECK_IN:
3133 case LFUN_VC_CHECK_OUT:
3134 case LFUN_VC_REPO_UPDATE:
3135 case LFUN_VC_LOCKING_TOGGLE:
3136 case LFUN_VC_REVERT:
3137 case LFUN_VC_UNDO_LAST:
3138 case LFUN_VC_COMMAND:
3139 case LFUN_VC_COMPARE:
3143 case LFUN_SERVER_GOTO_FILE_ROW:
3144 goToFileRow(to_utf8(cmd.argument()));
3148 dr.dispatched(false);
3152 // Part of automatic menu appearance feature.
3153 if (isFullScreen()) {
3154 if (menuBar()->isVisible() && lyxrc.full_screen_menubar)
3156 if (statusBar()->isVisible())
3157 statusBar()->hide();
3164 bool GuiView::lfunUiToggle(string const & ui_component)
3166 if (ui_component == "scrollbar") {
3167 // hide() is of no help
3168 if (d.current_work_area_->verticalScrollBarPolicy() ==
3169 Qt::ScrollBarAlwaysOff)
3171 d.current_work_area_->setVerticalScrollBarPolicy(
3172 Qt::ScrollBarAsNeeded);
3174 d.current_work_area_->setVerticalScrollBarPolicy(
3175 Qt::ScrollBarAlwaysOff);
3176 } else if (ui_component == "statusbar") {
3177 statusBar()->setVisible(!statusBar()->isVisible());
3178 } else if (ui_component == "menubar") {
3179 menuBar()->setVisible(!menuBar()->isVisible());
3181 #if QT_VERSION >= 0x040300
3182 if (ui_component == "frame") {
3184 getContentsMargins(&l, &t, &r, &b);
3185 //are the frames in default state?
3186 d.current_work_area_->setFrameStyle(QFrame::NoFrame);
3188 setContentsMargins(-2, -2, -2, -2);
3190 setContentsMargins(0, 0, 0, 0);
3194 if (ui_component == "fullscreen") {
3202 void GuiView::toggleFullScreen()
3204 if (isFullScreen()) {
3205 for (int i = 0; i != d.splitter_->count(); ++i)
3206 d.tabWorkArea(i)->setFullScreen(false);
3207 #if QT_VERSION >= 0x040300
3208 setContentsMargins(0, 0, 0, 0);
3210 setWindowState(windowState() ^ Qt::WindowFullScreen);
3213 statusBar()->show();
3216 hideDialogs("prefs", 0);
3217 for (int i = 0; i != d.splitter_->count(); ++i)
3218 d.tabWorkArea(i)->setFullScreen(true);
3219 #if QT_VERSION >= 0x040300
3220 setContentsMargins(-2, -2, -2, -2);
3223 setWindowState(windowState() ^ Qt::WindowFullScreen);
3224 statusBar()->hide();
3225 if (lyxrc.full_screen_menubar)
3227 if (lyxrc.full_screen_toolbars) {
3228 ToolbarMap::iterator end = d.toolbars_.end();
3229 for (ToolbarMap::iterator it = d.toolbars_.begin(); it != end; ++it)
3234 // give dialogs like the TOC a chance to adapt
3239 Buffer const * GuiView::updateInset(Inset const * inset)
3241 if (!d.current_work_area_)
3245 d.current_work_area_->scheduleRedraw();
3247 return &d.current_work_area_->bufferView().buffer();
3251 void GuiView::restartCursor()
3253 /* When we move around, or type, it's nice to be able to see
3254 * the cursor immediately after the keypress.
3256 if (d.current_work_area_)
3257 d.current_work_area_->startBlinkingCursor();
3259 // Take this occasion to update the other GUI elements.
3265 void GuiView::updateCompletion(Cursor & cur, bool start, bool keep)
3267 if (d.current_work_area_)
3268 d.current_work_area_->completer().updateVisibility(cur, start, keep);
3273 // This list should be kept in sync with the list of insets in
3274 // src/insets/Inset.cpp. I.e., if a dialog goes with an inset, the
3275 // dialog should have the same name as the inset.
3276 // Changes should be also recorded in LFUN_DIALOG_SHOW doxygen
3277 // docs in LyXAction.cpp.
3279 char const * const dialognames[] = {
3280 "aboutlyx", "bibitem", "bibtex", "box", "branch", "changes", "character",
3281 "citation", "compare", "document", "errorlist", "ert", "external", "file",
3282 "findreplace", "findreplaceadv", "float", "graphics", "href", "include",
3283 "index", "index_print", "info", "listings", "label", "log", "mathdelimiter",
3284 "mathmatrix", "mathspace", "nomenclature", "nomencl_print", "note",
3285 "paragraph", "phantom", "prefs", "print", "ref", "sendto", "space",
3286 "spellchecker", "symbols", "tabular", "tabularcreate", "thesaurus", "texinfo",
3287 "toc", "view-source", "vspace", "wrap", "progress"};
3289 char const * const * const end_dialognames =
3290 dialognames + (sizeof(dialognames) / sizeof(char *));
3294 cmpCStr(char const * name) : name_(name) {}
3295 bool operator()(char const * other) {
3296 return strcmp(other, name_) == 0;
3303 bool isValidName(string const & name)
3305 return find_if(dialognames, end_dialognames,
3306 cmpCStr(name.c_str())) != end_dialognames;
3312 void GuiView::resetDialogs()
3314 // Make sure that no LFUN uses any GuiView.
3315 guiApp->setCurrentView(0);
3318 constructToolbars();
3319 guiApp->menus().fillMenuBar(menuBar(), this, false);
3320 d.layout_->updateContents(true);
3321 // Now update controls with current buffer.
3322 guiApp->setCurrentView(this);
3328 Dialog * GuiView::findOrBuild(string const & name, bool hide_it)
3330 if (!isValidName(name))
3333 map<string, DialogPtr>::iterator it = d.dialogs_.find(name);
3335 if (it != d.dialogs_.end()) {
3337 it->second->hideView();
3338 return it->second.get();
3341 Dialog * dialog = build(name);
3342 d.dialogs_[name].reset(dialog);
3343 if (lyxrc.allow_geometry_session)
3344 dialog->restoreSession();
3351 void GuiView::showDialog(string const & name, string const & data,
3354 triggerShowDialog(toqstr(name), toqstr(data), inset);
3358 void GuiView::doShowDialog(QString const & qname, QString const & qdata,
3364 const string name = fromqstr(qname);
3365 const string data = fromqstr(qdata);
3369 Dialog * dialog = findOrBuild(name, false);
3371 dialog->showData(data);
3372 if (inset && currentBufferView())
3373 currentBufferView()->editInset(name, inset);
3376 catch (ExceptionMessage const & ex) {
3384 bool GuiView::isDialogVisible(string const & name) const
3386 map<string, DialogPtr>::const_iterator it = d.dialogs_.find(name);
3387 if (it == d.dialogs_.end())
3389 return it->second.get()->isVisibleView() && !it->second.get()->isClosing();
3393 void GuiView::hideDialog(string const & name, Inset * inset)
3395 map<string, DialogPtr>::const_iterator it = d.dialogs_.find(name);
3396 if (it == d.dialogs_.end())
3399 if (inset && currentBufferView()
3400 && inset != currentBufferView()->editedInset(name))
3403 Dialog * const dialog = it->second.get();
3404 if (dialog->isVisibleView())
3406 if (currentBufferView())
3407 currentBufferView()->editInset(name, 0);
3411 void GuiView::disconnectDialog(string const & name)
3413 if (!isValidName(name))
3415 if (currentBufferView())
3416 currentBufferView()->editInset(name, 0);
3420 void GuiView::hideAll() const
3422 map<string, DialogPtr>::const_iterator it = d.dialogs_.begin();
3423 map<string, DialogPtr>::const_iterator end = d.dialogs_.end();
3425 for(; it != end; ++it)
3426 it->second->hideView();
3430 void GuiView::updateDialogs()
3432 map<string, DialogPtr>::const_iterator it = d.dialogs_.begin();
3433 map<string, DialogPtr>::const_iterator end = d.dialogs_.end();
3435 for(; it != end; ++it) {
3436 Dialog * dialog = it->second.get();
3438 if (dialog->isBufferDependent() && !documentBufferView())
3439 hideDialog(fromqstr(dialog->name()), 0);
3440 else if (dialog->isVisibleView())
3441 dialog->checkStatus();
3448 Dialog * createDialog(GuiView & lv, string const & name);
3450 // will be replaced by a proper factory...
3451 Dialog * createGuiAbout(GuiView & lv);
3452 Dialog * createGuiBibitem(GuiView & lv);
3453 Dialog * createGuiBibtex(GuiView & lv);
3454 Dialog * createGuiChanges(GuiView & lv);
3455 Dialog * createGuiCharacter(GuiView & lv);
3456 Dialog * createGuiCitation(GuiView & lv);
3457 Dialog * createGuiCompare(GuiView & lv);
3458 Dialog * createGuiDelimiter(GuiView & lv);
3459 Dialog * createGuiDocument(GuiView & lv);
3460 Dialog * createGuiErrorList(GuiView & lv);
3461 Dialog * createGuiExternal(GuiView & lv);
3462 Dialog * createGuiGraphics(GuiView & lv);
3463 Dialog * createGuiInclude(GuiView & lv);
3464 Dialog * createGuiIndex(GuiView & lv);
3465 Dialog * createGuiLabel(GuiView & lv);
3466 Dialog * createGuiListings(GuiView & lv);
3467 Dialog * createGuiLog(GuiView & lv);
3468 Dialog * createGuiMathMatrix(GuiView & lv);
3469 Dialog * createGuiNomenclature(GuiView & lv);
3470 Dialog * createGuiNote(GuiView & lv);
3471 Dialog * createGuiParagraph(GuiView & lv);
3472 Dialog * createGuiPhantom(GuiView & lv);
3473 Dialog * createGuiPreferences(GuiView & lv);
3474 Dialog * createGuiPrint(GuiView & lv);
3475 Dialog * createGuiPrintindex(GuiView & lv);
3476 Dialog * createGuiPrintNomencl(GuiView & lv);
3477 Dialog * createGuiRef(GuiView & lv);
3478 Dialog * createGuiSearch(GuiView & lv);
3479 Dialog * createGuiSearchAdv(GuiView & lv);
3480 Dialog * createGuiSendTo(GuiView & lv);
3481 Dialog * createGuiShowFile(GuiView & lv);
3482 Dialog * createGuiSpellchecker(GuiView & lv);
3483 Dialog * createGuiSymbols(GuiView & lv);
3484 Dialog * createGuiTabularCreate(GuiView & lv);
3485 Dialog * createGuiTexInfo(GuiView & lv);
3486 Dialog * createGuiToc(GuiView & lv);
3487 Dialog * createGuiThesaurus(GuiView & lv);
3488 Dialog * createGuiHyperlink(GuiView & lv);
3489 Dialog * createGuiViewSource(GuiView & lv);
3490 Dialog * createGuiWrap(GuiView & lv);
3491 Dialog * createGuiProgressView(GuiView & lv);
3495 Dialog * GuiView::build(string const & name)
3497 LASSERT(isValidName(name), return 0);
3499 Dialog * dialog = createDialog(*this, name);
3503 if (name == "aboutlyx")
3504 return createGuiAbout(*this);
3505 if (name == "bibitem")
3506 return createGuiBibitem(*this);
3507 if (name == "bibtex")
3508 return createGuiBibtex(*this);
3509 if (name == "changes")
3510 return createGuiChanges(*this);
3511 if (name == "character")
3512 return createGuiCharacter(*this);
3513 if (name == "citation")
3514 return createGuiCitation(*this);
3515 if (name == "compare")
3516 return createGuiCompare(*this);
3517 if (name == "document")
3518 return createGuiDocument(*this);
3519 if (name == "errorlist")
3520 return createGuiErrorList(*this);
3521 if (name == "external")
3522 return createGuiExternal(*this);
3524 return createGuiShowFile(*this);
3525 if (name == "findreplace")
3526 return createGuiSearch(*this);
3527 if (name == "findreplaceadv")
3528 return createGuiSearchAdv(*this);
3529 if (name == "graphics")
3530 return createGuiGraphics(*this);
3532 return createGuiHyperlink(*this);
3533 if (name == "include")
3534 return createGuiInclude(*this);
3535 if (name == "index")
3536 return createGuiIndex(*this);
3537 if (name == "index_print")
3538 return createGuiPrintindex(*this);
3539 if (name == "label")
3540 return createGuiLabel(*this);
3541 if (name == "listings")
3542 return createGuiListings(*this);
3544 return createGuiLog(*this);
3545 if (name == "mathdelimiter")
3546 return createGuiDelimiter(*this);
3547 if (name == "mathmatrix")
3548 return createGuiMathMatrix(*this);
3549 if (name == "nomenclature")
3550 return createGuiNomenclature(*this);
3551 if (name == "nomencl_print")
3552 return createGuiPrintNomencl(*this);
3554 return createGuiNote(*this);
3555 if (name == "paragraph")
3556 return createGuiParagraph(*this);
3557 if (name == "phantom")
3558 return createGuiPhantom(*this);
3559 if (name == "prefs")
3560 return createGuiPreferences(*this);
3561 if (name == "print")
3562 return createGuiPrint(*this);
3564 return createGuiRef(*this);
3565 if (name == "sendto")
3566 return createGuiSendTo(*this);
3567 if (name == "spellchecker")
3568 return createGuiSpellchecker(*this);
3569 if (name == "symbols")
3570 return createGuiSymbols(*this);
3571 if (name == "tabularcreate")
3572 return createGuiTabularCreate(*this);
3573 if (name == "texinfo")
3574 return createGuiTexInfo(*this);
3575 if (name == "thesaurus")
3576 return createGuiThesaurus(*this);
3578 return createGuiToc(*this);
3579 if (name == "view-source")
3580 return createGuiViewSource(*this);
3582 return createGuiWrap(*this);
3583 if (name == "progress")
3584 return createGuiProgressView(*this);
3590 } // namespace frontend
3593 #include "moc_GuiView.cpp"