# HG changeset patch # User Jacob Dawid # Date 1342609638 14400 # Node ID 5d74d8b982a5711b1656a3a83ca09e8e6e125884 # Parent 355d6c165df05fad8632c8fb7aaec2500c9559e6 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. diff --git a/gui/src/m-editor/file-editor-tab.cc b/gui/src/m-editor/file-editor-tab.cc --- a/gui/src/m-editor/file-editor-tab.cc +++ b/gui/src/m-editor/file-editor-tab.cc @@ -29,7 +29,6 @@ #include #include #include - #include "resource-manager.h" #include #include @@ -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 (); diff --git a/gui/src/m-editor/file-editor.cc b/gui/src/m-editor/file-editor.cc --- 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); diff --git a/gui/src/workspace-view.cc b/gui/src/workspace-view.cc --- 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); diff --git a/gui/src/workspace-view.h b/gui/src/workspace-view.h --- a/gui/src/workspace-view.h +++ b/gui/src/workspace-view.h @@ -44,6 +44,7 @@ protected slots: void collapse_requested (QModelIndex index); void expand_requested (QModelIndex index); + void item_double_clicked (QModelIndex index); private: QTreeView *_workspace_tree_view;