Added logic to call the indenter and update the preview

Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
pull/3/head
Michele Calgaro 2 years ago
parent 74e91ff8c1
commit 63d63ad52b
Signed by: MicheleC
GPG Key ID: 2A75B7CA8ADED5CF

@ -30,6 +30,7 @@
#include "UiGuiSettings.h" #include "UiGuiSettings.h"
#include "TemplateBatchScript.h" #include "TemplateBatchScript.h"
#include <tqaction.h>
#include <tqapplication.h> #include <tqapplication.h>
#include <tqcheckbox.h> #include <tqcheckbox.h>
#include <tqcombobox.h> #include <tqcombobox.h>
@ -44,19 +45,15 @@
#include <tqpopupmenu.h> #include <tqpopupmenu.h>
#include <tqprocess.h> #include <tqprocess.h>
#include <tqspinbox.h> #include <tqspinbox.h>
#include <tqstringlist.h>
#include <tqtextcodec.h>
#include <tqtextstream.h>
#include <tqtoolbox.h> #include <tqtoolbox.h>
#include <tqtoolbutton.h> #include <tqtoolbutton.h>
#include <tqtooltip.h> #include <tqtooltip.h>
//--- #include <tqsettings.h> //--- #include <tqsettings.h>
//--- #include <tqstringlist.h>
//--- #include <tqbytearray.h> //--- #include <tqbytearray.h>
//--- #include <tqtextstream.h>
//--- #include <tqtextcodec.h>
//--- #include <tqtscript.h> //--- #include <tqtscript.h>
//--- #include <tqdesktopservices.h>
//--- #include <tqaction.h>
//--- #include <tqcontextmenuevent.h>
//--- #include <tqtdebug.h>
// \defgroup grp_Indenter All concerning handling of the indenter. // \defgroup grp_Indenter All concerning handling of the indenter.
@ -306,32 +303,32 @@ TQString IndentHandler::generateShellScript(const TQString &configFilename)
return shellScript; return shellScript;
} }
//--- /* /*
//--- \brief Format \a sourceCode by calling the indenter. \brief Format \a sourceCode by calling the indenter.
//---
//--- The \a inputFileExtension has to be given as parameter so the called indenter The \a inputFileExtension has to be given as parameter so the called indenter
//--- can identify the programming language if needed. can identify the programming language if needed.
//--- */ */
//--- TQString IndentHandler::callIndenter(TQString sourceCode, TQString inputFileExtension) TQString IndentHandler::callIndenter(const TQString &sourceCode, const TQString &inputFileExtension)
//--- { {
//--- if (m_indenterExecutableSuffix == ".js") if (m_indenterExecutableSuffix == ".js")
//--- { {
//--- return callJavaScriptIndenter(sourceCode); return callJavaScriptIndenter(sourceCode);
//--- } }
//--- else else
//--- { {
//--- return callExecutableIndenter(sourceCode, inputFileExtension); return callExecutableIndenter(sourceCode, inputFileExtension);
//--- } }
//--- } }
//---
//--- /* /*
//--- \brief Format \a sourceCode by calling the interpreted JavaScript code of the indenter. \brief Format \a sourceCode by calling the interpreted JavaScript code of the indenter.
//---
//--- The \a inputFileExtension has to be given as parameter so the called indenter The \a inputFileExtension has to be given as parameter so the called indenter
//--- can identify the programming language if needed. can identify the programming language if needed.
//--- */ */
//--- TQString IndentHandler::callJavaScriptIndenter(TQString sourceCode) TQString IndentHandler::callJavaScriptIndenter(const TQString &sourceCode)
//--- { {
//--- TQScriptEngine engine; //--- TQScriptEngine engine;
//--- //---
//--- engine.globalObject().setProperty("unformattedCode", sourceCode); //--- engine.globalObject().setProperty("unformattedCode", sourceCode);
@ -346,263 +343,190 @@ TQString IndentHandler::generateShellScript(const TQString &configFilename)
//--- //---
//--- TQScriptValue value = engine.evaluate(jsDecoderCode); //--- TQScriptValue value = engine.evaluate(jsDecoderCode);
//--- return value.toString(); //--- return value.toString();
//--- } return "";
//--- }
//--- /*
//--- \brief Format \a sourceCode by calling the binary executable of the indenter. /*
//--- \brief Format \a sourceCode by calling the binary executable of the indenter.
//--- The \a inputFileExtension has to be given as parameter so the called indenter
//--- can identify the programming language if needed. The \a inputFileExt has to be given as parameter so the called indenter
//--- */ can identify the programming language if needed.
//--- TQString IndentHandler::callExecutableIndenter(TQString sourceCode, TQString inputFileExtension) */
//--- { TQString IndentHandler::callExecutableIndenter(const TQString &sourceCode, const TQString &inputFileExt)
//--- Q_ASSERT_X(!m_inputFileName.isEmpty(), "callIndenter", "m_inputFileName is empty"); {
//--- // Q_ASSERT_X( !m_outputFileName.isEmpty(), "callIndenter", "m_outputFileName is empty" ); if (m_indenterFileName.isEmpty() || inputFileExt.isEmpty())
//--- Q_ASSERT_X(!m_indenterFileName.isEmpty(), "callIndenter", "m_indenterFileName is empty"); {
//--- return TQString::null;
//--- if (m_indenterFileName.isEmpty()) }
//--- {
//--- return ""; TQString indenterCompleteCallString;
//--- } TQString parameterInputFile;
//--- TQString parameterOuputFile;
//--- TQString formattedSourceCode; TQString parameterParameterFile;
//--- TQString indenterCompleteCallString; TQProcess indentProcess;
//--- TQString parameterInputFile;
//--- TQString parameterOuputFile; TQObject::connect(&indentProcess, SIGNAL(processExited()), this, SLOT(indenterProcessFinished()));
//--- TQString parameterParameterFile;
//--- TQProcess indentProcess; // Generate the parameter string that will be saved to the indenters config file
//--- TQString processReturnString; TQString parameterString = getParameterString();
//---
//--- // Generate the parameter string that will be saved to the indenters config file if (!m_globalConfigFilename.isEmpty())
//--- TQString parameterString = getParameterString(); {
//--- saveConfigFile(m_tempDirectoryStr + "/" + m_globalConfigFilename, parameterString);
//--- if (!m_globalConfigFilename.isEmpty()) }
//--- {
//--- saveConfigFile(m_tempDirectoryStr + "/" + m_globalConfigFilename, parameterString); // Only add a dot to file extension if the string is not empty
//--- } TQString inputFileExtension = "." + inputFileExt;
//---
//--- // Only add a dot to file extension if the string is not empty // Delete any previously used input src file and create a new input src file.
//--- if (!inputFileExtension.isEmpty()) TQFile::remove(m_tempDirectoryStr + "/" + m_inputFileName + inputFileExtension);
//--- { TQFile inputSrcFile(m_tempDirectoryStr + "/" + m_inputFileName + inputFileExtension);
//--- inputFileExtension = "." + inputFileExtension; // Write the source code to the input file for the indenter
//--- } if (inputSrcFile.open(IO_ReadWrite | IO_Translate))
//--- {
//--- // Delete any previously used input src file and create a new input src file. TQCString sourceCodeCString = sourceCode.utf8();
//--- TQFile::remove(m_tempDirectoryStr + "/" + m_inputFileName + inputFileExtension); inputSrcFile.writeBlock(sourceCodeCString.data(), sourceCodeCString.length());
//--- TQFile inputSrcFile(m_tempDirectoryStr + "/" + m_inputFileName + inputFileExtension); inputSrcFile.close();
//--- // Write the source code to the input file for the indenter // tqDebug("Wrote source code to be indented to file %s", inputSrcFile.name().local8Bit().data());
//--- if (inputSrcFile.open(TQFile::ReadWrite | TQFile::Text)) }
//--- { else
//--- inputSrcFile.write(sourceCode.toUtf8()); {
//--- inputSrcFile.close(); tqDebug("Couldn't write to be indented source code to file %s", inputSrcFile.name().local8Bit().data());
//--- tqDebug() << __LINE__ << " " << __FUNCTION__ << ": Wrote to be indented source code to file " << }
//--- inputSrcFile.fileName();
//--- } // Set the input file for the indenter to be called.
//--- else if (m_inputFileParameter.stripWhiteSpace() == "<" || m_inputFileParameter == "stdin")
//--- { {
//--- qCritical() << __LINE__ << " " << __FUNCTION__ << parameterInputFile = " < " + inputSrcFile.name();
//--- ": Couldn't write to be indented source code to file " << inputSrcFile.fileName(); }
//--- } else
//--- {
//--- // Set the input file for the to be called indenter. parameterInputFile = " " + m_inputFileParameter + m_inputFileName + inputFileExtension;
//--- if (m_inputFileParameter.trimmed() == "<" || m_inputFileParameter == "stdin") }
//--- {
//--- parameterInputFile = ""; // Set the output file for the to be called indenter.
//--- indentProcess.setStandardInputFile(inputSrcFile.fileName()); if (m_outputFileParameter != "none" && m_outputFileParameter != "stdout")
//--- } {
//--- else parameterOuputFile = " " + m_outputFileParameter + m_outputFileName + inputFileExtension;
//--- { }
//--- parameterInputFile = " " + m_inputFileParameter + m_inputFileName + inputFileExtension;
//--- } // If the config file name is empty it is assumed that all parameters are sent via command line
//--- // call
//--- // Set the output file for the to be called indenter. if (m_globalConfigFilename.isEmpty())
//--- if (m_outputFileParameter != "none" && m_outputFileParameter != "stdout") {
//--- { parameterParameterFile = " " + parameterString;
//--- parameterOuputFile = " " + m_outputFileParameter + m_outputFileName + inputFileExtension; }
//--- } // if needed add the parameter to the indenter call string where the config file can be found
//--- else if (m_useCfgFileParameter != "none")
//--- // If the config file name is empty it is assumed that all parameters are sent via command line {
//--- // call parameterParameterFile = " " + m_useCfgFileParameter + m_tempDirectoryStr + "/" +
//--- if (m_globalConfigFilename.isEmpty()) m_globalConfigFilename;
//--- { }
//--- parameterParameterFile = " " + parameterString;
//--- } // Assemble indenter call string for parameters according to the set order.
//--- // if needed add the parameter to the indenter call string where the config file can be found if (m_parameterOrder == "ipo")
//--- else if (m_useCfgFileParameter != "none") {
//--- { indenterCompleteCallString = parameterInputFile + parameterParameterFile + parameterOuputFile;
//--- parameterParameterFile = " " + m_useCfgFileParameter + "\"" + m_tempDirectoryStr + "/" + }
//--- m_globalConfigFilename + "\""; else if (m_parameterOrder == "pio")
//--- } {
//--- indenterCompleteCallString = parameterParameterFile + parameterInputFile + parameterOuputFile;
//--- // Assemble indenter call string for parameters according to the set order. }
//--- if (m_parameterOrder == "ipo") else if (m_parameterOrder == "poi")
//--- { {
//--- indenterCompleteCallString = parameterInputFile + parameterParameterFile + parameterOuputFile; indenterCompleteCallString = parameterParameterFile + parameterOuputFile + parameterInputFile;
//--- } }
//--- else if (m_parameterOrder == "pio") else
//--- { {
//--- indenterCompleteCallString = parameterParameterFile + parameterInputFile + parameterOuputFile; indenterCompleteCallString = parameterInputFile + parameterOuputFile + parameterParameterFile;
//--- } }
//--- else if (m_parameterOrder == "poi")
//--- { // If no indenter executable call string could be created before, show an error message.
//--- indenterCompleteCallString = parameterParameterFile + parameterOuputFile + parameterInputFile; if (m_indenterExecutableCallString.isEmpty())
//--- } {
//--- else m_errorMessageDialog->showMessage(tr("No indenter executable"), tr(
//--- { "There exists no indenter executable with the name \"%1\" in the directory \"%2\" nor in the global environment.").arg(
//--- indenterCompleteCallString = parameterInputFile + parameterOuputFile + parameterParameterFile; m_indenterFileName).arg(m_indenterDirectoryStr));
//--- } return sourceCode;
//--- }
//--- // If no indenter executable call string could be created before, show an error message.
//--- if (m_indenterExecutableCallString.isEmpty()) // Generate the indenter call string either for win32 or other systems.
//--- { indenterCompleteCallString = m_indenterExecutableCallString + indenterCompleteCallString;
//--- m_errorMessageDialog->showMessage(tr("No indenter executable"), tr(
//--- "There exists no indenter executable with the name \"%1\" in the directory \"%2\" nor in the global environment.").arg( // errors and standard outputs from the process call are merged together
//--- m_indenterFileName).arg(m_indenterDirectoryStr)); //indentProcess.setReadChannelMode(TQProcess::MergedChannels);
//--- return sourceCode;
//--- } // Set the directory for the indenter execution
//--- indentProcess.setWorkingDirectory(TQFileInfo(m_tempDirectoryStr).absFilePath());
//--- // Generate the indenter call string either for win32 or other systems.
//--- indenterCompleteCallString = m_indenterExecutableCallString + indenterCompleteCallString; // tqDebug(TQString("Will call the indenter in the directory ") + indentProcess.workingDirectory().path() +
//--- // " using this commandline call: " + indenterCompleteCallString);
//--- // errors and standard outputs from the process call are merged together
//--- //indentProcess.setReadChannelMode(TQProcess::MergedChannels); indentProcess.clearArguments();
//--- TQStringList arguments = TQStringList::split(" ", indenterCompleteCallString);
//--- // Set the directory where the indenter will be executed for the process' environment as PWD. for (const TQString &argument : arguments)
//--- TQStringList env = indentProcess.environment(); {
//--- env << "PWD=" + TQFileInfo(m_tempDirectoryStr).absFilePath(); indentProcess.addArgument(argument);
//--- indentProcess.setEnvironment(env); }
//---
//--- // Set the directory for the indenter execution m_indenterProcessFinished = false;
//--- indentProcess.setWorkingDirectory(TQFileInfo(m_tempDirectoryStr).absFilePath()); indentProcess.start();
//--- int counter = 100; // roughtly 10s at 100ms interval
//--- tqDebug() << __LINE__ << " " << __FUNCTION__ << ": Will call the indenter in the directory " << while (!m_indenterProcessFinished && counter > 0)
//--- indentProcess.workingDirectory() << " using this commandline call: " << {
//--- indenterCompleteCallString; usleep(100 * 1000);
//--- tqApp->processEvents();
//--- indentProcess.start(indenterCompleteCallString); --counter;
//--- }
//--- processReturnString = "";
//--- bool calledProcessSuccessfully = indentProcess.waitForFinished(10000); TQString formattedSourceCode = sourceCode;
//--- // test if there was an error during starting the process of the indenter bool calledProcessSuccessfully = indentProcess.normalExit();
//--- if (!calledProcessSuccessfully) // test if there was an error during starting the process of the indenter
//--- { if (!calledProcessSuccessfully || indentProcess.exitStatus() != 0)
//--- processReturnString = "<html><body>"; {
//--- processReturnString += tr("<b>Returned error message:</b> ") + indentProcess.errorString() + TQString processReturnString = "<html><body>";
//--- "<br>"; processReturnString += tr("<b>Returned error code:</b> ") +
//--- TQString::number(indentProcess.exitStatus()) + "<br/>";
//--- switch (indentProcess.error()) processReturnString += tr("<br/><b>Call string:</b><br/>") +
//--- { encodeToHTML(indenterCompleteCallString) + "<br/>";
//--- case TQProcess::FailedToStart: processReturnString += tr("<br/><b>Process standard output:</b><br/>") +
//--- { encodeToHTML(TQString(indentProcess.readStdout())) + "<br/>";
//--- processReturnString += tr("<b>Reason could be:</b> ") + processReturnString += tr("<br/><b>Process error output:</b><br/>") +
//--- "The process failed to start. Either the invoked program is missing, or you may have insufficient permissions to invoke the program.<br>"; encodeToHTML(TQString(indentProcess.readStderr())) + "<br/>";
//--- break; TQApplication::restoreOverrideCursor();
//--- } m_errorMessageDialog->showMessage(tr("Error calling Indenter"), processReturnString);
//--- }
//--- case TQProcess::Crashed: else
//--- { {
//--- processReturnString += "The process crashed some time after starting successfully.<br>"; if (m_outputFileParameter == "stdout")
//--- break; {
//--- } formattedSourceCode = TQString(indentProcess.readStdout());
//--- }
//--- case TQProcess::Timedout: // ... else read the output file generated by the indenter call.
//--- { else
//--- processReturnString += {
//--- "The called indenter did not response for over 10 seconds, so aborted its execution.<br>"; TQFile outSrcFile(m_tempDirectoryStr + "/" + m_outputFileName + inputFileExtension);
//--- break; if (outSrcFile.open(IO_ReadOnly | IO_Translate))
//--- } {
//--- TQTextStream outSrcStrm(&outSrcFile);
//--- case TQProcess::WriteError: outSrcStrm.setCodec(TQTextCodec::codecForName("UTF-8"));
//--- { formattedSourceCode = outSrcStrm.read();
//--- processReturnString += outSrcFile.close();
//--- "An error occurred when attempting to write to the process. For example, the process may not be running, or it may have closed its input channel.<br>"; // tqDebug("Read indenter output from file " + outSrcFile.name());
//--- break; }
//--- } else
//--- {
//--- case TQProcess::ReadError: tqDebug("Couldn't read indenter output from file " + outSrcFile.name());
//--- { }
//--- processReturnString += }
//--- "An error occurred when attempting to read from the process. For example, the process may not be running.<br>"; }
//--- break;
//--- } // Delete the temporary input and output files.
//--- TQFile::remove(m_tempDirectoryStr + "/" + m_outputFileName + inputFileExtension);
//--- case TQProcess::UnknownError: TQFile::remove(m_tempDirectoryStr + "/" + m_inputFileName + inputFileExtension);
//--- {
//--- processReturnString += return formattedSourceCode;
//--- "An unknown error occurred. This is the default return value of error().<br>"; }
//--- break;
//--- }
//---
//--- default:
//--- {
//--- break;
//--- }
//--- }
//--- processReturnString += tr("<br><b>Callstring was:</b> ") + encodeToHTML(
//--- indenterCompleteCallString);
//--- processReturnString += tr("<br><br><b>Indenter output was:</b><pre>") + "<br>" + "(STDOUT):" +
//--- encodeToHTML(indentProcess.readAllStandardOutput()) + "<br>" + "(STDERR):" +
//--- encodeToHTML(indentProcess.readAllStandardError()) + "<br>" + "</pre></html></body>";
//--- tqWarning() << __LINE__ << " " << __FUNCTION__ << processReturnString;
//--- TQApplication::restoreOverrideCursor();
//--- m_errorMessageDialog->showMessage(tr("Error calling Indenter"), processReturnString);
//--- }
//---
//--- // If the indenter returned an error code != 0 show its output.
//--- if (indentProcess.exitCode() != 0)
//--- {
//--- TQString exitCode;
//--- exitCode.setNum(indentProcess.exitCode());
//--- processReturnString = tr("<b>Indenter returned with exit code:</b> ") + exitCode + "<br>" + tr(
//--- "<b>Indent console output was:</b> ") + "<br>" + "(STDOUT):" + encodeToHTML(
//--- indentProcess.readAllStandardOutput()) + "<br>" + "(STDERR):" + encodeToHTML(
//--- indentProcess.readAllStandardError()) + "<br>" + tr("<br><b>Callstring was:</b> ") +
//--- encodeToHTML(indenterCompleteCallString) + "</html></body>";
//--- tqWarning() << __LINE__ << " " << __FUNCTION__ << processReturnString;
//--- TQApplication::restoreOverrideCursor();
//--- m_errorMessageDialog->showMessage(tr("Indenter returned error"), processReturnString);
//--- }
//---
//--- // Only get the formatted source code, if calling the indenter did succeed.
//--- if (calledProcessSuccessfully)
//--- {
//--- // If the indenter results are written to stdout, read them from there...
//--- if (indentProcess.exitCode() == 0 && m_outputFileParameter == "stdout")
//--- {
//--- formattedSourceCode = indentProcess.readAllStandardOutput();
//--- tqDebug() << __LINE__ << " " << __FUNCTION__ << ": Read indenter output from StdOut.";
//--- }
//--- // ... else read the output file generated by the indenter call.
//--- else
//--- {
//--- TQFile outSrcFile(m_tempDirectoryStr + "/" + m_outputFileName + inputFileExtension);
//--- if (outSrcFile.open(TQFile::ReadOnly | TQFile::Text))
//--- {
//--- TQTextStream outSrcStrm(&outSrcFile);
//--- outSrcStrm.setCodec(TQTextCodec::codecForName("UTF-8"));
//--- formattedSourceCode = outSrcStrm.readAll();
//--- outSrcFile.close();
//--- tqDebug() << __LINE__ << " " << __FUNCTION__ << ": Read indenter output from file " <<
//--- outSrcFile.fileName();
//--- }
//--- else
//--- {
//--- qCritical() << __LINE__ << " " << __FUNCTION__ <<
//--- ": Couldn't read indenter output from file " << outSrcFile.fileName();
//--- }
//--- }
//--- }
//--- else
//--- {
//--- return sourceCode;
//--- }
//---
//--- // Delete the temporary input and output files.
//--- TQFile::remove(m_tempDirectoryStr + "/" + m_outputFileName + inputFileExtension);
//--- TQFile::remove(m_tempDirectoryStr + "/" + m_inputFileName + inputFileExtension);
//---
//--- return formattedSourceCode;
//--- }
/* /*
\brief Generates and returns a string with all parameters needed to call the indenter. \brief Generates and returns a string with all parameters needed to call the indenter.
@ -767,7 +691,7 @@ bool IndentHandler::loadConfigFile(const TQString &filePathName)
// Search for name of each numeric parameter and set the value found behind it. // Search for name of each numeric parameter and set the value found behind it.
for(const ParamNumeric &pNumeric : m_paramNumerics) for(const ParamNumeric &pNumeric : m_paramNumerics)
{ {
int index = cfgFileData.find(pNumeric.paramCallName, 0, false); int index = cfgFileData.find(pNumeric.paramCallName, 0);
// parameter was found in config file // parameter was found in config file
if (index != -1) if (index != -1)
{ {
@ -1784,22 +1708,22 @@ void IndentHandler::handleChangedIndenterSettings()
emit(indenterSettingsChanged()); emit(indenterSettingsChanged());
} }
//--- /*! /*!
//--- \brief Converts characters < > and & in the \a text to HTML codes &lt &gt and &amp. \brief Converts characters < > and & in the \a text to HTML codes &lt &gt and &amp.
//--- */ */
//--- TQString IndentHandler::encodeToHTML(const TQString &text) TQString IndentHandler::encodeToHTML(const TQString &text)
//--- { {
//--- TQString htmlText = text; TQString htmlText = text;
//--- htmlText.replace("&", "&amp;"); htmlText.replace("&", "&amp;");
//--- htmlText.replace("<", "&lt;"); htmlText.replace("<", "&lt;");
//--- htmlText.replace(">", "&gt;"); htmlText.replace(">", "&gt;");
//--- htmlText.replace('"', "&quot;"); htmlText.replace('"', "&quot;");
//--- htmlText.replace("'", "&#39;"); htmlText.replace("'", "&#39;");
//--- htmlText.replace("^", "&circ;"); htmlText.replace("^", "&circ;");
//--- htmlText.replace("~", "&tilde;"); htmlText.replace("~", "&tilde;");
//--- htmlText.replace("€", "&euro;"); htmlText.replace("", "&euro;");
//--- htmlText.replace("©", "&copy;"); htmlText.replace("©", "&copy;");
//--- return htmlText; return htmlText;
//--- } }
#include "IndentHandler.moc" #include "IndentHandler.moc"

