comparison gui/src/backend/OctaveLink.cpp @ 14700:7623bece76df gui

Implemented logic for current directory bar. * MainWindow: Changed current working directory line edit to combo box. Added various signals and slots. * OctaveLink: Added signal that will be emitted whenever a current directory change occurs.
author Jacob Dawid <jacob.dawid@googlemail.com>
date Tue, 29 May 2012 19:08:05 +0200
parents 79c9a6d06590
children
comparison
equal deleted inserted replaced
14699:0bab96aeb995 14700:7623bece76df
15 * along with this program. If not, see <http://www.gnu.org/licenses/>. 15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 #include "OctaveLink.h" 18 #include "OctaveLink.h"
19 #include "load-path.h" 19 #include "load-path.h"
20 #include "oct-env.h"
20 #include <QDir> 21 #include <QDir>
21 #include <QApplication> 22 #include <QApplication>
22 23
23 int octave_readline_hook () 24 int octave_readline_hook ()
24 { 25 {
25 OctaveLink::instance ()->triggerUpdateHistoryModel (); 26 OctaveLink::instance ()->triggerUpdateHistoryModel ();
26 OctaveLink::instance ()->buildSymbolInformation (); 27 OctaveLink::instance ()->buildSymbolInformation ();
27 QDir::setCurrent (load_path::get_command_line_path ().c_str ()); 28 OctaveLink::instance ()->updateCurrentWorkingDirectory ();
28 return 0; 29 return 0;
29 } 30 }
30 31
31 void octave_exit_hook (int status) 32 void octave_exit_hook (int status)
32 { 33 {
50 _updateWorkspaceModelTimer.setSingleShot (false); 51 _updateWorkspaceModelTimer.setSingleShot (false);
51 connect(&_updateWorkspaceModelTimer, SIGNAL (timeout ()), 52 connect(&_updateWorkspaceModelTimer, SIGNAL (timeout ()),
52 m_workspaceModel, SLOT (updateFromSymbolTable ())); 53 m_workspaceModel, SLOT (updateFromSymbolTable ()));
53 54
54 _symbolInformationSemaphore = new QSemaphore (1); 55 _symbolInformationSemaphore = new QSemaphore (1);
56 _currentWorkingDirectory = "";
55 } 57 }
56 58
57 OctaveLink::~OctaveLink () 59 OctaveLink::~OctaveLink ()
58 { 60 {
59 } 61 }
90 for (int i = clientHistoryLength; i < serverHistoryLength; i++) 92 for (int i = clientHistoryLength; i < serverHistoryLength; i++)
91 { 93 {
92 m_historyModel->insertRow (0); 94 m_historyModel->insertRow (0);
93 m_historyModel->setData (m_historyModel->index (0), QString (command_history::get_entry (i).c_str ())); 95 m_historyModel->setData (m_historyModel->index (0), QString (command_history::get_entry (i).c_str ()));
94 } 96 }
97 }
98 }
99
100 void
101 OctaveLink::updateCurrentWorkingDirectory ()
102 {
103 QString _queriedWorkingDirectory = octave_env::get_current_directory ().c_str();
104 if (_currentWorkingDirectory != _queriedWorkingDirectory)
105 {
106 _currentWorkingDirectory = _queriedWorkingDirectory;
107 QDir::setCurrent (_currentWorkingDirectory);
108 emit workingDirectoryChanged (_currentWorkingDirectory);
95 } 109 }
96 } 110 }
97 111
98 void 112 void
99 OctaveLink::acquireSymbolInformation () 113 OctaveLink::acquireSymbolInformation ()