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 "FileDialog.h"
20 #include "FontLoader.h"
21 #include "GuiApplication.h"
22 #include "GuiCommandBuffer.h"
23 #include "GuiCompleter.h"
24 #include "GuiWorkArea.h"
25 #include "GuiKeySymbol.h"
27 #include "GuiToolbar.h"
28 #include "LayoutBox.h"
32 #include "qt_helpers.h"
34 #include "frontends/alert.h"
36 #include "buffer_funcs.h"
38 #include "BufferList.h"
39 #include "BufferParams.h"
40 #include "BufferView.h"
41 #include "Converter.h"
43 #include "CutAndPaste.h"
45 #include "ErrorList.h"
47 #include "FuncStatus.h"
48 #include "FuncRequest.h"
56 #include "Paragraph.h"
57 #include "SpellChecker.h"
58 #include "TextClass.h"
63 #include "support/convert.h"
64 #include "support/debug.h"
65 #include "support/ExceptionMessage.h"
66 #include "support/FileName.h"
67 #include "support/filetools.h"
68 #include "support/gettext.h"
69 #include "support/ForkedCalls.h"
70 #include "support/lassert.h"
71 #include "support/lstrings.h"
72 #include "support/os.h"
73 #include "support/Package.h"
74 #include "support/Timeout.h"
77 #include <QApplication>
78 #include <QCloseEvent>
80 #include <QDesktopWidget>
81 #include <QDragEnterEvent>
88 #include <QPixmapCache>
90 #include <QPushButton>
94 #include <QStackedWidget>
101 #include <boost/bind.hpp>
103 #ifdef HAVE_SYS_TIME_H
104 # include <sys/time.h>
111 using namespace lyx::support;
118 class BackgroundWidget : public QWidget
123 LYXERR(Debug::GUI, "show banner: " << lyxrc.show_banner);
124 /// The text to be written on top of the pixmap
125 QString const text = lyx_version ?
126 qt_("version ") + lyx_version : qt_("unknown version");
127 splash_ = getPixmap("images/", "banner", "png");
129 QPainter pain(&splash_);
130 pain.setPen(QColor(0, 0, 0));
132 // The font used to display the version info
133 font.setStyleHint(QFont::SansSerif);
134 font.setWeight(QFont::Bold);
135 font.setPointSize(int(toqstr(lyxrc.font_sizes[FONT_SIZE_LARGE]).toDouble()));
137 pain.drawText(260, 15, text);
140 void paintEvent(QPaintEvent *)
142 int x = (width() - splash_.width()) / 2;
143 int y = (height() - splash_.height()) / 2;
145 pain.drawPixmap(x, y, splash_);
153 /// Toolbar store providing access to individual toolbars by name.
154 typedef std::map<std::string, GuiToolbar *> ToolbarMap;
156 typedef boost::shared_ptr<Dialog> DialogPtr;
161 struct GuiView::GuiViewPrivate
164 : current_work_area_(0), current_main_work_area_(0),
165 layout_(0), autosave_timeout_(5000),
168 // hardcode here the platform specific icon size
169 smallIconSize = 14; // scaling problems
170 normalIconSize = 20; // ok, default
171 bigIconSize = 26; // better for some math icons
173 splitter_ = new QSplitter;
174 bg_widget_ = new BackgroundWidget;
175 stack_widget_ = new QStackedWidget;
176 stack_widget_->addWidget(bg_widget_);
177 stack_widget_->addWidget(splitter_);
185 delete stack_widget_;
188 QMenu * toolBarPopup(GuiView * parent)
190 // FIXME: translation
191 QMenu * menu = new QMenu(parent);
192 QActionGroup * iconSizeGroup = new QActionGroup(parent);
194 QAction * smallIcons = new QAction(iconSizeGroup);
195 smallIcons->setText(qt_("Small-sized icons"));
196 smallIcons->setCheckable(true);
197 QObject::connect(smallIcons, SIGNAL(triggered()),
198 parent, SLOT(smallSizedIcons()));
199 menu->addAction(smallIcons);
201 QAction * normalIcons = new QAction(iconSizeGroup);
202 normalIcons->setText(qt_("Normal-sized icons"));
203 normalIcons->setCheckable(true);
204 QObject::connect(normalIcons, SIGNAL(triggered()),
205 parent, SLOT(normalSizedIcons()));
206 menu->addAction(normalIcons);
208 QAction * bigIcons = new QAction(iconSizeGroup);
209 bigIcons->setText(qt_("Big-sized icons"));
210 bigIcons->setCheckable(true);
211 QObject::connect(bigIcons, SIGNAL(triggered()),
212 parent, SLOT(bigSizedIcons()));
213 menu->addAction(bigIcons);
215 unsigned int cur = parent->iconSize().width();
216 if ( cur == parent->d.smallIconSize)
217 smallIcons->setChecked(true);
218 else if (cur == parent->d.normalIconSize)
219 normalIcons->setChecked(true);
220 else if (cur == parent->d.bigIconSize)
221 bigIcons->setChecked(true);
228 stack_widget_->setCurrentWidget(bg_widget_);
229 bg_widget_->setUpdatesEnabled(true);
232 TabWorkArea * tabWorkArea(int i)
234 return dynamic_cast<TabWorkArea *>(splitter_->widget(i));
237 TabWorkArea * currentTabWorkArea()
239 if (splitter_->count() == 1)
240 // The first TabWorkArea is always the first one, if any.
241 return tabWorkArea(0);
243 for (int i = 0; i != splitter_->count(); ++i) {
244 TabWorkArea * twa = tabWorkArea(i);
245 if (current_main_work_area_ == twa->currentWorkArea())
249 // None has the focus so we just take the first one.
250 return tabWorkArea(0);
254 GuiWorkArea * current_work_area_;
255 GuiWorkArea * current_main_work_area_;
256 QSplitter * splitter_;
257 QStackedWidget * stack_widget_;
258 BackgroundWidget * bg_widget_;
260 ToolbarMap toolbars_;
261 /// The main layout box.
263 * \warning Don't Delete! The layout box is actually owned by
264 * whichever toolbar contains it. All the GuiView class needs is a
265 * means of accessing it.
267 * FIXME: replace that with a proper model so that we are not limited
268 * to only one dialog.
273 map<string, Inset *> open_insets_;
276 map<string, DialogPtr> dialogs_;
278 unsigned int smallIconSize;
279 unsigned int normalIconSize;
280 unsigned int bigIconSize;
282 QTimer statusbar_timer_;
283 /// auto-saving of buffers
284 Timeout autosave_timeout_;
285 /// flag against a race condition due to multiclicks, see bug #1119
289 TocModels toc_models_;
293 GuiView::GuiView(int id)
294 : d(*new GuiViewPrivate), id_(id), closing_(false)
296 // GuiToolbars *must* be initialised before the menu bar.
297 normalSizedIcons(); // at least on Mac the default is 32 otherwise, which is huge
299 d.layout_ = new LayoutBox(*this);
300 d.stack_widget_->addWidget(d.layout_);
302 // set ourself as the current view. This is needed for the menu bar
303 // filling, at least for the static special menu item on Mac. Otherwise
304 // they are greyed out.
305 theLyXFunc().setLyXView(this);
307 // Fill up the menu bar.
308 guiApp->menus().fillMenuBar(menuBar(), this, true);
310 setCentralWidget(d.stack_widget_);
312 // Start autosave timer
313 if (lyxrc.autosave) {
314 d.autosave_timeout_.timeout.connect(boost::bind(&GuiView::autoSave, this));
315 d.autosave_timeout_.setTimeout(lyxrc.autosave * 1000);
316 d.autosave_timeout_.start();
318 connect(&d.statusbar_timer_, SIGNAL(timeout()),
319 this, SLOT(clearMessage()));
321 // We don't want to keep the window in memory if it is closed.
322 setAttribute(Qt::WA_DeleteOnClose, true);
324 #if (!defined(Q_WS_WIN) && !defined(Q_WS_MACX))
325 // assign an icon to main form. We do not do it under Qt/Win or Qt/Mac,
326 // since the icon is provided in the application bundle.
327 setWindowIcon(getPixmap("images/", "lyx", "png"));
331 setAcceptDrops(true);
333 statusBar()->setSizeGripEnabled(true);
335 // Forbid too small unresizable window because it can happen
336 // with some window manager under X11.
337 setMinimumSize(300, 200);
339 if (lyxrc.allow_geometry_session) {
340 // Now take care of session management.
345 // no session handling, default to a sane size.
346 setGeometry(50, 50, 690, 510);
349 // clear session data if any.
351 settings.remove("views");
361 void GuiView::saveLayout() const
364 settings.beginGroup("views");
365 settings.beginGroup(QString::number(id_));
367 settings.setValue("pos", pos());
368 settings.setValue("size", size());
370 settings.setValue("geometry", saveGeometry());
372 settings.setValue("layout", saveState(0));
373 settings.setValue("icon_size", iconSize());
377 bool GuiView::restoreLayout()
380 settings.beginGroup("views");
381 settings.beginGroup(QString::number(id_));
382 QString const icon_key = "icon_size";
383 if (!settings.contains(icon_key))
386 //code below is skipped when when ~/.config/LyX is (re)created
387 setIconSize(settings.value(icon_key).toSize());
389 QPoint pos = settings.value("pos", QPoint(50, 50)).toPoint();
390 QSize size = settings.value("size", QSize(690, 510)).toSize();
394 // Work-around for bug #6034: the window ends up in an undetermined
395 // state when trying to restore a maximized window when it is
396 // already maximized.
397 if (!(windowState() & Qt::WindowMaximized))
398 if (!restoreGeometry(settings.value("geometry").toByteArray()))
399 setGeometry(50, 50, 690, 510);
401 // Make sure layout is correctly oriented.
402 setLayoutDirection(qApp->layoutDirection());
404 // Allow the toc and view-source dock widget to be restored if needed.
406 if ((dialog = findOrBuild("toc", true)))
407 // see bug 5082. At least setup title and enabled state.
408 // Visibility will be adjusted by restoreState below.
409 dialog->prepareView();
410 if ((dialog = findOrBuild("view-source", true)))
411 dialog->prepareView();
413 if (!restoreState(settings.value("layout").toByteArray(), 0))
420 GuiToolbar * GuiView::toolbar(string const & name)
422 ToolbarMap::iterator it = d.toolbars_.find(name);
423 if (it != d.toolbars_.end())
426 LYXERR(Debug::GUI, "Toolbar::display: no toolbar named " << name);
427 message(bformat(_("Unknown toolbar \"%1$s\""), from_utf8(name)));
432 void GuiView::constructToolbars()
434 ToolbarMap::iterator it = d.toolbars_.begin();
435 for (; it != d.toolbars_.end(); ++it)
439 // extracts the toolbars from the backend
440 Toolbars::Infos::iterator cit = guiApp->toolbars().begin();
441 Toolbars::Infos::iterator end = guiApp->toolbars().end();
442 for (; cit != end; ++cit)
443 d.toolbars_[cit->name] = new GuiToolbar(*cit, *this);
447 void GuiView::initToolbars()
449 // extracts the toolbars from the backend
450 Toolbars::Infos::iterator cit = guiApp->toolbars().begin();
451 Toolbars::Infos::iterator end = guiApp->toolbars().end();
452 for (; cit != end; ++cit) {
453 GuiToolbar * tb = toolbar(cit->name);
456 int const visibility = guiApp->toolbars().defaultVisibility(cit->name);
458 tb->setVisible(false);
459 tb->setVisibility(visibility);
461 if (visibility & Toolbars::TOP) {
463 addToolBarBreak(Qt::TopToolBarArea);
464 addToolBar(Qt::TopToolBarArea, tb);
467 if (visibility & Toolbars::BOTTOM) {
468 // Qt < 4.2.2 cannot handle ToolBarBreak on non-TOP dock.
469 #if (QT_VERSION >= 0x040202)
470 addToolBarBreak(Qt::BottomToolBarArea);
472 addToolBar(Qt::BottomToolBarArea, tb);
475 if (visibility & Toolbars::LEFT) {
476 // Qt < 4.2.2 cannot handle ToolBarBreak on non-TOP dock.
477 #if (QT_VERSION >= 0x040202)
478 addToolBarBreak(Qt::LeftToolBarArea);
480 addToolBar(Qt::LeftToolBarArea, tb);
483 if (visibility & Toolbars::RIGHT) {
484 // Qt < 4.2.2 cannot handle ToolBarBreak on non-TOP dock.
485 #if (QT_VERSION >= 0x040202)
486 addToolBarBreak(Qt::RightToolBarArea);
488 addToolBar(Qt::RightToolBarArea, tb);
491 if (visibility & Toolbars::ON)
492 tb->setVisible(true);
497 TocModels & GuiView::tocModels()
499 return d.toc_models_;
503 void GuiView::setFocus()
505 LYXERR(Debug::DEBUG, "GuiView::setFocus()" << this);
506 // Make sure LyXFunc points to the correct view.
507 guiApp->setCurrentView(this);
508 theLyXFunc().setLyXView(this);
509 QMainWindow::setFocus();
510 if (d.current_work_area_)
511 d.current_work_area_->setFocus();
515 QMenu * GuiView::createPopupMenu()
517 return d.toolBarPopup(this);
521 void GuiView::showEvent(QShowEvent * e)
523 LYXERR(Debug::GUI, "Passed Geometry "
524 << size().height() << "x" << size().width()
525 << "+" << pos().x() << "+" << pos().y());
527 if (d.splitter_->count() == 0)
528 // No work area, switch to the background widget.
531 QMainWindow::showEvent(e);
535 /** Destroy only all tabbed WorkAreas. Destruction of other WorkAreas
536 ** is responsibility of the container (e.g., dialog)
538 void GuiView::closeEvent(QCloseEvent * close_event)
540 LYXERR(Debug::DEBUG, "GuiView::closeEvent()");
543 // it can happen that this event arrives without selecting the view,
544 // e.g. when clicking the close button on a background window.
546 if (!closeBufferAll(true)) {
548 close_event->ignore();
552 // Make sure that nothing will use this close to be closed View.
553 guiApp->unregisterView(this);
555 if (isFullScreen()) {
556 // Switch off fullscreen before closing.
561 // Make sure the timer time out will not trigger a statusbar update.
562 d.statusbar_timer_.stop();
564 // Saving fullscreen requires additional tweaks in the toolbar code.
565 // It wouldn't also work under linux natively.
566 if (lyxrc.allow_geometry_session) {
567 // Save this window geometry and layout.
569 // Then the toolbar private states.
570 ToolbarMap::iterator end = d.toolbars_.end();
571 for (ToolbarMap::iterator it = d.toolbars_.begin(); it != end; ++it)
572 it->second->saveSession();
573 // Now take care of all other dialogs:
574 map<string, DialogPtr>::const_iterator it = d.dialogs_.begin();
575 for (; it!= d.dialogs_.end(); ++it)
576 it->second->saveSession();
579 close_event->accept();
583 bool GuiView::closeBufferAll(bool tolastopened)
585 GuiWorkArea * active_wa = currentMainWorkArea();
586 setCurrentWorkArea(active_wa);
588 // We might be in a situation that there is still a tabWorkArea, but
589 // there are no tabs anymore. This can happen when we get here after a
590 // TabWorkArea::lastWorkAreaRemoved() signal. Therefore we count how
591 // many TabWorkArea's have no documents anymore.
594 // We have to call count() each time, because it can happen that
595 // more than one splitter will disappear in one iteration (bug 5998).
596 for (; d.splitter_->count() > empty_twa; ) {
597 TabWorkArea * twa = d.tabWorkArea(empty_twa);
599 int twa_count = twa->count();
600 if (twa->count() == 0)
603 for (; twa_count; --twa_count) {
604 twa->setCurrentIndex(twa_count-1);
606 GuiWorkArea * wa = twa->currentWorkArea();
607 bool const is_active_wa = active_wa == wa;
608 Buffer * b = &wa->bufferView().buffer();
610 // This is a child document, just close the tab
611 // after saving but keep the file loaded.
612 if (!closeBuffer(*b, false, tolastopened, is_active_wa))
617 vector<Buffer *> clist = b->getChildren();
618 for (vector<Buffer *>::const_iterator it = clist.begin();
619 it != clist.end(); ++it) {
620 if ((*it)->isClean())
623 // If a child is dirty, do not close
624 // without user intervention
625 //FIXME: should buffers be closed or not?
626 if (!closeBuffer(*c, false, false))
630 QList<int> const ids = guiApp->viewIds();
631 for (int i = 0; i != ids.size(); ++i) {
634 if (guiApp->view(ids[i]).workArea(*b)) {
635 // FIXME 1: should we put an alert box here
636 // that the buffer is viewed elsewhere?
637 // FIXME 2: should we try to save this buffer in any case?
640 // This buffer is also opened in another view, so
641 // close the associated work area...
643 // ... but don't close the buffer.
648 // closeBuffer() needs buffer workArea still alive and
649 // set as currrent one, and destroys it
650 if (b && !closeBuffer(*b, true, tolastopened, is_active_wa))
658 void GuiView::dragEnterEvent(QDragEnterEvent * event)
660 if (event->mimeData()->hasUrls())
662 /// \todo Ask lyx-devel is this is enough:
663 /// if (event->mimeData()->hasFormat("text/plain"))
664 /// event->acceptProposedAction();
668 void GuiView::dropEvent(QDropEvent * event)
670 QList<QUrl> files = event->mimeData()->urls();
674 LYXERR(Debug::GUI, "GuiView::dropEvent: got URLs!");
675 for (int i = 0; i != files.size(); ++i) {
676 string const file = os::internal_path(fromqstr(
677 files.at(i).toLocalFile()));
679 // Asynchronously post the event. DropEvent usually come
680 // from the BufferView. But reloading a file might close
681 // the BufferView from within its own event handler.
682 guiApp->dispatchDelayed(FuncRequest(LFUN_FILE_OPEN, file));
689 void GuiView::message(docstring const & str)
691 if (ForkedProcess::iAmAChild())
694 statusBar()->showMessage(toqstr(str));
695 d.statusbar_timer_.stop();
696 d.statusbar_timer_.start(3000);
700 void GuiView::smallSizedIcons()
702 setIconSize(QSize(d.smallIconSize, d.smallIconSize));
706 void GuiView::normalSizedIcons()
708 setIconSize(QSize(d.normalIconSize, d.normalIconSize));
712 void GuiView::bigSizedIcons()
714 setIconSize(QSize(d.bigIconSize, d.bigIconSize));
718 void GuiView::clearMessage()
722 theLyXFunc().setLyXView(this);
723 statusBar()->showMessage(toqstr(theLyXFunc().viewStatusMessage()));
724 d.statusbar_timer_.stop();
728 void GuiView::updateWindowTitle(GuiWorkArea * wa)
730 if (wa != d.current_work_area_)
732 setWindowTitle(qt_("LyX: ") + wa->windowTitle());
733 setWindowIconText(wa->windowIconText());
737 void GuiView::on_currentWorkAreaChanged(GuiWorkArea * wa)
740 disconnectBufferView();
741 connectBufferView(wa->bufferView());
742 connectBuffer(wa->bufferView().buffer());
743 d.current_work_area_ = wa;
744 QObject::connect(wa, SIGNAL(titleChanged(GuiWorkArea *)),
745 this, SLOT(updateWindowTitle(GuiWorkArea *)));
746 updateWindowTitle(wa);
750 // The document settings needs to be reinitialised.
751 updateDialog("document", "");
753 // Buffer-dependent dialogs must be updated. This is done here because
754 // some dialogs require buffer()->text.
759 void GuiView::on_lastWorkAreaRemoved()
762 // We already are in a close event. Nothing more to do.
765 if (d.splitter_->count() > 1)
766 // We have a splitter so don't close anything.
769 // Reset and updates the dialogs.
770 d.toc_models_.reset(0);
771 updateDialog("document", "");
774 resetWindowTitleAndIconText();
776 if (lyxrc.open_buffers_in_tabs)
777 // Nothing more to do, the window should stay open.
780 if (guiApp->viewIds().size() > 1) {
786 // On Mac we also close the last window because the application stay
787 // resident in memory. On other platforms we don't close the last
788 // window because this would quit the application.
794 void GuiView::updateStatusBar()
796 // let the user see the explicit message
797 if (d.statusbar_timer_.isActive())
800 theLyXFunc().setLyXView(this);
801 statusBar()->showMessage(toqstr(theLyXFunc().viewStatusMessage()));
805 bool GuiView::hasFocus() const
807 return qApp->activeWindow() == this;
811 bool GuiView::event(QEvent * e)
815 // Useful debug code:
816 //case QEvent::ActivationChange:
817 //case QEvent::WindowDeactivate:
818 //case QEvent::Paint:
819 //case QEvent::Enter:
820 //case QEvent::Leave:
821 //case QEvent::HoverEnter:
822 //case QEvent::HoverLeave:
823 //case QEvent::HoverMove:
824 //case QEvent::StatusTip:
825 //case QEvent::DragEnter:
826 //case QEvent::DragLeave:
830 case QEvent::WindowActivate: {
831 if (this == guiApp->currentView()) {
833 return QMainWindow::event(e);
835 guiApp->setCurrentView(this);
836 theLyXFunc().setLyXView(this);
837 if (d.current_work_area_) {
838 BufferView & bv = d.current_work_area_->bufferView();
839 connectBufferView(bv);
840 connectBuffer(bv.buffer());
841 // The document structure, name and dialogs might have
842 // changed in another view.
844 // The document settings needs to be reinitialised.
845 updateDialog("document", "");
848 resetWindowTitleAndIconText();
851 return QMainWindow::event(e);
854 case QEvent::ShortcutOverride: {
857 #if (!defined Q_WS_X11) || (QT_VERSION >= 0x040500)
858 if (isFullScreen() && menuBar()->isHidden()) {
859 QKeyEvent * ke = static_cast<QKeyEvent*>(e);
860 // FIXME: we should also try to detect special LyX shortcut such as
861 // Alt-P and Alt-M. Right now there is a hack in
862 // GuiWorkArea::processKeySym() that hides again the menubar for
864 if (ke->modifiers() & Qt::AltModifier && ke->key() != Qt::Key_Alt) {
866 return QMainWindow::event(e);
871 if (d.current_work_area_)
872 // Nothing special to do.
873 return QMainWindow::event(e);
875 QKeyEvent * ke = static_cast<QKeyEvent*>(e);
876 // Let Qt handle menu access and the Tab keys to navigate keys to navigate
878 if (ke->modifiers() & Qt::AltModifier || ke->key() == Qt::Key_Tab
879 || ke->key() == Qt::Key_Backtab)
880 return QMainWindow::event(e);
882 // Allow processing of shortcuts that are allowed even when no Buffer
884 theLyXFunc().setLyXView(this);
886 setKeySymbol(&sym, ke);
887 theLyXFunc().processKeySym(sym, q_key_state(ke->modifiers()));
893 return QMainWindow::event(e);
897 void GuiView::resetWindowTitleAndIconText()
899 setWindowTitle(qt_("LyX"));
900 setWindowIconText(qt_("LyX"));
903 bool GuiView::focusNextPrevChild(bool /*next*/)
910 void GuiView::setBusy(bool busy)
912 if (d.current_work_area_) {
913 d.current_work_area_->setUpdatesEnabled(!busy);
915 d.current_work_area_->stopBlinkingCursor();
917 d.current_work_area_->startBlinkingCursor();
921 QApplication::setOverrideCursor(Qt::WaitCursor);
923 QApplication::restoreOverrideCursor();
927 GuiWorkArea * GuiView::workArea(Buffer & buffer)
929 if (currentWorkArea()
930 && ¤tWorkArea()->bufferView().buffer() == &buffer)
931 return (GuiWorkArea *) currentWorkArea();
932 if (TabWorkArea * twa = d.currentTabWorkArea())
933 return twa->workArea(buffer);
938 GuiWorkArea * GuiView::addWorkArea(Buffer & buffer)
940 // Automatically create a TabWorkArea if there are none yet.
941 TabWorkArea * tab_widget = d.splitter_->count()
942 ? d.currentTabWorkArea() : addTabWorkArea();
943 return tab_widget->addWorkArea(buffer, *this);
947 TabWorkArea * GuiView::addTabWorkArea()
949 TabWorkArea * twa = new TabWorkArea;
950 QObject::connect(twa, SIGNAL(currentWorkAreaChanged(GuiWorkArea *)),
951 this, SLOT(on_currentWorkAreaChanged(GuiWorkArea *)));
952 QObject::connect(twa, SIGNAL(lastWorkAreaRemoved()),
953 this, SLOT(on_lastWorkAreaRemoved()));
955 d.splitter_->addWidget(twa);
956 d.stack_widget_->setCurrentWidget(d.splitter_);
961 GuiWorkArea const * GuiView::currentWorkArea() const
963 return d.current_work_area_;
967 GuiWorkArea * GuiView::currentWorkArea()
969 return d.current_work_area_;
973 GuiWorkArea const * GuiView::currentMainWorkArea() const
975 if (d.currentTabWorkArea() == NULL)
977 return d.currentTabWorkArea()->currentWorkArea();
981 GuiWorkArea * GuiView::currentMainWorkArea()
983 if (d.currentTabWorkArea() == NULL)
985 return d.currentTabWorkArea()->currentWorkArea();
989 void GuiView::setCurrentWorkArea(GuiWorkArea * wa)
991 LYXERR(Debug::DEBUG, "Setting current wa: " << wa << endl);
993 d.current_work_area_ = NULL;
997 GuiWorkArea * old_gwa = theGuiApp()->currentView()->currentWorkArea();
1002 cap::saveSelection(view()->cursor());
1004 theGuiApp()->setCurrentView(this);
1005 d.current_work_area_ = wa;
1006 for (int i = 0; i != d.splitter_->count(); ++i) {
1007 if (d.tabWorkArea(i)->setCurrentWorkArea(wa)) {
1008 //if (d.current_main_work_area_)
1009 // d.current_main_work_area_->setFrameStyle(QFrame::NoFrame);
1010 d.current_main_work_area_ = wa;
1011 //d.current_main_work_area_->setFrameStyle(QFrame::Box | QFrame::Plain);
1012 //d.current_main_work_area_->setLineWidth(2);
1013 LYXERR(Debug::DEBUG, "Current wa: " << currentWorkArea() << ", Current main wa: " << currentMainWorkArea());
1017 LYXERR(Debug::DEBUG, "This is not a tabbed wa");
1018 on_currentWorkAreaChanged(wa);
1019 BufferView & bv = wa->bufferView();
1020 bv.cursor().fixIfBroken();
1022 wa->setUpdatesEnabled(true);
1023 LYXERR(Debug::DEBUG, "Current wa: " << currentWorkArea() << ", Current main wa: " << currentMainWorkArea());
1027 void GuiView::removeWorkArea(GuiWorkArea * wa)
1029 LASSERT(wa, return);
1030 if (wa == d.current_work_area_) {
1032 disconnectBufferView();
1033 d.current_work_area_ = 0;
1034 d.current_main_work_area_ = 0;
1037 bool found_twa = false;
1038 for (int i = 0; i != d.splitter_->count(); ++i) {
1039 TabWorkArea * twa = d.tabWorkArea(i);
1040 if (twa->removeWorkArea(wa)) {
1041 // Found in this tab group, and deleted the GuiWorkArea.
1043 if (twa->count() != 0) {
1044 if (d.current_work_area_ == 0)
1045 // This means that we are closing the current GuiWorkArea, so
1046 // switch to the next GuiWorkArea in the found TabWorkArea.
1047 setCurrentWorkArea(twa->currentWorkArea());
1049 // No more WorkAreas in this tab group, so delete it.
1056 // It is not a tabbed work area (i.e., the search work area), so it
1057 // should be deleted by other means.
1058 LASSERT(found_twa, /* */);
1060 if (d.current_work_area_ == 0) {
1061 if (d.splitter_->count() != 0) {
1062 TabWorkArea * twa = d.currentTabWorkArea();
1063 setCurrentWorkArea(twa->currentWorkArea());
1065 // No more work areas, switch to the background widget.
1066 setCurrentWorkArea(0);
1072 LayoutBox * GuiView::getLayoutDialog() const
1078 void GuiView::updateLayoutList()
1081 d.layout_->updateContents(false);
1085 void GuiView::updateToolbars()
1087 ToolbarMap::iterator end = d.toolbars_.end();
1088 if (d.current_work_area_) {
1090 d.current_work_area_->bufferView().cursor().inMathed();
1092 lyx::getStatus(FuncRequest(LFUN_LAYOUT_TABULAR)).enabled();
1094 lyx::getStatus(FuncRequest(LFUN_CHANGES_TRACK)).enabled() &&
1095 lyx::getStatus(FuncRequest(LFUN_CHANGES_TRACK)).onoff(true);
1096 bool const mathmacrotemplate =
1097 lyx::getStatus(FuncRequest(LFUN_IN_MATHMACROTEMPLATE)).enabled();
1099 for (ToolbarMap::iterator it = d.toolbars_.begin(); it != end; ++it)
1100 it->second->update(math, table, review, mathmacrotemplate);
1102 for (ToolbarMap::iterator it = d.toolbars_.begin(); it != end; ++it)
1103 it->second->update(false, false, false, false);
1107 Buffer * GuiView::buffer()
1109 if (d.current_work_area_)
1110 return &d.current_work_area_->bufferView().buffer();
1115 Buffer const * GuiView::buffer() const
1117 if (d.current_work_area_)
1118 return &d.current_work_area_->bufferView().buffer();
1123 void GuiView::setBuffer(Buffer * newBuffer)
1125 LYXERR(Debug::DEBUG, "Setting buffer: " << newBuffer << std::endl);
1126 LASSERT(newBuffer, return);
1129 GuiWorkArea * wa = workArea(*newBuffer);
1131 newBuffer->masterBuffer()->updateLabels();
1132 wa = addWorkArea(*newBuffer);
1134 //Disconnect the old buffer...there's no new one.
1137 connectBuffer(*newBuffer);
1138 connectBufferView(wa->bufferView());
1139 setCurrentWorkArea(wa);
1145 void GuiView::connectBuffer(Buffer & buf)
1147 buf.setGuiDelegate(this);
1151 void GuiView::disconnectBuffer()
1153 if (d.current_work_area_)
1154 d.current_work_area_->bufferView().setGuiDelegate(0);
1158 void GuiView::connectBufferView(BufferView & bv)
1160 bv.setGuiDelegate(this);
1164 void GuiView::disconnectBufferView()
1166 if (d.current_work_area_)
1167 d.current_work_area_->bufferView().setGuiDelegate(0);
1171 void GuiView::errors(string const & error_type, bool from_master)
1173 ErrorList & el = from_master ?
1174 buffer()->masterBuffer()->errorList(error_type)
1175 : buffer()->errorList(error_type);
1176 string data = error_type;
1178 data = "from_master|" + error_type;
1180 showDialog("errorlist", data);
1184 void GuiView::updateTocItem(std::string const & type, DocIterator const & dit)
1186 d.toc_models_.updateItem(toqstr(type), dit);
1190 void GuiView::structureChanged()
1192 d.toc_models_.reset(view());
1193 // Navigator needs more than a simple update in this case. It needs to be
1195 updateDialog("toc", "");
1199 void GuiView::updateDialog(string const & name, string const & data)
1201 if (!isDialogVisible(name))
1204 map<string, DialogPtr>::const_iterator it = d.dialogs_.find(name);
1205 if (it == d.dialogs_.end())
1208 Dialog * const dialog = it->second.get();
1209 if (dialog->isVisibleView())
1210 dialog->initialiseParams(data);
1214 BufferView * GuiView::view()
1216 return d.current_work_area_ ? &d.current_work_area_->bufferView() : 0;
1220 void GuiView::autoSave()
1222 LYXERR(Debug::INFO, "Running autoSave()");
1225 view()->buffer().autoSave();
1229 void GuiView::resetAutosaveTimers()
1232 d.autosave_timeout_.restart();
1236 bool GuiView::getStatus(FuncRequest const & cmd, FuncStatus & flag)
1239 Buffer * buf = buffer();
1241 if (cmd.origin == FuncRequest::TOC) {
1242 GuiToc * toc = static_cast<GuiToc*>(findOrBuild("toc", false));
1244 if (toc->getStatus(view()->cursor(), cmd, fs))
1247 flag.setEnabled(false);
1251 switch(cmd.action) {
1252 case LFUN_BUFFER_WRITE:
1253 enable = buf && (buf->isUnnamed() || !buf->isClean());
1256 case LFUN_BUFFER_WRITE_AS:
1260 case LFUN_BUFFER_CLOSE_ALL: {
1262 BufferList::iterator it = theBufferList().begin();
1263 BufferList::iterator end = theBufferList().end();
1264 int visible_buffers = 0;
1265 for (; it != end; ++it) {
1268 if (visible_buffers > 1) {
1276 case LFUN_SPLIT_VIEW:
1277 if (cmd.getArg(0) == "vertical")
1278 enable = buf && (d.splitter_->count() == 1 ||
1279 d.splitter_->orientation() == Qt::Vertical);
1281 enable = buf && (d.splitter_->count() == 1 ||
1282 d.splitter_->orientation() == Qt::Horizontal);
1285 case LFUN_CLOSE_TAB_GROUP:
1286 enable = d.currentTabWorkArea();
1289 case LFUN_TOOLBAR_TOGGLE:
1290 if (GuiToolbar * t = toolbar(cmd.getArg(0)))
1291 flag.setOnOff(t->isVisible());
1294 case LFUN_UI_TOGGLE:
1295 flag.setOnOff(isFullScreen());
1298 case LFUN_DIALOG_TOGGLE:
1299 flag.setOnOff(isDialogVisible(cmd.getArg(0)));
1300 // fall through to set "enable"
1301 case LFUN_DIALOG_SHOW: {
1302 string const name = cmd.getArg(0);
1304 enable = name == "aboutlyx"
1305 || name == "file" //FIXME: should be removed.
1307 || name == "texinfo";
1308 else if (name == "print")
1309 enable = buf->isExportable("dvi")
1310 && lyxrc.print_command != "none";
1311 else if (name == "character" || name == "symbols") {
1312 if (buf->isReadonly() || !view() || !view()->cursor().inTexted())
1315 // FIXME we should consider passthru
1317 Inset const & in = view()->cursor().inset();
1318 enable = !in.getLayout().isPassThru();
1321 else if (name == "latexlog")
1322 enable = FileName(buf->logName()).isReadableFile();
1323 else if (name == "spellchecker")
1324 enable = theSpellChecker() && !buf->isReadonly();
1325 else if (name == "vclog")
1326 enable = buf->lyxvc().inUse();
1330 case LFUN_DIALOG_UPDATE: {
1331 string const name = cmd.getArg(0);
1333 enable = name == "prefs";
1337 case LFUN_INSET_APPLY: {
1338 string const name = cmd.getArg(0);
1339 Inset * inset = getOpenInset(name);
1341 FuncRequest fr(LFUN_INSET_MODIFY, cmd.argument());
1343 if (!inset->getStatus(view()->cursor(), fr, fs)) {
1344 // Every inset is supposed to handle this
1345 LASSERT(false, break);
1349 FuncRequest fr(LFUN_INSET_INSERT, cmd.argument());
1350 flag |= lyx::getStatus(fr);
1352 enable = flag.enabled();
1356 case LFUN_COMPLETION_INLINE:
1357 if (!d.current_work_area_
1358 || !d.current_work_area_->completer().inlinePossible(view()->cursor()))
1362 case LFUN_COMPLETION_POPUP:
1363 if (!d.current_work_area_
1364 || !d.current_work_area_->completer().popupPossible(view()->cursor()))
1368 case LFUN_COMPLETION_COMPLETE:
1369 if (!d.current_work_area_
1370 || !d.current_work_area_->completer().inlinePossible(view()->cursor()))
1374 case LFUN_COMPLETION_ACCEPT:
1375 if (!d.current_work_area_
1376 || (!d.current_work_area_->completer().popupVisible()
1377 && !d.current_work_area_->completer().inlineVisible()
1378 && !d.current_work_area_->completer().completionAvailable()))
1382 case LFUN_COMPLETION_CANCEL:
1383 if (!d.current_work_area_
1384 || (!d.current_work_area_->completer().popupVisible()
1385 && !d.current_work_area_->completer().inlineVisible()))
1389 case LFUN_BUFFER_ZOOM_OUT:
1390 enable = buf && lyxrc.zoom > 10;
1393 case LFUN_BUFFER_ZOOM_IN:
1402 flag.setEnabled(false);
1408 static FileName selectTemplateFile()
1410 FileDialog dlg(qt_("Select template file"));
1411 dlg.setButton1(qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
1412 dlg.setButton1(qt_("Templates|#T#t"), toqstr(lyxrc.template_path));
1414 FileDialog::Result result = dlg.open(toqstr(lyxrc.template_path),
1415 QStringList(qt_("LyX Documents (*.lyx)")));
1417 if (result.first == FileDialog::Later)
1419 if (result.second.isEmpty())
1421 return FileName(fromqstr(result.second));
1425 Buffer * GuiView::loadDocument(FileName const & filename, bool tolastfiles)
1429 Buffer * newBuffer = checkAndLoadLyXFile(filename);
1432 message(_("Document not loaded."));
1437 setBuffer(newBuffer);
1439 // scroll to the position when the file was last closed
1440 if (lyxrc.use_lastfilepos) {
1441 LastFilePosSection::FilePos filepos =
1442 theSession().lastFilePos().load(filename);
1443 view()->moveToPosition(filepos.pit, filepos.pos, 0, 0);
1447 theSession().lastFiles().add(filename);
1454 void GuiView::openDocument(string const & fname)
1456 string initpath = lyxrc.document_path;
1459 string const trypath = buffer()->filePath();
1460 // If directory is writeable, use this as default.
1461 if (FileName(trypath).isDirWritable())
1467 if (fname.empty()) {
1468 FileDialog dlg(qt_("Select document to open"), LFUN_FILE_OPEN);
1469 dlg.setButton1(qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
1470 dlg.setButton2(qt_("Examples|#E#e"),
1471 toqstr(addPath(package().system_support().absFilename(), "examples")));
1473 QStringList filter(qt_("LyX Documents (*.lyx)"));
1474 filter << qt_("LyX-1.3.x Documents (*.lyx13)")
1475 << qt_("LyX-1.4.x Documents (*.lyx14)")
1476 << qt_("LyX-1.5.x Documents (*.lyx15)")
1477 << qt_("LyX-1.6.x Documents (*.lyx16)");
1478 FileDialog::Result result =
1479 dlg.open(toqstr(initpath), filter);
1481 if (result.first == FileDialog::Later)
1484 filename = fromqstr(result.second);
1486 // check selected filename
1487 if (filename.empty()) {
1488 message(_("Canceled."));
1494 // get absolute path of file and add ".lyx" to the filename if
1496 FileName const fullname =
1497 fileSearch(string(), filename, "lyx", support::may_not_exist);
1498 if (!fullname.empty())
1499 filename = fullname.absFilename();
1501 if (!fullname.onlyPath().isDirectory()) {
1502 Alert::warning(_("Invalid filename"),
1503 bformat(_("The directory in the given path\n%1$s\ndoes not exist."),
1504 from_utf8(fullname.absFilename())));
1507 // if the file doesn't exist, let the user create one
1508 if (!fullname.exists()) {
1509 // the user specifically chose this name. Believe him.
1510 Buffer * const b = newFile(filename, string(), true);
1516 docstring const disp_fn = makeDisplayPath(filename);
1517 message(bformat(_("Opening document %1$s..."), disp_fn));
1520 Buffer * buf = loadDocument(fullname);
1522 buf->updateLabels();
1524 buf->errors("Parse");
1525 str2 = bformat(_("Document %1$s opened."), disp_fn);
1526 if (buf->lyxvc().inUse())
1527 str2 += " " + from_utf8(buf->lyxvc().versionString()) +
1528 " " + _("Version control detected.");
1530 str2 = bformat(_("Could not open document %1$s"), disp_fn);
1535 // FIXME: clean that
1536 static bool import(GuiView * lv, FileName const & filename,
1537 string const & format, ErrorList & errorList)
1539 FileName const lyxfile(support::changeExtension(filename.absFilename(), ".lyx"));
1541 string loader_format;
1542 vector<string> loaders = theConverters().loaders();
1543 if (find(loaders.begin(), loaders.end(), format) == loaders.end()) {
1544 for (vector<string>::const_iterator it = loaders.begin();
1545 it != loaders.end(); ++it) {
1546 if (!theConverters().isReachable(format, *it))
1549 string const tofile =
1550 support::changeExtension(filename.absFilename(),
1551 formats.extension(*it));
1552 if (!theConverters().convert(0, filename, FileName(tofile),
1553 filename, format, *it, errorList))
1555 loader_format = *it;
1558 if (loader_format.empty()) {
1559 frontend::Alert::error(_("Couldn't import file"),
1560 bformat(_("No information for importing the format %1$s."),
1561 formats.prettyName(format)));
1565 loader_format = format;
1567 if (loader_format == "lyx") {
1568 Buffer * buf = lv->loadDocument(lyxfile);
1571 buf->updateLabels();
1573 buf->errors("Parse");
1575 Buffer * const b = newFile(lyxfile.absFilename(), string(), true);
1579 bool as_paragraphs = loader_format == "textparagraph";
1580 string filename2 = (loader_format == format) ? filename.absFilename()
1581 : support::changeExtension(filename.absFilename(),
1582 formats.extension(loader_format));
1583 lv->view()->insertPlaintextFile(FileName(filename2), as_paragraphs);
1584 theLyXFunc().setLyXView(lv);
1585 lyx::dispatch(FuncRequest(LFUN_MARK_OFF));
1592 void GuiView::importDocument(string const & argument)
1595 string filename = split(argument, format, ' ');
1597 LYXERR(Debug::INFO, format << " file: " << filename);
1599 // need user interaction
1600 if (filename.empty()) {
1601 string initpath = lyxrc.document_path;
1603 Buffer const * buf = buffer();
1605 string const trypath = buf->filePath();
1606 // If directory is writeable, use this as default.
1607 if (FileName(trypath).isDirWritable())
1611 docstring const text = bformat(_("Select %1$s file to import"),
1612 formats.prettyName(format));
1614 FileDialog dlg(toqstr(text), LFUN_BUFFER_IMPORT);
1615 dlg.setButton1(qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
1616 dlg.setButton2(qt_("Examples|#E#e"),
1617 toqstr(addPath(package().system_support().absFilename(), "examples")));
1619 docstring filter = formats.prettyName(format);
1622 filter += from_utf8(formats.extension(format));
1625 FileDialog::Result result =
1626 dlg.open(toqstr(initpath), fileFilters(toqstr(filter)));
1628 if (result.first == FileDialog::Later)
1631 filename = fromqstr(result.second);
1633 // check selected filename
1634 if (filename.empty())
1635 message(_("Canceled."));
1638 if (filename.empty())
1641 // get absolute path of file
1642 FileName const fullname(support::makeAbsPath(filename));
1644 FileName const lyxfile(support::changeExtension(fullname.absFilename(), ".lyx"));
1646 // Check if the document already is open
1647 Buffer * buf = theBufferList().getBuffer(lyxfile);
1650 if (!closeBuffer()) {
1651 message(_("Canceled."));
1656 docstring const displaypath = makeDisplayPath(lyxfile.absFilename(), 30);
1658 // if the file exists already, and we didn't do
1659 // -i lyx thefile.lyx, warn
1660 if (lyxfile.exists() && fullname != lyxfile) {
1662 docstring text = bformat(_("The document %1$s already exists.\n\n"
1663 "Do you want to overwrite that document?"), displaypath);
1664 int const ret = Alert::prompt(_("Overwrite document?"),
1665 text, 0, 1, _("&Overwrite"), _("&Cancel"));
1668 message(_("Canceled."));
1673 message(bformat(_("Importing %1$s..."), displaypath));
1674 ErrorList errorList;
1675 if (import(this, fullname, format, errorList))
1676 message(_("imported."));
1678 message(_("file not imported!"));
1680 // FIXME (Abdel 12/08/06): Is there a need to display the error list here?
1684 void GuiView::newDocument(string const & filename, bool from_template)
1686 FileName initpath(lyxrc.document_path);
1687 Buffer * buf = buffer();
1689 FileName const trypath(buf->filePath());
1690 // If directory is writeable, use this as default.
1691 if (trypath.isDirWritable())
1695 string templatefile;
1696 if (from_template) {
1697 templatefile = selectTemplateFile().absFilename();
1698 if (templatefile.empty())
1703 if (filename.empty())
1704 b = newUnnamedFile(templatefile, initpath);
1706 b = newFile(filename, templatefile, true);
1711 // If no new document could be created, it is unsure
1712 // whether there is a valid BufferView.
1714 // Ensure the cursor is correctly positioned on screen.
1715 view()->showCursor();
1719 void GuiView::insertLyXFile(docstring const & fname)
1721 BufferView * bv = view();
1726 FileName filename(to_utf8(fname));
1728 if (!filename.empty()) {
1729 bv->insertLyXFile(filename);
1733 // Launch a file browser
1735 string initpath = lyxrc.document_path;
1736 string const trypath = bv->buffer().filePath();
1737 // If directory is writeable, use this as default.
1738 if (FileName(trypath).isDirWritable())
1742 FileDialog dlg(qt_("Select LyX document to insert"), LFUN_FILE_INSERT);
1743 dlg.setButton1(qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
1744 dlg.setButton2(qt_("Examples|#E#e"),
1745 toqstr(addPath(package().system_support().absFilename(),
1748 FileDialog::Result result = dlg.open(toqstr(initpath),
1749 QStringList(qt_("LyX Documents (*.lyx)")));
1751 if (result.first == FileDialog::Later)
1755 filename.set(fromqstr(result.second));
1757 // check selected filename
1758 if (filename.empty()) {
1759 // emit message signal.
1760 message(_("Canceled."));
1764 bv->insertLyXFile(filename);
1768 void GuiView::insertPlaintextFile(docstring const & fname,
1771 BufferView * bv = view();
1775 if (!fname.empty() && !FileName::isAbsolute(to_utf8(fname))) {
1776 message(_("Absolute filename expected."));
1781 FileName filename(to_utf8(fname));
1783 if (!filename.empty()) {
1784 bv->insertPlaintextFile(filename, asParagraph);
1788 FileDialog dlg(qt_("Select file to insert"), (asParagraph ?
1789 LFUN_FILE_INSERT_PLAINTEXT_PARA : LFUN_FILE_INSERT_PLAINTEXT));
1791 FileDialog::Result result = dlg.open(toqstr(bv->buffer().filePath()),
1792 QStringList(qt_("All Files (*)")));
1794 if (result.first == FileDialog::Later)
1798 filename.set(fromqstr(result.second));
1800 // check selected filename
1801 if (filename.empty()) {
1802 // emit message signal.
1803 message(_("Canceled."));
1807 bv->insertPlaintextFile(filename, asParagraph);
1811 bool GuiView::renameBuffer(Buffer & b, docstring const & newname)
1813 FileName fname = b.fileName();
1814 FileName const oldname = fname;
1816 if (!newname.empty()) {
1818 fname = support::makeAbsPath(to_utf8(newname), oldname.onlyPath().absFilename());
1820 // Switch to this Buffer.
1823 // No argument? Ask user through dialog.
1825 FileDialog dlg(qt_("Choose a filename to save document as"),
1826 LFUN_BUFFER_WRITE_AS);
1827 dlg.setButton1(qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
1828 dlg.setButton2(qt_("Templates|#T#t"), toqstr(lyxrc.template_path));
1830 if (!isLyXFilename(fname.absFilename()))
1831 fname.changeExtension(".lyx");
1833 FileDialog::Result result =
1834 dlg.save(toqstr(fname.onlyPath().absFilename()),
1835 QStringList(qt_("LyX Documents (*.lyx)")),
1836 toqstr(fname.onlyFileName()));
1838 if (result.first == FileDialog::Later)
1841 fname.set(fromqstr(result.second));
1846 if (!isLyXFilename(fname.absFilename()))
1847 fname.changeExtension(".lyx");
1850 if (FileName(fname).exists()) {
1851 docstring const file = makeDisplayPath(fname.absFilename(), 30);
1852 docstring text = bformat(_("The document %1$s already "
1853 "exists.\n\nDo you want to "
1854 "overwrite that document?"),
1856 int const ret = Alert::prompt(_("Overwrite document?"),
1857 text, 0, 2, _("&Overwrite"), _("&Rename"), _("&Cancel"));
1860 case 1: return renameBuffer(b, docstring());
1861 case 2: return false;
1865 FileName oldauto = b.getAutosaveFilename();
1867 // Ok, change the name of the buffer
1868 b.setFileName(fname.absFilename());
1870 bool unnamed = b.isUnnamed();
1871 b.setUnnamed(false);
1872 b.saveCheckSum(fname);
1874 // bring the autosave file with us, just in case.
1875 b.moveAutosaveFile(oldauto);
1877 if (!saveBuffer(b)) {
1878 oldauto = b.getAutosaveFilename();
1879 b.setFileName(oldname.absFilename());
1880 b.setUnnamed(unnamed);
1881 b.saveCheckSum(oldname);
1882 b.moveAutosaveFile(oldauto);
1890 bool GuiView::saveBuffer(Buffer & b)
1892 if (workArea(b) && workArea(b)->inDialogMode())
1896 return renameBuffer(b, docstring());
1899 theSession().lastFiles().add(b.fileName());
1903 // Switch to this Buffer.
1906 // FIXME: we don't tell the user *WHY* the save failed !!
1907 docstring const file = makeDisplayPath(b.absFileName(), 30);
1908 docstring text = bformat(_("The document %1$s could not be saved.\n\n"
1909 "Do you want to rename the document and "
1910 "try again?"), file);
1911 int const ret = Alert::prompt(_("Rename and save?"),
1912 text, 0, 2, _("&Rename"), _("&Retry"), _("&Cancel"));
1915 if (!renameBuffer(b, docstring()))
1924 return saveBuffer(b);
1928 bool GuiView::closeBuffer()
1930 Buffer * buf = buffer();
1931 return buf && closeBuffer(*buf, !buf->parent());
1935 bool GuiView::closeBuffer(Buffer & buf, bool close_buffer,
1936 bool tolastopened, bool mark_active)
1938 // goto bookmark to update bookmark pit.
1939 //FIXME: we should update only the bookmarks related to this buffer!
1940 LYXERR(Debug::DEBUG, "GuiView::closeBuffer()");
1941 for (size_t i = 0; i < theSession().bookmarks().size(); ++i)
1942 theLyXFunc().gotoBookmark(i+1, false, false);
1944 if (saveBufferIfNeeded(buf)) {
1945 // save in sessions if requested
1946 // do not save childs if their master
1947 // is opened as well
1949 theSession().lastOpened().add(buf.fileName(), mark_active);
1951 removeWorkArea(currentMainWorkArea());
1953 theBufferList().release(&buf);
1960 bool GuiView::saveBufferIfNeeded(Buffer & buf)
1962 if (buf.isClean() || buf.paragraphs().empty())
1965 // Switch to this Buffer.
1970 if (buf.isUnnamed())
1971 file = from_utf8(buf.fileName().onlyFileName());
1973 file = buf.fileName().displayName(30);
1975 // Bring this window to top before asking questions.
1979 docstring const text = bformat(_("The document %1$s has unsaved changes."
1980 "\n\nDo you want to save the document or discard the changes?"), file);
1981 int const ret = Alert::prompt(_("Save changed document?"),
1982 text, 0, 2, _("&Save"), _("&Discard"), _("&Cancel"));
1986 if (!saveBuffer(buf))
1990 // if we crash after this we could
1991 // have no autosave file but I guess
1992 // this is really improbable (Jug)
1993 buf.removeAutosaveFile();
2002 void GuiView::gotoNextOrPreviousBuffer(NextOrPrevious np)
2004 Buffer * const curbuf = buffer();
2005 Buffer * nextbuf = curbuf;
2007 if (np == NEXTBUFFER)
2008 nextbuf = theBufferList().next(nextbuf);
2010 nextbuf = theBufferList().previous(nextbuf);
2011 if (nextbuf == curbuf)
2017 if (workArea(*nextbuf))
2024 bool GuiView::dispatch(FuncRequest const & cmd)
2026 BufferView * bv = view();
2027 // By default we won't need any update.
2029 bv->cursor().updateFlags(Update::None);
2030 bool dispatched = true;
2032 if (cmd.origin == FuncRequest::TOC) {
2033 GuiToc * toc = static_cast<GuiToc*>(findOrBuild("toc", false));
2034 toc->doDispatch(bv->cursor(), cmd);
2038 switch(cmd.action) {
2039 case LFUN_BUFFER_IMPORT:
2040 importDocument(to_utf8(cmd.argument()));
2043 case LFUN_BUFFER_SWITCH:
2044 if (FileName::isAbsolute(to_utf8(cmd.argument()))) {
2046 theBufferList().getBuffer(FileName(to_utf8(cmd.argument())));
2050 bv->cursor().message(_("Document not loaded"));
2054 case LFUN_BUFFER_NEXT:
2055 gotoNextOrPreviousBuffer(NEXTBUFFER);
2058 case LFUN_BUFFER_PREVIOUS:
2059 gotoNextOrPreviousBuffer(PREVBUFFER);
2062 case LFUN_COMMAND_EXECUTE: {
2063 bool const show_it = cmd.argument() != "off";
2064 // FIXME: this is a hack, "minibuffer" should not be
2066 if (GuiToolbar * t = toolbar("minibuffer")) {
2067 t->setVisible(show_it);
2068 if (show_it && t->commandBuffer())
2069 t->commandBuffer()->setFocus();
2073 case LFUN_DROP_LAYOUTS_CHOICE:
2074 d.layout_->showPopup();
2077 case LFUN_MENU_OPEN:
2078 if (QMenu * menu = guiApp->menus().menu(toqstr(cmd.argument()), *this))
2079 menu->exec(QCursor::pos());
2082 case LFUN_FILE_INSERT:
2083 insertLyXFile(cmd.argument());
2085 case LFUN_FILE_INSERT_PLAINTEXT_PARA:
2086 insertPlaintextFile(cmd.argument(), true);
2089 case LFUN_FILE_INSERT_PLAINTEXT:
2090 insertPlaintextFile(cmd.argument(), false);
2093 case LFUN_BUFFER_WRITE:
2095 saveBuffer(bv->buffer());
2098 case LFUN_BUFFER_WRITE_AS:
2100 renameBuffer(bv->buffer(), cmd.argument());
2103 case LFUN_BUFFER_WRITE_ALL: {
2104 Buffer * first = theBufferList().first();
2107 message(_("Saving all documents..."));
2108 // We cannot use a for loop as the buffer list cycles.
2111 if (!b->isClean()) {
2113 LYXERR(Debug::ACTION, "Saved " << b->absFileName());
2115 b = theBufferList().next(b);
2116 } while (b != first);
2117 message(_("All documents saved."));
2121 case LFUN_TOOLBAR_TOGGLE: {
2122 string const name = cmd.getArg(0);
2123 if (GuiToolbar * t = toolbar(name))
2128 case LFUN_DIALOG_UPDATE: {
2129 string const name = to_utf8(cmd.argument());
2130 // Can only update a dialog connected to an existing inset
2131 Inset * inset = getOpenInset(name);
2133 FuncRequest fr(LFUN_INSET_DIALOG_UPDATE, cmd.argument());
2134 inset->dispatch(view()->cursor(), fr);
2135 } else if (name == "paragraph") {
2136 lyx::dispatch(FuncRequest(LFUN_PARAGRAPH_UPDATE));
2137 } else if (name == "prefs" || name == "document") {
2138 updateDialog(name, string());
2143 case LFUN_DIALOG_TOGGLE: {
2144 if (isDialogVisible(cmd.getArg(0)))
2145 dispatch(FuncRequest(LFUN_DIALOG_HIDE, cmd.argument()));
2147 dispatch(FuncRequest(LFUN_DIALOG_SHOW, cmd.argument()));
2151 case LFUN_DIALOG_DISCONNECT_INSET:
2152 disconnectDialog(to_utf8(cmd.argument()));
2155 case LFUN_DIALOG_HIDE: {
2156 guiApp->hideDialogs(to_utf8(cmd.argument()), 0);
2160 case LFUN_DIALOG_SHOW: {
2161 string const name = cmd.getArg(0);
2162 string data = trim(to_utf8(cmd.argument()).substr(name.size()));
2164 if (name == "character") {
2165 data = freefont2string();
2167 showDialog("character", data);
2168 } else if (name == "latexlog") {
2169 Buffer::LogType type;
2170 string const logfile = buffer()->logName(&type);
2172 case Buffer::latexlog:
2175 case Buffer::buildlog:
2179 data += Lexer::quoteString(logfile);
2180 showDialog("log", data);
2181 } else if (name == "vclog") {
2182 string const data = "vc " +
2183 Lexer::quoteString(buffer()->lyxvc().getLogFile());
2184 showDialog("log", data);
2185 } else if (name == "symbols") {
2186 data = bv->cursor().getEncoding()->name();
2188 showDialog("symbols", data);
2190 } else if (name == "prefs" && isFullScreen()) {
2191 FuncRequest fr(LFUN_INSET_INSERT, "fullscreen");
2193 showDialog("prefs", data);
2195 showDialog(name, data);
2199 case LFUN_INSET_APPLY: {
2200 string const name = cmd.getArg(0);
2201 Inset * inset = getOpenInset(name);
2203 // put cursor in front of inset.
2204 if (!view()->setCursorFromInset(inset)) {
2205 LASSERT(false, break);
2208 // useful if we are called from a dialog.
2209 view()->cursor().beginUndoGroup();
2210 view()->cursor().recordUndo();
2211 FuncRequest fr(LFUN_INSET_MODIFY, cmd.argument());
2212 inset->dispatch(view()->cursor(), fr);
2213 view()->cursor().endUndoGroup();
2215 FuncRequest fr(LFUN_INSET_INSERT, cmd.argument());
2221 case LFUN_UI_TOGGLE:
2223 // Make sure the keyboard focus stays in the work area.
2227 case LFUN_SPLIT_VIEW:
2228 if (Buffer * buf = buffer()) {
2229 string const orientation = cmd.getArg(0);
2230 d.splitter_->setOrientation(orientation == "vertical"
2231 ? Qt::Vertical : Qt::Horizontal);
2232 TabWorkArea * twa = addTabWorkArea();
2233 GuiWorkArea * wa = twa->addWorkArea(*buf, *this);
2234 setCurrentWorkArea(wa);
2238 case LFUN_CLOSE_TAB_GROUP:
2239 if (TabWorkArea * twa = d.currentTabWorkArea()) {
2241 twa = d.currentTabWorkArea();
2242 // Switch to the next GuiWorkArea in the found TabWorkArea.
2244 // Make sure the work area is up to date.
2245 setCurrentWorkArea(twa->currentWorkArea());
2247 setCurrentWorkArea(0);
2252 case LFUN_COMPLETION_INLINE:
2253 if (d.current_work_area_)
2254 d.current_work_area_->completer().showInline();
2257 case LFUN_COMPLETION_POPUP:
2258 if (d.current_work_area_)
2259 d.current_work_area_->completer().showPopup();
2263 case LFUN_COMPLETION_COMPLETE:
2264 if (d.current_work_area_)
2265 d.current_work_area_->completer().tab();
2268 case LFUN_COMPLETION_CANCEL:
2269 if (d.current_work_area_) {
2270 if (d.current_work_area_->completer().popupVisible())
2271 d.current_work_area_->completer().hidePopup();
2273 d.current_work_area_->completer().hideInline();
2277 case LFUN_COMPLETION_ACCEPT:
2278 if (d.current_work_area_)
2279 d.current_work_area_->completer().activate();
2282 case LFUN_BUFFER_ZOOM_IN:
2283 case LFUN_BUFFER_ZOOM_OUT:
2284 if (cmd.argument().empty()) {
2285 if (cmd.action == LFUN_BUFFER_ZOOM_IN)
2290 lyxrc.zoom += convert<int>(cmd.argument());
2292 if (lyxrc.zoom < 10)
2295 // The global QPixmapCache is used in GuiPainter to cache text
2296 // painting so we must reset it.
2297 QPixmapCache::clear();
2298 guiApp->fontLoader().update();
2299 lyx::dispatch(FuncRequest(LFUN_SCREEN_FONT_UPDATE));
2307 // Part of automatic menu appearance feature.
2308 if (isFullScreen()) {
2309 if (menuBar()->isVisible() && lyxrc.full_screen_menubar)
2311 if (statusBar()->isVisible())
2312 statusBar()->hide();
2319 void GuiView::lfunUiToggle(FuncRequest const & cmd)
2321 string const arg = cmd.getArg(0);
2322 if (arg == "scrollbar") {
2323 // hide() is of no help
2324 if (d.current_work_area_->verticalScrollBarPolicy() ==
2325 Qt::ScrollBarAlwaysOff)
2327 d.current_work_area_->setVerticalScrollBarPolicy(
2328 Qt::ScrollBarAsNeeded);
2330 d.current_work_area_->setVerticalScrollBarPolicy(
2331 Qt::ScrollBarAlwaysOff);
2334 if (arg == "statusbar") {
2335 statusBar()->setVisible(!statusBar()->isVisible());
2338 if (arg == "menubar") {
2339 menuBar()->setVisible(!menuBar()->isVisible());
2342 #if QT_VERSION >= 0x040300
2343 if (arg == "frame") {
2345 getContentsMargins(&l, &t, &r, &b);
2346 //are the frames in default state?
2347 d.current_work_area_->setFrameStyle(QFrame::NoFrame);
2349 setContentsMargins(-2, -2, -2, -2);
2351 setContentsMargins(0, 0, 0, 0);
2356 if (arg == "fullscreen") {
2361 message(bformat("LFUN_UI_TOGGLE " + _("%1$s unknown command!"), from_utf8(arg)));
2365 void GuiView::toggleFullScreen()
2367 if (isFullScreen()) {
2368 for (int i = 0; i != d.splitter_->count(); ++i)
2369 d.tabWorkArea(i)->setFullScreen(false);
2370 #if QT_VERSION >= 0x040300
2371 setContentsMargins(0, 0, 0, 0);
2373 setWindowState(windowState() ^ Qt::WindowFullScreen);
2376 statusBar()->show();
2379 hideDialogs("prefs", 0);
2380 for (int i = 0; i != d.splitter_->count(); ++i)
2381 d.tabWorkArea(i)->setFullScreen(true);
2382 #if QT_VERSION >= 0x040300
2383 setContentsMargins(-2, -2, -2, -2);
2386 setWindowState(windowState() ^ Qt::WindowFullScreen);
2387 statusBar()->hide();
2388 if (lyxrc.full_screen_menubar)
2390 if (lyxrc.full_screen_toolbars) {
2391 ToolbarMap::iterator end = d.toolbars_.end();
2392 for (ToolbarMap::iterator it = d.toolbars_.begin(); it != end; ++it)
2397 // give dialogs like the TOC a chance to adapt
2402 Buffer const * GuiView::updateInset(Inset const * inset)
2404 if (!d.current_work_area_)
2408 d.current_work_area_->scheduleRedraw();
2410 return &d.current_work_area_->bufferView().buffer();
2414 void GuiView::restartCursor()
2416 /* When we move around, or type, it's nice to be able to see
2417 * the cursor immediately after the keypress.
2419 if (d.current_work_area_)
2420 d.current_work_area_->startBlinkingCursor();
2422 // Take this occasion to update the other GUI elements.
2428 void GuiView::updateCompletion(Cursor & cur, bool start, bool keep)
2430 if (d.current_work_area_)
2431 d.current_work_area_->completer().updateVisibility(cur, start, keep);
2436 // This list should be kept in sync with the list of insets in
2437 // src/insets/Inset.cpp. I.e., if a dialog goes with an inset, the
2438 // dialog should have the same name as the inset.
2439 // Changes should be also recorded in LFUN_DIALOG_SHOW doxygen
2440 // docs in LyXAction.cpp.
2442 char const * const dialognames[] = {
2443 "aboutlyx", "bibitem", "bibtex", "box", "branch", "changes", "character",
2444 "citation", "document", "errorlist", "ert", "external", "file", "findreplace",
2445 "findreplaceadv", "float", "graphics", "href", "include", "index",
2446 "index_print", "info", "listings", "label", "log", "mathdelimiter",
2447 "mathmatrix", "mathspace", "nomenclature", "nomencl_print", "note",
2448 "paragraph", "phantom", "prefs", "print", "ref", "sendto", "space",
2449 "spellchecker", "symbols", "tabular", "tabularcreate", "thesaurus", "texinfo",
2450 "toc", "view-source", "vspace", "wrap" };
2452 char const * const * const end_dialognames =
2453 dialognames + (sizeof(dialognames) / sizeof(char *));
2457 cmpCStr(char const * name) : name_(name) {}
2458 bool operator()(char const * other) {
2459 return strcmp(other, name_) == 0;
2466 bool isValidName(string const & name)
2468 return find_if(dialognames, end_dialognames,
2469 cmpCStr(name.c_str())) != end_dialognames;
2475 void GuiView::resetDialogs()
2477 // Make sure that no LFUN uses any LyXView.
2478 theLyXFunc().setLyXView(0);
2481 constructToolbars();
2482 guiApp->menus().fillMenuBar(menuBar(), this, false);
2483 d.layout_->updateContents(true);
2484 // Now update controls with current buffer.
2485 theLyXFunc().setLyXView(this);
2491 Dialog * GuiView::findOrBuild(string const & name, bool hide_it)
2493 if (!isValidName(name))
2496 map<string, DialogPtr>::iterator it = d.dialogs_.find(name);
2498 if (it != d.dialogs_.end()) {
2500 it->second->hideView();
2501 return it->second.get();
2504 Dialog * dialog = build(name);
2505 d.dialogs_[name].reset(dialog);
2506 if (lyxrc.allow_geometry_session)
2507 dialog->restoreSession();
2514 void GuiView::showDialog(string const & name, string const & data,
2522 Dialog * dialog = findOrBuild(name, false);
2524 dialog->showData(data);
2526 d.open_insets_[name] = inset;
2529 catch (ExceptionMessage const & ex) {
2537 bool GuiView::isDialogVisible(string const & name) const
2539 map<string, DialogPtr>::const_iterator it = d.dialogs_.find(name);
2540 if (it == d.dialogs_.end())
2542 return it->second.get()->isVisibleView() && !it->second.get()->isClosing();
2546 void GuiView::hideDialog(string const & name, Inset * inset)
2548 map<string, DialogPtr>::const_iterator it = d.dialogs_.find(name);
2549 if (it == d.dialogs_.end())
2552 if (inset && inset != getOpenInset(name))
2555 Dialog * const dialog = it->second.get();
2556 if (dialog->isVisibleView())
2558 d.open_insets_[name] = 0;
2562 void GuiView::disconnectDialog(string const & name)
2564 if (!isValidName(name))
2567 if (d.open_insets_.find(name) != d.open_insets_.end())
2568 d.open_insets_[name] = 0;
2572 Inset * GuiView::getOpenInset(string const & name) const
2574 if (!isValidName(name))
2577 map<string, Inset *>::const_iterator it = d.open_insets_.find(name);
2578 return it == d.open_insets_.end() ? 0 : it->second;
2582 void GuiView::hideAll() const
2584 map<string, DialogPtr>::const_iterator it = d.dialogs_.begin();
2585 map<string, DialogPtr>::const_iterator end = d.dialogs_.end();
2587 for(; it != end; ++it)
2588 it->second->hideView();
2592 void GuiView::updateDialogs()
2594 map<string, DialogPtr>::const_iterator it = d.dialogs_.begin();
2595 map<string, DialogPtr>::const_iterator end = d.dialogs_.end();
2597 for(; it != end; ++it) {
2598 Dialog * dialog = it->second.get();
2599 if (dialog && dialog->isVisibleView())
2600 dialog->checkStatus();
2607 // will be replaced by a proper factory...
2608 Dialog * createGuiAbout(GuiView & lv);
2609 Dialog * createGuiBibitem(GuiView & lv);
2610 Dialog * createGuiBibtex(GuiView & lv);
2611 Dialog * createGuiBox(GuiView & lv);
2612 Dialog * createGuiBranch(GuiView & lv);
2613 Dialog * createGuiChanges(GuiView & lv);
2614 Dialog * createGuiCharacter(GuiView & lv);
2615 Dialog * createGuiCitation(GuiView & lv);
2616 Dialog * createGuiDelimiter(GuiView & lv);
2617 Dialog * createGuiDocument(GuiView & lv);
2618 Dialog * createGuiErrorList(GuiView & lv);
2619 Dialog * createGuiERT(GuiView & lv);
2620 Dialog * createGuiExternal(GuiView & lv);
2621 Dialog * createGuiFloat(GuiView & lv);
2622 Dialog * createGuiGraphics(GuiView & lv);
2623 Dialog * createGuiInclude(GuiView & lv);
2624 Dialog * createGuiIndex(GuiView & lv);
2625 Dialog * createGuiInfo(GuiView & lv);
2626 Dialog * createGuiLabel(GuiView & lv);
2627 Dialog * createGuiListings(GuiView & lv);
2628 Dialog * createGuiLog(GuiView & lv);
2629 Dialog * createGuiMathHSpace(GuiView & lv);
2630 Dialog * createGuiMathMatrix(GuiView & lv);
2631 Dialog * createGuiNomenclature(GuiView & lv);
2632 Dialog * createGuiNote(GuiView & lv);
2633 Dialog * createGuiParagraph(GuiView & lv);
2634 Dialog * createGuiPhantom(GuiView & lv);
2635 Dialog * createGuiPreferences(GuiView & lv);
2636 Dialog * createGuiPrint(GuiView & lv);
2637 Dialog * createGuiPrintindex(GuiView & lv);
2638 Dialog * createGuiPrintNomencl(GuiView & lv);
2639 Dialog * createGuiRef(GuiView & lv);
2640 Dialog * createGuiSearch(GuiView & lv);
2641 Dialog * createGuiSearchAdv(GuiView & lv);
2642 Dialog * createGuiSendTo(GuiView & lv);
2643 Dialog * createGuiShowFile(GuiView & lv);
2644 Dialog * createGuiSpellchecker(GuiView & lv);
2645 Dialog * createGuiSymbols(GuiView & lv);
2646 Dialog * createGuiTabularCreate(GuiView & lv);
2647 Dialog * createGuiTabular(GuiView & lv);
2648 Dialog * createGuiTexInfo(GuiView & lv);
2649 Dialog * createGuiTextHSpace(GuiView & lv);
2650 Dialog * createGuiToc(GuiView & lv);
2651 Dialog * createGuiThesaurus(GuiView & lv);
2652 Dialog * createGuiHyperlink(GuiView & lv);
2653 Dialog * createGuiVSpace(GuiView & lv);
2654 Dialog * createGuiViewSource(GuiView & lv);
2655 Dialog * createGuiWrap(GuiView & lv);
2658 Dialog * GuiView::build(string const & name)
2660 LASSERT(isValidName(name), return 0);
2662 if (name == "aboutlyx")
2663 return createGuiAbout(*this);
2664 if (name == "bibitem")
2665 return createGuiBibitem(*this);
2666 if (name == "bibtex")
2667 return createGuiBibtex(*this);
2669 return createGuiBox(*this);
2670 if (name == "branch")
2671 return createGuiBranch(*this);
2672 if (name == "changes")
2673 return createGuiChanges(*this);
2674 if (name == "character")
2675 return createGuiCharacter(*this);
2676 if (name == "citation")
2677 return createGuiCitation(*this);
2678 if (name == "document")
2679 return createGuiDocument(*this);
2680 if (name == "errorlist")
2681 return createGuiErrorList(*this);
2683 return createGuiERT(*this);
2684 if (name == "external")
2685 return createGuiExternal(*this);
2687 return createGuiShowFile(*this);
2688 if (name == "findreplace")
2689 return createGuiSearch(*this);
2690 if (name == "findreplaceadv")
2691 return createGuiSearchAdv(*this);
2692 if (name == "float")
2693 return createGuiFloat(*this);
2694 if (name == "graphics")
2695 return createGuiGraphics(*this);
2697 return createGuiHyperlink(*this);
2698 if (name == "include")
2699 return createGuiInclude(*this);
2700 if (name == "index")
2701 return createGuiIndex(*this);
2702 if (name == "index_print")
2703 return createGuiPrintindex(*this);
2705 return createGuiInfo(*this);
2706 if (name == "label")
2707 return createGuiLabel(*this);
2708 if (name == "listings")
2709 return createGuiListings(*this);
2711 return createGuiLog(*this);
2712 if (name == "mathdelimiter")
2713 return createGuiDelimiter(*this);
2714 if (name == "mathspace")
2715 return createGuiMathHSpace(*this);
2716 if (name == "mathmatrix")
2717 return createGuiMathMatrix(*this);
2718 if (name == "nomenclature")
2719 return createGuiNomenclature(*this);
2720 if (name == "nomencl_print")
2721 return createGuiPrintNomencl(*this);
2723 return createGuiNote(*this);
2724 if (name == "paragraph")
2725 return createGuiParagraph(*this);
2726 if (name == "phantom")
2727 return createGuiPhantom(*this);
2728 if (name == "prefs")
2729 return createGuiPreferences(*this);
2730 if (name == "print")
2731 return createGuiPrint(*this);
2733 return createGuiRef(*this);
2734 if (name == "sendto")
2735 return createGuiSendTo(*this);
2736 if (name == "space")
2737 return createGuiTextHSpace(*this);
2738 if (name == "spellchecker")
2739 return createGuiSpellchecker(*this);
2740 if (name == "symbols")
2741 return createGuiSymbols(*this);
2742 if (name == "tabular")
2743 return createGuiTabular(*this);
2744 if (name == "tabularcreate")
2745 return createGuiTabularCreate(*this);
2746 if (name == "texinfo")
2747 return createGuiTexInfo(*this);
2748 if (name == "thesaurus")
2749 return createGuiThesaurus(*this);
2751 return createGuiToc(*this);
2752 if (name == "view-source")
2753 return createGuiViewSource(*this);
2754 if (name == "vspace")
2755 return createGuiVSpace(*this);
2757 return createGuiWrap(*this);
2763 } // namespace frontend
2766 #include "moc_GuiView.cpp"