Skip to content

Commit

Permalink
Revert "Refs #7938 added listed improvements and simple font selector"
Browse files Browse the repository at this point in the history
This reverts commit ea0ad05.
  • Loading branch information
JohnRHill committed Nov 25, 2014
1 parent ea0ad05 commit 23f84db
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 420 deletions.
155 changes: 0 additions & 155 deletions Code/Mantid/MantidPlot/src/MultiTabScriptInterpreter.cpp
Expand Up @@ -19,9 +19,6 @@
#include <QTabBar>
#include <QFileInfo>
#include <QFileDialog>
#include <QListWidget>
#include <QSpinBox>
#include <QFontDatabase>

// std
#include <stdexcept>
Expand Down Expand Up @@ -91,10 +88,6 @@ void MultiTabScriptInterpreter::newTab(int index, const QString & filename)
ScriptFileInterpreter *scriptRunner = new ScriptFileInterpreter(this,"ScriptWindow");
scriptRunner->setup(*scriptingEnv(), filename);
scriptRunner->toggleProgressReporting(m_reportProgress);
scriptRunner->toggleWhitespace(m_showWhitespace);
scriptRunner->setTabWhitespaceCount(m_tabWhitespaceCount);
scriptRunner->toggleReplaceTabs(m_replaceTabs);
scriptRunner->setFont(m_fontFamily);
connect(scriptRunner, SIGNAL(editorModificationChanged(bool)),
this, SLOT(currentEditorModified(bool)));
index = insertTab(index, scriptRunner, "");
Expand Down Expand Up @@ -270,18 +263,6 @@ void MultiTabScriptInterpreter::paste()
m_current->paste();
}

///comment method
void MultiTabScriptInterpreter::comment()
{
m_current->comment();
}

///uncomment method
void MultiTabScriptInterpreter::uncomment()
{
m_current->uncomment();
}

/**
* Execute the highlighted code from the current tab
* *@param mode :: The mode used to execute
Expand Down Expand Up @@ -409,142 +390,6 @@ void MultiTabScriptInterpreter::toggleCodeFolding(bool state)
interpreterAt(index)->toggleCodeFolding(state);
}
}
/**
* Toggle the whitespace arrow on/off
* @param state :: The state of the option
*/
void MultiTabScriptInterpreter::toggleWhitespace(bool state)
{
m_showWhitespace = state;
int index_end = count() - 1;
for( int index = index_end; index >= 0; --index )
{
interpreterAt(index)->toggleWhitespace(state);
}
}

/**
* Show configuration dialogue for tab whitespace
*/
void MultiTabScriptInterpreter::openConfigTabs()
{
// Create dialogue
QDialog configTabs(this,"Configure Tab Whitespace",false,Qt::Dialog);
QBoxLayout *layoutTabDialogue = new QBoxLayout(QBoxLayout::Direction::TopToBottom);
configTabs.setLayout(layoutTabDialogue);

// Toggle replace tab with spaces
QCheckBox *chkbxReplaceTabs = new QCheckBox("Replace tabs with spaces?");
chkbxReplaceTabs->setChecked(m_replaceTabs);
connect(chkbxReplaceTabs, SIGNAL(toggled(bool)), this, SLOT(toggleReplaceTabs(bool)));
layoutTabDialogue->addWidget(chkbxReplaceTabs);

// Count spaces per tab
QFrame *frameSpacesPerTab = new QFrame();
QBoxLayout *layoutSpacesPerTab = new QBoxLayout(QBoxLayout::Direction::LeftToRight);
frameSpacesPerTab->setLayout(layoutSpacesPerTab);
layoutTabDialogue->addWidget(frameSpacesPerTab);

QLabel *labelSpaceCount = new QLabel("Number of spaces per tab");
layoutSpacesPerTab->addWidget(labelSpaceCount);

QSpinBox *spinnerSpaceCount = new QSpinBox();
spinnerSpaceCount->setRange(0,20);
spinnerSpaceCount->setValue(m_tabWhitespaceCount);
connect (spinnerSpaceCount,SIGNAL(valueChanged(int)),this,SLOT(changeWhitespaceCount(int)));
layoutSpacesPerTab->addWidget(spinnerSpaceCount);

configTabs.exec();
}

/**
* Toggle tabs being replaced with whitespace
* @param state :: The state of the option
*/
void MultiTabScriptInterpreter::toggleReplaceTabs(bool state)
{
m_replaceTabs = state;

int index_end = count() - 1;
for( int index = index_end; index >= 0; --index )
{
interpreterAt(index)->toggleReplaceTabs(state);
}
}