@ -47,7 +47,7 @@ class IndentHandler : public TQWidget
~IndentHandler(); ~IndentHandler();
TQString generateShellScript(const TQString &configFilename); TQString generateShellScript(const TQString &configFilename);
///-- TQString callIndenter(TQString sourceCode, TQString inputFileExtension); TQString callIndenter(const TQString &sourceCode, const TQString &inputFileExtension);
bool loadConfigFile(const TQString &filePathName); bool loadConfigFile(const TQString &filePathName);
void resetToDefaultValues(); void resetToDefaultValues();
TQStringList getAvailableIndenters(); TQStringList getAvailableIndenters();
@ -77,8 +77,8 @@ class IndentHandler : public TQWidget
void indenterProcessFinished(); void indenterProcessFinished();
private: private:
///-- TQString callExecutableIndenter(TQString sourceCode, TQString inputFileExtension); TQString callExecutableIndenter(const TQString &sourceCode, const TQString &inputFileExt);
///-- TQString callJavaScriptIndenter(TQString sourceCode); TQString callJavaScriptIndenter(const TQString &sourceCode);
void saveConfigFile(const TQString &filePathName, const TQString &parameterString); void saveConfigFile(const TQString &filePathName, const TQString &parameterString);
void readIndentIniFile(const TQString &iniFilePath); void readIndentIniFile(const TQString &iniFilePath);
bool createIndenterCallString(); bool createIndenterCallString();
@ -169,8 +169,8 @@ class IndentHandler : public TQWidget
TQString m_indenterExecutableSuffix; TQString m_indenterExecutableSuffix;
bool m_indenterProcessFinished; bool m_indenterProcessFinished;
///-- //TODO: This function should go into a string helper/tool class/file. //TODO: This function should go into a string helper/tool class/file.
///-- TQString encodeToHTML(const TQString &text); TQString encodeToHTML(const TQString &text);
}; };
#endif // INDENTHANDLER_H #endif // INDENTHANDLER_H

