2006-03-05 17:24:44 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/**
|
2006-06-20 09:33:01 +00:00
|
|
|
* \file GuiView.h
|
2006-03-05 17:24:44 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author Lars Gullik Bjornes
|
|
|
|
* \author John Levon
|
|
|
|
* \author Abdelrazak Younes
|
2008-11-14 15:58:50 +00:00
|
|
|
* \author Peter Kümmel
|
2006-03-05 17:24:44 +00:00
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
2006-06-26 16:55:35 +00:00
|
|
|
#ifndef GUI_VIEW_H
|
|
|
|
#define GUI_VIEW_H
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2007-11-27 08:24:56 +00:00
|
|
|
#include "frontends/Delegates.h"
|
2006-03-05 17:24:44 +00:00
|
|
|
#include "frontends/LyXView.h"
|
|
|
|
|
2007-11-22 23:29:53 +00:00
|
|
|
#include "support/strfwd.h"
|
2007-11-18 00:01:14 +00:00
|
|
|
|
2007-08-14 13:20:16 +00:00
|
|
|
#include <QMainWindow>
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2007-11-12 23:23:19 +00:00
|
|
|
class QCloseEvent;
|
2007-08-14 13:20:16 +00:00
|
|
|
class QDragEnterEvent;
|
|
|
|
class QDropEvent;
|
2006-11-08 23:10:46 +00:00
|
|
|
class QMenu;
|
2007-11-15 12:58:44 +00:00
|
|
|
class QShowEvent;
|
2007-11-12 23:23:19 +00:00
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
namespace lyx {
|
2007-11-12 23:23:19 +00:00
|
|
|
|
2008-02-29 09:18:46 +00:00
|
|
|
class Cursor;
|
2007-11-12 23:23:19 +00:00
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
namespace frontend {
|
|
|
|
|
2007-11-18 23:49:52 +00:00
|
|
|
class Dialog;
|
2009-08-12 21:51:10 +00:00
|
|
|
class LayoutBox;
|
2007-10-01 20:45:50 +00:00
|
|
|
class GuiToolbar;
|
2007-10-06 15:48:58 +00:00
|
|
|
class GuiWorkArea;
|
2008-02-20 21:46:49 +00:00
|
|
|
class TabWorkArea;
|
2008-05-02 12:09:51 +00:00
|
|
|
class TocModels;
|
2008-05-25 08:30:06 +00:00
|
|
|
class ToolbarInfo;
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
/**
|
2006-06-20 09:33:01 +00:00
|
|
|
* GuiView - Qt4 implementation of LyXView
|
2006-03-05 17:24:44 +00:00
|
|
|
*
|
2006-06-26 16:55:35 +00:00
|
|
|
* qt4-private implementation of the main LyX window.
|
2006-10-24 15:01:07 +00:00
|
|
|
*
|
2007-08-31 05:53:55 +00:00
|
|
|
* Note: a QObject emits a destroyed(QObject *) Qt signal when it
|
|
|
|
* is deleted. This might be useful for closing other dialogs
|
|
|
|
* depending on a given GuiView.
|
2006-03-05 17:24:44 +00:00
|
|
|
*/
|
2007-11-21 22:48:13 +00:00
|
|
|
class GuiView : public QMainWindow, public LyXView, public GuiBufferViewDelegate,
|
|
|
|
public GuiBufferDelegate
|
2007-09-05 20:33:29 +00:00
|
|
|
{
|
2006-03-05 17:24:44 +00:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2006-06-26 16:55:35 +00:00
|
|
|
/// create a main window of the given dimensions
|
2007-11-05 13:52:37 +00:00
|
|
|
GuiView(int id);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2007-11-05 13:52:37 +00:00
|
|
|
~GuiView();
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2009-09-05 14:29:11 +00:00
|
|
|
/// LyXView inherited methods.
|
|
|
|
///@{
|
2009-09-05 14:48:36 +00:00
|
|
|
int id() const { return id_; };
|
2007-11-18 23:30:41 +00:00
|
|
|
void setBusy(bool);
|
2009-09-05 14:29:11 +00:00
|
|
|
BufferView * currentBufferView();
|
|
|
|
BufferView const * currentBufferView() const;
|
|
|
|
BufferView * documentBufferView();
|
|
|
|
BufferView const * documentBufferView() const;
|
|
|
|
void newDocument(std::string const & filename,
|
|
|
|
bool fromTemplate);
|
|
|
|
void message(docstring const &);
|
|
|
|
bool getStatus(FuncRequest const & cmd, FuncStatus & flag);
|
|
|
|
bool dispatch(FuncRequest const & cmd);
|
|
|
|
void restartCursor();
|
|
|
|
void updateCompletion(Cursor & cur, bool start, bool keep);
|
|
|
|
void setFocus();
|
|
|
|
///@}
|
2007-11-15 12:58:44 +00:00
|
|
|
|
2009-10-05 21:32:20 +00:00
|
|
|
/// set a buffer to the current workarea.
|
|
|
|
void setBuffer(Buffer * b); ///< \c Buffer to set.
|
|
|
|
|
|
|
|
/// load a document into the current workarea.
|
|
|
|
Buffer * loadDocument(
|
|
|
|
support::FileName const & name, ///< File to load.
|
|
|
|
bool tolastfiles = true ///< append to the "Open recent" menu?
|
|
|
|
);
|
|
|
|
|
2007-01-31 02:39:46 +00:00
|
|
|
/// add toolbar, if newline==true, add a toolbar break before the toolbar
|
2007-10-01 20:45:50 +00:00
|
|
|
GuiToolbar * makeToolbar(ToolbarInfo const & tbinfo, bool newline);
|
2009-09-05 14:29:11 +00:00
|
|
|
void updateStatusBar();
|
2007-11-20 22:03:56 +00:00
|
|
|
|
|
|
|
/// updates the possible layouts selectable
|
|
|
|
void updateLayoutList();
|
2007-10-01 20:45:50 +00:00
|
|
|
void updateToolbars();
|
2007-11-12 23:23:19 +00:00
|
|
|
QMenu * createPopupMenu();
|
|
|
|
|
2007-11-20 22:03:56 +00:00
|
|
|
///
|
2009-08-14 22:58:57 +00:00
|
|
|
LayoutBox * getLayoutDialog() const;
|
2007-11-20 22:03:56 +00:00
|
|
|
|
2009-08-15 14:07:05 +00:00
|
|
|
/// hides the workarea and makes sure it is clean
|
|
|
|
bool hideWorkArea(GuiWorkArea * wa);
|
2009-08-17 22:33:49 +00:00
|
|
|
/// closes the workarea
|
|
|
|
bool closeWorkArea(GuiWorkArea * wa);
|
2009-10-29 23:22:50 +00:00
|
|
|
/// closes the buffer
|
|
|
|
bool closeBuffer(Buffer & buf);
|
2008-02-06 23:02:57 +00:00
|
|
|
///
|
|
|
|
void openDocument(std::string const & filename);
|
2007-12-07 11:57:13 +00:00
|
|
|
///
|
2008-02-06 23:54:13 +00:00
|
|
|
void importDocument(std::string const &);
|
2007-11-12 23:23:19 +00:00
|
|
|
|
2007-11-13 14:04:32 +00:00
|
|
|
/// GuiBufferDelegate.
|
|
|
|
///@{
|
|
|
|
void resetAutosaveTimers();
|
2009-06-21 12:26:41 +00:00
|
|
|
void errors(std::string const &, bool from_master = false);
|
2008-04-28 04:57:31 +00:00
|
|
|
void structureChanged();
|
2008-09-30 09:50:54 +00:00
|
|
|
void updateTocItem(std::string const &, DocIterator const &);
|
2007-11-13 14:04:32 +00:00
|
|
|
///@}
|
2008-05-02 12:09:51 +00:00
|
|
|
|
|
|
|
///
|
|
|
|
TocModels & tocModels();
|
2007-11-13 14:04:32 +00:00
|
|
|
|
|
|
|
/// called on timeout
|
|
|
|
void autoSave();
|
2007-11-11 22:30:21 +00:00
|
|
|
|
2009-11-24 18:47:43 +00:00
|
|
|
/// check for external change of any opened buffer, mainly for svn usage
|
|
|
|
void checkExternallyModifiedBuffers();
|
|
|
|
|
2007-11-13 14:04:32 +00:00
|
|
|
/** redraw \c inset in all the BufferViews in which it is currently
|
|
|
|
* visible. If successful return a pointer to the owning Buffer.
|
|
|
|
*/
|
|
|
|
Buffer const * updateInset(Inset const *);
|
2006-06-21 10:30:32 +00:00
|
|
|
|
2007-08-21 07:33:46 +00:00
|
|
|
/// \return the \c Workarea associated to \p Buffer
|
|
|
|
/// \retval 0 if no \c WorkArea is found.
|
2007-11-13 09:52:28 +00:00
|
|
|
GuiWorkArea * workArea(Buffer & buffer);
|
2007-08-21 07:33:46 +00:00
|
|
|
|
|
|
|
/// Add a \c WorkArea
|
|
|
|
/// \return the \c Workarea associated to \p Buffer
|
|
|
|
/// \retval 0 if no \c WorkArea is found.
|
2007-11-13 09:52:28 +00:00
|
|
|
GuiWorkArea * addWorkArea(Buffer & buffer);
|
2009-08-22 16:16:56 +00:00
|
|
|
/// \param work_area The current \c WorkArea, or \c NULL
|
2007-11-13 09:52:28 +00:00
|
|
|
void setCurrentWorkArea(GuiWorkArea * work_area);
|
2007-11-12 23:23:19 +00:00
|
|
|
///
|
2007-11-13 09:52:28 +00:00
|
|
|
void removeWorkArea(GuiWorkArea * work_area);
|
|
|
|
/// return the current WorkArea (the one that has the focus).
|
|
|
|
GuiWorkArea const * currentWorkArea() const;
|
2008-11-16 01:20:34 +00:00
|
|
|
/// return the current WorkArea (the one that has the focus).
|
|
|
|
GuiWorkArea * currentWorkArea();
|
|
|
|
|
|
|
|
/// return the current document WorkArea (it may not have the focus).
|
|
|
|
GuiWorkArea const * currentMainWorkArea() const;
|
|
|
|
/// return the current document WorkArea (it may not have the focus).
|
|
|
|
GuiWorkArea * currentMainWorkArea();
|
2007-11-13 09:52:28 +00:00
|
|
|
|
2007-11-13 14:04:32 +00:00
|
|
|
Q_SIGNALS:
|
|
|
|
void closing(int);
|
2007-11-13 09:52:28 +00:00
|
|
|
|
2007-11-13 14:04:32 +00:00
|
|
|
public Q_SLOTS:
|
|
|
|
/// idle timeout.
|
|
|
|
/// clear any temporary message and replace with current status.
|
|
|
|
void clearMessage();
|
|
|
|
|
|
|
|
private Q_SLOTS:
|
|
|
|
///
|
|
|
|
void updateWindowTitle(GuiWorkArea * wa);
|
2008-08-11 12:57:02 +00:00
|
|
|
///
|
|
|
|
void resetWindowTitleAndIconText();
|
2007-11-13 14:04:32 +00:00
|
|
|
|
|
|
|
///
|
|
|
|
void on_currentWorkAreaChanged(GuiWorkArea *);
|
2008-03-14 23:24:59 +00:00
|
|
|
///
|
|
|
|
void on_lastWorkAreaRemoved();
|
2007-11-13 14:04:32 +00:00
|
|
|
|
|
|
|
/// slots to change the icon size
|
|
|
|
void smallSizedIcons();
|
|
|
|
void normalSizedIcons();
|
|
|
|
void bigSizedIcons();
|
|
|
|
|
2009-12-13 21:00:46 +00:00
|
|
|
/// For completion of Buffer autosave thread.
|
|
|
|
void autoSaveFinished();
|
|
|
|
|
2007-11-13 14:04:32 +00:00
|
|
|
private:
|
2009-09-19 16:49:31 +00:00
|
|
|
/// Open given child document in current buffer directory.
|
|
|
|
void openChildDocument(std::string const & filename);
|
2009-09-19 16:14:03 +00:00
|
|
|
/// Close current document buffer.
|
|
|
|
bool closeBuffer();
|
|
|
|
/// Close all document buffers.
|
|
|
|
bool closeBufferAll();
|
2007-11-13 14:04:32 +00:00
|
|
|
///
|
2008-02-20 21:46:49 +00:00
|
|
|
TabWorkArea * addTabWorkArea();
|
2007-11-13 09:52:28 +00:00
|
|
|
|
|
|
|
/// connect to signals in the given BufferView
|
2007-11-12 23:23:19 +00:00
|
|
|
void connectBufferView(BufferView & bv);
|
2007-11-13 09:52:28 +00:00
|
|
|
/// disconnect from signals in the given BufferView
|
2007-11-12 23:23:19 +00:00
|
|
|
void disconnectBufferView();
|
2007-11-13 09:52:28 +00:00
|
|
|
/// connect to signals in the given buffer
|
|
|
|
void connectBuffer(Buffer & buf);
|
|
|
|
/// disconnect from signals in the given buffer
|
|
|
|
void disconnectBuffer();
|
2007-11-12 23:23:19 +00:00
|
|
|
///
|
2007-08-14 13:14:47 +00:00
|
|
|
void dragEnterEvent(QDragEnterEvent * ev);
|
|
|
|
///
|
|
|
|
void dropEvent(QDropEvent * ev);
|
2007-11-13 14:04:32 +00:00
|
|
|
/// make sure we quit cleanly
|
2007-11-15 12:58:44 +00:00
|
|
|
void closeEvent(QCloseEvent * e);
|
2007-11-13 14:04:32 +00:00
|
|
|
///
|
2007-11-15 12:58:44 +00:00
|
|
|
void showEvent(QShowEvent *);
|
2007-08-14 13:14:47 +00:00
|
|
|
|
2006-12-20 21:28:05 +00:00
|
|
|
/// in order to catch Tab key press.
|
|
|
|
bool event(QEvent * e);
|
2006-12-22 16:13:19 +00:00
|
|
|
bool focusNextPrevChild(bool);
|
2007-11-12 22:15:51 +00:00
|
|
|
|
2009-09-23 13:45:58 +00:00
|
|
|
///
|
|
|
|
bool goToFileRow(std::string const & argument);
|
|
|
|
|
2007-11-12 22:15:51 +00:00
|
|
|
///
|
|
|
|
struct GuiViewPrivate;
|
|
|
|
GuiViewPrivate & d;
|
2006-12-20 21:28:05 +00:00
|
|
|
|
2007-11-18 00:01:14 +00:00
|
|
|
public:
|
|
|
|
///
|
2007-11-12 23:23:19 +00:00
|
|
|
/// dialogs for this view
|
2007-11-18 00:01:14 +00:00
|
|
|
///
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2007-11-21 15:12:47 +00:00
|
|
|
///
|
|
|
|
void resetDialogs();
|
|
|
|
|
2008-05-02 20:58:25 +00:00
|
|
|
/// Hide all visible dialogs
|
|
|
|
void hideAll() const;
|
|
|
|
|
|
|
|
/// Update all visible dialogs.
|
|
|
|
/**
|
|
|
|
* Check the status of all visible dialogs and disable or reenable
|
2007-11-18 00:01:14 +00:00
|
|
|
* them as appropriate.
|
|
|
|
*
|
|
|
|
* Disabling is needed for example when a dialog is open and the
|
|
|
|
* cursor moves to a position where the corresponding inset is not
|
|
|
|
* allowed.
|
|
|
|
*/
|
2008-04-27 22:24:20 +00:00
|
|
|
void updateDialogs();
|
2007-11-18 00:01:14 +00:00
|
|
|
|
|
|
|
/** \param name == "bibtex", "citation" etc; an identifier used to
|
|
|
|
launch a particular dialog.
|
|
|
|
\param data is a string representation of the Inset contents.
|
|
|
|
It is often little more than the output from Inset::write.
|
|
|
|
It is passed to, and parsed by, the frontend dialog.
|
|
|
|
Several of these dialogs do not need any data,
|
|
|
|
so it defaults to string().
|
|
|
|
\param inset ownership is _not_ passed to the frontend dialog.
|
|
|
|
It is stored internally and used by the kernel to ascertain
|
|
|
|
what to do with the FuncRequest dispatched from the frontend
|
|
|
|
dialog on 'Apply'; should it be used to create a new inset at
|
|
|
|
the current cursor position or modify an existing, 'open' inset?
|
|
|
|
*/
|
|
|
|
void showDialog(std::string const & name,
|
2007-11-18 00:39:15 +00:00
|
|
|
std::string const & data, Inset * inset = 0);
|
2007-11-18 00:01:14 +00:00
|
|
|
|
|
|
|
/** \param name == "citation", "bibtex" etc; an identifier used
|
2008-05-02 21:38:23 +00:00
|
|
|
to reset the contents of a particular dialog with \param data.
|
2007-11-18 00:01:14 +00:00
|
|
|
See the comments to 'show', above.
|
|
|
|
*/
|
|
|
|
void updateDialog(std::string const & name, std::string const & data);
|
|
|
|
|
|
|
|
/** All Dialogs of the given \param name will be closed if they are
|
|
|
|
connected to the given \param inset.
|
|
|
|
*/
|
|
|
|
void hideDialog(std::string const & name, Inset * inset);
|
|
|
|
///
|
|
|
|
void disconnectDialog(std::string const & name);
|
2007-11-23 09:44:02 +00:00
|
|
|
|
|
|
|
private:
|
2008-05-27 13:16:50 +00:00
|
|
|
///
|
|
|
|
void saveLayout() const;
|
|
|
|
///
|
2008-06-19 17:30:30 +00:00
|
|
|
bool restoreLayout();
|
2008-05-27 11:15:17 +00:00
|
|
|
///
|
|
|
|
GuiToolbar * toolbar(std::string const & name);
|
|
|
|
///
|
|
|
|
void constructToolbars();
|
|
|
|
///
|
|
|
|
void initToolbars();
|
2008-02-09 17:54:28 +00:00
|
|
|
///
|
|
|
|
void lfunUiToggle(FuncRequest const & cmd);
|
2008-05-27 12:01:50 +00:00
|
|
|
///
|
|
|
|
void toggleFullScreen();
|
2007-12-02 17:50:08 +00:00
|
|
|
///
|
|
|
|
void insertLyXFile(docstring const & fname);
|
2007-11-18 00:01:14 +00:00
|
|
|
///
|
2007-12-02 20:05:17 +00:00
|
|
|
void insertPlaintextFile(docstring const & fname,
|
|
|
|
bool asParagraph);
|
2007-12-04 22:21:25 +00:00
|
|
|
|
|
|
|
/// Save a buffer as a new file.
|
|
|
|
/**
|
|
|
|
Write a buffer to a new file name and rename the buffer
|
|
|
|
according to the new file name.
|
|
|
|
|
|
|
|
This function is e.g. used by menu callbacks and
|
|
|
|
LFUN_BUFFER_WRITE_AS.
|
|
|
|
|
|
|
|
If 'newname' is empty, the user is asked via a
|
|
|
|
dialog for the buffer's new name and location.
|
|
|
|
|
|
|
|
If 'newname' is non-empty and has an absolute path, that is used.
|
|
|
|
Otherwise the base directory of the buffer is used as the base
|
|
|
|
for any relative path in 'newname'.
|
|
|
|
*/
|
|
|
|
bool renameBuffer(Buffer & b, docstring const & newname);
|
|
|
|
///
|
|
|
|
bool saveBuffer(Buffer & b);
|
2009-08-18 20:48:15 +00:00
|
|
|
/// closes a workarea, if close_buffer is true the buffer will
|
|
|
|
/// also be released, otherwise the buffer will be hidden.
|
2009-08-21 20:29:40 +00:00
|
|
|
bool closeWorkArea(GuiWorkArea * wa, bool close_buffer);
|
2009-08-18 20:48:15 +00:00
|
|
|
/// closes the tabworkarea and all tabs. If we are in a close event,
|
|
|
|
/// all buffers will be closed, otherwise they will be hidden.
|
2009-08-21 20:29:40 +00:00
|
|
|
bool closeTabWorkArea(TabWorkArea * twa);
|
2009-08-14 23:12:21 +00:00
|
|
|
/// gives the user the possibility to save his work
|
|
|
|
/// or to discard the changes. If hiding is true, the
|
|
|
|
/// document will be reloaded.
|
|
|
|
bool saveBufferIfNeeded(Buffer & buf, bool hiding);
|
2009-08-18 20:48:15 +00:00
|
|
|
/// closes all workareas
|
|
|
|
bool closeWorkAreaAll();
|
2009-08-19 20:06:57 +00:00
|
|
|
/// write all open workareas into the session file
|
|
|
|
void writeSession() const;
|
2009-08-15 21:46:39 +00:00
|
|
|
/// is the buffer in this workarea also shown in another tab ?
|
|
|
|
/// This tab can either be in the same view or in another one.
|
|
|
|
bool inMultiTabs(GuiWorkArea * wa);
|
2009-08-15 18:13:21 +00:00
|
|
|
/// is the buffer in this workarea also shown in another view ?
|
|
|
|
bool inMultiViews(GuiWorkArea * wa);
|
2009-08-06 23:17:16 +00:00
|
|
|
///
|
2009-03-25 14:34:42 +00:00
|
|
|
enum NextOrPrevious {
|
|
|
|
NEXTBUFFER,
|
|
|
|
PREVBUFFER
|
|
|
|
};
|
|
|
|
///
|
|
|
|
void gotoNextOrPreviousBuffer(NextOrPrevious np);
|
2007-12-04 22:21:25 +00:00
|
|
|
|
2007-11-19 20:56:05 +00:00
|
|
|
/// Is the dialog currently visible?
|
|
|
|
bool isDialogVisible(std::string const & name) const;
|
2007-11-18 00:01:14 +00:00
|
|
|
///
|
2008-06-25 07:23:30 +00:00
|
|
|
Dialog * findOrBuild(std::string const & name, bool hide_it);
|
2007-11-18 00:01:14 +00:00
|
|
|
///
|
|
|
|
Dialog * build(std::string const & name);
|
2009-09-12 20:41:24 +00:00
|
|
|
///
|
|
|
|
void reloadBuffer();
|
2009-11-24 18:47:43 +00:00
|
|
|
void reloadBuffer(Buffer * buf);
|
2009-09-12 20:41:24 +00:00
|
|
|
///
|
|
|
|
void dispatchVC(FuncRequest const & cmd);
|
2009-09-30 07:40:27 +00:00
|
|
|
///
|
|
|
|
void showMessage();
|
2007-11-18 00:01:14 +00:00
|
|
|
|
2007-11-18 23:30:41 +00:00
|
|
|
/// This view ID.
|
|
|
|
int id_;
|
2008-06-19 15:39:15 +00:00
|
|
|
|
|
|
|
/// flag to avoid two concurrent close events.
|
|
|
|
bool closing_;
|
2007-11-18 00:01:14 +00:00
|
|
|
};
|
2007-10-06 15:48:58 +00:00
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|
|
|
|
|
2006-06-20 09:33:01 +00:00
|
|
|
#endif // GUIVIEW_H
|