Mercurial > hg > octave-nkf
changeset 16057:c3057d80cf91
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
author | Richard Crozier <richard.crozier@yahoo.co.uk> |
---|---|
date | Wed, 06 Feb 2013 21:45:04 +0000 |
parents | f4f0aea29b21 |
children | 444de2c0af0e |
files | libgui/src/files-dockwidget.cc libgui/src/files-dockwidget.h libgui/src/history-dockwidget.cc libgui/src/history-dockwidget.h libgui/src/m-editor/file-editor-interface.h libgui/src/m-editor/file-editor.cc libgui/src/m-editor/file-editor.h libgui/src/module.mk libgui/src/octave-dock-widget.h libgui/src/terminal-dockwidget.cc libgui/src/terminal-dockwidget.h |
diffstat | 11 files changed, 107 insertions(+), 162 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/src/files-dockwidget.cc +++ b/libgui/src/files-dockwidget.cc @@ -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 - } -}
--- a/libgui/src/files-dockwidget.h +++ b/libgui/src/files-dockwidget.h @@ -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
--- a/libgui/src/history-dockwidget.cc +++ b/libgui/src/history-dockwidget.cc @@ -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;
--- a/libgui/src/history-dockwidget.h +++ b/libgui/src/history-dockwidget.h @@ -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);
--- a/libgui/src/m-editor/file-editor-interface.h +++ b/libgui/src/m-editor/file-editor-interface.h @@ -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
--- a/libgui/src/m-editor/file-editor.cc +++ b/libgui/src/m-editor/file-editor.cc @@ -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"));
--- a/libgui/src/m-editor/file-editor.h +++ b/libgui/src/m-editor/file-editor.h @@ -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 ();
--- a/libgui/src/module.mk +++ b/libgui/src/module.mk @@ -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 \
new file mode 100644 --- /dev/null +++ b/libgui/src/octave-dock-widget.h @@ -0,0 +1,81 @@ +/* + +Copyright (C) 2012-2013 Richard Crozier + +This file is part of Octave. + +Octave 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. + +Octave 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 Octave; see the file COPYING. If not, see +<http://www.gnu.org/licenses/>. + +*/ + +#ifndef OCTAVEDOCKWIDGET_H +#define OCTAVEDOCKWIDGET_H + +#include <QDockWidget> +//#include <QMenu> +//#include <QToolBar> + +class octave_dock_widget : public QDockWidget +{ + Q_OBJECT + + public: + octave_dock_widget (QWidget *p) + : QDockWidget (p) + { + connect (this, SIGNAL (visibilityChanged (bool)), + this, SLOT (handle_visibility_changed (bool))); + + connect (this, SIGNAL (topLevelChanged(bool)), + this, SLOT(top_level_changed(bool))); + } + + virtual ~octave_dock_widget () { } + +signals: + /** Custom signal that tells if a user has clicked away + * that dock widget, i.e the active dock widget has + * changed. */ + virtual void active_changed (bool active); + +protected: + virtual void closeEvent (QCloseEvent *e) + { + emit active_changed (false); + QDockWidget::closeEvent (e); + } + +protected slots: + + /** Slot to steer changing visibility from outside. */ + virtual void handle_visibility_changed (bool visible) + { + if (visible) + emit active_changed (true); + } + + /** Slot when floating property changes */ + virtual void 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 + } + } + +}; + +#endif // OCTAVEDOCKWIDGET_H
--- a/libgui/src/terminal-dockwidget.cc +++ b/libgui/src/terminal-dockwidget.cc @@ -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 - } -}
--- a/libgui/src/terminal-dockwidget.h +++ b/libgui/src/terminal-dockwidget.h @@ -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); + };