Mercurial > hg > octave-terminal
changeset 14874:5d74d8b982a5 gui
Forgot to have a fallback lexer when the file suffix is unknown. Removed unused variable and added comments.
* file-editor-tab.cc: Made the bash lexer the default lexer for unknown file types.
* file-editor.cc: Removed unused variable.
* workspace-view: Added comments and slot for items being double clicked in the workspace view.
author | Jacob Dawid <jacob.dawid@gmail.com> |
---|---|
date | Wed, 18 Jul 2012 07:07:18 -0400 |
parents | 355d6c165df0 |
children | 3fd857c284fe |
files | gui/src/m-editor/file-editor-tab.cc gui/src/m-editor/file-editor.cc gui/src/workspace-view.cc gui/src/workspace-view.h |
diffstat | 4 files changed, 44 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/gui/src/m-editor/file-editor-tab.cc +++ b/gui/src/m-editor/file-editor-tab.cc @@ -29,7 +29,6 @@ #include <Qsci/qscilexerperl.h> #include <Qsci/qscilexerbatch.h> #include <Qsci/qscilexerdiff.h> - #include "resource-manager.h" #include <QMessageBox> #include <QVBoxLayout> @@ -243,14 +242,18 @@ } lexer_api->prepare (); // prepare API info ... this make take some time } - else if (_file_name.endsWith (".c") || _file_name.endsWith (".cc") || _file_name.endsWith (".cpp")) + else if (_file_name.endsWith (".c") + || _file_name.endsWith (".cc") + || _file_name.endsWith (".cpp") + || _file_name.endsWith (".cxx") + || _file_name.endsWith (".c++") + || _file_name.endsWith (".h") + || _file_name.endsWith (".hh") + || _file_name.endsWith (".hpp") + || _file_name.endsWith (".h++")) { lexer = new QsciLexerCPP (); } - else if (_file_name.endsWith (".sh")) - { - lexer = new QsciLexerBash (); - } else if (_file_name.endsWith (".pl")) { lexer = new QsciLexerPerl (); @@ -263,6 +266,10 @@ { lexer = new QsciLexerDiff (); } + else // Default to bash lexer. + { + lexer = new QsciLexerBash (); + } QSettings *settings = resource_manager::instance ()->get_settings ();
--- a/gui/src/m-editor/file-editor.cc +++ b/gui/src/m-editor/file-editor.cc @@ -320,7 +320,6 @@ file_editor::construct () { QWidget *widget = new QWidget (this); - QSettings *settings = resource_manager::instance ()->get_settings (); QStyle *style = QApplication::style (); _menu_bar = new QMenuBar (widget);
--- a/gui/src/workspace-view.cc +++ b/gui/src/workspace-view.cc @@ -26,22 +26,35 @@ setObjectName ("WorkspaceView"); setWindowTitle (tr ("Workspace")); + // Create a new workspace model. _workspace_model = new workspace_model (); - _workspace_tree_view = new QTreeView (this); - _workspace_tree_view->setHeaderHidden (false); - _workspace_tree_view->setAlternatingRowColors (true); - //_workspace_tree_view->setAnimated (true); - _workspace_tree_view->setModel (_workspace_model); - _workspace_tree_view->setTextElideMode (Qt::ElideRight); - _workspace_tree_view->setWordWrap (false); + _workspace_tree_view = new QTreeView (this); // Create a new tree view. + _workspace_tree_view->setHeaderHidden (false); // Do not show header columns. + _workspace_tree_view->setAlternatingRowColors (true); // Activate alternating row colors. + _workspace_tree_view->setAnimated (false); // Deactivate animations because of strange glitches. + _workspace_tree_view->setTextElideMode (Qt::ElideRight);// Elide text to the right side of the cells. + _workspace_tree_view->setWordWrap (false); // No wordwrapping in cells. + _workspace_tree_view->setModel (_workspace_model); // Assign model. + // Set an empty widget, so we can assign a layout to it. setWidget (new QWidget (this)); + + // Create a new layout and add widgets to it. QVBoxLayout *layout = new QVBoxLayout (); layout->addWidget (_workspace_tree_view); layout->setMargin (2); + + // Set the empty widget to have our layout. widget ()->setLayout (layout); + // Initialize collapse/expand state of the workspace subcategories. + _explicit_collapse.local = false; + _explicit_collapse.global = false; + _explicit_collapse.persistent = false; + _explicit_collapse.hidden = false; + + // Connect signals and slots. connect (this, SIGNAL (visibilityChanged (bool)), this, SLOT(handle_visibility_changed (bool))); @@ -53,10 +66,9 @@ connect (_workspace_tree_view, SIGNAL (expanded (QModelIndex)), this, SLOT (expand_requested (QModelIndex))); - _explicit_collapse.local = false; - _explicit_collapse.global = false; - _explicit_collapse.persistent = false; - _explicit_collapse.hidden = false; + connect (_workspace_tree_view, SIGNAL (doubleClicked (QModelIndex)), + this, SLOT (item_double_clicked (QModelIndex))); + } void @@ -172,6 +184,13 @@ } void +workspace_view::item_double_clicked (QModelIndex index) +{ + Q_UNUSED (index); + // TODO: Implement opening a dialog that allows the user to change a variable in the workspace. +} + +void workspace_view::closeEvent (QCloseEvent *event) { emit active_changed (false);