From 248b7b323f99d2ac00d9508c9832b2c1fcd5b4fc Mon Sep 17 00:00:00 2001 From: Martyn Gigg <martyn.gigg@gmail.com> Date: Fri, 31 Jul 2015 12:17:10 +0100 Subject: [PATCH] Refactor to put members in the same order as the header. Refs #13265 --- .../Mantid/MantidPlot/src/ScriptingWindow.cpp | 136 +++++++++--------- Code/Mantid/MantidPlot/src/ScriptingWindow.h | 11 +- 2 files changed, 77 insertions(+), 70 deletions(-) diff --git a/Code/Mantid/MantidPlot/src/ScriptingWindow.cpp b/Code/Mantid/MantidPlot/src/ScriptingWindow.cpp index 8e7d4832d0a..ed9ffa0d888 100755 --- a/Code/Mantid/MantidPlot/src/ScriptingWindow.cpp +++ b/Code/Mantid/MantidPlot/src/ScriptingWindow.cpp @@ -408,6 +408,63 @@ void ScriptingWindow::acceptCloseEvent(const bool value) { m_acceptClose = value; } +//------------------------------------------- +// Protected non-slot member functions +//------------------------------------------- +/** + * Accept a custom event and in this case test if it is a ScriptingChangeEvent + * @param event :: The custom event + */ +void ScriptingWindow::customEvent(QEvent *event) { + if (!m_manager->isExecuting() && event->type() == SCRIPTING_CHANGE_EVENT) { + ScriptingChangeEvent *sce = static_cast<ScriptingChangeEvent *>(event); + setWindowTitle("MantidPlot: " + sce->scriptingEnv()->languageName() + + " Window"); + } +} + +/** + * Accept a drag enter event and selects whether to accept the action + * @param de :: The drag enter event + */ +void ScriptingWindow::dragEnterEvent(QDragEnterEvent *de) { + const QMimeData *mimeData = de->mimeData(); + if (mimeData->hasUrls()) { + if (extractPyFiles(mimeData->urls()).size() > 0) { + de->acceptProposedAction(); + } + } +} + +/** + * Accept a drag move event and selects whether to accept the action + * @param de :: The drag move event + */ +void ScriptingWindow::dragMoveEvent(QDragMoveEvent *de) { + const QMimeData *mimeData = de->mimeData(); + if (mimeData->hasUrls()) { + if (extractPyFiles(mimeData->urls()).size() > 0) { + de->accept(); + } + } +} + +/** + * Accept a drag drop event and process the data appropriately + * @param de :: The drag drop event + */ +void ScriptingWindow::dropEvent(QDropEvent *de) { + const QMimeData *mimeData = de->mimeData(); + if (mimeData->hasUrls()) { + QStringList filenames = extractPyFiles(mimeData->urls()); + de->acceptProposedAction(); + + for (int i = 0; i < filenames.size(); ++i) { + m_manager->openInNewTab(filenames[i]); + } + } +} + //------------------------------------------- // Private non-slot member functions //------------------------------------------- @@ -681,68 +738,30 @@ void ScriptingWindow::initHelpMenuActions() { } /** - * Returns the current execution mode set in the menu + * Opens a set of files in new tabs + * @param tabsToOpen A list of filenames to open in new tabs */ -Script::ExecutionMode ScriptingWindow::getExecutionMode() const { - if (m_execParallel->isChecked()) - return Script::Asynchronous; - else - return Script::Serialised; -} - -/** - * Accept a custom event and in this case test if it is a ScriptingChangeEvent - * @param event :: The custom event - */ -void ScriptingWindow::customEvent(QEvent *event) { - if (!m_manager->isExecuting() && event->type() == SCRIPTING_CHANGE_EVENT) { - ScriptingChangeEvent *sce = static_cast<ScriptingChangeEvent *>(event); - setWindowTitle("MantidPlot: " + sce->scriptingEnv()->languageName() + - " Window"); - } -} - -/** - * Accept a drag move event and selects whether to accept the action - * @param de :: The drag move event - */ -void ScriptingWindow::dragMoveEvent(QDragMoveEvent *de) { - const QMimeData *mimeData = de->mimeData(); - if (mimeData->hasUrls()) { - if (extractPyFiles(mimeData->urls()).size() > 0) { - de->accept(); +void ScriptingWindow::openPreviousTabs(const QStringList &tabsToOpen) { + const int totalFiles = tabsToOpen.size(); + if (totalFiles == 0) { + m_manager->newTab(); + } else { + for (int i = 0; i < totalFiles; i++) { + m_manager->newTab(i, tabsToOpen[i]); } } } /** - * Accept a drag enter event and selects whether to accept the action - * @param de :: The drag enter event + * Returns the current execution mode set in the menu */ -void ScriptingWindow::dragEnterEvent(QDragEnterEvent *de) { - const QMimeData *mimeData = de->mimeData(); - if (mimeData->hasUrls()) { - if (extractPyFiles(mimeData->urls()).size() > 0) { - de->acceptProposedAction(); - } - } +Script::ExecutionMode ScriptingWindow::getExecutionMode() const { + if (m_execParallel->isChecked()) + return Script::Asynchronous; + else + return Script::Serialised; } -/** - * Accept a drag drop event and process the data appropriately - * @param de :: The drag drop event - */ -void ScriptingWindow::dropEvent(QDropEvent *de) { - const QMimeData *mimeData = de->mimeData(); - if (mimeData->hasUrls()) { - QStringList filenames = extractPyFiles(mimeData->urls()); - de->acceptProposedAction(); - - for (int i = 0; i < filenames.size(); ++i) { - m_manager->openInNewTab(filenames[i]); - } - } -} QStringList ScriptingWindow::extractPyFiles(const QList<QUrl> &urlList) const { QStringList filenames; @@ -758,14 +777,3 @@ QStringList ScriptingWindow::extractPyFiles(const QList<QUrl> &urlList) const { } return filenames; } - -void ScriptingWindow::openPreviousTabs(const QStringList &tabsToOpen) { - const int totalFiles = tabsToOpen.size(); - if (totalFiles == 0) { - m_manager->newTab(); - } else { - for (int i = 0; i < totalFiles; i++) { - m_manager->newTab(i, tabsToOpen[i]); - } - } -} diff --git a/Code/Mantid/MantidPlot/src/ScriptingWindow.h b/Code/Mantid/MantidPlot/src/ScriptingWindow.h index 63ea67565bc..5a63b911e67 100755 --- a/Code/Mantid/MantidPlot/src/ScriptingWindow.h +++ b/Code/Mantid/MantidPlot/src/ScriptingWindow.h @@ -65,9 +65,11 @@ signals: void hideMe(); protected: - void dropEvent(QDropEvent *de); - void dragMoveEvent(QDragMoveEvent *de); + /// Accept a custom defined event + void customEvent(QEvent *event); void dragEnterEvent(QDragEnterEvent *de); + void dragMoveEvent(QDragMoveEvent *de); + void dropEvent(QDropEvent *de); private slots: /// Populate file menu @@ -126,15 +128,12 @@ private: void initWindowMenuActions(); /// Create the help menu actions void initHelpMenuActions(); + /// Opens tabs based on QStringList void openPreviousTabs(const QStringList &tabsToOpen); - /// Returns the current execution mode Script::ExecutionMode getExecutionMode() const; - /// Accept a custom defined event - void customEvent(QEvent *event); - /// Extract py files from urllist QStringList extractPyFiles(const QList<QUrl> &urlList) const; -- GitLab