# HG changeset patch # User John W. Eaton # Date 1363765581 14400 # Node ID b91e86175a240a209e98f4bc9a491049e91d4ec3 # Parent 0c340bf413d7f3448214ba3d70e9aebfa26a8a8f [mq]: workspace-timer diff --git a/libgui/src/main-window.cc b/libgui/src/main-window.cc --- a/libgui/src/main-window.cc +++ b/libgui/src/main-window.cc @@ -300,6 +300,12 @@ } void +main_window::update_workspace (void) +{ + _workspace_view->model_changed (); +} + +void main_window::change_current_working_directory () { QString directory = @@ -1125,6 +1131,11 @@ SLOT (current_working_directory_has_changed (QString))); connect (_octave_qt_event_listener, + SIGNAL (update_workspace_signal ()), + this, + SLOT (update_workspace ())); + + connect (_octave_qt_event_listener, SIGNAL (entered_debug_mode_signal ()), this, SLOT(handle_entered_debug_mode ())); diff --git a/libgui/src/main-window.h b/libgui/src/main-window.h --- a/libgui/src/main-window.h +++ b/libgui/src/main-window.h @@ -96,6 +96,7 @@ void prepare_for_quit (); void reset_windows (); void current_working_directory_has_changed (const QString& directory); + void update_workspace (void); void change_current_working_directory (); void set_current_working_directory (const QString& directory); void current_working_directory_up (); diff --git a/libgui/src/octave-adapter/octave-event-listener.h b/libgui/src/octave-adapter/octave-event-listener.h --- a/libgui/src/octave-adapter/octave-event-listener.h +++ b/libgui/src/octave-adapter/octave-event-listener.h @@ -34,6 +34,9 @@ virtual void current_directory_has_changed (const std::string& directory) = 0; + virtual void + update_workspace (void) = 0; + virtual void about_to_exit () = 0; virtual void entered_debug_mode () = 0; diff --git a/libgui/src/octave-adapter/octave-link.cc b/libgui/src/octave-adapter/octave-link.cc --- a/libgui/src/octave-adapter/octave-link.cc +++ b/libgui/src/octave-adapter/octave-link.cc @@ -81,6 +81,9 @@ void octave_link::do_generate_events (void) { + if (event_listener) + event_listener->update_workspace (); + std::string current_working_directory = octave_env::get_current_directory (); if (current_working_directory != last_cwd) diff --git a/libgui/src/octave-qt-event-listener.cc b/libgui/src/octave-qt-event-listener.cc --- a/libgui/src/octave-qt-event-listener.cc +++ b/libgui/src/octave-qt-event-listener.cc @@ -40,6 +40,12 @@ } void +octave_qt_event_listener::update_workspace (void) +{ + emit update_workspace_signal (); +} + +void octave_qt_event_listener::about_to_exit () { qApp->quit (); diff --git a/libgui/src/octave-qt-event-listener.h b/libgui/src/octave-qt-event-listener.h --- a/libgui/src/octave-qt-event-listener.h +++ b/libgui/src/octave-qt-event-listener.h @@ -35,6 +35,7 @@ octave_qt_event_listener (QObject *parent = 0); void current_directory_has_changed (const std::string& directory); + void update_workspace (void); void about_to_exit (); void entered_debug_mode (); @@ -42,6 +43,7 @@ signals: void current_directory_has_changed_signal (const QString& directory); + void update_workspace_signal (void); void entered_debug_mode_signal (); void quit_debug_mode_signal (); }; diff --git a/libgui/src/workspace-model.cc b/libgui/src/workspace-model.cc --- a/libgui/src/workspace-model.cc +++ b/libgui/src/workspace-model.cc @@ -46,16 +46,6 @@ insert_top_level_item(0, new tree_item ("Local")); insert_top_level_item(1, new tree_item ("Global")); insert_top_level_item(2, new tree_item ("Persistent")); - - connect(&_update_workspace_model_timer, - SIGNAL (timeout ()), - this, - SLOT (request_update_workspace())); - - _update_event_enabled = true; - _update_workspace_model_timer.setInterval (500); - _update_workspace_model_timer.setSingleShot (false); - _update_workspace_model_timer.start (); } workspace_model::~workspace_model() @@ -66,11 +56,7 @@ void workspace_model::request_update_workspace () { - 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); - } + octave_link::post_event (this, &workspace_model::update_workspace_callback); } QModelIndex @@ -226,9 +212,4 @@ } endResetModel(); - emit model_changed(); - - // update is processed, re-enable further updates events triggered by timer - _update_event_enabled = true; - } diff --git a/libgui/src/workspace-model.h b/libgui/src/workspace-model.h --- a/libgui/src/workspace-model.h +++ b/libgui/src/workspace-model.h @@ -27,7 +27,6 @@ #include #include #include -#include #include "symbol-information.h" @@ -132,6 +131,8 @@ void insert_top_level_item (int at, tree_item *treeItem); tree_item *top_level_item (int at); + void update_workspace_callback (void); + public slots: void request_update_workspace (); @@ -140,14 +141,6 @@ private: - bool _update_event_enabled; - - void update_workspace_callback (void); - - /** Timer for periodically updating the workspace model from the current - * symbol information. */ - QTimer _update_workspace_model_timer; - /** Stores the current symbol information. */ QList _symbol_information; tree_item *_rootItem; diff --git a/libgui/src/workspace-view.cc b/libgui/src/workspace-view.cc --- a/libgui/src/workspace-view.cc +++ b/libgui/src/workspace-view.cc @@ -114,6 +114,8 @@ void workspace_view::model_changed () { + _workspace_model->update_workspace_callback (); + // This code is very quirky and requires some explanation. // Usually, we should not deal with collapsing or expanding ourselves, // because the view itself determines (based on the model) whether it