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();
614 // This is a child document, just close the tab
615 // after saving but keep the file loaded.
616 if (!closeBuffer(*b, false, tolastopened, is_active_wa))
621 vector<Buffer *> clist = b->getChildren();
622 for (vector<Buffer *>::const_iterator it = clist.begin();
623 it != clist.end(); ++it) {
624 if ((*it)->isClean())
627 // If a child is dirty, do not close
628 // without user intervention
629 //FIXME: should buffers be closed or not?
630 if (!closeBuffer(*c, false, false))
634 // We only want to close the buffer if the same buffer is not in
636 bool const close_buffer = !inMultiViews(wa);
638 // closeBuffer() needs buffer workArea still alive and
639 // set as currrent one, and destroys it
640 if (b && !closeBuffer(*b, close_buffer, tolastopened, is_active_wa))
648 void GuiView::dragEnterEvent(QDragEnterEvent * event)
650 if (event->mimeData()->hasUrls())
652 /// \todo Ask lyx-devel is this is enough:
653 /// if (event->mimeData()->hasFormat("text/plain"))
654 /// event->acceptProposedAction();
658 void GuiView::dropEvent(QDropEvent * event)
660 QList<QUrl> files = event->mimeData()->urls();
664 LYXERR(Debug::GUI, "GuiView::dropEvent: got URLs!");
665 for (int i = 0; i != files.size(); ++i) {
666 string const file = os::internal_path(fromqstr(
667 files.at(i).toLocalFile()));
669 // Asynchronously post the event. DropEvent usually come
670 // from the BufferView. But reloading a file might close
671 // the BufferView from within its own event handler.
672 guiApp->dispatchDelayed(FuncRequest(LFUN_FILE_OPEN, file));
679 void GuiView::message(docstring const & str)
681 if (ForkedProcess::iAmAChild())
684 statusBar()->showMessage(toqstr(str));
685 d.statusbar_timer_.stop();
686 d.statusbar_timer_.start(3000);
690 void GuiView::smallSizedIcons()
692 setIconSize(QSize(d.smallIconSize, d.smallIconSize));
696 void GuiView::normalSizedIcons()
698 setIconSize(QSize(d.normalIconSize, d.normalIconSize));
702 void GuiView::bigSizedIcons()
704 setIconSize(QSize(d.bigIconSize, d.bigIconSize));
708 void GuiView::clearMessage()
712 theLyXFunc().setLyXView(this);
713 statusBar()->showMessage(toqstr(theLyXFunc().viewStatusMessage()));
714 d.statusbar_timer_.stop();
718 void GuiView::updateWindowTitle(GuiWorkArea * wa)
720 if (wa != d.current_work_area_)
722 setWindowTitle(qt_("LyX: ") + wa->windowTitle());
723 setWindowIconText(wa->windowIconText());
727 void GuiView::on_currentWorkAreaChanged(GuiWorkArea * wa)
730 disconnectBufferView();
731 connectBufferView(wa->bufferView());
732 connectBuffer(wa->bufferView().buffer());
733 d.current_work_area_ = wa;
734 QObject::connect(wa, SIGNAL(titleChanged(GuiWorkArea *)),
735 this, SLOT(updateWindowTitle(GuiWorkArea *)));
736 updateWindowTitle(wa);
740 // The document settings needs to be reinitialised.
741 updateDialog("document", "");
743 // Buffer-dependent dialogs must be updated. This is done here because
744 // some dialogs require buffer()->text.
749 void GuiView::on_lastWorkAreaRemoved()
752 // We already are in a close event. Nothing more to do.
755 if (d.splitter_->count() > 1)
756 // We have a splitter so don't close anything.
759 // Reset and updates the dialogs.
760 d.toc_models_.reset(0);
761 updateDialog("document", "");
764 resetWindowTitleAndIconText();
766 if (lyxrc.open_buffers_in_tabs)
767 // Nothing more to do, the window should stay open.
770 if (guiApp->viewIds().size() > 1) {
776 // On Mac we also close the last window because the application stay
777 // resident in memory. On other platforms we don't close the last
778 // window because this would quit the application.
784 void GuiView::updateStatusBar()
786 // let the user see the explicit message
787 if (d.statusbar_timer_.isActive())
790 theLyXFunc().setLyXView(this);
791 statusBar()->showMessage(toqstr(theLyXFunc().viewStatusMessage()));
795 bool GuiView::hasFocus() const
797 return qApp->activeWindow() == this;
801 bool GuiView::event(QEvent * e)
805 // Useful debug code:
806 //case QEvent::ActivationChange:
807 //case QEvent::WindowDeactivate:
808 //case QEvent::Paint:
809 //case QEvent::Enter:
810 //case QEvent::Leave:
811 //case QEvent::HoverEnter:
812 //case QEvent::HoverLeave:
813 //case QEvent::HoverMove:
814 //case QEvent::StatusTip:
815 //case QEvent::DragEnter:
816 //case QEvent::DragLeave:
820 case QEvent::WindowActivate: {
821 if (this == guiApp->currentView()) {
823 return QMainWindow::event(e);
825 guiApp->setCurrentView(this);
826 theLyXFunc().setLyXView(this);
827 if (d.current_work_area_) {
828 BufferView & bv = d.current_work_area_->bufferView();
829 connectBufferView(bv);
830 connectBuffer(bv.buffer());
831 // The document structure, name and dialogs might have
832 // changed in another view.
834 // The document settings needs to be reinitialised.
835 updateDialog("document", "");
838 resetWindowTitleAndIconText();
841 return QMainWindow::event(e);
844 case QEvent::ShortcutOverride: {
847 #if (!defined Q_WS_X11) || (QT_VERSION >= 0x040500)
848 if (isFullScreen() && menuBar()->isHidden()) {
849 QKeyEvent * ke = static_cast<QKeyEvent*>(e);
850 // FIXME: we should also try to detect special LyX shortcut such as
851 // Alt-P and Alt-M. Right now there is a hack in
852 // GuiWorkArea::processKeySym() that hides again the menubar for
854 if (ke->modifiers() & Qt::AltModifier && ke->key() != Qt::Key_Alt) {
856 return QMainWindow::event(e);
861 if (d.current_work_area_)
862 // Nothing special to do.
863 return QMainWindow::event(e);
865 QKeyEvent * ke = static_cast<QKeyEvent*>(e);
866 // Let Qt handle menu access and the Tab keys to navigate keys to navigate
868 if (ke->modifiers() & Qt::AltModifier || ke->key() == Qt::Key_Tab
869 || ke->key() == Qt::Key_Backtab)
870 return QMainWindow::event(e);
872 // Allow processing of shortcuts that are allowed even when no Buffer
874 theLyXFunc().setLyXView(this);
876 setKeySymbol(&sym, ke);
877 theLyXFunc().processKeySym(sym, q_key_state(ke->modifiers()));
883 return QMainWindow::event(e);
887 void GuiView::resetWindowTitleAndIconText()
889 setWindowTitle(qt_("LyX"));
890 setWindowIconText(qt_("LyX"));
893 bool GuiView::focusNextPrevChild(bool /*next*/)
900 void GuiView::setBusy(bool busy)
902 if (d.current_work_area_) {
903 d.current_work_area_->setUpdatesEnabled(!busy);
905 d.current_work_area_->stopBlinkingCursor();
907 d.current_work_area_->startBlinkingCursor();
911 QApplication::setOverrideCursor(Qt::WaitCursor);
913 QApplication::restoreOverrideCursor();
917 GuiWorkArea * GuiView::workArea(Buffer & buffer)
919 if (currentWorkArea()
920 && ¤tWorkArea()->bufferView().buffer() == &buffer)
921 return (GuiWorkArea *) currentWorkArea();
922 if (TabWorkArea * twa = d.currentTabWorkArea())
923 return twa->workArea(buffer);
928 GuiWorkArea * GuiView::addWorkArea(Buffer & buffer)
930 // Automatically create a TabWorkArea if there are none yet.
931 TabWorkArea * tab_widget = d.splitter_->count()
932 ? d.currentTabWorkArea() : addTabWorkArea();
933 return tab_widget->addWorkArea(buffer, *this);
937 TabWorkArea * GuiView::addTabWorkArea()
939 TabWorkArea * twa = new TabWorkArea;
940 QObject::connect(twa, SIGNAL(currentWorkAreaChanged(GuiWorkArea *)),
941 this, SLOT(on_currentWorkAreaChanged(GuiWorkArea *)));
942 QObject::connect(twa, SIGNAL(lastWorkAreaRemoved()),
943 this, SLOT(on_lastWorkAreaRemoved()));
945 d.splitter_->addWidget(twa);
946 d.stack_widget_->setCurrentWidget(d.splitter_);
951 GuiWorkArea const * GuiView::currentWorkArea() const
953 return d.current_work_area_;
957 GuiWorkArea * GuiView::currentWorkArea()
959 return d.current_work_area_;
963 GuiWorkArea const * GuiView::currentMainWorkArea() const
965 if (d.currentTabWorkArea() == NULL)
967 return d.currentTabWorkArea()->currentWorkArea();
971 GuiWorkArea * GuiView::currentMainWorkArea()
973 if (d.currentTabWorkArea() == NULL)
975 return d.currentTabWorkArea()->currentWorkArea();
979 void GuiView::setCurrentWorkArea(GuiWorkArea * wa)
981 LYXERR(Debug::DEBUG, "Setting current wa: " << wa << endl);
983 d.current_work_area_ = NULL;
987 GuiWorkArea * old_gwa = theGuiApp()->currentView()->currentWorkArea();
992 cap::saveSelection(view()->cursor());
994 theGuiApp()->setCurrentView(this);
995 d.current_work_area_ = wa;
996 for (int i = 0; i != d.splitter_->count(); ++i) {
997 if (d.tabWorkArea(i)->setCurrentWorkArea(wa)) {
998 //if (d.current_main_work_area_)
999 // d.current_main_work_area_->setFrameStyle(QFrame::NoFrame);
1000 d.current_main_work_area_ = wa;
1001 //d.current_main_work_area_->setFrameStyle(QFrame::Box | QFrame::Plain);
1002 //d.current_main_work_area_->setLineWidth(2);
1003 LYXERR(Debug::DEBUG, "Current wa: " << currentWorkArea() << ", Current main wa: " << currentMainWorkArea());
1007 LYXERR(Debug::DEBUG, "This is not a tabbed wa");
1008 on_currentWorkAreaChanged(wa);
1009 BufferView & bv = wa->bufferView();
1010 bv.cursor().fixIfBroken();
1012 wa->setUpdatesEnabled(true);
1013 LYXERR(Debug::DEBUG, "Current wa: " << currentWorkArea() << ", Current main wa: " << currentMainWorkArea());
1017 void GuiView::removeWorkArea(GuiWorkArea * wa)
1019 LASSERT(wa, return);
1020 if (wa == d.current_work_area_) {
1022 disconnectBufferView();
1023 d.current_work_area_ = 0;
1024 d.current_main_work_area_ = 0;
1027 bool found_twa = false;
1028 for (int i = 0; i != d.splitter_->count(); ++i) {
1029 TabWorkArea * twa = d.tabWorkArea(i);
1030 if (twa->removeWorkArea(wa)) {
1031 // Found in this tab group, and deleted the GuiWorkArea.
1033 if (twa->count() != 0) {
1034 if (d.current_work_area_ == 0)
1035 // This means that we are closing the current GuiWorkArea, so
1036 // switch to the next GuiWorkArea in the found TabWorkArea.
1037 setCurrentWorkArea(twa->currentWorkArea());
1039 // No more WorkAreas in this tab group, so delete it.
1046 // It is not a tabbed work area (i.e., the search work area), so it
1047 // should be deleted by other means.
1048 LASSERT(found_twa, /* */);
1050 if (d.current_work_area_ == 0) {
1051 if (d.splitter_->count() != 0) {
1052 TabWorkArea * twa = d.currentTabWorkArea();
1053 setCurrentWorkArea(twa->currentWorkArea());
1055 // No more work areas, switch to the background widget.
1056 setCurrentWorkArea(0);
1062 LayoutBox * GuiView::getLayoutDialog() const
1068 void GuiView::updateLayoutList()
1071 d.layout_->updateContents(false);
1075 void GuiView::updateToolbars()
1077 ToolbarMap::iterator end = d.toolbars_.end();
1078 if (d.current_work_area_) {
1080 d.current_work_area_->bufferView().cursor().inMathed();
1082 lyx::getStatus(FuncRequest(LFUN_LAYOUT_TABULAR)).enabled();
1084 lyx::getStatus(FuncRequest(LFUN_CHANGES_TRACK)).enabled() &&
1085 lyx::getStatus(FuncRequest(LFUN_CHANGES_TRACK)).onoff(true);
1086 bool const mathmacrotemplate =
1087 lyx::getStatus(FuncRequest(LFUN_IN_MATHMACROTEMPLATE)).enabled();
1089 for (ToolbarMap::iterator it = d.toolbars_.begin(); it != end; ++it)
1090 it->second->update(math, table, review, mathmacrotemplate);
1092 for (ToolbarMap::iterator it = d.toolbars_.begin(); it != end; ++it)
1093 it->second->update(false, false, false, false);
1097 Buffer * GuiView::buffer()
1099 if (d.current_work_area_)
1100 return &d.current_work_area_->bufferView().buffer();
1105 Buffer const * GuiView::buffer() const
1107 if (d.current_work_area_)
1108 return &d.current_work_area_->bufferView().buffer();
1113 void GuiView::setBuffer(Buffer * newBuffer)
1115 LYXERR(Debug::DEBUG, "Setting buffer: " << newBuffer << std::endl);
1116 LASSERT(newBuffer, return);
1119 GuiWorkArea * wa = workArea(*newBuffer);
1121 newBuffer->masterBuffer()->updateLabels();
1122 wa = addWorkArea(*newBuffer);
1124 //Disconnect the old buffer...there's no new one.
1127 connectBuffer(*newBuffer);
1128 connectBufferView(wa->bufferView());
1129 setCurrentWorkArea(wa);
1135 void GuiView::connectBuffer(Buffer & buf)
1137 buf.setGuiDelegate(this);
1141 void GuiView::disconnectBuffer()
1143 if (d.current_work_area_)
1144 d.current_work_area_->bufferView().setGuiDelegate(0);
1148 void GuiView::connectBufferView(BufferView & bv)
1150 bv.setGuiDelegate(this);
1154 void GuiView::disconnectBufferView()
1156 if (d.current_work_area_)
1157 d.current_work_area_->bufferView().setGuiDelegate(0);
1161 void GuiView::errors(string const & error_type, bool from_master)
1163 ErrorList & el = from_master ?
1164 buffer()->masterBuffer()->errorList(error_type)
1165 : buffer()->errorList(error_type);
1166 string data = error_type;
1168 data = "from_master|" + error_type;
1170 showDialog("errorlist", data);
1174 void GuiView::updateTocItem(std::string const & type, DocIterator const & dit)
1176 d.toc_models_.updateItem(toqstr(type), dit);
1180 void GuiView::structureChanged()
1182 d.toc_models_.reset(view());
1183 // Navigator needs more than a simple update in this case. It needs to be
1185 updateDialog("toc", "");
1189 void GuiView::updateDialog(string const & name, string const & data)
1191 if (!isDialogVisible(name))
1194 map<string, DialogPtr>::const_iterator it = d.dialogs_.find(name);
1195 if (it == d.dialogs_.end())
1198 Dialog * const dialog = it->second.get();
1199 if (dialog->isVisibleView())
1200 dialog->initialiseParams(data);
1204 BufferView * GuiView::view()
1206 return d.current_work_area_ ? &d.current_work_area_->bufferView() : 0;
1210 void GuiView::autoSave()
1212 LYXERR(Debug::INFO, "Running autoSave()");
1215 view()->buffer().autoSave();
1219 void GuiView::resetAutosaveTimers()
1222 d.autosave_timeout_.restart();
1226 bool GuiView::getStatus(FuncRequest const & cmd, FuncStatus & flag)
1229 Buffer * buf = buffer();
1231 if (cmd.origin == FuncRequest::TOC) {
1232 GuiToc * toc = static_cast<GuiToc*>(findOrBuild("toc", false));
1234 if (toc->getStatus(view()->cursor(), cmd, fs))
1237 flag.setEnabled(false);
1241 switch(cmd.action) {
1242 case LFUN_BUFFER_WRITE:
1243 enable = buf && (buf->isUnnamed() || !buf->isClean());
1246 case LFUN_BUFFER_WRITE_AS:
1250 case LFUN_BUFFER_CLOSE_ALL: {
1252 BufferList::iterator it = theBufferList().begin();
1253 BufferList::iterator end = theBufferList().end();
1254 int visible_buffers = 0;
1255 for (; it != end; ++it) {
1258 if (visible_buffers > 1) {
1266 case LFUN_SPLIT_VIEW:
1267 if (cmd.getArg(0) == "vertical")
1268 enable = buf && (d.splitter_->count() == 1 ||
1269 d.splitter_->orientation() == Qt::Vertical);
1271 enable = buf && (d.splitter_->count() == 1 ||
1272 d.splitter_->orientation() == Qt::Horizontal);
1275 case LFUN_CLOSE_TAB_GROUP:
1276 enable = d.currentTabWorkArea();
1279 case LFUN_TOOLBAR_TOGGLE:
1280 if (GuiToolbar * t = toolbar(cmd.getArg(0)))
1281 flag.setOnOff(t->isVisible());
1284 case LFUN_UI_TOGGLE:
1285 flag.setOnOff(isFullScreen());
1288 case LFUN_DIALOG_TOGGLE:
1289 flag.setOnOff(isDialogVisible(cmd.getArg(0)));
1290 // fall through to set "enable"
1291 case LFUN_DIALOG_SHOW: {
1292 string const name = cmd.getArg(0);
1294 enable = name == "aboutlyx"
1295 || name == "file" //FIXME: should be removed.
1297 || name == "texinfo";
1298 else if (name == "print")
1299 enable = buf->isExportable("dvi")
1300 && lyxrc.print_command != "none";
1301 else if (name == "character" || name == "symbols") {
1302 if (buf->isReadonly() || !view() || !view()->cursor().inTexted())
1305 // FIXME we should consider passthru
1307 Inset const & in = view()->cursor().inset();
1308 enable = !in.getLayout().isPassThru();
1311 else if (name == "latexlog")
1312 enable = FileName(buf->logName()).isReadableFile();
1313 else if (name == "spellchecker")
1314 enable = theSpellChecker() && !buf->isReadonly();
1315 else if (name == "vclog")
1316 enable = buf->lyxvc().inUse();
1320 case LFUN_DIALOG_UPDATE: {
1321 string const name = cmd.getArg(0);
1323 enable = name == "prefs";
1327 case LFUN_INSET_APPLY: {
1328 string const name = cmd.getArg(0);
1329 Inset * inset = getOpenInset(name);
1331 FuncRequest fr(LFUN_INSET_MODIFY, cmd.argument());
1333 if (!inset->getStatus(view()->cursor(), fr, fs)) {
1334 // Every inset is supposed to handle this
1335 LASSERT(false, break);
1339 FuncRequest fr(LFUN_INSET_INSERT, cmd.argument());
1340 flag |= lyx::getStatus(fr);
1342 enable = flag.enabled();
1346 case LFUN_COMPLETION_INLINE:
1347 if (!d.current_work_area_
1348 || !d.current_work_area_->completer().inlinePossible(view()->cursor()))
1352 case LFUN_COMPLETION_POPUP:
1353 if (!d.current_work_area_
1354 || !d.current_work_area_->completer().popupPossible(view()->cursor()))
1358 case LFUN_COMPLETION_COMPLETE:
1359 if (!d.current_work_area_
1360 || !d.current_work_area_->completer().inlinePossible(view()->cursor()))
1364 case LFUN_COMPLETION_ACCEPT:
1365 if (!d.current_work_area_
1366 || (!d.current_work_area_->completer().popupVisible()
1367 && !d.current_work_area_->completer().inlineVisible()
1368 && !d.current_work_area_->completer().completionAvailable()))
1372 case LFUN_COMPLETION_CANCEL:
1373 if (!d.current_work_area_
1374 || (!d.current_work_area_->completer().popupVisible()
1375 && !d.current_work_area_->completer().inlineVisible()))
1379 case LFUN_BUFFER_ZOOM_OUT:
1380 enable = buf && lyxrc.zoom > 10;
1383 case LFUN_BUFFER_ZOOM_IN:
1392 flag.setEnabled(false);
1398 static FileName selectTemplateFile()
1400 FileDialog dlg(qt_("Select template file"));
1401 dlg.setButton1(qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
1402 dlg.setButton1(qt_("Templates|#T#t"), toqstr(lyxrc.template_path));
1404 FileDialog::Result result = dlg.open(toqstr(lyxrc.template_path),
1405 QStringList(qt_("LyX Documents (*.lyx)")));
1407 if (result.first == FileDialog::Later)
1409 if (result.second.isEmpty())
1411 return FileName(fromqstr(result.second));
1415 Buffer * GuiView::loadDocument(FileName const & filename, bool tolastfiles)
1419 Buffer * newBuffer = checkAndLoadLyXFile(filename);
1422 message(_("Document not loaded."));
1427 setBuffer(newBuffer);
1429 // scroll to the position when the file was last closed
1430 if (lyxrc.use_lastfilepos) {
1431 LastFilePosSection::FilePos filepos =
1432 theSession().lastFilePos().load(filename);
1433 view()->moveToPosition(filepos.pit, filepos.pos, 0, 0);
1437 theSession().lastFiles().add(filename);
1444 void GuiView::openDocument(string const & fname)
1446 string initpath = lyxrc.document_path;
1449 string const trypath = buffer()->filePath();
1450 // If directory is writeable, use this as default.
1451 if (FileName(trypath).isDirWritable())
1457 if (fname.empty()) {
1458 FileDialog dlg(qt_("Select document to open"), LFUN_FILE_OPEN);
1459 dlg.setButton1(qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
1460 dlg.setButton2(qt_("Examples|#E#e"),
1461 toqstr(addPath(package().system_support().absFilename(), "examples")));
1463 QStringList filter(qt_("LyX Documents (*.lyx)"));
1464 filter << qt_("LyX-1.3.x Documents (*.lyx13)")
1465 << qt_("LyX-1.4.x Documents (*.lyx14)")
1466 << qt_("LyX-1.5.x Documents (*.lyx15)")
1467 << qt_("LyX-1.6.x Documents (*.lyx16)");
1468 FileDialog::Result result =
1469 dlg.open(toqstr(initpath), filter);
1471 if (result.first == FileDialog::Later)
1474 filename = fromqstr(result.second);
1476 // check selected filename
1477 if (filename.empty()) {
1478 message(_("Canceled."));
1484 // get absolute path of file and add ".lyx" to the filename if
1486 FileName const fullname =
1487 fileSearch(string(), filename, "lyx", support::may_not_exist);
1488 if (!fullname.empty())
1489 filename = fullname.absFilename();
1491 if (!fullname.onlyPath().isDirectory()) {
1492 Alert::warning(_("Invalid filename"),
1493 bformat(_("The directory in the given path\n%1$s\ndoes not exist."),
1494 from_utf8(fullname.absFilename())));
1497 // if the file doesn't exist, let the user create one
1498 if (!fullname.exists()) {
1499 // the user specifically chose this name. Believe him.
1500 Buffer * const b = newFile(filename, string(), true);
1506 docstring const disp_fn = makeDisplayPath(filename);
1507 message(bformat(_("Opening document %1$s..."), disp_fn));
1510 Buffer * buf = loadDocument(fullname);
1512 buf->updateLabels();
1514 buf->errors("Parse");
1515 str2 = bformat(_("Document %1$s opened."), disp_fn);
1516 if (buf->lyxvc().inUse())
1517 str2 += " " + from_utf8(buf->lyxvc().versionString()) +
1518 " " + _("Version control detected.");
1520 str2 = bformat(_("Could not open document %1$s"), disp_fn);
1525 // FIXME: clean that
1526 static bool import(GuiView * lv, FileName const & filename,
1527 string const & format, ErrorList & errorList)
1529 FileName const lyxfile(support::changeExtension(filename.absFilename(), ".lyx"));
1531 string loader_format;
1532 vector<string> loaders = theConverters().loaders();
1533 if (find(loaders.begin(), loaders.end(), format) == loaders.end()) {
1534 for (vector<string>::const_iterator it = loaders.begin();
1535 it != loaders.end(); ++it) {
1536 if (!theConverters().isReachable(format, *it))
1539 string const tofile =
1540 support::changeExtension(filename.absFilename(),
1541 formats.extension(*it));
1542 if (!theConverters().convert(0, filename, FileName(tofile),
1543 filename, format, *it, errorList))
1545 loader_format = *it;
1548 if (loader_format.empty()) {
1549 frontend::Alert::error(_("Couldn't import file"),
1550 bformat(_("No information for importing the format %1$s."),
1551 formats.prettyName(format)));
1555 loader_format = format;
1557 if (loader_format == "lyx") {
1558 Buffer * buf = lv->loadDocument(lyxfile);
1561 buf->updateLabels();
1563 buf->errors("Parse");
1565 Buffer * const b = newFile(lyxfile.absFilename(), string(), true);
1569 bool as_paragraphs = loader_format == "textparagraph";
1570 string filename2 = (loader_format == format) ? filename.absFilename()
1571 : support::changeExtension(filename.absFilename(),
1572 formats.extension(loader_format));
1573 lv->view()->insertPlaintextFile(FileName(filename2), as_paragraphs);
1574 theLyXFunc().setLyXView(lv);
1575 lyx::dispatch(FuncRequest(LFUN_MARK_OFF));
1582 void GuiView::importDocument(string const & argument)
1585 string filename = split(argument, format, ' ');
1587 LYXERR(Debug::INFO, format << " file: " << filename);
1589 // need user interaction
1590 if (filename.empty()) {
1591 string initpath = lyxrc.document_path;
1593 Buffer const * buf = buffer();
1595 string const trypath = buf->filePath();
1596 // If directory is writeable, use this as default.
1597 if (FileName(trypath).isDirWritable())
1601 docstring const text = bformat(_("Select %1$s file to import"),
1602 formats.prettyName(format));
1604 FileDialog dlg(toqstr(text), LFUN_BUFFER_IMPORT);
1605 dlg.setButton1(qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
1606 dlg.setButton2(qt_("Examples|#E#e"),
1607 toqstr(addPath(package().system_support().absFilename(), "examples")));
1609 docstring filter = formats.prettyName(format);
1612 filter += from_utf8(formats.extension(format));
1615 FileDialog::Result result =
1616 dlg.open(toqstr(initpath), fileFilters(toqstr(filter)));
1618 if (result.first == FileDialog::Later)
1621 filename = fromqstr(result.second);
1623 // check selected filename
1624 if (filename.empty())
1625 message(_("Canceled."));
1628 if (filename.empty())
1631 // get absolute path of file
1632 FileName const fullname(support::makeAbsPath(filename));
1634 FileName const lyxfile(support::changeExtension(fullname.absFilename(), ".lyx"));
1636 // Check if the document already is open
1637 Buffer * buf = theBufferList().getBuffer(lyxfile);
1640 if (!closeBuffer()) {
1641 message(_("Canceled."));
1646 docstring const displaypath = makeDisplayPath(lyxfile.absFilename(), 30);
1648 // if the file exists already, and we didn't do
1649 // -i lyx thefile.lyx, warn
1650 if (lyxfile.exists() && fullname != lyxfile) {
1652 docstring text = bformat(_("The document %1$s already exists.\n\n"
1653 "Do you want to overwrite that document?"), displaypath);
1654 int const ret = Alert::prompt(_("Overwrite document?"),
1655 text, 0, 1, _("&Overwrite"), _("&Cancel"));
1658 message(_("Canceled."));
1663 message(bformat(_("Importing %1$s..."), displaypath));
1664 ErrorList errorList;
1665 if (import(this, fullname, format, errorList))
1666 message(_("imported."));
1668 message(_("file not imported!"));
1670 // FIXME (Abdel 12/08/06): Is there a need to display the error list here?
1674 void GuiView::newDocument(string const & filename, bool from_template)
1676 FileName initpath(lyxrc.document_path);
1677 Buffer * buf = buffer();
1679 FileName const trypath(buf->filePath());
1680 // If directory is writeable, use this as default.
1681 if (trypath.isDirWritable())
1685 string templatefile;
1686 if (from_template) {
1687 templatefile = selectTemplateFile().absFilename();
1688 if (templatefile.empty())
1693 if (filename.empty())
1694 b = newUnnamedFile(templatefile, initpath);
1696 b = newFile(filename, templatefile, true);
1701 // If no new document could be created, it is unsure
1702 // whether there is a valid BufferView.
1704 // Ensure the cursor is correctly positioned on screen.
1705 view()->showCursor();
1709 void GuiView::insertLyXFile(docstring const & fname)
1711 BufferView * bv = view();
1716 FileName filename(to_utf8(fname));
1718 if (!filename.empty()) {
1719 bv->insertLyXFile(filename);
1723 // Launch a file browser
1725 string initpath = lyxrc.document_path;
1726 string const trypath = bv->buffer().filePath();
1727 // If directory is writeable, use this as default.
1728 if (FileName(trypath).isDirWritable())
1732 FileDialog dlg(qt_("Select LyX document to insert"), LFUN_FILE_INSERT);
1733 dlg.setButton1(qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
1734 dlg.setButton2(qt_("Examples|#E#e"),
1735 toqstr(addPath(package().system_support().absFilename(),
1738 FileDialog::Result result = dlg.open(toqstr(initpath),
1739 QStringList(qt_("LyX Documents (*.lyx)")));
1741 if (result.first == FileDialog::Later)
1745 filename.set(fromqstr(result.second));
1747 // check selected filename
1748 if (filename.empty()) {
1749 // emit message signal.
1750 message(_("Canceled."));
1754 bv->insertLyXFile(filename);
1758 void GuiView::insertPlaintextFile(docstring const & fname,
1761 BufferView * bv = view();
1765 if (!fname.empty() && !FileName::isAbsolute(to_utf8(fname))) {
1766 message(_("Absolute filename expected."));
1771 FileName filename(to_utf8(fname));
1773 if (!filename.empty()) {
1774 bv->insertPlaintextFile(filename, asParagraph);
1778 FileDialog dlg(qt_("Select file to insert"), (asParagraph ?
1779 LFUN_FILE_INSERT_PLAINTEXT_PARA : LFUN_FILE_INSERT_PLAINTEXT));
1781 FileDialog::Result result = dlg.open(toqstr(bv->buffer().filePath()),
1782 QStringList(qt_("All Files (*)")));
1784 if (result.first == FileDialog::Later)
1788 filename.set(fromqstr(result.second));
1790 // check selected filename
1791 if (filename.empty()) {
1792 // emit message signal.
1793 message(_("Canceled."));
1797 bv->insertPlaintextFile(filename, asParagraph);
1801 bool GuiView::renameBuffer(Buffer & b, docstring const & newname)
1803 FileName fname = b.fileName();
1804 FileName const oldname = fname;
1806 if (!newname.empty()) {
1808 fname = support::makeAbsPath(to_utf8(newname), oldname.onlyPath().absFilename());
1810 // Switch to this Buffer.
1813 // No argument? Ask user through dialog.
1815 FileDialog dlg(qt_("Choose a filename to save document as"),
1816 LFUN_BUFFER_WRITE_AS);
1817 dlg.setButton1(qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
1818 dlg.setButton2(qt_("Templates|#T#t"), toqstr(lyxrc.template_path));
1820 if (!isLyXFilename(fname.absFilename()))
1821 fname.changeExtension(".lyx");
1823 FileDialog::Result result =
1824 dlg.save(toqstr(fname.onlyPath().absFilename()),
1825 QStringList(qt_("LyX Documents (*.lyx)")),
1826 toqstr(fname.onlyFileName()));
1828 if (result.first == FileDialog::Later)
1831 fname.set(fromqstr(result.second));
1836 if (!isLyXFilename(fname.absFilename()))
1837 fname.changeExtension(".lyx");
1840 if (FileName(fname).exists()) {
1841 docstring const file = makeDisplayPath(fname.absFilename(), 30);
1842 docstring text = bformat(_("The document %1$s already "
1843 "exists.\n\nDo you want to "
1844 "overwrite that document?"),
1846 int const ret = Alert::prompt(_("Overwrite document?"),
1847 text, 0, 2, _("&Overwrite"), _("&Rename"), _("&Cancel"));
1850 case 1: return renameBuffer(b, docstring());
1851 case 2: return false;
1855 FileName oldauto = b.getAutosaveFilename();
1857 // Ok, change the name of the buffer
1858 b.setFileName(fname.absFilename());
1860 bool unnamed = b.isUnnamed();
1861 b.setUnnamed(false);
1862 b.saveCheckSum(fname);
1864 // bring the autosave file with us, just in case.
1865 b.moveAutosaveFile(oldauto);
1867 if (!saveBuffer(b)) {
1868 oldauto = b.getAutosaveFilename();
1869 b.setFileName(oldname.absFilename());
1870 b.setUnnamed(unnamed);
1871 b.saveCheckSum(oldname);
1872 b.moveAutosaveFile(oldauto);
1880 bool GuiView::saveBuffer(Buffer & b)
1882 if (workArea(b) && workArea(b)->inDialogMode())
1886 return renameBuffer(b, docstring());
1889 theSession().lastFiles().add(b.fileName());
1893 // Switch to this Buffer.
1896 // FIXME: we don't tell the user *WHY* the save failed !!
1897 docstring const file = makeDisplayPath(b.absFileName(), 30);
1898 docstring text = bformat(_("The document %1$s could not be saved.\n\n"
1899 "Do you want to rename the document and "
1900 "try again?"), file);
1901 int const ret = Alert::prompt(_("Rename and save?"),
1902 text, 0, 2, _("&Rename"), _("&Retry"), _("&Cancel"));
1905 if (!renameBuffer(b, docstring()))
1914 return saveBuffer(b);
1918 bool GuiView::hideWorkArea(GuiWorkArea * wa)
1920 Buffer & buf = wa->bufferView().buffer();
1921 return closeBuffer(buf, false);
1925 bool GuiView::closeBuffer()
1927 Buffer * buf = buffer();
1928 return buf && closeBuffer(*buf, !buf->parent());
1932 bool GuiView::closeBuffer(Buffer & buf, bool close_buffer,
1933 bool tolastopened, bool mark_active)
1935 // goto bookmark to update bookmark pit.
1936 //FIXME: we should update only the bookmarks related to this buffer!
1937 LYXERR(Debug::DEBUG, "GuiView::closeBuffer()");
1938 for (size_t i = 0; i < theSession().bookmarks().size(); ++i)
1939 theLyXFunc().gotoBookmark(i+1, false, false);
1941 if (saveBufferIfNeeded(buf, !close_buffer)) {
1942 // save in sessions if requested
1943 // do not save childs if their master
1944 // is opened as well
1946 theSession().lastOpened().add(buf.fileName(), mark_active);
1948 removeWorkArea(currentMainWorkArea());
1950 theBufferList().release(&buf);
1957 bool GuiView::saveBufferIfNeeded(Buffer & buf, bool hiding)
1959 if (buf.isClean() || buf.paragraphs().empty())
1962 // Switch to this Buffer.
1967 if (buf.isUnnamed())
1968 file = from_utf8(buf.fileName().onlyFileName());
1970 file = buf.fileName().displayName(30);
1972 // Bring this window to top before asking questions.
1977 if (hiding && buf.isUnnamed()) {
1978 docstring const text = bformat(_("The document %1$s has not been "
1979 "saved yet.\n\nDo you want to save "
1980 "the document?"), file);
1981 ret = Alert::prompt(_("Save new document?"),
1982 text, 0, 1, _("&Save"), _("&Cancel"));
1986 docstring const text = bformat(_("The document %1$s has unsaved changes."
1987 "\n\nDo you want to save the document or discard the changes?"), file);
1988 ret = Alert::prompt(_("Save changed document?"),
1989 text, 0, 2, _("&Save"), _("&Discard"), _("&Cancel"));
1994 if (!saveBuffer(buf))
1998 // if we crash after this we could
1999 // have no autosave file but I guess
2000 // this is really improbable (Jug)
2001 buf.removeAutosaveFile();
2003 // revert all changes
2004 buf.loadLyXFile(buf.fileName());
2015 bool GuiView::inMultiViews(GuiWorkArea * wa)
2017 QList<int> const ids = guiApp->viewIds();
2018 Buffer & buf = wa->bufferView().buffer();
2021 for (int i = 0; i != ids.size() && found_twa <= 1; ++i) {
2025 if (guiApp->view(ids[i]).workArea(buf))
2032 void GuiView::gotoNextOrPreviousBuffer(NextOrPrevious np)
2034 Buffer * const curbuf = buffer();
2035 Buffer * nextbuf = curbuf;
2037 if (np == NEXTBUFFER)
2038 nextbuf = theBufferList().next(nextbuf);
2040 nextbuf = theBufferList().previous(nextbuf);
2041 if (nextbuf == curbuf)
2047 if (workArea(*nextbuf))
2054 bool GuiView::dispatch(FuncRequest const & cmd)
2056 BufferView * bv = view();
2057 // By default we won't need any update.
2059 bv->cursor().updateFlags(Update::None);
2060 bool dispatched = true;
2062 if (cmd.origin == FuncRequest::TOC) {
2063 GuiToc * toc = static_cast<GuiToc*>(findOrBuild("toc", false));
2064 toc->doDispatch(bv->cursor(), cmd);
2068 switch(cmd.action) {
2069 case LFUN_BUFFER_IMPORT:
2070 importDocument(to_utf8(cmd.argument()));
2073 case LFUN_BUFFER_SWITCH:
2074 if (FileName::isAbsolute(to_utf8(cmd.argument()))) {
2076 theBufferList().getBuffer(FileName(to_utf8(cmd.argument())));
2080 bv->cursor().message(_("Document not loaded"));
2084 case LFUN_BUFFER_NEXT:
2085 gotoNextOrPreviousBuffer(NEXTBUFFER);
2088 case LFUN_BUFFER_PREVIOUS:
2089 gotoNextOrPreviousBuffer(PREVBUFFER);
2092 case LFUN_COMMAND_EXECUTE: {
2093 bool const show_it = cmd.argument() != "off";
2094 // FIXME: this is a hack, "minibuffer" should not be
2096 if (GuiToolbar * t = toolbar("minibuffer")) {
2097 t->setVisible(show_it);
2098 if (show_it && t->commandBuffer())
2099 t->commandBuffer()->setFocus();
2103 case LFUN_DROP_LAYOUTS_CHOICE:
2104 d.layout_->showPopup();
2107 case LFUN_MENU_OPEN:
2108 if (QMenu * menu = guiApp->menus().menu(toqstr(cmd.argument()), *this))
2109 menu->exec(QCursor::pos());
2112 case LFUN_FILE_INSERT:
2113 insertLyXFile(cmd.argument());
2115 case LFUN_FILE_INSERT_PLAINTEXT_PARA:
2116 insertPlaintextFile(cmd.argument(), true);
2119 case LFUN_FILE_INSERT_PLAINTEXT:
2120 insertPlaintextFile(cmd.argument(), false);
2123 case LFUN_BUFFER_WRITE:
2125 saveBuffer(bv->buffer());
2128 case LFUN_BUFFER_WRITE_AS:
2130 renameBuffer(bv->buffer(), cmd.argument());
2133 case LFUN_BUFFER_WRITE_ALL: {
2134 Buffer * first = theBufferList().first();
2137 message(_("Saving all documents..."));
2138 // We cannot use a for loop as the buffer list cycles.
2141 if (!b->isClean()) {
2143 LYXERR(Debug::ACTION, "Saved " << b->absFileName());
2145 b = theBufferList().next(b);
2146 } while (b != first);
2147 message(_("All documents saved."));
2151 case LFUN_TOOLBAR_TOGGLE: {
2152 string const name = cmd.getArg(0);
2153 if (GuiToolbar * t = toolbar(name))
2158 case LFUN_DIALOG_UPDATE: {
2159 string const name = to_utf8(cmd.argument());
2160 // Can only update a dialog connected to an existing inset
2161 Inset * inset = getOpenInset(name);
2163 FuncRequest fr(LFUN_INSET_DIALOG_UPDATE, cmd.argument());
2164 inset->dispatch(view()->cursor(), fr);
2165 } else if (name == "paragraph") {
2166 lyx::dispatch(FuncRequest(LFUN_PARAGRAPH_UPDATE));
2167 } else if (name == "prefs" || name == "document") {
2168 updateDialog(name, string());
2173 case LFUN_DIALOG_TOGGLE: {
2174 if (isDialogVisible(cmd.getArg(0)))
2175 dispatch(FuncRequest(LFUN_DIALOG_HIDE, cmd.argument()));
2177 dispatch(FuncRequest(LFUN_DIALOG_SHOW, cmd.argument()));
2181 case LFUN_DIALOG_DISCONNECT_INSET:
2182 disconnectDialog(to_utf8(cmd.argument()));
2185 case LFUN_DIALOG_HIDE: {
2186 guiApp->hideDialogs(to_utf8(cmd.argument()), 0);
2190 case LFUN_DIALOG_SHOW: {
2191 string const name = cmd.getArg(0);
2192 string data = trim(to_utf8(cmd.argument()).substr(name.size()));
2194 if (name == "character") {
2195 data = freefont2string();
2197 showDialog("character", data);
2198 } else if (name == "latexlog") {
2199 Buffer::LogType type;
2200 string const logfile = buffer()->logName(&type);
2202 case Buffer::latexlog:
2205 case Buffer::buildlog:
2209 data += Lexer::quoteString(logfile);
2210 showDialog("log", data);
2211 } else if (name == "vclog") {
2212 string const data = "vc " +
2213 Lexer::quoteString(buffer()->lyxvc().getLogFile());
2214 showDialog("log", data);
2215 } else if (name == "symbols") {
2216 data = bv->cursor().getEncoding()->name();
2218 showDialog("symbols", data);
2220 } else if (name == "prefs" && isFullScreen()) {
2221 FuncRequest fr(LFUN_INSET_INSERT, "fullscreen");
2223 showDialog("prefs", data);
2225 showDialog(name, data);
2229 case LFUN_INSET_APPLY: {
2230 string const name = cmd.getArg(0);
2231 Inset * inset = getOpenInset(name);
2233 // put cursor in front of inset.
2234 if (!view()->setCursorFromInset(inset)) {
2235 LASSERT(false, break);
2238 // useful if we are called from a dialog.
2239 view()->cursor().beginUndoGroup();
2240 view()->cursor().recordUndo();
2241 FuncRequest fr(LFUN_INSET_MODIFY, cmd.argument());
2242 inset->dispatch(view()->cursor(), fr);
2243 view()->cursor().endUndoGroup();
2245 FuncRequest fr(LFUN_INSET_INSERT, cmd.argument());
2251 case LFUN_UI_TOGGLE:
2253 // Make sure the keyboard focus stays in the work area.
2257 case LFUN_SPLIT_VIEW:
2258 if (Buffer * buf = buffer()) {
2259 string const orientation = cmd.getArg(0);
2260 d.splitter_->setOrientation(orientation == "vertical"
2261 ? Qt::Vertical : Qt::Horizontal);
2262 TabWorkArea * twa = addTabWorkArea();
2263 GuiWorkArea * wa = twa->addWorkArea(*buf, *this);
2264 setCurrentWorkArea(wa);
2268 case LFUN_CLOSE_TAB_GROUP:
2269 if (TabWorkArea * twa = d.currentTabWorkArea()) {
2271 d.current_work_area_ = 0;
2272 twa = d.currentTabWorkArea();
2273 // Switch to the next GuiWorkArea in the found TabWorkArea.
2275 // Make sure the work area is up to date.
2276 setCurrentWorkArea(twa->currentWorkArea());
2278 setCurrentWorkArea(0);
2283 case LFUN_COMPLETION_INLINE:
2284 if (d.current_work_area_)
2285 d.current_work_area_->completer().showInline();
2288 case LFUN_COMPLETION_POPUP:
2289 if (d.current_work_area_)
2290 d.current_work_area_->completer().showPopup();
2294 case LFUN_COMPLETION_COMPLETE:
2295 if (d.current_work_area_)
2296 d.current_work_area_->completer().tab();
2299 case LFUN_COMPLETION_CANCEL:
2300 if (d.current_work_area_) {
2301 if (d.current_work_area_->completer().popupVisible())
2302 d.current_work_area_->completer().hidePopup();
2304 d.current_work_area_->completer().hideInline();
2308 case LFUN_COMPLETION_ACCEPT:
2309 if (d.current_work_area_)
2310 d.current_work_area_->completer().activate();
2313 case LFUN_BUFFER_ZOOM_IN:
2314 case LFUN_BUFFER_ZOOM_OUT:
2315 if (cmd.argument().empty()) {
2316 if (cmd.action == LFUN_BUFFER_ZOOM_IN)
2321 lyxrc.zoom += convert<int>(cmd.argument());
2323 if (lyxrc.zoom < 10)
2326 // The global QPixmapCache is used in GuiPainter to cache text
2327 // painting so we must reset it.
2328 QPixmapCache::clear();
2329 guiApp->fontLoader().update();
2330 lyx::dispatch(FuncRequest(LFUN_SCREEN_FONT_UPDATE));
2338 // Part of automatic menu appearance feature.
2339 if (isFullScreen()) {
2340 if (menuBar()->isVisible() && lyxrc.full_screen_menubar)
2342 if (statusBar()->isVisible())
2343 statusBar()->hide();
2350 void GuiView::lfunUiToggle(FuncRequest const & cmd)
2352 string const arg = cmd.getArg(0);
2353 if (arg == "scrollbar") {
2354 // hide() is of no help
2355 if (d.current_work_area_->verticalScrollBarPolicy() ==
2356 Qt::ScrollBarAlwaysOff)
2358 d.current_work_area_->setVerticalScrollBarPolicy(
2359 Qt::ScrollBarAsNeeded);
2361 d.current_work_area_->setVerticalScrollBarPolicy(
2362 Qt::ScrollBarAlwaysOff);
2365 if (arg == "statusbar") {
2366 statusBar()->setVisible(!statusBar()->isVisible());
2369 if (arg == "menubar") {
2370 menuBar()->setVisible(!menuBar()->isVisible());
2373 #if QT_VERSION >= 0x040300
2374 if (arg == "frame") {
2376 getContentsMargins(&l, &t, &r, &b);
2377 //are the frames in default state?
2378 d.current_work_area_->setFrameStyle(QFrame::NoFrame);
2380 setContentsMargins(-2, -2, -2, -2);
2382 setContentsMargins(0, 0, 0, 0);
2387 if (arg == "fullscreen") {
2392 message(bformat("LFUN_UI_TOGGLE " + _("%1$s unknown command!"), from_utf8(arg)));
2396 void GuiView::toggleFullScreen()
2398 if (isFullScreen()) {
2399 for (int i = 0; i != d.splitter_->count(); ++i)
2400 d.tabWorkArea(i)->setFullScreen(false);
2401 #if QT_VERSION >= 0x040300
2402 setContentsMargins(0, 0, 0, 0);
2404 setWindowState(windowState() ^ Qt::WindowFullScreen);
2407 statusBar()->show();
2410 hideDialogs("prefs", 0);
2411 for (int i = 0; i != d.splitter_->count(); ++i)
2412 d.tabWorkArea(i)->setFullScreen(true);
2413 #if QT_VERSION >= 0x040300
2414 setContentsMargins(-2, -2, -2, -2);
2417 setWindowState(windowState() ^ Qt::WindowFullScreen);
2418 statusBar()->hide();
2419 if (lyxrc.full_screen_menubar)
2421 if (lyxrc.full_screen_toolbars) {
2422 ToolbarMap::iterator end = d.toolbars_.end();
2423 for (ToolbarMap::iterator it = d.toolbars_.begin(); it != end; ++it)
2428 // give dialogs like the TOC a chance to adapt
2433 Buffer const * GuiView::updateInset(Inset const * inset)
2435 if (!d.current_work_area_)
2439 d.current_work_area_->scheduleRedraw();
2441 return &d.current_work_area_->bufferView().buffer();
2445 void GuiView::restartCursor()
2447 /* When we move around, or type, it's nice to be able to see
2448 * the cursor immediately after the keypress.
2450 if (d.current_work_area_)
2451 d.current_work_area_->startBlinkingCursor();
2453 // Take this occasion to update the other GUI elements.
2459 void GuiView::updateCompletion(Cursor & cur, bool start, bool keep)
2461 if (d.current_work_area_)
2462 d.current_work_area_->completer().updateVisibility(cur, start, keep);
2467 // This list should be kept in sync with the list of insets in
2468 // src/insets/Inset.cpp. I.e., if a dialog goes with an inset, the
2469 // dialog should have the same name as the inset.
2470 // Changes should be also recorded in LFUN_DIALOG_SHOW doxygen
2471 // docs in LyXAction.cpp.
2473 char const * const dialognames[] = {
2474 "aboutlyx", "bibitem", "bibtex", "box", "branch", "changes", "character",
2475 "citation", "document", "errorlist", "ert", "external", "file", "findreplace",
2476 "findreplaceadv", "float", "graphics", "href", "include", "index",
2477 "index_print", "info", "listings", "label", "log", "mathdelimiter",
2478 "mathmatrix", "mathspace", "nomenclature", "nomencl_print", "note",
2479 "paragraph", "phantom", "prefs", "print", "ref", "sendto", "space",
2480 "spellchecker", "symbols", "tabular", "tabularcreate", "thesaurus", "texinfo",
2481 "toc", "view-source", "vspace", "wrap" };
2483 char const * const * const end_dialognames =
2484 dialognames + (sizeof(dialognames) / sizeof(char *));
2488 cmpCStr(char const * name) : name_(name) {}
2489 bool operator()(char const * other) {
2490 return strcmp(other, name_) == 0;
2497 bool isValidName(string const & name)
2499 return find_if(dialognames, end_dialognames,
2500 cmpCStr(name.c_str())) != end_dialognames;
2506 void GuiView::resetDialogs()
2508 // Make sure that no LFUN uses any LyXView.
2509 theLyXFunc().setLyXView(0);
2512 constructToolbars();
2513 guiApp->menus().fillMenuBar(menuBar(), this, false);
2514 d.layout_->updateContents(true);
2515 // Now update controls with current buffer.
2516 theLyXFunc().setLyXView(this);
2522 Dialog * GuiView::findOrBuild(string const & name, bool hide_it)
2524 if (!isValidName(name))
2527 map<string, DialogPtr>::iterator it = d.dialogs_.find(name);
2529 if (it != d.dialogs_.end()) {
2531 it->second->hideView();
2532 return it->second.get();
2535 Dialog * dialog = build(name);
2536 d.dialogs_[name].reset(dialog);
2537 if (lyxrc.allow_geometry_session)
2538 dialog->restoreSession();
2545 void GuiView::showDialog(string const & name, string const & data,
2553 Dialog * dialog = findOrBuild(name, false);
2555 dialog->showData(data);
2557 d.open_insets_[name] = inset;
2560 catch (ExceptionMessage const & ex) {
2568 bool GuiView::isDialogVisible(string const & name) const
2570 map<string, DialogPtr>::const_iterator it = d.dialogs_.find(name);
2571 if (it == d.dialogs_.end())
2573 return it->second.get()->isVisibleView() && !it->second.get()->isClosing();
2577 void GuiView::hideDialog(string const & name, Inset * inset)
2579 map<string, DialogPtr>::const_iterator it = d.dialogs_.find(name);
2580 if (it == d.dialogs_.end())
2583 if (inset && inset != getOpenInset(name))
2586 Dialog * const dialog = it->second.get();
2587 if (dialog->isVisibleView())
2589 d.open_insets_[name] = 0;
2593 void GuiView::disconnectDialog(string const & name)
2595 if (!isValidName(name))
2598 if (d.open_insets_.find(name) != d.open_insets_.end())
2599 d.open_insets_[name] = 0;
2603 Inset * GuiView::getOpenInset(string const & name) const
2605 if (!isValidName(name))
2608 map<string, Inset *>::const_iterator it = d.open_insets_.find(name);
2609 return it == d.open_insets_.end() ? 0 : it->second;
2613 void GuiView::hideAll() const
2615 map<string, DialogPtr>::const_iterator it = d.dialogs_.begin();
2616 map<string, DialogPtr>::const_iterator end = d.dialogs_.end();
2618 for(; it != end; ++it)
2619 it->second->hideView();
2623 void GuiView::updateDialogs()
2625 map<string, DialogPtr>::const_iterator it = d.dialogs_.begin();
2626 map<string, DialogPtr>::const_iterator end = d.dialogs_.end();
2628 for(; it != end; ++it) {
2629 Dialog * dialog = it->second.get();
2630 if (dialog && dialog->isVisibleView())
2631 dialog->checkStatus();
2638 // will be replaced by a proper factory...
2639 Dialog * createGuiAbout(GuiView & lv);
2640 Dialog * createGuiBibitem(GuiView & lv);
2641 Dialog * createGuiBibtex(GuiView & lv);
2642 Dialog * createGuiBox(GuiView & lv);
2643 Dialog * createGuiBranch(GuiView & lv);
2644 Dialog * createGuiChanges(GuiView & lv);
2645 Dialog * createGuiCharacter(GuiView & lv);
2646 Dialog * createGuiCitation(GuiView & lv);
2647 Dialog * createGuiDelimiter(GuiView & lv);
2648 Dialog * createGuiDocument(GuiView & lv);
2649 Dialog * createGuiErrorList(GuiView & lv);
2650 Dialog * createGuiERT(GuiView & lv);
2651 Dialog * createGuiExternal(GuiView & lv);
2652 Dialog * createGuiFloat(GuiView & lv);
2653 Dialog * createGuiGraphics(GuiView & lv);
2654 Dialog * createGuiInclude(GuiView & lv);
2655 Dialog * createGuiIndex(GuiView & lv);
2656 Dialog * createGuiInfo(GuiView & lv);
2657 Dialog * createGuiLabel(GuiView & lv);
2658 Dialog * createGuiListings(GuiView & lv);
2659 Dialog * createGuiLog(GuiView & lv);
2660 Dialog * createGuiMathHSpace(GuiView & lv);
2661 Dialog * createGuiMathMatrix(GuiView & lv);
2662 Dialog * createGuiNomenclature(GuiView & lv);
2663 Dialog * createGuiNote(GuiView & lv);
2664 Dialog * createGuiParagraph(GuiView & lv);
2665 Dialog * createGuiPhantom(GuiView & lv);
2666 Dialog * createGuiPreferences(GuiView & lv);
2667 Dialog * createGuiPrint(GuiView & lv);
2668 Dialog * createGuiPrintindex(GuiView & lv);
2669 Dialog * createGuiPrintNomencl(GuiView & lv);
2670 Dialog * createGuiRef(GuiView & lv);
2671 Dialog * createGuiSearch(GuiView & lv);
2672 Dialog * createGuiSearchAdv(GuiView & lv);
2673 Dialog * createGuiSendTo(GuiView & lv);
2674 Dialog * createGuiShowFile(GuiView & lv);
2675 Dialog * createGuiSpellchecker(GuiView & lv);
2676 Dialog * createGuiSymbols(GuiView & lv);
2677 Dialog * createGuiTabularCreate(GuiView & lv);
2678 Dialog * createGuiTabular(GuiView & lv);
2679 Dialog * createGuiTexInfo(GuiView & lv);
2680 Dialog * createGuiTextHSpace(GuiView & lv);
2681 Dialog * createGuiToc(GuiView & lv);
2682 Dialog * createGuiThesaurus(GuiView & lv);
2683 Dialog * createGuiHyperlink(GuiView & lv);
2684 Dialog * createGuiVSpace(GuiView & lv);
2685 Dialog * createGuiViewSource(GuiView & lv);
2686 Dialog * createGuiWrap(GuiView & lv);
2689 Dialog * GuiView::build(string const & name)
2691 LASSERT(isValidName(name), return 0);
2693 if (name == "aboutlyx")
2694 return createGuiAbout(*this);
2695 if (name == "bibitem")
2696 return createGuiBibitem(*this);
2697 if (name == "bibtex")
2698 return createGuiBibtex(*this);
2700 return createGuiBox(*this);
2701 if (name == "branch")
2702 return createGuiBranch(*this);
2703 if (name == "changes")
2704 return createGuiChanges(*this);
2705 if (name == "character")
2706 return createGuiCharacter(*this);
2707 if (name == "citation")
2708 return createGuiCitation(*this);
2709 if (name == "document")
2710 return createGuiDocument(*this);
2711 if (name == "errorlist")
2712 return createGuiErrorList(*this);
2714 return createGuiERT(*this);
2715 if (name == "external")
2716 return createGuiExternal(*this);
2718 return createGuiShowFile(*this);
2719 if (name == "findreplace")
2720 return createGuiSearch(*this);
2721 if (name == "findreplaceadv")
2722 return createGuiSearchAdv(*this);
2723 if (name == "float")
2724 return createGuiFloat(*this);
2725 if (name == "graphics")
2726 return createGuiGraphics(*this);
2728 return createGuiHyperlink(*this);
2729 if (name == "include")
2730 return createGuiInclude(*this);
2731 if (name == "index")
2732 return createGuiIndex(*this);
2733 if (name == "index_print")
2734 return createGuiPrintindex(*this);
2736 return createGuiInfo(*this);
2737 if (name == "label")
2738 return createGuiLabel(*this);
2739 if (name == "listings")
2740 return createGuiListings(*this);
2742 return createGuiLog(*this);
2743 if (name == "mathdelimiter")
2744 return createGuiDelimiter(*this);
2745 if (name == "mathspace")
2746 return createGuiMathHSpace(*this);
2747 if (name == "mathmatrix")
2748 return createGuiMathMatrix(*this);
2749 if (name == "nomenclature")
2750 return createGuiNomenclature(*this);
2751 if (name == "nomencl_print")
2752 return createGuiPrintNomencl(*this);
2754 return createGuiNote(*this);
2755 if (name == "paragraph")
2756 return createGuiParagraph(*this);
2757 if (name == "phantom")
2758 return createGuiPhantom(*this);
2759 if (name == "prefs")
2760 return createGuiPreferences(*this);
2761 if (name == "print")
2762 return createGuiPrint(*this);
2764 return createGuiRef(*this);
2765 if (name == "sendto")
2766 return createGuiSendTo(*this);
2767 if (name == "space")
2768 return createGuiTextHSpace(*this);
2769 if (name == "spellchecker")
2770 return createGuiSpellchecker(*this);
2771 if (name == "symbols")
2772 return createGuiSymbols(*this);
2773 if (name == "tabular")
2774 return createGuiTabular(*this);
2775 if (name == "tabularcreate")
2776 return createGuiTabularCreate(*this);
2777 if (name == "texinfo")
2778 return createGuiTexInfo(*this);
2779 if (name == "thesaurus")
2780 return createGuiThesaurus(*this);
2782 return createGuiToc(*this);
2783 if (name == "view-source")
2784 return createGuiViewSource(*this);
2785 if (name == "vspace")
2786 return createGuiVSpace(*this);
2788 return createGuiWrap(*this);
2794 } // namespace frontend
2797 #include "moc_GuiView.cpp"