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
300 // set ourself as the current view. This is needed for the menu bar
301 // filling, at least for the static special menu item on Mac. Otherwise
302 // they are greyed out.
303 theLyXFunc().setLyXView(this);
305 // Fill up the menu bar.
306 guiApp->menus().fillMenuBar(menuBar(), this, true);
308 setCentralWidget(d.stack_widget_);
310 // Start autosave timer
311 if (lyxrc.autosave) {
312 d.autosave_timeout_.timeout.connect(boost::bind(&GuiView::autoSave, this));
313 d.autosave_timeout_.setTimeout(lyxrc.autosave * 1000);
314 d.autosave_timeout_.start();
316 connect(&d.statusbar_timer_, SIGNAL(timeout()),
317 this, SLOT(clearMessage()));
319 // We don't want to keep the window in memory if it is closed.
320 setAttribute(Qt::WA_DeleteOnClose, true);
322 #if (!defined(Q_WS_WIN) && !defined(Q_WS_MACX))
323 // assign an icon to main form. We do not do it under Qt/Win or Qt/Mac,
324 // since the icon is provided in the application bundle.
325 setWindowIcon(getPixmap("images/", "lyx", "png"));
329 setAcceptDrops(true);
331 statusBar()->setSizeGripEnabled(true);
333 // Forbid too small unresizable window because it can happen
334 // with some window manager under X11.
335 setMinimumSize(300, 200);
337 if (lyxrc.allow_geometry_session) {
338 // Now take care of session management.
343 // no session handling, default to a sane size.
344 setGeometry(50, 50, 690, 510);
347 // clear session data if any.
349 settings.remove("views");
359 void GuiView::saveLayout() const
362 settings.beginGroup("views");
363 settings.beginGroup(QString::number(id_));
365 settings.setValue("pos", pos());
366 settings.setValue("size", size());
368 settings.setValue("geometry", saveGeometry());
370 settings.setValue("layout", saveState(0));
371 settings.setValue("icon_size", iconSize());
375 bool GuiView::restoreLayout()
378 settings.beginGroup("views");
379 settings.beginGroup(QString::number(id_));
380 QString const icon_key = "icon_size";
381 if (!settings.contains(icon_key))
384 //code below is skipped when when ~/.config/LyX is (re)created
385 setIconSize(settings.value(icon_key).toSize());
387 QPoint pos = settings.value("pos", QPoint(50, 50)).toPoint();
388 QSize size = settings.value("size", QSize(690, 510)).toSize();
392 // Work-around for bug #6034: the window ends up in an undetermined
393 // state when trying to restore a maximized window when it is
394 // already maximized.
395 if (!(windowState() & Qt::WindowMaximized))
396 if (!restoreGeometry(settings.value("geometry").toByteArray()))
397 setGeometry(50, 50, 690, 510);
399 // Make sure layout is correctly oriented.
400 setLayoutDirection(qApp->layoutDirection());
402 // Allow the toc and view-source dock widget to be restored if needed.
404 if ((dialog = findOrBuild("toc", true)))
405 // see bug 5082. At least setup title and enabled state.
406 // Visibility will be adjusted by restoreState below.
407 dialog->prepareView();
408 if ((dialog = findOrBuild("view-source", true)))
409 dialog->prepareView();
411 if (!restoreState(settings.value("layout").toByteArray(), 0))
418 GuiToolbar * GuiView::toolbar(string const & name)
420 ToolbarMap::iterator it = d.toolbars_.find(name);
421 if (it != d.toolbars_.end())
424 LYXERR(Debug::GUI, "Toolbar::display: no toolbar named " << name);
425 message(bformat(_("Unknown toolbar \"%1$s\""), from_utf8(name)));
430 void GuiView::constructToolbars()
432 ToolbarMap::iterator it = d.toolbars_.begin();
433 for (; it != d.toolbars_.end(); ++it)
437 // I don't like doing this here, but the standard toolbar
438 // destroys this object when it's destroyed itself (vfr)
439 d.layout_ = new LayoutBox(*this);
440 d.stack_widget_->addWidget(d.layout_);
441 d.layout_->move(0,0);
443 // extracts the toolbars from the backend
444 Toolbars::Infos::iterator cit = guiApp->toolbars().begin();
445 Toolbars::Infos::iterator end = guiApp->toolbars().end();
446 for (; cit != end; ++cit)
447 d.toolbars_[cit->name] = new GuiToolbar(*cit, *this);
451 void GuiView::initToolbars()
453 // extracts the toolbars from the backend
454 Toolbars::Infos::iterator cit = guiApp->toolbars().begin();
455 Toolbars::Infos::iterator end = guiApp->toolbars().end();
456 for (; cit != end; ++cit) {
457 GuiToolbar * tb = toolbar(cit->name);
460 int const visibility = guiApp->toolbars().defaultVisibility(cit->name);
462 tb->setVisible(false);
463 tb->setVisibility(visibility);
465 if (visibility & Toolbars::TOP) {
467 addToolBarBreak(Qt::TopToolBarArea);
468 addToolBar(Qt::TopToolBarArea, tb);
471 if (visibility & Toolbars::BOTTOM) {
472 // Qt < 4.2.2 cannot handle ToolBarBreak on non-TOP dock.
473 #if (QT_VERSION >= 0x040202)
474 addToolBarBreak(Qt::BottomToolBarArea);
476 addToolBar(Qt::BottomToolBarArea, tb);
479 if (visibility & Toolbars::LEFT) {
480 // Qt < 4.2.2 cannot handle ToolBarBreak on non-TOP dock.
481 #if (QT_VERSION >= 0x040202)
482 addToolBarBreak(Qt::LeftToolBarArea);
484 addToolBar(Qt::LeftToolBarArea, tb);
487 if (visibility & Toolbars::RIGHT) {
488 // Qt < 4.2.2 cannot handle ToolBarBreak on non-TOP dock.
489 #if (QT_VERSION >= 0x040202)
490 addToolBarBreak(Qt::RightToolBarArea);
492 addToolBar(Qt::RightToolBarArea, tb);
495 if (visibility & Toolbars::ON)
496 tb->setVisible(true);
501 TocModels & GuiView::tocModels()
503 return d.toc_models_;
507 void GuiView::setFocus()
509 LYXERR(Debug::DEBUG, "GuiView::setFocus()" << this);
510 // Make sure LyXFunc points to the correct view.
511 guiApp->setCurrentView(this);
512 theLyXFunc().setLyXView(this);
513 QMainWindow::setFocus();
514 if (d.current_work_area_)
515 d.current_work_area_->setFocus();
519 QMenu * GuiView::createPopupMenu()
521 return d.toolBarPopup(this);
525 void GuiView::showEvent(QShowEvent * e)
527 LYXERR(Debug::GUI, "Passed Geometry "
528 << size().height() << "x" << size().width()
529 << "+" << pos().x() << "+" << pos().y());
531 if (d.splitter_->count() == 0)
532 // No work area, switch to the background widget.
535 QMainWindow::showEvent(e);
539 /** Destroy only all tabbed WorkAreas. Destruction of other WorkAreas
540 ** is responsibility of the container (e.g., dialog)
542 void GuiView::closeEvent(QCloseEvent * close_event)
544 LYXERR(Debug::DEBUG, "GuiView::closeEvent()");
547 // it can happen that this event arrives without selecting the view,
548 // e.g. when clicking the close button on a background window.
550 if (!closeBufferAll(true)) {
552 close_event->ignore();
556 // Make sure that nothing will use this to be closed View.
557 guiApp->unregisterView(this);
559 if (isFullScreen()) {
560 // Switch off fullscreen before closing.
565 // Make sure the timer time out will not trigger a statusbar update.
566 d.statusbar_timer_.stop();
568 // Saving fullscreen requires additional tweaks in the toolbar code.
569 // It wouldn't also work under linux natively.
570 if (lyxrc.allow_geometry_session) {
571 // Save this window geometry and layout.
573 // Then the toolbar private states.
574 ToolbarMap::iterator end = d.toolbars_.end();
575 for (ToolbarMap::iterator it = d.toolbars_.begin(); it != end; ++it)
576 it->second->saveSession();
577 // Now take care of all other dialogs:
578 map<string, DialogPtr>::const_iterator it = d.dialogs_.begin();
579 for (; it!= d.dialogs_.end(); ++it)
580 it->second->saveSession();
583 close_event->accept();
587 bool GuiView::closeBufferAll(bool tolastopened)
589 GuiWorkArea * active_wa = currentMainWorkArea();
590 setCurrentWorkArea(active_wa);
592 // We might be in a situation that there is still a tabWorkArea, but
593 // there are no tabs anymore. This can happen when we get here after a
594 // TabWorkArea::lastWorkAreaRemoved() signal. Therefore we count how
595 // many TabWorkArea's have no documents anymore.
598 // We have to call count() each time, because it can happen that
599 // more than one splitter will disappear in one iteration (bug 5998).
600 for (; d.splitter_->count() > empty_twa; ) {
601 TabWorkArea * twa = d.tabWorkArea(empty_twa);
603 int twa_count = twa->count();
604 if (twa->count() == 0)
607 for (; twa_count; --twa_count) {
608 twa->setCurrentIndex(twa_count-1);
610 GuiWorkArea * wa = twa->currentWorkArea();
611 bool const is_active_wa = active_wa == wa;
612 Buffer & b = wa->bufferView().buffer();
615 // This is a child document, just close the tab
616 // after saving but keep the file loaded.
617 if (!closeWorkArea(wa, false, tolastopened, is_active_wa))
622 vector<Buffer *> clist = b.getChildren();
623 for (vector<Buffer *>::const_iterator it = clist.begin();
624 it != clist.end(); ++it) {
625 if ((*it)->isClean())
628 // If a child is dirty, do not close
629 // without user intervention
630 //FIXME: should buffers be closed or not?
631 if (!closeWorkArea(workArea(*c), false, false))
635 // We only want to close the buffer if the same buffer is not in
637 bool const close_buffer = !inMultiViews(wa);
639 // closeBuffer() needs buffer workArea still alive and
640 // set as currrent one, and destroys it
641 if (!closeWorkArea(wa, close_buffer, tolastopened, is_active_wa))
649 void GuiView::dragEnterEvent(QDragEnterEvent * event)
651 if (event->mimeData()->hasUrls())
653 /// \todo Ask lyx-devel is this is enough:
654 /// if (event->mimeData()->hasFormat("text/plain"))
655 /// event->acceptProposedAction();
659 void GuiView::dropEvent(QDropEvent * event)
661 QList<QUrl> files = event->mimeData()->urls();
665 LYXERR(Debug::GUI, "GuiView::dropEvent: got URLs!");
666 for (int i = 0; i != files.size(); ++i) {
667 string const file = os::internal_path(fromqstr(
668 files.at(i).toLocalFile()));
670 // Asynchronously post the event. DropEvent usually come
671 // from the BufferView. But reloading a file might close
672 // the BufferView from within its own event handler.
673 guiApp->dispatchDelayed(FuncRequest(LFUN_FILE_OPEN, file));
680 void GuiView::message(docstring const & str)
682 if (ForkedProcess::iAmAChild())
685 statusBar()->showMessage(toqstr(str));
686 d.statusbar_timer_.stop();
687 d.statusbar_timer_.start(3000);
691 void GuiView::smallSizedIcons()
693 setIconSize(QSize(d.smallIconSize, d.smallIconSize));
697 void GuiView::normalSizedIcons()
699 setIconSize(QSize(d.normalIconSize, d.normalIconSize));
703 void GuiView::bigSizedIcons()
705 setIconSize(QSize(d.bigIconSize, d.bigIconSize));
709 void GuiView::clearMessage()
713 theLyXFunc().setLyXView(this);
714 statusBar()->showMessage(toqstr(theLyXFunc().viewStatusMessage()));
715 d.statusbar_timer_.stop();
719 void GuiView::updateWindowTitle(GuiWorkArea * wa)
721 if (wa != d.current_work_area_)
723 setWindowTitle(qt_("LyX: ") + wa->windowTitle());
724 setWindowIconText(wa->windowIconText());
728 void GuiView::on_currentWorkAreaChanged(GuiWorkArea * wa)
731 disconnectBufferView();
732 connectBufferView(wa->bufferView());
733 connectBuffer(wa->bufferView().buffer());
734 d.current_work_area_ = wa;
735 QObject::connect(wa, SIGNAL(titleChanged(GuiWorkArea *)),
736 this, SLOT(updateWindowTitle(GuiWorkArea *)));
737 updateWindowTitle(wa);
741 // The document settings needs to be reinitialised.
742 updateDialog("document", "");
744 // Buffer-dependent dialogs must be updated. This is done here because
745 // some dialogs require buffer()->text.
750 void GuiView::on_lastWorkAreaRemoved()
753 // We already are in a close event. Nothing more to do.
756 if (d.splitter_->count() > 1)
757 // We have a splitter so don't close anything.
760 // Reset and updates the dialogs.
761 d.toc_models_.reset(0);
762 updateDialog("document", "");
765 resetWindowTitleAndIconText();
767 if (lyxrc.open_buffers_in_tabs)
768 // Nothing more to do, the window should stay open.
771 if (guiApp->viewIds().size() > 1) {
777 // On Mac we also close the last window because the application stay
778 // resident in memory. On other platforms we don't close the last
779 // window because this would quit the application.
785 void GuiView::updateStatusBar()
787 // let the user see the explicit message
788 if (d.statusbar_timer_.isActive())
791 theLyXFunc().setLyXView(this);
792 statusBar()->showMessage(toqstr(theLyXFunc().viewStatusMessage()));
796 bool GuiView::hasFocus() const
798 return qApp->activeWindow() == this;
802 bool GuiView::event(QEvent * e)
806 // Useful debug code:
807 //case QEvent::ActivationChange:
808 //case QEvent::WindowDeactivate:
809 //case QEvent::Paint:
810 //case QEvent::Enter:
811 //case QEvent::Leave:
812 //case QEvent::HoverEnter:
813 //case QEvent::HoverLeave:
814 //case QEvent::HoverMove:
815 //case QEvent::StatusTip:
816 //case QEvent::DragEnter:
817 //case QEvent::DragLeave:
821 case QEvent::WindowActivate: {
822 if (this == guiApp->currentView()) {
824 return QMainWindow::event(e);
826 guiApp->setCurrentView(this);
827 theLyXFunc().setLyXView(this);
828 if (d.current_work_area_) {
829 BufferView & bv = d.current_work_area_->bufferView();
830 connectBufferView(bv);
831 connectBuffer(bv.buffer());
832 // The document structure, name and dialogs might have
833 // changed in another view.
835 // The document settings needs to be reinitialised.
836 updateDialog("document", "");
839 resetWindowTitleAndIconText();
842 return QMainWindow::event(e);
845 case QEvent::ShortcutOverride: {
848 #if (!defined Q_WS_X11) || (QT_VERSION >= 0x040500)
849 if (isFullScreen() && menuBar()->isHidden()) {
850 QKeyEvent * ke = static_cast<QKeyEvent*>(e);
851 // FIXME: we should also try to detect special LyX shortcut such as
852 // Alt-P and Alt-M. Right now there is a hack in
853 // GuiWorkArea::processKeySym() that hides again the menubar for
855 if (ke->modifiers() & Qt::AltModifier && ke->key() != Qt::Key_Alt) {
857 return QMainWindow::event(e);
862 if (d.current_work_area_)
863 // Nothing special to do.
864 return QMainWindow::event(e);
866 QKeyEvent * ke = static_cast<QKeyEvent*>(e);
867 // Let Qt handle menu access and the Tab keys to navigate keys to navigate
869 if (ke->modifiers() & Qt::AltModifier || ke->key() == Qt::Key_Tab
870 || ke->key() == Qt::Key_Backtab)
871 return QMainWindow::event(e);
873 // Allow processing of shortcuts that are allowed even when no Buffer
875 theLyXFunc().setLyXView(this);
877 setKeySymbol(&sym, ke);
878 theLyXFunc().processKeySym(sym, q_key_state(ke->modifiers()));
884 return QMainWindow::event(e);
888 void GuiView::resetWindowTitleAndIconText()
890 setWindowTitle(qt_("LyX"));
891 setWindowIconText(qt_("LyX"));
894 bool GuiView::focusNextPrevChild(bool /*next*/)
901 void GuiView::setBusy(bool busy)
903 if (d.current_work_area_) {
904 d.current_work_area_->setUpdatesEnabled(!busy);
906 d.current_work_area_->stopBlinkingCursor();
908 d.current_work_area_->startBlinkingCursor();
912 QApplication::setOverrideCursor(Qt::WaitCursor);
914 QApplication::restoreOverrideCursor();
918 GuiWorkArea * GuiView::workArea(Buffer & buffer)
920 if (currentWorkArea()
921 && ¤tWorkArea()->bufferView().buffer() == &buffer)
922 return (GuiWorkArea *) currentWorkArea();
923 if (TabWorkArea * twa = d.currentTabWorkArea())
924 return twa->workArea(buffer);
929 GuiWorkArea * GuiView::addWorkArea(Buffer & buffer)
931 // Automatically create a TabWorkArea if there are none yet.
932 TabWorkArea * tab_widget = d.splitter_->count()
933 ? d.currentTabWorkArea() : addTabWorkArea();
934 return tab_widget->addWorkArea(buffer, *this);
938 TabWorkArea * GuiView::addTabWorkArea()
940 TabWorkArea * twa = new TabWorkArea;
941 QObject::connect(twa, SIGNAL(currentWorkAreaChanged(GuiWorkArea *)),
942 this, SLOT(on_currentWorkAreaChanged(GuiWorkArea *)));
943 QObject::connect(twa, SIGNAL(lastWorkAreaRemoved()),
944 this, SLOT(on_lastWorkAreaRemoved()));
946 d.splitter_->addWidget(twa);
947 d.stack_widget_->setCurrentWidget(d.splitter_);
952 GuiWorkArea const * GuiView::currentWorkArea() const
954 return d.current_work_area_;
958 GuiWorkArea * GuiView::currentWorkArea()
960 return d.current_work_area_;
964 GuiWorkArea const * GuiView::currentMainWorkArea() const
966 if (d.currentTabWorkArea() == NULL)
968 return d.currentTabWorkArea()->currentWorkArea();
972 GuiWorkArea * GuiView::currentMainWorkArea()
974 if (d.currentTabWorkArea() == NULL)
976 return d.currentTabWorkArea()->currentWorkArea();
980 void GuiView::setCurrentWorkArea(GuiWorkArea * wa)
982 LYXERR(Debug::DEBUG, "Setting current wa: " << wa << endl);
984 d.current_work_area_ = NULL;
988 GuiWorkArea * old_gwa = theGuiApp()->currentView()->currentWorkArea();
993 cap::saveSelection(view()->cursor());
995 theGuiApp()->setCurrentView(this);
996 d.current_work_area_ = wa;
997 for (int i = 0; i != d.splitter_->count(); ++i) {
998 if (d.tabWorkArea(i)->setCurrentWorkArea(wa)) {
999 //if (d.current_main_work_area_)
1000 // d.current_main_work_area_->setFrameStyle(QFrame::NoFrame);
1001 d.current_main_work_area_ = wa;
1002 //d.current_main_work_area_->setFrameStyle(QFrame::Box | QFrame::Plain);
1003 //d.current_main_work_area_->setLineWidth(2);
1004 LYXERR(Debug::DEBUG, "Current wa: " << currentWorkArea() << ", Current main wa: " << currentMainWorkArea());
1008 LYXERR(Debug::DEBUG, "This is not a tabbed wa");
1009 on_currentWorkAreaChanged(wa);
1010 BufferView & bv = wa->bufferView();
1011 bv.cursor().fixIfBroken();
1013 wa->setUpdatesEnabled(true);
1014 LYXERR(Debug::DEBUG, "Current wa: " << currentWorkArea() << ", Current main wa: " << currentMainWorkArea());
1018 void GuiView::removeWorkArea(GuiWorkArea * wa)
1020 LASSERT(wa, return);
1021 if (wa == d.current_work_area_) {
1023 disconnectBufferView();
1024 d.current_work_area_ = 0;
1025 d.current_main_work_area_ = 0;
1028 bool found_twa = false;
1029 for (int i = 0; i != d.splitter_->count(); ++i) {
1030 TabWorkArea * twa = d.tabWorkArea(i);
1031 if (twa->removeWorkArea(wa)) {
1032 // Found in this tab group, and deleted the GuiWorkArea.
1034 if (twa->count() != 0) {
1035 if (d.current_work_area_ == 0)
1036 // This means that we are closing the current GuiWorkArea, so
1037 // switch to the next GuiWorkArea in the found TabWorkArea.
1038 setCurrentWorkArea(twa->currentWorkArea());
1040 // No more WorkAreas in this tab group, so delete it.
1047 // It is not a tabbed work area (i.e., the search work area), so it
1048 // should be deleted by other means.
1049 LASSERT(found_twa, /* */);
1051 if (d.current_work_area_ == 0) {
1052 if (d.splitter_->count() != 0) {
1053 TabWorkArea * twa = d.currentTabWorkArea();
1054 setCurrentWorkArea(twa->currentWorkArea());
1056 // No more work areas, switch to the background widget.
1057 setCurrentWorkArea(0);
1063 LayoutBox * GuiView::getLayoutDialog() const
1069 void GuiView::updateLayoutList()
1072 d.layout_->updateContents(false);
1076 void GuiView::updateToolbars()
1078 ToolbarMap::iterator end = d.toolbars_.end();
1079 if (d.current_work_area_) {
1081 d.current_work_area_->bufferView().cursor().inMathed();
1083 lyx::getStatus(FuncRequest(LFUN_LAYOUT_TABULAR)).enabled();
1085 lyx::getStatus(FuncRequest(LFUN_CHANGES_TRACK)).enabled() &&
1086 lyx::getStatus(FuncRequest(LFUN_CHANGES_TRACK)).onoff(true);
1087 bool const mathmacrotemplate =
1088 lyx::getStatus(FuncRequest(LFUN_IN_MATHMACROTEMPLATE)).enabled();
1090 for (ToolbarMap::iterator it = d.toolbars_.begin(); it != end; ++it)
1091 it->second->update(math, table, review, mathmacrotemplate);
1093 for (ToolbarMap::iterator it = d.toolbars_.begin(); it != end; ++it)
1094 it->second->update(false, false, false, false);
1098 Buffer * GuiView::buffer()
1100 if (d.current_work_area_)
1101 return &d.current_work_area_->bufferView().buffer();
1106 Buffer const * GuiView::buffer() const
1108 if (d.current_work_area_)
1109 return &d.current_work_area_->bufferView().buffer();
1114 void GuiView::setBuffer(Buffer * newBuffer)
1116 LYXERR(Debug::DEBUG, "Setting buffer: " << newBuffer << std::endl);
1117 LASSERT(newBuffer, return);
1120 GuiWorkArea * wa = workArea(*newBuffer);
1122 newBuffer->masterBuffer()->updateLabels();
1123 wa = addWorkArea(*newBuffer);
1125 //Disconnect the old buffer...there's no new one.
1128 connectBuffer(*newBuffer);
1129 connectBufferView(wa->bufferView());
1130 setCurrentWorkArea(wa);
1136 void GuiView::connectBuffer(Buffer & buf)
1138 buf.setGuiDelegate(this);
1142 void GuiView::disconnectBuffer()
1144 if (d.current_work_area_)
1145 d.current_work_area_->bufferView().setGuiDelegate(0);
1149 void GuiView::connectBufferView(BufferView & bv)
1151 bv.setGuiDelegate(this);
1155 void GuiView::disconnectBufferView()
1157 if (d.current_work_area_)
1158 d.current_work_area_->bufferView().setGuiDelegate(0);
1162 void GuiView::errors(string const & error_type, bool from_master)
1164 ErrorList & el = from_master ?
1165 buffer()->masterBuffer()->errorList(error_type)
1166 : buffer()->errorList(error_type);
1167 string data = error_type;
1169 data = "from_master|" + error_type;
1171 showDialog("errorlist", data);
1175 void GuiView::updateTocItem(std::string const & type, DocIterator const & dit)
1177 d.toc_models_.updateItem(toqstr(type), dit);
1181 void GuiView::structureChanged()
1183 d.toc_models_.reset(view());
1184 // Navigator needs more than a simple update in this case. It needs to be
1186 updateDialog("toc", "");
1190 void GuiView::updateDialog(string const & name, string const & data)
1192 if (!isDialogVisible(name))
1195 map<string, DialogPtr>::const_iterator it = d.dialogs_.find(name);
1196 if (it == d.dialogs_.end())
1199 Dialog * const dialog = it->second.get();
1200 if (dialog->isVisibleView())
1201 dialog->initialiseParams(data);
1205 BufferView * GuiView::view()
1207 return d.current_work_area_ ? &d.current_work_area_->bufferView() : 0;
1211 void GuiView::autoSave()
1213 LYXERR(Debug::INFO, "Running autoSave()");
1216 view()->buffer().autoSave();
1220 void GuiView::resetAutosaveTimers()
1223 d.autosave_timeout_.restart();
1227 bool GuiView::getStatus(FuncRequest const & cmd, FuncStatus & flag)
1230 Buffer * buf = buffer();
1232 if (cmd.origin == FuncRequest::TOC) {
1233 GuiToc * toc = static_cast<GuiToc*>(findOrBuild("toc", false));
1235 if (toc->getStatus(view()->cursor(), cmd, fs))
1238 flag.setEnabled(false);
1242 switch(cmd.action) {
1243 case LFUN_BUFFER_WRITE:
1244 enable = buf && (buf->isUnnamed() || !buf->isClean());
1247 case LFUN_BUFFER_WRITE_AS:
1251 case LFUN_BUFFER_CLOSE_ALL: {
1253 BufferList::iterator it = theBufferList().begin();
1254 BufferList::iterator end = theBufferList().end();
1255 int visible_buffers = 0;
1256 for (; it != end; ++it) {
1259 if (visible_buffers > 1) {
1267 case LFUN_SPLIT_VIEW:
1268 if (cmd.getArg(0) == "vertical")
1269 enable = buf && (d.splitter_->count() == 1 ||
1270 d.splitter_->orientation() == Qt::Vertical);
1272 enable = buf && (d.splitter_->count() == 1 ||
1273 d.splitter_->orientation() == Qt::Horizontal);
1276 case LFUN_CLOSE_TAB_GROUP:
1277 enable = d.currentTabWorkArea();
1280 case LFUN_TOOLBAR_TOGGLE:
1281 if (GuiToolbar * t = toolbar(cmd.getArg(0)))
1282 flag.setOnOff(t->isVisible());
1285 case LFUN_UI_TOGGLE:
1286 flag.setOnOff(isFullScreen());
1289 case LFUN_DIALOG_TOGGLE:
1290 flag.setOnOff(isDialogVisible(cmd.getArg(0)));
1291 // fall through to set "enable"
1292 case LFUN_DIALOG_SHOW: {
1293 string const name = cmd.getArg(0);
1295 enable = name == "aboutlyx"
1296 || name == "file" //FIXME: should be removed.
1298 || name == "texinfo";
1299 else if (name == "print")
1300 enable = buf->isExportable("dvi")
1301 && lyxrc.print_command != "none";
1302 else if (name == "character" || name == "symbols") {
1303 if (buf->isReadonly() || !view() || !view()->cursor().inTexted())
1306 // FIXME we should consider passthru
1308 Inset const & in = view()->cursor().inset();
1309 enable = !in.getLayout().isPassThru();
1312 else if (name == "latexlog")
1313 enable = FileName(buf->logName()).isReadableFile();
1314 else if (name == "spellchecker")
1315 enable = theSpellChecker() && !buf->isReadonly();
1316 else if (name == "vclog")
1317 enable = buf->lyxvc().inUse();
1321 case LFUN_DIALOG_UPDATE: {
1322 string const name = cmd.getArg(0);
1324 enable = name == "prefs";
1328 case LFUN_INSET_APPLY: {
1329 string const name = cmd.getArg(0);
1330 Inset * inset = getOpenInset(name);
1332 FuncRequest fr(LFUN_INSET_MODIFY, cmd.argument());
1334 if (!inset->getStatus(view()->cursor(), fr, fs)) {
1335 // Every inset is supposed to handle this
1336 LASSERT(false, break);
1340 FuncRequest fr(LFUN_INSET_INSERT, cmd.argument());
1341 flag |= lyx::getStatus(fr);
1343 enable = flag.enabled();
1347 case LFUN_COMPLETION_INLINE:
1348 if (!d.current_work_area_
1349 || !d.current_work_area_->completer().inlinePossible(view()->cursor()))
1353 case LFUN_COMPLETION_POPUP:
1354 if (!d.current_work_area_
1355 || !d.current_work_area_->completer().popupPossible(view()->cursor()))
1359 case LFUN_COMPLETION_COMPLETE:
1360 if (!d.current_work_area_
1361 || !d.current_work_area_->completer().inlinePossible(view()->cursor()))
1365 case LFUN_COMPLETION_ACCEPT:
1366 if (!d.current_work_area_
1367 || (!d.current_work_area_->completer().popupVisible()
1368 && !d.current_work_area_->completer().inlineVisible()
1369 && !d.current_work_area_->completer().completionAvailable()))
1373 case LFUN_COMPLETION_CANCEL:
1374 if (!d.current_work_area_
1375 || (!d.current_work_area_->completer().popupVisible()
1376 && !d.current_work_area_->completer().inlineVisible()))
1380 case LFUN_BUFFER_ZOOM_OUT:
1381 enable = buf && lyxrc.zoom > 10;
1384 case LFUN_BUFFER_ZOOM_IN:
1393 flag.setEnabled(false);
1399 static FileName selectTemplateFile()
1401 FileDialog dlg(qt_("Select template file"));
1402 dlg.setButton1(qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
1403 dlg.setButton1(qt_("Templates|#T#t"), toqstr(lyxrc.template_path));
1405 FileDialog::Result result = dlg.open(toqstr(lyxrc.template_path),
1406 QStringList(qt_("LyX Documents (*.lyx)")));
1408 if (result.first == FileDialog::Later)
1410 if (result.second.isEmpty())
1412 return FileName(fromqstr(result.second));
1416 Buffer * GuiView::loadDocument(FileName const & filename, bool tolastfiles)
1420 Buffer * newBuffer = checkAndLoadLyXFile(filename);
1423 message(_("Document not loaded."));
1428 setBuffer(newBuffer);
1430 // scroll to the position when the file was last closed
1431 if (lyxrc.use_lastfilepos) {
1432 LastFilePosSection::FilePos filepos =
1433 theSession().lastFilePos().load(filename);
1434 view()->moveToPosition(filepos.pit, filepos.pos, 0, 0);
1438 theSession().lastFiles().add(filename);
1445 void GuiView::openDocument(string const & fname)
1447 string initpath = lyxrc.document_path;
1450 string const trypath = buffer()->filePath();
1451 // If directory is writeable, use this as default.
1452 if (FileName(trypath).isDirWritable())
1458 if (fname.empty()) {
1459 FileDialog dlg(qt_("Select document to open"), LFUN_FILE_OPEN);
1460 dlg.setButton1(qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
1461 dlg.setButton2(qt_("Examples|#E#e"),
1462 toqstr(addPath(package().system_support().absFilename(), "examples")));
1464 QStringList filter(qt_("LyX Documents (*.lyx)"));
1465 filter << qt_("LyX-1.3.x Documents (*.lyx13)")
1466 << qt_("LyX-1.4.x Documents (*.lyx14)")
1467 << qt_("LyX-1.5.x Documents (*.lyx15)")
1468 << qt_("LyX-1.6.x Documents (*.lyx16)");
1469 FileDialog::Result result =
1470 dlg.open(toqstr(initpath), filter);
1472 if (result.first == FileDialog::Later)
1475 filename = fromqstr(result.second);
1477 // check selected filename
1478 if (filename.empty()) {
1479 message(_("Canceled."));
1485 // get absolute path of file and add ".lyx" to the filename if
1487 FileName const fullname =
1488 fileSearch(string(), filename, "lyx", support::may_not_exist);
1489 if (!fullname.empty())
1490 filename = fullname.absFilename();
1492 if (!fullname.onlyPath().isDirectory()) {
1493 Alert::warning(_("Invalid filename"),
1494 bformat(_("The directory in the given path\n%1$s\ndoes not exist."),
1495 from_utf8(fullname.absFilename())));
1498 // if the file doesn't exist, let the user create one
1499 if (!fullname.exists()) {
1500 // the user specifically chose this name. Believe him.
1501 Buffer * const b = newFile(filename, string(), true);
1507 docstring const disp_fn = makeDisplayPath(filename);
1508 message(bformat(_("Opening document %1$s..."), disp_fn));
1511 Buffer * buf = loadDocument(fullname);
1513 buf->updateLabels();
1515 buf->errors("Parse");
1516 str2 = bformat(_("Document %1$s opened."), disp_fn);
1517 if (buf->lyxvc().inUse())
1518 str2 += " " + from_utf8(buf->lyxvc().versionString()) +
1519 " " + _("Version control detected.");
1521 str2 = bformat(_("Could not open document %1$s"), disp_fn);
1526 // FIXME: clean that
1527 static bool import(GuiView * lv, FileName const & filename,
1528 string const & format, ErrorList & errorList)
1530 FileName const lyxfile(support::changeExtension(filename.absFilename(), ".lyx"));
1532 string loader_format;
1533 vector<string> loaders = theConverters().loaders();
1534 if (find(loaders.begin(), loaders.end(), format) == loaders.end()) {
1535 for (vector<string>::const_iterator it = loaders.begin();
1536 it != loaders.end(); ++it) {
1537 if (!theConverters().isReachable(format, *it))
1540 string const tofile =
1541 support::changeExtension(filename.absFilename(),
1542 formats.extension(*it));
1543 if (!theConverters().convert(0, filename, FileName(tofile),
1544 filename, format, *it, errorList))
1546 loader_format = *it;
1549 if (loader_format.empty()) {
1550 frontend::Alert::error(_("Couldn't import file"),
1551 bformat(_("No information for importing the format %1$s."),
1552 formats.prettyName(format)));
1556 loader_format = format;
1558 if (loader_format == "lyx") {
1559 Buffer * buf = lv->loadDocument(lyxfile);
1562 buf->updateLabels();
1564 buf->errors("Parse");
1566 Buffer * const b = newFile(lyxfile.absFilename(), string(), true);
1570 bool as_paragraphs = loader_format == "textparagraph";
1571 string filename2 = (loader_format == format) ? filename.absFilename()
1572 : support::changeExtension(filename.absFilename(),
1573 formats.extension(loader_format));
1574 lv->view()->insertPlaintextFile(FileName(filename2), as_paragraphs);
1575 theLyXFunc().setLyXView(lv);
1576 lyx::dispatch(FuncRequest(LFUN_MARK_OFF));
1583 void GuiView::importDocument(string const & argument)
1586 string filename = split(argument, format, ' ');
1588 LYXERR(Debug::INFO, format << " file: " << filename);
1590 // need user interaction
1591 if (filename.empty()) {
1592 string initpath = lyxrc.document_path;
1594 Buffer const * buf = buffer();
1596 string const trypath = buf->filePath();
1597 // If directory is writeable, use this as default.
1598 if (FileName(trypath).isDirWritable())
1602 docstring const text = bformat(_("Select %1$s file to import"),
1603 formats.prettyName(format));
1605 FileDialog dlg(toqstr(text), LFUN_BUFFER_IMPORT);
1606 dlg.setButton1(qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
1607 dlg.setButton2(qt_("Examples|#E#e"),
1608 toqstr(addPath(package().system_support().absFilename(), "examples")));
1610 docstring filter = formats.prettyName(format);
1613 filter += from_utf8(formats.extension(format));
1616 FileDialog::Result result =
1617 dlg.open(toqstr(initpath), fileFilters(toqstr(filter)));
1619 if (result.first == FileDialog::Later)
1622 filename = fromqstr(result.second);
1624 // check selected filename
1625 if (filename.empty())
1626 message(_("Canceled."));
1629 if (filename.empty())
1632 // get absolute path of file
1633 FileName const fullname(support::makeAbsPath(filename));
1635 FileName const lyxfile(support::changeExtension(fullname.absFilename(), ".lyx"));
1637 // Check if the document already is open
1638 Buffer * buf = theBufferList().getBuffer(lyxfile);
1641 if (!closeBuffer()) {
1642 message(_("Canceled."));
1647 docstring const displaypath = makeDisplayPath(lyxfile.absFilename(), 30);
1649 // if the file exists already, and we didn't do
1650 // -i lyx thefile.lyx, warn
1651 if (lyxfile.exists() && fullname != lyxfile) {
1653 docstring text = bformat(_("The document %1$s already exists.\n\n"
1654 "Do you want to overwrite that document?"), displaypath);
1655 int const ret = Alert::prompt(_("Overwrite document?"),
1656 text, 0, 1, _("&Overwrite"), _("&Cancel"));
1659 message(_("Canceled."));
1664 message(bformat(_("Importing %1$s..."), displaypath));
1665 ErrorList errorList;
1666 if (import(this, fullname, format, errorList))
1667 message(_("imported."));
1669 message(_("file not imported!"));
1671 // FIXME (Abdel 12/08/06): Is there a need to display the error list here?
1675 void GuiView::newDocument(string const & filename, bool from_template)
1677 FileName initpath(lyxrc.document_path);
1678 Buffer * buf = buffer();
1680 FileName const trypath(buf->filePath());
1681 // If directory is writeable, use this as default.
1682 if (trypath.isDirWritable())
1686 string templatefile;
1687 if (from_template) {
1688 templatefile = selectTemplateFile().absFilename();
1689 if (templatefile.empty())
1694 if (filename.empty())
1695 b = newUnnamedFile(templatefile, initpath);
1697 b = newFile(filename, templatefile, true);
1702 // If no new document could be created, it is unsure
1703 // whether there is a valid BufferView.
1705 // Ensure the cursor is correctly positioned on screen.
1706 view()->showCursor();
1710 void GuiView::insertLyXFile(docstring const & fname)
1712 BufferView * bv = view();
1717 FileName filename(to_utf8(fname));
1719 if (!filename.empty()) {
1720 bv->insertLyXFile(filename);
1724 // Launch a file browser
1726 string initpath = lyxrc.document_path;
1727 string const trypath = bv->buffer().filePath();
1728 // If directory is writeable, use this as default.
1729 if (FileName(trypath).isDirWritable())
1733 FileDialog dlg(qt_("Select LyX document to insert"), LFUN_FILE_INSERT);
1734 dlg.setButton1(qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
1735 dlg.setButton2(qt_("Examples|#E#e"),
1736 toqstr(addPath(package().system_support().absFilename(),
1739 FileDialog::Result result = dlg.open(toqstr(initpath),
1740 QStringList(qt_("LyX Documents (*.lyx)")));
1742 if (result.first == FileDialog::Later)
1746 filename.set(fromqstr(result.second));
1748 // check selected filename
1749 if (filename.empty()) {
1750 // emit message signal.
1751 message(_("Canceled."));
1755 bv->insertLyXFile(filename);
1759 void GuiView::insertPlaintextFile(docstring const & fname,
1762 BufferView * bv = view();
1766 if (!fname.empty() && !FileName::isAbsolute(to_utf8(fname))) {
1767 message(_("Absolute filename expected."));
1772 FileName filename(to_utf8(fname));
1774 if (!filename.empty()) {
1775 bv->insertPlaintextFile(filename, asParagraph);
1779 FileDialog dlg(qt_("Select file to insert"), (asParagraph ?
1780 LFUN_FILE_INSERT_PLAINTEXT_PARA : LFUN_FILE_INSERT_PLAINTEXT));
1782 FileDialog::Result result = dlg.open(toqstr(bv->buffer().filePath()),
1783 QStringList(qt_("All Files (*)")));
1785 if (result.first == FileDialog::Later)
1789 filename.set(fromqstr(result.second));
1791 // check selected filename
1792 if (filename.empty()) {
1793 // emit message signal.
1794 message(_("Canceled."));
1798 bv->insertPlaintextFile(filename, asParagraph);
1802 bool GuiView::renameBuffer(Buffer & b, docstring const & newname)
1804 FileName fname = b.fileName();
1805 FileName const oldname = fname;
1807 if (!newname.empty()) {
1809 fname = support::makeAbsPath(to_utf8(newname), oldname.onlyPath().absFilename());
1811 // Switch to this Buffer.
1814 // No argument? Ask user through dialog.
1816 FileDialog dlg(qt_("Choose a filename to save document as"),
1817 LFUN_BUFFER_WRITE_AS);
1818 dlg.setButton1(qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
1819 dlg.setButton2(qt_("Templates|#T#t"), toqstr(lyxrc.template_path));
1821 if (!isLyXFilename(fname.absFilename()))
1822 fname.changeExtension(".lyx");
1824 FileDialog::Result result =
1825 dlg.save(toqstr(fname.onlyPath().absFilename()),
1826 QStringList(qt_("LyX Documents (*.lyx)")),
1827 toqstr(fname.onlyFileName()));
1829 if (result.first == FileDialog::Later)
1832 fname.set(fromqstr(result.second));
1837 if (!isLyXFilename(fname.absFilename()))
1838 fname.changeExtension(".lyx");
1841 if (FileName(fname).exists()) {
1842 docstring const file = makeDisplayPath(fname.absFilename(), 30);
1843 docstring text = bformat(_("The document %1$s already "
1844 "exists.\n\nDo you want to "
1845 "overwrite that document?"),
1847 int const ret = Alert::prompt(_("Overwrite document?"),
1848 text, 0, 2, _("&Overwrite"), _("&Rename"), _("&Cancel"));
1851 case 1: return renameBuffer(b, docstring());
1852 case 2: return false;
1856 FileName oldauto = b.getAutosaveFilename();
1858 // Ok, change the name of the buffer
1859 b.setFileName(fname.absFilename());
1861 bool unnamed = b.isUnnamed();
1862 b.setUnnamed(false);
1863 b.saveCheckSum(fname);
1865 // bring the autosave file with us, just in case.
1866 b.moveAutosaveFile(oldauto);
1868 if (!saveBuffer(b)) {
1869 oldauto = b.getAutosaveFilename();
1870 b.setFileName(oldname.absFilename());
1871 b.setUnnamed(unnamed);
1872 b.saveCheckSum(oldname);
1873 b.moveAutosaveFile(oldauto);
1881 bool GuiView::saveBuffer(Buffer & b)
1883 if (workArea(b) && workArea(b)->inDialogMode())
1887 return renameBuffer(b, docstring());
1890 theSession().lastFiles().add(b.fileName());
1894 // Switch to this Buffer.
1897 // FIXME: we don't tell the user *WHY* the save failed !!
1898 docstring const file = makeDisplayPath(b.absFileName(), 30);
1899 docstring text = bformat(_("The document %1$s could not be saved.\n\n"
1900 "Do you want to rename the document and "
1901 "try again?"), file);
1902 int const ret = Alert::prompt(_("Rename and save?"),
1903 text, 0, 2, _("&Rename"), _("&Retry"), _("&Cancel"));
1906 if (!renameBuffer(b, docstring()))
1915 return saveBuffer(b);
1919 bool GuiView::hideWorkArea(GuiWorkArea * wa)
1921 return closeWorkArea(wa, false);
1925 bool GuiView::closeBuffer()
1927 GuiWorkArea * wa = currentMainWorkArea();
1928 Buffer & buf = wa->bufferView().buffer();
1929 return wa && closeWorkArea(wa, !buf.parent());
1933 bool GuiView::closeWorkArea(GuiWorkArea * wa, bool close_buffer,
1934 bool tolastopened, bool mark_active)
1936 // goto bookmark to update bookmark pit.
1937 //FIXME: we should update only the bookmarks related to this buffer!
1938 LYXERR(Debug::DEBUG, "GuiView::closeBuffer()");
1939 for (size_t i = 0; i < theSession().bookmarks().size(); ++i)
1940 theLyXFunc().gotoBookmark(i+1, false, false);
1942 Buffer & buf = wa->bufferView().buffer();
1943 if (saveBufferIfNeeded(buf, !close_buffer)) {
1944 // save in sessions if requested
1945 // do not save childs if their master
1946 // is opened as well
1948 theSession().lastOpened().add(buf.fileName(), mark_active);
1952 theBufferList().release(&buf);
1959 bool GuiView::saveBufferIfNeeded(Buffer & buf, bool hiding)
1961 if (buf.isClean() || buf.paragraphs().empty())
1964 // Switch to this Buffer.
1969 if (buf.isUnnamed())
1970 file = from_utf8(buf.fileName().onlyFileName());
1972 file = buf.fileName().displayName(30);
1974 // Bring this window to top before asking questions.
1979 if (hiding && buf.isUnnamed()) {
1980 docstring const text = bformat(_("The document %1$s has not been "
1981 "saved yet.\n\nDo you want to save "
1982 "the document?"), file);
1983 ret = Alert::prompt(_("Save new document?"),
1984 text, 0, 1, _("&Save"), _("&Cancel"));
1988 docstring const text = bformat(_("The document %1$s has unsaved changes."
1989 "\n\nDo you want to save the document or discard the changes?"), file);
1990 ret = Alert::prompt(_("Save changed document?"),
1991 text, 0, 2, _("&Save"), _("&Discard"), _("&Cancel"));
1996 if (!saveBuffer(buf))
2000 // if we crash after this we could
2001 // have no autosave file but I guess
2002 // this is really improbable (Jug)
2003 buf.removeAutosaveFile();
2005 // revert all changes
2006 buf.loadLyXFile(buf.fileName());
2017 bool GuiView::inMultiViews(GuiWorkArea * wa)
2019 QList<int> const ids = guiApp->viewIds();
2020 Buffer & buf = wa->bufferView().buffer();
2023 for (int i = 0; i != ids.size() && found_twa <= 1; ++i) {
2027 if (guiApp->view(ids[i]).workArea(buf))
2034 void GuiView::gotoNextOrPreviousBuffer(NextOrPrevious np)
2036 Buffer * const curbuf = buffer();
2037 Buffer * nextbuf = curbuf;
2039 if (np == NEXTBUFFER)
2040 nextbuf = theBufferList().next(nextbuf);
2042 nextbuf = theBufferList().previous(nextbuf);
2043 if (nextbuf == curbuf)
2049 if (workArea(*nextbuf))
2056 bool GuiView::dispatch(FuncRequest const & cmd)
2058 BufferView * bv = view();
2059 // By default we won't need any update.
2061 bv->cursor().updateFlags(Update::None);
2062 bool dispatched = true;
2064 if (cmd.origin == FuncRequest::TOC) {
2065 GuiToc * toc = static_cast<GuiToc*>(findOrBuild("toc", false));
2066 toc->doDispatch(bv->cursor(), cmd);
2070 switch(cmd.action) {
2071 case LFUN_BUFFER_IMPORT:
2072 importDocument(to_utf8(cmd.argument()));
2075 case LFUN_BUFFER_SWITCH:
2076 if (FileName::isAbsolute(to_utf8(cmd.argument()))) {
2078 theBufferList().getBuffer(FileName(to_utf8(cmd.argument())));
2082 bv->cursor().message(_("Document not loaded"));
2086 case LFUN_BUFFER_NEXT:
2087 gotoNextOrPreviousBuffer(NEXTBUFFER);
2090 case LFUN_BUFFER_PREVIOUS:
2091 gotoNextOrPreviousBuffer(PREVBUFFER);
2094 case LFUN_COMMAND_EXECUTE: {
2095 bool const show_it = cmd.argument() != "off";
2096 // FIXME: this is a hack, "minibuffer" should not be
2098 if (GuiToolbar * t = toolbar("minibuffer")) {
2099 t->setVisible(show_it);
2100 if (show_it && t->commandBuffer())
2101 t->commandBuffer()->setFocus();
2105 case LFUN_DROP_LAYOUTS_CHOICE:
2106 d.layout_->showPopup();
2109 case LFUN_MENU_OPEN:
2110 if (QMenu * menu = guiApp->menus().menu(toqstr(cmd.argument()), *this))
2111 menu->exec(QCursor::pos());
2114 case LFUN_FILE_INSERT:
2115 insertLyXFile(cmd.argument());
2117 case LFUN_FILE_INSERT_PLAINTEXT_PARA:
2118 insertPlaintextFile(cmd.argument(), true);
2121 case LFUN_FILE_INSERT_PLAINTEXT:
2122 insertPlaintextFile(cmd.argument(), false);
2125 case LFUN_BUFFER_WRITE:
2127 saveBuffer(bv->buffer());
2130 case LFUN_BUFFER_WRITE_AS:
2132 renameBuffer(bv->buffer(), cmd.argument());
2135 case LFUN_BUFFER_WRITE_ALL: {
2136 Buffer * first = theBufferList().first();
2139 message(_("Saving all documents..."));
2140 // We cannot use a for loop as the buffer list cycles.
2143 if (!b->isClean()) {
2145 LYXERR(Debug::ACTION, "Saved " << b->absFileName());
2147 b = theBufferList().next(b);
2148 } while (b != first);
2149 message(_("All documents saved."));
2153 case LFUN_TOOLBAR_TOGGLE: {
2154 string const name = cmd.getArg(0);
2155 if (GuiToolbar * t = toolbar(name))
2160 case LFUN_DIALOG_UPDATE: {
2161 string const name = to_utf8(cmd.argument());
2162 // Can only update a dialog connected to an existing inset
2163 Inset * inset = getOpenInset(name);
2165 FuncRequest fr(LFUN_INSET_DIALOG_UPDATE, cmd.argument());
2166 inset->dispatch(view()->cursor(), fr);
2167 } else if (name == "paragraph") {
2168 lyx::dispatch(FuncRequest(LFUN_PARAGRAPH_UPDATE));
2169 } else if (name == "prefs" || name == "document") {
2170 updateDialog(name, string());
2175 case LFUN_DIALOG_TOGGLE: {
2176 if (isDialogVisible(cmd.getArg(0)))
2177 dispatch(FuncRequest(LFUN_DIALOG_HIDE, cmd.argument()));
2179 dispatch(FuncRequest(LFUN_DIALOG_SHOW, cmd.argument()));
2183 case LFUN_DIALOG_DISCONNECT_INSET:
2184 disconnectDialog(to_utf8(cmd.argument()));
2187 case LFUN_DIALOG_HIDE: {
2188 guiApp->hideDialogs(to_utf8(cmd.argument()), 0);
2192 case LFUN_DIALOG_SHOW: {
2193 string const name = cmd.getArg(0);
2194 string data = trim(to_utf8(cmd.argument()).substr(name.size()));
2196 if (name == "character") {
2197 data = freefont2string();
2199 showDialog("character", data);
2200 } else if (name == "latexlog") {
2201 Buffer::LogType type;
2202 string const logfile = buffer()->logName(&type);
2204 case Buffer::latexlog:
2207 case Buffer::buildlog:
2211 data += Lexer::quoteString(logfile);
2212 showDialog("log", data);
2213 } else if (name == "vclog") {
2214 string const data = "vc " +
2215 Lexer::quoteString(buffer()->lyxvc().getLogFile());
2216 showDialog("log", data);
2217 } else if (name == "symbols") {
2218 data = bv->cursor().getEncoding()->name();
2220 showDialog("symbols", data);
2222 } else if (name == "prefs" && isFullScreen()) {
2223 FuncRequest fr(LFUN_INSET_INSERT, "fullscreen");
2225 showDialog("prefs", data);
2227 showDialog(name, data);
2231 case LFUN_INSET_APPLY: {
2232 string const name = cmd.getArg(0);
2233 Inset * inset = getOpenInset(name);
2235 // put cursor in front of inset.
2236 if (!view()->setCursorFromInset(inset)) {
2237 LASSERT(false, break);
2240 // useful if we are called from a dialog.
2241 view()->cursor().beginUndoGroup();
2242 view()->cursor().recordUndo();
2243 FuncRequest fr(LFUN_INSET_MODIFY, cmd.argument());
2244 inset->dispatch(view()->cursor(), fr);
2245 view()->cursor().endUndoGroup();
2247 FuncRequest fr(LFUN_INSET_INSERT, cmd.argument());
2253 case LFUN_UI_TOGGLE:
2255 // Make sure the keyboard focus stays in the work area.
2259 case LFUN_SPLIT_VIEW:
2260 if (Buffer * buf = buffer()) {
2261 string const orientation = cmd.getArg(0);
2262 d.splitter_->setOrientation(orientation == "vertical"
2263 ? Qt::Vertical : Qt::Horizontal);
2264 TabWorkArea * twa = addTabWorkArea();
2265 GuiWorkArea * wa = twa->addWorkArea(*buf, *this);
2266 setCurrentWorkArea(wa);
2270 case LFUN_CLOSE_TAB_GROUP:
2271 if (TabWorkArea * twa = d.currentTabWorkArea()) {
2273 d.current_work_area_ = 0;
2274 twa = d.currentTabWorkArea();
2275 // Switch to the next GuiWorkArea in the found TabWorkArea.
2277 // Make sure the work area is up to date.
2278 setCurrentWorkArea(twa->currentWorkArea());
2280 setCurrentWorkArea(0);
2285 case LFUN_COMPLETION_INLINE:
2286 if (d.current_work_area_)
2287 d.current_work_area_->completer().showInline();
2290 case LFUN_COMPLETION_POPUP:
2291 if (d.current_work_area_)
2292 d.current_work_area_->completer().showPopup();
2296 case LFUN_COMPLETION_COMPLETE:
2297 if (d.current_work_area_)
2298 d.current_work_area_->completer().tab();
2301 case LFUN_COMPLETION_CANCEL:
2302 if (d.current_work_area_) {
2303 if (d.current_work_area_->completer().popupVisible())
2304 d.current_work_area_->completer().hidePopup();
2306 d.current_work_area_->completer().hideInline();
2310 case LFUN_COMPLETION_ACCEPT:
2311 if (d.current_work_area_)
2312 d.current_work_area_->completer().activate();
2315 case LFUN_BUFFER_ZOOM_IN:
2316 case LFUN_BUFFER_ZOOM_OUT:
2317 if (cmd.argument().empty()) {
2318 if (cmd.action == LFUN_BUFFER_ZOOM_IN)
2323 lyxrc.zoom += convert<int>(cmd.argument());
2325 if (lyxrc.zoom < 10)
2328 // The global QPixmapCache is used in GuiPainter to cache text
2329 // painting so we must reset it.
2330 QPixmapCache::clear();
2331 guiApp->fontLoader().update();
2332 lyx::dispatch(FuncRequest(LFUN_SCREEN_FONT_UPDATE));
2340 // Part of automatic menu appearance feature.
2341 if (isFullScreen()) {
2342 if (menuBar()->isVisible() && lyxrc.full_screen_menubar)
2344 if (statusBar()->isVisible())
2345 statusBar()->hide();
2352 void GuiView::lfunUiToggle(FuncRequest const & cmd)
2354 string const arg = cmd.getArg(0);
2355 if (arg == "scrollbar") {
2356 // hide() is of no help
2357 if (d.current_work_area_->verticalScrollBarPolicy() ==
2358 Qt::ScrollBarAlwaysOff)
2360 d.current_work_area_->setVerticalScrollBarPolicy(
2361 Qt::ScrollBarAsNeeded);
2363 d.current_work_area_->setVerticalScrollBarPolicy(
2364 Qt::ScrollBarAlwaysOff);
2367 if (arg == "statusbar") {
2368 statusBar()->setVisible(!statusBar()->isVisible());
2371 if (arg == "menubar") {
2372 menuBar()->setVisible(!menuBar()->isVisible());
2375 #if QT_VERSION >= 0x040300
2376 if (arg == "frame") {
2378 getContentsMargins(&l, &t, &r, &b);
2379 //are the frames in default state?
2380 d.current_work_area_->setFrameStyle(QFrame::NoFrame);
2382 setContentsMargins(-2, -2, -2, -2);
2384 setContentsMargins(0, 0, 0, 0);
2389 if (arg == "fullscreen") {
2394 message(bformat("LFUN_UI_TOGGLE " + _("%1$s unknown command!"), from_utf8(arg)));
2398 void GuiView::toggleFullScreen()
2400 if (isFullScreen()) {
2401 for (int i = 0; i != d.splitter_->count(); ++i)
2402 d.tabWorkArea(i)->setFullScreen(false);
2403 #if QT_VERSION >= 0x040300
2404 setContentsMargins(0, 0, 0, 0);
2406 setWindowState(windowState() ^ Qt::WindowFullScreen);
2409 statusBar()->show();
2412 hideDialogs("prefs", 0);
2413 for (int i = 0; i != d.splitter_->count(); ++i)
2414 d.tabWorkArea(i)->setFullScreen(true);
2415 #if QT_VERSION >= 0x040300
2416 setContentsMargins(-2, -2, -2, -2);
2419 setWindowState(windowState() ^ Qt::WindowFullScreen);
2420 statusBar()->hide();
2421 if (lyxrc.full_screen_menubar)
2423 if (lyxrc.full_screen_toolbars) {
2424 ToolbarMap::iterator end = d.toolbars_.end();
2425 for (ToolbarMap::iterator it = d.toolbars_.begin(); it != end; ++it)
2430 // give dialogs like the TOC a chance to adapt
2435 Buffer const * GuiView::updateInset(Inset const * inset)
2437 if (!d.current_work_area_)
2441 d.current_work_area_->scheduleRedraw();
2443 return &d.current_work_area_->bufferView().buffer();
2447 void GuiView::restartCursor()
2449 /* When we move around, or type, it's nice to be able to see
2450 * the cursor immediately after the keypress.
2452 if (d.current_work_area_)
2453 d.current_work_area_->startBlinkingCursor();
2455 // Take this occasion to update the other GUI elements.
2461 void GuiView::updateCompletion(Cursor & cur, bool start, bool keep)
2463 if (d.current_work_area_)
2464 d.current_work_area_->completer().updateVisibility(cur, start, keep);
2469 // This list should be kept in sync with the list of insets in
2470 // src/insets/Inset.cpp. I.e., if a dialog goes with an inset, the
2471 // dialog should have the same name as the inset.
2472 // Changes should be also recorded in LFUN_DIALOG_SHOW doxygen
2473 // docs in LyXAction.cpp.
2475 char const * const dialognames[] = {
2476 "aboutlyx", "bibitem", "bibtex", "box", "branch", "changes", "character",
2477 "citation", "document", "errorlist", "ert", "external", "file", "findreplace",
2478 "findreplaceadv", "float", "graphics", "href", "include", "index",
2479 "index_print", "info", "listings", "label", "log", "mathdelimiter",
2480 "mathmatrix", "mathspace", "nomenclature", "nomencl_print", "note",
2481 "paragraph", "phantom", "prefs", "print", "ref", "sendto", "space",
2482 "spellchecker", "symbols", "tabular", "tabularcreate", "thesaurus", "texinfo",
2483 "toc", "view-source", "vspace", "wrap" };
2485 char const * const * const end_dialognames =
2486 dialognames + (sizeof(dialognames) / sizeof(char *));
2490 cmpCStr(char const * name) : name_(name) {}
2491 bool operator()(char const * other) {
2492 return strcmp(other, name_) == 0;
2499 bool isValidName(string const & name)
2501 return find_if(dialognames, end_dialognames,
2502 cmpCStr(name.c_str())) != end_dialognames;
2508 void GuiView::resetDialogs()
2510 // Make sure that no LFUN uses any LyXView.
2511 theLyXFunc().setLyXView(0);
2514 constructToolbars();
2515 guiApp->menus().fillMenuBar(menuBar(), this, false);
2516 d.layout_->updateContents(true);
2517 // Now update controls with current buffer.
2518 theLyXFunc().setLyXView(this);
2524 Dialog * GuiView::findOrBuild(string const & name, bool hide_it)
2526 if (!isValidName(name))
2529 map<string, DialogPtr>::iterator it = d.dialogs_.find(name);
2531 if (it != d.dialogs_.end()) {
2533 it->second->hideView();
2534 return it->second.get();
2537 Dialog * dialog = build(name);
2538 d.dialogs_[name].reset(dialog);
2539 if (lyxrc.allow_geometry_session)
2540 dialog->restoreSession();
2547 void GuiView::showDialog(string const & name, string const & data,
2555 Dialog * dialog = findOrBuild(name, false);
2557 dialog->showData(data);
2559 d.open_insets_[name] = inset;
2562 catch (ExceptionMessage const & ex) {
2570 bool GuiView::isDialogVisible(string const & name) const
2572 map<string, DialogPtr>::const_iterator it = d.dialogs_.find(name);
2573 if (it == d.dialogs_.end())
2575 return it->second.get()->isVisibleView() && !it->second.get()->isClosing();
2579 void GuiView::hideDialog(string const & name, Inset * inset)
2581 map<string, DialogPtr>::const_iterator it = d.dialogs_.find(name);
2582 if (it == d.dialogs_.end())
2585 if (inset && inset != getOpenInset(name))
2588 Dialog * const dialog = it->second.get();
2589 if (dialog->isVisibleView())
2591 d.open_insets_[name] = 0;
2595 void GuiView::disconnectDialog(string const & name)
2597 if (!isValidName(name))
2600 if (d.open_insets_.find(name) != d.open_insets_.end())
2601 d.open_insets_[name] = 0;
2605 Inset * GuiView::getOpenInset(string const & name) const
2607 if (!isValidName(name))
2610 map<string, Inset *>::const_iterator it = d.open_insets_.find(name);
2611 return it == d.open_insets_.end() ? 0 : it->second;
2615 void GuiView::hideAll() const
2617 map<string, DialogPtr>::const_iterator it = d.dialogs_.begin();
2618 map<string, DialogPtr>::const_iterator end = d.dialogs_.end();
2620 for(; it != end; ++it)
2621 it->second->hideView();
2625 void GuiView::updateDialogs()
2627 map<string, DialogPtr>::const_iterator it = d.dialogs_.begin();
2628 map<string, DialogPtr>::const_iterator end = d.dialogs_.end();
2630 for(; it != end; ++it) {
2631 Dialog * dialog = it->second.get();
2632 if (dialog && dialog->isVisibleView())
2633 dialog->checkStatus();
2640 // will be replaced by a proper factory...
2641 Dialog * createGuiAbout(GuiView & lv);
2642 Dialog * createGuiBibitem(GuiView & lv);
2643 Dialog * createGuiBibtex(GuiView & lv);
2644 Dialog * createGuiBox(GuiView & lv);
2645 Dialog * createGuiBranch(GuiView & lv);
2646 Dialog * createGuiChanges(GuiView & lv);
2647 Dialog * createGuiCharacter(GuiView & lv);
2648 Dialog * createGuiCitation(GuiView & lv);
2649 Dialog * createGuiDelimiter(GuiView & lv);
2650 Dialog * createGuiDocument(GuiView & lv);
2651 Dialog * createGuiErrorList(GuiView & lv);
2652 Dialog * createGuiERT(GuiView & lv);
2653 Dialog * createGuiExternal(GuiView & lv);
2654 Dialog * createGuiFloat(GuiView & lv);
2655 Dialog * createGuiGraphics(GuiView & lv);
2656 Dialog * createGuiInclude(GuiView & lv);
2657 Dialog * createGuiIndex(GuiView & lv);
2658 Dialog * createGuiInfo(GuiView & lv);
2659 Dialog * createGuiLabel(GuiView & lv);
2660 Dialog * createGuiListings(GuiView & lv);
2661 Dialog * createGuiLog(GuiView & lv);
2662 Dialog * createGuiMathHSpace(GuiView & lv);
2663 Dialog * createGuiMathMatrix(GuiView & lv);
2664 Dialog * createGuiNomenclature(GuiView & lv);
2665 Dialog * createGuiNote(GuiView & lv);
2666 Dialog * createGuiParagraph(GuiView & lv);
2667 Dialog * createGuiPhantom(GuiView & lv);
2668 Dialog * createGuiPreferences(GuiView & lv);
2669 Dialog * createGuiPrint(GuiView & lv);
2670 Dialog * createGuiPrintindex(GuiView & lv);
2671 Dialog * createGuiPrintNomencl(GuiView & lv);
2672 Dialog * createGuiRef(GuiView & lv);
2673 Dialog * createGuiSearch(GuiView & lv);
2674 Dialog * createGuiSearchAdv(GuiView & lv);
2675 Dialog * createGuiSendTo(GuiView & lv);
2676 Dialog * createGuiShowFile(GuiView & lv);
2677 Dialog * createGuiSpellchecker(GuiView & lv);
2678 Dialog * createGuiSymbols(GuiView & lv);
2679 Dialog * createGuiTabularCreate(GuiView & lv);
2680 Dialog * createGuiTabular(GuiView & lv);
2681 Dialog * createGuiTexInfo(GuiView & lv);
2682 Dialog * createGuiTextHSpace(GuiView & lv);
2683 Dialog * createGuiToc(GuiView & lv);
2684 Dialog * createGuiThesaurus(GuiView & lv);
2685 Dialog * createGuiHyperlink(GuiView & lv);
2686 Dialog * createGuiVSpace(GuiView & lv);
2687 Dialog * createGuiViewSource(GuiView & lv);
2688 Dialog * createGuiWrap(GuiView & lv);
2691 Dialog * GuiView::build(string const & name)
2693 LASSERT(isValidName(name), return 0);
2695 if (name == "aboutlyx")
2696 return createGuiAbout(*this);
2697 if (name == "bibitem")
2698 return createGuiBibitem(*this);
2699 if (name == "bibtex")
2700 return createGuiBibtex(*this);
2702 return createGuiBox(*this);
2703 if (name == "branch")
2704 return createGuiBranch(*this);
2705 if (name == "changes")
2706 return createGuiChanges(*this);
2707 if (name == "character")
2708 return createGuiCharacter(*this);
2709 if (name == "citation")
2710 return createGuiCitation(*this);
2711 if (name == "document")
2712 return createGuiDocument(*this);
2713 if (name == "errorlist")
2714 return createGuiErrorList(*this);
2716 return createGuiERT(*this);
2717 if (name == "external")
2718 return createGuiExternal(*this);
2720 return createGuiShowFile(*this);
2721 if (name == "findreplace")
2722 return createGuiSearch(*this);
2723 if (name == "findreplaceadv")
2724 return createGuiSearchAdv(*this);
2725 if (name == "float")
2726 return createGuiFloat(*this);
2727 if (name == "graphics")
2728 return createGuiGraphics(*this);
2730 return createGuiHyperlink(*this);
2731 if (name == "include")
2732 return createGuiInclude(*this);
2733 if (name == "index")
2734 return createGuiIndex(*this);
2735 if (name == "index_print")
2736 return createGuiPrintindex(*this);
2738 return createGuiInfo(*this);
2739 if (name == "label")
2740 return createGuiLabel(*this);
2741 if (name == "listings")
2742 return createGuiListings(*this);
2744 return createGuiLog(*this);
2745 if (name == "mathdelimiter")
2746 return createGuiDelimiter(*this);
2747 if (name == "mathspace")
2748 return createGuiMathHSpace(*this);
2749 if (name == "mathmatrix")
2750 return createGuiMathMatrix(*this);
2751 if (name == "nomenclature")
2752 return createGuiNomenclature(*this);
2753 if (name == "nomencl_print")
2754 return createGuiPrintNomencl(*this);
2756 return createGuiNote(*this);
2757 if (name == "paragraph")
2758 return createGuiParagraph(*this);
2759 if (name == "phantom")
2760 return createGuiPhantom(*this);
2761 if (name == "prefs")
2762 return createGuiPreferences(*this);
2763 if (name == "print")
2764 return createGuiPrint(*this);
2766 return createGuiRef(*this);
2767 if (name == "sendto")
2768 return createGuiSendTo(*this);
2769 if (name == "space")
2770 return createGuiTextHSpace(*this);
2771 if (name == "spellchecker")
2772 return createGuiSpellchecker(*this);
2773 if (name == "symbols")
2774 return createGuiSymbols(*this);
2775 if (name == "tabular")
2776 return createGuiTabular(*this);
2777 if (name == "tabularcreate")
2778 return createGuiTabularCreate(*this);
2779 if (name == "texinfo")
2780 return createGuiTexInfo(*this);
2781 if (name == "thesaurus")
2782 return createGuiThesaurus(*this);
2784 return createGuiToc(*this);
2785 if (name == "view-source")
2786 return createGuiViewSource(*this);
2787 if (name == "vspace")
2788 return createGuiVSpace(*this);
2790 return createGuiWrap(*this);
2796 } // namespace frontend
2799 #include "moc_GuiView.cpp"