diff options
author | Michele Calgaro <[email protected]> | 2023-05-31 19:27:38 +0900 |
---|---|---|
committer | Michele Calgaro <[email protected]> | 2023-05-31 19:27:45 +0900 |
commit | 44f39b628c487af77c0a503d622d57b99748e1e1 (patch) | |
tree | 96d32a035106586720de7905e7fb19f009a5829c | |
parent | dfb1b9f10a0c18ace12de3323e3eea410efa3b6c (diff) | |
download | universal-indent-gui-tqt-44f39b628c487af77c0a503d622d57b99748e1e1.tar.gz universal-indent-gui-tqt-44f39b628c487af77c0a503d622d57b99748e1e1.zip |
Added UiGuiErrorMessage, UiGuiIniFileParse and some code related to
them. Added indenter .ini files.
Signed-off-by: Michele Calgaro <[email protected]>
-rw-r--r-- | indenters/CMakeLists.txt | 24 | ||||
-rwxr-xr-x | indenters/uigui_CblBeau.ini (renamed from indenters/__TODO/uigui_CblBeau.ini) | 0 | ||||
-rwxr-xr-x | indenters/uigui_astyle.ini (renamed from indenters/__TODO/uigui_astyle.ini) | 0 | ||||
-rwxr-xr-x | indenters/uigui_bcpp.ini (renamed from indenters/__TODO/uigui_bcpp.ini) | 0 | ||||
-rwxr-xr-x | indenters/uigui_csstidy.ini (renamed from indenters/__TODO/uigui_csstidy.ini) | 0 | ||||
-rwxr-xr-x | indenters/uigui_f90ppr.ini (renamed from indenters/__TODO/uigui_f90ppr.ini) | 0 | ||||
-rwxr-xr-x | indenters/uigui_gnuindent.ini (renamed from indenters/__TODO/uigui_gnuindent.ini) | 0 | ||||
-rwxr-xr-x | indenters/uigui_greatcode.ini (renamed from indenters/__TODO/uigui_greatcode.ini) | 0 | ||||
-rwxr-xr-x | indenters/uigui_hindent.ini (renamed from indenters/__TODO/uigui_hindent.ini) | 0 | ||||
-rwxr-xr-x | indenters/uigui_htb.ini (renamed from indenters/__TODO/uigui_htb.ini) | 0 | ||||
-rwxr-xr-x | indenters/uigui_jsdecoder.ini (renamed from indenters/__TODO/uigui_jsdecoder.ini) | 0 | ||||
-rwxr-xr-x | indenters/uigui_jsppp.ini (renamed from indenters/__TODO/uigui_jsppp.ini) | 0 | ||||
-rwxr-xr-x | indenters/uigui_perltidy.ini (renamed from indenters/__TODO/uigui_perltidy.ini) | 0 | ||||
-rwxr-xr-x | indenters/uigui_phpCB.ini (renamed from indenters/__TODO/uigui_phpCB.ini) | 0 | ||||
-rwxr-xr-x | indenters/uigui_phpStylist.ini (renamed from indenters/__TODO/uigui_phpStylist.ini) | 0 | ||||
-rwxr-xr-x | indenters/uigui_php_Beautifier.ini (renamed from indenters/__TODO/uigui_php_Beautifier.ini) | 0 | ||||
-rwxr-xr-x | indenters/uigui_pindent.ini (renamed from indenters/__TODO/uigui_pindent.ini) | 0 | ||||
-rwxr-xr-x | indenters/uigui_psti.ini (renamed from indenters/__TODO/uigui_psti.ini) | 0 | ||||
-rwxr-xr-x | indenters/uigui_rbeautify.ini (renamed from indenters/__TODO/uigui_rbeautify.ini) | 0 | ||||
-rwxr-xr-x | indenters/uigui_rubyformatter.ini (renamed from indenters/__TODO/uigui_rubyformatter.ini) | 0 | ||||
-rwxr-xr-x | indenters/uigui_shellindent.ini (renamed from indenters/__TODO/uigui_shellindent.ini) | 0 | ||||
-rwxr-xr-x | indenters/uigui_tidy.ini (renamed from indenters/__TODO/uigui_tidy.ini) | 0 | ||||
-rwxr-xr-x | indenters/uigui_uncrustify.ini (renamed from indenters/__TODO/uigui_uncrustify.ini) | 0 | ||||
-rwxr-xr-x | indenters/uigui_vbsbeaut.ini (renamed from indenters/__TODO/uigui_vbsbeaut.ini) | 0 | ||||
-rwxr-xr-x | indenters/uigui_xmlindent.ini (renamed from indenters/__TODO/uigui_xmlindent.ini) | 0 | ||||
-rw-r--r-- | src/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/IndentHandler.cpp | 537 | ||||
-rw-r--r-- | src/IndentHandler.h | 40 | ||||
-rw-r--r-- | src/MainWindow.cpp | 26 | ||||
-rw-r--r-- | src/MainWindow.h | 2 | ||||
-rw-r--r-- | src/UiGuiErrorMessage.cpp (renamed from src/__TODO/UiGuiErrorMessage.cpp) | 36 | ||||
-rw-r--r-- | src/UiGuiErrorMessage.h (renamed from src/__TODO/UiGuiErrorMessage.h) | 9 | ||||
-rw-r--r-- | src/UiGuiIniFileParser.cpp (renamed from src/__TODO/UiGuiIniFileParser.cpp) | 67 | ||||
-rw-r--r-- | src/UiGuiIniFileParser.h (renamed from src/__TODO/UiGuiIniFileParser.h) | 17 |
34 files changed, 390 insertions, 370 deletions
diff --git a/indenters/CMakeLists.txt b/indenters/CMakeLists.txt index c0ae4b6..2fc3cb0 100644 --- a/indenters/CMakeLists.txt +++ b/indenters/CMakeLists.txt @@ -1,5 +1,29 @@ install( FILES example.cpp + uigui_astyle.ini + uigui_bcpp.ini + uigui_CblBeau.ini + uigui_csstidy.ini + uigui_f90ppr.ini + uigui_gnuindent.ini + uigui_greatcode.ini + uigui_hindent.ini + uigui_htb.ini + uigui_jsdecoder.ini + uigui_jsppp.ini + uigui_perltidy.ini + uigui_php_Beautifier.ini + uigui_phpCB.ini + uigui_phpStylist.ini + uigui_pindent.ini + uigui_psti.ini + uigui_rbeautify.ini + uigui_rubyformatter.ini + uigui_shellindent.ini + uigui_tidy.ini + uigui_uncrustify.ini + uigui_vbsbeaut.ini + uigui_xmlindent.ini DESTINATION ${SHARE_INSTALL_PREFIX}/universal-indent-gui-tqt/indenters ) diff --git a/indenters/__TODO/uigui_CblBeau.ini b/indenters/uigui_CblBeau.ini index 069f429..069f429 100755 --- a/indenters/__TODO/uigui_CblBeau.ini +++ b/indenters/uigui_CblBeau.ini diff --git a/indenters/__TODO/uigui_astyle.ini b/indenters/uigui_astyle.ini index 7d312b8..7d312b8 100755 --- a/indenters/__TODO/uigui_astyle.ini +++ b/indenters/uigui_astyle.ini diff --git a/indenters/__TODO/uigui_bcpp.ini b/indenters/uigui_bcpp.ini index c094f97..c094f97 100755 --- a/indenters/__TODO/uigui_bcpp.ini +++ b/indenters/uigui_bcpp.ini diff --git a/indenters/__TODO/uigui_csstidy.ini b/indenters/uigui_csstidy.ini index 2cca15a..2cca15a 100755 --- a/indenters/__TODO/uigui_csstidy.ini +++ b/indenters/uigui_csstidy.ini diff --git a/indenters/__TODO/uigui_f90ppr.ini b/indenters/uigui_f90ppr.ini index 9d3dc3c..9d3dc3c 100755 --- a/indenters/__TODO/uigui_f90ppr.ini +++ b/indenters/uigui_f90ppr.ini diff --git a/indenters/__TODO/uigui_gnuindent.ini b/indenters/uigui_gnuindent.ini index 53ac520..53ac520 100755 --- a/indenters/__TODO/uigui_gnuindent.ini +++ b/indenters/uigui_gnuindent.ini diff --git a/indenters/__TODO/uigui_greatcode.ini b/indenters/uigui_greatcode.ini index 24c7a58..24c7a58 100755 --- a/indenters/__TODO/uigui_greatcode.ini +++ b/indenters/uigui_greatcode.ini diff --git a/indenters/__TODO/uigui_hindent.ini b/indenters/uigui_hindent.ini index d9767b2..d9767b2 100755 --- a/indenters/__TODO/uigui_hindent.ini +++ b/indenters/uigui_hindent.ini diff --git a/indenters/__TODO/uigui_htb.ini b/indenters/uigui_htb.ini index c6227c0..c6227c0 100755 --- a/indenters/__TODO/uigui_htb.ini +++ b/indenters/uigui_htb.ini diff --git a/indenters/__TODO/uigui_jsdecoder.ini b/indenters/uigui_jsdecoder.ini index f22ea7b..f22ea7b 100755 --- a/indenters/__TODO/uigui_jsdecoder.ini +++ b/indenters/uigui_jsdecoder.ini diff --git a/indenters/__TODO/uigui_jsppp.ini b/indenters/uigui_jsppp.ini index 53c886c..53c886c 100755 --- a/indenters/__TODO/uigui_jsppp.ini +++ b/indenters/uigui_jsppp.ini diff --git a/indenters/__TODO/uigui_perltidy.ini b/indenters/uigui_perltidy.ini index bf2587b..bf2587b 100755 --- a/indenters/__TODO/uigui_perltidy.ini +++ b/indenters/uigui_perltidy.ini diff --git a/indenters/__TODO/uigui_phpCB.ini b/indenters/uigui_phpCB.ini index 00dbfc3..00dbfc3 100755 --- a/indenters/__TODO/uigui_phpCB.ini +++ b/indenters/uigui_phpCB.ini diff --git a/indenters/__TODO/uigui_phpStylist.ini b/indenters/uigui_phpStylist.ini index 6374906..6374906 100755 --- a/indenters/__TODO/uigui_phpStylist.ini +++ b/indenters/uigui_phpStylist.ini diff --git a/indenters/__TODO/uigui_php_Beautifier.ini b/indenters/uigui_php_Beautifier.ini index ab5364d..ab5364d 100755 --- a/indenters/__TODO/uigui_php_Beautifier.ini +++ b/indenters/uigui_php_Beautifier.ini diff --git a/indenters/__TODO/uigui_pindent.ini b/indenters/uigui_pindent.ini index ae17620..ae17620 100755 --- a/indenters/__TODO/uigui_pindent.ini +++ b/indenters/uigui_pindent.ini diff --git a/indenters/__TODO/uigui_psti.ini b/indenters/uigui_psti.ini index 9a1acb7..9a1acb7 100755 --- a/indenters/__TODO/uigui_psti.ini +++ b/indenters/uigui_psti.ini diff --git a/indenters/__TODO/uigui_rbeautify.ini b/indenters/uigui_rbeautify.ini index 38babe1..38babe1 100755 --- a/indenters/__TODO/uigui_rbeautify.ini +++ b/indenters/uigui_rbeautify.ini diff --git a/indenters/__TODO/uigui_rubyformatter.ini b/indenters/uigui_rubyformatter.ini index 1afba10..1afba10 100755 --- a/indenters/__TODO/uigui_rubyformatter.ini +++ b/indenters/uigui_rubyformatter.ini diff --git a/indenters/__TODO/uigui_shellindent.ini b/indenters/uigui_shellindent.ini index 2c36958..2c36958 100755 --- a/indenters/__TODO/uigui_shellindent.ini +++ b/indenters/uigui_shellindent.ini diff --git a/indenters/__TODO/uigui_tidy.ini b/indenters/uigui_tidy.ini index 1341d45..1341d45 100755 --- a/indenters/__TODO/uigui_tidy.ini +++ b/indenters/uigui_tidy.ini diff --git a/indenters/__TODO/uigui_uncrustify.ini b/indenters/uigui_uncrustify.ini index e16e560..e16e560 100755 --- a/indenters/__TODO/uigui_uncrustify.ini +++ b/indenters/uigui_uncrustify.ini diff --git a/indenters/__TODO/uigui_vbsbeaut.ini b/indenters/uigui_vbsbeaut.ini index 0168a92..0168a92 100755 --- a/indenters/__TODO/uigui_vbsbeaut.ini +++ b/indenters/uigui_vbsbeaut.ini diff --git a/indenters/__TODO/uigui_xmlindent.ini b/indenters/uigui_xmlindent.ini index 3717510..3717510 100755 --- a/indenters/__TODO/uigui_xmlindent.ini +++ b/indenters/uigui_xmlindent.ini diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index cff46f3..09f1b9a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -31,6 +31,8 @@ set( ${target}_SRCS ToolBarWidget.ui SettingsPaths.cpp + UiGuiErrorMessage.cpp + UiGuiIniFileParser.cpp UiGuiVersion.cpp # ongoing diff --git a/src/IndentHandler.cpp b/src/IndentHandler.cpp index 76033dc..eca9791 100644 --- a/src/IndentHandler.cpp +++ b/src/IndentHandler.cpp @@ -22,20 +22,22 @@ #include "MainWindow.h" #include "SettingsPaths.h" +#include "UiGuiErrorMessage.h" //--- #include "UiGuiSettings.h" -//--- #include "UiGuiErrorMessage.h" //--- #include "TemplateBatchScript.h" //--- #include "UiGuiIniFileParser.h" #include <tqcombobox.h> #include <tqdir.h> +#include <tqfile.h> +#include <tqfiledialog.h> #include <tqlayout.h> +#include <tqmessagebox.h> #include <tqpopupmenu.h> #include <tqtoolbox.h> #include <tqtoolbutton.h> //--- #include <tqapplication.h> //--- #include <tqcheckbox.h> -//--- #include <tqfile.h> //--- #include <tqprocess.h> //--- #include <tqsettings.h> //--- #include <tqstringlist.h> @@ -43,14 +45,12 @@ //--- #include <tqspinbox.h> //--- #include <tqlabel.h> //--- #include <tqbytearray.h> -//--- #include <tqmessagebox.h> //--- #include <tqtextstream.h> //--- #include <tqtextcodec.h> //--- #include <tqtscript.h> //--- #include <tqdesktopservices.h> //--- #include <tqaction.h> //--- #include <tqcontextmenuevent.h> -//--- #include <tqfiledialog.h> //--- #include <tqtdebug.h> // \defgroup grp_Indenter All concerning handling of the indenter. @@ -76,8 +76,8 @@ 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) -//--- _indenterSettings(nullptr), _errorMessageDialog(nullptr) + m_indenterParameterCategoriesToolBox(nullptr), m_errorMessageDialog(nullptr) +//--- m_indenterSettings(nullptr) { if (indenterID < 0) { @@ -133,55 +133,55 @@ IndentHandler::IndentHandler(int indenterID, MainWindow *mainWindow, TQWidget *p m_indenterDirectoryStr = SettingsPaths::getIndenterPath(); m_tempDirectoryStr = SettingsPaths::getTempPath(); m_settingsDirectoryStr = SettingsPaths::getSettingsPath(); + + if (m_mainWindow) + { + m_errorMessageDialog = new UiGuiErrorMessage(m_mainWindow); + } + else + { + m_errorMessageDialog = new UiGuiErrorMessage(this); + } + TQDir indenterDirectory = TQDir(m_indenterDirectoryStr); + m_indenterIniFileList = indenterDirectory.entryList(TQString("uigui_*.ini")); + if (m_indenterIniFileList.count() > 0) + { + // 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; + } -//--- if (m_mainWindow != nullptr) -//--- { -//--- _errorMessageDialog = new UiGuiErrorMessage(m_mainWindow); -//--- } -//--- else -//--- { -//--- _errorMessageDialog = new UiGuiErrorMessage(this); -//--- } + // Reads and parses the indenter ini file specified by indenterID and creates toolbox entries + readIndentIniFile(m_indenterDirectoryStr + "/" + m_indenterIniFileList[indenterID]); -//--- _indenterIniFileList = indenterDirectory.entryList(TQStringList("uigui_*.ini")); -//--- if (_indenterIniFileList.count() > 0) -//--- { -//--- // Take care if the selected indenterID is smaller or greater than the number of existing -//--- // indenters -//--- if (indenterID < 0) -//--- { -//--- indenterID = 0; -//--- } -//--- if (indenterID >= _indenterIniFileList.count()) -//--- { -//--- indenterID = _indenterIniFileList.count() - 1; -//--- } -//--- -//--- // Reads and parses the by indenterID defined indent ini file and creates toolbox entries -//--- readIndentIniFile(m_indenterDirectoryStr + "/" + _indenterIniFileList.at(indenterID)); -//--- -//--- // Find out how the indenter can be executed. -//--- createIndenterCallString(); -//--- -//--- // Load the users last settings made for this indenter. -//--- loadConfigFile(m_settingsDirectoryStr + "/" + _indenterFileName + ".cfg"); -//--- -//--- // Fill the indenter selection combo box with the list of available indenters. -//--- if (!getAvailableIndenters().isEmpty()) -//--- { -//--- m_indenterSelectionCombobox->addItems(getAvailableIndenters()); -//--- m_indenterSelectionCombobox->setCurrentIndex(indenterID); -//--- connect(m_indenterSelectionCombobox, SIGNAL(currentIndexChanged(int)), this, -//--- SIGNAL(selectedIndenterIndexChanged(int))); -//--- } -//--- } -//--- else -//--- { -//--- _errorMessageDialog->showMessage(tr("No indenter ini files"), -//--- tr("There exists no indenter ini files in the directory \"") + -//--- TQDir(m_indenterDirectoryStr).absolutePath() + "\"."); -//--- } + // Find out how the indenter can be executed. + createIndenterCallString(); + + // Load the users last settings made for this indenter. + loadConfigFile(m_settingsDirectoryStr + "/" + m_indenterFileName + ".cfg"); + + // Fill the indenter selection combo box with the list of available indenters. + TQStringList availableIndenters = getAvailableIndenters(); + if (!availableIndenters.isEmpty()) + { + m_indenterSelectionCombobox->insertStringList(availableIndenters); + m_indenterSelectionCombobox->setCurrentItem(indenterID); + // MIKE make sure setIndeter() is invoked, so indenter is correctly set at start + } + } + else + { + m_errorMessageDialog->showMessage(tr("No indenter ini files"), + tr("No valid indenter ini file found in directory ") + + TQDir(m_indenterDirectoryStr).absPath()); + } } /* @@ -189,14 +189,14 @@ IndentHandler::IndentHandler(int indenterID, MainWindow *mainWindow, TQWidget *p */ IndentHandler::~IndentHandler() { -//--- // Generate the parameter string that will be saved to the indenters config file. -//--- TQString parameterString = getParameterString(); -//--- if (!_indenterFileName.isEmpty()) -//--- { -//--- saveConfigFile(m_settingsDirectoryStr + "/" + _indenterFileName + ".cfg", parameterString); -//--- } -//--- -//--- delete _errorMessageDialog; + // 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); + } + + delete m_errorMessageDialog; } /* @@ -242,7 +242,7 @@ void IndentHandler::contextMenuEvent(TQContextMenuEvent *event) //--- //--- // If the config file name is empty it is assumed that all parameters are sent via command line //--- // call -//--- if (_globalConfigFilename.isEmpty()) +//--- if (m_globalConfigFilename.isEmpty()) //--- { //--- parameterParameterFile = " " + getParameterString(); //--- } @@ -351,9 +351,9 @@ void IndentHandler::contextMenuEvent(TQContextMenuEvent *event) //--- { //--- Q_ASSERT_X(!_inputFileName.isEmpty(), "callIndenter", "_inputFileName is empty"); //--- // Q_ASSERT_X( !_outputFileName.isEmpty(), "callIndenter", "_outputFileName is empty" ); -//--- Q_ASSERT_X(!_indenterFileName.isEmpty(), "callIndenter", "_indenterFileName is empty"); +//--- Q_ASSERT_X(!m_indenterFileName.isEmpty(), "callIndenter", "m_indenterFileName is empty"); //--- -//--- if (_indenterFileName.isEmpty()) +//--- if (m_indenterFileName.isEmpty()) //--- { //--- return ""; //--- } @@ -369,9 +369,9 @@ void IndentHandler::contextMenuEvent(TQContextMenuEvent *event) //--- // Generate the parameter string that will be saved to the indenters config file //--- TQString parameterString = getParameterString(); //--- -//--- if (!_globalConfigFilename.isEmpty()) +//--- if (!m_globalConfigFilename.isEmpty()) //--- { -//--- saveConfigFile(m_tempDirectoryStr + "/" + _globalConfigFilename, parameterString); +//--- saveConfigFile(m_tempDirectoryStr + "/" + m_globalConfigFilename, parameterString); //--- } //--- //--- // Only add a dot to file extension if the string is not empty @@ -416,7 +416,7 @@ void IndentHandler::contextMenuEvent(TQContextMenuEvent *event) //--- //--- // If the config file name is empty it is assumed that all parameters are sent via command line //--- // call -//--- if (_globalConfigFilename.isEmpty()) +//--- if (m_globalConfigFilename.isEmpty()) //--- { //--- parameterParameterFile = " " + parameterString; //--- } @@ -424,7 +424,7 @@ void IndentHandler::contextMenuEvent(TQContextMenuEvent *event) //--- else if (_useCfgFileParameter != "none") //--- { //--- parameterParameterFile = " " + _useCfgFileParameter + "\"" + m_tempDirectoryStr + "/" + -//--- _globalConfigFilename + "\""; +//--- m_globalConfigFilename + "\""; //--- } //--- //--- // Assemble indenter call string for parameters according to the set order. @@ -448,9 +448,9 @@ void IndentHandler::contextMenuEvent(TQContextMenuEvent *event) //--- // If no indenter executable call string could be created before, show an error message. //--- if (m_indenterExecutableCallString.isEmpty()) //--- { -//--- _errorMessageDialog->showMessage(tr("No indenter executable"), tr( +//--- 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( -//--- _indenterFileName).arg(m_indenterDirectoryStr)); +//--- m_indenterFileName).arg(m_indenterDirectoryStr)); //--- return sourceCode; //--- } //--- @@ -538,7 +538,7 @@ void IndentHandler::contextMenuEvent(TQContextMenuEvent *event) //--- encodeToHTML(indentProcess.readAllStandardError()) + "<br>" + "</pre></html></body>"; //--- tqWarning() << __LINE__ << " " << __FUNCTION__ << processReturnString; //--- TQApplication::restoreOverrideCursor(); -//--- _errorMessageDialog->showMessage(tr("Error calling Indenter"), processReturnString); +//--- m_errorMessageDialog->showMessage(tr("Error calling Indenter"), processReturnString); //--- } //--- //--- // If the indenter returned an error code != 0 show its output. @@ -553,7 +553,7 @@ void IndentHandler::contextMenuEvent(TQContextMenuEvent *event) //--- encodeToHTML(indenterCompleteCallString) + "</html></body>"; //--- tqWarning() << __LINE__ << " " << __FUNCTION__ << processReturnString; //--- TQApplication::restoreOverrideCursor(); -//--- _errorMessageDialog->showMessage(tr("Indenter returned error"), processReturnString); +//--- m_errorMessageDialog->showMessage(tr("Indenter returned error"), processReturnString); //--- } //--- //--- // Only get the formatted source code, if calling the indenter did succeed. @@ -596,14 +596,14 @@ void IndentHandler::contextMenuEvent(TQContextMenuEvent *event) //--- //--- return formattedSourceCode; //--- } -//--- -//--- /* -//--- \brief Generates and returns a string with all parameters needed to call the indenter. -//--- */ -//--- TQString IndentHandler::getParameterString() -//--- { -//--- TQString parameterString = ""; -//--- + +/* + \brief Generates and returns a string with all parameters needed to call the indenter. + */ +TQString IndentHandler::getParameterString() +{ + TQString parameterString = ""; + //--- // generate parameter string for all boolean values //--- foreach(ParamBoolean pBoolean, _paramBooleans) //--- { @@ -655,49 +655,49 @@ void IndentHandler::contextMenuEvent(TQContextMenuEvent *event) //--- _cfgFileParameterEnding; //--- } //--- } -//--- -//--- return parameterString; -//--- } -//--- -//--- /* -//--- \brief Write settings for the indenter to a config file. -//--- */ -//--- void IndentHandler::saveConfigFile(TQString filePathName, TQString paramString) -//--- { + + return parameterString; +} + +/* + \brief Write settings for the indenter to a config file. + */ +void IndentHandler::saveConfigFile(const TQString &filePathName, const TQString ¶mString) +{ //--- TQFile::remove(filePathName); //--- TQFile cfgFile(filePathName); //--- //--- cfgFile.open(TQFile::ReadWrite | TQFile::Text); //--- cfgFile.write(paramString.toAscii()); //--- cfgFile.close(); -//--- } -//--- -//--- /* -//--- \brief Load the config file for the indenter and apply the settings made there. -//--- */ -//--- bool IndentHandler::loadConfigFile(TQString filePathName) -//--- { -//--- TQFile cfgFile(filePathName); -//--- int index; -//--- int crPos; -//--- int paramValue = 0; -//--- TQString paramValueStr = ""; -//--- TQString cfgFileData = ""; -//--- -//--- // If the to be loaded config file does not exist leave all values as they are and return false. -//--- if (!cfgFile.exists()) -//--- { -//--- return false; -//--- } -//--- // else if the to be read config file exists, retrieve its whole content. -//--- else -//--- { -//--- // Open the config file and read all data -//--- cfgFile.open(TQFile::ReadOnly | TQFile::Text); -//--- cfgFileData = cfgFile.readAll(); -//--- cfgFile.close(); -//--- } -//--- +} + +/* + \brief Load the config file for the indenter and apply the settings made there. + */ +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()) + { + return false; + } + // else if the to be read config file exists, retrieve its whole content. + else + { + // Open the config file and read all data + 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) //--- { @@ -727,7 +727,7 @@ void IndentHandler::contextMenuEvent(TQContextMenuEvent *event) //--- // neither true nor false parameter found so use default value //--- else //--- { -//--- paramValue = _indenterSettings->value(pBoolean.paramName + "/ValueDefault").toBool(); +//--- paramValue = m_indenterSettings->value(pBoolean.paramName + "/ValueDefault").toBool(); //--- } //--- } //--- } @@ -753,7 +753,7 @@ void IndentHandler::contextMenuEvent(TQContextMenuEvent *event) //--- // neither true nor false parameter found so use default value //--- else //--- { -//--- paramValue = _indenterSettings->value(pBoolean.paramName + "/ValueDefault").toBool(); +//--- paramValue = m_indenterSettings->value(pBoolean.paramName + "/ValueDefault").toBool(); //--- } //--- } //--- } @@ -790,7 +790,7 @@ void IndentHandler::contextMenuEvent(TQContextMenuEvent *event) //--- // parameter was not found in config file //--- else //--- { -//--- int defaultValue = _indenterSettings->value(pNumeric.paramName + "/ValueDefault").toInt(); +//--- int defaultValue = m_indenterSettings->value(pNumeric.paramName + "/ValueDefault").toInt(); //--- pNumeric.spinBox->setValue(defaultValue); //--- pNumeric.valueEnabledChkBox->setChecked(false); //--- } @@ -839,7 +839,7 @@ void IndentHandler::contextMenuEvent(TQContextMenuEvent *event) //--- // Parameter was not found in config file //--- else //--- { -//--- paramValueStr = _indenterSettings->value(pString.paramName + "/ValueDefault").toString(); +//--- paramValueStr = m_indenterSettings->value(pString.paramName + "/ValueDefault").toString(); //--- pString.lineEdit->setText(paramValueStr); //--- pString.valueEnabledChkBox->setChecked(false); //--- } @@ -867,34 +867,34 @@ void IndentHandler::contextMenuEvent(TQContextMenuEvent *event) //--- // parameter was not set in config file, so use default value //--- if (index == -1) //--- { -//--- int defaultValue = _indenterSettings->value(pMultiple.paramName + "/ValueDefault").toInt(); +//--- int defaultValue = m_indenterSettings->value(pMultiple.paramName + "/ValueDefault").toInt(); //--- pMultiple.comboBox->setCurrentIndex(defaultValue); //--- pMultiple.valueEnabledChkBox->setChecked(false); //--- } //--- } -//--- -//--- return true; -//--- } -//--- -//--- /* -//--- \brief Sets all indenter parameters to their default values defined in the ini file. -//--- */ -//--- void IndentHandler::resetToDefaultValues() -//--- { + + return true; +} + +/* + \brief Sets all indenter parameters to their default values defined in the ini file. + */ +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 = _indenterSettings->value(pBoolean.paramName + "/ValueDefault").toBool(); +//--- 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 = _indenterSettings->value(pNumeric.paramName + "/ValueDefault").toInt(); +//--- int defaultValue = m_indenterSettings->value(pNumeric.paramName + "/ValueDefault").toInt(); //--- pNumeric.spinBox->setValue(defaultValue); -//--- pNumeric.valueEnabledChkBox->setChecked(_indenterSettings->value( +//--- pNumeric.valueEnabledChkBox->setChecked(m_indenterSettings->value( //--- pNumeric.paramName + "/Enabled").toBool()); //--- } //--- @@ -902,31 +902,36 @@ void IndentHandler::contextMenuEvent(TQContextMenuEvent *event) //--- foreach(ParamString pString, _paramStrings) //--- { //--- TQString defaultValue = -//--- _indenterSettings->value(pString.paramName + "/ValueDefault").toString(); +//--- m_indenterSettings->value(pString.paramName + "/ValueDefault").toString(); //--- pString.lineEdit->setText(defaultValue); -//--- pString.valueEnabledChkBox->setChecked(_indenterSettings->value( +//--- 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 = _indenterSettings->value(pMultiple.paramName + "/ValueDefault").toInt(); +//--- int defaultValue = m_indenterSettings->value(pMultiple.paramName + "/ValueDefault").toInt(); //--- pMultiple.comboBox->setCurrentIndex(defaultValue); -//--- pMultiple.valueEnabledChkBox->setChecked(_indenterSettings->value(pMultiple.paramName + +//--- pMultiple.valueEnabledChkBox->setChecked(m_indenterSettings->value(pMultiple.paramName + //--- "/Enabled").toBool()); //--- } -//--- } -//--- -//--- /* -//--- \brief Opens and parses the indenter ini file that is declared by \a iniFilePath. -//--- */ -//--- void IndentHandler::readIndentIniFile(TQString iniFilePath) -//--- { -//--- Q_ASSERT_X(!iniFilePath.isEmpty(), "readIndentIniFile", "iniFilePath is empty"); -//--- +} + +/* + \brief Opens and parses the indenter ini file that is declared by \a iniFilePath. + */ +void IndentHandler::readIndentIniFile(const TQString &iniFilePath) +{ + if (iniFilePath.isEmpty()) + { + m_errorMessageDialog->showMessage(tr("readIndentIniFile"), + tr("The iniFilePath for the indenter file is empty")); + return; + } + //--- // open the ini-file that contains all available indenter settings with their additional infos -//--- _indenterSettings = new UiGuiIniFileParser(iniFilePath); +//--- m_indenterSettings = new UiGuiIniFileParser(iniFilePath); //--- //--- TQStringList categories; //--- //TQString indenterGroupString = ""; @@ -936,36 +941,36 @@ void IndentHandler::contextMenuEvent(TQContextMenuEvent *event) //--- // parse ini file indenter header //--- // //--- -//--- _indenterName = _indenterSettings->value("header/indenterName").toString(); -//--- _indenterFileName = _indenterSettings->value("header/indenterFileName").toString(); -//--- _globalConfigFilename = _indenterSettings->value("header/configFilename").toString(); -//--- _useCfgFileParameter = _indenterSettings->value("header/useCfgFileParameter").toString(); -//--- _cfgFileParameterEnding = _indenterSettings->value("header/cfgFileParameterEnding").toString(); +//--- _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 = _indenterSettings->value("header/showHelpParameter").toString(); +//--- _indenterShowHelpParameter = m_indenterSettings->value("header/showHelpParameter").toString(); //--- -//--- if (_indenterFileName.isEmpty()) +//--- if (m_indenterFileName.isEmpty()) //--- { -//--- _errorMessageDialog->showMessage(tr("Indenter ini file header error"), tr( +//--- 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 = _indenterSettings->value("header/parameterOrder", "pio").toString(); -//--- _inputFileParameter = _indenterSettings->value("header/inputFileParameter").toString(); -//--- _inputFileName = _indenterSettings->value("header/inputFileName").toString(); -//--- _outputFileParameter = _indenterSettings->value("header/outputFileParameter").toString(); -//--- _outputFileName = _indenterSettings->value("header/outputFileName").toString(); -//--- _fileTypes = _indenterSettings->value("header/fileTypes").toString(); +//--- _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 = _indenterSettings->value("header/categories").toString(); +//--- 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()) @@ -995,7 +1000,7 @@ void IndentHandler::contextMenuEvent(TQContextMenuEvent *event) //--- // //--- //--- // read all possible parameters written in brackets [] -//--- _indenterParameters = _indenterSettings->childGroups(); +//--- _indenterParameters = m_indenterSettings->childGroups(); //--- //--- // read each parameter to create the corresponding input field //--- foreach(TQString indenterParameter, _indenterParameters) @@ -1005,25 +1010,25 @@ void IndentHandler::contextMenuEvent(TQContextMenuEvent *event) //--- if (indenterParameter != "header") //--- { //--- // read to which category the parameter belongs -//--- int category = _indenterSettings->value(indenterParameter + "/Category").toInt(); +//--- 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 = _indenterSettings->value(indenterParameter + "/EditorType").toString(); +//--- 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 = -//--- _indenterSettings->value(indenterParameter + "/CallName").toString(); +//--- m_indenterSettings->value(indenterParameter + "/CallName").toString(); //--- //--- // create checkbox which enables or disables the parameter //--- TQCheckBox *chkBox = new TQCheckBox(_indenterParameterCategoryPages.at(category).widget); -//--- chkBox->setChecked(_indenterSettings->value(indenterParameter + "/Enabled").toBool()); +//--- 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); @@ -1033,7 +1038,7 @@ void IndentHandler::contextMenuEvent(TQContextMenuEvent *event) //--- //--- // create the spinbox //--- TQSpinBox *spinBox = new TQSpinBox(_indenterParameterCategoryPages.at(category).widget); -//--- paramToolTip = _indenterSettings->value(indenterParameter + "/Description").toString(); +//--- paramToolTip = m_indenterSettings->value(indenterParameter + "/Description").toString(); //--- spinBox->setToolTip(paramToolTip); //--- spinBox->setMaximumWidth(50); //--- spinBox->setMinimumWidth(50); @@ -1041,17 +1046,17 @@ void IndentHandler::contextMenuEvent(TQContextMenuEvent *event) //--- { //--- spinBox->installEventFilter(m_mainWindow); //--- } -//--- if (_indenterSettings->value(indenterParameter + "/MinVal").toString() != "") +//--- if (m_indenterSettings->value(indenterParameter + "/MinVal").toString() != "") //--- { -//--- spinBox->setMinimum(_indenterSettings->value(indenterParameter + "/MinVal").toInt()); +//--- spinBox->setMinimum(m_indenterSettings->value(indenterParameter + "/MinVal").toInt()); //--- } //--- else //--- { //--- spinBox->setMinimum(0); //--- } -//--- if (_indenterSettings->value(indenterParameter + "/MaxVal").toString() != "") +//--- if (m_indenterSettings->value(indenterParameter + "/MaxVal").toString() != "") //--- { -//--- spinBox->setMaximum(_indenterSettings->value(indenterParameter + "/MaxVal").toInt()); +//--- spinBox->setMaximum(m_indenterSettings->value(indenterParameter + "/MaxVal").toInt()); //--- } //--- else //--- { @@ -1082,7 +1087,7 @@ void IndentHandler::contextMenuEvent(TQContextMenuEvent *event) //--- paramNumeric.spinBox = spinBox; //--- paramNumeric.label = label; //--- paramNumeric.valueEnabledChkBox = chkBox; -//--- paramNumeric.spinBox->setValue(_indenterSettings->value(paramNumeric.paramName + +//--- paramNumeric.spinBox->setValue(m_indenterSettings->value(paramNumeric.paramName + //--- "/ValueDefault").toInt()); //--- _paramNumerics.append(paramNumeric); //--- @@ -1096,7 +1101,7 @@ void IndentHandler::contextMenuEvent(TQContextMenuEvent *event) //--- // 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 = _indenterSettings->value(indenterParameter + "/Description").toString(); +//--- paramToolTip = m_indenterSettings->value(indenterParameter + "/Description").toString(); //--- chkBox->setToolTip(paramToolTip); //--- if (m_mainWindow != nullptr) //--- { @@ -1109,10 +1114,10 @@ void IndentHandler::contextMenuEvent(TQContextMenuEvent *event) //--- paramBoolean.paramName = indenterParameter; //--- paramBoolean.checkBox = chkBox; //--- TQStringList trueFalseStrings = -//--- _indenterSettings->value(indenterParameter + "/TrueFalse").toString().split("|"); +//--- m_indenterSettings->value(indenterParameter + "/TrueFalse").toString().split("|"); //--- paramBoolean.trueString = trueFalseStrings.at(0); //--- paramBoolean.falseString = trueFalseStrings.at(1); -//--- paramBoolean.checkBox->setChecked(_indenterSettings->value(paramBoolean.paramName + +//--- paramBoolean.checkBox->setChecked(m_indenterSettings->value(paramBoolean.paramName + //--- "/ValueDefault").toBool()); //--- _paramBooleans.append(paramBoolean); //--- @@ -1123,11 +1128,11 @@ void IndentHandler::contextMenuEvent(TQContextMenuEvent *event) //--- { //--- // read the parameter name as it is used at the command line or in its config file //--- TQString parameterCallName = -//--- _indenterSettings->value(indenterParameter + "/CallName").toString(); +//--- 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(_indenterSettings->value(indenterParameter + "/Enabled").toBool()); +//--- 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); @@ -1137,7 +1142,7 @@ void IndentHandler::contextMenuEvent(TQContextMenuEvent *event) //--- //--- // create the line edit //--- TQLineEdit *lineEdit = new TQLineEdit(_indenterParameterCategoryPages.at(category).widget); -//--- paramToolTip = _indenterSettings->value(indenterParameter + "/Description").toString(); +//--- paramToolTip = m_indenterSettings->value(indenterParameter + "/Description").toString(); //--- lineEdit->setToolTip(paramToolTip); //--- lineEdit->setMaximumWidth(50); //--- lineEdit->setMinimumWidth(50); @@ -1171,7 +1176,7 @@ void IndentHandler::contextMenuEvent(TQContextMenuEvent *event) //--- paramString.lineEdit = lineEdit; //--- paramString.label = label; //--- paramString.valueEnabledChkBox = chkBox; -//--- paramString.lineEdit->setText(_indenterSettings->value(paramString.paramName + +//--- paramString.lineEdit->setText(m_indenterSettings->value(paramString.paramName + //--- "/ValueDefault").toString()); //--- _paramStrings.append(paramString); //--- @@ -1184,11 +1189,11 @@ void IndentHandler::contextMenuEvent(TQContextMenuEvent *event) //--- { //--- // read the parameter name as it is used at the command line or in its config file //--- TQString parameterCallName = -//--- _indenterSettings->value(indenterParameter + "/CallName").toString(); +//--- m_indenterSettings->value(indenterParameter + "/CallName").toString(); //--- //--- // create checkbox which enables or disables the parameter //--- TQCheckBox *chkBox = new TQCheckBox(_indenterParameterCategoryPages.at(category).widget); -//--- chkBox->setChecked(_indenterSettings->value(indenterParameter + "/Enabled").toBool()); +//--- 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); @@ -1200,8 +1205,8 @@ void IndentHandler::contextMenuEvent(TQContextMenuEvent *event) //--- TQComboBox *comboBox = new TQComboBox(_indenterParameterCategoryPages.at( //--- category).widget); //--- TQStringList choicesStrings = -//--- _indenterSettings->value(indenterParameter + "/Choices").toString().split("|"); -//--- TQStringList choicesStringsReadable = _indenterSettings->value( +//--- m_indenterSettings->value(indenterParameter + "/Choices").toString().split("|"); +//--- TQStringList choicesStringsReadable = m_indenterSettings->value( //--- indenterParameter + "/ChoicesReadable").toString().split("|", TQString::SkipEmptyParts); //--- if (choicesStringsReadable.isEmpty()) //--- { @@ -1211,7 +1216,7 @@ void IndentHandler::contextMenuEvent(TQContextMenuEvent *event) //--- { //--- comboBox->addItems(choicesStringsReadable); //--- } -//--- paramToolTip = _indenterSettings->value(indenterParameter + "/Description").toString(); +//--- paramToolTip = m_indenterSettings->value(indenterParameter + "/Description").toString(); //--- comboBox->setToolTip(paramToolTip); //--- if (m_mainWindow != nullptr) //--- { @@ -1232,7 +1237,7 @@ void IndentHandler::contextMenuEvent(TQContextMenuEvent *event) //--- paramMultiple.choicesStrings = choicesStrings; //--- paramMultiple.choicesStringsReadable = choicesStringsReadable; //--- paramMultiple.valueEnabledChkBox = chkBox; -//--- paramMultiple.comboBox->setCurrentIndex(_indenterSettings->value(paramMultiple.paramName + +//--- paramMultiple.comboBox->setCurrentIndex(m_indenterSettings->value(paramMultiple.paramName + //--- "/ValueDefault").toInt()); //--- _paramMultiples.append(paramMultiple); //--- @@ -1248,20 +1253,20 @@ void IndentHandler::contextMenuEvent(TQContextMenuEvent *event) //--- { //--- categoryPage.vboxLayout->addStretch(); //--- } -//--- } -//--- -//--- /* -//--- \brief Searches and returns all indenters a configuration file is found for. -//--- -//--- Opens all uigui ini files found in the list \a _indenterIniFileList, opens each ini file -//--- and reads the there defined real name of the indenter. These names are being returned as TQStringList. -//--- */ -//--- TQStringList IndentHandler::getAvailableIndenters() -//--- { -//--- TQStringList indenterNamesList; +} + +/* + \brief Searches and returns all indenters a configuration file is found for. + + Opens all uigui ini files found in the list \a m_indenterIniFileList, opens each ini file + and reads the there defined real name of the indenter. These names are being returned as TQStringList. + */ +TQStringList IndentHandler::getAvailableIndenters() +{ + TQStringList indenterNamesList; //--- //--- // Loop for every existing uigui ini file -//--- foreach(TQString indenterIniFile, _indenterIniFileList) +//--- foreach(TQString indenterIniFile, m_indenterIniFileList) //--- { //--- // Open the ini file and search for the indenter name //--- TQFile file(m_indenterDirectoryStr + "/" + indenterIniFile); @@ -1283,8 +1288,8 @@ void IndentHandler::contextMenuEvent(TQContextMenuEvent *event) //--- } //--- } //--- } -//--- return indenterNamesList; -//--- } + return indenterNamesList; +} /* \brief Deletes all elements in the toolbox and initializes the indenter selected by \a indenterID. @@ -1295,9 +1300,9 @@ void IndentHandler::setIndenter(int indenterID) //--- //--- // Generate the parameter string that will be saved to the indenters config file. //--- TQString parameterString = getParameterString(); -//--- if (!_indenterFileName.isEmpty()) +//--- if (!m_indenterFileName.isEmpty()) //--- { -//--- saveConfigFile(m_settingsDirectoryStr + "/" + _indenterFileName + ".cfg", parameterString); +//--- saveConfigFile(m_settingsDirectoryStr + "/" + m_indenterFileName + ".cfg", parameterString); //--- } //--- //--- // Take care if the selected indenterID is smaller or greater than the number of existing @@ -1306,9 +1311,9 @@ void IndentHandler::setIndenter(int indenterID) //--- { //--- indenterID = 0; //--- } -//--- if (indenterID >= _indenterIniFileList.count()) +//--- if (indenterID >= m_indenterIniFileList.count()) //--- { -//--- indenterID = _indenterIniFileList.count() - 1; +//--- indenterID = m_indenterIniFileList.count() - 1; //--- } //--- //--- // MIKE: TODO: need to save selected indenterID into Settings @@ -1331,15 +1336,15 @@ void IndentHandler::setIndenter(int indenterID) //--- _paramNumerics.clear(); //--- _paramBooleans.clear(); //--- _paramMultiples.clear(); -//--- delete _indenterSettings; +//--- delete m_indenterSettings; //--- -//--- readIndentIniFile(m_indenterDirectoryStr + "/" + _indenterIniFileList.at(indenterID)); +//--- 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 + "/" + _indenterFileName + ".cfg"); +//--- loadConfigFile(m_settingsDirectoryStr + "/" + m_indenterFileName + ".cfg"); //--- //--- handleChangedIndenterSettings(); //--- @@ -1353,24 +1358,24 @@ void IndentHandler::setIndenter(int indenterID) //--- { //--- return _fileTypes; //--- } -//--- -//--- /* -//--- \brief Returns the path and filename of the current indenter config file. -//--- */ -//--- TQString IndentHandler::getIndenterCfgFile() -//--- { -//--- TQFileInfo fileInfo(m_indenterDirectoryStr + "/" + _globalConfigFilename); -//--- return fileInfo.absoluteFilePath(); -//--- } -//--- -//--- /* -//--- \brief Tries to create a call path string for the indenter executable. If successful returns true. -//--- */ -//--- bool IndentHandler::createIndenterCallString() -//--- { + +/* + \brief Returns the path and filename of the current indenter config file. + */ +TQString IndentHandler::getIndenterCfgFile() +{ + TQFileInfo fileInfo(m_indenterDirectoryStr + "/" + m_globalConfigFilename); + return fileInfo.absFilePath(); +} + +/* + \brief Tries to create a call path string for the indenter executable. If successful returns true. + */ +bool IndentHandler::createIndenterCallString() +{ //--- TQProcess indentProcess; //--- -//--- if (_indenterFileName.isEmpty()) +//--- if (m_indenterFileName.isEmpty()) //--- { //--- return false; //--- } @@ -1385,7 +1390,7 @@ void IndentHandler::setIndenter(int indenterID) //--- { //--- m_indenterExecutableSuffix = suffix; //--- m_indenterExecutableCallString = TQFileInfo(m_indenterDirectoryStr).absoluteFilePath() + "/" + -//--- _indenterFileName; +//--- m_indenterFileName; //--- m_indenterExecutableCallString += suffix; //--- //--- // Only try to call the indenter, if the file exists. @@ -1453,7 +1458,7 @@ void IndentHandler::setIndenter(int indenterID) //--- // now we know an interpreter is needed but it could not be called, so inform the user. //--- else //--- { -//--- _errorMessageDialog->showMessage(tr("Interpreter needed"), tr( +//--- m_errorMessageDialog->showMessage(tr("Interpreter needed"), tr( //--- "To use the selected indenter the program \"%1\" needs to be available in the global environment. You should add an entry to your path settings.").arg( //--- interpreterName)); //--- return true; @@ -1466,7 +1471,7 @@ void IndentHandler::setIndenter(int indenterID) //--- // ------------------------------------------------------------------- //--- m_indenterExecutableSuffix = ".js"; //--- m_indenterExecutableCallString = TQFileInfo(m_indenterDirectoryStr).absoluteFilePath() + "/" + -//--- _indenterFileName; +//--- m_indenterFileName; //--- m_indenterExecutableCallString += m_indenterExecutableSuffix; //--- if (TQFile::exists(m_indenterExecutableCallString)) //--- { @@ -1478,7 +1483,7 @@ void IndentHandler::setIndenter(int indenterID) //--- foreach(TQString suffix, TQStringList() << "" << ".exe" << ".bat" << ".com" << ".sh") //--- { //--- m_indenterExecutableSuffix = suffix; -//--- m_indenterExecutableCallString = _indenterFileName + suffix; +//--- m_indenterExecutableCallString = m_indenterFileName + suffix; //--- indentProcess.start(m_indenterExecutableCallString + " " + _indenterShowHelpParameter); //--- if (indentProcess.waitForFinished(2000)) //--- { @@ -1493,19 +1498,19 @@ void IndentHandler::setIndenter(int indenterID) //--- // If even globally calling the indenter fails, try calling .com and .exe via wine //--- // ------------------------------------------------------------------------------- //--- m_indenterExecutableCallString = "\"" + TQFileInfo(m_indenterDirectoryStr).absoluteFilePath() + "/" + -//--- _indenterFileName; +//--- m_indenterFileName; //--- //--- foreach(TQString suffix, TQStringList() << ".exe" << ".com") //--- { //--- m_indenterExecutableSuffix = suffix; -//--- if (TQFile::exists(m_indenterDirectoryStr + "/" + _indenterFileName + suffix)) +//--- if (TQFile::exists(m_indenterDirectoryStr + "/" + m_indenterFileName + suffix)) //--- { //--- TQProcess wineTestProcess; //--- wineTestProcess.start("wine --version"); //--- // if the process of wine was not callable assume that wine is not installed //--- if (!wineTestProcess.waitForFinished(2000)) //--- { -//--- _errorMessageDialog->showMessage(tr("wine not installed"), tr( +//--- m_errorMessageDialog->showMessage(tr("wine not installed"), tr( //--- "There exists only a win32 executable of the indenter and wine does not seem to be installed. Please install wine to be able to run the indenter.")); //--- m_indenterExecutableCallString = ""; //--- return false; @@ -1514,7 +1519,7 @@ void IndentHandler::setIndenter(int indenterID) //--- { //--- m_indenterExecutableCallString = "\"" + //--- TQFileInfo(m_indenterDirectoryStr).absoluteFilePath() + "/"; -//--- m_indenterExecutableCallString += _indenterFileName + suffix + "\""; +//--- m_indenterExecutableCallString += m_indenterFileName + suffix + "\""; //--- m_indenterExecutableCallString = "wine " + m_indenterExecutableCallString; //--- //--- return true; @@ -1524,17 +1529,17 @@ void IndentHandler::setIndenter(int indenterID) //--- //--- m_indenterExecutableCallString = ""; //--- m_indenterExecutableSuffix = ""; -//--- return false; -//--- } -//--- + return false; +} + //--- /* //--- \brief Returns a string that points to where the indenters manual can be found. //--- */ //--- TQString IndentHandler::getManual() //--- { -//--- if (_indenterSettings != nullptr) +//--- if (m_indenterSettings != nullptr) //--- { -//--- return _indenterSettings->value("header/manual").toString(); +//--- return m_indenterSettings->value("header/manual").toString(); //--- } //--- else //--- { @@ -1575,19 +1580,17 @@ void IndentHandler::showIndenterManual() const */ void IndentHandler::openConfigFileDialog() { -//--- TQString configFilePath; -//--- -//--- configFilePath = TQFileDialog::getOpenFileName(nullptr, tr( -//--- "Choose indenter config file"), getIndenterCfgFile(), "All files (*.*)"); -//--- -//--- if (configFilePath != "") -//--- { -//--- // If the config file was loaded successfully, inform any who is interested about it. -//--- if (loadConfigFile(configFilePath)) -//--- { -//--- handleChangedIndenterSettings(); -//--- } -//--- } + TQString configFilePath = TQFileDialog::getOpenFileName(getIndenterCfgFile(), "All files (*.*)", + nullptr, nullptr, tr("Choose indenter config file")); + + if (!configFilePath.isEmpty()) + { + // If the config file was loaded successfully, inform any who is interested about it. + if (loadConfigFile(configFilePath)) + { + handleChangedIndenterSettings(); + } + } } /* @@ -1645,7 +1648,7 @@ void IndentHandler::createIndenterCallShellScript() //--- if (outSrcFile.open(TQFile::ReadWrite | TQFile::Text)) //--- { //--- TQString shellScriptConfigFilename = TQFileInfo(shellScriptFileName).baseName() + "." + -//--- TQFileInfo(_globalConfigFilename).suffix(); +//--- TQFileInfo(m_globalConfigFilename).suffix(); //--- //--- // Get the content of the shell/batch script. //--- TQString indenterCallShellScript = generateShellScript(shellScriptConfigFilename); @@ -1662,7 +1665,7 @@ void IndentHandler::createIndenterCallShellScript() //--- //--- // Save the indenter config file to the same directory, where the shell srcipt was saved to, //--- // because the script will reference it there via "./". -//--- if (!_globalConfigFilename.isEmpty()) +//--- if (!m_globalConfigFilename.isEmpty()) //--- { //--- saveConfigFile(TQFileInfo( //--- shellScriptFileName).path() + "/" + shellScriptConfigFilename, @@ -1677,13 +1680,13 @@ void IndentHandler::createIndenterCallShellScript() */ void IndentHandler::resetIndenterParameter() { -//--- int messageBoxAnswer = TQMessageBox::question(this, tr("Really reset parameters?"), tr( -//--- "Do you really want to reset the indenter parameters to the default values?"), -//--- TQMessageBox::Yes | TQMessageBox::Abort); -//--- if (messageBoxAnswer == TQMessageBox::Yes) -//--- { -//--- resetToDefaultValues(); -//--- } + int messageBoxAnswer = TQMessageBox::question(this, tr("Really reset parameters?"), + tr("Do you really want to reset the indenter parameters to the default values?"), + TQMessageBox::Yes, TQMessageBox::Cancel); + if (messageBoxAnswer == TQMessageBox::Yes) + { + resetToDefaultValues(); + } } //--- /* @@ -1709,15 +1712,15 @@ void IndentHandler::resetIndenterParameter() //--- return TQWidget::event(event); //--- } //--- } -//--- -//--- /* -//--- \brief Emits the \a indenterSettingsChanged signal -//--- */ -//--- void IndentHandler::handleChangedIndenterSettings() -//--- { -//--- emit(indenterSettingsChanged()); -//--- } -//--- + +/* + \brief Emits the \a indenterSettingsChanged signal + */ +void IndentHandler::handleChangedIndenterSettings() +{ + emit(indenterSettingsChanged()); +} + //--- /* //--- \brief Returns the id (list index) of the currently selected indenter. //--- */ diff --git a/src/IndentHandler.h b/src/IndentHandler.h index d7b9239..97b00d1 100644 --- a/src/IndentHandler.h +++ b/src/IndentHandler.h @@ -23,7 +23,7 @@ #include <tqwidget.h> class MainWindow; -///-- class UiGuiErrorMessage; +class UiGuiErrorMessage; ///-- class UiGuiIniFileParser; class TQComboBox; @@ -47,21 +47,21 @@ class IndentHandler : public TQWidget ///-- TQString generateShellScript(const TQString &configFilename); ///-- TQString callIndenter(TQString sourceCode, TQString inputFileExtension); -///-- bool loadConfigFile(TQString filePathName); -///-- void resetToDefaultValues(); -///-- TQStringList getAvailableIndenters(); + bool loadConfigFile(const TQString &filePathName); + void resetToDefaultValues(); + TQStringList getAvailableIndenters(); ///-- TQString getPossibleIndenterFileExtensions(); -///-- TQString getParameterString(); -///-- TQString getIndenterCfgFile(); + TQString getParameterString(); + TQString getIndenterCfgFile(); ///-- TQString getManual(); ///-- TQString getCurrentIndenterName(); void contextMenuEvent(TQContextMenuEvent *event); ///-- int getIndenterId(); ///-- -///-- signals: -///-- void indenterSettingsChanged(); + signals: + void indenterSettingsChanged(); ///-- void selectedIndenterIndexChanged(int index); -///-- + ///-- protected: ///-- bool event(TQEvent *event); ///-- void wheelEvent(TQWheelEvent *event); @@ -73,14 +73,14 @@ class IndentHandler : public TQWidget void saveasIndentCfgFileDialog(); void createIndenterCallShellScript(); void resetIndenterParameter(); -///-- void handleChangedIndenterSettings(); -///-- -///-- private: + void handleChangedIndenterSettings(); + + private: ///-- TQString callExecutableIndenter(TQString sourceCode, TQString inputFileExtension); ///-- TQString callJavaScriptIndenter(TQString sourceCode); -///-- void saveConfigFile(TQString filePathName, TQString parameterString); -///-- void readIndentIniFile(TQString iniFilePath); -///-- bool createIndenterCallString(); + void saveConfigFile(const TQString &filePathName, const TQString ¶meterString); + void readIndentIniFile(const TQString &iniFilePath); + bool createIndenterCallString(); ///-- ///-- // Holds a reference to all created pages of the parameter categories toolbox and the pages ///-- // boxlayout @@ -146,18 +146,18 @@ class IndentHandler : public TQWidget ///-- // Vertical layout box, into which the toolbox will be added TQVBoxLayout *m_toolBoxContainerLayout; TQToolBox *m_indenterParameterCategoriesToolBox; -///-- UiGuiIniFileParser *_indenterSettings; +///-- 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 -///-- TQString _indenterFileName; + TQString m_indenterFileName; TQString m_indenterDirectoryStr; TQString m_tempDirectoryStr; TQString m_settingsDirectoryStr; -///-- TQStringList _indenterIniFileList; + TQStringList m_indenterIniFileList; ///-- TQString _parameterOrder; -///-- TQString _globalConfigFilename; + TQString m_globalConfigFilename; ///-- TQString _cfgFileParameterEnding; ///-- TQString _inputFileParameter; ///-- TQString _inputFileName; @@ -168,7 +168,7 @@ class IndentHandler : public TQWidget ///-- TQString _indenterShowHelpParameter; MainWindow *m_mainWindow; TQWidget *m_parent; -///-- UiGuiErrorMessage *_errorMessageDialog; + UiGuiErrorMessage *m_errorMessageDialog; TQString m_indenterExecutableCallString; TQString m_indenterExecutableSuffix; ///-- diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 36700d4..5c50627 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -464,10 +464,10 @@ void MainWindow::initIndenter() m_indentHandler = new IndentHandler(m_currentIndenterID, this, m_centralSplitter); m_centralSplitter->moveToFirst(m_indentHandler); -///-- // If _settings for the indenter have changed, let the main window know aboud it. -///-- connect(m_indentHandler, SIGNAL(indenterSettingsChanged()), this, -///-- SLOT(indentSettingsChangedSlot())); -///-- + // If _settings for the indenter have changed, let the main window know aboud it. + connect(m_indentHandler, SIGNAL(indenterSettingsChanged()), this, + SLOT(indentSettingsChangedSlot())); + ///-- // Set this true, so the indenter is called at first program start ///-- _indentSettingsChanged = true; ///-- m_previewToggled = true; @@ -864,14 +864,14 @@ void MainWindow::sourceCodeChangedSlot() ///-- //m_qSciSourceCodeEditor->SendScintilla(QsciScintillaBase::SCI_SETANCHOR, 50); } -///-- /* -///-- \brief This slot is called whenever one of the indenter _settings are changed. -///-- -///-- It calls the selected indenter if the preview is turned on. If preview -///-- is not active a flag is set, that the _settings have changed. -///-- */ -///-- void MainWindow::indentSettingsChangedSlot() -///-- { +/* + \brief This slot is called whenever one of the indenter settings are changed. + + It calls the selected indenter if the preview is turned on. If preview + is not active, set a flag to indicate that the settings have changed. + */ +void MainWindow::indentSettingsChangedSlot() +{ ///-- _indentSettingsChanged = true; ///-- ///-- int cursorLine, cursorPos; @@ -911,7 +911,7 @@ void MainWindow::sourceCodeChangedSlot() ///-- m_qSciSourceCodeEditor->setModified(true); // Has no effect according to TQScintilla docs. ///-- m_documentModified = true; ///-- } -///-- } +} /* \brief This slot is called whenever the preview button is turned on or off. diff --git a/src/MainWindow.h b/src/MainWindow.h index 61a9ff9..c259dd0 100644 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -66,7 +66,7 @@ class MainWindow : public MainWindowBase void setWhiteSpaceVisibility(bool visible); void sourceCodeChangedHelperSlot(); void sourceCodeChangedSlot(); -///-- void indentSettingsChangedSlot(); + void indentSettingsChangedSlot(); void previewTurnedOnOff(bool turnOn); void exportToPDF(); void exportToHTML(); diff --git a/src/__TODO/UiGuiErrorMessage.cpp b/src/UiGuiErrorMessage.cpp index 123a807..144a673 100644 --- a/src/__TODO/UiGuiErrorMessage.cpp +++ b/src/UiGuiErrorMessage.cpp @@ -19,11 +19,11 @@ #include "UiGuiErrorMessage.h" -#include <tntqcheckbox.h> +#include <ntqobjectdefs.h> +#include <tqcheckbox.h> /* \class UiGuiErrorMessage - \ingroup grp_Dialogs \brief UiGuiErrorMessage is a child of TQErrorMessage. But TQErrorMessages "Do not show again" didn't work with my strings, so this is my own, working implementation of it. @@ -32,16 +32,15 @@ /* \brief Initializes the dialog. - - Retrieves the object pointer to the \a _showAgainCheckBox check box, sets the dialogs + Retrieves the object pointer to the \a m_showAgainCheckBox check box, sets the dialogs modality and for a working translation sets the check box text. */ UiGuiErrorMessage::UiGuiErrorMessage(TQWidget *parent) : - TQErrorMessage(parent) + TQErrorMessage(parent) { - _showAgainCheckBox = findChild<TQCheckBox*>(); - setWindowModality(TQt::ApplicationModal); - _showAgainCheckBox->setText(tr("Show this message again")); + m_showAgainCheckBox = Q_CHILD(this, TQCheckBox, "again"); + setModal(true); + m_showAgainCheckBox->setText(tr("Show this message again")); } /* @@ -53,7 +52,6 @@ UiGuiErrorMessage::~UiGuiErrorMessage(void) /* \brief Shows an error \a message in a dialog box with \a title. - The shown \a message is added to a list, if not already in there. If it is already in that list and "Show this message again" is not checked, that message will not be shown. @@ -62,25 +60,25 @@ void UiGuiErrorMessage::showMessage(const TQString &title, const TQString &messa { bool showAgain = true; - if (_showAgainCheckBox != 0) + if (m_showAgainCheckBox) { - showAgain = _showAgainCheckBox->isChecked(); + showAgain = m_showAgainCheckBox->isChecked(); } - setWindowTitle(title); + setCaption(title); - if (!_errorMessageList.contains(message)) + if (!m_errorMessageList.contains(message)) { - _errorMessageList << message; - if (_showAgainCheckBox != 0) + m_errorMessageList << message; + if (m_showAgainCheckBox) { - _showAgainCheckBox->setChecked(true); + m_showAgainCheckBox->setChecked(true); } - TQErrorMessage::showMessage(message); + TQErrorMessage::message(message); } else if (showAgain) { - TQErrorMessage::showMessage(message); + TQErrorMessage::message(message); } } @@ -91,3 +89,5 @@ void UiGuiErrorMessage::showMessage(const TQString &message) { showMessage("UniversalIndentGUI", message); } + +#include "UiGuiErrorMessage.moc" diff --git a/src/__TODO/UiGuiErrorMessage.h b/src/UiGuiErrorMessage.h index 0ad9f70..480ec86 100644 --- a/src/__TODO/UiGuiErrorMessage.h +++ b/src/UiGuiErrorMessage.h @@ -20,7 +20,8 @@ #ifndef UIGUIERRORMESSAGE_H #define UIGUIERRORMESSAGE_H -#include <tntqerrormessage.h> +#include <tqerrormessage.h> +#include <tqstringlist.h> class TQCheckBox; @@ -30,15 +31,15 @@ class UiGuiErrorMessage : public TQErrorMessage Q_OBJECT public: - UiGuiErrorMessage(TQWidget *parent = 0); + UiGuiErrorMessage(TQWidget *parent = nullptr); ~UiGuiErrorMessage(void); void showMessage(const TQString &message); void showMessage(const TQString &title, const TQString &message); private: - TQCheckBox *_showAgainCheckBox; - TQStringList _errorMessageList; + TQCheckBox *m_showAgainCheckBox; + TQStringList m_errorMessageList; }; #endif // UIGUIERRORMESSAGE_H diff --git a/src/__TODO/UiGuiIniFileParser.cpp b/src/UiGuiIniFileParser.cpp index 9ff892d..bbfa39f 100644 --- a/src/__TODO/UiGuiIniFileParser.cpp +++ b/src/UiGuiIniFileParser.cpp @@ -19,23 +19,20 @@ #include "UiGuiIniFileParser.h" -#include <tntqfile.h> -#include <tntqstringlist.h> -#include <tntqvariant.h> -#include <tntqtextstream.h> - -// \defgroup grp_Settings All concerning applications settings. +#include <tqfile.h> +#include <tqstringlist.h> +#include <tqvariant.h> +#include <tqtextstream.h> /* \class UiGuiIniFileParser - \ingroup grp_Settings \brief UiGuiIniFileParser is a simple ini file format parser. These ini files need to have key-value pairs in the style - "keyname=keyvalue". Groups can be defined by writing the groupname + "key=value". Groups can be defined by writing the groupname in the style [groupname] before some key-value pairs. - The reason why I use my own class instead of TQSettings is mainly, that + The reason why I use my own class instead of TQSettings is mainly that TQSettings always internally sorts the groups alphabetically and also rewrites a settings file sorted. Very annoying for me. */ @@ -54,15 +51,15 @@ UiGuiIniFileParser::UiGuiIniFileParser(void) UiGuiIniFileParser::UiGuiIniFileParser(const TQString &iniFileName) { init(); - _iniFileName = iniFileName; + m_iniFileName = iniFileName; parseIniFile(); } void UiGuiIniFileParser::init() { - _sections.clear(); - _keyValueMap.clear(); - _iniFileName = ""; + m_sections.clear(); + m_keyValueMap.clear(); + m_iniFileName = TQString::null; } UiGuiIniFileParser::~UiGuiIniFileParser(void) @@ -74,14 +71,7 @@ UiGuiIniFileParser::~UiGuiIniFileParser(void) */ TQStringList UiGuiIniFileParser::childGroups() { - TQStringList sectionsStringList; - - for (unsigned int i = 0; i < _sections.size(); i++) - { - sectionsStringList << _sections[i]; - } - - return sectionsStringList; + return m_sections; } /* @@ -94,7 +84,11 @@ TQStringList UiGuiIniFileParser::childGroups() */ TQVariant UiGuiIniFileParser::value(const TQString &keyName, const TQString &defaultValue) { - return _keyValueMap.value(keyName, defaultValue); + if (m_keyValueMap.contains(keyName)) + { + return m_keyValueMap[keyName]; + } + return TQVariant(defaultValue); } /* @@ -102,37 +96,35 @@ TQVariant UiGuiIniFileParser::value(const TQString &keyName, const TQString &def */ void UiGuiIniFileParser::parseIniFile() { - TQFile iniFile(_iniFileName); + TQFile iniFile(m_iniFileName); - if (iniFile.open(TQFile::ReadOnly)) + if (iniFile.open(IO_ReadOnly)) { // Clear the vectors holding the keys and values. - _sections.clear(); - _keyValueMap.clear(); + m_sections.clear(); + m_keyValueMap.clear(); TQTextStream iniFileStream(&iniFile); TQString line; - TQString currentSectionName = ""; - TQString keyName = ""; - TQString valueAsString = ""; + TQString currentSectionName = TQString::null; + TQString keyName = TQString::null; + TQString valueAsString = TQString::null; while (!iniFileStream.atEnd()) { - line = iniFileStream.readLine().trimmed(); + line = iniFileStream.readLine().stripWhiteSpace(); // Test if the read line is a section name and if so remeber it. if (line.startsWith("[") && line.endsWith("]")) { - currentSectionName = line.remove(0, 1); - currentSectionName.chop(1); - // Store the section name. - _sections.push_back(currentSectionName); + currentSectionName = line.mid(1, line.length() - 2); + m_sections.push_back(currentSectionName); } // Otherwise test whether the line has a assign char else if (line.contains("=")) { - int indexOfFirstAssign = line.indexOf("="); + int indexOfFirstAssign = line.find("="); keyName = line.left(indexOfFirstAssign); if (!keyName.isEmpty()) @@ -141,8 +133,7 @@ void UiGuiIniFileParser::parseIniFile() // Remove any existing double quotes from the value. if (valueAsString.startsWith("\"") && valueAsString.endsWith("\"")) { - valueAsString = valueAsString.remove(0, 1); - valueAsString.chop(1); + valueAsString = valueAsString.mid(1, valueAsString.length() - 2); } // Prepend an eventually section name to the key name. @@ -152,7 +143,7 @@ void UiGuiIniFileParser::parseIniFile() } // Store the key and value in the map. - _keyValueMap.insert(keyName, valueAsString); + m_keyValueMap.insert(keyName, valueAsString); } } } diff --git a/src/__TODO/UiGuiIniFileParser.h b/src/UiGuiIniFileParser.h index 0aebb09..cd2c9ee 100644 --- a/src/__TODO/UiGuiIniFileParser.h +++ b/src/UiGuiIniFileParser.h @@ -20,10 +20,9 @@ #ifndef UIGUIINIFILEPARSER_H #define UIGUIINIFILEPARSER_H -#include <tntqmap.h> -#include <tntqstring.h> - -#include <vector> +#include <tqmap.h> +#include <tqstring.h> +#include <tqstringlist.h> class TQStringList; class TQVariant; @@ -36,7 +35,7 @@ class UiGuiIniFileParser UiGuiIniFileParser(const TQString &iniFileName); ~UiGuiIniFileParser(void); - TQVariant value(const TQString &keyName, const TQString &defaultValue = ""); + TQVariant value(const TQString &keyName, const TQString &defaultValue = TQString::null); TQStringList childGroups(); protected: @@ -45,9 +44,9 @@ class UiGuiIniFileParser private: void parseIniFile(); - TQString _iniFileName; - std::vector<TQString> _sections; - TQMap<TQString, TQVariant> _keyValueMap; + TQString m_iniFileName; + TQStringList m_sections; + TQMap<TQString, TQVariant> m_keyValueMap; }; -#endif // UIGUIINIFILEPARSER_H +#endif |