changeset 13517:86adc9c4ec4b

History deactivated.
author Jacob Dawid <jacob.dawid@googlemail.com>
date Tue, 19 Jul 2011 15:18:47 +0200
parents d53287c44e5a
children bace956a3724
files gui/src/HistoryDockWidget.cpp gui/src/HistoryDockWidget.h gui/src/MainWindow.cpp gui/src/MainWindow.h gui/src/OctaveLink.cpp gui/src/OctaveLink.h gui/src/OctaveTerminal.cpp gui/src/OctaveTerminal.h
diffstat 8 files changed, 83 insertions(+), 142 deletions(-) [+]
line wrap: on
line diff
--- a/gui/src/HistoryDockWidget.cpp	Tue Jul 19 13:17:18 2011 +0200
+++ b/gui/src/HistoryDockWidget.cpp	Tue Jul 19 15:18:47 2011 +0200
@@ -49,22 +49,14 @@
   layout->setMargin (2);
 
   widget ()->setLayout (layout);
-  connect (m_historyListView, SIGNAL (doubleClicked (QModelIndex)), this,
-	   SLOT (handleListViewItemDoubleClicked (QModelIndex)));
+  //connect (m_historyListView, SIGNAL (doubleClicked (QModelIndex)), this,
+  //	   SLOT (handleListViewItemDoubleClicked (QModelIndex)));
 }
 
 void
-HistoryDockWidget::updateHistory (string_vector historyEntries)
-{
-  QStringList stringList = m_historyListModel->stringList ();
-  for (int i = 0; i < historyEntries.length (); i++)
-    {
-      QString command (historyEntries[i].c_str ());
-      if (!command.startsWith ("#"))
-	{
-	  stringList.push_front (command);
-	}
-    }
-  m_historyListModel->setStringList (stringList);
+HistoryDockWidget::updateHistory (QStringList history)
+{/*
+  m_historyListModel->setStringList (history);
   emit information (tr ("History updated."));
+  */
 }
--- a/gui/src/HistoryDockWidget.h	Tue Jul 19 13:17:18 2011 +0200
+++ b/gui/src/HistoryDockWidget.h	Tue Jul 19 15:18:47 2011 +0200
@@ -23,44 +23,19 @@
 #include <QListView>
 #include <QStringListModel>
 
-// Octave includes
-#undef PACKAGE_BUGREPORT
-#undef PACKAGE_NAME
-#undef PACKAGE_STRING
-#undef PACKAGE_TARNAME
-#undef PACKAGE_VERSION
-#undef PACKAGE_URL
-#include "octave/config.h"
-
-#include "octave/debug.h"
-#include "octave/octave.h"
-#include "octave/symtab.h"
-#include "octave/parse.h"
-#include "octave/unwind-prot.h"
-#include "octave/toplev.h"
-#include "octave/load-path.h"
-#include "octave/error.h"
-#include "octave/quit.h"
-#include "octave/variables.h"
-#include "octave/sighandlers.h"
-#include "octave/sysdep.h"
-#include "octave/str-vec.h"
-#include "octave/cmd-hist.h"
-#include "octave/cmd-edit.h"
-#include "octave/oct-env.h"
-#include "octave/symtab.h"
-#include "cmd-edit.h"
-
 class HistoryDockWidget:public QDockWidget
 {
-Q_OBJECT public:
-  HistoryDockWidget (QWidget * parent = 0);
-  void updateHistory (string_vector historyEntries);
+Q_OBJECT
+public:
+  HistoryDockWidget (QWidget *parent = 0);
+  void updateHistory (QStringList history);
 
-    signals:void information (QString message);
+signals:
+  void information (QString message);
   void commandDoubleClicked (QString command);
 
-  private slots:void handleListViewItemDoubleClicked (QModelIndex modelIndex);
+private slots:
+  void handleListViewItemDoubleClicked (QModelIndex modelIndex);
 
 private:
   void construct ();
--- a/gui/src/MainWindow.cpp	Tue Jul 19 13:17:18 2011 +0200
+++ b/gui/src/MainWindow.cpp	Tue Jul 19 15:18:47 2011 +0200
@@ -26,6 +26,7 @@
 #include "FileEditorMdiSubWindow.h"
 #include "ImageViewerMdiSubWindow.h"
 #include "SettingsDialog.h"
+#include "cmd-edit.h"
 
 MainWindow::MainWindow (QWidget * parent):QMainWindow (parent),
 m_isRunning (true)
@@ -278,16 +279,6 @@
   m_octaveCallbackThread->start ();
 
   command_editor::add_event_hook (OctaveLink::readlineEventHook);
-
-  int fdm, fds;
-  if (openpty (&fdm, &fds, 0, 0, 0) < 0)
-    {
-      assert (0);
-    }
-  dup2 (fds, 0);
-  dup2 (fds, 1);
-  dup2 (fds, 2);
-
-  m_octaveTerminal->openTeletype (fdm);
+  m_octaveTerminal->openTerminal ();
   reportStatusMessage (tr ("Established link to Octave."));
 }
--- a/gui/src/MainWindow.h	Tue Jul 19 13:17:18 2011 +0200
+++ b/gui/src/MainWindow.h	Tue Jul 19 15:18:47 2011 +0200
@@ -34,49 +34,6 @@
 #include "BrowserWidget.h"
 #include "IRCWidget.h"
 
-// Octave includes
-#undef PACKAGE_BUGREPORT
-#undef PACKAGE_NAME
-#undef PACKAGE_STRING
-#undef PACKAGE_TARNAME
-#undef PACKAGE_VERSION
-#undef PACKAGE_URL
-#include "octave/config.h"
-
-#include "octave/debug.h"
-#include "octave/octave.h"
-#include "octave/symtab.h"
-#include "octave/parse.h"
-#include "octave/unwind-prot.h"
-#include "octave/toplev.h"
-#include "octave/load-path.h"
-#include "octave/error.h"
-#include "octave/quit.h"
-#include "octave/variables.h"
-#include "octave/sighandlers.h"
-#include "octave/sysdep.h"
-#include "octave/str-vec.h"
-#include "octave/cmd-hist.h"
-#include "octave/cmd-edit.h"
-#include "octave/oct-env.h"
-#include "octave/symtab.h"
-#include "cmd-edit.h"
-
-typedef struct yy_buffer_state *YY_BUFFER_STATE;
-extern OCTINTERP_API YY_BUFFER_STATE create_buffer (FILE * f);
-extern OCTINTERP_API void switch_to_buffer (YY_BUFFER_STATE buf);
-extern OCTINTERP_API FILE *get_input_from_stdin (void);
-
-// System
-#include <termios.h>
-#include <sys/types.h>
-#include <signal.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <iostream>
-#include <vector>
-#include "pty.h"
-
 class OctaveMainThread;
 class OctaveCallbackThread;
 
@@ -200,11 +157,10 @@
 	  }
 
 	// Collect history list.
