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()");
549 // it can happen that this event arrives without selecting the view,
550 // e.g. when clicking the close button on a background window.
552 if (!closeWorkAreaAll()) {
554 close_event->ignore();
558 // Make sure that nothing will use this to be closed View.
559 guiApp->unregisterView(this);
561 if (isFullScreen()) {
562 // Switch off fullscreen before closing.
567 // Make sure the timer time out will not trigger a statusbar update.
568 d.statusbar_timer_.stop();
570 // Saving fullscreen requires additional tweaks in the toolbar code.
571 // It wouldn't also work under linux natively.
572 if (lyxrc.allow_geometry_session) {
573 // Save this window geometry and layout.
575 // Then the toolbar private states.
576 ToolbarMap::iterator end = d.toolbars_.end();
577 for (ToolbarMap::iterator it = d.toolbars_.begin(); it != end; ++it)
578 it->second->saveSession();
579 // Now take care of all other dialogs:
580 map<string, DialogPtr>::const_iterator it = d.dialogs_.begin();
581 for (; it!= d.dialogs_.end(); ++it)
582 it->second->saveSession();
585 close_event->accept();
589 void GuiView::dragEnterEvent(QDragEnterEvent * event)
591 if (event->mimeData()->hasUrls())
593 /// \todo Ask lyx-devel is this is enough:
594 /// if (event->mimeData()->hasFormat("text/plain"))
595 /// event->acceptProposedAction();
599 void GuiView::dropEvent(QDropEvent * event)
601 QList<QUrl> files = event->mimeData()->urls();
605 LYXERR(Debug::GUI, "GuiView::dropEvent: got URLs!");
606 for (int i = 0; i != files.size(); ++i) {
607 string const file = os::internal_path(fromqstr(
608 files.at(i).toLocalFile()));
610 // Asynchronously post the event. DropEvent usually come
611 // from the BufferView. But reloading a file might close
612 // the BufferView from within its own event handler.
613 guiApp->dispatchDelayed(FuncRequest(LFUN_FILE_OPEN, file));
620 void GuiView::message(docstring const & str)
622 if (ForkedProcess::iAmAChild())
625 statusBar()->showMessage(toqstr(str));
626 d.statusbar_timer_.stop();
627 d.statusbar_timer_.start(3000);
631 void GuiView::smallSizedIcons()
633 setIconSize(QSize(d.smallIconSize, d.smallIconSize));
637 void GuiView::normalSizedIcons()
639 setIconSize(QSize(d.normalIconSize, d.normalIconSize));
643 void GuiView::bigSizedIcons()
645 setIconSize(QSize(d.bigIconSize, d.bigIconSize));
649 void GuiView::clearMessage()
653 theLyXFunc().setLyXView(this);
654 statusBar()->showMessage(toqstr(theLyXFunc().viewStatusMessage()));
655 d.statusbar_timer_.stop();
659 void GuiView::updateWindowTitle(GuiWorkArea * wa)
661 if (wa != d.current_work_area_)
663 setWindowTitle(qt_("LyX: ") + wa->windowTitle());
664 setWindowIconText(wa->windowIconText());
668 void GuiView::on_currentWorkAreaChanged(GuiWorkArea * wa)
671 disconnectBufferView();
672 connectBufferView(wa->bufferView());
673 connectBuffer(wa->bufferView().buffer());
674 d.current_work_area_ = wa;
675 QObject::connect(wa, SIGNAL(titleChanged(GuiWorkArea *)),
676 this, SLOT(updateWindowTitle(GuiWorkArea *)));
677 updateWindowTitle(wa);
681 // The document settings needs to be reinitialised.
682 updateDialog("document", "");
684 // Buffer-dependent dialogs must be updated. This is done here because
685 // some dialogs require buffer()->text.
690 void GuiView::on_lastWorkAreaRemoved()
693 // We already are in a close event. Nothing more to do.
696 if (d.splitter_->count() > 1)
697 // We have a splitter so don't close anything.
700 // Reset and updates the dialogs.
701 d.toc_models_.reset(0);
702 updateDialog("document", "");
705 resetWindowTitleAndIconText();
707 if (lyxrc.open_buffers_in_tabs)
708 // Nothing more to do, the window should stay open.
711 if (guiApp->viewIds().size() > 1) {
717 // On Mac we also close the last window because the application stay
718 // resident in memory. On other platforms we don't close the last
719 // window because this would quit the application.
725 void GuiView::updateStatusBar()
727 // let the user see the explicit message
728 if (d.statusbar_timer_.isActive())
731 theLyXFunc().setLyXView(this);
732 statusBar()->showMessage(toqstr(theLyXFunc().viewStatusMessage()));
736 bool GuiView::hasFocus() const
738 return qApp->activeWindow() == this;
742 bool GuiView::event(QEvent * e)
746 // Useful debug code:
747 //case QEvent::ActivationChange:
748 //case QEvent::WindowDeactivate:
749 //case QEvent::Paint:
750 //case QEvent::Enter:
751 //case QEvent::Leave:
752 //case QEvent::HoverEnter:
753 //case QEvent::HoverLeave:
754 //case QEvent::HoverMove:
755 //case QEvent::StatusTip:
756 //case QEvent::DragEnter:
757 //case QEvent::DragLeave:
761 case QEvent::WindowActivate: {
762 if (this == guiApp->currentView()) {
764 return QMainWindow::event(e);
766 guiApp->setCurrentView(this);
767 theLyXFunc().setLyXView(this);
768 if (d.current_work_area_) {
769 BufferView & bv = d.current_work_area_->bufferView();
770 connectBufferView(bv);
771 connectBuffer(bv.buffer());
772 // The document structure, name and dialogs might have
773 // changed in another view.
775 // The document settings needs to be reinitialised.
776 updateDialog("document", "");
779 resetWindowTitleAndIconText();
782 return QMainWindow::event(e);
785 case QEvent::ShortcutOverride: {
788 #if (!defined Q_WS_X11) || (QT_VERSION >= 0x040500)
789 if (isFullScreen() && menuBar()->isHidden()) {
790 QKeyEvent * ke = static_cast<QKeyEvent*>(e);
791 // FIXME: we should also try to detect special LyX shortcut such as
792 // Alt-P and Alt-M. Right now there is a hack in
793 // GuiWorkArea::processKeySym() that hides again the menubar for
795 if (ke->modifiers() & Qt::AltModifier && ke->key() != Qt::Key_Alt) {
797 return QMainWindow::event(e);
802 if (d.current_work_area_)
803 // Nothing special to do.
804 return QMainWindow::event(e);
806 QKeyEvent * ke = static_cast<QKeyEvent*>(e);
807 // Let Qt handle menu access and the Tab keys to navigate keys to navigate
809 if (ke->modifiers() & Qt::AltModifier || ke->key() == Qt::Key_Tab
810 || ke->key() == Qt::Key_Backtab)
811 return QMainWindow::event(e);
813 // Allow processing of shortcuts that are allowed even when no Buffer
815 theLyXFunc().setLyXView(this);
817 setKeySymbol(&sym, ke);
818 theLyXFunc().processKeySym(sym, q_key_state(ke->modifiers()));
824 return QMainWindow::event(e);
828 void GuiView::resetWindowTitleAndIconText()
830 setWindowTitle(qt_("LyX"));
831 setWindowIconText(qt_("LyX"));
834 bool GuiView::focusNextPrevChild(bool /*next*/)
841 void GuiView::setBusy(bool busy)
843 if (d.current_work_area_) {
844 d.current_work_area_->setUpdatesEnabled(!busy);
846 d.current_work_area_->stopBlinkingCursor();
848 d.current_work_area_->startBlinkingCursor();
852 QApplication::setOverrideCursor(Qt::WaitCursor);
854 QApplication::restoreOverrideCursor();
858 GuiWorkArea * GuiView::workArea(Buffer & buffer)
860 if (currentWorkArea()
861 && ¤tWorkArea()->bufferView().buffer() == &buffer)
862 return (GuiWorkArea *) currentWorkArea();
863 if (TabWorkArea * twa = d.currentTabWorkArea())
864 return twa->workArea(buffer);
869 GuiWorkArea * GuiView::addWorkArea(Buffer & buffer)
871 // Automatically create a TabWorkArea if there are none yet.
872 TabWorkArea * tab_widget = d.splitter_->count()
873 ? d.currentTabWorkArea() : addTabWorkArea();
874 return tab_widget->addWorkArea(buffer, *this);
878 TabWorkArea * GuiView::addTabWorkArea()
880 TabWorkArea * twa = new TabWorkArea;
881 QObject::connect(twa, SIGNAL(currentWorkAreaChanged(GuiWorkArea *)),
882 this, SLOT(on_currentWorkAreaChanged(GuiWorkArea *)));
883 QObject::connect(twa, SIGNAL(lastWorkAreaRemoved()),
884 this, SLOT(on_lastWorkAreaRemoved()));
886 d.splitter_->addWidget(twa);
887 d.stack_widget_->setCurrentWidget(d.splitter_);
892 GuiWorkArea const * GuiView::currentWorkArea() const
894 return d.current_work_area_;
898 GuiWorkArea * GuiView::currentWorkArea()
900 return d.current_work_area_;
904 GuiWorkArea const * GuiView::currentMainWorkArea() const
906 if (d.currentTabWorkArea() == NULL)
908 return d.currentTabWorkArea()->currentWorkArea();
912 GuiWorkArea * GuiView::currentMainWorkArea()
914 if (d.currentTabWorkArea() == NULL)
916 return d.currentTabWorkArea()->currentWorkArea();
920 void GuiView::setCurrentWorkArea(GuiWorkArea * wa)
922 LYXERR(Debug::DEBUG, "Setting current wa: " << wa << endl);
924 d.current_work_area_ = NULL;
928 GuiWorkArea * old_gwa = theGuiApp()->currentView()->currentWorkArea();
932 if (currentBufferView())
933 cap::saveSelection(currentBufferView()->cursor());
935 theGuiApp()->setCurrentView(this);
936 d.current_work_area_ = wa;
937 for (int i = 0; i != d.splitter_->count(); ++i) {
938 if (d.tabWorkArea(i)->setCurrentWorkArea(wa)) {
939 //if (d.current_main_work_area_)
940 // d.current_main_work_area_->setFrameStyle(QFrame::NoFrame);
941 d.current_main_work_area_ = wa;
942 //d.current_main_work_area_->setFrameStyle(QFrame::Box | QFrame::Plain);
943 //d.current_main_work_area_->setLineWidth(2);
944 LYXERR(Debug::DEBUG, "Current wa: " << currentWorkArea() << ", Current main wa: " << currentMainWorkArea());
948 LYXERR(Debug::DEBUG, "This is not a tabbed wa");
949 on_currentWorkAreaChanged(wa);
950 BufferView & bv = wa->bufferView();
951 bv.cursor().fixIfBroken();
953 wa->setUpdatesEnabled(true);
954 LYXERR(Debug::DEBUG, "Current wa: " << currentWorkArea() << ", Current main wa: " << currentMainWorkArea());
958 void GuiView::removeWorkArea(GuiWorkArea * wa)
961 if (wa == d.current_work_area_) {
963 disconnectBufferView();
964 d.current_work_area_ = 0;
965 d.current_main_work_area_ = 0;
968 bool found_twa = false;
969 for (int i = 0; i != d.splitter_->count(); ++i) {
970 TabWorkArea * twa = d.tabWorkArea(i);
971 if (twa->removeWorkArea(wa)) {
972 // Found in this tab group, and deleted the GuiWorkArea.
974 if (twa->count() != 0) {
975 if (d.current_work_area_ == 0)
976 // This means that we are closing the current GuiWorkArea, so
977 // switch to the next GuiWorkArea in the found TabWorkArea.
978 setCurrentWorkArea(twa->currentWorkArea());
980 // No more WorkAreas in this tab group, so delete it.
987 // It is not a tabbed work area (i.e., the search work area), so it
988 // should be deleted by other means.
989 LASSERT(found_twa, /* */);
991 if (d.current_work_area_ == 0) {
992 if (d.splitter_->count() != 0) {
993 TabWorkArea * twa = d.currentTabWorkArea();
994 setCurrentWorkArea(twa->currentWorkArea());
996 // No more work areas, switch to the background widget.
997 setCurrentWorkArea(0);
1003 LayoutBox * GuiView::getLayoutDialog() const
1009 void GuiView::updateLayoutList()
1012 d.layout_->updateContents(false);
1016 void GuiView::updateToolbars()
1018 ToolbarMap::iterator end = d.toolbars_.end();
1019 if (d.current_work_area_) {
1021 d.current_work_area_->bufferView().cursor().inMathed();
1023 lyx::getStatus(FuncRequest(LFUN_LAYOUT_TABULAR)).enabled();
1025 lyx::getStatus(FuncRequest(LFUN_CHANGES_TRACK)).enabled() &&
1026 lyx::getStatus(FuncRequest(LFUN_CHANGES_TRACK)).onoff(true);
1027 bool const mathmacrotemplate =
1028 lyx::getStatus(FuncRequest(LFUN_IN_MATHMACROTEMPLATE)).enabled();
1030 for (ToolbarMap::iterator it = d.toolbars_.begin(); it != end; ++it)
1031 it->second->update(math, table, review, mathmacrotemplate);
1033 for (ToolbarMap::iterator it = d.toolbars_.begin(); it != end; ++it)
1034 it->second->update(false, false, false, false);
1038 Buffer * GuiView::buffer()
1040 if (d.current_work_area_)
1041 return &d.current_work_area_->bufferView().buffer();
1046 Buffer const * GuiView::buffer() const
1048 if (d.current_work_area_)
1049 return &d.current_work_area_->bufferView().buffer();
1054 Buffer * GuiView::documentBuffer()
1056 TabWorkArea * twa = d.currentTabWorkArea();
1057 if (twa && twa->currentWorkArea())
1058 return &twa->currentWorkArea()->bufferView().buffer();
1063 Buffer const * GuiView::documentBuffer() const
1065 TabWorkArea * twa = d.currentTabWorkArea();
1066 if (twa && twa->currentWorkArea())
1067 return &twa->currentWorkArea()->bufferView().buffer();
1072 void GuiView::setBuffer(Buffer * newBuffer)
1074 LYXERR(Debug::DEBUG, "Setting buffer: " << newBuffer << std::endl);
1075 LASSERT(newBuffer, return);
1078 GuiWorkArea * wa = workArea(*newBuffer);
1080 newBuffer->masterBuffer()->updateLabels();
1081 wa = addWorkArea(*newBuffer);
1083 //Disconnect the old buffer...there's no new one.
1086 connectBuffer(*newBuffer);
1087 connectBufferView(wa->bufferView());
1088 setCurrentWorkArea(wa);
1094 void GuiView::connectBuffer(Buffer & buf)
1096 buf.setGuiDelegate(this);
1100 void GuiView::disconnectBuffer()
1102 if (d.current_work_area_)
1103 d.current_work_area_->bufferView().buffer().setGuiDelegate(0);
1107 void GuiView::connectBufferView(BufferView & bv)
1109 bv.setGuiDelegate(this);
1113 void GuiView::disconnectBufferView()
1115 if (d.current_work_area_)
1116 d.current_work_area_->bufferView().setGuiDelegate(0);
1120 void GuiView::errors(string const & error_type, bool from_master)
1122 ErrorList & el = from_master ?
1123 buffer()->masterBuffer()->errorList(error_type)
1124 : buffer()->errorList(error_type);
1125 string data = error_type;
1127 data = "from_master|" + error_type;
1129 showDialog("errorlist", data);
1133 void GuiView::updateTocItem(std::string const & type, DocIterator const & dit)
1135 d.toc_models_.updateItem(toqstr(type), dit);
1139 void GuiView::structureChanged()
1141 d.toc_models_.reset(documentBufferView());
1142 // Navigator needs more than a simple update in this case. It needs to be
1144 updateDialog("toc", "");
1148 void GuiView::updateDialog(string const & name, string const & data)
1150 if (!isDialogVisible(name))
1153 map<string, DialogPtr>::const_iterator it = d.dialogs_.find(name);
1154 if (it == d.dialogs_.end())
1157 Dialog * const dialog = it->second.get();
1158 if (dialog->isVisibleView())
1159 dialog->initialiseParams(data);
1163 BufferView * GuiView::documentBufferView()
1165 return currentMainWorkArea()
1166 ? ¤tMainWorkArea()->bufferView()
1171 BufferView const * GuiView::documentBufferView() const
1173 return currentMainWorkArea()
1174 ? ¤tMainWorkArea()->bufferView()
1179 BufferView * GuiView::currentBufferView()
1181 return d.current_work_area_ ? &d.current_work_area_->bufferView() : 0;
1185 BufferView const * GuiView::currentBufferView() const
1187 return d.current_work_area_ ? &d.current_work_area_->bufferView() : 0;
1191 void GuiView::autoSave()
1193 LYXERR(Debug::INFO, "Running autoSave()");
1195 if (documentBufferView())
1196 documentBufferView()->buffer().autoSave();
1200 void GuiView::resetAutosaveTimers()
1203 d.autosave_timeout_.restart();
1207 bool GuiView::getStatus(FuncRequest const & cmd, FuncStatus & flag)
1210 Buffer * buf = buffer();
1212 if (cmd.origin == FuncRequest::TOC) {
1213 GuiToc * toc = static_cast<GuiToc*>(findOrBuild("toc", false));
1215 if (toc->getStatus(documentBufferView()->cursor(), cmd, fs))
1218 flag.setEnabled(false);
1222 switch(cmd.action) {
1223 case LFUN_BUFFER_WRITE:
1224 enable = buf && (buf->isUnnamed() || !buf->isClean());
1227 case LFUN_BUFFER_WRITE_AS:
1231 case LFUN_BUFFER_CLOSE_ALL:
1232 enable = theBufferList().last() != theBufferList().first();
1235 case LFUN_SPLIT_VIEW:
1236 if (cmd.getArg(0) == "vertical")
1237 enable = buf && (d.splitter_->count() == 1 ||
1238 d.splitter_->orientation() == Qt::Vertical);
1240 enable = buf && (d.splitter_->count() == 1 ||
1241 d.splitter_->orientation() == Qt::Horizontal);
1244 case LFUN_CLOSE_TAB_GROUP:
1245 enable = d.currentTabWorkArea();
1248 case LFUN_TOOLBAR_TOGGLE:
1249 if (GuiToolbar * t = toolbar(cmd.getArg(0)))
1250 flag.setOnOff(t->isVisible());
1253 case LFUN_UI_TOGGLE:
1254 flag.setOnOff(isFullScreen());
1257 case LFUN_DIALOG_TOGGLE:
1258 flag.setOnOff(isDialogVisible(cmd.getArg(0)));
1259 // fall through to set "enable"
1260 case LFUN_DIALOG_SHOW: {
1261 string const name = cmd.getArg(0);
1263 enable = name == "aboutlyx"
1264 || name == "file" //FIXME: should be removed.
1266 || name == "texinfo";
1267 else if (name == "print")
1268 enable = buf->isExportable("dvi")
1269 && lyxrc.print_command != "none";
1270 else if (name == "character" || name == "symbols") {
1271 if (buf->isReadonly() || !currentBufferView()
1272 || !currentBufferView()->cursor().inTexted())
1275 // FIXME we should consider passthru
1277 Inset const & in = currentBufferView()->cursor().inset();
1278 enable = !in.getLayout().isPassThru();
1281 else if (name == "latexlog")
1282 enable = FileName(buf->logName()).isReadableFile();
1283 else if (name == "spellchecker")
1284 enable = theSpellChecker() && !buf->isReadonly();
1285 else if (name == "vclog")
1286 enable = buf->lyxvc().inUse();
1290 case LFUN_DIALOG_UPDATE: {
1291 string const name = cmd.getArg(0);
1293 enable = name == "prefs";
1297 case LFUN_INSET_APPLY: {
1298 string const name = cmd.getArg(0);
1299 Inset * inset = getOpenInset(name);
1301 FuncRequest fr(LFUN_INSET_MODIFY, cmd.argument());
1303 if (!inset->getStatus(currentBufferView()->cursor(), fr, fs)) {
1304 // Every inset is supposed to handle this
1305 LASSERT(false, break);
1309 FuncRequest fr(LFUN_INSET_INSERT, cmd.argument());
1310 flag |= lyx::getStatus(fr);
1312 enable = flag.enabled();
1316 case LFUN_COMPLETION_INLINE:
1317 if (!d.current_work_area_
1318 || !d.current_work_area_->completer().inlinePossible(
1319 currentBufferView()->cursor()))
1323 case LFUN_COMPLETION_POPUP:
1324 if (!d.current_work_area_
1325 || !d.current_work_area_->completer().popupPossible(
1326 currentBufferView()->cursor()))
1330 case LFUN_COMPLETION_COMPLETE:
1331 if (!d.current_work_area_
1332 || !d.current_work_area_->completer().inlinePossible(
1333 currentBufferView()->cursor()))
1337 case LFUN_COMPLETION_ACCEPT:
1338 if (!d.current_work_area_
1339 || (!d.current_work_area_->completer().popupVisible()
1340 && !d.current_work_area_->completer().inlineVisible()
1341 && !d.current_work_area_->completer().completionAvailable()))
1345 case LFUN_COMPLETION_CANCEL:
1346 if (!d.current_work_area_
1347 || (!d.current_work_area_->completer().popupVisible()
1348 && !d.current_work_area_->completer().inlineVisible()))
1352 case LFUN_BUFFER_ZOOM_OUT:
1353 enable = buf && lyxrc.zoom > 10;
1356 case LFUN_BUFFER_ZOOM_IN:
1365 flag.setEnabled(false);
1371 static FileName selectTemplateFile()
1373 FileDialog dlg(qt_("Select template file"));
1374 dlg.setButton1(qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
1375 dlg.setButton1(qt_("Templates|#T#t"), toqstr(lyxrc.template_path));
1377 FileDialog::Result result = dlg.open(toqstr(lyxrc.template_path),
1378 QStringList(qt_("LyX Documents (*.lyx)")));
1380 if (result.first == FileDialog::Later)
1382 if (result.second.isEmpty())
1384 return FileName(fromqstr(result.second));
1388 Buffer * GuiView::loadDocument(FileName const & filename, bool tolastfiles)
1392 Buffer * newBuffer = checkAndLoadLyXFile(filename);
1395 message(_("Document not loaded."));
1400 setBuffer(newBuffer);
1402 // scroll to the position when the file was last closed
1403 if (lyxrc.use_lastfilepos) {
1404 LastFilePosSection::FilePos filepos =
1405 theSession().lastFilePos().load(filename);
1406 documentBufferView()->moveToPosition(filepos.pit, filepos.pos, 0, 0);
1410 theSession().lastFiles().add(filename);
1417 void GuiView::openDocument(string const & fname)
1419 string initpath = lyxrc.document_path;
1422 string const trypath = buffer()->filePath();
1423 // If directory is writeable, use this as default.
1424 if (FileName(trypath).isDirWritable())
1430 if (fname.empty()) {
1431 FileDialog dlg(qt_("Select document to open"), LFUN_FILE_OPEN);
1432 dlg.setButton1(qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
1433 dlg.setButton2(qt_("Examples|#E#e"),
1434 toqstr(addPath(package().system_support().absFilename(), "examples")));
1436 QStringList filter(qt_("LyX Documents (*.lyx)"));
1437 filter << qt_("LyX-1.3.x Documents (*.lyx13)")
1438 << qt_("LyX-1.4.x Documents (*.lyx14)")
1439 << qt_("LyX-1.5.x Documents (*.lyx15)")
1440 << qt_("LyX-1.6.x Documents (*.lyx16)");
1441 FileDialog::Result result =
1442 dlg.open(toqstr(initpath), filter);
1444 if (result.first == FileDialog::Later)
1447 filename = fromqstr(result.second);
1449 // check selected filename
1450 if (filename.empty()) {
1451 message(_("Canceled."));
1457 // get absolute path of file and add ".lyx" to the filename if
1459 FileName const fullname =
1460 fileSearch(string(), filename, "lyx", support::may_not_exist);
1461 if (!fullname.empty())
1462 filename = fullname.absFilename();
1464 if (!fullname.onlyPath().isDirectory()) {
1465 Alert::warning(_("Invalid filename"),
1466 bformat(_("The directory in the given path\n%1$s\ndoes not exist."),
1467 from_utf8(fullname.absFilename())));
1470 // if the file doesn't exist, let the user create one
1471 if (!fullname.exists()) {
1472 // the user specifically chose this name. Believe him.
1473 Buffer * const b = newFile(filename, string(), true);
1479 docstring const disp_fn = makeDisplayPath(filename);
1480 message(bformat(_("Opening document %1$s..."), disp_fn));
1483 Buffer * buf = loadDocument(fullname);
1485 buf->updateLabels();
1487 buf->errors("Parse");
1488 str2 = bformat(_("Document %1$s opened."), disp_fn);
1489 if (buf->lyxvc().inUse())
1490 str2 += " " + from_utf8(buf->lyxvc().versionString()) +
1491 " " + _("Version control detected.");
1493 str2 = bformat(_("Could not open document %1$s"), disp_fn);
1498 // FIXME: clean that
1499 static bool import(GuiView * lv, FileName const & filename,
1500 string const & format, ErrorList & errorList)
1502 FileName const lyxfile(support::changeExtension(filename.absFilename(), ".lyx"));
1504 string loader_format;
1505 vector<string> loaders = theConverters().loaders();
1506 if (find(loaders.begin(), loaders.end(), format) == loaders.end()) {
1507 for (vector<string>::const_iterator it = loaders.begin();
1508 it != loaders.end(); ++it) {
1509 if (!theConverters().isReachable(format, *it))
1512 string const tofile =
1513 support::changeExtension(filename.absFilename(),
1514 formats.extension(*it));
1515 if (!theConverters().convert(0, filename, FileName(tofile),
1516 filename, format, *it, errorList))
1518 loader_format = *it;
1521 if (loader_format.empty()) {
1522 frontend::Alert::error(_("Couldn't import file"),
1523 bformat(_("No information for importing the format %1$s."),
1524 formats.prettyName(format)));
1528 loader_format = format;
1530 if (loader_format == "lyx") {
1531 Buffer * buf = lv->loadDocument(lyxfile);
1534 buf->updateLabels();
1536 buf->errors("Parse");
1538 Buffer * const b = newFile(lyxfile.absFilename(), string(), true);
1542 bool as_paragraphs = loader_format == "textparagraph";
1543 string filename2 = (loader_format == format) ? filename.absFilename()
1544 : support::changeExtension(filename.absFilename(),
1545 formats.extension(loader_format));
1546 lv->currentBufferView()->insertPlaintextFile(FileName(filename2),
1548 theLyXFunc().setLyXView(lv);
1549 lyx::dispatch(FuncRequest(LFUN_MARK_OFF));
1556 void GuiView::importDocument(string const & argument)
1559 string filename = split(argument, format, ' ');
1561 LYXERR(Debug::INFO, format << " file: " << filename);
1563 // need user interaction
1564 if (filename.empty()) {
1565 string initpath = lyxrc.document_path;
1567 Buffer const * buf = buffer();
1569 string const trypath = buf->filePath();
1570 // If directory is writeable, use this as default.
1571 if (FileName(trypath).isDirWritable())
1575 docstring const text = bformat(_("Select %1$s file to import"),
1576 formats.prettyName(format));
1578 FileDialog dlg(toqstr(text), LFUN_BUFFER_IMPORT);
1579 dlg.setButton1(qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
1580 dlg.setButton2(qt_("Examples|#E#e"),
1581 toqstr(addPath(package().system_support().absFilename(), "examples")));
1583 docstring filter = formats.prettyName(format);
1586 filter += from_utf8(formats.extension(format));
1589 FileDialog::Result result =
1590 dlg.open(toqstr(initpath), fileFilters(toqstr(filter)));
1592 if (result.first == FileDialog::Later)
1595 filename = fromqstr(result.second);
1597 // check selected filename
1598 if (filename.empty())
1599 message(_("Canceled."));
1602 if (filename.empty())
1605 // get absolute path of file
1606 FileName const fullname(support::makeAbsPath(filename));
1608 FileName const lyxfile(support::changeExtension(fullname.absFilename(), ".lyx"));
1610 // Check if the document already is open
1611 Buffer * buf = theBufferList().getBuffer(lyxfile);
1614 if (!closeBuffer()) {
1615 message(_("Canceled."));
1620 docstring const displaypath = makeDisplayPath(lyxfile.absFilename(), 30);
1622 // if the file exists already, and we didn't do
1623 // -i lyx thefile.lyx, warn
1624 if (lyxfile.exists() && fullname != lyxfile) {
1626 docstring text = bformat(_("The document %1$s already exists.\n\n"
1627 "Do you want to overwrite that document?"), displaypath);
1628 int const ret = Alert::prompt(_("Overwrite document?"),
1629 text, 0, 1, _("&Overwrite"), _("&Cancel"));
1632 message(_("Canceled."));
1637 message(bformat(_("Importing %1$s..."), displaypath));
1638 ErrorList errorList;
1639 if (import(this, fullname, format, errorList))
1640 message(_("imported."));
1642 message(_("file not imported!"));
1644 // FIXME (Abdel 12/08/06): Is there a need to display the error list here?
1648 void GuiView::newDocument(string const & filename, bool from_template)
1650 FileName initpath(lyxrc.document_path);
1651 Buffer * buf = buffer();
1653 FileName const trypath(buf->filePath());
1654 // If directory is writeable, use this as default.
1655 if (trypath.isDirWritable())
1659 string templatefile;
1660 if (from_template) {
1661 templatefile = selectTemplateFile().absFilename();
1662 if (templatefile.empty())
1667 if (filename.empty())
1668 b = newUnnamedFile(templatefile, initpath);
1670 b = newFile(filename, templatefile, true);
1675 // If no new document could be created, it is unsure
1676 // whether there is a valid BufferView.
1677 if (currentBufferView())
1678 // Ensure the cursor is correctly positioned on screen.
1679 currentBufferView()->showCursor();
1683 void GuiView::insertLyXFile(docstring const & fname)
1685 BufferView * bv = documentBufferView();
1690 FileName filename(to_utf8(fname));
1692 if (!filename.empty()) {
1693 bv->insertLyXFile(filename);
1697 // Launch a file browser
1699 string initpath = lyxrc.document_path;
1700 string const trypath = bv->buffer().filePath();
1701 // If directory is writeable, use this as default.
1702 if (FileName(trypath).isDirWritable())
1706 FileDialog dlg(qt_("Select LyX document to insert"), LFUN_FILE_INSERT);
1707 dlg.setButton1(qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
1708 dlg.setButton2(qt_("Examples|#E#e"),
1709 toqstr(addPath(package().system_support().absFilename(),
1712 FileDialog::Result result = dlg.open(toqstr(initpath),
1713 QStringList(qt_("LyX Documents (*.lyx)")));
1715 if (result.first == FileDialog::Later)
1719 filename.set(fromqstr(result.second));
1721 // check selected filename
1722 if (filename.empty()) {
1723 // emit message signal.
1724 message(_("Canceled."));
1728 bv->insertLyXFile(filename);
1732 void GuiView::insertPlaintextFile(docstring const & fname,
1735 BufferView * bv = documentBufferView();
1739 if (!fname.empty() && !FileName::isAbsolute(to_utf8(fname))) {
1740 message(_("Absolute filename expected."));
1745 FileName filename(to_utf8(fname));
1747 if (!filename.empty()) {
1748 bv->insertPlaintextFile(filename, asParagraph);
1752 FileDialog dlg(qt_("Select file to insert"), (asParagraph ?
1753 LFUN_FILE_INSERT_PLAINTEXT_PARA : LFUN_FILE_INSERT_PLAINTEXT));
1755 FileDialog::Result result = dlg.open(toqstr(bv->buffer().filePath()),
1756 QStringList(qt_("All Files (*)")));
1758 if (result.first == FileDialog::Later)
1762 filename.set(fromqstr(result.second));
1764 // check selected filename
1765 if (filename.empty()) {
1766 // emit message signal.
1767 message(_("Canceled."));
1771 bv->insertPlaintextFile(filename, asParagraph);
1775 bool GuiView::renameBuffer(Buffer & b, docstring const & newname)
1777 FileName fname = b.fileName();
1778 FileName const oldname = fname;
1780 if (!newname.empty()) {
1782 fname = support::makeAbsPath(to_utf8(newname), oldname.onlyPath().absFilename());
1784 // Switch to this Buffer.
1787 // No argument? Ask user through dialog.
1789 FileDialog dlg(qt_("Choose a filename to save document as"),
1790 LFUN_BUFFER_WRITE_AS);
1791 dlg.setButton1(qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
1792 dlg.setButton2(qt_("Templates|#T#t"), toqstr(lyxrc.template_path));
1794 if (!isLyXFilename(fname.absFilename()))
1795 fname.changeExtension(".lyx");
1797 FileDialog::Result result =
1798 dlg.save(toqstr(fname.onlyPath().absFilename()),
1799 QStringList(qt_("LyX Documents (*.lyx)")),
1800 toqstr(fname.onlyFileName()));
1802 if (result.first == FileDialog::Later)
1805 fname.set(fromqstr(result.second));
1810 if (!isLyXFilename(fname.absFilename()))
1811 fname.changeExtension(".lyx");
1814 if (FileName(fname).exists()) {
1815 docstring const file = makeDisplayPath(fname.absFilename(), 30);
1816 docstring text = bformat(_("The document %1$s already "
1817 "exists.\n\nDo you want to "
1818 "overwrite that document?"),
1820 int const ret = Alert::prompt(_("Overwrite document?"),
1821 text, 0, 2, _("&Overwrite"), _("&Rename"), _("&Cancel"));
1824 case 1: return renameBuffer(b, docstring());
1825 case 2: return false;
1829 FileName oldauto = b.getAutosaveFilename();
1831 // Ok, change the name of the buffer
1832 b.setFileName(fname.absFilename());
1834 bool unnamed = b.isUnnamed();
1835 b.setUnnamed(false);
1836 b.saveCheckSum(fname);
1838 // bring the autosave file with us, just in case.
1839 b.moveAutosaveFile(oldauto);
1841 if (!saveBuffer(b)) {
1842 oldauto = b.getAutosaveFilename();
1843 b.setFileName(oldname.absFilename());
1844 b.setUnnamed(unnamed);
1845 b.saveCheckSum(oldname);
1846 b.moveAutosaveFile(oldauto);
1854 bool GuiView::saveBuffer(Buffer & b)
1856 if (workArea(b) && workArea(b)->inDialogMode())
1860 return renameBuffer(b, docstring());
1863 theSession().lastFiles().add(b.fileName());
1867 // Switch to this Buffer.
1870 // FIXME: we don't tell the user *WHY* the save failed !!
1871 docstring const file = makeDisplayPath(b.absFileName(), 30);
1872 docstring text = bformat(_("The document %1$s could not be saved.\n\n"
1873 "Do you want to rename the document and "
1874 "try again?"), file);
1875 int const ret = Alert::prompt(_("Rename and save?"),
1876 text, 0, 2, _("&Rename"), _("&Retry"), _("&Cancel"));
1879 if (!renameBuffer(b, docstring()))
1888 return saveBuffer(b);
1892 bool GuiView::hideWorkArea(GuiWorkArea * wa)
1894 return closeWorkArea(wa, false);
1898 bool GuiView::closeWorkArea(GuiWorkArea * wa)
1900 Buffer & buf = wa->bufferView().buffer();
1901 return closeWorkArea(wa, !buf.parent());
1905 bool GuiView::closeBuffer()
1907 GuiWorkArea * wa = currentMainWorkArea();
1908 Buffer & buf = wa->bufferView().buffer();
1909 return wa && closeWorkArea(wa, !buf.parent());
1913 void GuiView::writeSession() const {
1914 GuiWorkArea const * active_wa = currentMainWorkArea();
1915 for (int i = 0; i < d.splitter_->count(); ++i) {
1916 TabWorkArea * twa = d.tabWorkArea(i);
1917 for (int j = 0; j < twa->count(); ++j) {
1918 GuiWorkArea * wa = static_cast<GuiWorkArea *>(twa->widget(j));
1919 Buffer & buf = wa->bufferView().buffer();
1920 theSession().lastOpened().add(buf.fileName(), wa == active_wa);
1926 bool GuiView::closeBufferAll()
1928 // Close the workareas in all other views
1929 QList<int> const ids = guiApp->viewIds();
1930 for (int i = 0; i != ids.size(); ++i) {
1931 if (id_ != ids[i] && !guiApp->view(ids[i]).closeWorkAreaAll())
1935 // Close our own workareas
1936 if (!closeWorkAreaAll())
1939 // Now close the hidden buffers. We prevent hidden buffers from being
1940 // dirty, so we can just close them.
1941 theBufferList().closeAll();
1946 bool GuiView::closeWorkAreaAll()
1948 setCurrentWorkArea(currentMainWorkArea());
1950 // We might be in a situation that there is still a tabWorkArea, but
1951 // there are no tabs anymore. This can happen when we get here after a
1952 // TabWorkArea::lastWorkAreaRemoved() signal. Therefore we count how
1953 // many TabWorkArea's have no documents anymore.
1956 // We have to call count() each time, because it can happen that
1957 // more than one splitter will disappear in one iteration (bug 5998).
1958 for (; d.splitter_->count() > empty_twa; ) {
1959 TabWorkArea * twa = d.tabWorkArea(empty_twa);
1961 if (twa->count() == 0)
1964 setCurrentWorkArea(twa->currentWorkArea());
1965 if (!closeTabWorkArea(twa))
1973 bool GuiView::closeWorkArea(GuiWorkArea * wa, bool close_buffer)
1975 Buffer & buf = wa->bufferView().buffer();
1977 // If we are in a close_event all children will be closed in some time,
1978 // so no need to do it here. This will ensure that the children end up
1979 // in the session file in the correct order. If we close the master
1980 // buffer, we can close or release the child buffers here too.
1981 if (close_buffer && !closing_) {
1982 vector<Buffer *> clist = buf.getChildren();
1983 for (vector<Buffer *>::const_iterator it = clist.begin();
1984 it != clist.end(); ++it) {
1985 // If a child is dirty, do not close
1986 // without user intervention
1987 //FIXME: should we look in other tabworkareas?
1988 Buffer * child_buf = *it;
1989 GuiWorkArea * child_wa = workArea(*child_buf);
1991 if (!closeWorkArea(child_wa, true))
1994 theBufferList().releaseChild(&buf, child_buf);
1997 // goto bookmark to update bookmark pit.
1998 //FIXME: we should update only the bookmarks related to this buffer!
1999 LYXERR(Debug::DEBUG, "GuiView::closeBuffer()");
2000 for (size_t i = 0; i < theSession().bookmarks().size(); ++i)
2001 theLyXFunc().gotoBookmark(i+1, false, false);
2003 // if we are only hiding the buffer and there are multiple views
2004 // of the buffer, then we do not need to ensure a clean buffer.
2005 bool const allow_dirty = inMultiTabs(wa) && !close_buffer;
2007 if (allow_dirty || saveBufferIfNeeded(buf, !close_buffer)) {
2008 // save in sessions if requested
2009 // do not save childs if their master
2010 // is opened as well
2014 theBufferList().release(&buf);
2021 bool GuiView::closeTabWorkArea(TabWorkArea * twa)
2023 while (twa == d.currentTabWorkArea()) {
2024 twa->setCurrentIndex(twa->count()-1);
2026 GuiWorkArea * wa = twa->currentWorkArea();
2027 Buffer & b = wa->bufferView().buffer();
2029 // We only want to close the buffer if the same buffer is not visible
2030 // in another view, and if this is not a child and if we are closing
2031 // a view (not a tabgroup).
2032 bool const close_buffer =
2033 !inMultiViews(wa) && !b.parent() && closing_;
2035 if (!closeWorkArea(wa, close_buffer))
2042 bool GuiView::saveBufferIfNeeded(Buffer & buf, bool hiding)
2044 if (buf.isClean() || buf.paragraphs().empty())
2047 // Switch to this Buffer.
2052 if (buf.isUnnamed())
2053 file = from_utf8(buf.fileName().onlyFileName());
2055 file = buf.fileName().displayName(30);
2057 // Bring this window to top before asking questions.
2062 if (hiding && buf.isUnnamed()) {
2063 docstring const text = bformat(_("The document %1$s has not been "
2064 "saved yet.\n\nDo you want to save "
2065 "the document?"), file);
2066 ret = Alert::prompt(_("Save new document?"),
2067 text, 0, 1, _("&Save"), _("&Cancel"));
2071 docstring const text = bformat(_("The document %1$s has unsaved changes."
2072 "\n\nDo you want to save the document or discard the changes?"), file);
2073 ret = Alert::prompt(_("Save changed document?"),
2074 text, 0, 2, _("&Save"), _("&Discard"), _("&Cancel"));
2079 if (!saveBuffer(buf))
2083 // if we crash after this we could
2084 // have no autosave file but I guess
2085 // this is really improbable (Jug)
2086 buf.removeAutosaveFile();
2088 // revert all changes
2089 buf.loadLyXFile(buf.fileName());
2099 bool GuiView::inMultiTabs(GuiWorkArea * wa)
2101 Buffer & buf = wa->bufferView().buffer();
2103 for (int i = 0; i != d.splitter_->count(); ++i) {
2104 GuiWorkArea * wa_ = d.tabWorkArea(i)->workArea(buf);
2105 if (wa_ && wa_ != wa)
2108 return inMultiViews(wa);
2112 bool GuiView::inMultiViews(GuiWorkArea * wa)
2114 QList<int> const ids = guiApp->viewIds();
2115 Buffer & buf = wa->bufferView().buffer();
2118 for (int i = 0; i != ids.size() && found_twa <= 1; ++i) {
2122 if (guiApp->view(ids[i]).workArea(buf))
2129 void GuiView::gotoNextOrPreviousBuffer(NextOrPrevious np)
2131 Buffer * const curbuf = buffer();
2132 Buffer * nextbuf = curbuf;
2134 if (np == NEXTBUFFER)
2135 nextbuf = theBufferList().next(nextbuf);
2137 nextbuf = theBufferList().previous(nextbuf);
2138 if (nextbuf == curbuf)
2144 if (workArea(*nextbuf))
2151 bool GuiView::dispatch(FuncRequest const & cmd)
2153 BufferView * bv = currentBufferView();
2154 // By default we won't need any update.
2156 bv->cursor().updateFlags(Update::None);
2157 bool dispatched = true;
2159 if (cmd.origin == FuncRequest::TOC) {
2160 GuiToc * toc = static_cast<GuiToc*>(findOrBuild("toc", false));
2161 toc->doDispatch(bv->cursor(), cmd);
2165 switch(cmd.action) {
2166 case LFUN_BUFFER_IMPORT:
2167 importDocument(to_utf8(cmd.argument()));
2170 case LFUN_BUFFER_SWITCH:
2171 if (FileName::isAbsolute(to_utf8(cmd.argument()))) {
2173 theBufferList().getBuffer(FileName(to_utf8(cmd.argument())));
2177 bv->cursor().message(_("Document not loaded"));
2181 case LFUN_BUFFER_NEXT:
2182 gotoNextOrPreviousBuffer(NEXTBUFFER);
2185 case LFUN_BUFFER_PREVIOUS:
2186 gotoNextOrPreviousBuffer(PREVBUFFER);
2189 case LFUN_COMMAND_EXECUTE: {
2190 bool const show_it = cmd.argument() != "off";
2191 // FIXME: this is a hack, "minibuffer" should not be
2193 if (GuiToolbar * t = toolbar("minibuffer")) {
2194 t->setVisible(show_it);
2195 if (show_it && t->commandBuffer())
2196 t->commandBuffer()->setFocus();
2200 case LFUN_DROP_LAYOUTS_CHOICE:
2201 d.layout_->showPopup();
2204 case LFUN_MENU_OPEN:
2205 if (QMenu * menu = guiApp->menus().menu(toqstr(cmd.argument()), *this))
2206 menu->exec(QCursor::pos());
2209 case LFUN_FILE_INSERT:
2210 insertLyXFile(cmd.argument());
2212 case LFUN_FILE_INSERT_PLAINTEXT_PARA:
2213 insertPlaintextFile(cmd.argument(), true);
2216 case LFUN_FILE_INSERT_PLAINTEXT:
2217 insertPlaintextFile(cmd.argument(), false);
2220 case LFUN_BUFFER_WRITE:
2222 saveBuffer(bv->buffer());
2225 case LFUN_BUFFER_WRITE_AS:
2227 renameBuffer(bv->buffer(), cmd.argument());
2230 case LFUN_BUFFER_WRITE_ALL: {
2231 Buffer * first = theBufferList().first();
2234 message(_("Saving all documents..."));
2235 // We cannot use a for loop as the buffer list cycles.
2238 if (!b->isClean()) {
2240 LYXERR(Debug::ACTION, "Saved " << b->absFileName());
2242 b = theBufferList().next(b);
2243 } while (b != first);
2244 message(_("All documents saved."));
2248 case LFUN_TOOLBAR_TOGGLE: {
2249 string const name = cmd.getArg(0);
2250 if (GuiToolbar * t = toolbar(name))
2255 case LFUN_DIALOG_UPDATE: {
2256 string const name = to_utf8(cmd.argument());
2257 // Can only update a dialog connected to an existing inset
2258 Inset * inset = getOpenInset(name);
2260 FuncRequest fr(LFUN_INSET_DIALOG_UPDATE, cmd.argument());
2261 inset->dispatch(currentBufferView()->cursor(), fr);
2262 } else if (name == "paragraph") {
2263 lyx::dispatch(FuncRequest(LFUN_PARAGRAPH_UPDATE));
2264 } else if (name == "prefs" || name == "document") {
2265 updateDialog(name, string());
2270 case LFUN_DIALOG_TOGGLE: {
2271 if (isDialogVisible(cmd.getArg(0)))
2272 dispatch(FuncRequest(LFUN_DIALOG_HIDE, cmd.argument()));
2274 dispatch(FuncRequest(LFUN_DIALOG_SHOW, cmd.argument()));
2278 case LFUN_DIALOG_DISCONNECT_INSET:
2279 disconnectDialog(to_utf8(cmd.argument()));
2282 case LFUN_DIALOG_HIDE: {
2283 guiApp->hideDialogs(to_utf8(cmd.argument()), 0);
2287 case LFUN_DIALOG_SHOW: {
2288 string const name = cmd.getArg(0);
2289 string data = trim(to_utf8(cmd.argument()).substr(name.size()));
2291 if (name == "character") {
2292 data = freefont2string();
2294 showDialog("character", data);
2295 } else if (name == "latexlog") {
2296 Buffer::LogType type;
2297 string const logfile = buffer()->logName(&type);
2299 case Buffer::latexlog:
2302 case Buffer::buildlog:
2306 data += Lexer::quoteString(logfile);
2307 showDialog("log", data);
2308 } else if (name == "vclog") {
2309 string const data = "vc " +
2310 Lexer::quoteString(buffer()->lyxvc().getLogFile());
2311 showDialog("log", data);
2312 } else if (name == "symbols") {
2313 data = bv->cursor().getEncoding()->name();
2315 showDialog("symbols", data);
2317 } else if (name == "prefs" && isFullScreen()) {
2318 FuncRequest fr(LFUN_INSET_INSERT, "fullscreen");
2320 showDialog("prefs", data);
2322 showDialog(name, data);
2326 case LFUN_INSET_APPLY: {
2327 string const name = cmd.getArg(0);
2328 Inset * inset = getOpenInset(name);
2330 // put cursor in front of inset.
2331 if (!currentBufferView()->setCursorFromInset(inset)) {
2332 LASSERT(false, break);
2334 BufferView * bv = currentBufferView();
2335 // useful if we are called from a dialog.
2336 bv->cursor().beginUndoGroup();
2337 bv->cursor().recordUndo();
2338 FuncRequest fr(LFUN_INSET_MODIFY, cmd.argument());
2339 inset->dispatch(bv->cursor(), fr);
2340 bv->cursor().endUndoGroup();
2342 FuncRequest fr(LFUN_INSET_INSERT, cmd.argument());
2348 case LFUN_UI_TOGGLE:
2350 // Make sure the keyboard focus stays in the work area.
2354 case LFUN_SPLIT_VIEW:
2355 if (Buffer * buf = buffer()) {
2356 string const orientation = cmd.getArg(0);
2357 d.splitter_->setOrientation(orientation == "vertical"
2358 ? Qt::Vertical : Qt::Horizontal);
2359 TabWorkArea * twa = addTabWorkArea();
2360 GuiWorkArea * wa = twa->addWorkArea(*buf, *this);
2361 setCurrentWorkArea(wa);
2365 case LFUN_CLOSE_TAB_GROUP:
2366 if (TabWorkArea * twa = d.currentTabWorkArea()) {
2367 closeTabWorkArea(twa);
2368 d.current_work_area_ = 0;
2369 twa = d.currentTabWorkArea();
2370 // Switch to the next GuiWorkArea in the found TabWorkArea.
2372 // Make sure the work area is up to date.
2373 setCurrentWorkArea(twa->currentWorkArea());
2375 setCurrentWorkArea(0);
2380 case LFUN_COMPLETION_INLINE:
2381 if (d.current_work_area_)
2382 d.current_work_area_->completer().showInline();
2385 case LFUN_COMPLETION_POPUP:
2386 if (d.current_work_area_)
2387 d.current_work_area_->completer().showPopup();
2391 case LFUN_COMPLETION_COMPLETE:
2392 if (d.current_work_area_)
2393 d.current_work_area_->completer().tab();
2396 case LFUN_COMPLETION_CANCEL:
2397 if (d.current_work_area_) {
2398 if (d.current_work_area_->completer().popupVisible())
2399 d.current_work_area_->completer().hidePopup();
2401 d.current_work_area_->completer().hideInline();
2405 case LFUN_COMPLETION_ACCEPT:
2406 if (d.current_work_area_)
2407 d.current_work_area_->completer().activate();
2410 case LFUN_BUFFER_ZOOM_IN:
2411 case LFUN_BUFFER_ZOOM_OUT:
2412 if (cmd.argument().empty()) {
2413 if (cmd.action == LFUN_BUFFER_ZOOM_IN)
2418 lyxrc.zoom += convert<int>(cmd.argument());
2420 if (lyxrc.zoom < 10)
2423 // The global QPixmapCache is used in GuiPainter to cache text
2424 // painting so we must reset it.
2425 QPixmapCache::clear();
2426 guiApp->fontLoader().update();
2427 lyx::dispatch(FuncRequest(LFUN_SCREEN_FONT_UPDATE));
2435 // Part of automatic menu appearance feature.
2436 if (isFullScreen()) {
2437 if (menuBar()->isVisible() && lyxrc.full_screen_menubar)
2439 if (statusBar()->isVisible())
2440 statusBar()->hide();
2447 void GuiView::lfunUiToggle(FuncRequest const & cmd)
2449 string const arg = cmd.getArg(0);
2450 if (arg == "scrollbar") {
2451 // hide() is of no help
2452 if (d.current_work_area_->verticalScrollBarPolicy() ==
2453 Qt::ScrollBarAlwaysOff)
2455 d.current_work_area_->setVerticalScrollBarPolicy(
2456 Qt::ScrollBarAsNeeded);
2458 d.current_work_area_->setVerticalScrollBarPolicy(
2459 Qt::ScrollBarAlwaysOff);
2462 if (arg == "statusbar") {
2463 statusBar()->setVisible(!statusBar()->isVisible());
2466 if (arg == "menubar") {
2467 menuBar()->setVisible(!menuBar()->isVisible());
2470 #if QT_VERSION >= 0x040300
2471 if (arg == "frame") {
2473 getContentsMargins(&l, &t, &r, &b);
2474 //are the frames in default state?
2475 d.current_work_area_->setFrameStyle(QFrame::NoFrame);
2477 setContentsMargins(-2, -2, -2, -2);
2479 setContentsMargins(0, 0, 0, 0);
2484 if (arg == "fullscreen") {
2489 message(bformat("LFUN_UI_TOGGLE " + _("%1$s unknown command!"), from_utf8(arg)));
2493 void GuiView::toggleFullScreen()
2495 if (isFullScreen()) {
2496 for (int i = 0; i != d.splitter_->count(); ++i)
2497 d.tabWorkArea(i)->setFullScreen(false);
2498 #if QT_VERSION >= 0x040300
2499 setContentsMargins(0, 0, 0, 0);
2501 setWindowState(windowState() ^ Qt::WindowFullScreen);
2504 statusBar()->show();
2507 hideDialogs("prefs", 0);
2508 for (int i = 0; i != d.splitter_->count(); ++i)
2509 d.tabWorkArea(i)->setFullScreen(true);
2510 #if QT_VERSION >= 0x040300
2511 setContentsMargins(-2, -2, -2, -2);
2514 setWindowState(windowState() ^ Qt::WindowFullScreen);
2515 statusBar()->hide();
2516 if (lyxrc.full_screen_menubar)
2518 if (lyxrc.full_screen_toolbars) {
2519 ToolbarMap::iterator end = d.toolbars_.end();
2520 for (ToolbarMap::iterator it = d.toolbars_.begin(); it != end; ++it)
2525 // give dialogs like the TOC a chance to adapt
2530 Buffer const * GuiView::updateInset(Inset const * inset)
2532 if (!d.current_work_area_)
2536 d.current_work_area_->scheduleRedraw();
2538 return &d.current_work_area_->bufferView().buffer();
2542 void GuiView::restartCursor()
2544 /* When we move around, or type, it's nice to be able to see
2545 * the cursor immediately after the keypress.
2547 if (d.current_work_area_)
2548 d.current_work_area_->startBlinkingCursor();
2550 // Take this occasion to update the other GUI elements.
2556 void GuiView::updateCompletion(Cursor & cur, bool start, bool keep)
2558 if (d.current_work_area_)
2559 d.current_work_area_->completer().updateVisibility(cur, start, keep);
2564 // This list should be kept in sync with the list of insets in
2565 // src/insets/Inset.cpp. I.e., if a dialog goes with an inset, the
2566 // dialog should have the same name as the inset.
2567 // Changes should be also recorded in LFUN_DIALOG_SHOW doxygen
2568 // docs in LyXAction.cpp.
2570 char const * const dialognames[] = {
2571 "aboutlyx", "bibitem", "bibtex", "box", "branch", "changes", "character",
2572 "citation", "document", "errorlist", "ert", "external", "file", "findreplace",
2573 "findreplaceadv", "float", "graphics", "href", "include", "index",
2574 "index_print", "info", "listings", "label", "log", "mathdelimiter",
2575 "mathmatrix", "mathspace", "nomenclature", "nomencl_print", "note",
2576 "paragraph", "phantom", "prefs", "print", "ref", "sendto", "space",
2577 "spellchecker", "symbols", "tabular", "tabularcreate", "thesaurus", "texinfo",
2578 "toc", "view-source", "vspace", "wrap" };
2580 char const * const * const end_dialognames =
2581 dialognames + (sizeof(dialognames) / sizeof(char *));
2585 cmpCStr(char const * name) : name_(name) {}
2586 bool operator()(char const * other) {
2587 return strcmp(other, name_) == 0;
2594 bool isValidName(string const & name)
2596 return find_if(dialognames, end_dialognames,
2597 cmpCStr(name.c_str())) != end_dialognames;
2603 void GuiView::resetDialogs()
2605 // Make sure that no LFUN uses any LyXView.
2606 theLyXFunc().setLyXView(0);
2609 constructToolbars();
2610 guiApp->menus().fillMenuBar(menuBar(), this, false);
2611 d.layout_->updateContents(true);
2612 // Now update controls with current buffer.
2613 theLyXFunc().setLyXView(this);
2619 Dialog * GuiView::findOrBuild(string const & name, bool hide_it)
2621 if (!isValidName(name))
2624 map<string, DialogPtr>::iterator it = d.dialogs_.find(name);
2626 if (it != d.dialogs_.end()) {
2628 it->second->hideView();
2629 return it->second.get();
2632 Dialog * dialog = build(name);
2633 d.dialogs_[name].reset(dialog);
2634 if (lyxrc.allow_geometry_session)
2635 dialog->restoreSession();
2642 void GuiView::showDialog(string const & name, string const & data,
2650 Dialog * dialog = findOrBuild(name, false);
2652 dialog->showData(data);
2654 d.open_insets_[name] = inset;
2657 catch (ExceptionMessage const & ex) {
2665 bool GuiView::isDialogVisible(string const & name) const
2667 map<string, DialogPtr>::const_iterator it = d.dialogs_.find(name);
2668 if (it == d.dialogs_.end())
2670 return it->second.get()->isVisibleView() && !it->second.get()->isClosing();
2674 void GuiView::hideDialog(string const & name, Inset * inset)
2676 map<string, DialogPtr>::const_iterator it = d.dialogs_.find(name);
2677 if (it == d.dialogs_.end())
2680 if (inset && inset != getOpenInset(name))
2683 Dialog * const dialog = it->second.get();
2684 if (dialog->isVisibleView())
2686 d.open_insets_[name] = 0;
2690 void GuiView::disconnectDialog(string const & name)
2692 if (!isValidName(name))
2695 if (d.open_insets_.find(name) != d.open_insets_.end())
2696 d.open_insets_[name] = 0;
2700 Inset * GuiView::getOpenInset(string const & name) const
2702 if (!isValidName(name))
2705 map<string, Inset *>::const_iterator it = d.open_insets_.find(name);
2706 return it == d.open_insets_.end() ? 0 : it->second;
2710 void GuiView::hideAll() const
2712 map<string, DialogPtr>::const_iterator it = d.dialogs_.begin();
2713 map<string, DialogPtr>::const_iterator end = d.dialogs_.end();
2715 for(; it != end; ++it)
2716 it->second->hideView();
2720 void GuiView::updateDialogs()
2722 map<string, DialogPtr>::const_iterator it = d.dialogs_.begin();
2723 map<string, DialogPtr>::const_iterator end = d.dialogs_.end();
2725 for(; it != end; ++it) {
2726 Dialog * dialog = it->second.get();
2727 if (dialog && dialog->isVisibleView())
2728 dialog->checkStatus();
2735 // will be replaced by a proper factory...
2736 Dialog * createGuiAbout(GuiView & lv);
2737 Dialog * createGuiBibitem(GuiView & lv);
2738 Dialog * createGuiBibtex(GuiView & lv);
2739 Dialog * createGuiBox(GuiView & lv);
2740 Dialog * createGuiBranch(GuiView & lv);
2741 Dialog * createGuiChanges(GuiView & lv);
2742 Dialog * createGuiCharacter(GuiView & lv);
2743 Dialog * createGuiCitation(GuiView & lv);
2744 Dialog * createGuiDelimiter(GuiView & lv);
2745 Dialog * createGuiDocument(GuiView & lv);
2746 Dialog * createGuiErrorList(GuiView & lv);
2747 Dialog * createGuiERT(GuiView & lv);
2748 Dialog * createGuiExternal(GuiView & lv);
2749 Dialog * createGuiFloat(GuiView & lv);
2750 Dialog * createGuiGraphics(GuiView & lv);
2751 Dialog * createGuiInclude(GuiView & lv);
2752 Dialog * createGuiIndex(GuiView & lv);
2753 Dialog * createGuiInfo(GuiView & lv);
2754 Dialog * createGuiLabel(GuiView & lv);
2755 Dialog * createGuiListings(GuiView & lv);
2756 Dialog * createGuiLog(GuiView & lv);
2757 Dialog * createGuiMathHSpace(GuiView & lv);
2758 Dialog * createGuiMathMatrix(GuiView & lv);
2759 Dialog * createGuiNomenclature(GuiView & lv);
2760 Dialog * createGuiNote(GuiView & lv);
2761 Dialog * createGuiParagraph(GuiView & lv);
2762 Dialog * createGuiPhantom(GuiView & lv);
2763 Dialog * createGuiPreferences(GuiView & lv);
2764 Dialog * createGuiPrint(GuiView & lv);
2765 Dialog * createGuiPrintindex(GuiView & lv);
2766 Dialog * createGuiPrintNomencl(GuiView & lv);
2767 Dialog * createGuiRef(GuiView & lv);
2768 Dialog * createGuiSearch(GuiView & lv);
2769 Dialog * createGuiSearchAdv(GuiView & lv);
2770 Dialog * createGuiSendTo(GuiView & lv);
2771 Dialog * createGuiShowFile(GuiView & lv);
2772 Dialog * createGuiSpellchecker(GuiView & lv);
2773 Dialog * createGuiSymbols(GuiView & lv);
2774 Dialog * createGuiTabularCreate(GuiView & lv);
2775 Dialog * createGuiTabular(GuiView & lv);
2776 Dialog * createGuiTexInfo(GuiView & lv);
2777 Dialog * createGuiTextHSpace(GuiView & lv);
2778 Dialog * createGuiToc(GuiView & lv);
2779 Dialog * createGuiThesaurus(GuiView & lv);
2780 Dialog * createGuiHyperlink(GuiView & lv);
2781 Dialog * createGuiVSpace(GuiView & lv);
2782 Dialog * createGuiViewSource(GuiView & lv);
2783 Dialog * createGuiWrap(GuiView & lv);
2786 Dialog * GuiView::build(string const & name)
2788 LASSERT(isValidName(name), return 0);
2790 if (name == "aboutlyx")
2791 return createGuiAbout(*this);
2792 if (name == "bibitem")
2793 return createGuiBibitem(*this);
2794 if (name == "bibtex")
2795 return createGuiBibtex(*this);
2797 return createGuiBox(*this);
2798 if (name == "branch")
2799 return createGuiBranch(*this);
2800 if (name == "changes")
2801 return createGuiChanges(*this);
2802 if (name == "character")
2803 return createGuiCharacter(*this);
2804 if (name == "citation")
2805 return createGuiCitation(*this);
2806 if (name == "document")
2807 return createGuiDocument(*this);
2808 if (name == "errorlist")
2809 return createGuiErrorList(*this);
2811 return createGuiERT(*this);
2812 if (name == "external")
2813 return createGuiExternal(*this);
2815 return createGuiShowFile(*this);
2816 if (name == "findreplace")
2817 return createGuiSearch(*this);
2818 if (name == "findreplaceadv")
2819 return createGuiSearchAdv(*this);
2820 if (name == "float")
2821 return createGuiFloat(*this);
2822 if (name == "graphics")
2823 return createGuiGraphics(*this);
2825 return createGuiHyperlink(*this);
2826 if (name == "include")
2827 return createGuiInclude(*this);
2828 if (name == "index")
2829 return createGuiIndex(*this);
2830 if (name == "index_print")
2831 return createGuiPrintindex(*this);
2833 return createGuiInfo(*this);
2834 if (name == "label")
2835 return createGuiLabel(*this);
2836 if (name == "listings")
2837 return createGuiListings(*this);
2839 return createGuiLog(*this);
2840 if (name == "mathdelimiter")
2841 return createGuiDelimiter(*this);
2842 if (name == "mathspace")
2843 return createGuiMathHSpace(*this);
2844 if (name == "mathmatrix")
2845 return createGuiMathMatrix(*this);
2846 if (name == "nomenclature")
2847 return createGuiNomenclature(*this);
2848 if (name == "nomencl_print")
2849 return createGuiPrintNomencl(*this);
2851 return createGuiNote(*this);
2852 if (name == "paragraph")
2853 return createGuiParagraph(*this);
2854 if (name == "phantom")
2855 return createGuiPhantom(*this);
2856 if (name == "prefs")
2857 return createGuiPreferences(*this);
2858 if (name == "print")
2859 return createGuiPrint(*this);
2861 return createGuiRef(*this);
2862 if (name == "sendto")
2863 return createGuiSendTo(*this);
2864 if (name == "space")
2865 return createGuiTextHSpace(*this);
2866 if (name == "spellchecker")
2867 return createGuiSpellchecker(*this);
2868 if (name == "symbols")
2869 return createGuiSymbols(*this);
2870 if (name == "tabular")
2871 return createGuiTabular(*this);
2872 if (name == "tabularcreate")
2873 return createGuiTabularCreate(*this);
2874 if (name == "texinfo")
2875 return createGuiTexInfo(*this);
2876 if (name == "thesaurus")
2877 return createGuiThesaurus(*this);
2879 return createGuiToc(*this);
2880 if (name == "view-source")
2881 return createGuiViewSource(*this);
2882 if (name == "vspace")
2883 return createGuiVSpace(*this);
2885 return createGuiWrap(*this);
2891 } // namespace frontend
2894 #include "moc_GuiView.cpp"