/// Change number of characters used for a tab
void MultiTabScriptInterpreter::changeWhitespaceCount(int value)
{
m_tabWhitespaceCount = value;

int index_end = count() - 1;
for( int index = index_end; index >= 0; --index )
{
interpreterAt(index)->setTabWhitespaceCount(value);
}
}

/// Convert tabs in selection to spaces
void MultiTabScriptInterpreter::tabsToSpaces()
{
m_current->tabsToSpaces();
}

/// Convert spaces in selection to tabs
void MultiTabScriptInterpreter::spacesToTabs()
{
m_current->spacesToTabs();
}

/// Show select font dialog
void MultiTabScriptInterpreter::showSelectFont()
{
// Would prefer to use QFontDialog but only interested in font family

QDialog *selectFont = new QDialog(this,"Configure Tab Whitespace",false,Qt::Dialog);
QBoxLayout *layoutFontDialogue = new QBoxLayout(QBoxLayout::Direction::TopToBottom);
selectFont->setLayout(layoutFontDialogue);

// Get available fonts
QListWidget *fontList = new QListWidget();
QFontDatabase database;
fontList->addItems(database.families());
layoutFontDialogue->addWidget(fontList);

// Select saved choice. If not available, use current font
QString fontToUse = m_current->font().family(); // Not actually the font used by default by the lexer

if(database.families().contains(m_fontFamily))
fontToUse = m_fontFamily;

QListWidgetItem *item = fontList->findItems(fontToUse,Qt::MatchExactly)[0];
fontList->setItemSelected(item, true);
fontList->scrollToItem(item, QAbstractItemView::PositionAtTop);

QFrame *frameButtons = new QFrame();
QBoxLayout *layoutButtons = new QBoxLayout(QBoxLayout::Direction::LeftToRight);
frameButtons->setLayout(layoutButtons);
layoutFontDialogue->addWidget(frameButtons);

QPushButton *cancelButton = new QPushButton("Cancel");
layoutButtons->addWidget(cancelButton);
connect (cancelButton,SIGNAL(clicked()), selectFont, SLOT(reject()));

QPushButton *acceptButton = new QPushButton("Set Font");
layoutButtons->addWidget(acceptButton);
connect (acceptButton,SIGNAL(clicked()), selectFont, SLOT(accept()));

if(selectFont->exec() == QDialog::Accepted)
{
m_fontFamily = fontList->selectedItems()[0]->text();

int index_end = count() - 1;
for( int index = index_end; index >= 0; --index )
{
interpreterAt(index)->setFont(m_fontFamily);
}
}
}

//--------------------------------------------
// Private slots
Expand Down
27 changes: 1 addition & 26 deletions Code/Mantid/MantidPlot/src/MultiTabScriptInterpreter.h
Expand Up @@ -124,14 +124,7 @@ public slots:
void closeAllTabs();
/// Show the find dialog
void showFindReplaceDialog();
/// Comment a block of code
void comment();
/// Uncomment a block of code
void uncomment();
/// Convert tabs in selection to spaces
void tabsToSpaces();
/// Convert spaces in selection to tabs
void spacesToTabs();

/// undo
void undo();
/// redo
Expand Down Expand Up @@ -174,16 +167,6 @@ public slots:
void toggleProgressReporting(bool on);
/// Toggle code folding
void toggleCodeFolding(bool on);
/// Toggle the whitespace reporting arrow
void toggleWhitespace(bool state);
/// Show configuration dialogue for tab whitespace
void openConfigTabs();
/// Toggle replacing tabs with whitespace
void toggleReplaceTabs(bool state);
/// Change whitespace count
void changeWhitespaceCount(int value);
/// Show select font dialog
void showSelectFont();

private slots:
/// Close clicked tab
Expand Down Expand Up @@ -236,14 +219,6 @@ private slots:
ScriptFileInterpreter *m_current;
/// Store the current global zoom level
int m_globalZoomLevel;
// Current whitespace visibility state
bool m_showWhitespace;
// Are tabs being inserted as whitespace
bool m_replaceTabs;
// Number of spaces to use for a tab
int m_tabWhitespaceCount;
// Font to use for script window
QString m_fontFamily;
};

#endif

0 comments on commit 23f84db

Please sign in to comment.