-	string_vector historyList =
-	  OctaveLink::instance ()->currentHistory ();
-	if (historyList.length ())
+        QStringList history = OctaveLink::instance ()->currentHistory ();
+        if (history.length ())
 	  {
-	    m_mainWindow->historyDockWidget ()->updateHistory (historyList);
+            m_mainWindow->historyDockWidget ()->updateHistory (history);
 	  }
 
 	usleep (100000);
--- a/gui/src/OctaveLink.cpp	Tue Jul 19 13:17:18 2011 +0200
+++ b/gui/src/OctaveLink.cpp	Tue Jul 19 15:18:47 2011 +0200
@@ -128,7 +128,9 @@
       m_historySemaphore->acquire ();
       for (int i = m_previousHistoryLength; i < currentLen; i++)
 	{
-	  m_historyBuffer.append (command_history::get_entry (i));
+          QString entry = QString(command_history::get_entry (i).c_str());
+          if (!entry.startsWith ("#"))
+            m_historyBuffer.append (entry);
 	}
       m_historySemaphore->release ();
       m_previousHistoryLength = currentLen;
@@ -149,14 +151,13 @@
   return m_symbolTableCopy;
 }
 
-string_vector
+QStringList
 OctaveLink::currentHistory ()
 {
   m_historySemaphore->acquire ();
-  string_vector retval (m_historyBuffer);
-  m_historyBuffer = string_vector ();
+  QStringList historyBuffer = m_historyBuffer;
   m_historySemaphore->release ();
-  return retval;
+  return historyBuffer;
 }
 
 void
--- a/gui/src/OctaveLink.h	Tue Jul 19 13:17:18 2011 +0200
+++ b/gui/src/OctaveLink.h	Tue Jul 19 15:18:47 2011 +0200
@@ -75,23 +75,19 @@
 #include <QFileInfo>
 #include <QList>
 #include <QString>
+#include <QStringList>
 #include <QVector>
 #include <QSemaphore>
 #include <QObject>
 
