# HG changeset patch
# User Richard Crozier <richard.crozier@yahoo.co.uk>
# Date 1360187104 0
# Node ID d9dcbf0cc8e34c196beb3c2049578e615cac3a45
# Parent  d53fa7e43aa919f9f0e8b8be10fa3ed911dc64f0
Created common octave_dock_widget class

* octave_dock_widget.h : New class octave_dock_widget with common dock widget methods, slots and signals
* file_editor_interface.h: Now inherit from octave_dock_widget, removed common dock widget code
* file_editor.h: Now inherit from octave_dock_widget, removed common dock widget code
* file_editor.cc: Now inherit from octave_dock_widget, removed common dock widget code
* files_dockwidget.h: Now inherit from octave_dock_widget, removed common dock widget code
* files_dockwidget.cc: Now inherit from octave_dock_widget, removed common dock widget code
* history_dockwidget.h: Now inherit from octave_dock_widget, removed common dock widget code
* history_dockwidget.cc: Now inherit from octave_dock_widget, removed common dock widget methods
* terminal_dockwidget.h: Now inherit from octave_dock_widget, removed common dock widget code
* terminal_dockwidget.cc: Now inherit from octave_dock_widget, removed common dock widget code
* module.mk: Added octave_dock_widget

diff -r d53fa7e43aa9 -r d9dcbf0cc8e3 libgui/src/files-dockwidget.cc
--- a/libgui/src/files-dockwidget.cc	Mon Feb 04 23:53:51 2013 +0000
+++ b/libgui/src/files-dockwidget.cc	Wed Feb 06 21:45:04 2013 +0000
@@ -36,7 +36,7 @@
 #include <QHeaderView>
 
 files_dock_widget::files_dock_widget (QWidget *p)
-  : QDockWidget (p)
+  : octave_dock_widget (p)
 {
   setObjectName ("FilesDockWidget");
   setWindowIcon (QIcon(":/actions/icons/logo.png"));
@@ -114,11 +114,6 @@
     completer = new QCompleter (_file_system_model, this);
   _current_directory->setCompleter (completer);
 
-  connect (this, SIGNAL (visibilityChanged (bool)),
-           this, SLOT (handle_visibility_changed (bool)));
-  // topLevelChanged is emitted when floating property changes (floating = true)
-  connect (this, SIGNAL (topLevelChanged(bool)), this, SLOT(top_level_changed(bool)));
-
   setFocusProxy (_current_directory);
 }
 
@@ -203,28 +198,3 @@
   //if (settings.value ("showHiddenFiles").toBool ())
   // TODO: React on option for hidden files.
 }
-
-void
-files_dock_widget::handle_visibility_changed (bool visible)
-{
-  if (visible)
-    emit active_changed (true);
-}
-
-void
-files_dock_widget::closeEvent (QCloseEvent *e)
-{
-  emit active_changed (false);
-  QDockWidget::closeEvent (e);
-}
-
-// slot for signal that is emitted when floating property changes
-void
-files_dock_widget::top_level_changed (bool floating)
-{
-  if(floating)
-    {
-      setWindowFlags(Qt::Window);  // make a window from the widget when floating
-      show();                      // make it visible again since setWindowFlags hides it
-    }
-}
diff -r d53fa7e43aa9 -r d9dcbf0cc8e3 libgui/src/files-dockwidget.h
--- a/libgui/src/files-dockwidget.h	Mon Feb 04 23:53:51 2013 +0000
+++ b/libgui/src/files-dockwidget.h	Wed Feb 06 21:45:04 2013 +0000
@@ -35,14 +35,14 @@
 #include <QAction>
 #include <QTreeView>
 
-#include <QDockWidget>
 #include <QLineEdit>
+#include "octave-dock-widget.h"
 
 /**
    \class files_dock_widget
    \brief Dock widget to display files in the current directory.
 */
