Mercurial > hg > octave-terminal
changeset 13519:35ecb6063c7b
Made the view connect with the history model.
author | Jacob Dawid <jacob.dawid@googlemail.com> |
---|---|
date | Tue, 19 Jul 2011 16:14:14 +0200 |
parents | bace956a3724 |
children | 17bb8974577b |
files | gui/src/OctaveLink.cpp gui/src/OctaveLink.h |
diffstat | 2 files changed, 14 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/gui/src/OctaveLink.cpp +++ b/gui/src/OctaveLink.cpp @@ -28,10 +28,9 @@ OctaveLink::m_singleton; -OctaveLink::OctaveLink ():QObject (), m_previousHistoryLength (0) +OctaveLink::OctaveLink ():QObject () { m_symbolTableSemaphore = new QSemaphore (1); - m_historySemaphore = new QSemaphore (1); m_historyModel = new QStringListModel (this); } @@ -136,22 +135,21 @@ void OctaveLink::updateHistoryModel () { - // TODO: Use the following code to update the history model. - /* - int currentLen = command_history::length (); - if (currentLen != m_previousHistoryLength) + // Determine the client's (our) history length and the one of the server. + int clientHistoryLength = m_history.length (); + int serverHistoryLength = command_history::length (); + + // If were behind the server, iterate through all new entries and add them to our history. + if (clientHistoryLength < serverHistoryLength) { - m_historySemaphore->acquire (); - for (int i = m_previousHistoryLength; i < currentLen; i++) + for (int i = clientHistoryLength; i < serverHistoryLength; i++) { - QString entry = QString(command_history::get_entry (i).c_str()); - if (!entry.startsWith ("#")) - m_historyBuffer.append (entry); + m_history.insert (0, QString (command_history::get_entry (i).c_str ())); } - m_historySemaphore->release (); - m_previousHistoryLength = currentLen; } - */ + + // Update the model by setting the new history. + m_historyModel->setStringList (m_history); } QStringListModel *
--- a/gui/src/OctaveLink.h +++ b/gui/src/OctaveLink.h @@ -138,9 +138,8 @@ /** History related member variables. */ QStringListModel *m_historyModel; - QSemaphore *m_historySemaphore; - QStringList m_historyBuffer; - int m_previousHistoryLength; + QStringList m_history; + static OctaveLink m_singleton; }; #endif // OCTAVELINK_H