-typedef
-  symbol_table::symbol_record
-  SymbolRecord;
-typedef octave_value
-  OctaveValue;
+typedef symbol_table::symbol_record SymbolRecord;
+typedef octave_value OctaveValue;
 
 /**
   * \class OctaveLink
   * Manages a link to an octave instance.
   */
-class
-  OctaveLink:
-  QObject
+class OctaveLink:QObject
 {
   Q_OBJECT
 public:
@@ -105,33 +101,33 @@
   static QString
   octaveValueAsQString (OctaveValue octaveValue);
 
-    /**
-      * Returns a copy of the current symbol table buffer.
-      * \return Copy of the current symbol table buffer.
-      */
+  /**
+    * Returns a copy of the current symbol table buffer.
+    * \return Copy of the current symbol table buffer.
+    */
   QList < SymbolRecord > currentSymbolTable ();
 
-    /**
-      * Returns a copy of the current history buffer.
-      * \return Copy of the current history buffer.
-      */
-  string_vector
+  /**
+    * Returns a copy of the current history buffer.
+    * \return Copy of the current history buffer.
+    */
+  QStringList
   currentHistory ();
 
   void
   processOctaveServerData ();
 
-    /**
-      * Updates the current symbol table with new data
-      * from octave.
-      */
+  /**
+    * Updates the current symbol table with new data
+    * from octave.
+    */
   void
   fetchSymbolTable ();
 
-    /**
-      * Updates the current history buffer with new data
-      * from octave.
-      */
+  /**
+    * Updates the current history buffer with new data
+    * from octave.
+    */
   void
   fetchHistory ();
 
@@ -145,13 +141,13 @@
   OctaveLink ();
   ~OctaveLink ();
 
-    /** Variable related member variables. */
+  /** Variable related member variables. */
   QSemaphore * m_symbolTableSemaphore;
   QList < SymbolRecord > m_symbolTableBuffer;
 
-    /** History related member variables. */
+  /** History related member variables. */
   QSemaphore *m_historySemaphore;
-  string_vector m_historyBuffer;
+  QStringList m_historyBuffer;
   int m_previousHistoryLength;
   static OctaveLink m_singleton;
 };
--- a/gui/src/OctaveTerminal.cpp	Tue Jul 19 13:17:18 2011 +0200
+++ b/gui/src/OctaveTerminal.cpp	Tue Jul 19 15:18:47 2011 +0200
@@ -22,7 +22,11 @@
 #include <QStringListModel>
 #include <QStringList>
 
-OctaveTerminal::OctaveTerminal (QWidget * parent):QTerminalWidget (0, parent)
+#include "pty.h"
+#include "unistd.h"
+#include <assert.h>
+
+OctaveTerminal::OctaveTerminal (QWidget * parent):QWidget (parent)
 {
   construct ();
 }
@@ -34,5 +38,26 @@
 void
 OctaveTerminal::construct ()
 {
-  setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Expanding);
+  m_terminalWidget = new QTerminalWidget (0, this);
+  m_terminalWidget->setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Expanding);
+  setFocusProxy (m_terminalWidget);
+
+  QVBoxLayout *layout = new QVBoxLayout ();
+  layout->addWidget (m_terminalWidget);
+  setLayout (layout);
 }
+
+void
+OctaveTerminal::openTerminal ()
+{
+  int fdm, fds;
+  if (openpty (&fdm, &fds, 0, 0, 0) < 0)
+    {
+      assert (0);
+    }
+  dup2 (fds, 0);
+  dup2 (fds, 1);
+  dup2 (fds, 2);
+
+  m_terminalWidget->openTeletype (fdm);
+}
--- a/gui/src/OctaveTerminal.h	Tue Jul 19 13:17:18 2011 +0200
+++ b/gui/src/OctaveTerminal.h	Tue Jul 19 15:18:47 2011 +0200
@@ -18,15 +18,20 @@
 
 #ifndef OCTAVETERMINAL_H
 #define OCTAVETERMINAL_H
+#include <QWidget>
 #include "QTerminalWidget.h"
 
-class OctaveTerminal:public QTerminalWidget
+class OctaveTerminal:public QWidget
 {
-Q_OBJECT public:
+Q_OBJECT
+public:
   OctaveTerminal (QWidget * parent = 0);
   ~OctaveTerminal ();
 
+  void sendText (QString text) { m_terminalWidget->sendText(text); }
+  void openTerminal ();
 private:
   void construct ();
+  QTerminalWidget *m_terminalWidget;
 };
 #endif // OCTAVETERMINAL_H