# HG changeset patch # User Jacob Dawid # Date 1336344834 -7200 # Node ID 97cb9286919c1664a83a61ba416c98fd065a064d # Parent fa52c6e84ae0cf4828e4abf1b8f3d6f2c4777f16 Cleaned up code. * .hgsub: Removed IRC Widget. * gui.pro: Removed dependency on IRC Widget and removed files. * class FileEditorMdiSubWindow: Renamed to FileEditor. File editor windows are now independent windows, thus removed the extra close button. * MainWindow: Removed MDI Area and replaced it with the terminal instead. * BrowserWidget: Removed browser widget. * SettingsDialog: Rearranged settings for the editor, removed tab for shortcuts. * OctaveCallbackThread: Raised update intervals from 0,5s to 1s. * OctaveLink: Replaced signals names for triggering updates on the symbol table. * WorkspaceView: Adjusted connect statements to fit the new signal names. diff -r fa52c6e84ae0 -r 97cb9286919c .hgsub --- a/.hgsub Mon Apr 30 19:38:24 2012 -0700 +++ b/.hgsub Mon May 07 00:53:54 2012 +0200 @@ -1,3 +1,2 @@ gnulib = [git]git://git.sv.gnu.org/gnulib gui/qterminal = [git]https://code.google.com/p/qterminal/ -gui/qirc = [git]https://code.google.com/p/qirc diff -r fa52c6e84ae0 -r 97cb9286919c .hgsubstate --- a/.hgsubstate Mon Apr 30 19:38:24 2012 -0700 +++ b/.hgsubstate Mon May 07 00:53:54 2012 +0200 @@ -1,3 +1,2 @@ f9813bce2c06a6130a68db4478d1b16ddadaf276 gnulib -34c2a274a1b607d2616d9903099a0905237c8f80 gui/qirc a81f99b9b77d9a402b92463b41c5fdb82324349a gui/qterminal diff -r fa52c6e84ae0 -r 97cb9286919c gui/gui.pro --- a/gui/gui.pro Mon Apr 30 19:38:24 2012 -0700 +++ b/gui/gui.pro Mon May 07 00:53:54 2012 +0200 @@ -1,2 +1,2 @@ TEMPLATE = subdirs -SUBDIRS = qterminal qirc src +SUBDIRS = qterminal src diff -r fa52c6e84ae0 -r 97cb9286919c gui/src/BrowserWidget.cpp --- a/gui/src/BrowserWidget.cpp Mon Apr 30 19:38:24 2012 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,105 +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 "BrowserWidget.h" -#include -#include -#include -#include - -BrowserWidget::BrowserWidget (QWidget * parent):QWidget (parent) -{ - construct (); -} - -void -BrowserWidget::construct () -{ - QStyle *style = QApplication::style (); - m_navigationToolBar = new QToolBar (this); - m_webView = new QWebView (this); - m_urlLineEdit = new QLineEdit (this); - m_statusBar = new QStatusBar (this); - m_progressBar = new QProgressBar (this); - m_progressBar->setMaximumWidth (150); - - m_webView->setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Expanding); - QAction *backAction = - new QAction (style->standardIcon (QStyle::SP_ArrowLeft), - "", m_navigationToolBar); - QAction *forwardAction = - new QAction (style->standardIcon (QStyle::SP_ArrowRight), - "", m_navigationToolBar); - - m_navigationToolBar->addAction (backAction); - m_navigationToolBar->addAction (forwardAction); - m_navigationToolBar->addWidget (m_urlLineEdit); - - QVBoxLayout *layout = new QVBoxLayout (); - layout->addWidget (m_navigationToolBar); - layout->addWidget (m_webView); - - QWidget *bottomWidget = new QWidget (this); - QHBoxLayout *bottomLineLayout = new QHBoxLayout (); - bottomLineLayout->addWidget (m_progressBar); - bottomLineLayout->addWidget (m_statusBar); - bottomLineLayout->setMargin (0); - bottomWidget->setLayout (bottomLineLayout); - - layout->addWidget (bottomWidget); - layout->setMargin (2); - setLayout (layout); - - connect (backAction, SIGNAL (triggered ()), m_webView, SLOT (back ())); - connect (forwardAction, SIGNAL (triggered ()), m_webView, - SLOT (forward ())); - connect (m_webView, SIGNAL (urlChanged (QUrl)), this, SLOT (setUrl (QUrl))); - connect (m_urlLineEdit, SIGNAL (returnPressed ()), this, - SLOT (jumpToWebsite ())); - - connect (m_webView, SIGNAL (statusBarMessage(QString)), - m_statusBar, SLOT (showMessage(QString))); - connect (m_webView, SIGNAL (loadProgress(int)), - m_progressBar, SLOT (setValue(int))); -} - -void -BrowserWidget::setUrl (QUrl url) -{ - m_urlLineEdit->setText (url.toString ()); -} - -void -BrowserWidget::jumpToWebsite () -{ - QString url = m_urlLineEdit->text (); - if (!url.startsWith ("http://") && !url.startsWith ("https://")) - url = "http://" + url; - load (url); -} - -void -BrowserWidget::showStatusMessage (QString message) -{ - m_statusBar->showMessage (message, 1000); -} - -void -BrowserWidget::load (QUrl url) -{ - m_webView->load (url); -} diff -r fa52c6e84ae0 -r 97cb9286919c gui/src/BrowserWidget.h --- a/gui/src/BrowserWidget.h Mon Apr 30 19:38:24 2012 -0700 +++ /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 BROWSERMDISUBWINDOW_H -#define BROWSERMDISUBWINDOW_H - -#include -#include -#include -#include -#include -#include - -class BrowserWidget:public QWidget -{ - Q_OBJECT -public: - BrowserWidget (QWidget * parent = 0); - void load (QUrl url); - -public slots: - void setUrl (QUrl url); - void jumpToWebsite (); - void showStatusMessage (QString message); - -private: - void construct (); - - QLineEdit *m_urlLineEdit; - QToolBar *m_navigationToolBar; - QWebView *m_webView; - QStatusBar *m_statusBar; - QProgressBar *m_progressBar; -}; - -#endif // BROWSERMDISUBWINDOW_H diff -r fa52c6e84ae0 -r 97cb9286919c gui/src/FileEditor.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/src/FileEditor.cpp Mon May 07 00:53:54 2012 +0200 @@ -0,0 +1,543 @@ +/* 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 "FileEditor.h" +#include +#include +#include +#include +#include +#include +#include +#include + +FileEditor::FileEditor (QWidget * parent) + : QWidget (parent) +{ + construct (); +} + +FileEditor::~FileEditor () +{ +} + +void +FileEditor::closeEvent(QCloseEvent *event) +{ + if ( m_mainWindow->isCloseApplication() ) + { + // close wohle application: save file or not if modified + checkFileModified ("Close Octave GUI",0); // no cancel possible + } + else + { + // ignore close event if file is not saved and user cancels closing this window + if (checkFileModified ("Close File",QMessageBox::Cancel)==QMessageBox::Cancel) + event->ignore(); + else + event->accept(); + } +} + +void +FileEditor::handleMarginClicked(int margin, int line, Qt::KeyboardModifiers state) +{ + Q_UNUSED (state); + if ( margin == 1 ) // marker margin + { + unsigned int mask = m_editor->markersAtLine (line); + if (mask && (1 << MARKER_BOOKMARK)) + m_editor->markerDelete(line,MARKER_BOOKMARK); + else + m_editor->markerAdd(line,MARKER_BOOKMARK); + } +} + +void +FileEditor::newWindowTitle(bool modified) +{ + QString title(m_fileName); + if ( !m_longTitle ) + { + QFileInfo file(m_fileName); + title = file.fileName(); + } + if ( modified ) + { + setWindowTitle(title.prepend("* ")); + } + else + setWindowTitle (title); +} + +void +FileEditor::handleCopyAvailable(bool enableCopy) +{ + m_copyAction->setEnabled(enableCopy); + m_cutAction->setEnabled(enableCopy); +} + + +void +FileEditor::openFile () +{ + if (checkFileModified ("Open File",QMessageBox::Cancel)==QMessageBox::Cancel) + { + return; // existing file not saved and opening another file canceled by user + } + QString openFileName; + QFileDialog dlg(this); + dlg.setNameFilter(SAVE_FILE_FILTER); + dlg.setAcceptMode(QFileDialog::AcceptOpen); + dlg.setViewMode(QFileDialog::Detail); + if ( dlg.exec() ) + { + openFileName = dlg.selectedFiles().at(0); + if (openFileName.isEmpty ()) + return; + loadFile(openFileName); + } +} + +void +FileEditor::loadFile (QString fileName) +{ + QFile file (fileName); + if (!file.open (QFile::ReadOnly)) + { + QMessageBox::warning (this, tr ("File Editor"), + tr ("Cannot read file %1:\n%2.").arg (fileName). + arg (file.errorString ())); + return; + } + + QTextStream in (&file); + QApplication::setOverrideCursor (Qt::WaitCursor); + m_editor->setText (in.readAll ()); + QApplication::restoreOverrideCursor (); + + m_fileName = fileName; + newWindowTitle (false); // window title (no modification) + m_statusBar->showMessage (tr ("File loaded."), 2000); + m_editor->setModified (false); // loaded file is not modified yet +} + +void +FileEditor::newFile () +{ + if (checkFileModified ("Create New File",QMessageBox::Cancel)==QMessageBox::Cancel) + { + return; // existing file not saved and creating new file canceled by user + } + + m_fileName = UNNAMED_FILE; + newWindowTitle (false); // window title (no modification) + m_editor->setText (""); + m_editor->setModified (false); // new file is not modified yet +} + +int +FileEditor::checkFileModified (QString msg, int cancelButton) +{ + int decision = QMessageBox::Yes; + if (m_editor->isModified ()) + { + // file is modified but not saved, aks user what to do + decision = QMessageBox::warning (this, + msg, + tr ("The file %1\n" + "has been modified. Do you want to save the changes?"). + arg (m_fileName), + QMessageBox::Save, QMessageBox::Discard, cancelButton ); + if (decision == QMessageBox::Save) + { + saveFile (); + if (m_editor->isModified ()) + { + // If the user attempted to save the file, but it's still + // modified, then probably something went wrong, so return cancel + // for cancel this operation or try to save files as if cancel not + // possible + if ( cancelButton ) + return (QMessageBox::Cancel); + else + saveFileAs (); + } + } + } + return (decision); +} + +void +FileEditor::saveFile () +{ + saveFile(m_fileName); +} + +void +FileEditor::saveFile (QString saveFileName) +{ + // it is a new file with the name "" -> call saveFielAs + if (saveFileName==UNNAMED_FILE || saveFileName.isEmpty ()) + { + saveFileAs(); + return; + } + + // open the file for writing + QFile file (saveFileName); + if (!file.open (QFile::WriteOnly)) + { + QMessageBox::warning (this, tr ("File Editor"), + tr ("Cannot write file %1:\n%2."). + arg (saveFileName).arg (file.errorString ())); + return; + } + + // save the contents into the file + QTextStream out (&file); + QApplication::setOverrideCursor (Qt::WaitCursor); + out << m_editor->text (); + QApplication::restoreOverrideCursor (); + m_fileName = saveFileName; // save file name for later use + newWindowTitle(false); // set the window title to actual file name (not modified) + m_statusBar->showMessage (tr ("File %1 saved").arg(m_fileName), 2000); + m_editor->setModified (false); // files is save -> not modified +} + +void +FileEditor::saveFileAs () +{ + QString saveFileName(m_fileName); + QFileDialog dlg(this); + if (saveFileName==UNNAMED_FILE || saveFileName.isEmpty ()) + { + saveFileName = QDir::homePath(); + dlg.setDirectory(saveFileName); + } + else + { + dlg.selectFile(saveFileName); + } + dlg.setNameFilter(SAVE_FILE_FILTER); + dlg.setDefaultSuffix("m"); + dlg.setAcceptMode(QFileDialog::AcceptSave); + dlg.setViewMode(QFileDialog::Detail); + if ( dlg.exec() ) + { + saveFileName = dlg.selectedFiles().at(0); + if (saveFileName.isEmpty ()) + return; + saveFile(saveFileName); + } +} + +// handle the run command +void +FileEditor::runFile () +{ + if (m_editor->isModified ()) + saveFile(m_fileName); + m_terminalView->sendText (QString ("run \'%1\'\n").arg (m_fileName)); + m_terminalView->setFocus (); +} + + +// (un)comment selected text +void +FileEditor::commentSelectedText () +{ + doCommentSelectedText (true); +} +void +FileEditor::uncommentSelectedText () +{ + doCommentSelectedText (false); +} +void +FileEditor::doCommentSelectedText (bool comment) +{ + if ( m_editor->hasSelectedText() ) + { + int lineFrom, lineTo, colFrom, colTo, i; + m_editor->getSelection (&lineFrom,&colFrom,&lineTo,&colTo); + if ( colTo == 0 ) // the beginning of last line is not selected + lineTo--; // stop at line above + m_editor->beginUndoAction (); + for ( i=lineFrom; i<=lineTo; i++ ) + { + if ( comment ) + m_editor->insertAt("%",i,0); + else + { + QString line(m_editor->text(i)); + if ( line.startsWith("%") ) + { + m_editor->setSelection(i,0,i,1); + m_editor->removeSelectedText(); + } + } + } + m_editor->endUndoAction (); + } +} + + +// remove bookmarks +void +FileEditor::removeBookmark () +{ + m_editor->markerDeleteAll(MARKER_BOOKMARK); +} +// toggle bookmark +void +FileEditor::toggleBookmark () +{ + int line,cur; + m_editor->getCursorPosition(&line,&cur); + if ( m_editor->markersAtLine (line) && (1 << MARKER_BOOKMARK) ) + m_editor->markerDelete(line,MARKER_BOOKMARK); + else + m_editor->markerAdd(line,MARKER_BOOKMARK); +} +// goto next bookmark +void +FileEditor::nextBookmark () +{ + int line,cur,nextline; + m_editor->getCursorPosition(&line,&cur); + if ( m_editor->markersAtLine(line) && (1 << MARKER_BOOKMARK) ) + line++; // we have a bookmark here, so start search from next line + nextline = m_editor->markerFindNext(line,(1 << MARKER_BOOKMARK)); + m_editor->setCursorPosition(nextline,0); +} +// goto previous bookmark +void +FileEditor::prevBookmark () +{ + int line,cur,prevline; + m_editor->getCursorPosition(&line,&cur); + if ( m_editor->markersAtLine(line) && (1 << MARKER_BOOKMARK) ) + line--; // we have a bookmark here, so start search from prev line + prevline = m_editor->markerFindPrevious(line,(1 << MARKER_BOOKMARK)); + m_editor->setCursorPosition(prevline,0); +} + +// function for setting the already existing lexer from MainWindow +void +FileEditor::initEditor (QTerminal* terminalView, + LexerOctaveGui* lexer, + MainWindow* mainWindow) +{ + m_editor->setLexer(lexer); + m_terminalView = terminalView; // for sending commands to octave + // TODO: make a global commandOctave function? + m_mainWindow = mainWindow; // get the MainWindow for chekcing state at subwindow close +} + +void +FileEditor::setModified (bool modified) +{ + m_modified = modified; +} + +void +FileEditor::construct () +{ + QSettings *settings = ResourceManager::instance ()->settings (); + QStyle *style = QApplication::style (); + + m_menuBar = new QMenuBar (this); + m_toolBar = new QToolBar (this); + m_statusBar = new QStatusBar (this); + m_editor = new QsciScintilla (this); + + // markers + m_editor->setMarginType (1, QsciScintilla::SymbolMargin); + m_editor->setMarginSensitivity(1,true); + m_editor->markerDefine(QsciScintilla::RightTriangle,MARKER_BOOKMARK); + connect(m_editor,SIGNAL(marginClicked(int,int,Qt::KeyboardModifiers)), + this,SLOT(handleMarginClicked(int,int,Qt::KeyboardModifiers))); + + // line numbers + m_editor->setMarginsForegroundColor(QColor(96,96,96)); + m_editor->setMarginsBackgroundColor(QColor(232,232,220)); + if ( settings->value ("editor/showLineNumbers",true).toBool () ) + { + QFont marginFont( settings->value ("editor/fontName","Courier").toString () , + settings->value ("editor/fontSize",10).toInt () ); + m_editor->setMarginsFont( marginFont ); + QFontMetrics metrics(marginFont); + m_editor->setMarginType (2, QsciScintilla::TextMargin); + m_editor->setMarginWidth(2, metrics.width("99999")); + m_editor->setMarginLineNumbers(2, true); + } + // code folding + m_editor->setMarginType (3, QsciScintilla::SymbolMargin); + m_editor->setFolding (QsciScintilla::BoxedTreeFoldStyle , 3); + // other features + if ( settings->value ("editor/highlightCurrentLine",true).toBool () ) + { + m_editor->setCaretLineVisible(true); + m_editor->setCaretLineBackgroundColor(QColor(245,245,245)); + } + m_editor->setBraceMatching (QsciScintilla::StrictBraceMatch); + m_editor->setAutoIndent (true); + m_editor->setIndentationWidth (2); + m_editor->setIndentationsUseTabs (false); + if ( settings->value ("editor/codeCompletion",true).toBool () ) + { + m_editor->autoCompleteFromAll (); + m_editor->setAutoCompletionSource(QsciScintilla::AcsAll); + m_editor->setAutoCompletionThreshold (1); + } + m_editor->setUtf8 (true); + m_longTitle = settings->value ("editor/longWindowTitle",true).toBool (); + + // The Actions + + // Theme icons with QStyle icons as fallback + QAction *newAction = new QAction ( + QIcon::fromTheme("document-new",style->standardIcon (QStyle::SP_FileIcon)), + tr("&New File"), m_toolBar); + QAction *openAction = new QAction ( + QIcon::fromTheme("document-open",style->standardIcon (QStyle::SP_DirOpenIcon)), + tr("&Open File"), m_toolBar); + QAction *saveAction = new QAction ( + QIcon::fromTheme("document-save",style->standardIcon (QStyle::SP_DriveHDIcon)), + tr("&Save File"), m_toolBar); + QAction *saveAsAction = new QAction ( + QIcon::fromTheme("document-save-as",style->standardIcon (QStyle::SP_DriveFDIcon)), + tr("Save File &As"), m_toolBar); + QAction *undoAction = new QAction ( + QIcon::fromTheme("edit-undo",style->standardIcon (QStyle::SP_ArrowLeft)), + tr("&Undo"), m_toolBar); + QAction *redoAction = new QAction ( + QIcon::fromTheme("edit-redo",style->standardIcon (QStyle::SP_ArrowRight)), + tr("&Redo"), m_toolBar); + m_copyAction = new QAction (QIcon::fromTheme("edit-copy"),tr("&Copy"),m_toolBar); + m_cutAction = new QAction (QIcon::fromTheme("edit-cut"),tr("Cu&t"),m_toolBar); + QAction *pasteAction = new QAction (QIcon::fromTheme("edit-paste"),tr("&Paste"),m_toolBar); + QAction *nextBookmarkAction = new QAction (tr("&Next Bookmark"),m_toolBar); + QAction *prevBookmarkAction = new QAction (tr("Pre&vious Bookmark"),m_toolBar); + QAction *toggleBookmarkAction = new QAction (tr("Toggle &Bookmark"),m_toolBar); + QAction *removeBookmarkAction = new QAction (tr("&Remove All Bookmarks"),m_toolBar); + QAction *commentSelectedAction = new QAction (tr("&Comment Selected Text"),m_toolBar); + QAction *uncommentSelectedAction = new QAction (tr("&Uncomment Selected Text"),m_toolBar); + QAction *runAction = new QAction ( + QIcon::fromTheme("media-play",style->standardIcon (QStyle::SP_MediaPlay)), + tr("&Run File"), m_toolBar); + + // some actions are disabled from the beginning + m_copyAction->setEnabled(false); + m_cutAction->setEnabled(false); + connect(m_editor,SIGNAL(copyAvailable(bool)),this,SLOT(handleCopyAvailable(bool))); + + // short cuts + newAction->setShortcut(QKeySequence::New); + openAction->setShortcut(QKeySequence::Open); + saveAction->setShortcut(QKeySequence::Save); + saveAsAction->setShortcut(QKeySequence::SaveAs); + undoAction->setShortcut(QKeySequence::Undo); + redoAction->setShortcut(QKeySequence::Redo); + m_copyAction->setShortcut(QKeySequence::Copy); + m_cutAction->setShortcut(QKeySequence::Cut); + pasteAction->setShortcut(QKeySequence::Paste); + runAction->setShortcut(Qt::Key_F5); + nextBookmarkAction->setShortcut(Qt::Key_F2); + prevBookmarkAction->setShortcut(Qt::SHIFT + Qt::Key_F2); + toggleBookmarkAction->setShortcut(Qt::Key_F7); + commentSelectedAction->setShortcut(Qt::CTRL + Qt::Key_R); + uncommentSelectedAction->setShortcut(Qt::CTRL + Qt::Key_T); + + // toolbar + m_toolBar->addAction (newAction); + m_toolBar->addAction (openAction); + m_toolBar->addAction (saveAction); + m_toolBar->addAction (saveAsAction); + m_toolBar->addSeparator(); + m_toolBar->addAction (undoAction); + m_toolBar->addAction (redoAction); + m_toolBar->addAction (m_copyAction); + m_toolBar->addAction (m_cutAction); + m_toolBar->addAction (pasteAction); + m_toolBar->addSeparator(); + m_toolBar->addAction (runAction); + + // menu bar + QMenu *fileMenu = new QMenu(tr("&File"),m_menuBar); + fileMenu->addAction(newAction); + fileMenu->addAction(openAction); + fileMenu->addAction(saveAction); + fileMenu->addAction(saveAsAction); + fileMenu->addSeparator(); + m_menuBar->addMenu(fileMenu); + QMenu *editMenu = new QMenu(tr("&Edit"),m_menuBar); + editMenu->addAction(undoAction); + editMenu->addAction(redoAction); + editMenu->addSeparator(); + editMenu->addAction(m_copyAction); + editMenu->addAction(m_cutAction); + editMenu->addAction(pasteAction); + editMenu->addSeparator(); + editMenu->addAction(commentSelectedAction); + editMenu->addAction(uncommentSelectedAction); + editMenu->addSeparator(); + editMenu->addAction(toggleBookmarkAction); + editMenu->addAction(nextBookmarkAction); + editMenu->addAction(prevBookmarkAction); + editMenu->addAction(removeBookmarkAction); + m_menuBar->addMenu(editMenu); + QMenu *runMenu = new QMenu(tr("&Run"),m_menuBar); + runMenu->addAction(runAction); + m_menuBar->addMenu(runMenu); + + + QVBoxLayout *layout = new QVBoxLayout (); + layout->addWidget (m_menuBar); + layout->addWidget (m_toolBar); + layout->addWidget (m_editor); + layout->addWidget (m_statusBar); + layout->setMargin (2); + setLayout (layout); + + connect (newAction, SIGNAL (triggered ()), this, SLOT (newFile ())); + connect (openAction, SIGNAL (triggered ()), this, SLOT (openFile ())); + connect (undoAction, SIGNAL (triggered ()), m_editor, SLOT (undo ())); + connect (redoAction, SIGNAL (triggered ()), m_editor, SLOT (redo ())); + connect (m_copyAction, SIGNAL (triggered ()), m_editor, SLOT (copy ())); + connect (m_cutAction, SIGNAL (triggered ()), m_editor, SLOT (cut ())); + connect (pasteAction, SIGNAL (triggered ()), m_editor, SLOT (paste ())); + connect (saveAction, SIGNAL (triggered ()), this, SLOT (saveFile ())); + connect (saveAsAction, SIGNAL (triggered ()), this, SLOT (saveFileAs ())); + connect (runAction, SIGNAL (triggered ()), this, SLOT (runFile ())); + connect (toggleBookmarkAction, SIGNAL (triggered ()), this, SLOT (toggleBookmark ())); + connect (nextBookmarkAction, SIGNAL (triggered ()), this, SLOT (nextBookmark ())); + connect (prevBookmarkAction, SIGNAL (triggered ()), this, SLOT (prevBookmark ())); + connect (removeBookmarkAction, SIGNAL (triggered ()), this, SLOT (removeBookmark ())); + connect (commentSelectedAction, SIGNAL (triggered ()), this, SLOT (commentSelectedText ())); + connect (uncommentSelectedAction, SIGNAL (triggered ()), this, SLOT (uncommentSelectedText ())); + + + // connect modified signal + connect (m_editor, SIGNAL (modificationChanged(bool)), this, SLOT (newWindowTitle(bool)) ); + + m_fileName = ""; + newWindowTitle (false); + setWindowIcon(QIcon::fromTheme("accessories-text-editor",style->standardIcon (QStyle::SP_FileIcon))); + show (); +} diff -r fa52c6e84ae0 -r 97cb9286919c gui/src/FileEditor.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/src/FileEditor.h Mon May 07 00:53:54 2012 +0200 @@ -0,0 +1,99 @@ +/* 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 FILEEDITORMDISUBWINDOW_H +#define FILEEDITORMDISUBWINDOW_H + +#include "MainWindow.h" + +#include +#include +#include +#include +#include +#include +#include +// Not available in the Debian repos yet! +// #include +#include "lexer/lexeroctavegui.h" + +const char UNNAMED_FILE[] = ""; +const char SAVE_FILE_FILTER[] = "Octave Files (*.m);;All Files (*.*)"; +enum MARKER + { + MARKER_BOOKMARK, + MARKER_BREAKPOINT + }; + +class FileEditor : public QWidget +{ +Q_OBJECT + +public: + FileEditor (QWidget * parent = 0); + ~FileEditor (); + void loadFile (QString fileName); + void initEditor (QTerminal *terminalView, + LexerOctaveGui *lexer, + MainWindow *mainWindow); + +public slots: + + void newFile (); + void openFile (); + void saveFile (); + void saveFile (QString fileName); + void saveFileAs (); + + void setModified (bool modified); + +protected: + void closeEvent(QCloseEvent *event); + +private: + int checkFileModified (QString msg, int cancelButton); + void construct (); + void doCommentSelectedText (bool comment); + QMenuBar *m_menuBar; + QToolBar *m_toolBar; + QsciScintilla *m_editor; + QStatusBar *m_statusBar; + QString m_fileName; + QString m_fileNameShort; + QTerminal* m_terminalView; + QAction* m_copyAction; + QAction* m_cutAction; + MainWindow* m_mainWindow; + int m_markerBookmark; + bool m_modified; + bool m_longTitle; + +private slots: + void newWindowTitle(bool modified); + void handleMarginClicked(int line, int margin, Qt::KeyboardModifiers state); + void handleCopyAvailable(bool enableCopy); + void runFile(); + void removeBookmark (); + void toggleBookmark (); + void nextBookmark(); + void prevBookmark(); + void commentSelectedText(); + void uncommentSelectedText(); + +}; + +#endif // FILEEDITORMDISUBWINDOW_H diff -r fa52c6e84ae0 -r 97cb9286919c gui/src/FileEditorMdiSubWindow.cpp --- a/gui/src/FileEditorMdiSubWindow.cpp Mon Apr 30 19:38:24 2012 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,596 +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 "FileEditorMdiSubWindow.h" -#include -#include -#include -#include -#include -#include -#include -#include - -FileEditorMdiSubWindow::FileEditorMdiSubWindow (QWidget * parent):QMdiSubWindow - (parent) -{ - construct (); -} - -FileEditorMdiSubWindow::~FileEditorMdiSubWindow () -{ -} - -void -FileEditorMdiSubWindow::closeEvent(QCloseEvent *event) -{ - if ( m_mainWindow->isCloseApplication() ) - { - // close wohle application: save file or not if modified - checkFileModified ("Close Octave GUI",0); // no cancel possible - } - else - { - // ignore close event if file is not saved and user cancels closing this window - if (checkFileModified ("Close File",QMessageBox::Cancel)==QMessageBox::Cancel) - event->ignore(); - else - event->accept(); - } -} - -void -FileEditorMdiSubWindow::handleMarginClicked(int margin, int line, Qt::KeyboardModifiers state) -{ - Q_UNUSED (state); - if ( margin == 1 ) // marker margin - { - unsigned int mask = m_editor->markersAtLine (line); - if (mask && (1 << MARKER_BOOKMARK)) - m_editor->markerDelete(line,MARKER_BOOKMARK); - else - m_editor->markerAdd(line,MARKER_BOOKMARK); - } -} - -void -FileEditorMdiSubWindow::newWindowTitle(bool modified) -{ - QString title(m_fileName); - if ( !m_longTitle ) - { - QFileInfo file(m_fileName); - title = file.fileName(); - } - if ( modified ) - { - setWindowTitle(title.prepend("* ")); - } - else - setWindowTitle (title); -} - -void -FileEditorMdiSubWindow::handleCopyAvailable(bool enableCopy) -{ - m_copyAction->setEnabled(enableCopy); - m_cutAction->setEnabled(enableCopy); -} - - -void -FileEditorMdiSubWindow::openFile () -{ - if (checkFileModified ("Open File",QMessageBox::Cancel)==QMessageBox::Cancel) - { - return; // existing file not saved and opening another file canceled by user - } - QString openFileName; - QFileDialog dlg(this); - dlg.setNameFilter(SAVE_FILE_FILTER); - dlg.setAcceptMode(QFileDialog::AcceptOpen); - dlg.setViewMode(QFileDialog::Detail); - if ( dlg.exec() ) - { - openFileName = dlg.selectedFiles().at(0); - if (openFileName.isEmpty ()) - return; - loadFile(openFileName); - } -} - -void -FileEditorMdiSubWindow::loadFile (QString fileName) -{ - QFile file (fileName); - if (!file.open (QFile::ReadOnly)) - { - QMessageBox::warning (this, tr ("File Editor"), - tr ("Cannot read file %1:\n%2.").arg (fileName). - arg (file.errorString ())); - return; - } - - QTextStream in (&file); - QApplication::setOverrideCursor (Qt::WaitCursor); - m_editor->setText (in.readAll ()); - QApplication::restoreOverrideCursor (); - - m_fileName = fileName; - newWindowTitle (false); // window title (no modification) - m_statusBar->showMessage (tr ("File loaded."), 2000); - m_editor->setModified (false); // loaded file is not modified yet -} - -void -FileEditorMdiSubWindow::newFile () -{ - if (checkFileModified ("Create New File",QMessageBox::Cancel)==QMessageBox::Cancel) - { - return; // existing file not saved and creating new file canceled by user - } - m_fileName = UNNAMED_FILE; - newWindowTitle (false); // window title (no modification) - m_editor->setText (""); - m_editor->setModified (false); // new file is not modified yet -} - -int -FileEditorMdiSubWindow::checkFileModified (QString msg, int cancelButton) -{ - int decision = QMessageBox::Yes; - if (m_editor->isModified ()) - { - // file is modified but not saved, aks user what to do - decision = QMessageBox::warning (this, - msg, - tr ("The file %1\n" - "has been modified. Do you want to save the changes?"). - arg (m_fileName), - QMessageBox::Save, QMessageBox::Discard, cancelButton ); - if (decision == QMessageBox::Save) - { - saveFile (); - if (m_editor->isModified ()) - { - // If the user attempted to save the file, but it's still - // modified, then probably something went wrong, so return cancel - // for cancel this operation or try to save files as if cancel not - // possible - if ( cancelButton ) - return (QMessageBox::Cancel); - else - saveFileAs (); - } - } - } - return (decision); -} - -void -FileEditorMdiSubWindow::saveFile () -{ - saveFile(m_fileName); -} - -void -FileEditorMdiSubWindow::saveFile (QString saveFileName) -{ - // it is a new file with the name "" -> call saveFielAs - if (saveFileName==UNNAMED_FILE || saveFileName.isEmpty ()) - { - saveFileAs(); - return; - } - - // open the file for writing - QFile file (saveFileName); - if (!file.open (QFile::WriteOnly)) - { - QMessageBox::warning (this, tr ("File Editor"), - tr ("Cannot write file %1:\n%2."). - arg (saveFileName).arg (file.errorString ())); - return; - } - - // save the contents into the file - QTextStream out (&file); - QApplication::setOverrideCursor (Qt::WaitCursor); - out << m_editor->text (); - QApplication::restoreOverrideCursor (); - m_fileName = saveFileName; // save file name for later use - newWindowTitle(false); // set the window title to actual file name (not modified) - m_statusBar->showMessage (tr ("File %1 saved").arg(m_fileName), 2000); - m_editor->setModified (false); // files is save -> not modified -} - -void -FileEditorMdiSubWindow::saveFileAs () -{ - QString saveFileName(m_fileName); - QFileDialog dlg(this); - if (saveFileName==UNNAMED_FILE || saveFileName.isEmpty ()) - { - saveFileName = QDir::homePath(); - dlg.setDirectory(saveFileName); - } - else - { - dlg.selectFile(saveFileName); - } - dlg.setNameFilter(SAVE_FILE_FILTER); - dlg.setDefaultSuffix("m"); - dlg.setAcceptMode(QFileDialog::AcceptSave); - dlg.setViewMode(QFileDialog::Detail); - if ( dlg.exec() ) - { - saveFileName = dlg.selectedFiles().at(0); - if (saveFileName.isEmpty ()) - return; - saveFile(saveFileName); - } -} - -// handle the run command -void -FileEditorMdiSubWindow::runFile () -{ - if (m_editor->isModified ()) - saveFile(m_fileName); - m_terminalView->sendText (QString ("run \'%1\'\n").arg (m_fileName)); - m_terminalView->setFocus (); -} - - -// (un)comment selected text -void -FileEditorMdiSubWindow::commentSelectedText () -{ - doCommentSelectedText (true); -} -void -FileEditorMdiSubWindow::uncommentSelectedText () -{ - doCommentSelectedText (false); -} -void -FileEditorMdiSubWindow::doCommentSelectedText (bool comment) -{ - if ( m_editor->hasSelectedText() ) - { - int lineFrom, lineTo, colFrom, colTo, i; - m_editor->getSelection (&lineFrom,&colFrom,&lineTo,&colTo); - if ( colTo == 0 ) // the beginning of last line is not selected - lineTo--; // stop at line above - m_editor->beginUndoAction (); - for ( i=lineFrom; i<=lineTo; i++ ) - { - if ( comment ) - m_editor->insertAt("%",i,0); - else - { - QString line(m_editor->text(i)); - if ( line.startsWith("%") ) - { - m_editor->setSelection(i,0,i,1); - m_editor->removeSelectedText(); - } - } - } - m_editor->endUndoAction (); - } -} - - -// remove bookmarks -void -FileEditorMdiSubWindow::removeBookmark () -{ - m_editor->markerDeleteAll(MARKER_BOOKMARK); -} -// toggle bookmark -void -FileEditorMdiSubWindow::toggleBookmark () -{ - int line,cur; - m_editor->getCursorPosition(&line,&cur); - if ( m_editor->markersAtLine (line) && (1 << MARKER_BOOKMARK) ) - m_editor->markerDelete(line,MARKER_BOOKMARK); - else - m_editor->markerAdd(line,MARKER_BOOKMARK); -} -// goto next bookmark -void -FileEditorMdiSubWindow::nextBookmark () -{ - int line,cur,nextline; - m_editor->getCursorPosition(&line,&cur); - if ( m_editor->markersAtLine(line) && (1 << MARKER_BOOKMARK) ) - line++; // we have a bookmark here, so start search from next line - nextline = m_editor->markerFindNext(line,(1 << MARKER_BOOKMARK)); - m_editor->setCursorPosition(nextline,0); -} -// goto previous bookmark -void -FileEditorMdiSubWindow::prevBookmark () -{ - int line,cur,prevline; - m_editor->getCursorPosition(&line,&cur); - if ( m_editor->markersAtLine(line) && (1 << MARKER_BOOKMARK) ) - line--; // we have a bookmark here, so start search from prev line - prevline = m_editor->markerFindPrevious(line,(1 << MARKER_BOOKMARK)); - m_editor->setCursorPosition(prevline,0); -} - -// function for setting the already existing lexer from MainWindow -void -FileEditorMdiSubWindow::initEditor (QTerminal* terminalView, - LexerOctaveGui* lexer, - MainWindow* mainWindow) -{ - m_editor->setLexer(lexer); - m_terminalView = terminalView; // for sending commands to octave - // TODO: make a global commandOctave function? - m_mainWindow = mainWindow; // get the MainWindow for chekcing state at subwindow close -} - -// TODO: Do we still need tool tips in the status bar? Tool tips are now -// shown directly at the theme icons -void -FileEditorMdiSubWindow::showToolTipNew () -{ - m_statusBar->showMessage ("Create a new file", 2000); -} - -void -FileEditorMdiSubWindow::showToolTipOpen () -{ - m_statusBar->showMessage ("Open a file", 2000); -} - -void -FileEditorMdiSubWindow::showToolTipSave () -{ - m_statusBar->showMessage ("Save the file", 2000); -} - -void -FileEditorMdiSubWindow::showToolTipSaveAs () -{ - m_statusBar->showMessage ("Save the file as", 2000); -} - -void -FileEditorMdiSubWindow::showToolTipUndo () -{ - m_statusBar->showMessage ("Revert previous changes", 2000); -} - -void -FileEditorMdiSubWindow::showToolTipRedo () -{ - m_statusBar->showMessage ("Append previous changes", 2000); -} - -void -FileEditorMdiSubWindow::registerModified (bool modified) -{ - m_modified = modified; -} - -void -FileEditorMdiSubWindow::construct () -{ - QSettings *settings = ResourceManager::instance ()->settings (); - QStyle *style = QApplication::style (); - setWidget (new QWidget ()); - - m_menuBar = new QMenuBar (this); - m_toolBar = new QToolBar (this); - m_statusBar = new QStatusBar (this); - m_editor = new QsciScintilla (this); - - // markers - m_editor->setMarginType (1, QsciScintilla::SymbolMargin); - m_editor->setMarginSensitivity(1,true); - m_editor->markerDefine(QsciScintilla::RightTriangle,MARKER_BOOKMARK); - connect(m_editor,SIGNAL(marginClicked(int,int,Qt::KeyboardModifiers)), - this,SLOT(handleMarginClicked(int,int,Qt::KeyboardModifiers))); - - // line numbers - m_editor->setMarginsForegroundColor(QColor(96,96,96)); - m_editor->setMarginsBackgroundColor(QColor(232,232,220)); - if ( settings->value ("editor/showLineNumbers",true).toBool () ) - { - QFont marginFont( settings->value ("editor/fontName","Courier").toString () , - settings->value ("editor/fontSize",10).toInt () ); - m_editor->setMarginsFont( marginFont ); - QFontMetrics metrics(marginFont); - m_editor->setMarginType (2, QsciScintilla::TextMargin); - m_editor->setMarginWidth(2, metrics.width("99999")); - m_editor->setMarginLineNumbers(2, true); - } - // code folding - m_editor->setMarginType (3, QsciScintilla::SymbolMargin); - m_editor->setFolding (QsciScintilla::BoxedTreeFoldStyle , 3); - // other features - if ( settings->value ("editor/highlightCurrentLine",true).toBool () ) - { - m_editor->setCaretLineVisible(true); - m_editor->setCaretLineBackgroundColor(QColor(245,245,245)); - } - m_editor->setBraceMatching (QsciScintilla::StrictBraceMatch); - m_editor->setAutoIndent (true); - m_editor->setIndentationWidth (2); - m_editor->setIndentationsUseTabs (false); - if ( settings->value ("editor/codeCompletion",true).toBool () ) - { - m_editor->autoCompleteFromAll (); - m_editor->setAutoCompletionSource(QsciScintilla::AcsAll); - m_editor->setAutoCompletionThreshold (1); - } - m_editor->setUtf8 (true); - m_longTitle = settings->value ("editor/longWindowTitle",true).toBool (); - - // The Actions - - // Theme icons with QStyle icons as fallback - QAction *closeAction = new QAction ( - QIcon::fromTheme("window-close",style->standardIcon (QStyle::SP_DialogCloseButton)), - tr("&Close File"), m_toolBar); - QAction *newAction = new QAction ( - QIcon::fromTheme("document-new",style->standardIcon (QStyle::SP_FileIcon)), - tr("&New File"), m_toolBar); - QAction *openAction = new QAction ( - QIcon::fromTheme("document-open",style->standardIcon (QStyle::SP_DirOpenIcon)), - tr("&Open File"), m_toolBar); - QAction *saveAction = new QAction ( - QIcon::fromTheme("document-save",style->standardIcon (QStyle::SP_DriveHDIcon)), - tr("&Save File"), m_toolBar); - QAction *saveAsAction = new QAction ( - QIcon::fromTheme("document-save-as",style->standardIcon (QStyle::SP_DriveFDIcon)), - tr("Save File &As"), m_toolBar); - QAction *undoAction = new QAction ( - QIcon::fromTheme("edit-undo",style->standardIcon (QStyle::SP_ArrowLeft)), - tr("&Undo"), m_toolBar); - QAction *redoAction = new QAction ( - QIcon::fromTheme("edit-redo",style->standardIcon (QStyle::SP_ArrowRight)), - tr("&Redo"), m_toolBar); - m_copyAction = new QAction (QIcon::fromTheme("edit-copy"),tr("&Copy"),m_toolBar); - m_cutAction = new QAction (QIcon::fromTheme("edit-cut"),tr("Cu&t"),m_toolBar); - QAction *pasteAction = new QAction (QIcon::fromTheme("edit-paste"),tr("&Paste"),m_toolBar); - QAction *nextBookmarkAction = new QAction (tr("&Next Bookmark"),m_toolBar); - QAction *prevBookmarkAction = new QAction (tr("Pre&vious Bookmark"),m_toolBar); - QAction *toggleBookmarkAction = new QAction (tr("Toggle &Bookmark"),m_toolBar); - QAction *removeBookmarkAction = new QAction (tr("&Remove All Bookmarks"),m_toolBar); - QAction *commentSelectedAction = new QAction (tr("&Comment Selected Text"),m_toolBar); - QAction *uncommentSelectedAction = new QAction (tr("&Uncomment Selected Text"),m_toolBar); - QAction *runAction = new QAction ( - QIcon::fromTheme("media-play",style->standardIcon (QStyle::SP_MediaPlay)), - tr("&Run File"), m_toolBar); - - // some actions are disabled from the beginning - m_copyAction->setEnabled(false); - m_cutAction->setEnabled(false); - connect(m_editor,SIGNAL(copyAvailable(bool)),this,SLOT(handleCopyAvailable(bool))); - - // short cuts - newAction->setShortcut(QKeySequence::New); - openAction->setShortcut(QKeySequence::Open); - saveAction->setShortcut(QKeySequence::Save); - saveAsAction->setShortcut(QKeySequence::SaveAs); - undoAction->setShortcut(QKeySequence::Undo); - redoAction->setShortcut(QKeySequence::Redo); - m_copyAction->setShortcut(QKeySequence::Copy); - m_cutAction->setShortcut(QKeySequence::Cut); - pasteAction->setShortcut(QKeySequence::Paste); - runAction->setShortcut(Qt::Key_F5); - nextBookmarkAction->setShortcut(Qt::Key_F2); - prevBookmarkAction->setShortcut(Qt::SHIFT + Qt::Key_F2); - toggleBookmarkAction->setShortcut(Qt::Key_F7); - commentSelectedAction->setShortcut(Qt::CTRL + Qt::Key_R); - uncommentSelectedAction->setShortcut(Qt::CTRL + Qt::Key_T); - - // toolbar - m_toolBar->setIconSize(QSize(16,16)); // smaller icons (make configurable in user settings?) - m_toolBar->addAction (closeAction); - m_toolBar->addAction (newAction); - m_toolBar->addAction (openAction); - m_toolBar->addAction (saveAction); - m_toolBar->addAction (saveAsAction); - m_toolBar->addSeparator(); - m_toolBar->addAction (undoAction); - m_toolBar->addAction (redoAction); - m_toolBar->addAction (m_copyAction); - m_toolBar->addAction (m_cutAction); - m_toolBar->addAction (pasteAction); - m_toolBar->addSeparator(); - m_toolBar->addAction (runAction); - - // menu bar - QMenu *fileMenu = new QMenu(tr("&File"),m_menuBar); - fileMenu->addAction(newAction); - fileMenu->addAction(openAction); - fileMenu->addAction(saveAction); - fileMenu->addAction(saveAsAction); - fileMenu->addSeparator(); - fileMenu->addAction (closeAction); - m_menuBar->addMenu(fileMenu); - QMenu *editMenu = new QMenu(tr("&Edit"),m_menuBar); - editMenu->addAction(undoAction); - editMenu->addAction(redoAction); - editMenu->addSeparator(); - editMenu->addAction(m_copyAction); - editMenu->addAction(m_cutAction); - editMenu->addAction(pasteAction); - editMenu->addSeparator(); - editMenu->addAction(commentSelectedAction); - editMenu->addAction(uncommentSelectedAction); - editMenu->addSeparator(); - editMenu->addAction(toggleBookmarkAction); - editMenu->addAction(nextBookmarkAction); - editMenu->addAction(prevBookmarkAction); - editMenu->addAction(removeBookmarkAction); - m_menuBar->addMenu(editMenu); - QMenu *runMenu = new QMenu(tr("&Run"),m_menuBar); - runMenu->addAction(runAction); - m_menuBar->addMenu(runMenu); - - - QVBoxLayout *layout = new QVBoxLayout (); - layout->addWidget (m_menuBar); - layout->addWidget (m_toolBar); - layout->addWidget (m_editor); - layout->addWidget (m_statusBar); - layout->setMargin (2); - widget ()->setLayout (layout); - - connect (closeAction, SIGNAL (triggered()), this, SLOT (close())); - connect (newAction, SIGNAL (triggered ()), this, SLOT (newFile ())); - connect (openAction, SIGNAL (triggered ()), this, SLOT (openFile ())); - connect (undoAction, SIGNAL (triggered ()), m_editor, SLOT (undo ())); - connect (redoAction, SIGNAL (triggered ()), m_editor, SLOT (redo ())); - connect (m_copyAction, SIGNAL (triggered ()), m_editor, SLOT (copy ())); - connect (m_cutAction, SIGNAL (triggered ()), m_editor, SLOT (cut ())); - connect (pasteAction, SIGNAL (triggered ()), m_editor, SLOT (paste ())); - connect (saveAction, SIGNAL (triggered ()), this, SLOT (saveFile ())); - connect (saveAsAction, SIGNAL (triggered ()), this, SLOT (saveFileAs ())); - connect (runAction, SIGNAL (triggered ()), this, SLOT (runFile ())); - connect (toggleBookmarkAction, SIGNAL (triggered ()), this, SLOT (toggleBookmark ())); - connect (nextBookmarkAction, SIGNAL (triggered ()), this, SLOT (nextBookmark ())); - connect (prevBookmarkAction, SIGNAL (triggered ()), this, SLOT (prevBookmark ())); - connect (removeBookmarkAction, SIGNAL (triggered ()), this, SLOT (removeBookmark ())); - connect (commentSelectedAction, SIGNAL (triggered ()), this, SLOT (commentSelectedText ())); - connect (uncommentSelectedAction, SIGNAL (triggered ()), this, SLOT (uncommentSelectedText ())); - - // TODO: Do we still need tool tips in the status bar? Tool tips are now - // shown directly at the theme icons - connect (newAction, SIGNAL (hovered ()), this, SLOT (showToolTipNew ())); - connect (openAction, SIGNAL (hovered ()), this, SLOT (showToolTipOpen ())); - connect (undoAction, SIGNAL (hovered ()), this, SLOT (showToolTipUndo ())); - connect (redoAction, SIGNAL (hovered ()), this, SLOT (showToolTipRedo ())); - connect (saveAction, SIGNAL (hovered ()), this, SLOT (showToolTipSave ())); - connect (saveAsAction, SIGNAL (hovered ()), this,SLOT (showToolTipSaveAs ())); - - // connect modified signal - connect (m_editor, SIGNAL (modificationChanged(bool)), this, SLOT (newWindowTitle(bool)) ); - - m_fileName = ""; - newWindowTitle (false); - setWindowIcon(QIcon::fromTheme("accessories-text-editor",style->standardIcon (QStyle::SP_FileIcon))); - show (); -} diff -r fa52c6e84ae0 -r 97cb9286919c gui/src/FileEditorMdiSubWindow.h --- a/gui/src/FileEditorMdiSubWindow.h Mon Apr 30 19:38:24 2012 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,105 +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 FILEEDITORMDISUBWINDOW_H -#define FILEEDITORMDISUBWINDOW_H - -#include "MainWindow.h" - -#include -#include -#include -#include -#include -#include -#include -// Not available in the Debian repos yet! -// #include -#include "lexer/lexeroctavegui.h" - -const char UNNAMED_FILE[] = ""; -const char SAVE_FILE_FILTER[] = "Octave Files (*.m);;All Files (*.*)"; -enum MARKER - { - MARKER_BOOKMARK, - MARKER_BREAKPOINT - }; - -class FileEditorMdiSubWindow:public QMdiSubWindow -{ -Q_OBJECT - -public: - FileEditorMdiSubWindow (QWidget * parent = 0); - ~FileEditorMdiSubWindow (); - void loadFile (QString fileName); - void initEditor (QTerminal *terminalView, - LexerOctaveGui *lexer, - MainWindow *mainWindow); - -public slots: - - void newFile (); - void openFile (); - void saveFile (); - void saveFile (QString fileName); - void saveFileAs (); - - void showToolTipNew (); - void showToolTipOpen (); - void showToolTipSave (); - void showToolTipSaveAs (); - void showToolTipUndo (); - void showToolTipRedo (); - void registerModified (bool modified); - -protected: - void closeEvent(QCloseEvent *event); - -private: - int checkFileModified (QString msg, int cancelButton); - void construct (); - void doCommentSelectedText (bool comment); - QMenuBar *m_menuBar; - QToolBar *m_toolBar; - QsciScintilla *m_editor; - QStatusBar *m_statusBar; - QString m_fileName; - QString m_fileNameShort; - QTerminal* m_terminalView; - QAction* m_copyAction; - QAction* m_cutAction; - MainWindow* m_mainWindow; - int m_markerBookmark; - bool m_modified; - bool m_longTitle; - -private slots: - void newWindowTitle(bool modified); - void handleMarginClicked(int line, int margin, Qt::KeyboardModifiers state); - void handleCopyAvailable(bool enableCopy); - void runFile(); - void removeBookmark (); - void toggleBookmark (); - void nextBookmark(); - void prevBookmark(); - void commentSelectedText(); - void uncommentSelectedText(); - -}; - -#endif // FILEEDITORMDISUBWINDOW_H diff -r fa52c6e84ae0 -r 97cb9286919c gui/src/MainWindow.cpp --- a/gui/src/MainWindow.cpp Mon Apr 30 19:38:24 2012 -0700 +++ b/gui/src/MainWindow.cpp Mon May 07 00:53:54 2012 +0200 @@ -23,13 +23,14 @@ #include #include #include "MainWindow.h" -#include "FileEditorMdiSubWindow.h" +#include "FileEditor.h" #include "SettingsDialog.h" #define VERSION_STRING "Octave GUI (0.8.8)" MainWindow::MainWindow (QWidget * parent):QMainWindow (parent) { + // We have to set up all our windows, before we finally launch octave. construct (); OctaveLink::instance ()->launchOctave(); } @@ -39,33 +40,23 @@ } void -MainWindow::handleOpenFileRequest (QString fileName) +MainWindow::openExistingFile (QString fileName) { - reportStatusMessage (tr ("Opening file.")); - QPixmap pixmap; - if (pixmap.load (fileName)) - { -// ImageViewerMdiSubWindow *subWindow = new ImageViewerMdiSubWindow(pixmap, this); -// subWindow->setAttribute(Qt::WA_DeleteOnClose); -// m_centralMdiArea->addSubWindow(subWindow); -// subWindow->setWindowTitle(fileName); - } - else - { - openEditorFile(fileName); - } + reportStatusMessage (tr ("Opening file..")); + newEditorWindow(fileName); } void -MainWindow::openEditor () +MainWindow::newFile () { - openEditorFile(QString()); + newEditorWindow(QString()); } + void -MainWindow::openEditorFile (QString fileName) +MainWindow::newEditorWindow (QString fileName) { - FileEditorMdiSubWindow *subWindow = new FileEditorMdiSubWindow (m_centralMdiArea); - subWindow->setAttribute (Qt::WA_DeleteOnClose); + FileEditor *fileEditor = new FileEditor (); + fileEditor->setAttribute (Qt::WA_DeleteOnClose); // check whether lexer is already prepared and prepare it if not if ( m_lexer == NULL ) { @@ -97,12 +88,12 @@ } m_lexerAPI->prepare(); // prepare API info ... this make take some time } - subWindow->initEditor(m_terminalView, m_lexer, this); // init necessary informations for editor + fileEditor->initEditor(m_terminalView, m_lexer, this); // init necessary informations for editor if ( fileName.isEmpty() ) - subWindow->newFile (); + fileEditor->newFile (); else - subWindow->loadFile (fileName); + fileEditor->loadFile (fileName); } @@ -113,29 +104,6 @@ } void -MainWindow::openWebPage (QString url) -{ - m_documentationWidget->load (QUrl (url)); -} - -void -MainWindow::openChat () -{ - if (!m_ircWidget) - { - m_ircWidget = new QIRCWidget (); - m_ircWidget->setWindowTitle ("Chat"); - m_ircWidget->connectToServer ("irc.freenode.net", "Octave-GUI-User", "#octave"); - } - - if (!m_ircWidget->isVisible ()) - { - m_ircWidget->setVisible (true); - m_ircWidget->raise (); - } -} - -void MainWindow::handleSaveWorkspaceRequest () { QString selectedFile = @@ -170,12 +138,6 @@ } void -MainWindow::alignMdiWindows () -{ - m_centralMdiArea->tileSubWindows (); -} - -void MainWindow::openBugTrackerPage () { QDesktopServices::openUrl (QUrl ("http://savannah.gnu.org/bugs/?group=octave")); @@ -241,20 +203,13 @@ } void -MainWindow::showAboutQt () -{ - QMessageBox::aboutQt (this); -} - -void MainWindow::closeEvent (QCloseEvent * closeEvent) { reportStatusMessage (tr ("Saving data and shutting down.")); writeSettings (); m_closeApplication = true; // inform editor window that whole application is closed OctaveLink::instance ()->terminateOctave(); - m_centralMdiArea->closeAllSubWindows(); // send close events to subwindows - // (editor files can be saved!) + QMainWindow::closeEvent (closeEvent); } @@ -264,7 +219,6 @@ QSettings *settings = ResourceManager::instance ()->settings (); restoreGeometry (settings->value ("MainWindow/geometry").toByteArray ()); restoreState (settings->value ("MainWindow/windowState").toByteArray ()); - m_centralMdiArea->restoreGeometry (settings->value ("MdiArea/geometry").toByteArray ()); emit settingsChanged (); } @@ -274,22 +228,15 @@ QSettings *settings = ResourceManager::instance ()->settings (); settings->setValue ("MainWindow/geometry", saveGeometry ()); settings->setValue ("MainWindow/windowState", saveState ()); - settings->setValue ("MdiArea/geometry", m_centralMdiArea->saveGeometry ()); } void MainWindow::construct () { + // TODO: Check this. m_closeApplication = false; // flag for editor files when closed setWindowIcon (ResourceManager::instance ()->icon (ResourceManager::Octave)); - m_ircWidget = 0; - - // Initialize MDI area. - m_centralMdiArea = new QMdiArea (this); - m_centralMdiArea->setObjectName ("CentralMdiArea"); - m_centralMdiArea->setViewMode (QMdiArea::TabbedView); - // Setup dockable widgets and the status bar. m_workspaceView = new WorkspaceView (this); m_workspaceView->setStatusTip (tr ("View the variables in the active workspace.")); @@ -299,33 +246,9 @@ m_filesDockWidget->setStatusTip (tr ("Browse your files.")); m_statusBar = new QStatusBar (this); - // Documentation subwindow. - m_documentationWidget = new BrowserWidget (this); - m_documentationWidgetSubWindow = new NonClosableMdiSubWindow (this); - m_documentationWidgetSubWindow->setWidget (m_documentationWidget); - m_centralMdiArea->addSubWindow (m_documentationWidgetSubWindow, Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint); - - m_documentationWidgetSubWindow->setObjectName ("DocumentationWidgetSubWindow"); - m_documentationWidgetSubWindow->setWindowTitle (tr ("Documentation")); - m_documentationWidgetSubWindow - ->setWindowIcon (ResourceManager::instance ()->icon (ResourceManager::Documentation)); - m_documentationWidgetSubWindow->setFocusProxy (m_documentationWidget); - m_documentationWidgetSubWindow->setStatusTip (tr ("Browse the Octave documentation for help.")); - m_documentationWidgetSubWindow->setMinimumSize (300, 300); - // Octave Terminal subwindow. m_terminalView = new QTerminal(this); - m_terminalViewSubWindow = new NonClosableMdiSubWindow (this); - m_terminalViewSubWindow->setWidget (m_terminalView); - m_centralMdiArea->addSubWindow (m_terminalViewSubWindow, Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint); - - m_terminalViewSubWindow->setObjectName ("OctaveTerminalSubWindow"); - m_terminalViewSubWindow->setWindowTitle (tr ("Terminal")); - m_terminalViewSubWindow - ->setWindowIcon (ResourceManager::instance ()->icon (ResourceManager::Terminal)); - m_terminalViewSubWindow->setFocusProxy (m_terminalView); - m_terminalViewSubWindow->setStatusTip (tr ("Enter your commands into the Octave terminal.")); - m_terminalViewSubWindow->setMinimumSize (300, 300); + setCentralWidget (m_terminalView); m_lexer = NULL; // initialise the empty lexer for the edtiors @@ -336,8 +259,6 @@ QMenu *interfaceMenu = menuBar ()->addMenu (tr ("Interface")); - QAction *alignWindowsAction = interfaceMenu->addAction (tr ("Align Windows")); - interfaceMenu->addSeparator (); QAction *showWorkspaceAction = interfaceMenu->addAction (tr ("Workspace")); showWorkspaceAction->setCheckable (true); @@ -357,25 +278,19 @@ QAction *clearWorkspaceAction = workspaceMenu->addAction (tr ("Clear")); QMenu *communityMenu = menuBar ()->addMenu (tr ("Community")); - QAction *openChatAction = communityMenu->addAction (tr ("Chat")); - communityMenu->addSeparator(); QAction *reportBugAction = communityMenu->addAction (tr ("Report Bug")); QAction *agoraAction = communityMenu->addAction (tr ("Agora")); QAction *octaveForgeAction = communityMenu->addAction (tr ("Octave Forge")); communityMenu->addSeparator (); QAction *aboutOctaveAction = communityMenu->addAction (tr ("About Octave")); - QAction *aboutQt = communityMenu->addAction (tr ("About Qt")); connect (settingsAction, SIGNAL (triggered ()), this, SLOT (processSettingsDialogRequest ())); connect (exitAction, SIGNAL (triggered ()), this, SLOT (close ())); - connect (alignWindowsAction, SIGNAL (triggered ()), this, SLOT (alignMdiWindows ())); - connect (openEditorAction, SIGNAL (triggered ()), this, SLOT (openEditor ())); - connect (openChatAction, SIGNAL (triggered ()), this, SLOT (openChat ())); + connect (openEditorAction, SIGNAL (triggered ()), this, SLOT (newFile ())); connect (reportBugAction, SIGNAL (triggered ()), this, SLOT (openBugTrackerPage ())); connect (agoraAction, SIGNAL (triggered ()), this, SLOT (openAgoraPage ())); connect (octaveForgeAction, SIGNAL (triggered ()), this, SLOT (openOctaveForgePage ())); connect (aboutOctaveAction, SIGNAL (triggered ()), this, SLOT (showAboutOctave ())); - connect (aboutQt, SIGNAL (triggered ()), this, SLOT (showAboutQt ())); connect (showWorkspaceAction, SIGNAL (toggled (bool)), m_workspaceView, SLOT (setShown (bool))); connect (m_workspaceView, SIGNAL (activeChanged (bool)), showWorkspaceAction, SLOT (setChecked (bool))); @@ -388,7 +303,7 @@ //connect (this, SIGNAL (settingsChanged ()), m_historyDockWidget, SLOT (noticeSettings ())); connect (this, SIGNAL (settingsChanged ()), m_filesDockWidget, SLOT (noticeSettings ())); - connect (m_filesDockWidget, SIGNAL (openFile (QString)), this, SLOT (handleOpenFileRequest (QString))); + connect (m_filesDockWidget, SIGNAL (openFile (QString)), this, SLOT (openExistingFile (QString))); connect (m_historyDockWidget, SIGNAL (information (QString)), this, SLOT (reportStatusMessage (QString))); connect (m_historyDockWidget, SIGNAL (commandDoubleClicked (QString)), this, SLOT (handleCommandDoubleClicked (QString))); connect (saveWorkspaceAction, SIGNAL (triggered ()), this, SLOT (handleSaveWorkspaceRequest ())); @@ -397,7 +312,6 @@ setWindowTitle (QString (VERSION_STRING)); - setCentralWidget (m_centralMdiArea); addDockWidget (Qt::LeftDockWidgetArea, m_workspaceView); addDockWidget (Qt::LeftDockWidgetArea, m_historyDockWidget); addDockWidget (Qt::RightDockWidgetArea, m_filesDockWidget); @@ -405,6 +319,5 @@ readSettings (); updateTerminalFont(); - openWebPage ("http://www.gnu.org/software/octave/doc/interpreter/"); } diff -r fa52c6e84ae0 -r 97cb9286919c gui/src/MainWindow.h --- a/gui/src/MainWindow.h Mon Apr 30 19:38:24 2012 -0700 +++ b/gui/src/MainWindow.h Mon May 07 00:53:54 2012 +0200 @@ -18,6 +18,7 @@ #ifndef MAINWINDOW_H #define MAINWINDOW_H +// Qt includes #include #include #include @@ -25,32 +26,22 @@ #include #include #include -#include #include #include + +// QScintilla includes +#include +#include "lexer/lexeroctavegui.h" + +// QTerminal includes +#include "QTerminal.h" + +// Own includes #include "ResourceManager.h" #include "OctaveLink.h" #include "WorkspaceView.h" #include "HistoryDockWidget.h" #include "FilesDockWidget.h" -#include "BrowserWidget.h" -#include "lexer/lexeroctavegui.h" -#include "QTerminal.h" -#include "QIRCWidget.h" - -class NonClosableMdiSubWindow : public QMdiSubWindow -{ - Q_OBJECT -public: - explicit NonClosableMdiSubWindow (QWidget *parent = 0) - : QMdiSubWindow (parent) { } - virtual ~NonClosableMdiSubWindow () { } -protected: - void closeEvent (QCloseEvent *closeEvent) - { - closeEvent->ignore (); - } -}; /** * \class MainWindow @@ -85,23 +76,19 @@ void settingsChanged (); public slots: - void handleOpenFileRequest (QString fileName); + void openExistingFile (QString fileName); void reportStatusMessage (QString statusMessage); - void openWebPage (QString url); - void openChat (); void handleSaveWorkspaceRequest (); void handleLoadWorkspaceRequest (); void handleClearWorkspaceRequest (); void handleCommandDoubleClicked (QString command); - void alignMdiWindows (); - void openEditor (); - void openEditorFile (QString fileName); + void newFile (); + void newEditorWindow (QString fileName); void openBugTrackerPage (); void openAgoraPage (); void openOctaveForgePage (); void processSettingsDialogRequest (); void showAboutOctave (); - void showAboutQt (); void updateTerminalFont (); protected: @@ -112,15 +99,8 @@ private: void construct (); void establishOctaveLink (); - QMdiArea *m_centralMdiArea; - // Mdi sub windows. QTerminal *m_terminalView; - BrowserWidget *m_documentationWidget; - QIRCWidget *m_ircWidget; - - NonClosableMdiSubWindow *m_terminalViewSubWindow; - NonClosableMdiSubWindow *m_documentationWidgetSubWindow; // Dock widgets. WorkspaceView *m_workspaceView; diff -r fa52c6e84ae0 -r 97cb9286919c gui/src/SettingsDialog.cpp --- a/gui/src/SettingsDialog.cpp Mon Apr 30 19:38:24 2012 -0700 +++ b/gui/src/SettingsDialog.cpp Mon May 07 00:53:54 2012 +0200 @@ -56,33 +56,6 @@ ui->proxyPort->setText (settings->value ("proxyPort").toString ()); ui->proxyUserName->setText (settings->value ("proxyUserName").toString ()); ui->proxyPassword->setText (settings->value ("proxyPassword").toString ()); - - // Short cuts - QStringList headerLabels; - headerLabels << "Modifier" << "Key" << "Action"; - ui->shortcutTableWidget->setColumnCount (3); - ui->shortcutTableWidget->setRowCount (10); - ui->shortcutTableWidget->horizontalHeader ()->setStretchLastSection (true); - ui->shortcutTableWidget->setHorizontalHeaderLabels (headerLabels); - ui->shortcutTableWidget->setSelectionBehavior(QAbstractItemView::SelectRows); - ui->shortcutTableWidget->setSelectionMode(QAbstractItemView::SingleSelection); - - /* - newAction->setShortcut(QKeySequence::New); - openAction->setShortcut(QKeySequence::Open); - saveAction->setShortcut(QKeySequence::Save); - saveAsAction->setShortcut(QKeySequence::SaveAs); - undoAction->setShortcut(QKeySequence::Undo); - redoAction->setShortcut(QKeySequence::Redo); - m_copyAction->setShortcut(QKeySequence::Copy); - m_cutAction->setShortcut(QKeySequence::Cut); - pasteAction->setShortcut(QKeySequence::Paste); - runAction->setShortcut(Qt::Key_F5); - nextBookmarkAction->setShortcut(Qt::Key_F2); - prevBookmarkAction->setShortcut(Qt::SHIFT + Qt::Key_F2); - toggleBookmarkAction->setShortcut(Qt::Key_F7); - commentSelectedAction->setShortcut(Qt::CTRL + Qt::Key_R); - uncommentSelectedAction->setShortcut(Qt::CTRL + Qt::Key_T);*/ } SettingsDialog::~SettingsDialog () diff -r fa52c6e84ae0 -r 97cb9286919c gui/src/SettingsDialog.ui --- a/gui/src/SettingsDialog.ui Mon Apr 30 19:38:24 2012 -0700 +++ b/gui/src/SettingsDialog.ui Mon May 07 00:53:54 2012 +0200 @@ -34,93 +34,62 @@ 0 - - - Interface - - - - - - Shortcuts: - - - - - - - false - - - - - - - - - false - - - Add - - - - - - - false - - - Remove - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Editor - + - + - + - - - true + + + Font - - Use custom file editor: + + + + + + false - - - false - + - emacs + Font Size + + + + 2 + + + 96 + + + 10 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + @@ -172,30 +141,74 @@ - + + + Qt::Vertical + + + + 20 + 40 + + + + + + - + + + true + + + Use custom file editor: + + + + + + + false + + + emacs + + + + + + + + + + Terminal + + + + + + Font - + false - + Font Size - + 2 @@ -208,7 +221,7 @@ - + Qt::Horizontal @@ -223,84 +236,20 @@ - + Qt::Vertical 20 - 40 + 321 - - - Terminal - - - - - 10 - 10 - 436 - 22 - - - - - - - Font - - - - - - - false - - - - - - - Font Size - - - - - - - 2 - - - 96 - - - 10 - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - File Browser diff -r fa52c6e84ae0 -r 97cb9286919c gui/src/WorkspaceView.cpp --- a/gui/src/WorkspaceView.cpp Mon Apr 30 19:38:24 2012 -0700 +++ b/gui/src/WorkspaceView.cpp Mon May 07 00:53:54 2012 +0200 @@ -59,8 +59,10 @@ m_variablesTreeWidget->setAlternatingRowColors (true); m_variablesTreeWidget->setAnimated (true); - connect (this, SIGNAL (visibilityChanged(bool)), this, SLOT(handleVisibilityChanged(bool))); - connect (OctaveLink::instance(), SIGNAL (symbolTableChanged()), this, SLOT (fetchSymbolTable())); + connect (this, SIGNAL (visibilityChanged (bool)), + this, SLOT(handleVisibilityChanged (bool))); + connect (OctaveLink::instance(), SIGNAL (updateSymbolTable ()), + this, SLOT (fetchSymbolTable ())); } void @@ -68,7 +70,7 @@ { treeItem->setData (0, 0, QString (symbolRecord.name ().c_str ())); treeItem->setData (1, 0, - QString (symbolRecord.varval ().type_name ().c_str ())); + QString (symbolRecord.varval ().type_name ().c_str ())); treeItem->setData (2, 0, OctaveLink::octaveValueAsQString (symbolRecord. varval ())); diff -r fa52c6e84ae0 -r 97cb9286919c gui/src/backend/OctaveCallbackThread.cpp --- a/gui/src/backend/OctaveCallbackThread.cpp Mon Apr 30 19:38:24 2012 -0700 +++ b/gui/src/backend/OctaveCallbackThread.cpp Mon May 07 00:53:54 2012 +0200 @@ -39,9 +39,9 @@ bool running = true; while (running) { - OctaveLink::instance ()->emitSymbolTableChanged(); - OctaveLink::instance ()->updateHistoryModel (); - usleep (500000); + OctaveLink::instance ()->triggerUpdateSymbolTable (); + OctaveLink::instance ()->triggerUpdateHistoryModel (); + usleep (1000000); m_runningSemaphore->acquire (); running = m_running; diff -r fa52c6e84ae0 -r 97cb9286919c gui/src/backend/OctaveLink.cpp --- a/gui/src/backend/OctaveLink.cpp Mon Apr 30 19:38:24 2012 -0700 +++ b/gui/src/backend/OctaveLink.cpp Mon May 07 00:53:54 2012 +0200 @@ -121,12 +121,15 @@ std::list < SymbolRecord >::iterator iterator; for (iterator = allVariables.begin (); iterator != allVariables.end (); iterator++) - m_symbolTableBuffer.append (iterator->dup()); + { + SymbolRecord s = iterator->dup (); + m_symbolTableBuffer.append (s); + } return m_symbolTableBuffer; } void -OctaveLink::updateHistoryModel () +OctaveLink::triggerUpdateHistoryModel () { // Determine the client's (our) history length and the one of the server. int clientHistoryLength = m_historyModel->rowCount (); diff -r fa52c6e84ae0 -r 97cb9286919c gui/src/backend/OctaveLink.h --- a/gui/src/backend/OctaveLink.h Mon Apr 30 19:38:24 2012 -0700 +++ b/gui/src/backend/OctaveLink.h Mon May 07 00:53:54 2012 +0200 @@ -111,12 +111,12 @@ */ QList < SymbolRecord > copyCurrentSymbolTable (); - void updateHistoryModel (); + void triggerUpdateHistoryModel (); QStringListModel *historyModel (); - void emitSymbolTableChanged() { emit symbolTableChanged(); } + void triggerUpdateSymbolTable() { emit updateSymbolTable(); } signals: - void symbolTableChanged (); + void updateSymbolTable (); private: OctaveLink (); diff -r fa52c6e84ae0 -r 97cb9286919c gui/src/src.pro --- a/gui/src/src.pro Mon Apr 30 19:38:24 2012 -0700 +++ b/gui/src/src.pro Mon May 07 00:53:54 2012 +0200 @@ -31,7 +31,6 @@ win32-msvc*: include(msvc.pri) LIBS += -lqscintilla2 \ - -L../qirc/libqirc/$$LIBDIR_SUFFIX -lqirc \ -L../qterminal/libqterminal/$$LIBDIR_SUFFIX -lqterminal \ $$system(mkoctfile -p LIBS) \ $$system(mkoctfile -p OCTAVE_LIBS) @@ -41,7 +40,7 @@ } # Includepaths and libraries to link against: -INCLUDEPATH += . backend ../qterminal/libqterminal ../qirc/libqirc \ +INCLUDEPATH += . backend ../qterminal/libqterminal \ $$system(mkoctfile -p INCFLAGS) INCFLAGS += $$system(mkoctfile -p INCFLAGS) mac { @@ -80,8 +79,6 @@ WorkspaceView.cpp \ HistoryDockWidget.cpp \ FilesDockWidget.cpp \ - FileEditorMdiSubWindow.cpp \ - BrowserWidget.cpp \ SettingsDialog.cpp \ OctaveGUI.cpp \ ResourceManager.cpp \ @@ -90,7 +87,8 @@ backend/OctaveLink.cpp \ backend/OctaveMainThread.cpp \ backend/ReadlineAdapter.cpp \ - WelcomeWizard.cpp + WelcomeWizard.cpp \ + FileEditor.cpp HEADERS += \ lexer/lexeroctavegui.h \ @@ -98,8 +96,6 @@ WorkspaceView.h \ HistoryDockWidget.h \ FilesDockWidget.h \ - FileEditorMdiSubWindow.h \ - BrowserWidget.h \ SettingsDialog.h \ ResourceManager.h \ CommandLineParser.h \ @@ -107,7 +103,8 @@ backend/OctaveLink.h \ backend/OctaveMainThread.h \ backend/ReadlineAdapter.h \ - WelcomeWizard.h + WelcomeWizard.h \ + FileEditor.h FORMS += \ SettingsDialog.ui \