Mercurial > hg > octave-nkf
changeset 16069:0486a29d780f
gui: fix updating history and workspace widget for mxe-octave
* history-dock-widget.h: new flag _update_event_enabled for disabling and
enabling the update event
* histroy-dock-widget.cc(construct): change update timer to periodic and to an
interval of 500 ms, enable update
* history-dock-widget.cc(request_history_model_update): if update is enabled
post update event and disable update in order to prevent further events
* history-dock-widget.cc(update_history_callback): reenalbe update when update
is complete
* workspace-model.h: new flag _update_event_enabled for disabling and enabling
the update event
* workspace-model.cc(workspace_model): change update timer to periodic,
enable update
* workspace-model.cc(request_update_workspace): if update is enabled post update
event and disable update in order to prevent further events
* workspace-model.cc(update_workspace_callback): reenalbe update when update
is complete
author | Torsten <ttl@justmail.de> |
---|---|
date | Sun, 17 Feb 2013 21:17:46 +0100 |
parents | b309a5da17f5 |
children | ac672925fc98 |
files | libgui/src/history-dockwidget.cc libgui/src/history-dockwidget.h libgui/src/workspace-model.cc libgui/src/workspace-model.h |
diffstat | 4 files changed, 25 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/src/history-dockwidget.cc +++ b/libgui/src/history-dockwidget.cc @@ -77,8 +77,9 @@ connect (_history_list_view, SIGNAL (doubleClicked (QModelIndex)), this, SLOT (handle_double_click (QModelIndex))); - _update_history_model_timer.setInterval (200); - _update_history_model_timer.setSingleShot (true); + _update_event_enabled = true; + _update_history_model_timer.setInterval (500); + _update_history_model_timer.setSingleShot (false); connect (&_update_history_model_timer, SIGNAL (timeout ()), @@ -132,7 +133,11 @@ void history_dock_widget::request_history_model_update () { - octave_link::post_event (this, &history_dock_widget::update_history_callback); + if (_update_event_enabled) + { + _update_event_enabled = false; // no more update until this one is processed + octave_link::post_event (this, &history_dock_widget::update_history_callback); + } } void @@ -181,7 +186,7 @@ _history_list_view->scrollToBottom (); } - // Post a new update event in a given time. This prevents flooding the - // event queue. - _update_history_model_timer.start (); + // update is processed, re-enable further updates events triggered by timer + _update_event_enabled = true; + }
--- a/libgui/src/history-dockwidget.h +++ b/libgui/src/history-dockwidget.h @@ -66,6 +66,7 @@ QTimer _update_history_model_timer; void update_history_callback (void); + bool _update_event_enabled; }; #endif // HISTORYDOCKWIDGET_H
--- a/libgui/src/workspace-model.cc +++ b/libgui/src/workspace-model.cc @@ -1,3 +1,4 @@ + /* Copyright (C) 2011-2012 Jacob Dawid @@ -51,8 +52,9 @@ this, SLOT (request_update_workspace())); + _update_event_enabled = true; _update_workspace_model_timer.setInterval (500); - _update_workspace_model_timer.setSingleShot (true); + _update_workspace_model_timer.setSingleShot (false); _update_workspace_model_timer.start (); } @@ -64,7 +66,11 @@ void workspace_model::request_update_workspace () { - octave_link::post_event (this, &workspace_model::update_workspace_callback); + if (_update_event_enabled) + { + _update_event_enabled = false; // no more update until this one is processed + octave_link::post_event (this, &workspace_model::update_workspace_callback); + } } QModelIndex @@ -222,8 +228,7 @@ endResetModel(); emit model_changed(); - // Post a new event in a given time. - // This prevents flooding the event queue when no events are being processed. - _update_workspace_model_timer.start (); + // update is processed, re-enable further updates events triggered by timer + _update_event_enabled = true; + } -