Skip to content
Snippets Groups Projects
Commit 248b7b32 authored by Martyn Gigg's avatar Martyn Gigg
Browse files

Refactor to put members in the same order as the header.

Refs #13265
parent 94438332
No related branches found
No related tags found
No related merge requests found
...@@ -408,6 +408,63 @@ void ScriptingWindow::acceptCloseEvent(const bool value) { ...@@ -408,6 +408,63 @@ void ScriptingWindow::acceptCloseEvent(const bool value) {
m_acceptClose = 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 // Private non-slot member functions
//------------------------------------------- //-------------------------------------------
...@@ -681,68 +738,30 @@ void ScriptingWindow::initHelpMenuActions() { ...@@ -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 { void ScriptingWindow::openPreviousTabs(const QStringList &tabsToOpen) {
if (m_execParallel->isChecked()) const int totalFiles = tabsToOpen.size();
return Script::Asynchronous; if (totalFiles == 0) {
else m_manager->newTab();
return Script::Serialised; } else {
} for (int i = 0; i < totalFiles; i++) {
m_manager->newTab(i, tabsToOpen[i]);
/**
* 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();
} }
} }
} }
/** /**
* Accept a drag enter event and selects whether to accept the action * Returns the current execution mode set in the menu
* @param de :: The drag enter event
*/ */
void ScriptingWindow::dragEnterEvent(QDragEnterEvent *de) { Script::ExecutionMode ScriptingWindow::getExecutionMode() const {
const QMimeData *mimeData = de->mimeData(); if (m_execParallel->isChecked())
if (mimeData->hasUrls()) { return Script::Asynchronous;
if (extractPyFiles(mimeData->urls()).size() > 0) { else
de->acceptProposedAction(); 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 ScriptingWindow::extractPyFiles(const QList<QUrl> &urlList) const {
QStringList filenames; QStringList filenames;
...@@ -758,14 +777,3 @@ QStringList ScriptingWindow::extractPyFiles(const QList<QUrl> &urlList) const { ...@@ -758,14 +777,3 @@ QStringList ScriptingWindow::extractPyFiles(const QList<QUrl> &urlList) const {
} }
return filenames; 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]);
}
}
}
...@@ -65,9 +65,11 @@ signals: ...@@ -65,9 +65,11 @@ signals:
void hideMe(); void hideMe();
protected: protected:
void dropEvent(QDropEvent *de); /// Accept a custom defined event
void dragMoveEvent(QDragMoveEvent *de); void customEvent(QEvent *event);
void dragEnterEvent(QDragEnterEvent *de); void dragEnterEvent(QDragEnterEvent *de);
void dragMoveEvent(QDragMoveEvent *de);
void dropEvent(QDropEvent *de);
private slots: private slots:
/// Populate file menu /// Populate file menu
...@@ -126,15 +128,12 @@ private: ...@@ -126,15 +128,12 @@ private:
void initWindowMenuActions(); void initWindowMenuActions();
/// Create the help menu actions /// Create the help menu actions
void initHelpMenuActions(); void initHelpMenuActions();
/// Opens tabs based on QStringList /// Opens tabs based on QStringList
void openPreviousTabs(const QStringList &tabsToOpen); void openPreviousTabs(const QStringList &tabsToOpen);
/// Returns the current execution mode /// Returns the current execution mode
Script::ExecutionMode getExecutionMode() const; Script::ExecutionMode getExecutionMode() const;
/// Accept a custom defined event
void customEvent(QEvent *event);
/// Extract py files from urllist /// Extract py files from urllist
QStringList extractPyFiles(const QList<QUrl> &urlList) const; QStringList extractPyFiles(const QList<QUrl> &urlList) const;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment