Mercurial > hg > octave-lyh
diff gui/src/octave-adapter/octave-link.h @ 14718:3df7ef0080c7 gui
Added event based processing and implement exit and change directory event.
* octave-event-observer.h: Implements observer part for the observer pattern.
* main-window.cc: Posting events instead of emulating keypresses.
* octave-event.h: Added new event types.
* octave-link: Subclassed octave_event_observer and implemented events.
* src.pro: Added file for tracking.
author | Jacob Dawid <jacob.dawid@googlemail.com> |
---|---|
date | Mon, 04 Jun 2012 01:42:58 +0200 |
parents | 4ff6c21c18c4 |
children | 89c64340e9ab |
line wrap: on
line diff
--- a/gui/src/octave-adapter/octave-link.h +++ b/gui/src/octave-adapter/octave-link.h @@ -72,10 +72,12 @@ #include <QObject> #include <QStringListModel> #include <QTimer> +#include <QQueue> #include "workspace-model.h" #include "octave-main-thread.h" #include "octave-event.h" +#include "octave-event-observer.h" #include "symbol-information.h" /** @@ -86,7 +88,7 @@ * buffering access operations to octave and executing them in the readline * even hook, which lives in the octave thread. */ -class octave_link : public QObject +class octave_link : public QObject, public octave_event_observer { Q_OBJECT public: @@ -129,6 +131,15 @@ */ const QList <symbol_information>& get_symbol_information () const; + void process_events (); + void post_event (octave_event *e); + void event_accepted (octave_event *e) const; + void event_ignored (octave_event *e) const; + + + void request_working_directory_change (std::string directory); + void request_octave_exit (); + signals: /** Emitted, whenever the working directory of octave changed. */ void working_directory_changed (QString directory); @@ -154,6 +165,12 @@ /** Semaphore to lock access to the symbol information. */ QSemaphore *_symbol_information_semaphore; + /** Semaphore to lock access to the event queue. */ + QSemaphore *_event_queue_semaphore; + + /** Buffer for queueing events until they will be processed. */ + QQueue <octave_event *> _event_queue; + /** Stores the current symbol information. */ QList <symbol_information> _symbol_information;