# HG changeset patch # User Jacob Dawid # Date 1337670826 -7200 # Node ID 6a6733a5598298f3017b95ee7e630d9a372db39b # Parent 664f54233c9804f6d14797e118bea46c080f7343 Removed unused classes and added octave loop hook. * OctaveGUI.cpp: Removed header for command line parsing and command line parser. * WorkspaceModel: Optimized updated the model from the symbol table by passing pointers instead of copying. * OctaveLink: Removed polling thread. * src.pro: Removed deleted files. * OctaveCallbackThread: Not used anymore, hence removed. * CommandLineParser: Not used anymore, hence removed. * ReadlineAdapter: Not used anymore, hence removed. diff -r 664f54233c98 -r 6a6733a55982 gui/src/CommandLineParser.cpp --- a/gui/src/CommandLineParser.cpp Sun May 20 22:05:49 2012 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,47 +0,0 @@ -/* OctaveGUI - A graphical user interface for Octave - * Copyright (C) 2011 Jacob Dawid (jacob.dawid@googlemail.com) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include "CommandLineParser.h" - -CommandLineParser::CommandLineParser () -{ -} - -void -CommandLineParser::registerOption (CommandLineOption commandLineOption) -{ - if (m_registeredCommandLineOptions.contains(commandLineOption)) - m_registeredCommandLineOptions.append(commandLineOption); -} - -void -CommandLineParser::registerOption (QString longOption, QString shortOption, QString description, bool withArgument) -{ - CommandLineOption commandLineOption; - commandLineOption.longOption = longOption; - commandLineOption.shortOption = shortOption; - commandLineOption.description = description; - commandLineOption.withArgument = withArgument; - registerOption (commandLineOption); -} - -void -CommandLineParser::parse (int argc, char** argv) -{ - Q_UNUSED(argc); - Q_UNUSED(argv); -} diff -r 664f54233c98 -r 6a6733a55982 gui/src/CommandLineParser.h --- a/gui/src/CommandLineParser.h Sun May 20 22:05:49 2012 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,50 +0,0 @@ -/* OctaveGUI - A graphical user interface for Octave - * Copyright (C) 2011 Jacob Dawid (jacob.dawid@googlemail.com) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef COMMANDLINEPARSER_H -#define COMMANDLINEPARSER_H - -#include -#include - -class CommandLineParser -{ -public: - struct CommandLineOption - { - QString longOption; - QString shortOption; - QString description; - bool withArgument; - - bool operator== (CommandLineOption other) - { - return longOption == other.longOption - || shortOption == other.shortOption; - } - }; - - CommandLineParser (); - void registerOption (CommandLineOption commandLineOption); - void registerOption (QString longOption, QString shortOption, QString description, bool withArgument); - void parse (int argc, char** argv); - -private: - QList m_registeredCommandLineOptions; -}; - -#endif // COMMANDLINEPARSER_H diff -r 664f54233c98 -r 6a6733a55982 gui/src/OctaveGUI.cpp --- a/gui/src/OctaveGUI.cpp Sun May 20 22:05:49 2012 +0200 +++ b/gui/src/OctaveGUI.cpp Tue May 22 09:13:46 2012 +0200 @@ -18,7 +18,6 @@ #include #include #include -#include "CommandLineParser.h" #include "WelcomeWizard.h" #include "ResourceManager.h" #include "MainWindow.h" @@ -71,10 +70,6 @@ } else { - CommandLineParser commandLineParser; - commandLineParser.registerOption ("--config", "-c", "Tells OctaveGUI to use that configuration file.", true); - commandLineParser.parse (argc, argv); - QSettings *settings = ResourceManager::instance ()->settings (); QString language = settings->value ("language").toString (); diff -r 664f54233c98 -r 6a6733a55982 gui/src/WorkspaceModel.cpp --- a/gui/src/WorkspaceModel.cpp Sun May 20 22:05:49 2012 +0200 +++ b/gui/src/WorkspaceModel.cpp Tue May 22 09:13:46 2012 +0200 @@ -135,12 +135,11 @@ } void -WorkspaceModel::updateTreeEntry (TreeItem * treeItem, symbol_table::symbol_record symbolRecord) +WorkspaceModel::updateTreeEntry (TreeItem * treeItem, symbol_table::symbol_record *symbolRecord) { - treeItem->setData (0, QString (symbolRecord.name ().c_str ())); - treeItem->setData (1, QString (symbolRecord.varval ().type_name ().c_str ())); - treeItem->setData (2, octaveValueAsQString (symbolRecord.varval ())); - emit dataChanged(index(treeItem->row(), 0), index(treeItem->row(), 2)); + treeItem->setData (0, QString (symbolRecord->name ().c_str ())); + treeItem->setData (1, QString (symbolRecord->varval ().type_name ().c_str ())); + treeItem->setData (2, octaveValueAsQString (symbolRecord->varval ())); } void @@ -149,10 +148,10 @@ std::list < symbol_table::symbol_record > allVariables = symbol_table::all_variables (); // Split the symbol table into its different categories. - QList < symbol_table::symbol_record > localSymbolTable; - QList < symbol_table::symbol_record > globalSymbolTable; - QList < symbol_table::symbol_record > persistentSymbolTable; - QList < symbol_table::symbol_record > hiddenSymbolTable; + QList < symbol_table::symbol_record* > localSymbolTable; + QList < symbol_table::symbol_record* > globalSymbolTable; + QList < symbol_table::symbol_record* > persistentSymbolTable; + QList < symbol_table::symbol_record* > hiddenSymbolTable; for (std::list < symbol_table::symbol_record > ::iterator iterator = allVariables.begin (); iterator != allVariables.end (); iterator++) @@ -161,22 +160,22 @@ // but we want to distinguish that here. if (iterator->is_local () && !iterator->is_global () && !iterator->is_hidden ()) { - localSymbolTable.append (iterator->dup (symbol_table::global_scope ())); + localSymbolTable.append (&(*iterator)); } if (iterator->is_global ()) { - globalSymbolTable.append (iterator->dup (symbol_table::global_scope ())); + globalSymbolTable.append (&(*iterator)); } if (iterator->is_persistent ()) { - persistentSymbolTable.append (iterator->dup (symbol_table::global_scope ())); + persistentSymbolTable.append (&(*iterator)); } if (iterator->is_hidden ()) { - hiddenSymbolTable.append (iterator->dup (symbol_table::global_scope ())); + hiddenSymbolTable.append (&(*iterator)); } } @@ -184,10 +183,12 @@ updateCategory (1, globalSymbolTable); updateCategory (2, persistentSymbolTable); updateCategory (3, hiddenSymbolTable); + reset(); + emit expandRequest(); } void -WorkspaceModel::updateCategory (int topLevelItemIndex, QList < symbol_table::symbol_record > symbolTable) +WorkspaceModel::updateCategory (int topLevelItemIndex, QList < symbol_table::symbol_record* > symbolTable) { // This method may be a little bit confusing; variablesList is a complete list of all // variables that are in the workspace currently. @@ -195,7 +196,7 @@ // First we check, if any variables that exist in the model tree have to be updated // or created. So we walk the variablesList check against the tree. - foreach (symbol_table::symbol_record symbolRecord, symbolTable) + foreach (symbol_table::symbol_record *symbolRecord, symbolTable) { int childCount = treeItem->childCount (); bool alreadyExists = false; @@ -207,7 +208,7 @@ { child = treeItem->child (i); if (child->data (0).toString () == - QString (symbolRecord.name ().c_str ())) + QString (symbolRecord->name ().c_str ())) { alreadyExists = true; break; @@ -233,9 +234,9 @@ { bool existsInVariableList = false; TreeItem *child = treeItem->child (i); - foreach (symbol_table::symbol_record symbolRecord, symbolTable) + foreach (symbol_table::symbol_record *symbolRecord, symbolTable) { - if (QString (symbolRecord.name ().c_str ()) == + if (QString (symbolRecord->name ().c_str ()) == child->data (0).toString ()) { existsInVariableList = true; @@ -252,7 +253,7 @@ } QString -WorkspaceModel::octaveValueAsQString (octave_value octaveValue) +WorkspaceModel::octaveValueAsQString (const octave_value& octaveValue) { // Convert single qouted string. if (octaveValue.is_sq_string ()) diff -r 664f54233c98 -r 6a6733a55982 gui/src/WorkspaceModel.h --- a/gui/src/WorkspaceModel.h Sun May 20 22:05:49 2012 +0200 +++ b/gui/src/WorkspaceModel.h Tue May 22 09:13:46 2012 +0200 @@ -92,7 +92,7 @@ QVariant data(int column) const { - return _itemData.value(column); + return _itemData[column]; } void setData(int column, QVariant data) @@ -101,7 +101,7 @@ } TreeItem *child(int row) { - return _childItems.value(row); + return _childItems[row]; } int childCount() const { @@ -153,9 +153,12 @@ TreeItem *topLevelItem (int at); void updateFromSymbolTable (); - void updateTreeEntry (TreeItem * treeItem, symbol_table::symbol_record symbolRecord); - void updateCategory (int topLevelItemIndex, QList < symbol_table::symbol_record > symbolTable); - QString octaveValueAsQString (octave_value octaveValue); + void updateTreeEntry (TreeItem * treeItem, symbol_table::symbol_record *symbolRecord); + void updateCategory (int topLevelItemIndex, QList < symbol_table::symbol_record *> symbolTable); + QString octaveValueAsQString (const octave_value &octaveValue); + +signals: + void expandRequest(); private: TreeItem *_rootItem; diff -r 664f54233c98 -r 6a6733a55982 gui/src/WorkspaceView.cpp --- a/gui/src/WorkspaceView.cpp Sun May 20 22:05:49 2012 +0200 +++ b/gui/src/WorkspaceView.cpp Tue May 22 09:13:46 2012 +0200 @@ -41,7 +41,7 @@ connect (this, SIGNAL (visibilityChanged (bool)), this, SLOT(handleVisibilityChanged (bool))); - connect (OctaveLink::instance()->workspaceModel(), SIGNAL(dataChanged(QModelIndex,QModelIndex)), + connect (OctaveLink::instance()->workspaceModel(), SIGNAL(expandRequest()), m_workspaceTreeView, SLOT(expandAll())); } diff -r 664f54233c98 -r 6a6733a55982 gui/src/backend/OctaveCallbackThread.cpp --- a/gui/src/backend/OctaveCallbackThread.cpp Sun May 20 22:05:49 2012 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,50 +0,0 @@ -/* OctaveGUI - A graphical user interface for Octave - * Copyright (C) 2011 Jacob Dawid (jacob.dawid@googlemail.com) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include "OctaveCallbackThread.h" -#include "MainWindow.h" - -OctaveCallbackThread::OctaveCallbackThread (QObject * parent) - : QThread (parent) -{ - m_runningSemaphore = new QSemaphore(1); - m_running = true; -} - -void -OctaveCallbackThread::halt () -{ - m_runningSemaphore->acquire (); - m_running = false; - m_runningSemaphore->release (); -} - -void -OctaveCallbackThread::run () -{ - bool running = true; - while (running) - { - OctaveLink::instance ()->triggerUpdateSymbolTable (); - OctaveLink::instance ()->triggerUpdateHistoryModel (); - usleep (1000000); - - m_runningSemaphore->acquire (); - running = m_running; - m_runningSemaphore->release (); - } -} diff -r 664f54233c98 -r 6a6733a55982 gui/src/backend/OctaveCallbackThread.h --- a/gui/src/backend/OctaveCallbackThread.h Sun May 20 22:05:49 2012 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,37 +0,0 @@ -/* OctaveGUI - A graphical user interface for Octave - * Copyright (C) 2011 Jacob Dawid (jacob.dawid@googlemail.com) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef OCTAVECALLBACKTHREAD_H -#define OCTAVECALLBACKTHREAD_H - -#include -#include - -class OctaveCallbackThread:public QThread -{ - Q_OBJECT -public: - void halt(); - OctaveCallbackThread (QObject * parent); -protected: - void run (); -private: - QSemaphore *m_runningSemaphore; - bool m_running; -}; - -#endif // OCTAVECALLBACKTHREAD_H diff -r 664f54233c98 -r 6a6733a55982 gui/src/backend/OctaveLink.cpp --- a/gui/src/backend/OctaveLink.cpp Sun May 20 22:05:49 2012 +0200 +++ b/gui/src/backend/OctaveLink.cpp Tue May 22 09:13:46 2012 +0200 @@ -17,6 +17,13 @@ #include "OctaveLink.h" +void octave_loop_hook_impl() +{ + OctaveLink::instance()->triggerUpdateHistoryModel(); + OctaveLink::instance()->triggerUpdateSymbolTable(); +} + + OctaveLink OctaveLink::m_singleton; OctaveLink::OctaveLink ():QObject () @@ -39,10 +46,7 @@ { // Create both threads. m_octaveMainThread = new OctaveMainThread (this); - m_octaveCallbackThread = new OctaveCallbackThread (this); - - // Launch the second as soon as the first ist ready. - connect (m_octaveMainThread, SIGNAL (ready ()), m_octaveCallbackThread, SLOT (start ())); + octave_loop_hook = octave_loop_hook_impl; // Start the first one. m_octaveMainThread->start (); @@ -51,11 +55,8 @@ void OctaveLink::terminateOctave () { - m_octaveCallbackThread->halt (); - m_octaveCallbackThread->wait (); - m_octaveMainThread->terminate (); - //m_octaveMainThread->wait(); + m_octaveMainThread->wait(); } void diff -r 664f54233c98 -r 6a6733a55982 gui/src/backend/OctaveLink.h --- a/gui/src/backend/OctaveLink.h Sun May 20 22:05:49 2012 +0200 +++ b/gui/src/backend/OctaveLink.h Tue May 22 09:13:46 2012 +0200 @@ -73,7 +73,6 @@ #include #include "WorkspaceModel.h" -#include "OctaveCallbackThread.h" #include "OctaveMainThread.h" /** @@ -102,15 +101,11 @@ OctaveLink (); ~OctaveLink (); - //QSemaphore * m_symbolTableSemaphore; - //QList < symbol_table::symbol_record > m_symbolTableBuffer; - QStringListModel *m_historyModel; WorkspaceModel *m_workspaceModel; // Threads for running octave and managing the data interaction. OctaveMainThread *m_octaveMainThread; - OctaveCallbackThread *m_octaveCallbackThread; static OctaveLink m_singleton; }; diff -r 664f54233c98 -r 6a6733a55982 gui/src/backend/ReadlineAdapter.cpp --- a/gui/src/backend/ReadlineAdapter.cpp Sun May 20 22:05:49 2012 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,23 +0,0 @@ -/* OctaveGUI - A graphical user interface for Octave - * Copyright (C) 2011 Jacob Dawid (jacob.dawid@googlemail.com) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include "ReadlineAdapter.h" - -ReadlineAdapter::ReadlineAdapter (QObject *parent) : - QObject (parent), command_editor () -{ -} diff -r 664f54233c98 -r 6a6733a55982 gui/src/backend/ReadlineAdapter.h --- a/gui/src/backend/ReadlineAdapter.h Sun May 20 22:05:49 2012 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,37 +0,0 @@ -/* OctaveGUI - A graphical user interface for Octave - * Copyright (C) 2011 Jacob Dawid (jacob.dawid@googlemail.com) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef READLINEADAPTER_H -#define READLINEADAPTER_H - -#include "octave/config.h" -#include "octave/cmd-edit.h" -#include - -class ReadlineAdapter : public QObject, public command_editor -{ - Q_OBJECT -public: - explicit ReadlineAdapter (QObject *parent = 0); - -signals: - -public slots: - -}; - -#endif // READLINEADAPTER_H diff -r 664f54233c98 -r 6a6733a55982 gui/src/src.pro --- a/gui/src/src.pro Sun May 20 22:05:49 2012 +0200 +++ b/gui/src/src.pro Tue May 22 09:13:46 2012 +0200 @@ -82,11 +82,8 @@ SettingsDialog.cpp \ OctaveGUI.cpp \ ResourceManager.cpp \ - CommandLineParser.cpp \ - backend/OctaveCallbackThread.cpp \ backend/OctaveLink.cpp \ backend/OctaveMainThread.cpp \ - backend/ReadlineAdapter.cpp \ WelcomeWizard.cpp \ FileEditor.cpp \ WorkspaceModel.cpp @@ -99,11 +96,8 @@ FilesDockWidget.h \ SettingsDialog.h \ ResourceManager.h \ - CommandLineParser.h \ - backend/OctaveCallbackThread.h \ backend/OctaveLink.h \ backend/OctaveMainThread.h \ - backend/ReadlineAdapter.h \ WelcomeWizard.h \ FileEditor.h \ WorkspaceModel.h