summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/IndentHandler.cpp1010
-rw-r--r--src/IndentHandler.h161
-rw-r--r--src/MainWindow.cpp2
3 files changed, 579 insertions, 594 deletions
diff --git a/src/IndentHandler.cpp b/src/IndentHandler.cpp
index eca9791..f3eec88 100644
--- a/src/IndentHandler.cpp
+++ b/src/IndentHandler.cpp
@@ -23,27 +23,29 @@
#include "MainWindow.h"
#include "SettingsPaths.h"
#include "UiGuiErrorMessage.h"
-//--- #include "UiGuiSettings.h"
+#include "UiGuiIniFileParser.h"
+#include "UiGuiSettings.h"
//--- #include "TemplateBatchScript.h"
-//--- #include "UiGuiIniFileParser.h"
+#include <tqapplication.h>
+#include <tqcheckbox.h>
#include <tqcombobox.h>
+#include <tqcursor.h>
#include <tqdir.h>
#include <tqfile.h>
#include <tqfiledialog.h>
+#include <tqlabel.h>
#include <tqlayout.h>
+#include <tqlineedit.h>
#include <tqmessagebox.h>
#include <tqpopupmenu.h>
+#include <tqspinbox.h>
#include <tqtoolbox.h>
#include <tqtoolbutton.h>
-//--- #include <tqapplication.h>
-//--- #include <tqcheckbox.h>
+#include <tqtooltip.h>
//--- #include <tqprocess.h>
//--- #include <tqsettings.h>
//--- #include <tqstringlist.h>
-//--- #include <tqlineedit.h>
-//--- #include <tqspinbox.h>
-//--- #include <tqlabel.h>
//--- #include <tqbytearray.h>
//--- #include <tqtextstream.h>
//--- #include <tqtextcodec.h>
@@ -73,12 +75,15 @@
its \a indenterID, which is the number of found indenter ini files in alphabetic
order starting at index 0.
*/
-IndentHandler::IndentHandler(int indenterID, MainWindow *mainWindow, TQWidget *parent)
- : TQWidget(parent), m_mainWindow(mainWindow), m_parent(parent), m_toolBoxContainerLayout(nullptr),
- m_indenterSelectionCombobox(nullptr), m_indenterParameterHelpButton(nullptr),
- m_indenterParameterCategoriesToolBox(nullptr), m_errorMessageDialog(nullptr)
-//--- m_indenterSettings(nullptr)
+IndentHandler::IndentHandler(int indenterID, MainWindow *mainWindow, TQWidget *parent) :
+ TQWidget(parent), m_mainWindow(mainWindow), m_parent(parent),
+ m_indenterSelectionCombobox(nullptr), m_indenterParameterHelpButton(nullptr),
+ m_indenterParameterCategoriesToolBox(nullptr), m_errorMessageDialog(nullptr),
+ m_toolBoxContainerLayout(nullptr), m_indenterSettings(nullptr)
{
+ // Create the settings object, which loads all UiGui settings from a file.
+ m_settings = UiGuiSettings::getInstance();
+
if (indenterID < 0)
{
indenterID = 0;
@@ -173,7 +178,6 @@ IndentHandler::IndentHandler(int indenterID, MainWindow *mainWindow, TQWidget *p
{
m_indenterSelectionCombobox->insertStringList(availableIndenters);
m_indenterSelectionCombobox->setCurrentItem(indenterID);
- // MIKE make sure setIndeter() is invoked, so indenter is correctly set at start
}
}
else
@@ -226,17 +230,17 @@ void IndentHandler::contextMenuEvent(TQContextMenuEvent *event)
//--- // Define the placeholder for parameter variables either in batch or bash programming.
//--- TQString shellParameterPlaceholder = "$1";
//---
-//--- parameterInputFile = " " + _inputFileParameter + "\"" + shellParameterPlaceholder + "\"";
+//--- parameterInputFile = " " + m_inputFileParameter + "\"" + shellParameterPlaceholder + "\"";
//---
-//--- if (_outputFileParameter != "none" && _outputFileParameter != "stdout")
+//--- if (m_outputFileParameter != "none" && m_outputFileParameter != "stdout")
//--- {
-//--- if (_outputFileName == _inputFileName)
+//--- if (m_outputFileName == m_inputFileName)
//--- {
-//--- parameterOuputFile = " " + _outputFileParameter + "\"" + shellParameterPlaceholder + "\"";
+//--- parameterOuputFile = " " + m_outputFileParameter + "\"" + shellParameterPlaceholder + "\"";
//--- }
//--- else
//--- {
-//--- parameterOuputFile = " " + _outputFileParameter + _outputFileName + ".tmp";
+//--- parameterOuputFile = " " + m_outputFileParameter + m_outputFileName + ".tmp";
//--- }
//--- }
//---
@@ -248,21 +252,21 @@ void IndentHandler::contextMenuEvent(TQContextMenuEvent *event)
//--- }
//--- // else if needed add the parameter to the indenter call string where the config file can be
//--- // found.
-//--- else if (_useCfgFileParameter != "none")
+//--- else if (m_useCfgFileParameter != "none")
//--- {
-//--- parameterParameterFile = " " + _useCfgFileParameter + "\"./" + configFilename + "\"";
+//--- parameterParameterFile = " " + m_useCfgFileParameter + "\"./" + configFilename + "\"";
//--- }
//---
//--- // Assemble indenter call string for parameters according to the set order.
-//--- if (_parameterOrder == "ipo")
+//--- if (m_parameterOrder == "ipo")
//--- {
//--- indenterCompleteCallString = parameterInputFile + parameterParameterFile + parameterOuputFile;
//--- }
-//--- else if (_parameterOrder == "pio")
+//--- else if (m_parameterOrder == "pio")
//--- {
//--- indenterCompleteCallString = parameterParameterFile + parameterInputFile + parameterOuputFile;
//--- }
-//--- else if (_parameterOrder == "poi")
+//--- else if (m_parameterOrder == "poi")
//--- {
//--- indenterCompleteCallString = parameterParameterFile + parameterOuputFile + parameterInputFile;
//--- }
@@ -276,15 +280,15 @@ void IndentHandler::contextMenuEvent(TQContextMenuEvent *event)
//--- indenterCompleteCallString;
//---
//--- // If the indenter writes to stdout pipe the output into a file
-//--- if (_outputFileParameter == "stdout")
+//--- if (m_outputFileParameter == "stdout")
//--- {
-//--- indenterCompleteCallString = indenterCompleteCallString + " >" + _outputFileName + ".tmp";
+//--- indenterCompleteCallString = indenterCompleteCallString + " >" + m_outputFileName + ".tmp";
//--- }
//---
//--- // If the output filename is not the same as the input filename copy the output over the input.
-//--- if (_outputFileName != _inputFileName)
+//--- if (m_outputFileName != m_inputFileName)
//--- {
-//--- replaceInputFileCommand = "mv " + _outputFileName + ".tmp \"" + shellParameterPlaceholder +
+//--- replaceInputFileCommand = "mv " + m_outputFileName + ".tmp \"" + shellParameterPlaceholder +
//--- "\"\n";
//--- }
//---
@@ -349,8 +353,8 @@ void IndentHandler::contextMenuEvent(TQContextMenuEvent *event)
//--- */
//--- TQString IndentHandler::callExecutableIndenter(TQString sourceCode, TQString inputFileExtension)
//--- {
-//--- Q_ASSERT_X(!_inputFileName.isEmpty(), "callIndenter", "_inputFileName is empty");
-//--- // Q_ASSERT_X( !_outputFileName.isEmpty(), "callIndenter", "_outputFileName is empty" );
+//--- Q_ASSERT_X(!m_inputFileName.isEmpty(), "callIndenter", "m_inputFileName is empty");
+//--- // Q_ASSERT_X( !m_outputFileName.isEmpty(), "callIndenter", "m_outputFileName is empty" );
//--- Q_ASSERT_X(!m_indenterFileName.isEmpty(), "callIndenter", "m_indenterFileName is empty");
//---
//--- if (m_indenterFileName.isEmpty())
@@ -381,8 +385,8 @@ void IndentHandler::contextMenuEvent(TQContextMenuEvent *event)
//--- }
//---
//--- // Delete any previously used input src file and create a new input src file.
-//--- TQFile::remove(m_tempDirectoryStr + "/" + _inputFileName + inputFileExtension);
-//--- TQFile inputSrcFile(m_tempDirectoryStr + "/" + _inputFileName + inputFileExtension);
+//--- TQFile::remove(m_tempDirectoryStr + "/" + m_inputFileName + inputFileExtension);
+//--- TQFile inputSrcFile(m_tempDirectoryStr + "/" + m_inputFileName + inputFileExtension);
//--- // Write the source code to the input file for the indenter
//--- if (inputSrcFile.open(TQFile::ReadWrite | TQFile::Text))
//--- {
@@ -398,20 +402,20 @@ void IndentHandler::contextMenuEvent(TQContextMenuEvent *event)
//--- }
//---
//--- // Set the input file for the to be called indenter.
-//--- if (_inputFileParameter.trimmed() == "<" || _inputFileParameter == "stdin")
+//--- if (m_inputFileParameter.trimmed() == "<" || m_inputFileParameter == "stdin")
//--- {
//--- parameterInputFile = "";
//--- indentProcess.setStandardInputFile(inputSrcFile.fileName());
//--- }
//--- else
//--- {
-//--- parameterInputFile = " " + _inputFileParameter + _inputFileName + inputFileExtension;
+//--- parameterInputFile = " " + m_inputFileParameter + m_inputFileName + inputFileExtension;
//--- }
//---
//--- // Set the output file for the to be called indenter.
-//--- if (_outputFileParameter != "none" && _outputFileParameter != "stdout")
+//--- if (m_outputFileParameter != "none" && m_outputFileParameter != "stdout")
//--- {
-//--- parameterOuputFile = " " + _outputFileParameter + _outputFileName + inputFileExtension;
+//--- parameterOuputFile = " " + m_outputFileParameter + m_outputFileName + inputFileExtension;
//--- }
//---
//--- // If the config file name is empty it is assumed that all parameters are sent via command line
@@ -421,22 +425,22 @@ void IndentHandler::contextMenuEvent(TQContextMenuEvent *event)
//--- parameterParameterFile = " " + parameterString;
//--- }
//--- // if needed add the parameter to the indenter call string where the config file can be found
-//--- else if (_useCfgFileParameter != "none")
+//--- else if (m_useCfgFileParameter != "none")
//--- {
-//--- parameterParameterFile = " " + _useCfgFileParameter + "\"" + m_tempDirectoryStr + "/" +
+//--- parameterParameterFile = " " + m_useCfgFileParameter + "\"" + m_tempDirectoryStr + "/" +
//--- m_globalConfigFilename + "\"";
//--- }
//---
//--- // Assemble indenter call string for parameters according to the set order.
-//--- if (_parameterOrder == "ipo")
+//--- if (m_parameterOrder == "ipo")
//--- {
//--- indenterCompleteCallString = parameterInputFile + parameterParameterFile + parameterOuputFile;
//--- }
-//--- else if (_parameterOrder == "pio")
+//--- else if (m_parameterOrder == "pio")
//--- {
//--- indenterCompleteCallString = parameterParameterFile + parameterInputFile + parameterOuputFile;
//--- }
-//--- else if (_parameterOrder == "poi")
+//--- else if (m_parameterOrder == "poi")
//--- {
//--- indenterCompleteCallString = parameterParameterFile + parameterOuputFile + parameterInputFile;
//--- }
@@ -560,7 +564,7 @@ void IndentHandler::contextMenuEvent(TQContextMenuEvent *event)
//--- if (calledProcessSuccessfully)
//--- {
//--- // If the indenter results are written to stdout, read them from there...
-//--- if (indentProcess.exitCode() == 0 && _outputFileParameter == "stdout")
+//--- if (indentProcess.exitCode() == 0 && m_outputFileParameter == "stdout")
//--- {
//--- formattedSourceCode = indentProcess.readAllStandardOutput();
//--- tqDebug() << __LINE__ << " " << __FUNCTION__ << ": Read indenter output from StdOut.";
@@ -568,7 +572,7 @@ void IndentHandler::contextMenuEvent(TQContextMenuEvent *event)
//--- // ... else read the output file generated by the indenter call.
//--- else
//--- {
-//--- TQFile outSrcFile(m_tempDirectoryStr + "/" + _outputFileName + inputFileExtension);
+//--- TQFile outSrcFile(m_tempDirectoryStr + "/" + m_outputFileName + inputFileExtension);
//--- if (outSrcFile.open(TQFile::ReadOnly | TQFile::Text))
//--- {
//--- TQTextStream outSrcStrm(&outSrcFile);
@@ -591,8 +595,8 @@ void IndentHandler::contextMenuEvent(TQContextMenuEvent *event)
//--- }
//---
//--- // Delete the temporary input and output files.
-//--- TQFile::remove(m_tempDirectoryStr + "/" + _outputFileName + inputFileExtension);
-//--- TQFile::remove(m_tempDirectoryStr + "/" + _inputFileName + inputFileExtension);
+//--- TQFile::remove(m_tempDirectoryStr + "/" + m_outputFileName + inputFileExtension);
+//--- TQFile::remove(m_tempDirectoryStr + "/" + m_inputFileName + inputFileExtension);
//---
//--- return formattedSourceCode;
//--- }
@@ -605,54 +609,54 @@ TQString IndentHandler::getParameterString()
TQString parameterString = "";
//--- // generate parameter string for all boolean values
-//--- foreach(ParamBoolean pBoolean, _paramBooleans)
+//--- foreach(ParamBoolean pBoolean, m_paramBooleans)
//--- {
//--- if (pBoolean.checkBox->isChecked())
//--- {
//--- if (!pBoolean.trueString.isEmpty())
//--- {
-//--- parameterString += pBoolean.trueString + _cfgFileParameterEnding;
+//--- parameterString += pBoolean.trueString + m_cfgFileParameterEnding;
//--- }
//--- }
//--- else
//--- {
//--- if (!pBoolean.falseString.isEmpty())
//--- {
-//--- parameterString += pBoolean.falseString + _cfgFileParameterEnding;
+//--- parameterString += pBoolean.falseString + m_cfgFileParameterEnding;
//--- }
//--- }
//--- }
//---
//--- // generate parameter string for all numeric values
-//--- foreach(ParamNumeric pNumeric, _paramNumerics)
+//--- foreach(ParamNumeric pNumeric, m_paramNumerics)
//--- {
//--- if (pNumeric.valueEnabledChkBox->isChecked())
//--- {
//--- parameterString += pNumeric.paramCallName + TQString::number(pNumeric.spinBox->value()) +
-//--- _cfgFileParameterEnding;
+//--- m_cfgFileParameterEnding;
//--- }
//--- }
//---
//--- // generate parameter string for all string values
-//--- foreach(ParamString pString, _paramStrings)
+//--- foreach(ParamString pString, m_paramStrings)
//--- {
//--- if (!pString.lineEdit->text().isEmpty() && pString.valueEnabledChkBox->isChecked())
//--- {
//--- // Create parameter definition for each value devided by a | sign.
//--- foreach(TQString paramValue, pString.lineEdit->text().split("|"))
//--- {
-//--- parameterString += pString.paramCallName + paramValue + _cfgFileParameterEnding;
+//--- parameterString += pString.paramCallName + paramValue + m_cfgFileParameterEnding;
//--- }
//--- }
//--- }
//---
//--- // generate parameter string for all multiple choice values
-//--- foreach(ParamMultiple pMultiple, _paramMultiples)
+//--- foreach(ParamMultiple pMultiple, m_paramMultiples)
//--- {
//--- if (pMultiple.valueEnabledChkBox->isChecked())
//--- {
//--- parameterString += pMultiple.choicesStrings.at(pMultiple.comboBox->currentIndex()) +
-//--- _cfgFileParameterEnding;
+//--- m_cfgFileParameterEnding;
//--- }
//--- }
@@ -680,26 +684,21 @@ bool IndentHandler::loadConfigFile(const TQString &filePathName)
TQFile cfgFile(filePathName);
TQString cfgFileData = TQString::null;
- // If the config file to be loaded does not exist, leave all values as they are and return false.
if (!cfgFile.exists())
{
+ // If the config file to be loaded does not exist, leave all values as they are and return false
return false;
}
- // else if the to be read config file exists, retrieve its whole content.
else
{
- // Open the config file and read all data
+ // else if the config file exists, retrieve its whole content
cfgFile.open(IO_ReadOnly | IO_Translate);
cfgFileData = TQString(cfgFile.readAll());
cfgFile.close();
}
- int index;
- int crPos;
- int paramValue = 0;
- TQString paramValueStr = "";
//--- // Search for name of each boolean parameter and set its value if found.
-//--- foreach(ParamBoolean pBoolean, _paramBooleans)
+//--- for (const ParamBoolean &pBoolean : m_paramBooleans)
//--- {
//--- // boolean value that will be assigned to the checkbox
//--- bool paramValue = false;
@@ -761,7 +760,7 @@ bool IndentHandler::loadConfigFile(const TQString &filePathName)
//--- }
//---
//--- // Search for name of each numeric parameter and set the value found behind it.
-//--- foreach(ParamNumeric pNumeric, _paramNumerics)
+//--- foreach(ParamNumeric pNumeric, m_paramNumerics)
//--- {
//--- index = cfgFileData.indexOf(pNumeric.paramCallName, 0, TQt::CaseInsensitive);
//--- // parameter was found in config file
@@ -772,7 +771,7 @@ bool IndentHandler::loadConfigFile(const TQString &filePathName)
//---
//--- // Find the end of the parameter by searching for set config file parameter ending. Most of
//--- // time this is a carriage return.
-//--- crPos = cfgFileData.indexOf(_cfgFileParameterEnding, index + 1);
+//--- int crPos = cfgFileData.indexOf(m_cfgFileParameterEnding, index + 1);
//---
//--- // get the number and convert it to int
//--- TQString test = cfgFileData.mid(index, crPos - index);
@@ -797,7 +796,7 @@ bool IndentHandler::loadConfigFile(const TQString &filePathName)
//--- }
//---
//--- // Search for name of each string parameter and set it.
-//--- foreach(ParamString pString, _paramStrings)
+//--- foreach(ParamString pString, m_paramStrings)
//--- {
//--- paramValueStr = "";
//--- // The number of the found values for this parameter name.
@@ -815,7 +814,7 @@ bool IndentHandler::loadConfigFile(const TQString &filePathName)
//---
//--- // Find the end of the parameter by searching for set config file parameter ending. Most of
//--- // time this is a carriage return.
-//--- crPos = cfgFileData.indexOf(_cfgFileParameterEnding, index + 1);
+//--- crPos = cfgFileData.indexOf(m_cfgFileParameterEnding, index + 1);
//---
//--- // Get the string and remember it.
//--- if (numberOfValues < 2)
@@ -846,7 +845,7 @@ bool IndentHandler::loadConfigFile(const TQString &filePathName)
//--- }
//---
//--- // search for name of each multiple choice parameter and set it
-//--- foreach(ParamMultiple pMultiple, _paramMultiples)
+//--- foreach(ParamMultiple pMultiple, m_paramMultiples)
//--- {
//--- int i = 0;
//--- index = -1;
@@ -881,41 +880,41 @@ bool IndentHandler::loadConfigFile(const TQString &filePathName)
*/
void IndentHandler::resetToDefaultValues()
{
-//--- // Search for name of each boolean parameter and set its value if found.
-//--- foreach(ParamBoolean pBoolean, _paramBooleans)
-//--- {
-//--- // Boolean value that will be assigned to the checkbox.
-//--- bool defaultValue = m_indenterSettings->value(pBoolean.paramName + "/ValueDefault").toBool();
-//--- pBoolean.checkBox->setChecked(defaultValue);
-//--- }
-//---
-//--- // Search for name of each numeric parameter and set the value found behind it.
-//--- foreach(ParamNumeric pNumeric, _paramNumerics)
-//--- {
-//--- int defaultValue = m_indenterSettings->value(pNumeric.paramName + "/ValueDefault").toInt();
-//--- pNumeric.spinBox->setValue(defaultValue);
-//--- pNumeric.valueEnabledChkBox->setChecked(m_indenterSettings->value(
-//--- pNumeric.paramName + "/Enabled").toBool());
-//--- }
-//---
-//--- // Search for name of each string parameter and set it.
-//--- foreach(ParamString pString, _paramStrings)
-//--- {
-//--- TQString defaultValue =
-//--- m_indenterSettings->value(pString.paramName + "/ValueDefault").toString();
-//--- pString.lineEdit->setText(defaultValue);
-//--- pString.valueEnabledChkBox->setChecked(m_indenterSettings->value(
-//--- pString.paramName + "/Enabled").toBool());
-//--- }
-//---
-//--- // Search for name of each multiple choice parameter and set it.
-//--- foreach(ParamMultiple pMultiple, _paramMultiples)
-//--- {
-//--- int defaultValue = m_indenterSettings->value(pMultiple.paramName + "/ValueDefault").toInt();
-//--- pMultiple.comboBox->setCurrentIndex(defaultValue);
-//--- pMultiple.valueEnabledChkBox->setChecked(m_indenterSettings->value(pMultiple.paramName +
-//--- "/Enabled").toBool());
-//--- }
+ // Search for name of each boolean parameter and set its value if found.
+ for (ParamBoolean &pBoolean : m_paramBooleans)
+ {
+ // Boolean value that will be assigned to the checkbox.
+ bool defaultValue = m_indenterSettings->value(pBoolean.paramName + "/ValueDefault").toBool();
+ pBoolean.checkBox->setChecked(defaultValue);
+ }
+
+ // Search for name of each numeric parameter and set the value found behind it.
+ for (ParamNumeric &pNumeric : m_paramNumerics)
+ {
+ int defaultValue = m_indenterSettings->value(pNumeric.paramName + "/ValueDefault").toInt();
+ pNumeric.spinBox->setValue(defaultValue);
+ pNumeric.valueEnabledChkBox->setChecked(m_indenterSettings->value(
+ pNumeric.paramName + "/Enabled").toBool());
+ }
+
+ // Search for name of each string parameter and set it.
+ for (ParamString &pString : m_paramStrings)
+ {
+ TQString defaultValue =
+ m_indenterSettings->value(pString.paramName + "/ValueDefault").toString();
+ pString.lineEdit->setText(defaultValue);
+ pString.valueEnabledChkBox->setChecked(m_indenterSettings->value(
+ pString.paramName + "/Enabled").toBool());
+ }
+
+ // Search for name of each multiple choice parameter and set it.
+ for (ParamMultiple &pMultiple : m_paramMultiples)
+ {
+ int defaultValue = m_indenterSettings->value(pMultiple.paramName + "/ValueDefault").toInt();
+ pMultiple.comboBox->setCurrentItem(defaultValue);
+ pMultiple.valueEnabledChkBox->setChecked(m_indenterSettings->value(pMultiple.paramName +
+ "/Enabled").toBool());
+ }
}
/*
@@ -930,329 +929,326 @@ void IndentHandler::readIndentIniFile(const TQString &iniFilePath)
return;
}
-//--- // open the ini-file that contains all available indenter settings with their additional infos
-//--- m_indenterSettings = new UiGuiIniFileParser(iniFilePath);
-//---
-//--- TQStringList categories;
-//--- //TQString indenterGroupString = "";
-//--- TQString paramToolTip = "";
-//---
-//--- //
-//--- // parse ini file indenter header
-//--- //
-//---
-//--- _indenterName = m_indenterSettings->value("header/indenterName").toString();
-//--- m_indenterFileName = m_indenterSettings->value("header/indenterFileName").toString();
-//--- m_globalConfigFilename = m_indenterSettings->value("header/configFilename").toString();
-//--- _useCfgFileParameter = m_indenterSettings->value("header/useCfgFileParameter").toString();
-//--- _cfgFileParameterEnding = m_indenterSettings->value("header/cfgFileParameterEnding").toString();
-//--- if (_cfgFileParameterEnding == "cr")
-//--- {
-//--- _cfgFileParameterEnding = "\n";
-//--- }
-//--- _indenterShowHelpParameter = m_indenterSettings->value("header/showHelpParameter").toString();
-//---
-//--- if (m_indenterFileName.isEmpty())
-//--- {
-//--- m_errorMessageDialog->showMessage(tr("Indenter ini file header error"), tr(
-//--- "The loaded indenter ini file \"%1\"has a faulty header. At least the indenters file name is not set.").arg(
-//--- iniFilePath));
-//--- }
-//---
-//--- // Read the parameter order. Possible values are (p=parameter[file] i=inputfile o=outputfile)
-//--- // pio, ipo, iop
-//--- _parameterOrder = m_indenterSettings->value("header/parameterOrder", "pio").toString();
-//--- _inputFileParameter = m_indenterSettings->value("header/inputFileParameter").toString();
-//--- _inputFileName = m_indenterSettings->value("header/inputFileName").toString();
-//--- _outputFileParameter = m_indenterSettings->value("header/outputFileParameter").toString();
-//--- _outputFileName = m_indenterSettings->value("header/outputFileName").toString();
-//--- _fileTypes = m_indenterSettings->value("header/fileTypes").toString();
-//--- _fileTypes.replace('|', " ");
-//---
-//--- // read the categories names which are separated by "|"
-//--- TQString categoriesStr = m_indenterSettings->value("header/categories").toString();
-//--- categories = categoriesStr.split("|");
-//--- // Assure that the category list is never empty. At least contain a "general" section.
-//--- if (categories.isEmpty())
-//--- {
-//--- categories.append("General");
-//--- }
-//---
-//--- IndenterParameterCategoryPage categoryPage;
-//---
-//--- // create a page for each category and store its references in a toolboxpage-array
-//--- foreach(TQString category, categories)
-//--- {
-//--- categoryPage.widget = new TQWidget();
-//--- categoryPage.widget->setObjectName(category);
-//--- categoryPage.widget->setSizePolicy(TQSizePolicy::MinimumExpanding,
-//--- TQSizePolicy::MinimumExpanding);
-//--- categoryPage.vboxLayout = new TQVBoxLayout(categoryPage.widget);
-//--- categoryPage.vboxLayout->setSpacing(6);
-//--- categoryPage.vboxLayout->setMargin(9);
-//--- categoryPage.vboxLayout->setObjectName(category);
-//--- _indenterParameterCategoryPages.append(categoryPage);
-//--- m_indenterParameterCategoriesToolBox->addItem(categoryPage.widget, category);
-//--- }
-//---
-//--- //
-//--- // parse ini file indenter parameters
-//--- //
-//---
-//--- // read all possible parameters written in brackets []
-//--- _indenterParameters = m_indenterSettings->childGroups();
-//---
-//--- // read each parameter to create the corresponding input field
-//--- foreach(TQString indenterParameter, _indenterParameters)
-//--- {
-//--- // if it is not the indent header definition read the parameter and add it to
-//--- // the corresponding category toolbox page
-//--- if (indenterParameter != "header")
-//--- {
-//--- // read to which category the parameter belongs
-//--- int category = m_indenterSettings->value(indenterParameter + "/Category").toInt();
-//--- // Assure that the category number is never greater than the available categories.
-//--- if (category > _indenterParameterCategoryPages.size() - 1)
-//--- {
-//--- category = _indenterParameterCategoryPages.size() - 1;
-//--- }
-//--- // read which type of input field the parameter needs
-//--- TQString editType = m_indenterSettings->value(indenterParameter + "/EditorType").toString();
-//---
-//--- // edit type is numeric so create a spinbox with label
-//--- if (editType == "numeric")
-//--- {
-//--- // read the parameter name as it is used at the command line or in its config file
-//--- TQString parameterCallName =
-//--- m_indenterSettings->value(indenterParameter + "/CallName").toString();
-//---
-//--- // create checkbox which enables or disables the parameter
-//--- TQCheckBox *chkBox = new TQCheckBox(_indenterParameterCategoryPages.at(category).widget);
-//--- chkBox->setChecked(m_indenterSettings->value(indenterParameter + "/Enabled").toBool());
-//--- chkBox->setToolTip(
-//--- "Enables/disables the parameter. If disabled the indenters default value will be used.");
-//--- chkBox->setSizePolicy(TQSizePolicy::Fixed, TQSizePolicy::Fixed);
-//--- int left, top, right, bottom;
-//--- chkBox->getContentsMargins(&left, &top, &right, &bottom);
-//--- chkBox->setContentsMargins(left, top, 0, bottom);
-//---
-//--- // create the spinbox
-//--- TQSpinBox *spinBox = new TQSpinBox(_indenterParameterCategoryPages.at(category).widget);
-//--- paramToolTip = m_indenterSettings->value(indenterParameter + "/Description").toString();
-//--- spinBox->setToolTip(paramToolTip);
-//--- spinBox->setMaximumWidth(50);
-//--- spinBox->setMinimumWidth(50);
-//--- if (m_mainWindow != nullptr)
-//--- {
-//--- spinBox->installEventFilter(m_mainWindow);
-//--- }
-//--- if (m_indenterSettings->value(indenterParameter + "/MinVal").toString() != "")
-//--- {
-//--- spinBox->setMinimum(m_indenterSettings->value(indenterParameter + "/MinVal").toInt());
-//--- }
-//--- else
-//--- {
-//--- spinBox->setMinimum(0);
-//--- }
-//--- if (m_indenterSettings->value(indenterParameter + "/MaxVal").toString() != "")
-//--- {
-//--- spinBox->setMaximum(m_indenterSettings->value(indenterParameter + "/MaxVal").toInt());
-//--- }
-//--- else
-//--- {
-//--- spinBox->setMaximum(2000);
-//--- }
-//---
-//--- // create the label
-//--- TQLabel *label = new TQLabel(_indenterParameterCategoryPages.at(category).widget);
-//--- label->setText(indenterParameter);
-//--- label->setBuddy(spinBox);
-//--- label->setToolTip(paramToolTip);
-//--- if (m_mainWindow != nullptr)
-//--- {
-//--- label->installEventFilter(m_mainWindow);
-//--- }
-//---
-//--- // put all into a layout and add it to the toolbox page
-//--- TQHBoxLayout *hboxLayout = new TQHBoxLayout();
-//--- hboxLayout->addWidget(chkBox);
-//--- hboxLayout->addWidget(spinBox);
-//--- hboxLayout->addWidget(label);
-//--- _indenterParameterCategoryPages.at(category).vboxLayout->addLayout(hboxLayout);
-//---
-//--- // remember parameter name and reference to its spinbox
-//--- ParamNumeric paramNumeric;
-//--- paramNumeric.paramName = indenterParameter;
-//--- paramNumeric.paramCallName = parameterCallName;
-//--- paramNumeric.spinBox = spinBox;
-//--- paramNumeric.label = label;
-//--- paramNumeric.valueEnabledChkBox = chkBox;
-//--- paramNumeric.spinBox->setValue(m_indenterSettings->value(paramNumeric.paramName +
-//--- "/ValueDefault").toInt());
-//--- _paramNumerics.append(paramNumeric);
-//---
-//--- TQObject::connect(spinBox, SIGNAL(valueChanged(int)), this,
-//--- SLOT(handleChangedIndenterSettings()));
-//--- TQObject::connect(chkBox, SIGNAL(clicked()), this, SLOT(handleChangedIndenterSettings()));
-//--- }
-//--- // edit type is boolean so create a checkbox
-//--- else if (editType == "boolean")
-//--- {
-//--- // create the checkbox, make its settings and add it to the toolbox page
-//--- TQCheckBox *chkBox = new TQCheckBox(_indenterParameterCategoryPages.at(category).widget);
-//--- chkBox->setText(indenterParameter);
-//--- paramToolTip = m_indenterSettings->value(indenterParameter + "/Description").toString();
-//--- chkBox->setToolTip(paramToolTip);
-//--- if (m_mainWindow != nullptr)
-//--- {
-//--- chkBox->installEventFilter(m_mainWindow);
-//--- }
-//--- _indenterParameterCategoryPages.at(category).vboxLayout->addWidget(chkBox);
-//---
-//--- // remember parameter name and reference to its checkbox
-//--- ParamBoolean paramBoolean;
-//--- paramBoolean.paramName = indenterParameter;
-//--- paramBoolean.checkBox = chkBox;
-//--- TQStringList trueFalseStrings =
-//--- m_indenterSettings->value(indenterParameter + "/TrueFalse").toString().split("|");
-//--- paramBoolean.trueString = trueFalseStrings.at(0);
-//--- paramBoolean.falseString = trueFalseStrings.at(1);
-//--- paramBoolean.checkBox->setChecked(m_indenterSettings->value(paramBoolean.paramName +
-//--- "/ValueDefault").toBool());
-//--- _paramBooleans.append(paramBoolean);
-//---
-//--- TQObject::connect(chkBox, SIGNAL(clicked()), this, SLOT(handleChangedIndenterSettings()));
-//--- }
-//--- // edit type is numeric so create a line edit with label
-//--- else if (editType == "string")
-//--- {
-//--- // read the parameter name as it is used at the command line or in its config file
-//--- TQString parameterCallName =
-//--- m_indenterSettings->value(indenterParameter + "/CallName").toString();
-//---
-//--- // create check box which enables or disables the parameter
-//--- TQCheckBox *chkBox = new TQCheckBox(_indenterParameterCategoryPages.at(category).widget);
-//--- chkBox->setChecked(m_indenterSettings->value(indenterParameter + "/Enabled").toBool());
-//--- chkBox->setToolTip(
-//--- "Enables/disables the parameter. If disabled the indenters default value will be used.");
-//--- chkBox->setSizePolicy(TQSizePolicy::Fixed, TQSizePolicy::Fixed);
-//--- int left, top, right, bottom;
-//--- chkBox->getContentsMargins(&left, &top, &right, &bottom);
-//--- chkBox->setContentsMargins(left, top, 0, bottom);
-//---
-//--- // create the line edit
-//--- TQLineEdit *lineEdit = new TQLineEdit(_indenterParameterCategoryPages.at(category).widget);
-//--- paramToolTip = m_indenterSettings->value(indenterParameter + "/Description").toString();
-//--- lineEdit->setToolTip(paramToolTip);
-//--- lineEdit->setMaximumWidth(50);
-//--- lineEdit->setMinimumWidth(50);
-//--- if (m_mainWindow != nullptr)
-//--- {
-//--- lineEdit->installEventFilter(m_mainWindow);
-//--- }
-//---
-//--- // create the label
-//--- TQLabel *label = new TQLabel(_indenterParameterCategoryPages.at(category).widget);
-//--- label->setText(indenterParameter);
-//--- label->setBuddy(lineEdit);
-//--- label->setSizePolicy(TQSizePolicy::MinimumExpanding, TQSizePolicy::Preferred);
-//--- label->setToolTip(paramToolTip);
-//--- if (m_mainWindow != nullptr)
-//--- {
-//--- label->installEventFilter(m_mainWindow);
-//--- }
-//---
-//--- // put all into a layout and add it to the toolbox page
-//--- TQHBoxLayout *hboxLayout = new TQHBoxLayout();
-//--- hboxLayout->addWidget(chkBox);
-//--- hboxLayout->addWidget(lineEdit);
-//--- hboxLayout->addWidget(label);
-//--- _indenterParameterCategoryPages.at(category).vboxLayout->addLayout(hboxLayout);
-//---
-//--- // remember parameter name and reference to its line edit
-//--- ParamString paramString;
-//--- paramString.paramName = indenterParameter;
-//--- paramString.paramCallName = parameterCallName;
-//--- paramString.lineEdit = lineEdit;
-//--- paramString.label = label;
-//--- paramString.valueEnabledChkBox = chkBox;
-//--- paramString.lineEdit->setText(m_indenterSettings->value(paramString.paramName +
-//--- "/ValueDefault").toString());
-//--- _paramStrings.append(paramString);
-//---
-//--- TQObject::connect(lineEdit, SIGNAL(editingFinished()), this,
-//--- SLOT(handleChangedIndenterSettings()));
-//--- TQObject::connect(chkBox, SIGNAL(clicked()), this, SLOT(handleChangedIndenterSettings()));
-//--- }
-//--- // edit type is multiple so create a combobox with label
-//--- else if (editType == "multiple")
-//--- {
-//--- // read the parameter name as it is used at the command line or in its config file
-//--- TQString parameterCallName =
-//--- m_indenterSettings->value(indenterParameter + "/CallName").toString();
-//---
-//--- // create checkbox which enables or disables the parameter
-//--- TQCheckBox *chkBox = new TQCheckBox(_indenterParameterCategoryPages.at(category).widget);
-//--- chkBox->setChecked(m_indenterSettings->value(indenterParameter + "/Enabled").toBool());
-//--- chkBox->setToolTip(
-//--- "Enables/disables the parameter. If disabled the indenters default value will be used.");
-//--- chkBox->setSizePolicy(TQSizePolicy::Fixed, TQSizePolicy::Fixed);
-//--- int left, top, right, bottom;
-//--- chkBox->getContentsMargins(&left, &top, &right, &bottom);
-//--- chkBox->setContentsMargins(left, top, 0, bottom);
-//---
-//--- // create the combo box
-//--- TQComboBox *comboBox = new TQComboBox(_indenterParameterCategoryPages.at(
-//--- category).widget);
-//--- TQStringList choicesStrings =
-//--- m_indenterSettings->value(indenterParameter + "/Choices").toString().split("|");
-//--- TQStringList choicesStringsReadable = m_indenterSettings->value(
-//--- indenterParameter + "/ChoicesReadable").toString().split("|", TQString::SkipEmptyParts);
-//--- if (choicesStringsReadable.isEmpty())
-//--- {
-//--- comboBox->addItems(choicesStrings);
-//--- }
-//--- else
-//--- {
-//--- comboBox->addItems(choicesStringsReadable);
-//--- }
-//--- paramToolTip = m_indenterSettings->value(indenterParameter + "/Description").toString();
-//--- comboBox->setToolTip(paramToolTip);
-//--- if (m_mainWindow != nullptr)
-//--- {
-//--- comboBox->installEventFilter(m_mainWindow);
-//--- }
-//---
-//--- // put all into a layout and add it to the toolbox page
-//--- TQHBoxLayout *hboxLayout = new TQHBoxLayout();
-//--- hboxLayout->addWidget(chkBox);
-//--- hboxLayout->addWidget(comboBox);
-//--- _indenterParameterCategoryPages.at(category).vboxLayout->addLayout(hboxLayout);
-//---
-//--- // remember parameter name and reference to its lineedit
-//--- ParamMultiple paramMultiple;
-//--- paramMultiple.paramName = indenterParameter;
-//--- paramMultiple.paramCallName = parameterCallName;
-//--- paramMultiple.comboBox = comboBox;
-//--- paramMultiple.choicesStrings = choicesStrings;
-//--- paramMultiple.choicesStringsReadable = choicesStringsReadable;
-//--- paramMultiple.valueEnabledChkBox = chkBox;
-//--- paramMultiple.comboBox->setCurrentIndex(m_indenterSettings->value(paramMultiple.paramName +
-//--- "/ValueDefault").toInt());
-//--- _paramMultiples.append(paramMultiple);
-//---
-//--- TQObject::connect(comboBox, SIGNAL(activated(int)), this,
-//--- SLOT(handleChangedIndenterSettings()));
-//--- TQObject::connect(chkBox, SIGNAL(clicked()), this, SLOT(handleChangedIndenterSettings()));
-//--- }
-//--- }
-//--- }
-//---
-//--- // put a spacer at each page end
-//--- foreach(IndenterParameterCategoryPage categoryPage, _indenterParameterCategoryPages)
-//--- {
-//--- categoryPage.vboxLayout->addStretch();
-//--- }
+ // open the ini-file that contains all available indenter settings with their additional infos
+ m_indenterSettings = new UiGuiIniFileParser(iniFilePath);
+
+ //
+ // parse ini file indenter header
+ //
+
+ m_indenterName = m_indenterSettings->value("header/indenterName").toString();
+ m_indenterFileName = m_indenterSettings->value("header/indenterFileName").toString();
+ m_globalConfigFilename = m_indenterSettings->value("header/configFilename").toString();
+ m_useCfgFileParameter = m_indenterSettings->value("header/useCfgFileParameter").toString();
+ m_cfgFileParameterEnding = m_indenterSettings->value("header/cfgFileParameterEnding").toString();
+ if (m_cfgFileParameterEnding == "cr")
+ {
+ m_cfgFileParameterEnding = "\n";
+ }
+ m_indenterShowHelpParameter = m_indenterSettings->value("header/showHelpParameter").toString();
+
+ if (m_indenterFileName.isEmpty())
+ {
+ m_errorMessageDialog->showMessage(tr("Indenter ini file header error"),
+ tr("The loaded indenter ini file \"%1\"has a faulty header. At least the indenter file name is not set.").
+ arg(iniFilePath));
+ }
+
+ // Read the parameter order. Possible values are (p=parameter[file] i=inputfile o=outputfile)
+ // pio, ipo, iop
+ m_parameterOrder = m_indenterSettings->value("header/parameterOrder", "pio").toString();
+ m_inputFileParameter = m_indenterSettings->value("header/inputFileParameter").toString();
+ m_inputFileName = m_indenterSettings->value("header/inputFileName").toString();
+ m_outputFileParameter = m_indenterSettings->value("header/outputFileParameter").toString();
+ m_outputFileName = m_indenterSettings->value("header/outputFileName").toString();
+ m_fileTypes = m_indenterSettings->value("header/fileTypes").toString();
+ m_fileTypes.replace('|', " ");
+
+ // read the categories names which are separated by "|"
+ TQString categoriesStr = m_indenterSettings->value("header/categories").toString();
+ TQStringList categories = TQStringList::split('|', categoriesStr);
+ // Assure that the category list is never empty. At least contain a "general" section.
+ if (categories.isEmpty())
+ {
+ categories.append("General");
+ }
+
+ IndenterParameterCategoryPage categoryPage;
+
+ // For some unknown reasons, TQToolbox does not display the content of the first
+ // widget once the indenter is changed. To work around this problem we insert a
+ // dummy widget before the real categories and we will get rid of it at the end
+ TQWidget *dummyWidget = new TQWidget();
+ m_indenterParameterCategoriesToolBox->addItem(dummyWidget, "Dummy");
+
+ // create a page for each category and store its references in a toolboxpage-array
+ for (const TQString &category : categories)
+ {
+ tqWarning("Creating category "+category);
+ categoryPage.widget = new TQWidget();
+ categoryPage.widget->setName(category.local8Bit());
+ categoryPage.widget->setSizePolicy(TQSizePolicy::MinimumExpanding,
+ TQSizePolicy::MinimumExpanding);
+ categoryPage.vboxLayout = new TQVBoxLayout(categoryPage.widget);
+ categoryPage.vboxLayout->setSpacing(6);
+ categoryPage.vboxLayout->setMargin(9);
+ categoryPage.vboxLayout->setName(category.local8Bit());
+ m_indenterParameterCategoryPages.append(categoryPage);
+ m_indenterParameterCategoriesToolBox->addItem(categoryPage.widget, category);
+ }
+
+ //
+ // parse ini file indenter parameters
+ //
+
+ // read all possible parameters written in brackets []
+ m_indenterParameters = m_indenterSettings->childGroups();
+
+ // read each parameter to create the corresponding input field
+ for (const TQString &indenterParameter : m_indenterParameters)
+ {
+ // if it is not the indent header definition read the parameter and add it to
+ // the corresponding category toolbox page
+ if (indenterParameter != "header")
+ {
+ // read to which category the parameter belongs
+ int category = m_indenterSettings->value(indenterParameter + "/Category").toInt();
+ // Assure that the category number is never greater than the available categories.
+ if (category > m_indenterParameterCategoryPages.size() - 1)
+ {
+ category = m_indenterParameterCategoryPages.size() - 1;
+ }
+ // read which type of input field the parameter needs
+ TQString editType = m_indenterSettings->value(indenterParameter + "/EditorType").toString();
+
+ // edit type is numeric so create a spinbox with label
+ if (editType == "numeric")
+ {
+ // read the parameter name as it is used at the command line or in its config file
+ TQString parameterCallName =
+ m_indenterSettings->value(indenterParameter + "/CallName").toString();
+
+ // create checkbox which enables or disables the parameter
+ TQCheckBox *chkBox = new TQCheckBox(m_indenterParameterCategoryPages.at(category).widget);
+ chkBox->setChecked(m_indenterSettings->value(indenterParameter + "/Enabled").toBool());
+ TQToolTip::add(chkBox,
+ "Enables/disables the parameter. If disabled the indenters default value will be used.");
+ chkBox->setSizePolicy(TQSizePolicy::Fixed, TQSizePolicy::Fixed);
+
+ // create the spinbox
+ TQSpinBox *spinBox = new TQSpinBox(m_indenterParameterCategoryPages.at(category).widget);
+ TQString paramToolTip = m_indenterSettings->value(indenterParameter + "/Description").toString();
+ TQToolTip::add(spinBox, paramToolTip);
+ spinBox->setMaximumWidth(50);
+ spinBox->setMinimumWidth(50);
+ if (m_mainWindow != nullptr)
+ {
+ spinBox->installEventFilter(m_mainWindow);
+ }
+ if (m_indenterSettings->value(indenterParameter + "/MinVal").toString() != "")
+ {
+ spinBox->setMinValue(m_indenterSettings->value(indenterParameter + "/MinVal").toInt());
+ }
+ else
+ {
+ spinBox->setMinValue(0);
+ }
+ if (m_indenterSettings->value(indenterParameter + "/MaxVal").toString() != "")
+ {
+ spinBox->setMaxValue(m_indenterSettings->value(indenterParameter + "/MaxVal").toInt());
+ }
+ else
+ {
+ spinBox->setMaxValue(2000);
+ }
+
+ // create the label
+ TQLabel *label = new TQLabel(m_indenterParameterCategoryPages.at(category).widget);
+ label->setText(indenterParameter);
+ label->setBuddy(spinBox);
+ TQToolTip::add(label, paramToolTip);
+ if (m_mainWindow != nullptr)
+ {
+ label->installEventFilter(m_mainWindow);
+ }
+
+ // put all into a layout and add it to the toolbox page
+ TQHBoxLayout *hboxLayout = new TQHBoxLayout();
+ hboxLayout->addWidget(chkBox);
+ hboxLayout->addWidget(spinBox);
+ hboxLayout->addWidget(label);
+ m_indenterParameterCategoryPages.at(category).vboxLayout->addLayout(hboxLayout);
+
+ // remember parameter name and reference to its spinbox
+ ParamNumeric paramNumeric;
+ paramNumeric.paramName = indenterParameter;
+ paramNumeric.paramCallName = parameterCallName;
+ paramNumeric.spinBox = spinBox;
+ paramNumeric.label = label;
+ paramNumeric.valueEnabledChkBox = chkBox;
+ paramNumeric.spinBox->setValue(m_indenterSettings->value(paramNumeric.paramName +
+ "/ValueDefault").toInt());
+ m_paramNumerics.append(paramNumeric);
+
+ TQObject::connect(spinBox, SIGNAL(valueChanged(int)), this,
+ SLOT(handleChangedIndenterSettings()));
+ TQObject::connect(chkBox, SIGNAL(clicked()), this, SLOT(handleChangedIndenterSettings()));
+ }
+ // edit type is boolean so create a checkbox
+ else if (editType == "boolean")
+ {
+ // create the checkbox, make its settings and add it to the toolbox page
+ TQCheckBox *chkBox = new TQCheckBox(m_indenterParameterCategoryPages.at(category).widget);
+ chkBox->setText(indenterParameter);
+ TQString paramToolTip = m_indenterSettings->value(indenterParameter + "/Description").toString();
+ TQToolTip::add(chkBox, paramToolTip);
+ if (m_mainWindow != nullptr)
+ {
+ chkBox->installEventFilter(m_mainWindow);
+ }
+ m_indenterParameterCategoryPages.at(category).vboxLayout->addWidget(chkBox);
+
+ // remember parameter name and reference to its checkbox
+ ParamBoolean paramBoolean;
+ paramBoolean.paramName = indenterParameter;
+ paramBoolean.checkBox = chkBox;
+ TQStringList trueFalseStrings = TQStringList::split("|",
+ m_indenterSettings->value(indenterParameter + "/TrueFalse").toString());
+ paramBoolean.trueString = trueFalseStrings[0];
+ paramBoolean.falseString = trueFalseStrings[1];
+ paramBoolean.checkBox->setChecked(m_indenterSettings->value(paramBoolean.paramName +
+ "/ValueDefault").toBool());
+ m_paramBooleans.append(paramBoolean);
+
+ TQObject::connect(chkBox, SIGNAL(clicked()), this, SLOT(handleChangedIndenterSettings()));
+ }
+ // edit type is numeric so create a line edit with label
+ else if (editType == "string")
+ {
+ // read the parameter name as it is used at the command line or in its config file
+ TQString parameterCallName =
+ m_indenterSettings->value(indenterParameter + "/CallName").toString();
+
+ // create check box which enables or disables the parameter
+ TQCheckBox *chkBox = new TQCheckBox(m_indenterParameterCategoryPages.at(category).widget);
+ chkBox->setChecked(m_indenterSettings->value(indenterParameter + "/Enabled").toBool());
+ TQToolTip::add(chkBox,
+ "Enables/disables the parameter. If disabled the indenters default value will be used.");
+ chkBox->setSizePolicy(TQSizePolicy::Fixed, TQSizePolicy::Fixed);
+
+ // create the line edit
+ TQLineEdit *lineEdit = new TQLineEdit(m_indenterParameterCategoryPages.at(category).widget);
+ TQString paramToolTip = m_indenterSettings->value(indenterParameter + "/Description").toString();
+ TQToolTip::add(lineEdit, paramToolTip);
+ lineEdit->setMaximumWidth(50);
+ lineEdit->setMinimumWidth(50);
+ if (m_mainWindow != nullptr)
+ {
+ lineEdit->installEventFilter(m_mainWindow);
+ }
+
+ // create the label
+ TQLabel *label = new TQLabel(m_indenterParameterCategoryPages.at(category).widget);
+ label->setText(indenterParameter);
+ label->setBuddy(lineEdit);
+ label->setSizePolicy(TQSizePolicy::MinimumExpanding, TQSizePolicy::Preferred);
+ TQToolTip::add(label, paramToolTip);
+ if (m_mainWindow != nullptr)
+ {
+ label->installEventFilter(m_mainWindow);
+ }
+
+ // put all into a layout and add it to the toolbox page
+ TQHBoxLayout *hboxLayout = new TQHBoxLayout();
+ hboxLayout->addWidget(chkBox);
+ hboxLayout->addWidget(lineEdit);
+ hboxLayout->addWidget(label);
+ m_indenterParameterCategoryPages.at(category).vboxLayout->addLayout(hboxLayout);
+
+ // remember parameter name and reference to its line edit
+ ParamString paramString;
+ paramString.paramName = indenterParameter;
+ paramString.paramCallName = parameterCallName;
+ paramString.lineEdit = lineEdit;
+ paramString.label = label;
+ paramString.valueEnabledChkBox = chkBox;
+ paramString.lineEdit->setText(m_indenterSettings->value(paramString.paramName +
+ "/ValueDefault").toString());
+ m_paramStrings.append(paramString);
+
+ TQObject::connect(lineEdit, SIGNAL(returnPressed()), this,
+ SLOT(handleChangedIndenterSettings()));
+ TQObject::connect(chkBox, SIGNAL(clicked()), this, SLOT(handleChangedIndenterSettings()));
+ }
+ // edit type is multiple so create a combobox with label
+ else if (editType == "multiple")
+ {
+ // read the parameter name as it is used at the command line or in its config file
+ TQString parameterCallName =
+ m_indenterSettings->value(indenterParameter + "/CallName").toString();
+
+ // create checkbox which enables or disables the parameter
+ TQCheckBox *chkBox = new TQCheckBox(m_indenterParameterCategoryPages.at(category).widget);
+ chkBox->setChecked(m_indenterSettings->value(indenterParameter + "/Enabled").toBool());
+ TQToolTip::add(chkBox,
+ "Enables/disables the parameter. If disabled the indenters default value will be used.");
+ chkBox->setSizePolicy(TQSizePolicy::Fixed, TQSizePolicy::Fixed);
+
+ // create the combo box
+ TQComboBox *comboBox = new TQComboBox(m_indenterParameterCategoryPages.at(category).widget);
+ TQStringList choicesStrings = TQStringList::split("|",
+ m_indenterSettings->value(indenterParameter + "/Choices").toString());
+ TQStringList choicesStringsReadable = TQStringList::split("|",
+ m_indenterSettings->value(indenterParameter + "/ChoicesReadable").toString(), true);
+ if (choicesStringsReadable.isEmpty())
+ {
+ comboBox->insertStringList(choicesStrings);
+ }
+ else
+ {
+ comboBox->insertStringList(choicesStringsReadable);
+ }
+ TQString paramToolTip = m_indenterSettings->value(indenterParameter + "/Description").toString();
+ TQToolTip::add(comboBox, paramToolTip);
+ if (m_mainWindow != nullptr)
+ {
+ comboBox->installEventFilter(m_mainWindow);
+ }
+
+ // put all into a layout and add it to the toolbox page
+ TQHBoxLayout *hboxLayout = new TQHBoxLayout();
+ hboxLayout->addWidget(chkBox);
+ hboxLayout->addWidget(comboBox);
+ m_indenterParameterCategoryPages.at(category).vboxLayout->addLayout(hboxLayout);
+
+ // remember parameter name and reference to its lineedit
+ ParamMultiple paramMultiple;
+ paramMultiple.paramName = indenterParameter;
+ paramMultiple.paramCallName = parameterCallName;
+ paramMultiple.comboBox = comboBox;
+ paramMultiple.choicesStrings = choicesStrings;
+ paramMultiple.choicesStringsReadable = choicesStringsReadable;
+ paramMultiple.valueEnabledChkBox = chkBox;
+ paramMultiple.comboBox->setCurrentItem(m_indenterSettings->value(paramMultiple.paramName +
+ "/ValueDefault").toInt());
+ m_paramMultiples.append(paramMultiple);
+
+ TQObject::connect(comboBox, SIGNAL(activated(int)), this,
+ SLOT(handleChangedIndenterSettings()));
+ TQObject::connect(chkBox, SIGNAL(clicked()), this, SLOT(handleChangedIndenterSettings()));
+ }
+ }
+ }
+
+ // put a spacer at each page end
+ for(IndenterParameterCategoryPage &categoryPage : m_indenterParameterCategoryPages)
+ {
+ categoryPage.vboxLayout->addStretch();
+ }
+
+ // Get rid of the dummy widget previously created
+ m_indenterParameterCategoriesToolBox->removeItem(dummyWidget);
+ delete dummyWidget;
}
/*
@@ -1264,30 +1260,32 @@ void IndentHandler::readIndentIniFile(const TQString &iniFilePath)
TQStringList IndentHandler::getAvailableIndenters()
{
TQStringList indenterNamesList;
-//---
-//--- // Loop for every existing uigui ini file
-//--- foreach(TQString indenterIniFile, m_indenterIniFileList)
-//--- {
-//--- // Open the ini file and search for the indenter name
-//--- TQFile file(m_indenterDirectoryStr + "/" + indenterIniFile);
-//--- if (file.open(TQIODevice::ReadOnly | TQIODevice::Text))
-//--- {
-//--- int index = -1;
-//--- TQByteArray line;
-//--- // Search for the string "indenterName=" and get the following string until line end.
-//--- while (index == -1 && !file.atEnd())
-//--- {
-//--- line = file.readLine();
-//--- index = line.indexOf("indenterName=", 0);
-//--- }
-//---
-//--- if (index == 0)
-//--- {
-//--- line = line.remove(0, 13);
-//--- indenterNamesList << line.trimmed();
-//--- }
-//--- }
-//--- }
+
+ // Loop for every existing uigui ini file
+ for (const TQString indenterIniFile : m_indenterIniFileList)
+ {
+ // Open the ini file and search for the indenter name
+ TQFile file(m_indenterDirectoryStr + "/" + indenterIniFile);
+ if (file.open(IO_ReadOnly | IO_Translate))
+ {
+ int index = -1;
+ TQTextStream stream(&file);
+ TQString line;
+ // Search for the string "indenterName=" and get the following string until line end.
+ while (index == -1 && !file.atEnd())
+ {
+ line = stream.readLine();
+ index = line.find("indenterName=", 0);
+ }
+
+ if (index == 0)
+ {
+ line = line.remove(0, 13);
+ indenterNamesList << line.stripWhiteSpace();
+ }
+ }
+ file.close();
+ }
return indenterNamesList;
}
@@ -1296,59 +1294,53 @@ TQStringList IndentHandler::getAvailableIndenters()
*/
void IndentHandler::setIndenter(int indenterID)
{
-//--- TQApplication::setOverrideCursor(TQt::WaitCursor);
-//---
-//--- // Generate the parameter string that will be saved to the indenters config file.
-//--- TQString parameterString = getParameterString();
-//--- if (!m_indenterFileName.isEmpty())
-//--- {
-//--- saveConfigFile(m_settingsDirectoryStr + "/" + m_indenterFileName + ".cfg", parameterString);
-//--- }
-//---
-//--- // Take care if the selected indenterID is smaller or greater than the number of existing
-//--- // indenters
-//--- if (indenterID < 0)
-//--- {
-//--- indenterID = 0;
-//--- }
-//--- if (indenterID >= m_indenterIniFileList.count())
-//--- {
-//--- indenterID = m_indenterIniFileList.count() - 1;
-//--- }
-//---
-//--- // MIKE: TODO: need to save selected indenterID into Settings
-//---
-//--- // remove all pages from the toolbox
-//--- for (int i = 0; i < m_indenterParameterCategoriesToolBox->count(); i++)
-//--- {
-//--- m_indenterParameterCategoriesToolBox->removeItem(i);
-//--- }
-//---
-//--- // delete all toolbox pages and by this its children
-//--- foreach(IndenterParameterCategoryPage categoryPage, _indenterParameterCategoryPages)
-//--- {
-//--- delete categoryPage.widget;
-//--- }
-//---
-//--- // empty all lists, which stored infos for the toolbox pages and its widgets
-//--- _indenterParameterCategoryPages.clear();
-//--- _paramStrings.clear();
-//--- _paramNumerics.clear();
-//--- _paramBooleans.clear();
-//--- _paramMultiples.clear();
-//--- delete m_indenterSettings;
-//---
-//--- readIndentIniFile(m_indenterDirectoryStr + "/" + m_indenterIniFileList.at(indenterID));
-//---
-//--- // Find out how the indenter can be executed.
-//--- createIndenterCallString();
-//---
-//--- // Load the users last settings made for this indenter.
-//--- loadConfigFile(m_settingsDirectoryStr + "/" + m_indenterFileName + ".cfg");
-//---
-//--- handleChangedIndenterSettings();
-//---
-//--- TQApplication::restoreOverrideCursor();
+ TQApplication::setOverrideCursor(TQt::WaitCursor);
+
+ // Generate the parameter string that will be saved to the indenters config file.
+ TQString parameterString = getParameterString();
+ if (!m_indenterFileName.isEmpty())
+ {
+ saveConfigFile(m_settingsDirectoryStr + "/" + m_indenterFileName + ".cfg", parameterString);
+ }
+
+ // Make sure the selected indenterID is valid
+ if (indenterID < 0)
+ {
+ indenterID = 0;
+ }
+ if (indenterID >= m_indenterIniFileList.count())
+ {
+ indenterID = m_indenterIniFileList.count() - 1;
+ }
+
+ m_settings->setValueByName("SelectedIndenter", indenterID);
+
+ // delete all toolbox pages and by this its children
+ for (IndenterParameterCategoryPage &categoryPage : m_indenterParameterCategoryPages)
+ {
+ m_indenterParameterCategoriesToolBox->removeItem(categoryPage.widget);
+ delete categoryPage.widget;
+ }
+
+ // empty all lists, which stored infos for the toolbox pages and its widgets
+ m_indenterParameterCategoryPages.clear();
+ m_paramStrings.clear();
+ m_paramNumerics.clear();
+ m_paramBooleans.clear();
+ m_paramMultiples.clear();
+ delete m_indenterSettings;
+
+ readIndentIniFile(m_indenterDirectoryStr + "/" + m_indenterIniFileList[indenterID]);
+
+ // Find out how the indenter can be executed.
+ createIndenterCallString();
+
+ // Load the users last settings made for this indenter.
+ loadConfigFile(m_settingsDirectoryStr + "/" + m_indenterFileName + ".cfg");
+
+ handleChangedIndenterSettings();
+
+ TQApplication::restoreOverrideCursor();
}
//--- /*
@@ -1356,7 +1348,7 @@ void IndentHandler::setIndenter(int indenterID)
//--- */
//--- TQString IndentHandler::getPossibleIndenterFileExtensions()
//--- {
-//--- return _fileTypes;
+//--- return m_fileTypes;
//--- }
/*
@@ -1400,7 +1392,7 @@ bool IndentHandler::createIndenterCallString()
//--- if (TQFileInfo(m_indenterExecutableCallString).suffix().toLower() != "php")
//--- {
//--- indentProcess.start(
-//--- "\"" + m_indenterExecutableCallString + +"\" " + _indenterShowHelpParameter);
+//--- "\"" + m_indenterExecutableCallString + +"\" " + m_indenterShowHelpParameter);
//--- if (indentProcess.waitForFinished(2000))
//--- {
//--- m_indenterExecutableCallString = "\"" + m_indenterExecutableCallString + "\"";
@@ -1484,7 +1476,7 @@ bool IndentHandler::createIndenterCallString()
//--- {
//--- m_indenterExecutableSuffix = suffix;
//--- m_indenterExecutableCallString = m_indenterFileName + suffix;
-//--- indentProcess.start(m_indenterExecutableCallString + " " + _indenterShowHelpParameter);
+//--- indentProcess.start(m_indenterExecutableCallString + " " + m_indenterShowHelpParameter);
//--- if (indentProcess.waitForFinished(2000))
//--- {
//--- return true;
@@ -1721,14 +1713,12 @@ void IndentHandler::handleChangedIndenterSettings()
emit(indenterSettingsChanged());
}
-//--- /*
-//--- \brief Returns the id (list index) of the currently selected indenter.
+//--- /*!
+//--- \brief Converts characters < > and & in the \a text to HTML codes &lt &gt and &amp.
//--- */
-//--- int IndentHandler::getIndenterId()
+//--- TQString IndentHandler::encodeToHTML(const TQString &text)
//--- {
-//--- return m_indenterSelectionCombobox->currentIndex();
-//--- }
-//---
+//--- TQString htmlText = text;
//--- htmlText.replace("&", "&amp;");
//--- htmlText.replace("<", "&lt;");
//--- htmlText.replace(">", "&gt;");
diff --git a/src/IndentHandler.h b/src/IndentHandler.h
index 97b00d1..05c0ce9 100644
--- a/src/IndentHandler.h
+++ b/src/IndentHandler.h
@@ -21,20 +21,21 @@
#define INDENTHANDLER_H
#include <tqwidget.h>
+#include <tqvaluevector.h>
class MainWindow;
class UiGuiErrorMessage;
-///-- class UiGuiIniFileParser;
+class UiGuiIniFileParser;
+class UiGuiSettings;
+class TQCheckBox;
class TQComboBox;
+class TQLabel;
+class TQLineEdit;
+class TQSpinBox;
class TQToolBox;
class TQToolButton;
class TQVBoxLayout;
-///-- class TQMenu;
-///-- class TQLabel;
-///-- class TQSpinBox;
-///-- class TQCheckBox;
-///-- class TQLineEdit;
class IndentHandler : public TQWidget
@@ -56,8 +57,7 @@ class IndentHandler : public TQWidget
///-- TQString getManual();
///-- TQString getCurrentIndenterName();
void contextMenuEvent(TQContextMenuEvent *event);
-///-- int getIndenterId();
-///--
+
signals:
void indenterSettingsChanged();
///-- void selectedIndenterIndexChanged(int index);
@@ -81,91 +81,86 @@ class IndentHandler : public TQWidget
void saveConfigFile(const TQString &filePathName, const TQString &parameterString);
void readIndentIniFile(const TQString &iniFilePath);
bool createIndenterCallString();
-///--
-///-- // Holds a reference to all created pages of the parameter categories toolbox and the pages
-///-- // boxlayout
-///-- struct IndenterParameterCategoryPage
-///-- {
-///-- TQWidget *widget;
-///-- TQVBoxLayout *vboxLayout;
-///-- };
-///--
-///-- TQVector<IndenterParameterCategoryPage> _indenterParameterCategoryPages;
-///--
-///-- // Holds a reference to all checkboxes needed for boolean parameter setting and the parameters
-///-- // name
-///-- struct ParamBoolean
-///-- {
-///-- TQString paramName;
-///-- TQString trueString;
-///-- TQString falseString;
-///-- TQCheckBox *checkBox;
-///-- };
-///--
-///-- TQVector<ParamBoolean> _paramBooleans;
-///--
-///-- // Holds a reference to all line edits needed for parameter setting and the parameters name
-///-- struct ParamString
-///-- {
-///-- TQString paramName;
-///-- TQString paramCallName;
-///-- TQCheckBox *valueEnabledChkBox;
-///-- TQLineEdit *lineEdit;
-///-- TQLabel *label;
-///-- };
-///--
-///-- TQVector<ParamString> _paramStrings;
-///--
-///-- // Hold a reference to all spin boxes needed for parameter setting and the parameters name
-///-- struct ParamNumeric
-///-- {
-///-- TQString paramName;
-///-- TQString paramCallName;
-///-- TQCheckBox *valueEnabledChkBox;
-///-- TQSpinBox *spinBox;
-///-- TQLabel *label;
-///-- };
-///--
-///-- TQVector<ParamNumeric> _paramNumerics;
-///--
-///-- // Hold a reference to all combo boxes needed for parameter setting and the parameters name
-///-- struct ParamMultiple
-///-- {
-///-- TQString paramName;
-///-- TQString paramCallName;
-///-- TQCheckBox *valueEnabledChkBox;
-///-- TQComboBox *comboBox;
-///-- TQStringList choicesStrings;
-///-- TQStringList choicesStringsReadable;
-///-- };
-///--
-///-- TQVector<ParamMultiple> _paramMultiples;
-///--
+
+ // Holds a reference to all created pages of the parameter categories toolbox and their layout
+ struct IndenterParameterCategoryPage
+ {
+ TQWidget *widget;
+ TQVBoxLayout *vboxLayout;
+ };
+ TQValueVector<IndenterParameterCategoryPage> m_indenterParameterCategoryPages;
+
+ // Holds a reference to all checkboxes needed for boolean parameters and their names
+ struct ParamBoolean
+ {
+ TQString paramName;
+ TQString trueString;
+ TQString falseString;
+ TQCheckBox *checkBox;
+ };
+ TQValueVector<ParamBoolean> m_paramBooleans;
+
+ // Holds a reference to all line edits needed for parameter setting and the parameters name
+ struct ParamString
+ {
+ TQString paramName;
+ TQString paramCallName;
+ TQCheckBox *valueEnabledChkBox;
+ TQLineEdit *lineEdit;
+ TQLabel *label;
+ };
+ TQValueVector<ParamString> m_paramStrings;
+
+ // Hold a reference to all spin boxes needed for parameter setting and the parameters name
+ struct ParamNumeric
+ {
+ TQString paramName;
+ TQString paramCallName;
+ TQCheckBox *valueEnabledChkBox;
+ TQSpinBox *spinBox;
+ TQLabel *label;
+ };
+ TQValueVector<ParamNumeric> m_paramNumerics;
+
+ // Hold a reference to all combo boxes needed for parameter setting and the parameters name
+ struct ParamMultiple
+ {
+ TQString paramName;
+ TQString paramCallName;
+ TQCheckBox *valueEnabledChkBox;
+ TQComboBox *comboBox;
+ TQStringList choicesStrings;
+ TQStringList choicesStringsReadable;
+ };
+ TQValueVector<ParamMultiple> m_paramMultiples;
+
+ UiGuiSettings *m_settings;
+
TQComboBox *m_indenterSelectionCombobox;
TQToolButton *m_indenterParameterHelpButton;
-///-- // Vertical layout box, into which the toolbox will be added
+ // Vertical layout box, into which the toolbox will be added
TQVBoxLayout *m_toolBoxContainerLayout;
TQToolBox *m_indenterParameterCategoriesToolBox;
-///-- UiGuiIniFileParser *m_indenterSettings;
-///-- TQStringList _indenterParameters;
-///-- // The indenters name in a descriptive form
-///-- TQString _indenterName;
-///-- // The indenters file name (w/o extension), that is being called
+ UiGuiIniFileParser *m_indenterSettings;
+ TQStringList m_indenterParameters;
+ // The indenters name in a descriptive form
+ TQString m_indenterName;
+ // The indenters file name (w/o extension), that is being called
TQString m_indenterFileName;
TQString m_indenterDirectoryStr;
TQString m_tempDirectoryStr;
TQString m_settingsDirectoryStr;
TQStringList m_indenterIniFileList;
-///-- TQString _parameterOrder;
TQString m_globalConfigFilename;
-///-- TQString _cfgFileParameterEnding;
-///-- TQString _inputFileParameter;
-///-- TQString _inputFileName;
-///-- TQString _outputFileParameter;
-///-- TQString _outputFileName;
-///-- TQString _fileTypes;
-///-- TQString _useCfgFileParameter;
-///-- TQString _indenterShowHelpParameter;
+ TQString m_cfgFileParameterEnding;
+ TQString m_parameterOrder;
+ TQString m_inputFileParameter;
+ TQString m_inputFileName;
+ TQString m_outputFileParameter;
+ TQString m_outputFileName;
+ TQString m_fileTypes;
+ TQString m_useCfgFileParameter;
+ TQString m_indenterShowHelpParameter;
MainWindow *m_mainWindow;
TQWidget *m_parent;
UiGuiErrorMessage *m_errorMessageDialog;
diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp
index 5c50627..34cc09f 100644
--- a/src/MainWindow.cpp
+++ b/src/MainWindow.cpp
@@ -682,7 +682,7 @@ void MainWindow::updateSourceView()
*/
void MainWindow::callIndenter()
{
- TQApplication::setOverrideCursor(TQCursor(TQt::WaitCursor));
+ TQApplication::setOverrideCursor(TQt::WaitCursor);
///-- m_sourceFormattedContent = m_indentHandler->callIndenter(m_sourceFileContent,
///-- m_currentSourceFileExtension);
updateSourceView();