Mercurial > octave
changeset 24713:36cd70fc2d63
style fixes for file editor
* file-editor.cc (file_editor_tab_widget::file_editor_tab_widget):
moved some setups of file_editor_tab_widget into its constructor;
(file_editor_tab_widget::tabBar) renamed into get_tab_bar and casting here;
(file_editor::construct): setup of tab widget moved into the constructor,
no more casting when getting the tab bar
* file-editor.h: renamed file_editor_tab_widget::tabBar
author | Torsten <mttl@mailbox.org> |
---|---|
date | Fri, 09 Feb 2018 19:57:39 +0100 |
parents | 95815fc93a3a |
children | d2c727a438ab |
files | libgui/src/m-editor/file-editor.cc libgui/src/m-editor/file-editor.h |
diffstat | 2 files changed, 15 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/src/m-editor/file-editor.cc Fri Feb 09 19:57:36 2018 +0100 +++ b/libgui/src/m-editor/file-editor.cc Fri Feb 09 19:57:39 2018 +0100 @@ -29,7 +29,6 @@ #include "file-editor.h" #include "resource-manager.h" #include "shortcut-manager.h" -#include "tab-bar.h" #include <QApplication> #include <QFile> @@ -55,21 +54,28 @@ file_editor_tab_widget::file_editor_tab_widget (QWidget *p) : QTabWidget (p) { - tab_bar *bar; - bar = new tab_bar (this); + tab_bar *bar = new tab_bar (this); connect (bar, SIGNAL (close_current_tab_signal (bool)), p->parent (), SLOT (request_close_file (bool))); this->setTabBar (bar); + + setTabsClosable (true); +#if defined (HAVE_QTABWIDGET_SETMOVABLE) + setMovable (true); +#endif } -QTabBar* -file_editor_tab_widget::tabBar (void) const +tab_bar * +file_editor_tab_widget::get_tab_bar (void) const { - return (QTabWidget::tabBar ()); + return qobject_cast<tab_bar *> (tabBar ()); } + +// File editor + file_editor::file_editor (QWidget *p) : file_editor_interface (p) { @@ -1626,10 +1632,6 @@ m_tool_bar->setMovable (true); m_tab_widget = new file_editor_tab_widget (editor_widget); - m_tab_widget->setTabsClosable (true); -#if defined (HAVE_QTABWIDGET_SETMOVABLE) - m_tab_widget->setMovable (true); -#endif // the mru-list and an empty array of actions QSettings *settings = resource_manager::get_settings (); @@ -1958,8 +1960,7 @@ setWidget (editor_widget); // create the context menu of the tab bar - tab_bar *bar - = static_cast<tab_bar *>(m_tab_widget->tabBar ()); + tab_bar *bar = m_tab_widget->get_tab_bar (); QMenu *ctx_men = bar->get_context_menu (); ctx_men->addAction (m_close_action); ctx_men->addAction (m_close_all_action);
--- a/libgui/src/m-editor/file-editor.h Fri Feb 09 19:57:36 2018 +0100 +++ b/libgui/src/m-editor/file-editor.h Fri Feb 09 19:57:39 2018 +0100 @@ -38,6 +38,7 @@ #include "file-editor-interface.h" #include "file-editor-tab.h" +#include "tab-bar.h" // subclassed QTabWidget for using custom tabbar @@ -52,7 +53,7 @@ ~file_editor_tab_widget (void) = default; - QTabBar * tabBar (void) const; + tab_bar * get_tab_bar (void) const; }; // the class for the file editor