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 in_close_event)
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 == d.tabWorkArea(empty_twa) && 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 // We only want to close the buffer if the same buffer is not in
616 bool const close_buffer = !(inMultiViews(wa) || b.parent());
618 // closeBuffer() needs buffer workArea still alive and
619 // set as currrent one, and destroys it
620 if (!closeWorkArea(wa, close_buffer, in_close_event, is_active_wa))
628 void GuiView::dragEnterEvent(QDragEnterEvent * event)
630 if (event->mimeData()->hasUrls())
632 /// \todo Ask lyx-devel is this is enough:
633 /// if (event->mimeData()->hasFormat("text/plain"))
634 /// event->acceptProposedAction();
638 void GuiView::dropEvent(QDropEvent * event)
640 QList<QUrl> files = event->mimeData()->urls();
644 LYXERR(Debug::GUI, "GuiView::dropEvent: got URLs!");
645 for (int i = 0; i != files.size(); ++i) {
646 string const file = os::internal_path(fromqstr(
647 files.at(i).toLocalFile()));
649 // Asynchronously post the event. DropEvent usually come
650 // from the BufferView. But reloading a file might close
651 // the BufferView from within its own event handler.
652 guiApp->dispatchDelayed(FuncRequest(LFUN_FILE_OPEN, file));
659 void GuiView::message(docstring const & str)
661 if (ForkedProcess::iAmAChild())
664 statusBar()->showMessage(toqstr(str));
665 d.statusbar_timer_.stop();
666 d.statusbar_timer_.start(3000);
670 void GuiView::smallSizedIcons()
672 setIconSize(QSize(d.smallIconSize, d.smallIconSize));
676 void GuiView::normalSizedIcons()
678 setIconSize(QSize(d.normalIconSize, d.normalIconSize));
682 void GuiView::bigSizedIcons()
684 setIconSize(QSize(d.bigIconSize, d.bigIconSize));
688 void GuiView::clearMessage()
692 theLyXFunc().setLyXView(this);
693 statusBar()->showMessage(toqstr(theLyXFunc().viewStatusMessage()));
694 d.statusbar_timer_.stop();
698 void GuiView::updateWindowTitle(GuiWorkArea * wa)
700 if (wa != d.current_work_area_)
702 setWindowTitle(qt_("LyX: ") + wa->windowTitle());
703 setWindowIconText(wa->windowIconText());
707 void GuiView::on_currentWorkAreaChanged(GuiWorkArea * wa)
710 disconnectBufferView();
711 connectBufferView(wa->bufferView());
712 connectBuffer(wa->bufferView().buffer());
713 d.current_work_area_ = wa;
714 QObject::connect(wa, SIGNAL(titleChanged(GuiWorkArea *)),
715 this, SLOT(updateWindowTitle(GuiWorkArea *)));
716 updateWindowTitle(wa);
720 // The document settings needs to be reinitialised.
721 updateDialog("document", "");
723 // Buffer-dependent dialogs must be updated. This is done here because
724 // some dialogs require buffer()->text.
729 void GuiView::on_lastWorkAreaRemoved()
732 // We already are in a close event. Nothing more to do.
735 if (d.splitter_->count() > 1)
736 // We have a splitter so don't close anything.
739 // Reset and updates the dialogs.
740 d.toc_models_.reset(0);
741 updateDialog("document", "");
744 resetWindowTitleAndIconText();
746 if (lyxrc.open_buffers_in_tabs)
747 // Nothing more to do, the window should stay open.
750 if (guiApp->viewIds().size() > 1) {
756 // On Mac we also close the last window because the application stay
757 // resident in memory. On other platforms we don't close the last
758 // window because this would quit the application.
764 void GuiView::updateStatusBar()
766 // let the user see the explicit message
767 if (d.statusbar_timer_.isActive())
770 theLyXFunc().setLyXView(this);
771 statusBar()->showMessage(toqstr(theLyXFunc().viewStatusMessage()));
775 bool GuiView::hasFocus() const
777 return qApp->activeWindow() == this;
781 bool GuiView::event(QEvent * e)
785 // Useful debug code:
786 //case QEvent::ActivationChange:
787 //case QEvent::WindowDeactivate:
788 //case QEvent::Paint:
789 //case QEvent::Enter:
790 //case QEvent::Leave:
791 //case QEvent::HoverEnter:
792 //case QEvent::HoverLeave:
793 //case QEvent::HoverMove:
794 //case QEvent::StatusTip:
795 //case QEvent::DragEnter:
796 //case QEvent::DragLeave:
800 case QEvent::WindowActivate: {
801 if (this == guiApp->currentView()) {
803 return QMainWindow::event(e);
805 guiApp->setCurrentView(this);
806 theLyXFunc().setLyXView(this);
807 if (d.current_work_area_) {
808 BufferView & bv = d.current_work_area_->bufferView();
809 connectBufferView(bv);
810 connectBuffer(bv.buffer());
811 // The document structure, name and dialogs might have
812 // changed in another view.
814 // The document settings needs to be reinitialised.
815 updateDialog("document", "");
818 resetWindowTitleAndIconText();
821 return QMainWindow::event(e);
824 case QEvent::ShortcutOverride: {
827 #if (!defined Q_WS_X11) || (QT_VERSION >= 0x040500)
828 if (isFullScreen() && menuBar()->isHidden()) {
829 QKeyEvent * ke = static_cast<QKeyEvent*>(e);
830 // FIXME: we should also try to detect special LyX shortcut such as
831 // Alt-P and Alt-M. Right now there is a hack in
832 // GuiWorkArea::processKeySym() that hides again the menubar for
834 if (ke->modifiers() & Qt::AltModifier && ke->key() != Qt::Key_Alt) {
836 return QMainWindow::event(e);
841 if (d.current_work_area_)
842 // Nothing special to do.
843 return QMainWindow::event(e);
845 QKeyEvent * ke = static_cast<QKeyEvent*>(e);
846 // Let Qt handle menu access and the Tab keys to navigate keys to navigate
848 if (ke->modifiers() & Qt::AltModifier || ke->key() == Qt::Key_Tab
849 || ke->key() == Qt::Key_Backtab)
850 return QMainWindow::event(e);
852 // Allow processing of shortcuts that are allowed even when no Buffer
854 theLyXFunc().setLyXView(this);
856 setKeySymbol(&sym, ke);
857 theLyXFunc().processKeySym(sym, q_key_state(ke->modifiers()));
863 return QMainWindow::event(e);
867 void GuiView::resetWindowTitleAndIconText()
869 setWindowTitle(qt_("LyX"));
870 setWindowIconText(qt_("LyX"));
873 bool GuiView::focusNextPrevChild(bool /*next*/)
880 void GuiView::setBusy(bool busy)
882 if (d.current_work_area_) {
883 d.current_work_area_->setUpdatesEnabled(!busy);
885 d.current_work_area_->stopBlinkingCursor();
887 d.current_work_area_->startBlinkingCursor();
891 QApplication::setOverrideCursor(Qt::WaitCursor);
893 QApplication::restoreOverrideCursor();
897 GuiWorkArea * GuiView::workArea(Buffer & buffer)
899 if (currentWorkArea()
900 && ¤tWorkArea()->bufferView().buffer() == &buffer)
901 return (GuiWorkArea *) currentWorkArea();
902 if (TabWorkArea * twa = d.currentTabWorkArea())
903 return twa->workArea(buffer);
908 GuiWorkArea * GuiView::addWorkArea(Buffer & buffer)
910 // Automatically create a TabWorkArea if there are none yet.
911 TabWorkArea * tab_widget = d.splitter_->count()
912 ? d.currentTabWorkArea() : addTabWorkArea();
913 return tab_widget->addWorkArea(buffer, *this);
917 TabWorkArea * GuiView::addTabWorkArea()
919 TabWorkArea * twa = new TabWorkArea;
920 QObject::connect(twa, SIGNAL(currentWorkAreaChanged(GuiWorkArea *)),
921 this, SLOT(on_currentWorkAreaChanged(GuiWorkArea *)));
922 QObject::connect(twa, SIGNAL(lastWorkAreaRemoved()),
923 this, SLOT(on_lastWorkAreaRemoved()));
925 d.splitter_->addWidget(twa);
926 d.stack_widget_->setCurrentWidget(d.splitter_);
931 GuiWorkArea const * GuiView::currentWorkArea() const
933 return d.current_work_area_;
937 GuiWorkArea * GuiView::currentWorkArea()
939 return d.current_work_area_;
943 GuiWorkArea const * GuiView::currentMainWorkArea() const
945 if (d.currentTabWorkArea() == NULL)
947 return d.currentTabWorkArea()->currentWorkArea();
951 GuiWorkArea * GuiView::currentMainWorkArea()
953 if (d.currentTabWorkArea() == NULL)
955 return d.currentTabWorkArea()->currentWorkArea();
959 void GuiView::setCurrentWorkArea(GuiWorkArea * wa)
961 LYXERR(Debug::DEBUG, "Setting current wa: " << wa << endl);
963 d.current_work_area_ = NULL;
967 GuiWorkArea * old_gwa = theGuiApp()->currentView()->currentWorkArea();
972 cap::saveSelection(view()->cursor());
974 theGuiApp()->setCurrentView(this);
975 d.current_work_area_ = wa;
976 for (int i = 0; i != d.splitter_->count(); ++i) {
977 if (d.tabWorkArea(i)->setCurrentWorkArea(wa)) {
978 //if (d.current_main_work_area_)
979 // d.current_main_work_area_->setFrameStyle(QFrame::NoFrame);
980 d.current_main_work_area_ = wa;
981 //d.current_main_work_area_->setFrameStyle(QFrame::Box | QFrame::Plain);
982 //d.current_main_work_area_->setLineWidth(2);
983 LYXERR(Debug::DEBUG, "Current wa: " << currentWorkArea() << ", Current main wa: " << currentMainWorkArea());
987 LYXERR(Debug::DEBUG, "This is not a tabbed wa");
988 on_currentWorkAreaChanged(wa);
989 BufferView & bv = wa->bufferView();
990 bv.cursor().fixIfBroken();
992 wa->setUpdatesEnabled(true);
993 LYXERR(Debug::DEBUG, "Current wa: " << currentWorkArea() << ", Current main wa: " << currentMainWorkArea());
997 void GuiView::removeWorkArea(GuiWorkArea * wa)
1000 if (wa == d.current_work_area_) {
1002 disconnectBufferView();
1003 d.current_work_area_ = 0;
1004 d.current_main_work_area_ = 0;
1007 bool found_twa = false;
1008 for (int i = 0; i != d.splitter_->count(); ++i) {
1009 TabWorkArea * twa = d.tabWorkArea(i);
1010 if (twa->removeWorkArea(wa)) {
1011 // Found in this tab group, and deleted the GuiWorkArea.
1013 if (twa->count() != 0) {
1014 if (d.current_work_area_ == 0)
1015 // This means that we are closing the current GuiWorkArea, so
1016 // switch to the next GuiWorkArea in the found TabWorkArea.
1017 setCurrentWorkArea(twa->currentWorkArea());
1019 // No more WorkAreas in this tab group, so delete it.
1026 // It is not a tabbed work area (i.e., the search work area), so it
1027 // should be deleted by other means.
1028 LASSERT(found_twa, /* */);
1030 if (d.current_work_area_ == 0) {
1031 if (d.splitter_->count() != 0) {
1032 TabWorkArea * twa = d.currentTabWorkArea();
1033 setCurrentWorkArea(twa->currentWorkArea());
1035 // No more work areas, switch to the background widget.
1036 setCurrentWorkArea(0);
1042 LayoutBox * GuiView::getLayoutDialog() const
1048 void GuiView::updateLayoutList()
1051 d.layout_->updateContents(false);
1055 void GuiView::updateToolbars()
1057 ToolbarMap::iterator end = d.toolbars_.end();
1058 if (d.current_work_area_) {
1060 d.current_work_area_->bufferView().cursor().inMathed();
1062 lyx::getStatus(FuncRequest(LFUN_LAYOUT_TABULAR)).enabled();
1064 lyx::getStatus(FuncRequest(LFUN_CHANGES_TRACK)).enabled() &&
1065 lyx::getStatus(FuncRequest(LFUN_CHANGES_TRACK)).onoff(true);
1066 bool const mathmacrotemplate =
1067 lyx::getStatus(FuncRequest(LFUN_IN_MATHMACROTEMPLATE)).enabled();
1069 for (ToolbarMap::iterator it = d.toolbars_.begin(); it != end; ++it)
1070 it->second->update(math, table, review, mathmacrotemplate);
1072 for (ToolbarMap::iterator it = d.toolbars_.begin(); it != end; ++it)
1073 it->second->update(false, false, false, false);
1077 Buffer * GuiView::buffer()
1079 if (d.current_work_area_)
1080 return &d.current_work_area_->bufferView().buffer();
1085 Buffer const * GuiView::buffer() const
1087 if (d.current_work_area_)
1088 return &d.current_work_area_->bufferView().buffer();
1093 void GuiView::setBuffer(Buffer * newBuffer)
1095 LYXERR(Debug::DEBUG, "Setting buffer: " << newBuffer << std::endl);
1096 LASSERT(newBuffer, return);
1099 GuiWorkArea * wa = workArea(*newBuffer);
1101 newBuffer->masterBuffer()->updateLabels();
1102 wa = addWorkArea(*newBuffer);
1104 //Disconnect the old buffer...there's no new one.
1107 connectBuffer(*newBuffer);
1108 connectBufferView(wa->bufferView());
1109 setCurrentWorkArea(wa);
1115 void GuiView::connectBuffer(Buffer & buf)
1117 buf.setGuiDelegate(this);
1121 void GuiView::disconnectBuffer()
1123 if (d.current_work_area_)
1124 d.current_work_area_->bufferView().setGuiDelegate(0);
1128 void GuiView::connectBufferView(BufferView & bv)
1130 bv.setGuiDelegate(this);
1134 void GuiView::disconnectBufferView()
1136 if (d.current_work_area_)
1137 d.current_work_area_->bufferView().setGuiDelegate(0);
1141 void GuiView::errors(string const & error_type, bool from_master)
1143 ErrorList & el = from_master ?
1144 buffer()->masterBuffer()->errorList(error_type)
1145 : buffer()->errorList(error_type);
1146 string data = error_type;
1148 data = "from_master|" + error_type;
1150 showDialog("errorlist", data);
1154 void GuiView::updateTocItem(std::string const & type, DocIterator const & dit)
1156 d.toc_models_.updateItem(toqstr(type), dit);
1160 void GuiView::structureChanged()
1162 d.toc_models_.reset(view());
1163 // Navigator needs more than a simple update in this case. It needs to be
1165 updateDialog("toc", "");
1169 void GuiView::updateDialog(string const & name, string const & data)
1171 if (!isDialogVisible(name))
1174 map<string, DialogPtr>::const_iterator it = d.dialogs_.find(name);
1175 if (it == d.dialogs_.end())
1178 Dialog * const dialog = it->second.get();
1179 if (dialog->isVisibleView())
1180 dialog->initialiseParams(data);
1184 BufferView * GuiView::view()
1186 return d.current_work_area_ ? &d.current_work_area_->bufferView() : 0;
1190 void GuiView::autoSave()
1192 LYXERR(Debug::INFO, "Running autoSave()");
1195 view()->buffer().autoSave();
1199 void GuiView::resetAutosaveTimers()
1202 d.autosave_timeout_.restart();
1206 bool GuiView::getStatus(FuncRequest const & cmd, FuncStatus & flag)
1209 Buffer * buf = buffer();
1211 if (cmd.origin == FuncRequest::TOC) {
1212 GuiToc * toc = static_cast<GuiToc*>(findOrBuild("toc", false));
1214 if (toc->getStatus(view()->cursor(), cmd, fs))
1217 flag.setEnabled(false);
1221 switch(cmd.action) {
1222 case LFUN_BUFFER_WRITE:
1223 enable = buf && (buf->isUnnamed() || !buf->isClean());
1226 case LFUN_BUFFER_WRITE_AS:
1230 case LFUN_BUFFER_CLOSE_ALL: {
1232 BufferList::iterator it = theBufferList().begin();
1233 BufferList::iterator end = theBufferList().end();
1234 int visible_buffers = 0;
1235 for (; it != end; ++it) {
1238 if (visible_buffers > 1) {
1246 case LFUN_SPLIT_VIEW:
1247 if (cmd.getArg(0) == "vertical")
1248 enable = buf && (d.splitter_->count() == 1 ||
1249 d.splitter_->orientation() == Qt::Vertical);
1251 enable = buf && (d.splitter_->count() == 1 ||
1252 d.splitter_->orientation() == Qt::Horizontal);
1255 case LFUN_CLOSE_TAB_GROUP:
1256 enable = d.currentTabWorkArea();
1259 case LFUN_TOOLBAR_TOGGLE:
1260 if (GuiToolbar * t = toolbar(cmd.getArg(0)))
1261 flag.setOnOff(t->isVisible());
1264 case LFUN_UI_TOGGLE:
1265 flag.setOnOff(isFullScreen());
1268 case LFUN_DIALOG_TOGGLE:
1269 flag.setOnOff(isDialogVisible(cmd.getArg(0)));
1270 // fall through to set "enable"
1271 case LFUN_DIALOG_SHOW: {
1272 string const name = cmd.getArg(0);
1274 enable = name == "aboutlyx"
1275 || name == "file" //FIXME: should be removed.
1277 || name == "texinfo";
1278 else if (name == "print")
1279 enable = buf->isExportable("dvi")
1280 && lyxrc.print_command != "none";
1281 else if (name == "character" || name == "symbols") {
1282 if (buf->isReadonly() || !view() || !view()->cursor().inTexted())
1285 // FIXME we should consider passthru
1287 Inset const & in = view()->cursor().inset();
1288 enable = !in.getLayout().isPassThru();
1291 else if (name == "latexlog")
1292 enable = FileName(buf->logName()).isReadableFile();
1293 else if (name == "spellchecker")
1294 enable = theSpellChecker() && !buf->isReadonly();
1295 else if (name == "vclog")
1296 enable = buf->lyxvc().inUse();
1300 case LFUN_DIALOG_UPDATE: {
1301 string const name = cmd.getArg(0);
1303 enable = name == "prefs";
1307 case LFUN_INSET_APPLY: {
1308 string const name = cmd.getArg(0);
1309 Inset * inset = getOpenInset(name);
1311 FuncRequest fr(LFUN_INSET_MODIFY, cmd.argument());
1313 if (!inset->getStatus(view()->cursor(), fr, fs)) {
1314 // Every inset is supposed to handle this
1315 LASSERT(false, break);
1319 FuncRequest fr(LFUN_INSET_INSERT, cmd.argument());
1320 flag |= lyx::getStatus(fr);
1322 enable = flag.enabled();
1326 case LFUN_COMPLETION_INLINE:
1327 if (!d.current_work_area_
1328 || !d.current_work_area_->completer().inlinePossible(view()->cursor()))
1332 case LFUN_COMPLETION_POPUP:
1333 if (!d.current_work_area_
1334 || !d.current_work_area_->completer().popupPossible(view()->cursor()))
1338 case LFUN_COMPLETION_COMPLETE:
1339 if (!d.current_work_area_
1340 || !d.current_work_area_->completer().inlinePossible(view()->cursor()))
1344 case LFUN_COMPLETION_ACCEPT:
1345 if (!d.current_work_area_
1346 || (!d.current_work_area_->completer().popupVisible()
1347 && !d.current_work_area_->completer().inlineVisible()
1348 && !d.current_work_area_->completer().completionAvailable()))
1352 case LFUN_COMPLETION_CANCEL:
1353 if (!d.current_work_area_
1354 || (!d.current_work_area_->completer().popupVisible()
1355 && !d.current_work_area_->completer().inlineVisible()))
1359 case LFUN_BUFFER_ZOOM_OUT:
1360 enable = buf && lyxrc.zoom > 10;
1363 case LFUN_BUFFER_ZOOM_IN:
1372 flag.setEnabled(false);
1378 static FileName selectTemplateFile()
1380 FileDialog dlg(qt_("Select template file"));
1381 dlg.setButton1(qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
1382 dlg.setButton1(qt_("Templates|#T#t"), toqstr(lyxrc.template_path));
1384 FileDialog::Result result = dlg.open(toqstr(lyxrc.template_path),
1385 QStringList(qt_("LyX Documents (*.lyx)")));
1387 if (result.first == FileDialog::Later)
1389 if (result.second.isEmpty())
1391 return FileName(fromqstr(result.second));
1395 Buffer * GuiView::loadDocument(FileName const & filename, bool tolastfiles)
1399 Buffer * newBuffer = checkAndLoadLyXFile(filename);
1402 message(_("Document not loaded."));
1407 setBuffer(newBuffer);
1409 // scroll to the position when the file was last closed
1410 if (lyxrc.use_lastfilepos) {
1411 LastFilePosSection::FilePos filepos =
1412 theSession().lastFilePos().load(filename);
1413 view()->moveToPosition(filepos.pit, filepos.pos, 0, 0);
1417 theSession().lastFiles().add(filename);
1424 void GuiView::openDocument(string const & fname)
1426 string initpath = lyxrc.document_path;
1429 string const trypath = buffer()->filePath();
1430 // If directory is writeable, use this as default.
1431 if (FileName(trypath).isDirWritable())
1437 if (fname.empty()) {
1438 FileDialog dlg(qt_("Select document to open"), LFUN_FILE_OPEN);
1439 dlg.setButton1(qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
1440 dlg.setButton2(qt_("Examples|#E#e"),
1441 toqstr(addPath(package().system_support().absFilename(), "examples")));
1443 QStringList filter(qt_("LyX Documents (*.lyx)"));
1444 filter << qt_("LyX-1.3.x Documents (*.lyx13)")
1445 << qt_("LyX-1.4.x Documents (*.lyx14)")
1446 << qt_("LyX-1.5.x Documents (*.lyx15)")
1447 << qt_("LyX-1.6.x Documents (*.lyx16)");
1448 FileDialog::Result result =
1449 dlg.open(toqstr(initpath), filter);
1451 if (result.first == FileDialog::Later)
1454 filename = fromqstr(result.second);
1456 // check selected filename
1457 if (filename.empty()) {
1458 message(_("Canceled."));
1464 // get absolute path of file and add ".lyx" to the filename if
1466 FileName const fullname =
1467 fileSearch(string(), filename, "lyx", support::may_not_exist);
1468 if (!fullname.empty())
1469 filename = fullname.absFilename();
1471 if (!fullname.onlyPath().isDirectory()) {
1472 Alert::warning(_("Invalid filename"),
1473 bformat(_("The directory in the given path\n%1$s\ndoes not exist."),
1474 from_utf8(fullname.absFilename())));
1477 // if the file doesn't exist, let the user create one
1478 if (!fullname.exists()) {
1479 // the user specifically chose this name. Believe him.
1480 Buffer * const b = newFile(filename, string(), true);
1486 docstring const disp_fn = makeDisplayPath(filename);
1487 message(bformat(_("Opening document %1$s..."), disp_fn));
1490 Buffer * buf = loadDocument(fullname);
1492 buf->updateLabels();
1494 buf->errors("Parse");
1495 str2 = bformat(_("Document %1$s opened."), disp_fn);
1496 if (buf->lyxvc().inUse())
1497 str2 += " " + from_utf8(buf->lyxvc().versionString()) +
1498 " " + _("Version control detected.");
1500 str2 = bformat(_("Could not open document %1$s"), disp_fn);
1505 // FIXME: clean that
1506 static bool import(GuiView * lv, FileName const & filename,
1507 string const & format, ErrorList & errorList)
1509 FileName const lyxfile(support::changeExtension(filename.absFilename(), ".lyx"));
1511 string loader_format;
1512 vector<string> loaders = theConverters().loaders();
1513 if (find(loaders.begin(), loaders.end(), format) == loaders.end()) {
1514 for (vector<string>::const_iterator it = loaders.begin();
1515 it != loaders.end(); ++it) {
1516 if (!theConverters().isReachable(format, *it))
1519 string const tofile =
1520 support::changeExtension(filename.absFilename(),
1521 formats.extension(*it));
1522 if (!theConverters().convert(0, filename, FileName(tofile),
1523 filename, format, *it, errorList))
1525 loader_format = *it;
1528 if (loader_format.empty()) {
1529 frontend::Alert::error(_("Couldn't import file"),
1530 bformat(_("No information for importing the format %1$s."),
1531 formats.prettyName(format)));
1535 loader_format = format;
1537 if (loader_format == "lyx") {
1538 Buffer * buf = lv->loadDocument(lyxfile);
1541 buf->updateLabels();
1543 buf->errors("Parse");
1545 Buffer * const b = newFile(lyxfile.absFilename(), string(), true);
1549 bool as_paragraphs = loader_format == "textparagraph";
1550 string filename2 = (loader_format == format) ? filename.absFilename()
1551 : support::changeExtension(filename.absFilename(),
1552 formats.extension(loader_format));
1553 lv->view()->insertPlaintextFile(FileName(filename2), as_paragraphs);
1554 theLyXFunc().setLyXView(lv);
1555 lyx::dispatch(FuncRequest(LFUN_MARK_OFF));
1562 void GuiView::importDocument(string const & argument)
1565 string filename = split(argument, format, ' ');
1567 LYXERR(Debug::INFO, format << " file: " << filename);
1569 // need user interaction
1570 if (filename.empty()) {
1571 string initpath = lyxrc.document_path;
1573 Buffer const * buf = buffer();
1575 string const trypath = buf->filePath();
1576 // If directory is writeable, use this as default.
1577 if (FileName(trypath).isDirWritable())
1581 docstring const text = bformat(_("Select %1$s file to import"),
1582 formats.prettyName(format));
1584 FileDialog dlg(toqstr(text), LFUN_BUFFER_IMPORT);
1585 dlg.setButton1(qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
1586 dlg.setButton2(qt_("Examples|#E#e"),
1587 toqstr(addPath(package().system_support().absFilename(), "examples")));
1589 docstring filter = formats.prettyName(format);
1592 filter += from_utf8(formats.extension(format));
1595 FileDialog::Result result =
1596 dlg.open(toqstr(initpath), fileFilters(toqstr(filter)));
1598 if (result.first == FileDialog::Later)
1601 filename = fromqstr(result.second);
1603 // check selected filename
1604 if (filename.empty())
1605 message(_("Canceled."));
1608 if (filename.empty())
1611 // get absolute path of file
1612 FileName const fullname(support::makeAbsPath(filename));
1614 FileName const lyxfile(support::changeExtension(fullname.absFilename(), ".lyx"));
1616 // Check if the document already is open
1617 Buffer * buf = theBufferList().getBuffer(lyxfile);
1620 if (!closeBuffer()) {
1621 message(_("Canceled."));
1626 docstring const displaypath = makeDisplayPath(lyxfile.absFilename(), 30);
1628 // if the file exists already, and we didn't do
1629 // -i lyx thefile.lyx, warn
1630 if (lyxfile.exists() && fullname != lyxfile) {
1632 docstring text = bformat(_("The document %1$s already exists.\n\n"
1633 "Do you want to overwrite that document?"), displaypath);
1634 int const ret = Alert::prompt(_("Overwrite document?"),
1635 text, 0, 1, _("&Overwrite"), _("&Cancel"));
1638 message(_("Canceled."));
1643 message(bformat(_("Importing %1$s..."), displaypath));
1644 ErrorList errorList;
1645 if (import(this, fullname, format, errorList))
1646 message(_("imported."));
1648 message(_("file not imported!"));
1650 // FIXME (Abdel 12/08/06): Is there a need to display the error list here?
1654 void GuiView::newDocument(string const & filename, bool from_template)
1656 FileName initpath(lyxrc.document_path);
1657 Buffer * buf = buffer();
1659 FileName const trypath(buf->filePath());
1660 // If directory is writeable, use this as default.
1661 if (trypath.isDirWritable())
1665 string templatefile;
1666 if (from_template) {
1667 templatefile = selectTemplateFile().absFilename();
1668 if (templatefile.empty())
1673 if (filename.empty())
1674 b = newUnnamedFile(templatefile, initpath);
1676 b = newFile(filename, templatefile, true);
1681 // If no new document could be created, it is unsure
1682 // whether there is a valid BufferView.
1684 // Ensure the cursor is correctly positioned on screen.
1685 view()->showCursor();
1689 void GuiView::insertLyXFile(docstring const & fname)
1691 BufferView * bv = view();
1696 FileName filename(to_utf8(fname));
1698 if (!filename.empty()) {
1699 bv->insertLyXFile(filename);
1703 // Launch a file browser
1705 string initpath = lyxrc.document_path;
1706 string const trypath = bv->buffer().filePath();
1707 // If directory is writeable, use this as default.
1708 if (FileName(trypath).isDirWritable())
1712 FileDialog dlg(qt_("Select LyX document to insert"), LFUN_FILE_INSERT);
1713 dlg.setButton1(qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
1714 dlg.setButton2(qt_("Examples|#E#e"),
1715 toqstr(addPath(package().system_support().absFilename(),
1718 FileDialog::Result result = dlg.open(toqstr(initpath),
1719 QStringList(qt_("LyX Documents (*.lyx)")));
1721 if (result.first == FileDialog::Later)
1725 filename.set(fromqstr(result.second));
1727 // check selected filename
1728 if (filename.empty()) {
1729 // emit message signal.
1730 message(_("Canceled."));
1734 bv->insertLyXFile(filename);
1738 void GuiView::insertPlaintextFile(docstring const & fname,
1741 BufferView * bv = view();
1745 if (!fname.empty() && !FileName::isAbsolute(to_utf8(fname))) {
1746 message(_("Absolute filename expected."));
1751 FileName filename(to_utf8(fname));
1753 if (!filename.empty()) {
1754 bv->insertPlaintextFile(filename, asParagraph);
1758 FileDialog dlg(qt_("Select file to insert"), (asParagraph ?
1759 LFUN_FILE_INSERT_PLAINTEXT_PARA : LFUN_FILE_INSERT_PLAINTEXT));
1761 FileDialog::Result result = dlg.open(toqstr(bv->buffer().filePath()),
1762 QStringList(qt_("All Files (*)")));
1764 if (result.first == FileDialog::Later)
1768 filename.set(fromqstr(result.second));
1770 // check selected filename
1771 if (filename.empty()) {
1772 // emit message signal.
1773 message(_("Canceled."));
1777 bv->insertPlaintextFile(filename, asParagraph);
1781 bool GuiView::renameBuffer(Buffer & b, docstring const & newname)
1783 FileName fname = b.fileName();
1784 FileName const oldname = fname;
1786 if (!newname.empty()) {
1788 fname = support::makeAbsPath(to_utf8(newname), oldname.onlyPath().absFilename());
1790 // Switch to this Buffer.
1793 // No argument? Ask user through dialog.
1795 FileDialog dlg(qt_("Choose a filename to save document as"),
1796 LFUN_BUFFER_WRITE_AS);
1797 dlg.setButton1(qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
1798 dlg.setButton2(qt_("Templates|#T#t"), toqstr(lyxrc.template_path));
1800 if (!isLyXFilename(fname.absFilename()))
1801 fname.changeExtension(".lyx");
1803 FileDialog::Result result =
1804 dlg.save(toqstr(fname.onlyPath().absFilename()),
1805 QStringList(qt_("LyX Documents (*.lyx)")),
1806 toqstr(fname.onlyFileName()));
1808 if (result.first == FileDialog::Later)
1811 fname.set(fromqstr(result.second));
1816 if (!isLyXFilename(fname.absFilename()))
1817 fname.changeExtension(".lyx");
1820 if (FileName(fname).exists()) {
1821 docstring const file = makeDisplayPath(fname.absFilename(), 30);
1822 docstring text = bformat(_("The document %1$s already "
1823 "exists.\n\nDo you want to "
1824 "overwrite that document?"),
1826 int const ret = Alert::prompt(_("Overwrite document?"),
1827 text, 0, 2, _("&Overwrite"), _("&Rename"), _("&Cancel"));
1830 case 1: return renameBuffer(b, docstring());
1831 case 2: return false;
1835 FileName oldauto = b.getAutosaveFilename();
1837 // Ok, change the name of the buffer
1838 b.setFileName(fname.absFilename());
1840 bool unnamed = b.isUnnamed();
1841 b.setUnnamed(false);
1842 b.saveCheckSum(fname);
1844 // bring the autosave file with us, just in case.
1845 b.moveAutosaveFile(oldauto);
1847 if (!saveBuffer(b)) {
1848 oldauto = b.getAutosaveFilename();
1849 b.setFileName(oldname.absFilename());
1850 b.setUnnamed(unnamed);
1851 b.saveCheckSum(oldname);
1852 b.moveAutosaveFile(oldauto);
1860 bool GuiView::saveBuffer(Buffer & b)
1862 if (workArea(b) && workArea(b)->inDialogMode())
1866 return renameBuffer(b, docstring());
1869 theSession().lastFiles().add(b.fileName());
1873 // Switch to this Buffer.
1876 // FIXME: we don't tell the user *WHY* the save failed !!
1877 docstring const file = makeDisplayPath(b.absFileName(), 30);
1878 docstring text = bformat(_("The document %1$s could not be saved.\n\n"
1879 "Do you want to rename the document and "
1880 "try again?"), file);
1881 int const ret = Alert::prompt(_("Rename and save?"),
1882 text, 0, 2, _("&Rename"), _("&Retry"), _("&Cancel"));
1885 if (!renameBuffer(b, docstring()))
1894 return saveBuffer(b);
1898 bool GuiView::hideWorkArea(GuiWorkArea * wa)
1900 return closeWorkArea(wa, false);
1904 bool GuiView::closeWorkArea(GuiWorkArea * wa)
1906 Buffer & buf = wa->bufferView().buffer();
1907 return closeWorkArea(wa, !buf.parent());
1911 bool GuiView::closeBuffer()
1913 GuiWorkArea * wa = currentMainWorkArea();
1914 Buffer & buf = wa->bufferView().buffer();
1915 return wa && closeWorkArea(wa, !buf.parent());
1919 bool GuiView::closeWorkArea(GuiWorkArea * wa, bool close_buffer,
1920 bool in_close_event, bool mark_active)
1922 Buffer & buf = wa->bufferView().buffer();
1924 if (close_buffer && !in_close_event) {
1925 vector<Buffer *> clist = buf.getChildren();
1926 for (vector<Buffer *>::const_iterator it = clist.begin();
1927 it != clist.end(); ++it) {
1928 // If a child is dirty, do not close
1929 // without user intervention
1930 //FIXME: should buffers be closed or not?
1931 //FIXME: should we look in other tabworkareas?
1932 GuiWorkArea * child_wa = workArea(**it);
1933 if (child_wa && !closeWorkArea(child_wa, !close_buffer, false))
1937 // goto bookmark to update bookmark pit.
1938 //FIXME: we should update only the bookmarks related to this buffer!
1939 LYXERR(Debug::DEBUG, "GuiView::closeBuffer()");
1940 for (size_t i = 0; i < theSession().bookmarks().size(); ++i)
1941 theLyXFunc().gotoBookmark(i+1, false, false);
1943 // if we are only hiding the buffer and there are multiple views
1944 // of the buffer, then we do not need to ensure a clean buffer.
1945 bool const allow_dirty = inMultiTabs(wa) && !close_buffer;
1947 if (allow_dirty || saveBufferIfNeeded(buf, !close_buffer)) {
1948 // save in sessions if requested
1949 // do not save childs if their master
1950 // is opened as well
1952 theSession().lastOpened().add(buf.fileName(), mark_active);
1956 theBufferList().release(&buf);
1963 bool GuiView::saveBufferIfNeeded(Buffer & buf, bool hiding)
1965 if (buf.isClean() || buf.paragraphs().empty())
1968 // Switch to this Buffer.
1973 if (buf.isUnnamed())
1974 file = from_utf8(buf.fileName().onlyFileName());
1976 file = buf.fileName().displayName(30);
1978 // Bring this window to top before asking questions.
1983 if (hiding && buf.isUnnamed()) {
1984 docstring const text = bformat(_("The document %1$s has not been "
1985 "saved yet.\n\nDo you want to save "
1986 "the document?"), file);
1987 ret = Alert::prompt(_("Save new document?"),
1988 text, 0, 1, _("&Save"), _("&Cancel"));
1992 docstring const text = bformat(_("The document %1$s has unsaved changes."
1993 "\n\nDo you want to save the document or discard the changes?"), file);
1994 ret = Alert::prompt(_("Save changed document?"),
1995 text, 0, 2, _("&Save"), _("&Discard"), _("&Cancel"));
2000 if (!saveBuffer(buf))
2004 // if we crash after this we could
2005 // have no autosave file but I guess
2006 // this is really improbable (Jug)
2007 buf.removeAutosaveFile();
2009 // revert all changes
2010 buf.loadLyXFile(buf.fileName());
2020 bool GuiView::inMultiTabs(GuiWorkArea * wa)
2022 Buffer & buf = wa->bufferView().buffer();
2024 for (int i = 0; i != d.splitter_->count(); ++i) {
2025 GuiWorkArea * wa_ = d.tabWorkArea(i)->workArea(buf);
2026 if (wa_ && wa_ != wa)
2029 return inMultiViews(wa);
2033 bool GuiView::inMultiViews(GuiWorkArea * wa)
2035 QList<int> const ids = guiApp->viewIds();
2036 Buffer & buf = wa->bufferView().buffer();
2039 for (int i = 0; i != ids.size() && found_twa <= 1; ++i) {
2043 if (guiApp->view(ids[i]).workArea(buf))
2050 void GuiView::gotoNextOrPreviousBuffer(NextOrPrevious np)
2052 Buffer * const curbuf = buffer();
2053 Buffer * nextbuf = curbuf;
2055 if (np == NEXTBUFFER)
2056 nextbuf = theBufferList().next(nextbuf);
2058 nextbuf = theBufferList().previous(nextbuf);
2059 if (nextbuf == curbuf)
2065 if (workArea(*nextbuf))
2072 bool GuiView::dispatch(FuncRequest const & cmd)
2074 BufferView * bv = view();
2075 // By default we won't need any update.
2077 bv->cursor().updateFlags(Update::None);
2078 bool dispatched = true;
2080 if (cmd.origin == FuncRequest::TOC) {
2081 GuiToc * toc = static_cast<GuiToc*>(findOrBuild("toc", false));
2082 toc->doDispatch(bv->cursor(), cmd);
2086 switch(cmd.action) {
2087 case LFUN_BUFFER_IMPORT:
2088 importDocument(to_utf8(cmd.argument()));
2091 case LFUN_BUFFER_SWITCH:
2092 if (FileName::isAbsolute(to_utf8(cmd.argument()))) {
2094 theBufferList().getBuffer(FileName(to_utf8(cmd.argument())));
2098 bv->cursor().message(_("Document not loaded"));
2102 case LFUN_BUFFER_NEXT:
2103 gotoNextOrPreviousBuffer(NEXTBUFFER);
2106 case LFUN_BUFFER_PREVIOUS:
2107 gotoNextOrPreviousBuffer(PREVBUFFER);
2110 case LFUN_COMMAND_EXECUTE: {
2111 bool const show_it = cmd.argument() != "off";
2112 // FIXME: this is a hack, "minibuffer" should not be
2114 if (GuiToolbar * t = toolbar("minibuffer")) {
2115 t->setVisible(show_it);
2116 if (show_it && t->commandBuffer())
2117 t->commandBuffer()->setFocus();
2121 case LFUN_DROP_LAYOUTS_CHOICE:
2122 d.layout_->showPopup();
2125 case LFUN_MENU_OPEN:
2126 if (QMenu * menu = guiApp->menus().menu(toqstr(cmd.argument()), *this))
2127 menu->exec(QCursor::pos());
2130 case LFUN_FILE_INSERT:
2131 insertLyXFile(cmd.argument());
2133 case LFUN_FILE_INSERT_PLAINTEXT_PARA:
2134 insertPlaintextFile(cmd.argument(), true);
2137 case LFUN_FILE_INSERT_PLAINTEXT:
2138 insertPlaintextFile(cmd.argument(), false);
2141 case LFUN_BUFFER_WRITE:
2143 saveBuffer(bv->buffer());
2146 case LFUN_BUFFER_WRITE_AS:
2148 renameBuffer(bv->buffer(), cmd.argument());
2151 case LFUN_BUFFER_WRITE_ALL: {
2152 Buffer * first = theBufferList().first();
2155 message(_("Saving all documents..."));
2156 // We cannot use a for loop as the buffer list cycles.
2159 if (!b->isClean()) {
2161 LYXERR(Debug::ACTION, "Saved " << b->absFileName());
2163 b = theBufferList().next(b);
2164 } while (b != first);
2165 message(_("All documents saved."));
2169 case LFUN_TOOLBAR_TOGGLE: {
2170 string const name = cmd.getArg(0);
2171 if (GuiToolbar * t = toolbar(name))
2176 case LFUN_DIALOG_UPDATE: {
2177 string const name = to_utf8(cmd.argument());
2178 // Can only update a dialog connected to an existing inset
2179 Inset * inset = getOpenInset(name);
2181 FuncRequest fr(LFUN_INSET_DIALOG_UPDATE, cmd.argument());
2182 inset->dispatch(view()->cursor(), fr);
2183 } else if (name == "paragraph") {
2184 lyx::dispatch(FuncRequest(LFUN_PARAGRAPH_UPDATE));
2185 } else if (name == "prefs" || name == "document") {
2186 updateDialog(name, string());
2191 case LFUN_DIALOG_TOGGLE: {
2192 if (isDialogVisible(cmd.getArg(0)))
2193 dispatch(FuncRequest(LFUN_DIALOG_HIDE, cmd.argument()));
2195 dispatch(FuncRequest(LFUN_DIALOG_SHOW, cmd.argument()));
2199 case LFUN_DIALOG_DISCONNECT_INSET:
2200 disconnectDialog(to_utf8(cmd.argument()));
2203 case LFUN_DIALOG_HIDE: {
2204 guiApp->hideDialogs(to_utf8(cmd.argument()), 0);
2208 case LFUN_DIALOG_SHOW: {
2209 string const name = cmd.getArg(0);
2210 string data = trim(to_utf8(cmd.argument()).substr(name.size()));
2212 if (name == "character") {
2213 data = freefont2string();
2215 showDialog("character", data);
2216 } else if (name == "latexlog") {
2217 Buffer::LogType type;
2218 string const logfile = buffer()->logName(&type);
2220 case Buffer::latexlog:
2223 case Buffer::buildlog:
2227 data += Lexer::quoteString(logfile);
2228 showDialog("log", data);
2229 } else if (name == "vclog") {
2230 string const data = "vc " +
2231 Lexer::quoteString(buffer()->lyxvc().getLogFile());
2232 showDialog("log", data);
2233 } else if (name == "symbols") {
2234 data = bv->cursor().getEncoding()->name();
2236 showDialog("symbols", data);
2238 } else if (name == "prefs" && isFullScreen()) {
2239 FuncRequest fr(LFUN_INSET_INSERT, "fullscreen");
2241 showDialog("prefs", data);
2243 showDialog(name, data);
2247 case LFUN_INSET_APPLY: {
2248 string const name = cmd.getArg(0);
2249 Inset * inset = getOpenInset(name);
2251 // put cursor in front of inset.
2252 if (!view()->setCursorFromInset(inset)) {
2253 LASSERT(false, break);
2256 // useful if we are called from a dialog.
2257 view()->cursor().beginUndoGroup();
2258 view()->cursor().recordUndo();
2259 FuncRequest fr(LFUN_INSET_MODIFY, cmd.argument());
2260 inset->dispatch(view()->cursor(), fr);
2261 view()->cursor().endUndoGroup();
2263 FuncRequest fr(LFUN_INSET_INSERT, cmd.argument());
2269 case LFUN_UI_TOGGLE:
2271 // Make sure the keyboard focus stays in the work area.
2275 case LFUN_SPLIT_VIEW:
2276 if (Buffer * buf = buffer()) {
2277 string const orientation = cmd.getArg(0);
2278 d.splitter_->setOrientation(orientation == "vertical"
2279 ? Qt::Vertical : Qt::Horizontal);
2280 TabWorkArea * twa = addTabWorkArea();
2281 GuiWorkArea * wa = twa->addWorkArea(*buf, *this);
2282 setCurrentWorkArea(wa);
2286 case LFUN_CLOSE_TAB_GROUP:
2287 if (TabWorkArea * twa = d.currentTabWorkArea()) {
2289 d.current_work_area_ = 0;
2290 twa = d.currentTabWorkArea();
2291 // Switch to the next GuiWorkArea in the found TabWorkArea.
2293 // Make sure the work area is up to date.
2294 setCurrentWorkArea(twa->currentWorkArea());
2296 setCurrentWorkArea(0);
2301 case LFUN_COMPLETION_INLINE:
2302 if (d.current_work_area_)
2303 d.current_work_area_->completer().showInline();
2306 case LFUN_COMPLETION_POPUP:
2307 if (d.current_work_area_)
2308 d.current_work_area_->completer().showPopup();
2312 case LFUN_COMPLETION_COMPLETE:
2313 if (d.current_work_area_)
2314 d.current_work_area_->completer().tab();
2317 case LFUN_COMPLETION_CANCEL:
2318 if (d.current_work_area_) {
2319 if (d.current_work_area_->completer().popupVisible())
2320 d.current_work_area_->completer().hidePopup();
2322 d.current_work_area_->completer().hideInline();
2326 case LFUN_COMPLETION_ACCEPT:
2327 if (d.current_work_area_)
2328 d.current_work_area_->completer().activate();
2331 case LFUN_BUFFER_ZOOM_IN:
2332 case LFUN_BUFFER_ZOOM_OUT:
2333 if (cmd.argument().empty()) {
2334 if (cmd.action == LFUN_BUFFER_ZOOM_IN)
2339 lyxrc.zoom += convert<int>(cmd.argument());
2341 if (lyxrc.zoom < 10)
2344 // The global QPixmapCache is used in GuiPainter to cache text
2345 // painting so we must reset it.
2346 QPixmapCache::clear();
2347 guiApp->fontLoader().update();
2348 lyx::dispatch(FuncRequest(LFUN_SCREEN_FONT_UPDATE));
2356 // Part of automatic menu appearance feature.
2357 if (isFullScreen()) {
2358 if (menuBar()->isVisible() && lyxrc.full_screen_menubar)
2360 if (statusBar()->isVisible())
2361 statusBar()->hide();
2368 void GuiView::lfunUiToggle(FuncRequest const & cmd)
2370 string const arg = cmd.getArg(0);
2371 if (arg == "scrollbar") {
2372 // hide() is of no help
2373 if (d.current_work_area_->verticalScrollBarPolicy() ==
2374 Qt::ScrollBarAlwaysOff)
2376 d.current_work_area_->setVerticalScrollBarPolicy(
2377 Qt::ScrollBarAsNeeded);
2379 d.current_work_area_->setVerticalScrollBarPolicy(
2380 Qt::ScrollBarAlwaysOff);
2383 if (arg == "statusbar") {
2384 statusBar()->setVisible(!statusBar()->isVisible());
2387 if (arg == "menubar") {
2388 menuBar()->setVisible(!menuBar()->isVisible());
2391 #if QT_VERSION >= 0x040300
2392 if (arg == "frame") {
2394 getContentsMargins(&l, &t, &r, &b);
2395 //are the frames in default state?
2396 d.current_work_area_->setFrameStyle(QFrame::NoFrame);
2398 setContentsMargins(-2, -2, -2, -2);
2400 setContentsMargins(0, 0, 0, 0);
2405 if (arg == "fullscreen") {
2410 message(bformat("LFUN_UI_TOGGLE " + _("%1$s unknown command!"), from_utf8(arg)));
2414 void GuiView::toggleFullScreen()
2416 if (isFullScreen()) {
2417 for (int i = 0; i != d.splitter_->count(); ++i)
2418 d.tabWorkArea(i)->setFullScreen(false);
2419 #if QT_VERSION >= 0x040300
2420 setContentsMargins(0, 0, 0, 0);
2422 setWindowState(windowState() ^ Qt::WindowFullScreen);
2425 statusBar()->show();
2428 hideDialogs("prefs", 0);
2429 for (int i = 0; i != d.splitter_->count(); ++i)
2430 d.tabWorkArea(i)->setFullScreen(true);
2431 #if QT_VERSION >= 0x040300
2432 setContentsMargins(-2, -2, -2, -2);
2435 setWindowState(windowState() ^ Qt::WindowFullScreen);
2436 statusBar()->hide();
2437 if (lyxrc.full_screen_menubar)
2439 if (lyxrc.full_screen_toolbars) {
2440 ToolbarMap::iterator end = d.toolbars_.end();
2441 for (ToolbarMap::iterator it = d.toolbars_.begin(); it != end; ++it)
2446 // give dialogs like the TOC a chance to adapt
2451 Buffer const * GuiView::updateInset(Inset const * inset)
2453 if (!d.current_work_area_)
2457 d.current_work_area_->scheduleRedraw();
2459 return &d.current_work_area_->bufferView().buffer();
2463 void GuiView::restartCursor()
2465 /* When we move around, or type, it's nice to be able to see
2466 * the cursor immediately after the keypress.
2468 if (d.current_work_area_)
2469 d.current_work_area_->startBlinkingCursor();
2471 // Take this occasion to update the other GUI elements.
2477 void GuiView::updateCompletion(Cursor & cur, bool start, bool keep)
2479 if (d.current_work_area_)
2480 d.current_work_area_->completer().updateVisibility(cur, start, keep);
2485 // This list should be kept in sync with the list of insets in
2486 // src/insets/Inset.cpp. I.e., if a dialog goes with an inset, the
2487 // dialog should have the same name as the inset.
2488 // Changes should be also recorded in LFUN_DIALOG_SHOW doxygen
2489 // docs in LyXAction.cpp.
2491 char const * const dialognames[] = {
2492 "aboutlyx", "bibitem", "bibtex", "box", "branch", "changes", "character",
2493 "citation", "document", "errorlist", "ert", "external", "file", "findreplace",
2494 "findreplaceadv", "float", "graphics", "href", "include", "index",
2495 "index_print", "info", "listings", "label", "log", "mathdelimiter",
2496 "mathmatrix", "mathspace", "nomenclature", "nomencl_print", "note",
2497 "paragraph", "phantom", "prefs", "print", "ref", "sendto", "space",
2498 "spellchecker", "symbols", "tabular", "tabularcreate", "thesaurus", "texinfo",
2499 "toc", "view-source", "vspace", "wrap" };
2501 char const * const * const end_dialognames =
2502 dialognames + (sizeof(dialognames) / sizeof(char *));
2506 cmpCStr(char const * name) : name_(name) {}
2507 bool operator()(char const * other) {
2508 return strcmp(other, name_) == 0;
2515 bool isValidName(string const & name)
2517 return find_if(dialognames, end_dialognames,
2518 cmpCStr(name.c_str())) != end_dialognames;
2524 void GuiView::resetDialogs()
2526 // Make sure that no LFUN uses any LyXView.
2527 theLyXFunc().setLyXView(0);
2530 constructToolbars();
2531 guiApp->menus().fillMenuBar(menuBar(), this, false);
2532 d.layout_->updateContents(true);
2533 // Now update controls with current buffer.
2534 theLyXFunc().setLyXView(this);
2540 Dialog * GuiView::findOrBuild(string const & name, bool hide_it)
2542 if (!isValidName(name))
2545 map<string, DialogPtr>::iterator it = d.dialogs_.find(name);
2547 if (it != d.dialogs_.end()) {
2549 it->second->hideView();
2550 return it->second.get();
2553 Dialog * dialog = build(name);
2554 d.dialogs_[name].reset(dialog);
2555 if (lyxrc.allow_geometry_session)
2556 dialog->restoreSession();
2563 void GuiView::showDialog(string const & name, string const & data,
2571 Dialog * dialog = findOrBuild(name, false);
2573 dialog->showData(data);
2575 d.open_insets_[name] = inset;
2578 catch (ExceptionMessage const & ex) {
2586 bool GuiView::isDialogVisible(string const & name) const
2588 map<string, DialogPtr>::const_iterator it = d.dialogs_.find(name);
2589 if (it == d.dialogs_.end())
2591 return it->second.get()->isVisibleView() && !it->second.get()->isClosing();
2595 void GuiView::hideDialog(string const & name, Inset * inset)
2597 map<string, DialogPtr>::const_iterator it = d.dialogs_.find(name);
2598 if (it == d.dialogs_.end())
2601 if (inset && inset != getOpenInset(name))
2604 Dialog * const dialog = it->second.get();
2605 if (dialog->isVisibleView())
2607 d.open_insets_[name] = 0;
2611 void GuiView::disconnectDialog(string const & name)
2613 if (!isValidName(name))
2616 if (d.open_insets_.find(name) != d.open_insets_.end())
2617 d.open_insets_[name] = 0;
2621 Inset * GuiView::getOpenInset(string const & name) const
2623 if (!isValidName(name))
2626 map<string, Inset *>::const_iterator it = d.open_insets_.find(name);
2627 return it == d.open_insets_.end() ? 0 : it->second;
2631 void GuiView::hideAll() const
2633 map<string, DialogPtr>::const_iterator it = d.dialogs_.begin();
2634 map<string, DialogPtr>::const_iterator end = d.dialogs_.end();
2636 for(; it != end; ++it)
2637 it->second->hideView();
2641 void GuiView::updateDialogs()
2643 map<string, DialogPtr>::const_iterator it = d.dialogs_.begin();
2644 map<string, DialogPtr>::const_iterator end = d.dialogs_.end();
2646 for(; it != end; ++it) {
2647 Dialog * dialog = it->second.get();
2648 if (dialog && dialog->isVisibleView())
2649 dialog->checkStatus();
2656 // will be replaced by a proper factory...
2657 Dialog * createGuiAbout(GuiView & lv);
2658 Dialog * createGuiBibitem(GuiView & lv);
2659 Dialog * createGuiBibtex(GuiView & lv);
2660 Dialog * createGuiBox(GuiView & lv);
2661 Dialog * createGuiBranch(GuiView & lv);
2662 Dialog * createGuiChanges(GuiView & lv);
2663 Dialog * createGuiCharacter(GuiView & lv);
2664 Dialog * createGuiCitation(GuiView & lv);
2665 Dialog * createGuiDelimiter(GuiView & lv);
2666 Dialog * createGuiDocument(GuiView & lv);
2667 Dialog * createGuiErrorList(GuiView & lv);
2668 Dialog * createGuiERT(GuiView & lv);
2669 Dialog * createGuiExternal(GuiView & lv);
2670 Dialog * createGuiFloat(GuiView & lv);
2671 Dialog * createGuiGraphics(GuiView & lv);
2672 Dialog * createGuiInclude(GuiView & lv);
2673 Dialog * createGuiIndex(GuiView & lv);
2674 Dialog * createGuiInfo(GuiView & lv);
2675 Dialog * createGuiLabel(GuiView & lv);
2676 Dialog * createGuiListings(GuiView & lv);
2677 Dialog * createGuiLog(GuiView & lv);
2678 Dialog * createGuiMathHSpace(GuiView & lv);
2679 Dialog * createGuiMathMatrix(GuiView & lv);
2680 Dialog * createGuiNomenclature(GuiView & lv);
2681 Dialog * createGuiNote(GuiView & lv);
2682 Dialog * createGuiParagraph(GuiView & lv);
2683 Dialog * createGuiPhantom(GuiView & lv);
2684 Dialog * createGuiPreferences(GuiView & lv);
2685 Dialog * createGuiPrint(GuiView & lv);
2686 Dialog * createGuiPrintindex(GuiView & lv);
2687 Dialog * createGuiPrintNomencl(GuiView & lv);
2688 Dialog * createGuiRef(GuiView & lv);
2689 Dialog * createGuiSearch(GuiView & lv);
2690 Dialog * createGuiSearchAdv(GuiView & lv);
2691 Dialog * createGuiSendTo(GuiView & lv);
2692 Dialog * createGuiShowFile(GuiView & lv);
2693 Dialog * createGuiSpellchecker(GuiView & lv);
2694 Dialog * createGuiSymbols(GuiView & lv);
2695 Dialog * createGuiTabularCreate(GuiView & lv);
2696 Dialog * createGuiTabular(GuiView & lv);
2697 Dialog * createGuiTexInfo(GuiView & lv);
2698 Dialog * createGuiTextHSpace(GuiView & lv);
2699 Dialog * createGuiToc(GuiView & lv);
2700 Dialog * createGuiThesaurus(GuiView & lv);
2701 Dialog * createGuiHyperlink(GuiView & lv);
2702 Dialog * createGuiVSpace(GuiView & lv);
2703 Dialog * createGuiViewSource(GuiView & lv);
2704 Dialog * createGuiWrap(GuiView & lv);
2707 Dialog * GuiView::build(string const & name)
2709 LASSERT(isValidName(name), return 0);
2711 if (name == "aboutlyx")
2712 return createGuiAbout(*this);
2713 if (name == "bibitem")
2714 return createGuiBibitem(*this);
2715 if (name == "bibtex")
2716 return createGuiBibtex(*this);
2718 return createGuiBox(*this);
2719 if (name == "branch")
2720 return createGuiBranch(*this);
2721 if (name == "changes")
2722 return createGuiChanges(*this);
2723 if (name == "character")
2724 return createGuiCharacter(*this);
2725 if (name == "citation")
2726 return createGuiCitation(*this);
2727 if (name == "document")
2728 return createGuiDocument(*this);
2729 if (name == "errorlist")
2730 return createGuiErrorList(*this);
2732 return createGuiERT(*this);
2733 if (name == "external")
2734 return createGuiExternal(*this);
2736 return createGuiShowFile(*this);
2737 if (name == "findreplace")
2738 return createGuiSearch(*this);
2739 if (name == "findreplaceadv")
2740 return createGuiSearchAdv(*this);
2741 if (name == "float")
2742 return createGuiFloat(*this);
2743 if (name == "graphics")
2744 return createGuiGraphics(*this);
2746 return createGuiHyperlink(*this);
2747 if (name == "include")
2748 return createGuiInclude(*this);
2749 if (name == "index")
2750 return createGuiIndex(*this);
2751 if (name == "index_print")
2752 return createGuiPrintindex(*this);
2754 return createGuiInfo(*this);
2755 if (name == "label")
2756 return createGuiLabel(*this);
2757 if (name == "listings")
2758 return createGuiListings(*this);
2760 return createGuiLog(*this);
2761 if (name == "mathdelimiter")
2762 return createGuiDelimiter(*this);
2763 if (name == "mathspace")
2764 return createGuiMathHSpace(*this);
2765 if (name == "mathmatrix")
2766 return createGuiMathMatrix(*this);
2767 if (name == "nomenclature")
2768 return createGuiNomenclature(*this);
2769 if (name == "nomencl_print")
2770 return createGuiPrintNomencl(*this);
2772 return createGuiNote(*this);
2773 if (name == "paragraph")
2774 return createGuiParagraph(*this);
2775 if (name == "phantom")
2776 return createGuiPhantom(*this);
2777 if (name == "prefs")
2778 return createGuiPreferences(*this);
2779 if (name == "print")
2780 return createGuiPrint(*this);
2782 return createGuiRef(*this);
2783 if (name == "sendto")
2784 return createGuiSendTo(*this);
2785 if (name == "space")
2786 return createGuiTextHSpace(*this);
2787 if (name == "spellchecker")
2788 return createGuiSpellchecker(*this);
2789 if (name == "symbols")
2790 return createGuiSymbols(*this);
2791 if (name == "tabular")
2792 return createGuiTabular(*this);
2793 if (name == "tabularcreate")
2794 return createGuiTabularCreate(*this);
2795 if (name == "texinfo")
2796 return createGuiTexInfo(*this);
2797 if (name == "thesaurus")
2798 return createGuiThesaurus(*this);
2800 return createGuiToc(*this);
2801 if (name == "view-source")
2802 return createGuiViewSource(*this);
2803 if (name == "vspace")
2804 return createGuiVSpace(*this);
2806 return createGuiWrap(*this);
2812 } // namespace frontend
2815 #include "moc_GuiView.cpp"