@ -468,10 +468,10 @@ void MainWindow::initIndenter()
connect(m_indentHandler, SIGNAL(indenterSettingsChanged()), this, connect(m_indentHandler, SIGNAL(indenterSettingsChanged()), this,
SLOT(indentSettingsChangedSlot())); SLOT(indentSettingsChangedSlot()));
///-- // Set this true, so the indenter is called at first program start // Set this true, so the indenter is called at first program start
///-- _indentSettingsChanged = true; m_indentSettingsChanged = true;
///-- m_previewToggled = true; m_previewToggled = true;
///--
///-- // Handle if indenter parameter tool tips are enabled ///-- // Handle if indenter parameter tool tips are enabled
///-- _settings->registerObjectProperty(actionIndenterParameterTooltipsEnabled, ///-- _settings->registerObjectProperty(actionIndenterParameterTooltipsEnabled,
///-- "checked", "indenterParameterTooltipsEnabled"); ///-- "checked", "indenterParameterTooltipsEnabled");
@ -683,8 +683,8 @@ void MainWindow::updateSourceView()
void MainWindow::callIndenter() void MainWindow::callIndenter()
{ {
TQApplication::setOverrideCursor(TQt::WaitCursor); TQApplication::setOverrideCursor(TQt::WaitCursor);
///-- m_sourceFormattedContent = m_indentHandler->callIndenter(m_sourceFileContent, m_sourceFormattedContent = m_indentHandler->callIndenter(m_sourceFileContent,
///-- m_currentSourceFileExtension); m_currentSourceFileExtension);
updateSourceView(); updateSourceView();
TQApplication::restoreOverrideCursor(); TQApplication::restoreOverrideCursor();
} }
@ -872,45 +872,38 @@ void MainWindow::sourceCodeChangedSlot()
*/ */
void MainWindow::indentSettingsChangedSlot() void MainWindow::indentSettingsChangedSlot()
{ {
///-- _indentSettingsChanged = true; m_indentSettingsChanged = true;
///--
///-- int cursorLine, cursorPos; int cursorLine, cursorPos;
///-- m_qSciSourceCodeEditor->getCursorPosition(&cursorLine, &cursorPos); m_qSciSourceCodeEditor->getCursorPosition(&cursorLine, &cursorPos);
///--
///-- if (m_toolBarWidget->cbLivePreview->isChecked()) if (m_toolBarWidget->cbLivePreview->isChecked())
///-- { {
///-- callIndenter(); callIndenter();
///-- m_previewToggled = true; m_previewToggled = true;
///--
///-- updateSourceView(); updateSourceView();
///-- if (m_sourceCodeChanged) if (m_sourceCodeChanged)
///-- { {
///-- /* savedCursor = m_qSciSourceCodeEditor->textCursor(); m_sourceCodeChanged = false;
///-- if ( cursorPos >= m_qSciSourceCodeEditor->text().count() ) { }
///-- cursorPos = m_qSciSourceCodeEditor->text().count() - 1; m_indentSettingsChanged = false;
///-- } }
///-- savedCursor.setPosition( cursorPos ); else
///-- m_qSciSourceCodeEditor->setTextCursor( savedCursor ); {
///-- */ updateSourceView();
///-- m_sourceCodeChanged = false; }
///-- }
///-- _indentSettingsChanged = false; if (m_savedSourceContent == m_qSciSourceCodeEditor->text())
///-- } {
///-- else m_qSciSourceCodeEditor->setModified(false);
///-- { m_documentModified = false;
///-- updateSourceView(); }
///-- } else
///-- {
///-- if (m_savedSourceContent == m_qSciSourceCodeEditor->text()) m_qSciSourceCodeEditor->setModified(true); // Has no effect according to TQScintilla docs.
///-- { m_documentModified = true;
///-- m_qSciSourceCodeEditor->setModified(false); }
///-- m_documentModified = false;
///-- }
///-- else
///-- {
///-- m_qSciSourceCodeEditor->setModified(true); // Has no effect according to TQScintilla docs.
///-- m_documentModified = true;
///-- }
} }
/* /*
@ -921,39 +914,32 @@ void MainWindow::indentSettingsChangedSlot()
*/ */
void MainWindow::previewTurnedOnOff(bool turnOn) void MainWindow::previewTurnedOnOff(bool turnOn)
{ {
///-- m_previewToggled = true; m_previewToggled = true;
///--
///-- int cursorLine, cursorPos; int cursorLine, cursorPos;
///-- m_qSciSourceCodeEditor->getCursorPosition(&cursorLine, &cursorPos); m_qSciSourceCodeEditor->getCursorPosition(&cursorLine, &cursorPos);
///--
///-- if (turnOn && (_indentSettingsChanged || m_sourceCodeChanged)) if (turnOn && (m_indentSettingsChanged || m_sourceCodeChanged))
///-- { {
///-- callIndenter(); callIndenter();
///-- } }
///-- updateSourceView(); updateSourceView();
///-- if (m_sourceCodeChanged) if (m_sourceCodeChanged)
///-- { {
///-- /* savedCursor = m_qSciSourceCodeEditor->textCursor(); m_sourceCodeChanged = false;
///-- if ( cursorPos >= m_qSciSourceCodeEditor->text().count() ) { }
///-- cursorPos = m_qSciSourceCodeEditor->text().count() - 1; m_indentSettingsChanged = false;
///-- }
///-- savedCursor.setPosition( cursorPos ); if (m_savedSourceContent == m_qSciSourceCodeEditor->text())
///-- m_qSciSourceCodeEditor->setTextCursor( savedCursor ); {
///-- */ m_qSciSourceCodeEditor->setModified(false);
///-- m_sourceCodeChanged = false; m_documentModified = false;
///-- } }
///-- _indentSettingsChanged = false; else
///-- {
///-- if (m_savedSourceContent == m_qSciSourceCodeEditor->text()) m_qSciSourceCodeEditor->setModified(true);
///-- { m_documentModified = true;
///-- m_qSciSourceCodeEditor->setModified(false); }
///-- m_documentModified = false;
///-- }
///-- else
///-- {
///-- m_qSciSourceCodeEditor->setModified(true);
///-- m_documentModified = true;
///-- }
} }
/* /*

@ -22,7 +22,6 @@
#include "MainWindowBase.h" #include "MainWindowBase.h"
#include "tqobjdefs.h"
#include "tqvaluelist.h" #include "tqvaluelist.h"
@ -130,7 +129,7 @@ class MainWindow : public MainWindowBase
TQTranslator *m_qTranslator; TQTranslator *m_qTranslator;
bool m_sourceCodeChanged; bool m_sourceCodeChanged;
///-- bool _indentSettingsChanged; bool m_indentSettingsChanged;
bool m_previewToggled; bool m_previewToggled;
bool m_documentModified; bool m_documentModified;
TQStringList m_recentlyOpenedList; TQStringList m_recentlyOpenedList;

Loading…
Cancel
Save