mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
Replace Buffer' changed() and closing() signals with a WorkAreaManager before Andre erase everything :-)
The resulting source code is not much bigger actually. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20654 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
522c624821
commit
4ce0961b5a
@ -68,6 +68,7 @@
|
||||
#include "mathed/MathSupport.h"
|
||||
|
||||
#include "frontends/alert.h"
|
||||
#include "frontends/WorkAreaManager.h"
|
||||
|
||||
#include "graphics/Previews.h"
|
||||
|
||||
@ -206,13 +207,17 @@ public:
|
||||
/// modified. (Used to properly enable 'File->Revert to saved', bug 4114).
|
||||
time_t timestamp_;
|
||||
unsigned long checksum_;
|
||||
|
||||
///
|
||||
frontend::WorkAreaManager * wa_;
|
||||
};
|
||||
|
||||
|
||||
Buffer::Impl::Impl(Buffer & parent, FileName const & file, bool readonly_)
|
||||
: lyx_clean(true), bak_clean(true), unnamed(false), read_only(readonly_),
|
||||
filename(file), file_fully_loaded(false), inset(params),
|
||||
toc_backend(&parent), embedded_files(&parent), timestamp_(0), checksum_(0)
|
||||
toc_backend(&parent), embedded_files(&parent), timestamp_(0),
|
||||
checksum_(0), wa_(0)
|
||||
{
|
||||
inset.setAutoBreakRows(true);
|
||||
lyxvc.buffer(&parent);
|
||||
@ -221,6 +226,9 @@ Buffer::Impl::Impl(Buffer & parent, FileName const & file, bool readonly_)
|
||||
// FIXME: And now do something if temppath == string(), because we
|
||||
// assume from now on that temppath points to a valid temp dir.
|
||||
// See http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg67406.html
|
||||
|
||||
if (use_gui)
|
||||
wa_ = new frontend::WorkAreaManager;
|
||||
}
|
||||
|
||||
|
||||
@ -253,10 +261,25 @@ Buffer::~Buffer()
|
||||
// Remove any previewed LaTeX snippets associated with this buffer.
|
||||
graphics::Previews::get().removeLoader(*this);
|
||||
|
||||
closing(this);
|
||||
if (pimpl_->wa_) {
|
||||
pimpl_->wa_->closing();
|
||||
delete pimpl_->wa_;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Buffer::changed()
|
||||
{
|
||||
if (pimpl_->wa_)
|
||||
pimpl_->wa_->changed();
|
||||
}
|
||||
|
||||
|
||||
frontend::WorkAreaManager * Buffer::workAreaManager() const
|
||||
{
|
||||
return pimpl_->wa_;
|
||||
}
|
||||
|
||||
Text & Buffer::text() const
|
||||
{
|
||||
return const_cast<Text &>(pimpl_->inset.text_);
|
||||
|
11
src/Buffer.h
11
src/Buffer.h
@ -54,6 +54,9 @@ class TexRow;
|
||||
class TocBackend;
|
||||
class Undo;
|
||||
|
||||
namespace frontend {
|
||||
class WorkAreaManager;
|
||||
}
|
||||
|
||||
/** The buffer object.
|
||||
* This is the buffer object. It contains all the informations about
|
||||
@ -141,7 +144,11 @@ public:
|
||||
bool hasParWithID(int id) const;
|
||||
|
||||
/// This signal is emitted when the buffer is changed.
|
||||
boost::signal<void()> changed;
|
||||
void changed();
|
||||
|
||||
///
|
||||
frontend::WorkAreaManager * workAreaManager() const;
|
||||
|
||||
/// This signal is emitted when the buffer structure is changed.
|
||||
boost::signal<void()> structureChanged;
|
||||
/// This signal is emitted when an embedded file is changed
|
||||
@ -158,8 +165,6 @@ public:
|
||||
boost::signal<void()> updateTitles;
|
||||
/// Reset autosave timers for all users.
|
||||
boost::signal<void()> resetAutosaveTimers;
|
||||
/// This signal is emitting if the buffer is being closed.
|
||||
boost::signal<void(Buffer *)> closing;
|
||||
|
||||
|
||||
/** Save file.
|
||||
|
@ -626,8 +626,8 @@ void updateLabels(Buffer const & buf, bool childonly)
|
||||
// FIXME
|
||||
// the embedding signal is emitted with structureChanged signal
|
||||
// this is inaccurate so these two will be separated later.
|
||||
cbuf.embeddedFiles().update();
|
||||
cbuf.embeddingChanged();
|
||||
//cbuf.embeddedFiles().update();
|
||||
//cbuf.embeddingChanged();
|
||||
}
|
||||
|
||||
|
||||
|
@ -35,5 +35,7 @@ liblyxfrontends_la_SOURCES = \
|
||||
Selection.h \
|
||||
WorkArea.cpp \
|
||||
WorkArea.h \
|
||||
WorkAreaManager.cpp \
|
||||
WorkAreaManager.h \
|
||||
key_state.h \
|
||||
mouse_state.h
|
||||
|
@ -72,23 +72,12 @@ WorkArea::WorkArea(Buffer & buffer, LyXView & lv)
|
||||
timecon = cursor_timeout_.timeout
|
||||
.connect(boost::bind(&WorkArea::toggleCursor, this));
|
||||
|
||||
bufferChangedConnection_ =
|
||||
buffer.changed.connect(
|
||||
boost::bind(&WorkArea::redraw, this));
|
||||
|
||||
bufferClosingConnection_ =
|
||||
buffer.closing.connect(
|
||||
boost::bind(&WorkArea::close, this));
|
||||
|
||||
cursor_timeout_.start();
|
||||
}
|
||||
|
||||
|
||||
WorkArea::~WorkArea()
|
||||
{
|
||||
bufferChangedConnection_.disconnect();
|
||||
bufferClosingConnection_.disconnect();
|
||||
|
||||
delete buffer_view_;
|
||||
}
|
||||
|
||||
|
@ -19,8 +19,6 @@
|
||||
#include "support/Timeout.h"
|
||||
#include "support/docstring.h"
|
||||
|
||||
#include <boost/signals/trackable.hpp>
|
||||
|
||||
#undef CursorShape
|
||||
|
||||
namespace lyx {
|
||||
@ -52,7 +50,8 @@ enum CursorShape {
|
||||
* It works in concert with the BaseScreen class to update the
|
||||
* widget view of a document.
|
||||
*/
|
||||
class WorkArea : public boost::signals::trackable {
|
||||
class WorkArea
|
||||
{
|
||||
public:
|
||||
///
|
||||
WorkArea(Buffer & buffer, LyXView & lv);
|
||||
@ -100,6 +99,10 @@ public:
|
||||
/// This needs to be public because it is accessed externally by GuiView.
|
||||
void processKeySym(KeySymbol const & key, key_modifier::state state);
|
||||
|
||||
/// close this work area.
|
||||
/// Slot for Buffer::closing signal.
|
||||
void close();
|
||||
|
||||
protected:
|
||||
/// cause the display of the given area of the work area
|
||||
virtual void expose(int x, int y, int w, int h) = 0;
|
||||
@ -107,9 +110,6 @@ protected:
|
||||
void dispatch(FuncRequest const & cmd0,
|
||||
key_modifier::state = key_modifier::none);
|
||||
|
||||
/// close this work area.
|
||||
/// Slot for Buffer::closing boost signal.
|
||||
void close();
|
||||
///
|
||||
void resizeBufferView();
|
||||
/// hide the visible cursor, if it is visible
|
||||
@ -136,11 +136,6 @@ private:
|
||||
|
||||
///
|
||||
Timeout cursor_timeout_;
|
||||
|
||||
/// buffer changed signal connection
|
||||
boost::signals::connection bufferChangedConnection_;
|
||||
/// buffer closing signal connection
|
||||
boost::signals::connection bufferClosingConnection_;
|
||||
};
|
||||
|
||||
} // namespace frontend
|
||||
|
40
src/frontends/WorkAreaManager.cpp
Normal file
40
src/frontends/WorkAreaManager.cpp
Normal file
@ -0,0 +1,40 @@
|
||||
// -*- C++ -*-
|
||||
/**
|
||||
* \file WorkAreaManager.cpp
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Abdelrazak Younes
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "WorkArea.h"
|
||||
|
||||
#include "WorkAreaManager.h"
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
void WorkAreaManager::registerWorkArea(WorkArea * wa)
|
||||
{
|
||||
work_areas_.push_back(wa);
|
||||
}
|
||||
|
||||
void WorkAreaManager::changed()
|
||||
{
|
||||
for (size_t i = 0; i != work_areas_.size(); ++i)
|
||||
work_areas_[i]->redraw();
|
||||
}
|
||||
|
||||
void WorkAreaManager::closing()
|
||||
{
|
||||
for (size_t i = 0; i != work_areas_.size(); ++i)
|
||||
work_areas_[i]->close();
|
||||
}
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
||||
|
43
src/frontends/WorkAreaManager.h
Normal file
43
src/frontends/WorkAreaManager.h
Normal file
@ -0,0 +1,43 @@
|
||||
// -*- C++ -*-
|
||||
/**
|
||||
* \file WorkAreaManager.h
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Abdelrazak Younes
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#ifndef WORKAREA_MANAGER_H
|
||||
#define WORKAREA_MANAGER_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
class WorkArea;
|
||||
|
||||
class WorkAreaManager
|
||||
{
|
||||
public:
|
||||
WorkAreaManager() {}
|
||||
|
||||
///
|
||||
void registerWorkArea(WorkArea * wa);
|
||||
|
||||
///
|
||||
void changed();
|
||||
|
||||
///
|
||||
void closing();
|
||||
|
||||
private:
|
||||
std::vector<WorkArea *> work_areas_;
|
||||
};
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
||||
|
||||
#endif // BASE_WORKAREA_H
|
@ -27,6 +27,7 @@
|
||||
#include "frontends/Dialogs.h"
|
||||
#include "frontends/Gui.h"
|
||||
#include "frontends/WorkArea.h"
|
||||
#include "frontends/WorkAreaManager.h"
|
||||
|
||||
#include "support/filetools.h"
|
||||
#include "support/convert.h"
|
||||
@ -858,6 +859,8 @@ WorkArea * GuiViewBase::addWorkArea(Buffer & buffer)
|
||||
d.stack_widget_->setCurrentWidget(d.tab_widget_);
|
||||
// Hide tabbar if there's only one tab.
|
||||
d.tab_widget_->showBar(d.tab_widget_->count() > 1);
|
||||
///
|
||||
buffer.workAreaManager()->registerWorkArea(wa);
|
||||
return wa;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user