-class files_dock_widget : public QDockWidget
+class files_dock_widget : public octave_dock_widget
 {
   Q_OBJECT
   public:
@@ -51,6 +51,7 @@
   ~files_dock_widget ();
 
 public slots:
+
   /** Slot for handling a change in directory via double click. */
   void item_double_clicked (const QModelIndex & index);
 
@@ -68,12 +69,6 @@
   /** Tells the widget to react on changed settings. */
   void notice_settings ();
 
-  /** Slot to steer changing visibility from outside. */
-  void handle_visibility_changed (bool visible);
-
-  /** Slot when floating property changes */
-  void top_level_changed (bool floating);
-
 signals:
   /** Emitted, whenever the user requested to open a file. */
   void open_file (const QString& fileName);
@@ -81,11 +76,7 @@
   /** Emitted, whenever the currently displayed directory changed. */
   void displayed_directory_changed (const QString& directory);
 
-  /** Custom signal that tells if a user has clicke away that dock widget. */
-  void active_changed (bool active);
-
 protected:
-  void closeEvent (QCloseEvent *event);
 
 private:
   // TODO: Add toolbar with buttons for navigating the path, creating dirs, etc
diff -r d53fa7e43aa9 -r d9dcbf0cc8e3 libgui/src/history-dockwidget.cc
--- a/libgui/src/history-dockwidget.cc	Mon Feb 04 23:53:51 2013 +0000
+++ b/libgui/src/history-dockwidget.cc	Wed Feb 06 21:45:04 2013 +0000
@@ -37,7 +37,7 @@
 #include "octave-link.h"
 
 history_dock_widget::history_dock_widget (QWidget * p)
-  : QDockWidget (p)
+  : octave_dock_widget (p)
 {
   setObjectName ("HistoryDockWidget");
   construct ();
@@ -71,23 +71,11 @@
 
   widget ()->setLayout (vbox_layout);
 
-  connect (_filter_line_edit,
-           SIGNAL (textEdited (QString)),
-           &_sort_filter_proxy_model,
-           SLOT (setFilterWildcard (QString)));
+  connect (_filter_line_edit, SIGNAL (textEdited (QString)),
+           &_sort_filter_proxy_model, SLOT (setFilterWildcard (QString)));
 
-  connect (_history_list_view,
-           SIGNAL (doubleClicked (QModelIndex)),
-           this,
-           SLOT (handle_double_click (QModelIndex)));
-
-  connect (this,
-           SIGNAL (visibilityChanged (bool)),
-           this,
-           SLOT (handle_visibility_changed (bool)));
-
-  // topLevelChanged is emitted when floating property changes (floating = true)
-  connect (this, SIGNAL (topLevelChanged(bool)), this, SLOT(top_level_changed(bool)));
+  connect (_history_list_view, SIGNAL (doubleClicked (QModelIndex)),
+           this, SLOT (handle_double_click (QModelIndex)));
 
   _update_history_model_timer.setInterval (200);
   _update_history_model_timer.setSingleShot (true);
@@ -142,13 +130,6 @@
 }
 
 void
-history_dock_widget::handle_visibility_changed (bool visible)
-{
-  if (visible)
-    emit active_changed (true);
-}
-
-void
 history_dock_widget::request_history_model_update ()
 {
   octave_link::post_event (this, &history_dock_widget::update_history_callback);
@@ -161,24 +142,6 @@
 }
 
 void
-history_dock_widget::closeEvent (QCloseEvent *e)
-{
-  emit active_changed (false);
-  QDockWidget::closeEvent (e);
-}
-
-// slot for signal that is emitted when floating property changes
-void
-history_dock_widget::top_level_changed (bool floating)
-{
-  if(floating)
-    {
-      setWindowFlags(Qt::Window);  // make a window from the widget when floating
-      show();                      // make it visible again since setWindowFlags hides it
-    }
-}
-
-void
 history_dock_widget::update_history_callback (void)
 {
   static bool scroll_window = false;
diff -r d53fa7e43aa9 -r d9dcbf0cc8e3 libgui/src/history-dockwidget.h
--- a/libgui/src/history-dockwidget.h	Mon Feb 04 23:53:51 2013 +0000
+++ b/libgui/src/history-dockwidget.h	Wed Feb 06 21:45:04 2013 +0000
@@ -23,25 +23,22 @@
 #ifndef HISTORYDOCKWIDGET_H
 #define HISTORYDOCKWIDGET_H
 
-#include <QDockWidget>
 #include <QLineEdit>
 #include <QListView>
 #include <QSortFilterProxyModel>
 #include <QStringListModel>
 #include <QTimer>
+#include "octave-dock-widget.h"
 
-class history_dock_widget : public QDockWidget
+class history_dock_widget : public octave_dock_widget
 {
   Q_OBJECT
   public:
   history_dock_widget (QWidget *parent = 0);
 
 public slots:
-  void handle_visibility_changed (bool visible);
   void request_history_model_update ();
   void reset_model ();
-  /** Slot when floating property changes */
-  void top_level_changed (bool floating);
 
 signals:
   void information (const QString& message);
@@ -49,10 +46,8 @@
   /** Emitted, whenever the user double-clicked a command in the history. */
   void command_double_clicked (const QString& command);
 
-  /** Custom signal that tells if a user has clicked away that dock widget. */
-  void active_changed (bool active);
 protected:
-  void closeEvent (QCloseEvent *event);
+
 private slots:
   void handle_double_click (QModelIndex modelIndex);
   void handle_contextmenu_copy(bool flag);
diff -r d53fa7e43aa9 -r d9dcbf0cc8e3 libgui/src/m-editor/file-editor-interface.h
--- a/libgui/src/m-editor/file-editor-interface.h	Mon Feb 04 23:53:51 2013 +0000
+++ b/libgui/src/m-editor/file-editor-interface.h	Wed Feb 06 21:45:04 2013 +0000
@@ -23,22 +23,19 @@
 #ifndef FILEEDITORINTERFACE_H
 #define FILEEDITORINTERFACE_H
 
-#include <QDockWidget>
 #include <QMenu>
 #include <QToolBar>
+#include "octave-dock-widget.h"
 
-class file_editor_interface : public QDockWidget
+class file_editor_interface : public octave_dock_widget
 {
   Q_OBJECT
 
   public:
   file_editor_interface (QWidget *p)
-    : QDockWidget (p)
+    : octave_dock_widget (p)
   {
     setObjectName ("FileEditor");
-
-    connect (this, SIGNAL (visibilityChanged (bool)), this,
-             SLOT (handle_visibility_changed (bool)));
   }
 
   virtual ~file_editor_interface () { }
@@ -56,22 +53,12 @@
   virtual void request_open_file () = 0;
   virtual void request_open_file (const QString& fileName) = 0;
 
-signals:
-  void active_changed (bool active);
+//signals:
 
-protected:
-  void closeEvent (QCloseEvent *e)
-  {
-    emit active_changed (false);
-    QDockWidget::closeEvent (e);
-  }
+//protected:
 
-protected slots:
-  void handle_visibility_changed (bool visible)
-  {
-    if (visible)
-      emit active_changed (true);
-  }
+//protected slots:
+
 };
 
 #endif // FILEEDITORINTERFACE_H
diff -r d53fa7e43aa9 -r d9dcbf0cc8e3 libgui/src/m-editor/file-editor.cc
--- a/libgui/src/m-editor/file-editor.cc	Mon Feb 04 23:53:51 2013 +0000
+++ b/libgui/src/m-editor/file-editor.cc	Wed Feb 06 21:45:04 2013 +0000
@@ -517,17 +517,6 @@
   emit fetab_settings_changed ();
 }
 
-// slot for signal that is emitted when floating property changes
-void
-file_editor::top_level_changed (bool floating)
-{
-  if(floating)
-    {
-      setWindowFlags(Qt::Window);  // make a window from the widget when floating
-      show();                      // make it visible again since setWindowFlag hides it
-    }
-}
-
 void
 file_editor::construct ()
 {
@@ -751,8 +740,6 @@
            SIGNAL (tabCloseRequested (int)), this, SLOT (handle_tab_close_request (int)));
   connect (_tab_widget,
            SIGNAL (currentChanged(int)), this, SLOT (active_tab_changed (int)));
-  // topLevelChanged is emitted when floating property changes (floating = true)
-  connect (this, SIGNAL (topLevelChanged(bool)), this, SLOT(top_level_changed(bool)));
 
   resize (500, 400);
   setWindowIcon (QIcon(":/actions/icons/logo.png"));
diff -r d53fa7e43aa9 -r d9dcbf0cc8e3 libgui/src/m-editor/file-editor.h
--- a/libgui/src/m-editor/file-editor.h	Mon Feb 04 23:53:51 2013 +0000
+++ b/libgui/src/m-editor/file-editor.h	Wed Feb 06 21:45:04 2013 +0000
@@ -123,9 +123,6 @@
   void handle_mru_add_file (const QString& file_name);
   void check_conflict_save (const QString& fileName, bool remove_on_success);
 
-  /** Slot when floating property changes */
-  void top_level_changed (bool floating);
-
   /** Tells the editor to react on changed settings. */
   void notice_settings ();
 
diff -r d53fa7e43aa9 -r d9dcbf0cc8e3 libgui/src/module.mk
--- a/libgui/src/module.mk	Mon Feb 04 23:53:51 2013 +0000
+++ b/libgui/src/module.mk	Wed Feb 06 21:45:04 2013 +0000
@@ -73,7 +73,8 @@
   src/moc-workspace-view.cc \
   src/octave-adapter/moc-octave-main-thread.cc \
   src/qtinfo/moc-parser.cc \
-  src/qtinfo/moc-webinfo.cc
+  src/qtinfo/moc-webinfo.cc \
+  src/moc-octave-dock-widget.cc
 
 octave_gui_RC = src/qrc-resource.cc
 
@@ -86,6 +87,7 @@
 BUILT_SOURCES += $(octave_gui_UI_H)
 
 noinst_HEADERS += \
+  src/octave-dock-widget.h \
   src/documentation-dockwidget.h \
   src/files-dockwidget.h \
   src/history-dockwidget.h \
diff -r d53fa7e43aa9 -r d9dcbf0cc8e3 libgui/src/terminal-dockwidget.cc
--- a/libgui/src/terminal-dockwidget.cc	Mon Feb 04 23:53:51 2013 +0000
+++ b/libgui/src/terminal-dockwidget.cc	Wed Feb 06 21:45:04 2013 +0000
@@ -27,7 +27,7 @@
 #include "terminal-dockwidget.h"
 
 terminal_dock_widget::terminal_dock_widget (QTerminal *terminal, QWidget *p)
-  : QDockWidget (p)
+  : octave_dock_widget (p)
 {
   setObjectName ("TerminalDockWidget");
   setWindowIcon (QIcon(":/actions/icons/logo.png"));
@@ -39,27 +39,3 @@
   connect (this, SIGNAL (topLevelChanged(bool)), this, SLOT(top_level_changed(bool)));
 }
 
-void
-terminal_dock_widget::closeEvent (QCloseEvent *e)
-{
-  emit active_changed (false);
-  QDockWidget::closeEvent (e);
-}
-
-void
-terminal_dock_widget::handle_visibility_changed (bool visible)
-{
-  if (visible)
-    emit active_changed (true);
-}
-
-// slot for signal that is emitted when floating property changes
-void
-terminal_dock_widget::top_level_changed (bool floating)
-{
-  if(floating)
-    {
-      setWindowFlags(Qt::Window);  // make a window from the widget when floating
-      show();                      // make it visible again since setWindowFlags hides it
-    }
-}
diff -r d53fa7e43aa9 -r d9dcbf0cc8e3 libgui/src/terminal-dockwidget.h
--- a/libgui/src/terminal-dockwidget.h	Mon Feb 04 23:53:51 2013 +0000
+++ b/libgui/src/terminal-dockwidget.h	Wed Feb 06 21:45:04 2013 +0000
@@ -23,25 +23,21 @@
 #ifndef TERMINALDOCKWIDGET_H
 #define TERMINALDOCKWIDGET_H
 
-#include <QDockWidget>
 #include "QTerminal.h"
+#include "octave-dock-widget.h"
 
-class terminal_dock_widget : public QDockWidget
+class terminal_dock_widget : public octave_dock_widget
 {
   Q_OBJECT
   public:
   terminal_dock_widget (QTerminal *terminal, QWidget *parent = 0);
 
 signals:
-  void active_changed (bool active);
 
 public slots:
-  void handle_visibility_changed (bool visible);
-  /** Slot when floating property changes */
-  void top_level_changed (bool floating);
 
 protected:
-  void closeEvent (QCloseEvent *event);
+
 };
 
 
