Mercurial > hg > octave-nkf
changeset 13540:0dbf8681cd08
Seperated classes into own files.
author | Jacob Dawid <jacob.dawid@googlemail.com> |
---|---|
date | Tue, 26 Jul 2011 22:31:01 +0200 |
parents | a4b5cad8f7c6 |
children | b48ac9ad8de0 |
files | gui/octave-gui.pro gui/src/MainWindow.cpp gui/src/MainWindow.h gui/src/OctaveCallbackThread.cpp gui/src/OctaveCallbackThread.h gui/src/OctaveMainThread.cpp gui/src/OctaveMainThread.h |
diffstat | 7 files changed, 89 insertions(+), 59 deletions(-) [+] |
line wrap: on
line diff
--- a/gui/octave-gui.pro +++ b/gui/octave-gui.pro @@ -86,7 +86,9 @@ src/SettingsDialog.cpp \ src/OctaveGUI.cpp \ src/ResourceManager.cpp \ - src/CommandLineParser.cpp + src/CommandLineParser.cpp \ + src/OctaveMainThread.cpp \ + src/OctaveCallbackThread.cpp HEADERS += \ src/terminal/TerminalCharacterDecoder.h \ @@ -130,7 +132,9 @@ src/qirc/IClientSocket.h \ src/SettingsDialog.h \ src/ResourceManager.h \ - src/CommandLineParser.h + src/CommandLineParser.h \ + src/OctaveMainThread.h \ + src/OctaveCallbackThread.h FORMS += \ src/SettingsDialog.ui
--- a/gui/src/MainWindow.cpp +++ b/gui/src/MainWindow.cpp @@ -26,6 +26,7 @@ #include "FileEditorMdiSubWindow.h" #include "ImageViewerMdiSubWindow.h" #include "SettingsDialog.h" +#include "OctaveCallbackThread.h" #include "cmd-edit.h" #define VERSION_STRING "Octave GUI (0.6.0)"
--- a/gui/src/MainWindow.h +++ b/gui/src/MainWindow.h @@ -35,8 +35,8 @@ #include "BrowserWidget.h" #include "IRCWidget.h" -class OctaveMainThread; class OctaveCallbackThread; +#include "OctaveMainThread.h" /** * \class MainWindow @@ -120,60 +120,4 @@ bool m_isRunning; }; -class OctaveMainThread:public QThread -{ -Q_OBJECT -public: - OctaveMainThread (QObject * parent):QThread (parent) - { - } - -signals: - void ready(); - -protected: - void run () - { - int argc = 3; - const char *argv[] = { "octave", "--interactive", "--line-editing" }; - octave_main (argc, (char **) argv, 1); - emit ready(); - main_loop (); - clean_up_and_exit (0); - } -}; - -class OctaveCallbackThread:public QThread -{ -Q_OBJECT public: - OctaveCallbackThread (QObject * parent, - MainWindow * mainWindow):QThread (parent), - m_mainWindow (mainWindow) - { - } - -protected: - void run () - { - while (m_mainWindow->isRunning ()) - { - OctaveLink::instance ()->fetchSymbolTable (); - - // Get a full variable list. - QList < SymbolRecord > symbolTable = - OctaveLink::instance ()->copyCurrentSymbolTable (); - if (symbolTable.size ()) - { - m_mainWindow->variablesDockWidget ()-> - setVariablesList (symbolTable); - } - - OctaveLink::instance ()->updateHistoryModel (); - usleep (500000); - } - } -private: - MainWindow * m_mainWindow; -}; - #endif // MAINWINDOW_H
new file mode 100644 --- /dev/null +++ b/gui/src/OctaveCallbackThread.cpp @@ -0,0 +1,26 @@ +#include "OctaveCallbackThread.h" + +OctaveCallbackThread::OctaveCallbackThread (QObject * parent, + MainWindow * mainWindow):QThread (parent), + m_mainWindow (mainWindow) +{ +} + +void +OctaveCallbackThread::run () +{ + while (m_mainWindow->isRunning ()) + { + OctaveLink::instance ()->fetchSymbolTable (); + + // Get a full variable list. + QList < SymbolRecord > symbolTable = OctaveLink::instance ()->copyCurrentSymbolTable (); + if (symbolTable.size ()) + { + m_mainWindow->variablesDockWidget ()->setVariablesList (symbolTable); + } + + OctaveLink::instance ()->updateHistoryModel (); + usleep (500000); + } +}
new file mode 100644 --- /dev/null +++ b/gui/src/OctaveCallbackThread.h @@ -0,0 +1,19 @@ +#ifndef OCTAVECALLBACKTHREAD_H +#define OCTAVECALLBACKTHREAD_H + +#include <QThread> +#include "MainWindow.h" + +class OctaveCallbackThread:public QThread +{ + Q_OBJECT +public: + OctaveCallbackThread (QObject * parent, MainWindow * mainWindow); + +protected: + void run (); +private: + MainWindow * m_mainWindow; +}; + +#endif // OCTAVECALLBACKTHREAD_H
new file mode 100644 --- /dev/null +++ b/gui/src/OctaveMainThread.cpp @@ -0,0 +1,16 @@ +#include "OctaveMainThread.h" + +OctaveMainThread::OctaveMainThread (QObject * parent):QThread (parent) +{ +} + +void +OctaveMainThread::run () +{ + int argc = 3; + const char *argv[] = { "octave", "--interactive", "--line-editing" }; + octave_main (argc, (char **) argv, 1); + emit ready(); + main_loop (); + clean_up_and_exit (0); +}
new file mode 100644 --- /dev/null +++ b/gui/src/OctaveMainThread.h @@ -0,0 +1,20 @@ +#ifndef OCTAVEMAINTHREAD_H +#define OCTAVEMAINTHREAD_H + +#include <QThread> +#include "OctaveLink.h" + +class OctaveMainThread:public QThread +{ + Q_OBJECT +public: + OctaveMainThread (QObject * parent); + +signals: + void ready(); + +protected: + void run (); +}; + +#endif // OCTAVEMAINTHREAD_H