if (!pimpl_->files_to_load_.empty()) {
for_each(pimpl_->files_to_load_.begin(),
pimpl_->files_to_load_.end(),
- bind(&LyXView::loadLyXFile, view, _1, true));
+ bind(&LyXFunc::loadAndViewFile, pimpl_->lyxfunc_, _1, true));
// clear this list to save a few bytes of RAM
pimpl_->files_to_load_.clear();
pimpl_->session_->lastOpened().clear();
// last session, and should be already there (regular files), or should
// not be added at all (help files).
for_each(lastopened.begin(), lastopened.end(),
- bind(&LyXView::loadLyXFile, view, _1, false));
+ bind(&LyXFunc::loadAndViewFile, pimpl_->lyxfunc_, _1, false));
// clear this list to save a few bytes of RAM
pimpl_->session_->lastOpened().clear();
#include "support/environment.h"
#include "support/FileFilterList.h"
+#include "support/FileName.h"
#include "support/filetools.h"
#include "support/lstrings.h"
#include "support/Path.h"
if (loader_format == "lyx") {
- Buffer * buf = lv->loadLyXFile(lyxfile);
+ Buffer * buf = theLyXFunc().loadAndViewFile(lyxfile);
if (!buf) {
// we are done
lv->message(_("file not imported!"));
}
lyx_view_->message(bformat(_("Opening help file %1$s..."),
makeDisplayPath(fname.absFilename())));
- Buffer * buf = lyx_view_->loadLyXFile(fname, false);
+ Buffer * buf = loadAndViewFile(fname, false);
if (buf) {
updateLabels(*buf);
lyx_view_->setBuffer(buf);
if (theBufferList().exists(s.absFilename()))
buf = theBufferList().getBuffer(s.absFilename());
else {
- buf = lyx_view_->loadLyXFile(s);
+ buf = loadAndViewFile(s);
loaded = true;
}
}
} else {
setMessage(bformat(_("Opening child document %1$s..."),
makeDisplayPath(filename.absFilename())));
- child = lyx_view_->loadLyXFile(filename, true);
+ child = loadAndViewFile(filename, true);
parsed = true;
}
if (child) {
}
+Buffer * LyXFunc::loadAndViewFile(FileName const & filename, bool tolastfiles)
+{
+ lyx_view_->setBusy(true);
+
+ Buffer * newBuffer = checkAndLoadLyXFile(filename);
+
+ if (!newBuffer) {
+ lyx_view_->message(_("Document not loaded."));
+ lyx_view_->updateStatusBar();
+ lyx_view_->setBusy(false);
+ return 0;
+ }
+
+ lyx_view_->setBuffer(newBuffer);
+
+ // scroll to the position when the file was last closed
+ if (lyxrc.use_lastfilepos) {
+ LastFilePosSection::FilePos filepos =
+ LyX::ref().session().lastFilePos().load(filename);
+ lyx_view_->view()->moveToPosition(filepos.pit, filepos.pos, 0, 0);
+ }
+
+ if (tolastfiles)
+ LyX::ref().session().lastFiles().add(filename);
+
+ lyx_view_->setBusy(false);
+ return newBuffer;
+}
+
+
void LyXFunc::open(string const & fname)
{
string initpath = lyxrc.document_path;
lyx_view_->message(bformat(_("Opening document %1$s..."), disp_fn));
docstring str2;
- Buffer * buf = lyx_view_->loadLyXFile(fullname);
+ Buffer * buf = loadAndViewFile(fullname);
if (buf) {
updateLabels(*buf);
lyx_view_->setBuffer(buf);
docstring const disp_fn = makeDisplayPath(filename.absFilename());
docstring str;
closeBuffer();
- Buffer * buf = lyx_view_->loadLyXFile(filename);
+ Buffer * buf = loadAndViewFile(filename);
if (buf) {
updateLabels(*buf);
lyx_view_->setBuffer(buf);
class KeySymbol;
class Text;
+namespace support {
+class FileName;
+}
+
namespace frontend {
class LyXView;
}
/// not the current buffer
void gotoBookmark(unsigned int idx, bool openFile, bool switchToBuffer);
+ /// load a buffer into the current workarea.
+ Buffer * loadAndViewFile(support::FileName const & name, ///< File to load.
+ bool tolastfiles = true); ///< append to the "Open recent" menu?
+
private:
///
BufferView * view() const;
//@}
- /// load a buffer into the current workarea.
- virtual Buffer * loadLyXFile(support::FileName const & name, ///< File to load.
- bool tolastfiles = true) = 0; ///< append to the "Open recent" menu?
-
/// updates the possible layouts selectable
virtual void updateLayoutChoice(bool force) = 0;
/// update the toolbar
#include "qt_helpers.h"
-#include "support/filetools.h"
-#include "support/convert.h"
-#include "support/lstrings.h"
-#include "support/os.h"
-
#include "buffer_funcs.h"
#include "Buffer.h"
#include "BufferList.h"
#include "ToolbarBackend.h"
#include "version.h"
+#include "support/convert.h"
#include "support/lstrings.h"
-#include "support/filetools.h" // OnlyFilename()
+#include "support/os.h"
#include "support/Timeout.h"
#include <QAction>
namespace frontend {
using support::bformat;
-using support::FileName;
-using support::makeDisplayPath;
-using support::onlyFilename;
namespace {
}
-Buffer * GuiView::loadLyXFile(FileName const & filename, bool tolastfiles)
-{
- setBusy(true);
-
- Buffer * newBuffer = checkAndLoadLyXFile(filename);
-
- if (!newBuffer) {
- message(_("Document not loaded."));
- updateStatusBar();
- setBusy(false);
- return 0;
- }
-
- GuiWorkArea * wa = workArea(*newBuffer);
- if (wa == 0)
- wa = addWorkArea(*newBuffer);
-
- // scroll to the position when the file was last closed
- if (lyxrc.use_lastfilepos) {
- LastFilePosSection::FilePos filepos =
- LyX::ref().session().lastFilePos().load(filename);
- // if successfully move to pit (returned par_id is not zero),
- // update metrics and reset font
- wa->bufferView().moveToPosition(filepos.pit, filepos.pos, 0, 0);
- }
-
- if (tolastfiles)
- LyX::ref().session().lastFiles().add(filename);
-
- setBusy(false);
- return newBuffer;
-}
-
-
void GuiView::connectBuffer(Buffer & buf)
{
buf.setGuiDelegate(this);
/// \return the current buffer view.
BufferView * view();
- /// load a buffer into the current workarea.
- Buffer * loadLyXFile(support::FileName const & name, ///< File to load.
- bool tolastfiles = true); ///< append to the "Open recent" menu?
-
/** redraw \c inset in all the BufferViews in which it is currently
* visible. If successful return a pointer to the owning Buffer.
*/
{
GuiWorkArea * wa = new GuiWorkArea(buffer, view);
wa->setUpdatesEnabled(false);
+ // Hide tabbar if there's no tab (avoid a resize and a flashing tabbar
+ // when hiding it again below).
+ showBar(count() > 0);
addTab(wa, wa->windowTitle());
QObject::connect(wa, SIGNAL(titleChanged(GuiWorkArea *)),
this, SLOT(updateTabText(GuiWorkArea *)));
// Hide tabbar if there's only one tab.
showBar(count() > 1);
- wa->resizeBufferView();
return wa;
}