view gui/src/workspace-view.cc @ 14720:cecc7da96e2a gui

Added update events for the command history model and workspace model. * history-dockwidget.cc: Moved string list model to dock widget. * octave-event-observer.h: Removed constness from accepted and rejected methods. * octave-event.h: Removed constness from accepted and rejected methods, add new event types. * octave-link: Almost removed all Qt code. * workspace-model: Moved update timer to model. * workspace-view: Model workspace model to widget.
author Jacob Dawid <jacob.dawid@googlemail.com>
date Mon, 04 Jun 2012 21:28:08 +0200
parents 89c64340e9ab
children 8c4d5029d933
line wrap: on
line source

/* 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 <http://www.gnu.org/licenses/>.
 */

#include "workspace-view.h"
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QPushButton>

workspace_view::workspace_view (QWidget * parent) : QDockWidget
  (parent)
{
  setObjectName ("WorkspaceView");
  setWindowTitle (tr ("Workspace"));

  _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);

  setWidget (new QWidget (this));
  QVBoxLayout *layout = new QVBoxLayout ();
  layout->addWidget (_workspace_tree_view);
  layout->setMargin (2);
  widget ()->setLayout (layout);

  connect (this, SIGNAL (visibilityChanged (bool)),
           this, SLOT(handle_visibility_changed (bool)));

  connect (_workspace_model, SIGNAL(expand_request()),
           _workspace_tree_view, SLOT(expandAll()));
}

void
workspace_view::handle_visibility_changed (bool visible)
{
  if (visible)
  emit active_changed (true);
}

void
workspace_view::closeEvent (QCloseEvent *event)
{
  emit active_changed (false);
  QDockWidget::closeEvent (event);
}