mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
Use DispatchResult also in GuiView::dispatchVC to handle messages.
Make it possible to suppress messages stored in DispatchResult objects. BUG: 6417 git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@35662 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
ee2eabd416
commit
5520817bd3
@ -4,7 +4,7 @@
|
|||||||
* This file is part of LyX, the document processor.
|
* This file is part of LyX, the document processor.
|
||||||
* Licence details can be found in the file COPYING.
|
* Licence details can be found in the file COPYING.
|
||||||
*
|
*
|
||||||
* \author none
|
* \author Peter Kümmel
|
||||||
* \author Lars Gullik Bjønnes
|
* \author Lars Gullik Bjønnes
|
||||||
*
|
*
|
||||||
* Full author contact details are available in file CREDITS.
|
* Full author contact details are available in file CREDITS.
|
||||||
@ -19,15 +19,26 @@
|
|||||||
|
|
||||||
namespace lyx {
|
namespace lyx {
|
||||||
|
|
||||||
/// Maybe this can go entirely
|
|
||||||
class DispatchResult {
|
class DispatchResult
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
DispatchResult() : dispatched_(false), error_(false),
|
DispatchResult() :
|
||||||
update_(Update::None), need_buf_update_(false) {}
|
dispatched_(false),
|
||||||
|
error_(false),
|
||||||
|
update_(Update::None),
|
||||||
|
need_buf_update_(false),
|
||||||
|
need_msg_update_(true)
|
||||||
|
{}
|
||||||
///
|
///
|
||||||
DispatchResult(bool disp, Update::flags f)
|
DispatchResult(bool dispatched, Update::flags f) :
|
||||||
: dispatched_(disp), error_(false), update_(f) {}
|
dispatched_(dispatched),
|
||||||
|
error_(false),
|
||||||
|
update_(f),
|
||||||
|
need_buf_update_(false),
|
||||||
|
need_msg_update_(true)
|
||||||
|
{}
|
||||||
///
|
///
|
||||||
bool dispatched() const { return dispatched_; }
|
bool dispatched() const { return dispatched_; }
|
||||||
///
|
///
|
||||||
@ -39,7 +50,9 @@ public:
|
|||||||
///
|
///
|
||||||
docstring message() { return message_; }
|
docstring message() { return message_; }
|
||||||
///
|
///
|
||||||
void setMessage(docstring m) { message_ = m; }
|
void setMessage(docstring const & m) { message_ = m; }
|
||||||
|
///
|
||||||
|
void setMessage(std::string const & m) { message_ = from_utf8(m); }
|
||||||
///
|
///
|
||||||
Update::flags screenUpdate() const { return update_; }
|
Update::flags screenUpdate() const { return update_; }
|
||||||
///
|
///
|
||||||
@ -50,6 +63,13 @@ public:
|
|||||||
void forceBufferUpdate() { need_buf_update_ = true; }
|
void forceBufferUpdate() { need_buf_update_ = true; }
|
||||||
/// Clear the flag indicating we need an update
|
/// Clear the flag indicating we need an update
|
||||||
void clearBufferUpdate() { need_buf_update_ = false; }
|
void clearBufferUpdate() { need_buf_update_ = false; }
|
||||||
|
///
|
||||||
|
bool needMessageUpdate() const { return need_msg_update_; }
|
||||||
|
/// Force the buffer to be updated
|
||||||
|
void forceMessageUpdate() { need_msg_update_ = true; }
|
||||||
|
/// Clear the flag indicating we need an update
|
||||||
|
void suppressMessageUpdate() { need_msg_update_ = false; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// was the event fully dispatched?
|
/// was the event fully dispatched?
|
||||||
bool dispatched_;
|
bool dispatched_;
|
||||||
@ -61,6 +81,8 @@ private:
|
|||||||
docstring message_;
|
docstring message_;
|
||||||
///
|
///
|
||||||
bool need_buf_update_;
|
bool need_buf_update_;
|
||||||
|
///
|
||||||
|
bool need_msg_update_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -1116,9 +1116,11 @@ void GuiApplication::dispatch(FuncRequest const & cmd)
|
|||||||
// update gui
|
// update gui
|
||||||
current_view_->restartCursor();
|
current_view_->restartCursor();
|
||||||
}
|
}
|
||||||
// Some messages may already be translated, so we cannot use _()
|
if (dr.needMessageUpdate()) {
|
||||||
current_view_->message(makeDispatchMessage(
|
// Some messages may already be translated, so we cannot use _()
|
||||||
translateIfPossible(dr.message()), cmd));
|
current_view_->message(makeDispatchMessage(
|
||||||
|
translateIfPossible(dr.message()), cmd));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2522,10 +2522,10 @@ static bool ensureBufferClean(Buffer * buffer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GuiView::reloadBuffer()
|
bool GuiView::reloadBuffer()
|
||||||
{
|
{
|
||||||
Buffer * buf = &documentBufferView()->buffer();
|
Buffer * buf = &documentBufferView()->buffer();
|
||||||
buf->reload();
|
return buf->reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2548,11 +2548,8 @@ void GuiView::checkExternallyModifiedBuffers()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//FIXME use a DispatchResult object to transmit messages
|
void GuiView::dispatchVC(FuncRequest const & cmd, DispatchResult & dr)
|
||||||
void GuiView::dispatchVC(FuncRequest const & cmd)
|
|
||||||
{
|
{
|
||||||
// message for statusbar
|
|
||||||
string msg;
|
|
||||||
Buffer * buffer = documentBufferView()
|
Buffer * buffer = documentBufferView()
|
||||||
? &(documentBufferView()->buffer()) : 0;
|
? &(documentBufferView()->buffer()) : 0;
|
||||||
|
|
||||||
@ -2561,8 +2558,10 @@ void GuiView::dispatchVC(FuncRequest const & cmd)
|
|||||||
if (!buffer || !ensureBufferClean(buffer))
|
if (!buffer || !ensureBufferClean(buffer))
|
||||||
break;
|
break;
|
||||||
if (!buffer->lyxvc().inUse()) {
|
if (!buffer->lyxvc().inUse()) {
|
||||||
if (buffer->lyxvc().registrer())
|
if (buffer->lyxvc().registrer()) {
|
||||||
reloadBuffer();
|
reloadBuffer();
|
||||||
|
dr.suppressMessageUpdate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -2570,8 +2569,8 @@ void GuiView::dispatchVC(FuncRequest const & cmd)
|
|||||||
if (!buffer || !ensureBufferClean(buffer))
|
if (!buffer || !ensureBufferClean(buffer))
|
||||||
break;
|
break;
|
||||||
if (buffer->lyxvc().inUse() && !buffer->isReadonly()) {
|
if (buffer->lyxvc().inUse() && !buffer->isReadonly()) {
|
||||||
msg = buffer->lyxvc().checkIn();
|
dr.setMessage(buffer->lyxvc().checkIn());
|
||||||
if (!msg.empty())
|
if (!dr.message().empty())
|
||||||
reloadBuffer();
|
reloadBuffer();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -2580,7 +2579,7 @@ void GuiView::dispatchVC(FuncRequest const & cmd)
|
|||||||
if (!buffer || !ensureBufferClean(buffer))
|
if (!buffer || !ensureBufferClean(buffer))
|
||||||
break;
|
break;
|
||||||
if (buffer->lyxvc().inUse()) {
|
if (buffer->lyxvc().inUse()) {
|
||||||
msg = buffer->lyxvc().checkOut();
|
dr.setMessage(buffer->lyxvc().checkOut());
|
||||||
reloadBuffer();
|
reloadBuffer();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -2595,7 +2594,7 @@ void GuiView::dispatchVC(FuncRequest const & cmd)
|
|||||||
frontend::Alert::error(_("Revision control error."),
|
frontend::Alert::error(_("Revision control error."),
|
||||||
_("Error when setting the locking property."));
|
_("Error when setting the locking property."));
|
||||||
} else {
|
} else {
|
||||||
msg = res;
|
dr.setMessage(res);
|
||||||
reloadBuffer();
|
reloadBuffer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2605,18 +2604,20 @@ void GuiView::dispatchVC(FuncRequest const & cmd)
|
|||||||
LASSERT(buffer, return);
|
LASSERT(buffer, return);
|
||||||
buffer->lyxvc().revert();
|
buffer->lyxvc().revert();
|
||||||
reloadBuffer();
|
reloadBuffer();
|
||||||
|
dr.suppressMessageUpdate();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_VC_UNDO_LAST:
|
case LFUN_VC_UNDO_LAST:
|
||||||
LASSERT(buffer, return);
|
LASSERT(buffer, return);
|
||||||
buffer->lyxvc().undoLast();
|
buffer->lyxvc().undoLast();
|
||||||
reloadBuffer();
|
reloadBuffer();
|
||||||
|
dr.suppressMessageUpdate();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_VC_REPO_UPDATE:
|
case LFUN_VC_REPO_UPDATE:
|
||||||
LASSERT(buffer, return);
|
LASSERT(buffer, return);
|
||||||
if (ensureBufferClean(buffer)) {
|
if (ensureBufferClean(buffer)) {
|
||||||
msg = buffer->lyxvc().repoUpdate();
|
dr.setMessage(buffer->lyxvc().repoUpdate());
|
||||||
checkExternallyModifiedBuffers();
|
checkExternallyModifiedBuffers();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -2698,9 +2699,6 @@ void GuiView::dispatchVC(FuncRequest const & cmd)
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!msg.empty())
|
|
||||||
message(from_utf8(msg));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -3268,7 +3266,7 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
|
|||||||
case LFUN_VC_UNDO_LAST:
|
case LFUN_VC_UNDO_LAST:
|
||||||
case LFUN_VC_COMMAND:
|
case LFUN_VC_COMMAND:
|
||||||
case LFUN_VC_COMPARE:
|
case LFUN_VC_COMPARE:
|
||||||
dispatchVC(cmd);
|
dispatchVC(cmd, dr);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_SERVER_GOTO_FILE_ROW:
|
case LFUN_SERVER_GOTO_FILE_ROW:
|
||||||
|
@ -398,9 +398,9 @@ private:
|
|||||||
///
|
///
|
||||||
Dialog * build(std::string const & name);
|
Dialog * build(std::string const & name);
|
||||||
///
|
///
|
||||||
void reloadBuffer();
|
bool reloadBuffer();
|
||||||
///
|
///
|
||||||
void dispatchVC(FuncRequest const & cmd);
|
void dispatchVC(FuncRequest const & cmd, DispatchResult & dr);
|
||||||
///
|
///
|
||||||
void showMessage();
|
void showMessage();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user