mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
This is the continuation of my BufferView/LyXView cleanup. This commit replaces BufferView->LyXView->getDialogs().[show(), update()] with BufferView signal emissions.
The associated WorkArea is then responsible to connect these signals to its LyXView parent. * BufferView: - showDialog, showDialogWithData, showInsetDialog: new boost signals * LyXView: - connectBufferView(), disconnectBufferView(): new method in charge of the connection/disconnection of the above signal to associate private methods (showDialog(), etc). * WorkArea - setBufferView(): will connect/disconnect the BufferView to its LyXView parent. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15068 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
023fb5433c
commit
311ac9b192
@ -858,7 +858,7 @@ bool BufferView::dispatch(FuncRequest const & cmd)
|
||||
|
||||
case LFUN_CHANGES_MERGE:
|
||||
if (lyx::find::findNextChange(this))
|
||||
owner_->getDialogs().show("changes");
|
||||
showDialog("changes");
|
||||
break;
|
||||
|
||||
case LFUN_ALL_CHANGES_ACCEPT: {
|
||||
@ -1454,7 +1454,7 @@ void BufferView::trackChanges()
|
||||
} else {
|
||||
cursor_.setCursor(doc_iterator_begin(buffer_->inset()));
|
||||
if (lyx::find::findNextChange(this)) {
|
||||
owner_->getDialogs().show("changes");
|
||||
showDialog("changes");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -217,6 +217,22 @@ public:
|
||||
/// This signal is emitted when some message shows up.
|
||||
boost::signal<void(lyx::docstring)> message;
|
||||
|
||||
/// This signal is emitted when some dialog needs to be shown.
|
||||
boost::signal<void(std::string name)> showDialog;
|
||||
|
||||
/// This signal is emitted when some dialog needs to be shown with
|
||||
/// some data
|
||||
boost::signal<void(std::string name,
|
||||
std::string data)> showDialogWithData;
|
||||
|
||||
/// This signal is emitted when some inset dialogs needs to be shown.
|
||||
boost::signal<void(std::string name, std::string data,
|
||||
InsetBase * inset)> showInsetDialog;
|
||||
|
||||
/// This signal is emitted when some dialogs needs to be updated.
|
||||
boost::signal<void(std::string name,
|
||||
std::string data)> updateDialog;
|
||||
|
||||
private:
|
||||
///
|
||||
bool multiParSel();
|
||||
|
@ -83,6 +83,7 @@ LyXView::LyXView(Gui & owner)
|
||||
lyxerr[Debug::INIT] << "Initializing LyXFunc" << endl;
|
||||
}
|
||||
|
||||
|
||||
LyXView::~LyXView()
|
||||
{
|
||||
}
|
||||
@ -219,6 +220,28 @@ void LyXView::disconnectBuffer()
|
||||
}
|
||||
|
||||
|
||||
void LyXView::connectBufferView(BufferView & bv)
|
||||
{
|
||||
show_dialog_connection_ = bv.showDialog.connect(
|
||||
boost::bind(&LyXView::showDialog, this, _1));
|
||||
show_dialog_with_data_connection_ = bv.showDialogWithData.connect(
|
||||
boost::bind(&LyXView::showDialogWithData, this, _1, _2));
|
||||
show_inset_dialog_connection_ = bv.showInsetDialog.connect(
|
||||
boost::bind(&LyXView::showInsetDialog, this, _1, _2, _3));
|
||||
update_dialog_connection_ = bv.updateDialog.connect(
|
||||
boost::bind(&LyXView::updateDialog, this, _1, _2));
|
||||
}
|
||||
|
||||
|
||||
void LyXView::disconnectBufferView()
|
||||
{
|
||||
show_dialog_connection_.disconnect();
|
||||
show_dialog_with_data_connection_.disconnect();
|
||||
show_inset_dialog_connection_.disconnect();
|
||||
update_dialog_connection_.disconnect();
|
||||
}
|
||||
|
||||
|
||||
void LyXView::showErrorList(string const & error_type)
|
||||
{
|
||||
ErrorList & el = buffer()->errorList(error_type);
|
||||
@ -228,6 +251,33 @@ void LyXView::showErrorList(string const & error_type)
|
||||
}
|
||||
|
||||
|
||||
void LyXView::showDialog(string const & name)
|
||||
{
|
||||
getDialogs().show(name);
|
||||
}
|
||||
|
||||
|
||||
void LyXView::showDialogWithData(string const & name,
|
||||
string const & data)
|
||||
{
|
||||
getDialogs().show(name, data);
|
||||
}
|
||||
|
||||
|
||||
void LyXView::showInsetDialog(string const & name, string const & data,
|
||||
InsetBase * inset)
|
||||
{
|
||||
getDialogs().show(name, data, 0);
|
||||
}
|
||||
|
||||
|
||||
void LyXView::updateDialog(string const & name, string const & data)
|
||||
{
|
||||
if (getDialogs().visible(name))
|
||||
getDialogs().update(name, data);
|
||||
}
|
||||
|
||||
|
||||
void LyXView::showReadonly(bool)
|
||||
{
|
||||
updateWindowTitle();
|
||||
|
@ -165,6 +165,11 @@ public:
|
||||
/// show the error list to the user
|
||||
void showErrorList(std::string const &);
|
||||
|
||||
/// connect to signals in the given BufferView
|
||||
void connectBufferView(BufferView & bv);
|
||||
/// disconnect from signals in the given BufferView
|
||||
void disconnectBufferView();
|
||||
|
||||
protected:
|
||||
/// current work area (screen view of a BufferView).
|
||||
/**
|
||||
@ -214,6 +219,27 @@ private:
|
||||
void connectBuffer(Buffer & buf);
|
||||
/// disconnect from signals in the given buffer
|
||||
void disconnectBuffer();
|
||||
|
||||
/// BufferView messages signal connection
|
||||
//@{
|
||||
boost::signals::connection message_connection_;
|
||||
boost::signals::connection show_dialog_connection_;
|
||||
boost::signals::connection show_dialog_with_data_connection_;
|
||||
boost::signals::connection show_inset_dialog_connection_;
|
||||
boost::signals::connection update_dialog_connection_;
|
||||
//@}
|
||||
|
||||
/// Bind methods for BufferView messages signal connection
|
||||
//@{
|
||||
void showDialog(std::string const & name);
|
||||
void showDialogWithData(std::string const & name,
|
||||
std::string const & data);
|
||||
void showInsetDialog(std::string const & name,
|
||||
std::string const & data, InsetBase * inset);
|
||||
void updateDialog(std::string const & name,
|
||||
std::string const & data);
|
||||
//@}
|
||||
|
||||
/// notify readonly status
|
||||
void showReadonly(bool);
|
||||
|
||||
|
@ -159,8 +159,10 @@ WorkArea::WorkArea(LyXView & lyx_view)
|
||||
|
||||
void WorkArea::setBufferView(BufferView * buffer_view)
|
||||
{
|
||||
if (buffer_view_)
|
||||
if (buffer_view_) {
|
||||
message_connection_.disconnect();
|
||||
lyx_view_.disconnectBufferView();
|
||||
}
|
||||
|
||||
hideCursor();
|
||||
buffer_view_ = buffer_view;
|
||||
@ -168,6 +170,8 @@ void WorkArea::setBufferView(BufferView * buffer_view)
|
||||
|
||||
message_connection_ = buffer_view_->message.connect(
|
||||
boost::bind(&WorkArea::displayMessage, this, _1));
|
||||
|
||||
lyx_view_.connectBufferView(*buffer_view);
|
||||
}
|
||||
|
||||
|
||||
|
@ -24,7 +24,7 @@ using std::string;
|
||||
void MailInset::showDialog(BufferView * bv) const
|
||||
{
|
||||
BOOST_ASSERT(bv);
|
||||
bv->owner()->getDialogs().show(name(), inset2string(*bv->buffer()),
|
||||
bv->showInsetDialog(name(), inset2string(*bv->buffer()),
|
||||
&inset());
|
||||
}
|
||||
|
||||
@ -32,9 +32,7 @@ void MailInset::showDialog(BufferView * bv) const
|
||||
void MailInset::updateDialog(BufferView * bv) const
|
||||
{
|
||||
BOOST_ASSERT(bv);
|
||||
if (bv->owner()->getDialogs().visible(name()))
|
||||
bv->owner()->getDialogs().update(name(),
|
||||
inset2string(*bv->buffer()));
|
||||
bv->updateDialog(name(), inset2string(*bv->buffer()));
|
||||
}
|
||||
|
||||
|
||||
|
@ -41,7 +41,7 @@ class LyXView;
|
||||
class LyXFunc : public boost::signals::trackable {
|
||||
public:
|
||||
///
|
||||
explicit LyXFunc(LyXView *);
|
||||
explicit LyXFunc(LyXView * lv = 0);
|
||||
|
||||
/// LyX dispatcher, executes lyx actions.
|
||||
void dispatch(FuncRequest const &);
|
||||
|
@ -1081,7 +1081,7 @@ void InsetMathHull::doDispatch(LCursor & cur, FuncRequest & cmd)
|
||||
string const data = InsetCommandMailer::params2string("label", p);
|
||||
|
||||
if (cmd.argument().empty())
|
||||
cur.bv().owner()->getDialogs().show("label", data, 0);
|
||||
cur.bv().showInsetDialog("label", data, 0);
|
||||
else {
|
||||
FuncRequest fr(LFUN_INSET_INSERT, data);
|
||||
dispatch(cur, fr);
|
||||
|
@ -939,7 +939,7 @@ void InsetMathNest::doDispatch(LCursor & cur, FuncRequest & cmd)
|
||||
RefInset tmp(name);
|
||||
data = tmp.createDialogStr(name);
|
||||
}
|
||||
cur.bv().owner()->getDialogs().show(name, data, 0);
|
||||
cur.bv().showInsetDialog(name, data, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1126,7 +1126,7 @@ void InsetMathNest::lfunMouseRelease(LCursor & cur, FuncRequest & cmd)
|
||||
|
||||
if (cmd.button() == mouse_button::button3) {
|
||||
// try to dispatch to enclosed insets first
|
||||
cur.bv().owner()->getDialogs().show("mathpanel");
|
||||
cur.bv().showDialog("mathpanel");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -73,8 +73,7 @@ void RefInset::doDispatch(LCursor & cur, FuncRequest & cmd)
|
||||
|
||||
case LFUN_INSET_DIALOG_UPDATE: {
|
||||
string const data = createDialogStr("ref");
|
||||
if (cur.bv().owner()->getDialogs().visible("ref"))
|
||||
cur.bv().owner()->getDialogs().update("ref", data);
|
||||
cur.bv().updateDialog("ref", data);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -87,7 +86,7 @@ void RefInset::doDispatch(LCursor & cur, FuncRequest & cmd)
|
||||
if (cmd.button() == mouse_button::button1) {
|
||||
// Eventually trigger dialog with button 3, not 1
|
||||
string const data = createDialogStr("ref");
|
||||
cur.bv().owner()->getDialogs().show("ref", data, this);
|
||||
cur.bv().showInsetDialog("ref", data, this);
|
||||
break;
|
||||
}
|
||||
cur.undispatched();
|
||||
|
@ -196,7 +196,7 @@ public:
|
||||
lyxerr << "Undefined result from gettext" << endl;
|
||||
translated = from_ascii(tmp);
|
||||
} else if (msg == tmp) {
|
||||
lyxerr << "Same as entered returned" << endl;
|
||||
//lyxerr << "Same as entered returned" << endl;
|
||||
translated = from_ascii(tmp);
|
||||
} else {
|
||||
lyxerr << "We got a translation" << endl;
|
||||
|
16
src/text3.C
16
src/text3.C
@ -1091,14 +1091,14 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
|
||||
case LFUN_URL_INSERT: {
|
||||
InsetCommandParams p("url");
|
||||
string const data = InsetCommandMailer::params2string("url", p);
|
||||
bv->owner()->getDialogs().show("url", data, 0);
|
||||
bv->showInsetDialog("url", data, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_HTML_INSERT: {
|
||||
InsetCommandParams p("htmlurl");
|
||||
string const data = InsetCommandMailer::params2string("url", p);
|
||||
bv->owner()->getDialogs().show("url", data, 0);
|
||||
bv->showInsetDialog("url", data, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1111,7 +1111,7 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
|
||||
string const data = InsetCommandMailer::params2string("label", p);
|
||||
|
||||
if (cmd.argument().empty()) {
|
||||
bv->owner()->getDialogs().show("label", data, 0);
|
||||
bv->showInsetDialog("label", data, 0);
|
||||
} else {
|
||||
FuncRequest fr(LFUN_INSET_INSERT, data);
|
||||
dispatch(cur, fr);
|
||||
@ -1146,7 +1146,7 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
|
||||
if (doInsertInset(cur, this, cmd, false, true))
|
||||
cur.posRight();
|
||||
else
|
||||
bv->owner()->getDialogs().show("tabularcreate");
|
||||
bv->showDialog("tabularcreate");
|
||||
|
||||
break;
|
||||
|
||||
@ -1351,13 +1351,11 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
|
||||
string data;
|
||||
params2string(cur.paragraph(), data);
|
||||
data = "show\n" + data;
|
||||
bv->owner()->getDialogs().show("paragraph", data);
|
||||
bv->showDialogWithData("paragraph", data);
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_PARAGRAPH_UPDATE: {
|
||||
if (!bv->owner()->getDialogs().visible("paragraph"))
|
||||
break;
|
||||
string data;
|
||||
params2string(cur.paragraph(), data);
|
||||
|
||||
@ -1365,7 +1363,7 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
|
||||
bool const accept = !cur.inset().forceDefaultParagraphs(cur.idx());
|
||||
|
||||
data = "update " + convert<string>(accept) + '\n' + data;
|
||||
bv->owner()->getDialogs().update("paragraph", data);
|
||||
bv->updateDialog("paragraph", data);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1438,7 +1436,7 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
|
||||
arg = cur.selectionAsString(false);
|
||||
}
|
||||
}
|
||||
bv->owner()->getDialogs().show("thesaurus", lyx::to_utf8(arg));
|
||||
bv->showDialogWithData("thesaurus", lyx::to_utf8(arg));
|
||||
break;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user