@ -58,7 +58,7 @@
///-- #include <tqmessagebox.h>
///-- #include <tqmessagebox.h>
///-- #include <tqtdebug.h>
///-- #include <tqtdebug.h>
///--
///--
///-- #include <Qsci/qsciscintilla.h>
# include <tqextscintilla.h>
///-- #include <Qsci/qsciprinter.h>
///-- #include <Qsci/qsciprinter.h>
///--
///--
///-- using namespace tschweitzer;
///-- using namespace tschweitzer;
@ -79,16 +79,15 @@
\ brief Constructs the main window .
\ brief Constructs the main window .
*/
*/
MainWindow : : MainWindow ( TQString file2OpenOnStart , TQWidget * parent ) :
MainWindow : : MainWindow ( TQString file2OpenOnStart , TQWidget * parent ) :
MainWindowBase ( parent ) , m_aboutDialog ( NULL )
MainWindowBase ( parent ) , m_aboutDialog ( NULL ) , m_qSciSourceCodeEditor ( NULL )
///- _mainWindowForm(NULL), _ qSciSourceCodeEditor(NULL), _ settings(NULL),
///- _mainWindowForm(NULL), _ settings(NULL),
///- _highlighter(NULL), _textEditVScrollBar(NULL), _aboutDialogGraphicsView(
///- _highlighter(NULL), _textEditVScrollBar(NULL), _aboutDialogGraphicsView(
///- NULL), _settingsDialog(NULL), _encodingActionGroup(NULL), _saveEncodedActionGroup(NULL),
///- NULL), _settingsDialog(NULL), _encodingActionGroup(NULL), _saveEncodedActionGroup(NULL),
///- _highlighterActionGroup(NULL), _uiGuiTranslator(NULL), _qTTranslator(NULL), _toolBarWidget(
///- _highlighterActionGroup(NULL), _uiGuiTranslator(NULL), _qTTranslator(NULL), _toolBarWidget(
///- NULL), _indentHandler(NULL), _textEditLineColumnInfoLabel(NULL)
///- NULL), _indentHandler(NULL), _textEditLineColumnInfoLabel(NULL)
{
{
///-- // Init of some variables.
// Init of some variables.
///-- _sourceCodeChanged = false;
m_sourceCodeChanged = false ;
///-- _scrollPositionChanged = false;
// Create the _settings object, which loads all UiGui settings from a file.
// Create the _settings object, which loads all UiGui settings from a file.
m_settings = UiGuiSettings : : getInstance ( ) ;
m_settings = UiGuiSettings : : getInstance ( ) ;
@ -197,22 +196,39 @@ void MainWindow::initMainWindow()
showMaximized ( ) ;
showMaximized ( ) ;
}
}
///-- // Get last selected file encoding
// Get last selected file encoding
///-- // -------------------------------
// -------------------------------
///-- _currentEncoding = _settings->getValueByName("encoding").toString();
m_currentEncoding = m_settings - > getValueByName ( " FileEncoding " ) . toString ( ) ;
///--
///-- // Register the load last file setting in the menu to the _settings object.
// Register the syntax highlighting setting in the menu to the settings object.
///-- _settings->registerObjectProperty(actionLoadLastOpenedFileOnStartup, "checked",
connect ( actionEnableSyntaxHighlighting , SIGNAL ( toggled ( bool ) ) ,
///-- "loadLastSourceCodeFileOnStartup");
m_settings , SLOT ( handleValueChangeFromExtern ( bool ) ) ) ;
///--
connect ( m_settings , SIGNAL ( syntaxHighlightingEnabled ( bool ) ) ,
///-- // Tell the TQScintilla editor if it has to show white space.
actionEnableSyntaxHighlighting , SLOT ( setOn ( bool ) ) ) ;
///-- connect(_mainWindowForm->actionWhiteSpaceIsVisible, SIGNAL(acivated(bool)), this,
actionEnableSyntaxHighlighting - > setOn (
///-- SLOT(setWhiteSpaceVisibility(bool)));
m_settings - > getValueByName ( " SyntaxHighlightingEnabled " ) . toBool ( ) ) ;
///-- // Register the white space setting in the menu to the _settings object.
// Tell the highlighter if it has to be enabled or disabled.
///-- _settings->registerObjectProperty(actionWhiteSpaceIsVisible, "checked",
connect ( m_settings , SIGNAL ( syntaxHighlightingEnabled ( bool ) ) , this , SLOT ( turnHighlightOnOff ( bool ) ) ) ;
///-- "whiteSpaceIsVisible");
///--
// Register the load last file setting in the menu to the settings object
///-- // Connect the remaining menu items.
connect ( actionLoadLastOpenedFileOnStartup , SIGNAL ( toggled ( bool ) ) ,
m_settings , SLOT ( handleValueChangeFromExtern ( bool ) ) ) ;
connect ( m_settings , SIGNAL ( loadLastOpenedFileOnStartup ( bool ) ) ,
actionLoadLastOpenedFileOnStartup , SLOT ( setOn ( bool ) ) ) ;
actionLoadLastOpenedFileOnStartup - > setOn (
m_settings - > getValueByName ( " LoadLastOpenedFileOnStartup " ) . toBool ( ) ) ;
// Register the white space setting in the menu to the settings object.
connect ( actionWhiteSpaceIsVisible , SIGNAL ( toggled ( bool ) ) ,
m_settings , SLOT ( handleValueChangeFromExtern ( bool ) ) ) ;
connect ( m_settings , SIGNAL ( whiteSpaceIsVisible ( bool ) ) ,
actionWhiteSpaceIsVisible , SLOT ( setOn ( bool ) ) ) ;
actionWhiteSpaceIsVisible - > setOn ( m_settings - > getValueByName ( " WhiteSpaceIsVisible " ) . toBool ( ) ) ;
// Tell the TQScintilla editor if it has to show white space.
connect ( m_settings , SIGNAL ( whiteSpaceIsVisible ( bool ) ) , this , SLOT ( setWhiteSpaceVisibility ( bool ) ) ) ;
// Connect the remaining menu items.
connect ( actionOpenSourceFile , SIGNAL ( activated ( ) ) , this , SLOT ( openSourceFileDialog ( ) ) ) ;
connect ( actionOpenSourceFile , SIGNAL ( activated ( ) ) , this , SLOT ( openSourceFileDialog ( ) ) ) ;
connect ( actionSaveSourceFile , SIGNAL ( activated ( ) ) , this , SLOT ( saveSourceFile ( ) ) ) ;
connect ( actionSaveSourceFile , SIGNAL ( activated ( ) ) , this , SLOT ( saveSourceFile ( ) ) ) ;
connect ( actionSaveSourceFileAs , SIGNAL ( activated ( ) ) , this , SLOT ( saveasSourceFileDialog ( ) ) ) ;
connect ( actionSaveSourceFileAs , SIGNAL ( activated ( ) ) , this , SLOT ( saveasSourceFileDialog ( ) ) ) ;
@ -278,7 +294,7 @@ void MainWindow::initToolBar()
///-- // TQScintilla debug lib and the other way around.
///-- // TQScintilla debug lib and the other way around.
///-- try
///-- try
///-- {
///-- {
///-- _qSciSourceCodeEditor = new QsciScintilla(this);
///-- m _qSciSourceCodeEditor = new QsciScintilla(this);
///-- }
///-- }
///-- catch (...)
///-- catch (...)
///-- {
///-- {
@ -286,17 +302,17 @@ void MainWindow::initToolBar()
///-- "During trying to create the text editor component, that is based on TQScintilla, an error occurred. Please make sure that you have installed TQScintilla and not mixed release and debug versions.");
///-- "During trying to create the text editor component, that is based on TQScintilla, an error occurred. Please make sure that you have installed TQScintilla and not mixed release and debug versions.");
///-- exit(1);
///-- exit(1);
///-- }
///-- }
///-- _mainWindowForm->hboxLayout1->addWidget( _qSciSourceCodeEditor);
///-- _mainWindowForm->hboxLayout1->addWidget( m _qSciSourceCodeEditor);
///--
///--
///-- // Make some _settings for the TQScintilla widget.
///-- // Make some _settings for the TQScintilla widget.
///-- _qSciSourceCodeEditor->setUtf8(true);
///-- m _qSciSourceCodeEditor->setUtf8(true);
///-- _qSciSourceCodeEditor->setMarginLineNumbers(1, true);
///-- m _qSciSourceCodeEditor->setMarginLineNumbers(1, true);
///-- _qSciSourceCodeEditor->setMarginWidth(1, TQString("10000"));
///-- m _qSciSourceCodeEditor->setMarginWidth(1, TQString("10000"));
///-- _qSciSourceCodeEditor->setBraceMatching(_qSciSourceCodeEditor->SloppyBraceMatch);
///-- m _qSciSourceCodeEditor->setBraceMatching(m _qSciSourceCodeEditor->SloppyBraceMatch);
///-- _qSciSourceCodeEditor->setMatchedBraceForegroundColor(TQColor("red"));
///-- m _qSciSourceCodeEditor->setMatchedBraceForegroundColor(TQColor("red"));
///-- _qSciSourceCodeEditor->setFolding(QsciScintilla::BoxedTreeFoldStyle);
///-- m _qSciSourceCodeEditor->setFolding(QsciScintilla::BoxedTreeFoldStyle);
///-- _qSciSourceCodeEditor->setAutoCompletionSource(QsciScintilla::AcsAll);
///-- m _qSciSourceCodeEditor->setAutoCompletionSource(QsciScintilla::AcsAll);
///-- _qSciSourceCodeEditor->setAutoCompletionThreshold(3);
///-- m _qSciSourceCodeEditor->setAutoCompletionThreshold(3);
///--
///--
///-- // Handle if white space is set to be visible
///-- // Handle if white space is set to be visible
///-- bool whiteSpaceIsVisible = _settings->getValueByName("whiteSpaceIsVisible").toBool();
///-- bool whiteSpaceIsVisible = _settings->getValueByName("whiteSpaceIsVisible").toBool();
@ -304,24 +320,24 @@ void MainWindow::initToolBar()
///--
///--
///-- // Handle the width of tabs in spaces
///-- // Handle the width of tabs in spaces
///-- int tabWidth = _settings->getValueByName("tabWidth").toInt();
///-- int tabWidth = _settings->getValueByName("tabWidth").toInt();
///-- _qSciSourceCodeEditor->setTabWidth(tabWidth);
///-- m _qSciSourceCodeEditor->setTabWidth(tabWidth);
///--
///--
///-- // Remember a pointer to the scrollbar of the TQScintilla widget used to keep
///-- // Remember a pointer to the scrollbar of the TQScintilla widget used to keep
///-- // on the same line as before when turning preview on/off.
///-- // on the same line as before when turning preview on/off.
///-- _textEditVScrollBar = _qSciSourceCodeEditor->verticalScrollBar();
///-- _textEditVScrollBar = m _qSciSourceCodeEditor->verticalScrollBar();
///--
///--
///-- // Add a column row indicator to the status bar.
///-- // Add a column row indicator to the status bar.
///-- _textEditLineColumnInfoLabel = new TQLabel(tr("Line %1, Column %2").arg(1).arg(1));
///-- _textEditLineColumnInfoLabel = new TQLabel(tr("Line %1, Column %2").arg(1).arg(1));
///-- _mainWindowForm->statusbar->addPermanentWidget(_textEditLineColumnInfoLabel);
///-- _mainWindowForm->statusbar->addPermanentWidget(_textEditLineColumnInfoLabel);
///-- connect( _qSciSourceCodeEditor, SIGNAL(cursorPositionChanged(int,int)), this,
///-- connect( m _qSciSourceCodeEditor, SIGNAL(cursorPositionChanged(int,int)), this,
///-- SLOT(setStatusBarCursorPosInfo(int, int)));
///-- SLOT(setStatusBarCursorPosInfo(int, int)));
///--
///--
///-- // Connect the text editor to dependent functions.
///-- // Connect the text editor to dependent functions.
///-- connect( _qSciSourceCodeEditor, SIGNAL(textChanged()), this, SLOT(sourceCodeChangedHelperSlot()));
///-- connect( m _qSciSourceCodeEditor, SIGNAL(textChanged()), this, SLOT(sourceCodeChangedHelperSlot()));
///-- connect( _qSciSourceCodeEditor, SIGNAL(linesChanged()), this, SLOT(numberOfLinesChanged()));
///-- connect( m _qSciSourceCodeEditor, SIGNAL(linesChanged()), this, SLOT(numberOfLinesChanged()));
///-- //connect( _settings, SIGNAL(tabWidth(int)), _qSciSourceCodeEditor, SLOT(setTabWidth(int)) );
///-- //connect( _settings, SIGNAL(tabWidth(int)), m _qSciSourceCodeEditor, SLOT(setTabWidth(int)) );
///-- _settings->registerObjectSlot( _qSciSourceCodeEditor, "setTabWidth(int)", "tabWidth");
///-- _settings->registerObjectSlot( m _qSciSourceCodeEditor, "setTabWidth(int)", "tabWidth");
///-- _qSciSourceCodeEditor->setTabWidth(_settings->getValueByName("tabWidth").toInt());
///-- m _qSciSourceCodeEditor->setTabWidth(_settings->getValueByName("tabWidth").toInt());
///-- }
///-- }
///--
///--
///-- /*
///-- /*
@ -330,7 +346,7 @@ void MainWindow::initToolBar()
///-- void MainWindow::initSyntaxHighlighter()
///-- void MainWindow::initSyntaxHighlighter()
///-- {
///-- {
///-- // Create the _highlighter.
///-- // Create the _highlighter.
///-- _highlighter = new UiGuiHighlighter( _qSciSourceCodeEditor);
///-- _highlighter = new UiGuiHighlighter( m _qSciSourceCodeEditor);
///--
///--
///-- // Connect the syntax highlighting setting in the menu to the turnHighlightOnOff function.
///-- // Connect the syntax highlighting setting in the menu to the turnHighlightOnOff function.
///-- connect(actionEnableSyntaxHighlighting, SIGNAL(activated(bool)), this,
///-- connect(actionEnableSyntaxHighlighting, SIGNAL(activated(bool)), this,
@ -457,7 +473,7 @@ void MainWindow::initToolBar()
///-- {
///-- {
///-- TQTextStream inSrcStrm(&inSrcFile);
///-- TQTextStream inSrcStrm(&inSrcFile);
///-- TQApplication::setOverrideCursor(TQt::WaitCursor);
///-- TQApplication::setOverrideCursor(TQt::WaitCursor);
///-- inSrcStrm.setCodec(TQTextCodec::codecForName( _currentEncoding.toAscii()));
///-- inSrcStrm.setCodec(TQTextCodec::codecForName( m _currentEncoding.toAscii()));
///-- fileContent = inSrcStrm.readAll();
///-- fileContent = inSrcStrm.readAll();
///-- TQApplication::restoreOverrideCursor();
///-- TQApplication::restoreOverrideCursor();
///-- inSrcFile.close();
///-- inSrcFile.close();
@ -506,7 +522,7 @@ void MainWindow::openSourceFileDialog(TQString fileName)
///-- {
///-- {
///-- callIndenter();
///-- callIndenter();
///-- }
///-- }
///-- _sourceCodeChanged = true;
///-- m _sourceCodeChanged = true;
///-- _previewToggled = true;
///-- _previewToggled = true;
///-- updateSourceView();
///-- updateSourceView();
///-- updateWindowTitle();
///-- updateWindowTitle();
@ -515,7 +531,7 @@ void MainWindow::openSourceFileDialog(TQString fileName)
///-- _textEditVScrollBar->setValue(_textEditLastScrollPos);
///-- _textEditVScrollBar->setValue(_textEditLastScrollPos);
///--
///--
///-- _savedSourceContent = openedSourceFileContent;
///-- _savedSourceContent = openedSourceFileContent;
///-- _qSciSourceCodeEditor->setModified(false);
///-- m _qSciSourceCodeEditor->setModified(false);
///-- setWindowModified(false);
///-- setWindowModified(false);
///-- }
///-- }
}
}
@ -541,7 +557,7 @@ bool MainWindow::saveasSourceFileDialog(TQAction *chosenEncodingAction)
///-- return false;
///-- return false;
///-- }
///-- }
///--
///--
///-- _savedSourceContent = _qSciSourceCodeEditor->text();
///-- _savedSourceContent = m _qSciSourceCodeEditor->text();
///--
///--
///-- _currentSourceFile = fileName;
///-- _currentSourceFile = fileName;
///-- TQFile::remove(fileName);
///-- TQFile::remove(fileName);
@ -565,7 +581,7 @@ bool MainWindow::saveasSourceFileDialog(TQAction *chosenEncodingAction)
///-- TQFileInfo fileInfo(fileName);
///-- TQFileInfo fileInfo(fileName);
///-- _currentSourceFileExtension = fileInfo.suffix();
///-- _currentSourceFileExtension = fileInfo.suffix();
///--
///--
///-- _qSciSourceCodeEditor->setModified(false);
///-- m _qSciSourceCodeEditor->setModified(false);
///-- setWindowModified(false);
///-- setWindowModified(false);
///--
///--
///-- updateWindowTitle();
///-- updateWindowTitle();
@ -587,17 +603,17 @@ bool MainWindow::saveSourceFile()
///-- {
///-- {
///-- TQFile::remove(_currentSourceFile);
///-- TQFile::remove(_currentSourceFile);
///-- TQFile outSrcFile(_currentSourceFile);
///-- TQFile outSrcFile(_currentSourceFile);
///-- _savedSourceContent = _qSciSourceCodeEditor->text();
///-- _savedSourceContent = m _qSciSourceCodeEditor->text();
///-- outSrcFile.open(TQFile::ReadWrite | TQFile::Text);
///-- outSrcFile.open(TQFile::ReadWrite | TQFile::Text);
///--
///--
///-- // Get current encoding.
///-- // Get current encoding.
///-- TQString _currentEncoding = _encodingActionGroup->checkedAction()->text();
///-- TQString m _currentEncoding = _encodingActionGroup->checkedAction()->text();
///-- TQTextStream outSrcStrm(&outSrcFile);
///-- TQTextStream outSrcStrm(&outSrcFile);
///-- outSrcStrm.setCodec(TQTextCodec::codecForName( _currentEncoding.toAscii()));
///-- outSrcStrm.setCodec(TQTextCodec::codecForName( m _currentEncoding.toAscii()));
///-- outSrcStrm << _savedSourceContent;
///-- outSrcStrm << _savedSourceContent;
///-- outSrcFile.close();
///-- outSrcFile.close();
///--
///--
///-- _qSciSourceCodeEditor->setModified(false);
///-- m _qSciSourceCodeEditor->setModified(false);
///-- setWindowModified(false);
///-- setWindowModified(false);
///-- }
///-- }
return true ;
return true ;
@ -646,13 +662,13 @@ bool MainWindow::saveSourceFile()
///--
///--
///-- if (_previewToggled)
///-- if (_previewToggled)
///-- {
///-- {
///-- disconnect( _qSciSourceCodeEditor, SIGNAL(textChanged()), this,
///-- disconnect( m _qSciSourceCodeEditor, SIGNAL(textChanged()), this,
///-- SLOT(sourceCodeChangedHelperSlot()));
///-- SLOT(sourceCodeChangedHelperSlot()));
///-- bool textIsModified = isWindowModified();
///-- bool textIsModified = isWindowModified();
///-- _qSciSourceCodeEditor->setText(_sourceViewContent);
///-- m _qSciSourceCodeEditor->setText(_sourceViewContent);
///-- setWindowModified(textIsModified);
///-- setWindowModified(textIsModified);
///-- _previewToggled = false;
///-- _previewToggled = false;
///-- connect( _qSciSourceCodeEditor, SIGNAL(textChanged()), this,
///-- connect( m _qSciSourceCodeEditor, SIGNAL(textChanged()), this,
///-- SLOT(sourceCodeChangedHelperSlot()));
///-- SLOT(sourceCodeChangedHelperSlot()));
///-- }
///-- }
///--
///--
@ -672,12 +688,12 @@ bool MainWindow::saveSourceFile()
///-- //updateSourceView();
///-- //updateSourceView();
///-- TQApplication::restoreOverrideCursor();
///-- TQApplication::restoreOverrideCursor();
///-- }
///-- }
///--
///-- /*
/*
///-- \brief Switches the syntax highlighting corresponding to the value \a turnOn either on or off.
\ brief Switches the syntax highlighting corresponding to the value \ a turnOn either on or off .
///-- */
*/
///-- void MainWindow::turnHighlightOnOff(bool turnOn)
void MainWindow : : turnHighlightOnOff ( bool turnOn )
///-- {
{
///-- if (turnOn)
///-- if (turnOn)
///-- {
///-- {
///-- _highlighter->turnHighlightOn();
///-- _highlighter->turnHighlightOn();
@ -688,8 +704,8 @@ bool MainWindow::saveSourceFile()
///-- }
///-- }
///-- _previewToggled = true;
///-- _previewToggled = true;
///-- updateSourceView();
///-- updateSourceView();
///-- }
}
///--
///-- /*
///-- /*
///-- \brief Added this slot to avoid multiple calls because of changed text.
///-- \brief Added this slot to avoid multiple calls because of changed text.
///-- */
///-- */
@ -708,14 +724,10 @@ bool MainWindow::saveSourceFile()
///-- int cursorPos, cursorPosAbsolut, cursorLine;
///-- int cursorPos, cursorPosAbsolut, cursorLine;
///-- TQString text;
///-- TQString text;
///--
///--
///-- _sourceCodeChanged = true;
///-- m_sourceCodeChanged = true;
///-- if (_scrollPositionChanged)
///-- {
///-- _scrollPositionChanged = false;
///-- }
///--
///--
///-- // Get the content text of the text editor.
///-- // Get the content text of the text editor.
///-- _sourceFileContent = _qSciSourceCodeEditor->text();
///-- _sourceFileContent = m_qSciSourceCodeEditor->text();
///--
///--
///-- // Get the position of the cursor in the unindented text.
///-- // Get the position of the cursor in the unindented text.
///-- if (_sourceFileContent.isEmpty())
///-- if (_sourceFileContent.isEmpty())
@ -729,9 +741,9 @@ bool MainWindow::saveSourceFile()
///-- }
///-- }
///-- else
///-- else
///-- {
///-- {
///-- _qSciSourceCodeEditor->getCursorPosition(&cursorLine, &cursorPos);
///-- m _qSciSourceCodeEditor->getCursorPosition(&cursorLine, &cursorPos);
///-- cursorPosAbsolut = _qSciSourceCodeEditor->SendScintilla(QsciScintillaBase::SCI_GETCURRENTPOS);
///-- cursorPosAbsolut = m _qSciSourceCodeEditor->SendScintilla(QsciScintillaBase::SCI_GETCURRENTPOS);
///-- text = _qSciSourceCodeEditor->text(cursorLine);
///-- text = m _qSciSourceCodeEditor->text(cursorLine);
///-- if (cursorPosAbsolut > 0)
///-- if (cursorPosAbsolut > 0)
///-- {
///-- {
///-- cursorPosAbsolut--;
///-- cursorPosAbsolut--;
@ -765,10 +777,10 @@ bool MainWindow::saveSourceFile()
///--
///--
///-- // Search forward
///-- // Search forward
///-- for (cursorLine = saveCursorLine;
///-- for (cursorLine = saveCursorLine;
///-- cursorLine - saveCursorLine < 6 && cursorLine < _qSciSourceCodeEditor->lines();
///-- cursorLine - saveCursorLine < 6 && cursorLine < m _qSciSourceCodeEditor->lines();
///-- cursorLine++)
///-- cursorLine++)
///-- {
///-- {
///-- text = _qSciSourceCodeEditor->text(cursorLine);
///-- text = m _qSciSourceCodeEditor->text(cursorLine);
///-- while (cursorPos < text.count() && enteredCharacter != text.at(cursorPos))
///-- while (cursorPos < text.count() && enteredCharacter != text.at(cursorPos))
///-- {
///-- {
///-- cursorPos++;
///-- cursorPos++;
@ -787,7 +799,7 @@ bool MainWindow::saveSourceFile()
///-- // If foward search did not find the character, search backward
///-- // If foward search did not find the character, search backward
///-- if (!charFound)
///-- if (!charFound)
///-- {
///-- {
///-- text = _qSciSourceCodeEditor->text(saveCursorLine);
///-- text = m _qSciSourceCodeEditor->text(saveCursorLine);
///-- cursorPos = saveCursorPos;
///-- cursorPos = saveCursorPos;
///-- if (cursorPos >= text.count())
///-- if (cursorPos >= text.count())
///-- {
///-- {
@ -797,14 +809,14 @@ bool MainWindow::saveSourceFile()
///-- for (cursorLine = saveCursorLine; saveCursorLine - cursorLine < 6 && cursorLine >= 0;
///-- for (cursorLine = saveCursorLine; saveCursorLine - cursorLine < 6 && cursorLine >= 0;
///-- cursorLine--)
///-- cursorLine--)
///-- {
///-- {
///-- text = _qSciSourceCodeEditor->text(cursorLine);
///-- text = m _qSciSourceCodeEditor->text(cursorLine);
///-- while (cursorPos >= 0 && enteredCharacter != text.at(cursorPos))
///-- while (cursorPos >= 0 && enteredCharacter != text.at(cursorPos))
///-- {
///-- {
///-- cursorPos--;
///-- cursorPos--;
///-- }
///-- }
///-- if (cursorPos < 0)
///-- if (cursorPos < 0)
///-- {
///-- {
///-- cursorPos = _qSciSourceCodeEditor->lineLength(cursorLine - 1) - 1;
///-- cursorPos = m _qSciSourceCodeEditor->lineLength(cursorLine - 1) - 1;
///-- }
///-- }
///-- else
///-- else
///-- {
///-- {
@ -817,39 +829,39 @@ bool MainWindow::saveSourceFile()
///-- // If the character was found set its new cursor position...
///-- // If the character was found set its new cursor position...
///-- if (charFound)
///-- if (charFound)
///-- {
///-- {
///-- _qSciSourceCodeEditor->setCursorPosition(cursorLine, cursorPos + 1);
///-- m _qSciSourceCodeEditor->setCursorPosition(cursorLine, cursorPos + 1);
///-- }
///-- }
///-- // ...if it was not found, set the previous cursor position.
///-- // ...if it was not found, set the previous cursor position.
///-- else
///-- else
///-- {
///-- {
///-- _qSciSourceCodeEditor->setCursorPosition(saveCursorLine, saveCursorPos + 1);
///-- m _qSciSourceCodeEditor->setCursorPosition(saveCursorLine, saveCursorPos + 1);
///-- }
///-- }
///-- }
///-- }
///-- // set the previous cursor position.
///-- // set the previous cursor position.
///-- else if (enteredCharacter == 10)
///-- else if (enteredCharacter == 10)
///-- {
///-- {
///-- _qSciSourceCodeEditor->setCursorPosition(cursorLine, cursorPos);
///-- m _qSciSourceCodeEditor->setCursorPosition(cursorLine, cursorPos);
///-- }
///-- }
///--
///--
///-- if (m_toolBarWidget->cbLivePreview->isChecked())
///-- if (m_toolBarWidget->cbLivePreview->isChecked())
///-- {
///-- {
///-- _sourceCodeChanged = false;
///-- m _sourceCodeChanged = false;
///-- }
///-- }
///--
///--
///-- if (_savedSourceContent == _qSciSourceCodeEditor->text())
///-- if (_savedSourceContent == m _qSciSourceCodeEditor->text())
///-- {
///-- {
///-- _qSciSourceCodeEditor->setModified(false);
///-- m _qSciSourceCodeEditor->setModified(false);
///-- setWindowModified(false);
///-- setWindowModified(false);
///-- }
///-- }
///-- else
///-- else
///-- {
///-- {
///-- _qSciSourceCodeEditor->setModified(true); // Has no effect according to TQScintilla docs.
///-- m _qSciSourceCodeEditor->setModified(true); // Has no effect according to TQScintilla docs.
///-- setWindowModified(true);
///-- setWindowModified(true);
///-- }
///-- }
///--
///--
///-- // Could set cursor this way and use normal linear search in text instead of columns and rows.
///-- // Could set cursor this way and use normal linear search in text instead of columns and rows.
///-- // _qSciSourceCodeEditor->SendScintilla(QsciScintillaBase::SCI_SETCURRENTPOS, 50);
///-- // m _qSciSourceCodeEditor->SendScintilla(QsciScintillaBase::SCI_SETCURRENTPOS, 50);
///-- // _qSciSourceCodeEditor->SendScintilla(QsciScintillaBase::SCI_SETANCHOR, 50);
///-- // m _qSciSourceCodeEditor->SendScintilla(QsciScintillaBase::SCI_SETANCHOR, 50);
///-- }
///-- }
///--
///--
///-- /*
///-- /*
@ -863,7 +875,7 @@ bool MainWindow::saveSourceFile()
///-- _indentSettingsChanged = true;
///-- _indentSettingsChanged = true;
///--
///--
///-- int cursorLine, cursorPos;
///-- int cursorLine, cursorPos;
///-- _qSciSourceCodeEditor->getCursorPosition(&cursorLine, &cursorPos);
///-- m _qSciSourceCodeEditor->getCursorPosition(&cursorLine, &cursorPos);
///--
///--
///-- if (m_toolBarWidget->cbLivePreview->isChecked())
///-- if (m_toolBarWidget->cbLivePreview->isChecked())
///-- {
///-- {
@ -871,16 +883,16 @@ bool MainWindow::saveSourceFile()
///-- _previewToggled = true;
///-- _previewToggled = true;
///--
///--
///-- updateSourceView();
///-- updateSourceView();
///-- if ( _sourceCodeChanged)
///-- if ( m _sourceCodeChanged)
///-- {
///-- {
///-- /* savedCursor = _qSciSourceCodeEditor->textCursor();
///-- /* savedCursor = m _qSciSourceCodeEditor->textCursor();
///-- if ( cursorPos >= _qSciSourceCodeEditor->text().count() ) {
///-- if ( cursorPos >= m _qSciSourceCodeEditor->text().count() ) {
///-- cursorPos = _qSciSourceCodeEditor->text().count() - 1;
///-- cursorPos = m _qSciSourceCodeEditor->text().count() - 1;
///-- }
///-- }
///-- savedCursor.setPosition( cursorPos );
///-- savedCursor.setPosition( cursorPos );
///-- _qSciSourceCodeEditor->setTextCursor( savedCursor );
///-- m _qSciSourceCodeEditor->setTextCursor( savedCursor );
///-- */
///-- */
///-- _sourceCodeChanged = false;
///-- m _sourceCodeChanged = false;
///-- }
///-- }
///-- _indentSettingsChanged = false;
///-- _indentSettingsChanged = false;
///-- }
///-- }
@ -889,14 +901,14 @@ bool MainWindow::saveSourceFile()
///-- updateSourceView();
///-- updateSourceView();
///-- }
///-- }
///--
///--
///-- if (_savedSourceContent == _qSciSourceCodeEditor->text())
///-- if (_savedSourceContent == m _qSciSourceCodeEditor->text())
///-- {
///-- {
///-- _qSciSourceCodeEditor->setModified(false);
///-- m _qSciSourceCodeEditor->setModified(false);
///-- setWindowModified(false);
///-- setWindowModified(false);
///-- }
///-- }
///-- else
///-- else
///-- {
///-- {
///-- _qSciSourceCodeEditor->setModified(true); // Has no effect according to TQScintilla docs.
///-- m _qSciSourceCodeEditor->setModified(true); // Has no effect according to TQScintilla docs.
///-- setWindowModified(true);
///-- setWindowModified(true);
///-- }
///-- }
///-- }
///-- }
@ -912,34 +924,34 @@ void MainWindow::previewTurnedOnOff(bool turnOn)
///-- _previewToggled = true;
///-- _previewToggled = true;
///--
///--
///-- int cursorLine, cursorPos;
///-- int cursorLine, cursorPos;
///-- _qSciSourceCodeEditor->getCursorPosition(&cursorLine, &cursorPos);
///-- m _qSciSourceCodeEditor->getCursorPosition(&cursorLine, &cursorPos);
///--
///--
///-- if (turnOn && (_indentSettingsChanged || _sourceCodeChanged))
///-- if (turnOn && (_indentSettingsChanged || m _sourceCodeChanged))
///-- {
///-- {
///-- callIndenter();
///-- callIndenter();
///-- }
///-- }
///-- updateSourceView();
///-- updateSourceView();
///-- if ( _sourceCodeChanged)
///-- if ( m _sourceCodeChanged)
///-- {
///-- {
///-- /* savedCursor = _qSciSourceCodeEditor->textCursor();
///-- /* savedCursor = m _qSciSourceCodeEditor->textCursor();
///-- if ( cursorPos >= _qSciSourceCodeEditor->text().count() ) {
///-- if ( cursorPos >= m _qSciSourceCodeEditor->text().count() ) {
///-- cursorPos = _qSciSourceCodeEditor->text().count() - 1;
///-- cursorPos = m _qSciSourceCodeEditor->text().count() - 1;
///-- }
///-- }
///-- savedCursor.setPosition( cursorPos );
///-- savedCursor.setPosition( cursorPos );
///-- _qSciSourceCodeEditor->setTextCursor( savedCursor );
///-- m _qSciSourceCodeEditor->setTextCursor( savedCursor );
///-- */
///-- */
///-- _sourceCodeChanged = false;
///-- m _sourceCodeChanged = false;
///-- }
///-- }
///-- _indentSettingsChanged = false;
///-- _indentSettingsChanged = false;
///--
///--
///-- if (_savedSourceContent == _qSciSourceCodeEditor->text())
///-- if (_savedSourceContent == m _qSciSourceCodeEditor->text())
///-- {
///-- {
///-- _qSciSourceCodeEditor->setModified(false);
///-- m _qSciSourceCodeEditor->setModified(false);
///-- setWindowModified(false);
///-- setWindowModified(false);
///-- }
///-- }
///-- else
///-- else
///-- {
///-- {
///-- _qSciSourceCodeEditor->setModified(true);
///-- m _qSciSourceCodeEditor->setModified(true);
///-- setWindowModified(true);
///-- setWindowModified(true);
///-- }
///-- }
///-- }
///-- }
@ -974,7 +986,7 @@ void MainWindow::exportToPDF()
///-- QsciPrinter printer(TQPrinter::HighResolution);
///-- QsciPrinter printer(TQPrinter::HighResolution);
///-- printer.setOutputFormat(TQPrinter::PdfFormat);
///-- printer.setOutputFormat(TQPrinter::PdfFormat);
///-- printer.setOutputFileName(fileName);
///-- printer.setOutputFileName(fileName);
///-- printer.printRange( _qSciSourceCodeEditor);
///-- printer.printRange( m _qSciSourceCodeEditor);
///-- }
///-- }
}
}
@ -996,7 +1008,7 @@ void MainWindow::exportToHTML()
///-- if (!fileName.isEmpty())
///-- if (!fileName.isEmpty())
///-- {
///-- {
///-- // Create a document from which HTML code can be generated.
///-- // Create a document from which HTML code can be generated.
///-- TQTextDocument sourceCodeDocument( _qSciSourceCodeEditor->text());
///-- TQTextDocument sourceCodeDocument( m _qSciSourceCodeEditor->text());
///-- sourceCodeDocument.setDefaultFont(TQFont("Courier", 12, TQFont::Normal));
///-- sourceCodeDocument.setDefaultFont(TQFont("Courier", 12, TQFont::Normal));
///-- TQString sourceCodeAsHTML = sourceCodeDocument.toHtml();
///-- TQString sourceCodeAsHTML = sourceCodeDocument.toHtml();
///-- // To ensure that empty lines are kept in the HTML code make this replacement.
///-- // To ensure that empty lines are kept in the HTML code make this replacement.
@ -1073,14 +1085,14 @@ void MainWindow::exportToHTML()
*/
*/
void MainWindow : : saveSettings ( )
void MainWindow : : saveSettings ( )
{
{
///-- m_settings->setValueByName("encoding", _currentEncoding);
m_settings - > setValueByName ( " VersionInSettingsFile " , PROGRAM_VERSION_STRING ) ;
///-- m_settings->setValueByName("version", PROGRAM_VERSION_STRING);
m_settings - > setValueByName ( " WindowIsMaximized " , isMaximized ( ) ) ;
m_settings - > setValueByName ( " WindowIsMaximized " , isMaximized ( ) ) ;
if ( ! isMaximized ( ) )
if ( ! isMaximized ( ) )
{
{
m_settings - > setValueByName ( " WindowPosition " , pos ( ) ) ;
m_settings - > setValueByName ( " WindowPosition " , pos ( ) ) ;
m_settings - > setValueByName ( " WindowSize " , size ( ) ) ;
m_settings - > setValueByName ( " WindowSize " , size ( ) ) ;
}
}
m_settings - > setValueByName ( " FileEncoding " , m_currentEncoding ) ;
///-- m_settings->setValueByName("MainWindowState", saveState());
///-- m_settings->setValueByName("MainWindowState", saveState());
///--
///--
///-- // Also save the syntax highlight style for all lexers.
///-- // Also save the syntax highlight style for all lexers.
@ -1216,7 +1228,7 @@ bool MainWindow::maybeSave()
///-- "Reopen the currently opened source code file by using the text encoding scheme ") +
///-- "Reopen the currently opened source code file by using the text encoding scheme ") +
///-- encodingName);
///-- encodingName);
///-- encodingAction->setCheckable(true);
///-- encodingAction->setCheckable(true);
///-- if (encodingName == _currentEncoding)
///-- if (encodingName == m _currentEncoding)
///-- {
///-- {
///-- encodingAction->setChecked(true);
///-- encodingAction->setChecked(true);
///-- }
///-- }
@ -1281,13 +1293,13 @@ bool MainWindow::maybeSave()
///-- TQTextStream inSrcStrm(&inSrcFile);
///-- TQTextStream inSrcStrm(&inSrcFile);
///-- TQApplication::setOverrideCursor(TQt::WaitCursor);
///-- TQApplication::setOverrideCursor(TQt::WaitCursor);
///-- TQString encodingName = encodingAction->text();
///-- TQString encodingName = encodingAction->text();
///-- _currentEncoding = encodingName;
///-- m _currentEncoding = encodingName;
///-- inSrcStrm.setCodec(TQTextCodec::codecForName(encodingName.toAscii()));
///-- inSrcStrm.setCodec(TQTextCodec::codecForName(encodingName.toAscii()));
///-- fileContent = inSrcStrm.readAll();
///-- fileContent = inSrcStrm.readAll();
///-- TQApplication::restoreOverrideCursor();
///-- TQApplication::restoreOverrideCursor();
///-- inSrcFile.close();
///-- inSrcFile.close();
///-- _qSciSourceCodeEditor->setText(fileContent);
///-- m _qSciSourceCodeEditor->setText(fileContent);
///-- _qSciSourceCodeEditor->setModified(false);
///-- m _qSciSourceCodeEditor->setModified(false);
///-- }
///-- }
///-- }
///-- }
///-- }
///-- }
@ -1306,7 +1318,7 @@ bool MainWindow::maybeSave()
///-- foreach(highlighterName, _highlighter->getAvailableHighlighters())
///-- foreach(highlighterName, _highlighter->getAvailableHighlighters())
///-- {
///-- {
///-- highlighterAction = new TQAction(highlighterName, _highlighterActionGroup);
///-- highlighterAction = new TQAction(highlighterName, _highlighterActionGroup);
///-- highlighterAction->setStatusTip(tr("Set the syntax highlight n ing to ") + highlighterName);
///-- highlighterAction->setStatusTip(tr("Set the syntax highlight ing to ") + highlighterName);
///-- highlighterAction->setCheckable(true);
///-- highlighterAction->setCheckable(true);
///-- }
///-- }
///-- _mainWindowForm->popupMenuHighlighter->addActions(_highlighterActionGroup->actions());
///-- _mainWindowForm->popupMenuHighlighter->addActions(_highlighterActionGroup->actions());
@ -1316,25 +1328,25 @@ bool MainWindow::maybeSave()
///-- connect(_highlighterActionGroup, SIGNAL(triggered(TQAction*)), _highlighter,
///-- connect(_highlighterActionGroup, SIGNAL(triggered(TQAction*)), _highlighter,
///-- SLOT(setHighlighterByAction(TQAction*)));
///-- SLOT(setHighlighterByAction(TQAction*)));
///-- }
///-- }
///--
///-- /*
/*
///-- \brief Is called whenever the white space visibility is being changed in the menu.
\ brief Is called whenever the white space visibility is being changed in the menu .
///-- */
*/
///-- void MainWindow::setWhiteSpaceVisibility(bool visible)
void MainWindow : : setWhiteSpaceVisibility ( bool visible )
///-- {
{
///-- if (_qSciSourceCodeEditor != NULL)
if ( m_qSciSourceCodeEditor )
///-- {
{
///-- if (visible)
if ( visible )
///-- {
{
///-- _qSciSourceCodeEditor->setWhitespaceVisibility(QsciScintilla::WsVisible);
m_qSciSourceCodeEditor - > setWhitespaceVisibility ( TQextScintilla : : WsVisible ) ;
///-- }
}
///-- else
else
///-- {
{
///-- _qSciSourceCodeEditor->setWhitespaceVisibility(QsciScintilla::WsInvisible);
m_qSciSourceCodeEditor - > setWhitespaceVisibility ( TQextScintilla : : WsInvisible ) ;
///-- }
}
///-- }
}
///-- }
}
///--
///-- /*
///-- /*
///-- \brief This slot is called whenever the number of lines in the editor changes
///-- \brief This slot is called whenever the number of lines in the editor changes
///-- and adapts the margin for the displayed line numbers.
///-- and adapts the margin for the displayed line numbers.
@ -1342,8 +1354,8 @@ bool MainWindow::maybeSave()
///-- void MainWindow::numberOfLinesChanged()
///-- void MainWindow::numberOfLinesChanged()
///-- {
///-- {
///-- TQString lineNumbers;
///-- TQString lineNumbers;
///-- lineNumbers.setNum( _qSciSourceCodeEditor->lines() * 10);
///-- lineNumbers.setNum( m _qSciSourceCodeEditor->lines() * 10);
///-- _qSciSourceCodeEditor->setMarginWidth(1, lineNumbers);
///-- m _qSciSourceCodeEditor->setMarginWidth(1, lineNumbers);
///-- }
///-- }
///--
///--
///-- /*
///-- /*
@ -1391,13 +1403,13 @@ bool MainWindow::maybeSave()
///-- foreach(TQString highlighterName, _highlighter->getAvailableHighlighters())
///-- foreach(TQString highlighterName, _highlighter->getAvailableHighlighters())
///-- {
///-- {
///-- TQAction *highlighterAction = actionList.at(i);
///-- TQAction *highlighterAction = actionList.at(i);
///-- highlighterAction->setStatusTip(tr("Set the syntax highlight n ing to ") + highlighterName);
///-- highlighterAction->setStatusTip(tr("Set the syntax highlight ing to ") + highlighterName);
///-- i++;
///-- i++;
///-- }
///-- }
///--
///--
///-- // Translate the line and column indicators in the statusbar.
///-- // Translate the line and column indicators in the statusbar.
///-- int line, column;
///-- int line, column;
///-- _qSciSourceCodeEditor->getCursorPosition(&line, &column);
///-- m _qSciSourceCodeEditor->getCursorPosition(&line, &column);
///-- setStatusBarCursorPosInfo(line, column);
///-- setStatusBarCursorPosInfo(line, column);
///-- }
///-- }
///-- else
///-- else