added jump to block feature.
This commit is contained in:
@ -125,6 +125,7 @@ PTextEdit::PTextEdit( QWidget *parent )
|
||||
setupEditActions();
|
||||
setupTextActions();
|
||||
setupMusrActions();
|
||||
setupJumpToBlock();
|
||||
setupHelpActions();
|
||||
|
||||
fTabWidget = std::make_unique<QTabWidget>( this );
|
||||
@ -958,6 +959,31 @@ void PTextEdit::setupHelpActions()
|
||||
menu->addAction(a);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* <p>Setup the JumpToBlock actions.
|
||||
*/
|
||||
void PTextEdit::setupJumpToBlock()
|
||||
{
|
||||
QToolBar *tb = new QToolBar( this );
|
||||
tb->setWindowTitle( "JumpToBlock Actions" );
|
||||
addToolBar( tb );
|
||||
|
||||
QStringList jumpToBlockStr = {"FITPARAMETER", "THEORY", "FUNCTIONS", "GLOBAL", "RUN", "COMMANDS", "PLOT", "FOURIER", "STATISTIC"};
|
||||
fJumpToBlock = std::make_unique<QComboBox>();
|
||||
if (fJumpToBlock == nullptr)
|
||||
return;
|
||||
fJumpToBlock->addItems(jumpToBlockStr);
|
||||
fJumpToBlock->setEditable(false);
|
||||
|
||||
connect( fJumpToBlock.get(), SIGNAL( activated(int) ), this, SLOT( jumpToBlock(int) ));
|
||||
|
||||
QLabel *jstr = new QLabel(" Jump to block: ");
|
||||
|
||||
tb->addWidget(jstr);
|
||||
tb->addWidget(fJumpToBlock.get());
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* <p>load a msr-file.
|
||||
@ -3306,6 +3332,26 @@ void PTextEdit::setFileSystemWatcherActive()
|
||||
fFileSystemWatcherActive = true;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* <p>slot called when jumpToBlock combobox is selected
|
||||
* @param idx
|
||||
*/
|
||||
void PTextEdit::jumpToBlock(int idx)
|
||||
{
|
||||
QString str = fJumpToBlock->itemText(idx);
|
||||
|
||||
QTextDocument::FindFlags flags= QTextDocument::FindCaseSensitively | QTextDocument::FindWholeWords;
|
||||
|
||||
bool found = currentEditor()->find(str, flags);
|
||||
if (found)
|
||||
return;
|
||||
|
||||
// set cursor to start
|
||||
currentEditor()->moveCursor(QTextCursor::Start);
|
||||
currentEditor()->find(str, flags);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief PTextEdit::getTheme
|
||||
|
Reference in New Issue
Block a user