Mercurial > hg > octave-lyh
changeset 13384:c834fd0128fb
Command history updates automatically.
author | Jacob Dawid <jacob.dawid@googlemail.com> |
---|---|
date | Sat, 09 Apr 2011 10:24:55 +0200 |
parents | 44e8f4823151 |
children | 0b780509d3ac |
files | gui//src/TerminalMdiSubWindow.cpp gui//src/TerminalMdiSubWindow.h |
diffstat | 2 files changed, 22 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/gui//src/TerminalMdiSubWindow.cpp +++ b/gui//src/TerminalMdiSubWindow.cpp @@ -1,7 +1,8 @@ #include "TerminalMdiSubWindow.h" #include <QHBoxLayout> #include <QVBoxLayout> - +#include <QStringListModel> +#include <QStringList> bool is_inside_main_loop = false; bool is_cleanup_complete = false; @@ -72,7 +73,7 @@ m_terminalWidget = new QTerminalWidget(0, hWidget); m_terminalWidget->setScrollBarPosition(QTerminalWidget::ScrollBarRight); m_terminalWidget->setShellProgram("octave"); - // m_terminalWidget->startShellProgram(); + // m_terminalWidget->startShellProgram(); m_terminalWidget->openTeletype(fdm); m_terminalWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); m_terminalWidget->setColorScheme(QTerminalWidget::BlackOnLightYellow); @@ -81,7 +82,8 @@ QVBoxLayout *hvBoxLayout = new QVBoxLayout(); m_variableView = new QTreeView(hWidget); m_commandHistoryView = new QListView(hWidget); - hvWidget->setMaximumWidth(250); + m_commandHistoryView->setModel(new QStringListModel()); + hvWidget->setMaximumWidth(300); hvBoxLayout->addWidget(new QLabel("Variables", hWidget)); hvBoxLayout->addWidget(m_variableView); hvBoxLayout->addWidget(new QLabel("Command History", hWidget)); @@ -104,9 +106,20 @@ m_statusBar->showMessage("Ready."); } +void TerminalMdiSubWindow::updateHistory(string_vector historyEntries) { + QStringListModel * model = dynamic_cast<QStringListModel*>(m_commandHistoryView->model()); + if(!model) + return; + + QStringList stringList = model->stringList(); + for(size_t i = 0; i < historyEntries.length(); i++) + stringList.append(QString(historyEntries[i].c_str())); + + model->setStringList(stringList); +} + bool ui_can_interrupt = true; -void* TerminalMdiSubWindow::octave_monitor(void *octaveUI) -{ +void* TerminalMdiSubWindow::octave_monitor(void *octaveUI) { TerminalMdiSubWindow* oui = (TerminalMdiSubWindow*)octaveUI; while ( oui->isRunning ) @@ -115,9 +128,7 @@ std::vector<OctaveLink::VariableMetaData> variables = oct_octave_server.variableInfoList(); if ( variables.size() > 0 ) { - qDebug("Update variables."); - //oui->mVariablesTreeView.clearRows(); - //oui->mVariablesTreeView.addVariables(variables); + //qDebug("Update variables."); } // Check whether any requested variables have been returned @@ -133,9 +144,8 @@ string_vector historyList = oct_octave_server.getHistoryList(); if( historyList.length() > 0 ) { - qDebug("Update history."); - //oui->mHistoryTreeView.addRows(historyList); - //oui->historyListWidget->addRows(historyList); + //qDebug("Update history."); + oui->updateHistory(historyList); } // Put a marker in each buffer at the proper location
--- a/gui//src/TerminalMdiSubWindow.h +++ b/gui//src/TerminalMdiSubWindow.h @@ -66,6 +66,7 @@ */ bool isMonitorRunning() { return this->isRunning; } + void updateHistory(string_vector historyEntries); static void* octave_monitor(void *octaveUI); TerminalMdiSubWindow(QWidget *parent = 0); ~TerminalMdiSubWindow();