diff options
author | Michele Calgaro <michele.calgaro@yahoo.it> | 2023-05-31 19:27:38 +0900 |
---|---|---|
committer | Michele Calgaro <michele.calgaro@yahoo.it> | 2023-05-31 19:27:45 +0900 |
commit | 44f39b628c487af77c0a503d622d57b99748e1e1 (patch) | |
tree | 96d32a035106586720de7905e7fb19f009a5829c /src/__TODO | |
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 <michele.calgaro@yahoo.it>
Diffstat (limited to 'src/__TODO')
-rw-r--r-- | src/__TODO/UiGuiErrorMessage.cpp | 93 | ||||
-rw-r--r-- | src/__TODO/UiGuiErrorMessage.h | 44 | ||||
-rw-r--r-- | src/__TODO/UiGuiIniFileParser.cpp | 160 | ||||
-rw-r--r-- | src/__TODO/UiGuiIniFileParser.h | 53 |
4 files changed, 0 insertions, 350 deletions
diff --git a/src/__TODO/UiGuiErrorMessage.cpp b/src/__TODO/UiGuiErrorMessage.cpp deleted file mode 100644 index 123a807..0000000 --- a/src/__TODO/UiGuiErrorMessage.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006-2012 by Thomas Schweitzer * - * thomas-schweitzer(at)arcor.de * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License version 2.0 as * - * published by the Free Software Foundation. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program in the file LICENSE.GPL; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ - -#include "UiGuiErrorMessage.h" - -#include <tntqcheckbox.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. -*/ - - -/* - \brief Initializes the dialog. - - Retrieves the object pointer to the \a _showAgainCheckBox check box, sets the dialogs - modality and for a working translation sets the check box text. - */ -UiGuiErrorMessage::UiGuiErrorMessage(TQWidget *parent) : - TQErrorMessage(parent) -{ - _showAgainCheckBox = findChild<TQCheckBox*>(); - setWindowModality(TQt::ApplicationModal); - _showAgainCheckBox->setText(tr("Show this message again")); -} - -/* - \brief Just a lazy nothin doin destructive destructor. - */ -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. - */ -void UiGuiErrorMessage::showMessage(const TQString &title, const TQString &message) -{ - bool showAgain = true; - - if (_showAgainCheckBox != 0) - { - showAgain = _showAgainCheckBox->isChecked(); - } - - setWindowTitle(title); - - if (!_errorMessageList.contains(message)) - { - _errorMessageList << message; - if (_showAgainCheckBox != 0) - { - _showAgainCheckBox->setChecked(true); - } - TQErrorMessage::showMessage(message); - } - else if (showAgain) - { - TQErrorMessage::showMessage(message); - } -} - -/* - \brief For convinience, for showing a dialog box with the default title "UniversalIndentGUI". - */ -void UiGuiErrorMessage::showMessage(const TQString &message) -{ - showMessage("UniversalIndentGUI", message); -} diff --git a/src/__TODO/UiGuiErrorMessage.h b/src/__TODO/UiGuiErrorMessage.h deleted file mode 100644 index 0ad9f70..0000000 --- a/src/__TODO/UiGuiErrorMessage.h +++ /dev/null @@ -1,44 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006-2012 by Thomas Schweitzer * - * thomas-schweitzer(at)arcor.de * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License version 2.0 as * - * published by the Free Software Foundation. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program in the file LICENSE.GPL; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ - -#ifndef UIGUIERRORMESSAGE_H -#define UIGUIERRORMESSAGE_H - -#include <tntqerrormessage.h> - -class TQCheckBox; - - -class UiGuiErrorMessage : public TQErrorMessage -{ - Q_OBJECT - - public: - UiGuiErrorMessage(TQWidget *parent = 0); - ~UiGuiErrorMessage(void); - - void showMessage(const TQString &message); - void showMessage(const TQString &title, const TQString &message); - - private: - TQCheckBox *_showAgainCheckBox; - TQStringList _errorMessageList; -}; - -#endif // UIGUIERRORMESSAGE_H diff --git a/src/__TODO/UiGuiIniFileParser.cpp b/src/__TODO/UiGuiIniFileParser.cpp deleted file mode 100644 index 9ff892d..0000000 --- a/src/__TODO/UiGuiIniFileParser.cpp +++ /dev/null @@ -1,160 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006-2012 by Thomas Schweitzer * - * thomas-schweitzer(at)arcor.de * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License version 2.0 as * - * published by the Free Software Foundation. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program in the file LICENSE.GPL; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ - -#include "UiGuiIniFileParser.h" - -#include <tntqfile.h> -#include <tntqstringlist.h> -#include <tntqvariant.h> -#include <tntqtextstream.h> - -// \defgroup grp_Settings All concerning applications settings. - -/* - \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 - in the style [groupname] before some key-value pairs. - - 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. -*/ - -/* - \brief Init and empty all needed lists and strings. - */ -UiGuiIniFileParser::UiGuiIniFileParser(void) -{ - init(); -} - -/* - \brief Directly loads and parses the file with name \a iniFileName. - */ -UiGuiIniFileParser::UiGuiIniFileParser(const TQString &iniFileName) -{ - init(); - _iniFileName = iniFileName; - parseIniFile(); -} - -void UiGuiIniFileParser::init() -{ - _sections.clear(); - _keyValueMap.clear(); - _iniFileName = ""; -} - -UiGuiIniFileParser::~UiGuiIniFileParser(void) -{ -} - -/* - \brief Returns the group/section names in the same order as they occurr in the ini file as TQStringList. - */ -TQStringList UiGuiIniFileParser::childGroups() -{ - TQStringList sectionsStringList; - - for (unsigned int i = 0; i < _sections.size(); i++) - { - sectionsStringList << _sections[i]; - } - - return sectionsStringList; -} - -/* - \brief Returns the value of the defined \a keyName as TQVariant. - - The \a keyName is assembled by a section name, a slash and the key name itself. - For example if you wish to access the value of the following setting: - <code>[NiceSection]</br>niceKeyName=2</code> you would have to call - value("NiceSection/niceKeyName"). - */ -TQVariant UiGuiIniFileParser::value(const TQString &keyName, const TQString &defaultValue) -{ - return _keyValueMap.value(keyName, defaultValue); -} - -/* - \brief Parses the ini file and stores the key value pairs in the internal vectors \a keys and \a values. - */ -void UiGuiIniFileParser::parseIniFile() -{ - TQFile iniFile(_iniFileName); - - if (iniFile.open(TQFile::ReadOnly)) - { - // Clear the vectors holding the keys and values. - _sections.clear(); - _keyValueMap.clear(); - - TQTextStream iniFileStream(&iniFile); - TQString line; - TQString currentSectionName = ""; - TQString keyName = ""; - TQString valueAsString = ""; - - while (!iniFileStream.atEnd()) - { - line = iniFileStream.readLine().trimmed(); - - // 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); - } - // Otherwise test whether the line has a assign char - else if (line.contains("=")) - { - int indexOfFirstAssign = line.indexOf("="); - keyName = line.left(indexOfFirstAssign); - - if (!keyName.isEmpty()) - { - valueAsString = line.remove(0, indexOfFirstAssign + 1); - // Remove any existing double quotes from the value. - if (valueAsString.startsWith("\"") && valueAsString.endsWith("\"")) - { - valueAsString = valueAsString.remove(0, 1); - valueAsString.chop(1); - } - - // Prepend an eventually section name to the key name. - if (!currentSectionName.isEmpty()) - { - keyName = currentSectionName + "/" + keyName; - } - - // Store the key and value in the map. - _keyValueMap.insert(keyName, valueAsString); - } - } - } - } -} diff --git a/src/__TODO/UiGuiIniFileParser.h b/src/__TODO/UiGuiIniFileParser.h deleted file mode 100644 index 0aebb09..0000000 --- a/src/__TODO/UiGuiIniFileParser.h +++ /dev/null @@ -1,53 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006-2012 by Thomas Schweitzer * - * thomas-schweitzer(at)arcor.de * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License version 2.0 as * - * published by the Free Software Foundation. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program in the file LICENSE.GPL; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ - -#ifndef UIGUIINIFILEPARSER_H -#define UIGUIINIFILEPARSER_H - -#include <tntqmap.h> -#include <tntqstring.h> - -#include <vector> - -class TQStringList; -class TQVariant; - - -class UiGuiIniFileParser -{ - public: - UiGuiIniFileParser(void); - UiGuiIniFileParser(const TQString &iniFileName); - ~UiGuiIniFileParser(void); - - TQVariant value(const TQString &keyName, const TQString &defaultValue = ""); - TQStringList childGroups(); - - protected: - void init(); - - private: - void parseIniFile(); - - TQString _iniFileName; - std::vector<TQString> _sections; - TQMap<TQString, TQVariant> _keyValueMap; -}; - -#endif // UIGUIINIFILEPARSER_H |