annotate src/IndentHandler.cpp @ 751:ac165b6ae67e

Done some refactoring: - Moved includes into the cpp files where possible and using class pre-declarations if possible - Made class member variable names begin with an underscore - Made by uic created header files be used as class members instead of inherting them - Renamed some variables to reflect their purpose better - Added some NULL initializations and added some comments - Rearranged some include and declaration code parts to be consistent and better readable - Updated for QScintilla 2.4.5 - Made UiGuiSettings be accessed via a shared pointer only git-svn-id: svn://svn.code.sf.net/p/universalindent/code/trunk@1028 59b1889a-e5ac-428c-b0c7-476e01d41282
author thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
date Thu, 14 Oct 2010 19:52:47 +0000
parents a884b5861e93
children f3631db17328
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1 /***************************************************************************
727
aae5a8d04f70 Updated comment copyright year.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 723
diff changeset
2 * Copyright (C) 2006-2010 by Thomas Schweitzer *
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
3 * thomas-schweitzer(at)arcor.de *
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
4 * *
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
5 * This program is free software; you can redistribute it and/or modify *
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
6 * it under the terms of the GNU General Public License version 2.0 as *
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
7 * published by the Free Software Foundation. *
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
8 * *
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
9 * This program is distributed in the hope that it will be useful, *
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
12 * GNU General Public License for more details. *
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
13 * *
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
14 * You should have received a copy of the GNU General Public License *
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
15 * along with this program in the file LICENSE.GPL; if not, write to the *
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
16 * Free Software Foundation, Inc., *
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
17 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
18 ***************************************************************************/
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
19
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
20 #include "IndentHandler.h"
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
21
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
22 #include "UiGuiSettings.h"
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
23 #include "UiGuiErrorMessage.h"
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
24 #include "TemplateBatchScript.h"
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
25 #include "UiGuiIniFileParser.h"
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
26 #include "SettingsPaths.h"
687
b4aee13bc733 - Added a new class, that is responsible for logging of any kind and added some logging/debug output calls.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 684
diff changeset
27
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
28 #include <QToolBox>
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
29 #include <QVBoxLayout>
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
30 #include <QApplication>
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
31 #include <QCheckBox>
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
32 #include <QComboBox>
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
33 #include <QToolButton>
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
34 #include <QFile>
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
35 #include <QProcess>
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
36 #include <QSettings>
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
37 #include <QStringList>
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
38 #include <QLineEdit>
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
39 #include <QSpinBox>
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
40 #include <QLabel>
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
41 #include <QByteArray>
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
42 #include <QDir>
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
43 #include <QMessageBox>
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
44 #include <QMainWindow>
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
45 #include <QTextStream>
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
46 #include <QTextCodec>
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
47 #include <QtScript>
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
48 #include <QDesktopServices>
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
49 #include <QMenu>
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
50 #include <QAction>
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
51 #include <QContextMenuEvent>
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
52 #include <QFileDialog>
687
b4aee13bc733 - Added a new class, that is responsible for logging of any kind and added some logging/debug output calls.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 684
diff changeset
53 #include <QtDebug>
b4aee13bc733 - Added a new class, that is responsible for logging of any kind and added some logging/debug output calls.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 684
diff changeset
54
684
aa29b98f5242 [fix] Bug ID 2791229: If UiGUI was located in a path containing Unicode characters or such a path needed to be handed over to a called indenter, the indenter could get confused on Windows. So using the Windows 8.3 short path notation.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 681
diff changeset
55 #ifdef Q_OS_WIN32
aa29b98f5242 [fix] Bug ID 2791229: If UiGUI was located in a path containing Unicode characters or such a path needed to be handed over to a called indenter, the indenter could get confused on Windows. So using the Windows 8.3 short path notation.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 681
diff changeset
56 #include <Windows.h>
aa29b98f5242 [fix] Bug ID 2791229: If UiGUI was located in a path containing Unicode characters or such a path needed to be handed over to a called indenter, the indenter could get confused on Windows. So using the Windows 8.3 short path notation.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 681
diff changeset
57 #endif
aa29b98f5242 [fix] Bug ID 2791229: If UiGUI was located in a path containing Unicode characters or such a path needed to be handed over to a called indenter, the indenter could get confused on Windows. So using the Windows 8.3 short path notation.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 681
diff changeset
58
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
59 //! \defgroup grp_Indenter All concerning handling of the indenter.
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
60
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
61 /*!
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
62 \class IndentHandler
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
63 \ingroup grp_Indenter
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
64 \brief A widget for handling many indenters that are configured by an ini file.
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
65
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
66 This is a widget that is used by the main window. It handles access to the
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
67 indenter config file and calls the chosen indenter to reformat the source text.
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
68 Calls the indenter each time a setting has been changed and informs
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
69 the main window about the reformatted source code.
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
70 */
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
71
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
72
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
73 /*!
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
74 \brief Constructor of the indent handler.
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
75
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
76 By calling this constructor the indenter to be loaded, can be selected by setting
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
77 its \a indenterID, which is the number of found indenter ini files in alphabetic
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
78 order starting at index 0.
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
79 */
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
80 IndentHandler::IndentHandler(int indenterID, QWidget *mainWindow, QWidget *parent) : QWidget(parent)
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
81 , _indenterSelectionCombobox(NULL)
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
82 , _indenterParameterHelpButton(NULL)
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
83 , _toolBoxContainerLayout(NULL)
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
84 , _indenterParameterCategoriesToolBox(NULL)
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
85 , _indenterSettings(NULL)
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
86 , _mainWindow(NULL)
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
87 , _errorMessageDialog(NULL)
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
88 , _menuIndenter(NULL)
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
89 , _actionLoadIndenterConfigFile(NULL)
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
90 , _actionSaveIndenterConfigFile(NULL)
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
91 , _actionCreateShellScript(NULL)
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
92 , _actionResetIndenterParameters(NULL)
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
93 , _parameterChangedCallback(NULL)
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
94 , _windowClosedCallback(NULL)
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
95 {
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
96 Q_ASSERT_X( indenterID >= 0, "IndentHandler", "the selected indenterID is < 0" );
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
97
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
98 setObjectName(QString::fromUtf8("indentHandler"));
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
99
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
100 _mainWindow = mainWindow;
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
101
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
102 initIndenterMenu();
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
103
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
104 connect( _actionLoadIndenterConfigFile, SIGNAL(triggered()), this, SLOT(openConfigFileDialog()) );
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
105 connect( _actionSaveIndenterConfigFile, SIGNAL(triggered()), this, SLOT(saveasIndentCfgFileDialog()) );
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
106 connect( _actionCreateShellScript, SIGNAL(triggered()), this, SLOT(createIndenterCallShellScript()) );
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
107 connect( _actionResetIndenterParameters, SIGNAL(triggered()), this, SLOT(resetIndenterParameter()) );
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
108
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
109 // define this widgets resize behavior
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
110 setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
111
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
112 // create vertical layout box, into which the toolbox will be added
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
113 _toolBoxContainerLayout = new QVBoxLayout(this);
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
114 _toolBoxContainerLayout->setMargin(2);
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
115
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
116 // Create horizontal layout for indenter selector and help button.
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
117 QHBoxLayout *hboxLayout = new QHBoxLayout();
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
118 //hboxLayout->setMargin(2);
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
119 _toolBoxContainerLayout->addLayout( hboxLayout );
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
120
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
121 // Create the indenter selection combo box.
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
122 _indenterSelectionCombobox = new QComboBox(this);
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
123 _indenterSelectionCombobox->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLengthWithIcon);
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
124 _indenterSelectionCombobox->setMinimumContentsLength(20);
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
125 connect( _indenterSelectionCombobox, SIGNAL(activated(int)), this, SLOT(setIndenter(int)) );
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
126 UiGuiSettings::getInstance()->registerObjectProperty(_indenterSelectionCombobox, "currentIndex", "selectedIndenter");
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
127 hboxLayout->addWidget( _indenterSelectionCombobox );
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
128
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
129 // Create the indenter parameter help button.
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
130 _indenterParameterHelpButton = new QToolButton(this);
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
131 _indenterParameterHelpButton->setObjectName(QString::fromUtf8("indenterParameterHelpButton"));
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
132 _indenterParameterHelpButton->setIcon(QIcon(QString::fromUtf8(":/mainWindow/help.png")));
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
133 hboxLayout->addWidget( _indenterParameterHelpButton );
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
134 // Handle if the indenter parameter help button is pressed.
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
135 connect( _indenterParameterHelpButton, SIGNAL(clicked()), this, SLOT(showIndenterManual()) );
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
136
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
137 // create a toolbox and set its resize behavior
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
138 _indenterParameterCategoriesToolBox = new QToolBox(this);
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
139 _indenterParameterCategoriesToolBox->setObjectName(QString::fromUtf8("_indenterParameterCategoriesToolBox"));
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
140
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
141 #ifdef UNIVERSALINDENTGUI_NPP_EXPORTS
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
142 connect( _indenterParameterCategoriesToolBox, SIGNAL(currentChanged(int)), this, SLOT(updateDrawing()) );
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
143 #endif // UNIVERSALINDENTGUI_NPP_EXPORTS
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
144
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
145 //_indenterParameterCategoriesToolBox->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
146 //_indenterParameterCategoriesToolBox->setMaximumSize(QSize(16777215, 16777215));
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
147 // insert the toolbox into the vlayout
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
148 _toolBoxContainerLayout->addWidget(_indenterParameterCategoriesToolBox);
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
149
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
150 _indenterExecutableCallString = "";
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
151 _indenterExecutableSuffix = "";
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
152
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
153 _indenterDirctoryStr = SettingsPaths::getIndenterPath();
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
154 _tempDirctoryStr = SettingsPaths::getTempPath();
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
155 _settingsDirctoryStr = SettingsPaths::getSettingsPath();
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
156 QDir indenterDirctory = QDir(_indenterDirctoryStr);
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
157
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
158 if ( _mainWindow != NULL ) {
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
159 _errorMessageDialog = new UiGuiErrorMessage(_mainWindow);
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
160 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
161 else {
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
162 _errorMessageDialog = new UiGuiErrorMessage(this);
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
163 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
164
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
165 _indenterIniFileList = indenterDirctory.entryList( QStringList("uigui_*.ini") );
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
166 if ( _indenterIniFileList.count() > 0 ) {
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
167 // Take care if the selected indenterID is smaller or greater than the number of existing indenters
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
168 if ( indenterID < 0 ) {
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
169 indenterID = 0;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
170 }
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
171 if ( indenterID >= _indenterIniFileList.count() ) {
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
172 indenterID = _indenterIniFileList.count() - 1;
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
173 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
174
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
175 // Reads and parses the by indenterID defined indent ini file and creates toolbox entries
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
176 readIndentIniFile( _indenterDirctoryStr + "/" + _indenterIniFileList.at(indenterID) );
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
177
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
178 // Find out how the indenter can be executed.
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
179 createIndenterCallString();
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
180
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
181 // Load the users last settings made for this indenter.
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
182 loadConfigFile( _settingsDirctoryStr + "/" + _indenterFileName + ".cfg" );
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
183
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
184 // Fill the indenter selection combo box with the list of available indenters.
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
185 if ( !getAvailableIndenters().isEmpty() ) {
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
186 _indenterSelectionCombobox->addItems( getAvailableIndenters() );
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
187 _indenterSelectionCombobox->setCurrentIndex( indenterID );
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
188 connect( _indenterSelectionCombobox, SIGNAL(currentIndexChanged(int)), this, SIGNAL(selectedIndenterIndexChanged(int)) );
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
189 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
190 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
191 else {
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
192 _errorMessageDialog->showMessage(tr("No indenter ini files"), tr("There exists no indenter ini files in the directory \"") + QDir(_indenterDirctoryStr).absolutePath() + "\".");
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
193 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
194
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
195 retranslateUi();
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
196 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
197
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
198
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
199 /*!
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
200 \brief Implicitly writes the current indenter parameters to the indenters config file.
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
201 */
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
202 IndentHandler::~IndentHandler() {
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
203 // Generate the parameter string that will be saved to the indenters config file.
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
204 QString parameterString = getParameterString();
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
205 if ( !_indenterFileName.isEmpty() ) {
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
206 saveConfigFile( _settingsDirctoryStr + "/" + _indenterFileName + ".cfg", parameterString );
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
207 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
208
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
209 delete _errorMessageDialog;
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
210 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
211
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
212
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
213 /*!
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
214 \brief Initializes the context menu used for some actions like saving the indenter config file.
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
215 */
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
216 void IndentHandler::initIndenterMenu() {
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
217 if ( _menuIndenter == NULL ) {
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
218 _actionLoadIndenterConfigFile = new QAction(this);
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
219 _actionLoadIndenterConfigFile->setObjectName(QString::fromUtf8("_actionLoadIndenterConfigFile"));
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
220 _actionLoadIndenterConfigFile->setIcon(QIcon(QString::fromUtf8(":/mainWindow/load_indent_cfg.png")));
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
221
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
222 _actionSaveIndenterConfigFile = new QAction(this);
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
223 _actionSaveIndenterConfigFile->setObjectName(QString::fromUtf8("_actionSaveIndenterConfigFile"));
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
224 _actionSaveIndenterConfigFile->setIcon(QIcon(QString::fromUtf8(":/mainWindow/save_indent_cfg.png")));
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
225
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
226 _actionCreateShellScript = new QAction(this);
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
227 _actionCreateShellScript->setObjectName(QString::fromUtf8("_actionCreateShellScript"));
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
228 _actionCreateShellScript->setIcon(QIcon(QString::fromUtf8(":/mainWindow/shell.png")));
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
229
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
230 _actionResetIndenterParameters = new QAction(this);
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
231 _actionResetIndenterParameters->setObjectName(QString::fromUtf8("_actionResetIndenterParameters"));
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
232 _actionResetIndenterParameters->setIcon(QIcon(QString::fromUtf8(":/mainWindow/view-refresh.png")));
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
233
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
234 _menuIndenter = new QMenu(this);
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
235 _menuIndenter->setObjectName(QString::fromUtf8("_menuIndenter"));
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
236 _menuIndenter->addAction(_actionLoadIndenterConfigFile);
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
237 _menuIndenter->addAction(_actionSaveIndenterConfigFile);
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
238 _menuIndenter->addAction(_actionCreateShellScript);
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
239 _menuIndenter->addAction(_actionResetIndenterParameters);
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
240 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
241 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
242
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
243
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
244 /*!
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
245 \brief Returns the context menu used for some actions like saving the indenter config file.
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
246 */
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
247 QMenu* IndentHandler::getIndenterMenu() {
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
248 return _menuIndenter;
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
249 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
250
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
251
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
252 /*!
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
253 \brief Returns the actions of the context menu used for some actions like saving the indenter config file.
687
b4aee13bc733 - Added a new class, that is responsible for logging of any kind and added some logging/debug output calls.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 684
diff changeset
254 */
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
255 QList<QAction*> IndentHandler::getIndenterMenuActions() {
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
256 QList<QAction*> actionList;
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
257 actionList << _actionLoadIndenterConfigFile << _actionSaveIndenterConfigFile << _actionCreateShellScript << _actionResetIndenterParameters;
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
258 return actionList;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
259 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
260
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
261
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
262 /*!
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
263 \brief Opens the context menu, used for some actions like saving the indenter config file, at the event position.
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
264 */
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
265 void IndentHandler::contextMenuEvent( QContextMenuEvent *event ) {
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
266 getIndenterMenu()->exec( event->globalPos() );
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
267 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
268
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
269
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
270 /*!
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
271 \brief Creates the content for a shell script that can be used as a external tool call
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
272 to indent an as parameter defined file.
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
273 */
723
69e893792522 [fix] Bug ID 2942381: When loading an indenter configuration file, the settings displayed in th docking widget were correctly updated, but the code wasn't.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 716
diff changeset
274 QString IndentHandler::generateShellScript(const QString &configFilename) {
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
275 QString indenterCompleteCallString;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
276 QString parameterInputFile;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
277 QString parameterOuputFile;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
278 QString parameterParameterFile;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
279 QString replaceInputFileCommand;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
280
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
281 // Define the placeholder for parameter variables either in batch or bash programming.
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
282 #if defined(Q_OS_WIN32)
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
283 QString shellParameterPlaceholder = "%1";
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
284 #else
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
285 QString shellParameterPlaceholder = "$1";
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
286 #endif
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
287
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
288 parameterInputFile = " " + _inputFileParameter + "\"" + shellParameterPlaceholder + "\"";
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
289
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
290 if ( _outputFileParameter != "none" && _outputFileParameter != "stdout" ) {
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
291 if ( _outputFileName == _inputFileName ) {
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
292 parameterOuputFile = " " + _outputFileParameter + "\"" + shellParameterPlaceholder + "\"";
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
293 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
294 else {
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
295 parameterOuputFile = " " + _outputFileParameter + _outputFileName + ".tmp";
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
296 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
297 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
298
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
299 // If the config file name is empty it is assumed that all parameters are sent via command line call
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
300 if ( _globalConfigFilename.isEmpty() ) {
723
69e893792522 [fix] Bug ID 2942381: When loading an indenter configuration file, the settings displayed in th docking widget were correctly updated, but the code wasn't.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 716
diff changeset
301 parameterParameterFile = " " + getParameterString();
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
302 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
303 // else if needed add the parameter to the indenter call string where the config file can be found.
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
304 else if (_useCfgFileParameter != "none") {
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
305 parameterParameterFile = " " + _useCfgFileParameter + "\"./" + configFilename + "\"";
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
306 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
307
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
308 // Assemble indenter call string for parameters according to the set order.
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
309 if ( _parameterOrder == "ipo" ) {
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
310 indenterCompleteCallString = parameterInputFile + parameterParameterFile + parameterOuputFile;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
311 }
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
312 else if ( _parameterOrder == "pio" ) {
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
313 indenterCompleteCallString = parameterParameterFile + parameterInputFile + parameterOuputFile;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
314 }
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
315 else if ( _parameterOrder == "poi" ) {
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
316 indenterCompleteCallString = parameterParameterFile + parameterOuputFile + parameterInputFile;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
317 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
318 else {
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
319 indenterCompleteCallString = parameterInputFile + parameterOuputFile + parameterParameterFile;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
320 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
321
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
322 // Generate the indenter call string either for win32 or other systems.
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
323 #if defined(Q_OS_WIN32)
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
324 indenterCompleteCallString = _indenterExecutableCallString + indenterCompleteCallString;
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
325 #else
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
326 indenterCompleteCallString = "#!/bin/bash\n" + _indenterExecutableCallString + indenterCompleteCallString;
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
327 #endif
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
328
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
329 // If the indenter writes to stdout pipe the output into a file
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
330 if ( _outputFileParameter == "stdout" ) {
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
331 indenterCompleteCallString = indenterCompleteCallString + " >" + _outputFileName + ".tmp";
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
332 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
333
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
334 // If the output filename is not the same as the input filename copy the output over the input.
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
335 if ( _outputFileName != _inputFileName ) {
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
336 #if defined(Q_OS_WIN32)
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
337 replaceInputFileCommand = "move /Y " + _outputFileName + ".tmp \"" + shellParameterPlaceholder + "\"\n";
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
338 #else
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
339 replaceInputFileCommand = "mv " + _outputFileName + ".tmp \"" + shellParameterPlaceholder + "\"\n";
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
340 #endif
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
341 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
342
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
343 #if defined(Q_OS_WIN32)
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
344 QString shellScript( TemplateBatchScript::getTemplateBatchScript() );
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
345 shellScript = shellScript.replace("__INDENTERCALLSTRING2__", indenterCompleteCallString + "\n" + replaceInputFileCommand);
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
346 indenterCompleteCallString = indenterCompleteCallString.replace("%1", "%%G");
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
347 replaceInputFileCommand = replaceInputFileCommand.replace("%1", "%%G");
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
348 shellScript = shellScript.replace("__INDENTERCALLSTRING1__", indenterCompleteCallString + "\n" + replaceInputFileCommand);
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
349 #else
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
350 QString shellScript( TemplateBatchScript::getTemplateBatchScript() );
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
351 shellScript = shellScript.replace("__INDENTERCALLSTRING2__", indenterCompleteCallString + "\n" + replaceInputFileCommand);
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
352 indenterCompleteCallString = indenterCompleteCallString.replace("$1", "$file2indent");
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
353 replaceInputFileCommand = replaceInputFileCommand.replace("$1", "$file2indent");
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
354 shellScript = shellScript.replace("__INDENTERCALLSTRING1__", indenterCompleteCallString + "\n" + replaceInputFileCommand);
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
355 #endif
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
356
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
357 return shellScript;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
358 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
359
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
360
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
361 /*!
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
362 \brief Format \a sourceCode by calling the indenter.
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
363
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
364 The \a inputFileExtension has to be given as parameter so the called indenter
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
365 can identify the programming language if needed.
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
366 */
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
367 QString IndentHandler::callIndenter(QString sourceCode, QString inputFileExtension) {
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
368 if ( _indenterExecutableSuffix == ".js" ) {
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
369 return callJavaScriptIndenter(sourceCode);
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
370 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
371 else {
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
372 return callExecutableIndenter(sourceCode, inputFileExtension);
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
373 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
374 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
375
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
376
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
377 /*!
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
378 \brief Format \a sourceCode by calling the interpreted JavaScript code of the indenter.
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
379
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
380 The \a inputFileExtension has to be given as parameter so the called indenter
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
381 can identify the programming language if needed.
687
b4aee13bc733 - Added a new class, that is responsible for logging of any kind and added some logging/debug output calls.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 684
diff changeset
382 */
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
383 QString IndentHandler::callJavaScriptIndenter(QString sourceCode) {
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
384 QScriptEngine engine;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
385
750
a884b5861e93 Correction to make the JsDecoder work again.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 740
diff changeset
386 engine.globalObject().setProperty("unformattedCode", sourceCode);
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
387
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
388 QFile jsDecoderFile( _indenterExecutableCallString );
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
389 QString jsDecoderCode;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
390 if (jsDecoderFile.open(QFile::ReadOnly)) {
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
391 jsDecoderCode = jsDecoderFile.readAll();
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
392 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
393 jsDecoderFile.close();
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
394
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
395 QScriptValue value = engine.evaluate(jsDecoderCode);
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
396 return value.toString();
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
397 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
398
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
399
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
400 /*!
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
401 \brief Format \a sourceCode by calling the binary executable of the indenter.
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
402
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
403 The \a inputFileExtension has to be given as parameter so the called indenter
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
404 can identify the programming language if needed.
687
b4aee13bc733 - Added a new class, that is responsible for logging of any kind and added some logging/debug output calls.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 684
diff changeset
405 */
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
406 QString IndentHandler::callExecutableIndenter(QString sourceCode, QString inputFileExtension) {
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
407 Q_ASSERT_X( !_inputFileName.isEmpty(), "callIndenter", "_inputFileName is empty" );
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
408 // Q_ASSERT_X( !_outputFileName.isEmpty(), "callIndenter", "_outputFileName is empty" );
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
409 Q_ASSERT_X( !_indenterFileName.isEmpty(), "callIndenter", "_indenterFileName is empty" );
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
410
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
411 if ( _indenterFileName.isEmpty() ) {
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
412 return "";
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
413 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
414
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
415 QString formattedSourceCode;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
416 QString indenterCompleteCallString;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
417 QString parameterInputFile;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
418 QString parameterOuputFile;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
419 QString parameterParameterFile;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
420 QProcess indentProcess;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
421 QString processReturnString;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
422
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
423 // Generate the parameter string that will be saved to the indenters config file
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
424 QString parameterString = getParameterString();
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
425
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
426 if ( !_globalConfigFilename.isEmpty() ) {
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
427 saveConfigFile( _tempDirctoryStr + "/" + _globalConfigFilename, parameterString );
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
428 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
429
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
430 // Only add a dot to file extension if the string is not empty
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
431 if ( !inputFileExtension.isEmpty() ) {
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
432 inputFileExtension = "." + inputFileExtension;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
433 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
434
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
435 // Delete any previously used input src file and create a new input src file.
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
436 QFile::remove(_tempDirctoryStr + "/" + _inputFileName + inputFileExtension);
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
437 QFile inputSrcFile(_tempDirctoryStr + "/" + _inputFileName + inputFileExtension);
654
68b44fb0c0ce Made it possible to define "stdin" to be used for an indenter calling. Also encoded the messages to be shown in an error message box as HTML so that < > and & will be displayed correctly. And from now on no longer merging stdout and stderr so that outputs to stderr will no longer make it into the to stdout returned formatted code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 648
diff changeset
438 // Write the source code to the input file for the indenter
690
eec59baf5bee Added some more debug log outputs to the IndentHandler.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 687
diff changeset
439 if ( inputSrcFile.open( QFile::ReadWrite | QFile::Text ) ) {
eec59baf5bee Added some more debug log outputs to the IndentHandler.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 687
diff changeset
440 inputSrcFile.write( sourceCode.toUtf8() );
eec59baf5bee Added some more debug log outputs to the IndentHandler.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 687
diff changeset
441 inputSrcFile.close();
eec59baf5bee Added some more debug log outputs to the IndentHandler.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 687
diff changeset
442 qDebug() << __LINE__ << " " << __FUNCTION__ << ": Wrote to be indented source code to file " << inputSrcFile.fileName();
eec59baf5bee Added some more debug log outputs to the IndentHandler.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 687
diff changeset
443 }
eec59baf5bee Added some more debug log outputs to the IndentHandler.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 687
diff changeset
444 else {
eec59baf5bee Added some more debug log outputs to the IndentHandler.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 687
diff changeset
445 qCritical() << __LINE__ << " " << __FUNCTION__ << ": Couldn't write to be indented source code to file " << inputSrcFile.fileName();
eec59baf5bee Added some more debug log outputs to the IndentHandler.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 687
diff changeset
446 }
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
447
654
68b44fb0c0ce Made it possible to define "stdin" to be used for an indenter calling. Also encoded the messages to be shown in an error message box as HTML so that < > and & will be displayed correctly. And from now on no longer merging stdout and stderr so that outputs to stderr will no longer make it into the to stdout returned formatted code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 648
diff changeset
448 // Set the input file for the to be called indenter.
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
449 if ( _inputFileParameter.trimmed() == "<" || _inputFileParameter == "stdin" ) {
654
68b44fb0c0ce Made it possible to define "stdin" to be used for an indenter calling. Also encoded the messages to be shown in an error message box as HTML so that < > and & will be displayed correctly. And from now on no longer merging stdout and stderr so that outputs to stderr will no longer make it into the to stdout returned formatted code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 648
diff changeset
450 parameterInputFile = "";
68b44fb0c0ce Made it possible to define "stdin" to be used for an indenter calling. Also encoded the messages to be shown in an error message box as HTML so that < > and & will be displayed correctly. And from now on no longer merging stdout and stderr so that outputs to stderr will no longer make it into the to stdout returned formatted code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 648
diff changeset
451 indentProcess.setStandardInputFile( inputSrcFile.fileName() );
68b44fb0c0ce Made it possible to define "stdin" to be used for an indenter calling. Also encoded the messages to be shown in an error message box as HTML so that < > and & will be displayed correctly. And from now on no longer merging stdout and stderr so that outputs to stderr will no longer make it into the to stdout returned formatted code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 648
diff changeset
452 }
68b44fb0c0ce Made it possible to define "stdin" to be used for an indenter calling. Also encoded the messages to be shown in an error message box as HTML so that < > and & will be displayed correctly. And from now on no longer merging stdout and stderr so that outputs to stderr will no longer make it into the to stdout returned formatted code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 648
diff changeset
453 else {
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
454 parameterInputFile = " " + _inputFileParameter + _inputFileName + inputFileExtension;
654
68b44fb0c0ce Made it possible to define "stdin" to be used for an indenter calling. Also encoded the messages to be shown in an error message box as HTML so that < > and & will be displayed correctly. And from now on no longer merging stdout and stderr so that outputs to stderr will no longer make it into the to stdout returned formatted code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 648
diff changeset
455 }
68b44fb0c0ce Made it possible to define "stdin" to be used for an indenter calling. Also encoded the messages to be shown in an error message box as HTML so that < > and & will be displayed correctly. And from now on no longer merging stdout and stderr so that outputs to stderr will no longer make it into the to stdout returned formatted code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 648
diff changeset
456
68b44fb0c0ce Made it possible to define "stdin" to be used for an indenter calling. Also encoded the messages to be shown in an error message box as HTML so that < > and & will be displayed correctly. And from now on no longer merging stdout and stderr so that outputs to stderr will no longer make it into the to stdout returned formatted code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 648
diff changeset
457 // Set the output file for the to be called indenter.
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
458 if ( _outputFileParameter != "none" && _outputFileParameter != "stdout" ) {
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
459 parameterOuputFile = " " + _outputFileParameter + _outputFileName + inputFileExtension;
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
460 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
461
684
aa29b98f5242 [fix] Bug ID 2791229: If UiGUI was located in a path containing Unicode characters or such a path needed to be handed over to a called indenter, the indenter could get confused on Windows. So using the Windows 8.3 short path notation.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 681
diff changeset
462 #ifdef Q_OS_WIN32
aa29b98f5242 [fix] Bug ID 2791229: If UiGUI was located in a path containing Unicode characters or such a path needed to be handed over to a called indenter, the indenter could get confused on Windows. So using the Windows 8.3 short path notation.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 681
diff changeset
463 // Paths may contain Unicode or other foreign characters. Windows commands line tools will
aa29b98f5242 [fix] Bug ID 2791229: If UiGUI was located in a path containing Unicode characters or such a path needed to be handed over to a called indenter, the indenter could get confused on Windows. So using the Windows 8.3 short path notation.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 681
diff changeset
464 // receive als falsely encoded path string by QProcess or they connot correctly handle
aa29b98f5242 [fix] Bug ID 2791229: If UiGUI was located in a path containing Unicode characters or such a path needed to be handed over to a called indenter, the indenter could get confused on Windows. So using the Windows 8.3 short path notation.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 681
diff changeset
465 // the Unicode path on their own.
aa29b98f5242 [fix] Bug ID 2791229: If UiGUI was located in a path containing Unicode characters or such a path needed to be handed over to a called indenter, the indenter could get confused on Windows. So using the Windows 8.3 short path notation.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 681
diff changeset
466 // Because of this the path gets converted to Windows short paths using the 8.3 notation.
aa29b98f5242 [fix] Bug ID 2791229: If UiGUI was located in a path containing Unicode characters or such a path needed to be handed over to a called indenter, the indenter could get confused on Windows. So using the Windows 8.3 short path notation.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 681
diff changeset
467
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
468 qDebug() << __LINE__ << " " << __FUNCTION__ << ": Temp dir before trying to convert it to short Windows path is" << _tempDirctoryStr;
687
b4aee13bc733 - Added a new class, that is responsible for logging of any kind and added some logging/debug output calls.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 684
diff changeset
469
684
aa29b98f5242 [fix] Bug ID 2791229: If UiGUI was located in a path containing Unicode characters or such a path needed to be handed over to a called indenter, the indenter could get confused on Windows. So using the Windows 8.3 short path notation.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 681
diff changeset
470 // At first convert the temp path to Windows like separators.
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
471 QString tempDirctoryStrHelper = QDir::toNativeSeparators(_tempDirctoryStr).replace("\\", "\\\\");
684
aa29b98f5242 [fix] Bug ID 2791229: If UiGUI was located in a path containing Unicode characters or such a path needed to be handed over to a called indenter, the indenter could get confused on Windows. So using the Windows 8.3 short path notation.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 681
diff changeset
472 // Then convert the QString to a WCHAR array and NULL terminate it.
aa29b98f5242 [fix] Bug ID 2791229: If UiGUI was located in a path containing Unicode characters or such a path needed to be handed over to a called indenter, the indenter could get confused on Windows. So using the Windows 8.3 short path notation.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 681
diff changeset
473 WCHAR *tempDirctoryWindowsStr = new WCHAR[ tempDirctoryStrHelper.length()+1 ];
aa29b98f5242 [fix] Bug ID 2791229: If UiGUI was located in a path containing Unicode characters or such a path needed to be handed over to a called indenter, the indenter could get confused on Windows. So using the Windows 8.3 short path notation.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 681
diff changeset
474 tempDirctoryStrHelper.toWCharArray( tempDirctoryWindowsStr );
aa29b98f5242 [fix] Bug ID 2791229: If UiGUI was located in a path containing Unicode characters or such a path needed to be handed over to a called indenter, the indenter could get confused on Windows. So using the Windows 8.3 short path notation.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 681
diff changeset
475 tempDirctoryWindowsStr[ tempDirctoryStrHelper.length() ] = (WCHAR)NULL;
aa29b98f5242 [fix] Bug ID 2791229: If UiGUI was located in a path containing Unicode characters or such a path needed to be handed over to a called indenter, the indenter could get confused on Windows. So using the Windows 8.3 short path notation.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 681
diff changeset
476
aa29b98f5242 [fix] Bug ID 2791229: If UiGUI was located in a path containing Unicode characters or such a path needed to be handed over to a called indenter, the indenter could get confused on Windows. So using the Windows 8.3 short path notation.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 681
diff changeset
477 // Get the length of the resulting short path.
aa29b98f5242 [fix] Bug ID 2791229: If UiGUI was located in a path containing Unicode characters or such a path needed to be handed over to a called indenter, the indenter could get confused on Windows. So using the Windows 8.3 short path notation.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 681
diff changeset
478 long length = 0;
aa29b98f5242 [fix] Bug ID 2791229: If UiGUI was located in a path containing Unicode characters or such a path needed to be handed over to a called indenter, the indenter could get confused on Windows. So using the Windows 8.3 short path notation.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 681
diff changeset
479 TCHAR *buffer = NULL;
aa29b98f5242 [fix] Bug ID 2791229: If UiGUI was located in a path containing Unicode characters or such a path needed to be handed over to a called indenter, the indenter could get confused on Windows. So using the Windows 8.3 short path notation.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 681
diff changeset
480 length = GetShortPathName((LPCTSTR)tempDirctoryWindowsStr, NULL, 0);
aa29b98f5242 [fix] Bug ID 2791229: If UiGUI was located in a path containing Unicode characters or such a path needed to be handed over to a called indenter, the indenter could get confused on Windows. So using the Windows 8.3 short path notation.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 681
diff changeset
481
aa29b98f5242 [fix] Bug ID 2791229: If UiGUI was located in a path containing Unicode characters or such a path needed to be handed over to a called indenter, the indenter could get confused on Windows. So using the Windows 8.3 short path notation.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 681
diff changeset
482 // If the short path could be retrieved, create a correct sized buffer, store the
aa29b98f5242 [fix] Bug ID 2791229: If UiGUI was located in a path containing Unicode characters or such a path needed to be handed over to a called indenter, the indenter could get confused on Windows. So using the Windows 8.3 short path notation.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 681
diff changeset
483 // short path in it and convert all back to QString.
aa29b98f5242 [fix] Bug ID 2791229: If UiGUI was located in a path containing Unicode characters or such a path needed to be handed over to a called indenter, the indenter could get confused on Windows. So using the Windows 8.3 short path notation.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 681
diff changeset
484 if ( length != 0 ) {
713
56a36f633431 Differ between UNICODE and none UNICODE variant if trying the get the short notation windows path name.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 696
diff changeset
485 #ifdef UNICODE
684
aa29b98f5242 [fix] Bug ID 2791229: If UiGUI was located in a path containing Unicode characters or such a path needed to be handed over to a called indenter, the indenter could get confused on Windows. So using the Windows 8.3 short path notation.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 681
diff changeset
486 buffer = new WCHAR[length];
aa29b98f5242 [fix] Bug ID 2791229: If UiGUI was located in a path containing Unicode characters or such a path needed to be handed over to a called indenter, the indenter could get confused on Windows. So using the Windows 8.3 short path notation.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 681
diff changeset
487 length = GetShortPathName((LPCTSTR)tempDirctoryWindowsStr, buffer, length);
aa29b98f5242 [fix] Bug ID 2791229: If UiGUI was located in a path containing Unicode characters or such a path needed to be handed over to a called indenter, the indenter could get confused on Windows. So using the Windows 8.3 short path notation.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 681
diff changeset
488 tempDirctoryStrHelper = QString::fromWCharArray( buffer );
713
56a36f633431 Differ between UNICODE and none UNICODE variant if trying the get the short notation windows path name.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 696
diff changeset
489 #else
56a36f633431 Differ between UNICODE and none UNICODE variant if trying the get the short notation windows path name.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 696
diff changeset
490 buffer = new TCHAR[length];
56a36f633431 Differ between UNICODE and none UNICODE variant if trying the get the short notation windows path name.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 696
diff changeset
491 length = GetShortPathName((LPCTSTR)tempDirctoryWindowsStr, buffer, length);
56a36f633431 Differ between UNICODE and none UNICODE variant if trying the get the short notation windows path name.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 696
diff changeset
492 tempDirctoryStrHelper = buffer;
56a36f633431 Differ between UNICODE and none UNICODE variant if trying the get the short notation windows path name.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 696
diff changeset
493 #endif
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
494 _tempDirctoryStr = QDir::fromNativeSeparators(tempDirctoryStrHelper).replace("//", "/");
716
b9123ff53106 Run cppcheck over the code and removed some possible problems.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 714
diff changeset
495 delete [] buffer;
714
3363b7bb0d41 Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 713
diff changeset
496
687
b4aee13bc733 - Added a new class, that is responsible for logging of any kind and added some logging/debug output calls.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 684
diff changeset
497 // Check whether the short path still contains some kind of non ascii characters.
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
498 if ( _tempDirctoryStr.length() != _tempDirctoryStr.toAscii().length() ) {
687
b4aee13bc733 - Added a new class, that is responsible for logging of any kind and added some logging/debug output calls.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 684
diff changeset
499 qWarning() << __LINE__ << " " << __FUNCTION__ << ": Shortened path still contains non ascii characters. Could cause some indenters not to work properly!";
b4aee13bc733 - Added a new class, that is responsible for logging of any kind and added some logging/debug output calls.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 684
diff changeset
500 }
684
aa29b98f5242 [fix] Bug ID 2791229: If UiGUI was located in a path containing Unicode characters or such a path needed to be handed over to a called indenter, the indenter could get confused on Windows. So using the Windows 8.3 short path notation.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 681
diff changeset
501 }
687
b4aee13bc733 - Added a new class, that is responsible for logging of any kind and added some logging/debug output calls.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 684
diff changeset
502 else {
b4aee13bc733 - Added a new class, that is responsible for logging of any kind and added some logging/debug output calls.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 684
diff changeset
503 qWarning() << __LINE__ << " " << __FUNCTION__ << ": Couldn't retrieve a short version of the temporary path!";
b4aee13bc733 - Added a new class, that is responsible for logging of any kind and added some logging/debug output calls.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 684
diff changeset
504 }
b4aee13bc733 - Added a new class, that is responsible for logging of any kind and added some logging/debug output calls.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 684
diff changeset
505
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
506 qDebug() << __LINE__ << " " << __FUNCTION__ << ": Temp dir after trying to convert it to short Windows path is " << _tempDirctoryStr;
684
aa29b98f5242 [fix] Bug ID 2791229: If UiGUI was located in a path containing Unicode characters or such a path needed to be handed over to a called indenter, the indenter could get confused on Windows. So using the Windows 8.3 short path notation.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 681
diff changeset
507
716
b9123ff53106 Run cppcheck over the code and removed some possible problems.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 714
diff changeset
508 delete [] tempDirctoryWindowsStr;
684
aa29b98f5242 [fix] Bug ID 2791229: If UiGUI was located in a path containing Unicode characters or such a path needed to be handed over to a called indenter, the indenter could get confused on Windows. So using the Windows 8.3 short path notation.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 681
diff changeset
509 #endif
aa29b98f5242 [fix] Bug ID 2791229: If UiGUI was located in a path containing Unicode characters or such a path needed to be handed over to a called indenter, the indenter could get confused on Windows. So using the Windows 8.3 short path notation.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 681
diff changeset
510
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
511 // If the config file name is empty it is assumed that all parameters are sent via command line call
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
512 if ( _globalConfigFilename.isEmpty() ) {
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
513 parameterParameterFile = " " + parameterString;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
514 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
515 // if needed add the parameter to the indenter call string where the config file can be found
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
516 else if (_useCfgFileParameter != "none") {
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
517 parameterParameterFile = " " + _useCfgFileParameter + "\"" + _tempDirctoryStr + "/" + _globalConfigFilename + "\"";
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
518 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
519
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
520 // Assemble indenter call string for parameters according to the set order.
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
521 if ( _parameterOrder == "ipo" ) {
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
522 indenterCompleteCallString = parameterInputFile + parameterParameterFile + parameterOuputFile;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
523 }
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
524 else if ( _parameterOrder == "pio" ) {
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
525 indenterCompleteCallString = parameterParameterFile + parameterInputFile + parameterOuputFile;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
526 }
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
527 else if ( _parameterOrder == "poi" ) {
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
528 indenterCompleteCallString = parameterParameterFile + parameterOuputFile + parameterInputFile;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
529 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
530 else {
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
531 indenterCompleteCallString = parameterInputFile + parameterOuputFile + parameterParameterFile;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
532 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
533
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
534 // If no indenter executable call string could be created before, show an error message.
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
535 if ( _indenterExecutableCallString.isEmpty() ) {
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
536 _errorMessageDialog->showMessage(tr("No indenter executable"),
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
537 tr("There exists no indenter executable with the name \"%1\" in the directory \"%2\" nor in the global environment.").arg(_indenterFileName).arg(_indenterDirctoryStr) );
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
538 return sourceCode;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
539 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
540
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
541 // Generate the indenter call string either for win32 or other systems.
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
542 indenterCompleteCallString = _indenterExecutableCallString + indenterCompleteCallString;
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
543
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
544 // errors and standard outputs from the process call are merged together
654
68b44fb0c0ce Made it possible to define "stdin" to be used for an indenter calling. Also encoded the messages to be shown in an error message box as HTML so that < > and & will be displayed correctly. And from now on no longer merging stdout and stderr so that outputs to stderr will no longer make it into the to stdout returned formatted code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 648
diff changeset
545 //indentProcess.setReadChannelMode(QProcess::MergedChannels);
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
546
740
bc47ac0a44eb Changed the environment of the invoked indenter executable to contain the working directory within the PWD environment variable.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 728
diff changeset
547 // Set the directory where the indenter will be executed for the process' environment as PWD.
bc47ac0a44eb Changed the environment of the invoked indenter executable to contain the working directory within the PWD environment variable.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 728
diff changeset
548 QStringList env = indentProcess.environment();
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
549 env << "PWD=" + QFileInfo(_tempDirctoryStr).absoluteFilePath();
740
bc47ac0a44eb Changed the environment of the invoked indenter executable to contain the working directory within the PWD environment variable.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 728
diff changeset
550 indentProcess.setEnvironment( env );
bc47ac0a44eb Changed the environment of the invoked indenter executable to contain the working directory within the PWD environment variable.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 728
diff changeset
551
bc47ac0a44eb Changed the environment of the invoked indenter executable to contain the working directory within the PWD environment variable.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 728
diff changeset
552 // Set the directory for the indenter execution
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
553 indentProcess.setWorkingDirectory( QFileInfo(_tempDirctoryStr).absoluteFilePath() );
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
554
692
e3ff3c85d271 Added a class for retrieving info about the operating system and use this for logging info.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 690
diff changeset
555 qDebug() << __LINE__ << " " << __FUNCTION__ << ": Will call the indenter in the directory " << indentProcess.workingDirectory() << " using this commandline call: " << indenterCompleteCallString;
690
eec59baf5bee Added some more debug log outputs to the IndentHandler.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 687
diff changeset
556
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
557 indentProcess.start(indenterCompleteCallString);
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
558
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
559 processReturnString = "";
654
68b44fb0c0ce Made it possible to define "stdin" to be used for an indenter calling. Also encoded the messages to be shown in an error message box as HTML so that < > and & will be displayed correctly. And from now on no longer merging stdout and stderr so that outputs to stderr will no longer make it into the to stdout returned formatted code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 648
diff changeset
560 bool calledProcessSuccessfully = indentProcess.waitForFinished(10000);
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
561 // test if there was an error during starting the process of the indenter
654
68b44fb0c0ce Made it possible to define "stdin" to be used for an indenter calling. Also encoded the messages to be shown in an error message box as HTML so that < > and & will be displayed correctly. And from now on no longer merging stdout and stderr so that outputs to stderr will no longer make it into the to stdout returned formatted code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 648
diff changeset
562 if ( !calledProcessSuccessfully ) {
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
563 processReturnString = "<html><body>";
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
564 processReturnString += tr("<b>Returned error message:</b> ") + indentProcess.errorString() + "<br>";
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
565
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
566 switch ( indentProcess.error() ) {
714
3363b7bb0d41 Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 713
diff changeset
567 case QProcess::FailedToStart :
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
568 processReturnString += tr("<b>Reason could be:</b> ") + "The process failed to start. Either the invoked program is missing, or you may have insufficient permissions to invoke the program.<br>";
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
569 break;
714
3363b7bb0d41 Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 713
diff changeset
570 case QProcess::Crashed :
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
571 processReturnString += "The process crashed some time after starting successfully.<br>";
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
572 break;
714
3363b7bb0d41 Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 713
diff changeset
573 case QProcess::Timedout :
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
574 processReturnString += "The called indenter did not response for over 10 seconds, so aborted its execution.<br>";
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
575 break;
714
3363b7bb0d41 Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 713
diff changeset
576 case QProcess::WriteError :
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
577 processReturnString += "An error occurred when attempting to write to the process. For example, the process may not be running, or it may have closed its input channel.<br>";
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
578 break;
714
3363b7bb0d41 Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 713
diff changeset
579 case QProcess::ReadError :
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
580 processReturnString += "An error occurred when attempting to read from the process. For example, the process may not be running.<br>";
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
581 break;
714
3363b7bb0d41 Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 713
diff changeset
582 case QProcess::UnknownError :
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
583 processReturnString += "An unknown error occurred. This is the default return value of error().<br>";
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
584 break;
714
3363b7bb0d41 Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 713
diff changeset
585 default :
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
586 break;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
587 }
654
68b44fb0c0ce Made it possible to define "stdin" to be used for an indenter calling. Also encoded the messages to be shown in an error message box as HTML so that < > and & will be displayed correctly. And from now on no longer merging stdout and stderr so that outputs to stderr will no longer make it into the to stdout returned formatted code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 648
diff changeset
588 processReturnString += tr("<br><b>Callstring was:</b> ") + encodeToHTML(indenterCompleteCallString);
68b44fb0c0ce Made it possible to define "stdin" to be used for an indenter calling. Also encoded the messages to be shown in an error message box as HTML so that < > and & will be displayed correctly. And from now on no longer merging stdout and stderr so that outputs to stderr will no longer make it into the to stdout returned formatted code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 648
diff changeset
589 processReturnString += tr("<br><br><b>Indenter output was:</b><pre>") + "<br>" +
714
3363b7bb0d41 Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 713
diff changeset
590 "(STDOUT):" + encodeToHTML( indentProcess.readAllStandardOutput() ) + "<br>" +
3363b7bb0d41 Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 713
diff changeset
591 "(STDERR):" + encodeToHTML( indentProcess.readAllStandardError() ) + "<br>" +
3363b7bb0d41 Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 713
diff changeset
592 "</pre></html></body>";
696
454ff5b55d09 Added warning messages to the log if the indenter call fails.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 692
diff changeset
593 qWarning() << __LINE__ << " " << __FUNCTION__ << processReturnString;
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
594 QApplication::restoreOverrideCursor();
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
595 _errorMessageDialog->showMessage(tr("Error calling Indenter"), processReturnString);
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
596 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
597
740
bc47ac0a44eb Changed the environment of the invoked indenter executable to contain the working directory within the PWD environment variable.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 728
diff changeset
598
654
68b44fb0c0ce Made it possible to define "stdin" to be used for an indenter calling. Also encoded the messages to be shown in an error message box as HTML so that < > and & will be displayed correctly. And from now on no longer merging stdout and stderr so that outputs to stderr will no longer make it into the to stdout returned formatted code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 648
diff changeset
599 // If the indenter returned an error code != 0 show its output.
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
600 if ( indentProcess.exitCode() != 0 ) {
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
601 QString exitCode;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
602 exitCode.setNum(indentProcess.exitCode());
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
603 processReturnString = tr("<b>Indenter returned with exit code:</b> ") + exitCode + "<br>" +
714
3363b7bb0d41 Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 713
diff changeset
604 tr("<b>Indent console output was:</b> ") + "<br>" +
3363b7bb0d41 Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 713
diff changeset
605 "(STDOUT):" + encodeToHTML( indentProcess.readAllStandardOutput() ) + "<br>" +
3363b7bb0d41 Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 713
diff changeset
606 "(STDERR):" + encodeToHTML( indentProcess.readAllStandardError() ) + "<br>" +
3363b7bb0d41 Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 713
diff changeset
607 tr("<br><b>Callstring was:</b> ") + encodeToHTML(indenterCompleteCallString) +
3363b7bb0d41 Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 713
diff changeset
608 "</html></body>";
696
454ff5b55d09 Added warning messages to the log if the indenter call fails.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 692
diff changeset
609 qWarning() << __LINE__ << " " << __FUNCTION__ << processReturnString;
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
610 QApplication::restoreOverrideCursor();
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
611 _errorMessageDialog->showMessage( tr("Indenter returned error"), processReturnString );
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
612 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
613
654
68b44fb0c0ce Made it possible to define "stdin" to be used for an indenter calling. Also encoded the messages to be shown in an error message box as HTML so that < > and & will be displayed correctly. And from now on no longer merging stdout and stderr so that outputs to stderr will no longer make it into the to stdout returned formatted code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 648
diff changeset
614 // Only get the formatted source code, if calling the indenter did succeed.
68b44fb0c0ce Made it possible to define "stdin" to be used for an indenter calling. Also encoded the messages to be shown in an error message box as HTML so that < > and & will be displayed correctly. And from now on no longer merging stdout and stderr so that outputs to stderr will no longer make it into the to stdout returned formatted code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 648
diff changeset
615 if ( calledProcessSuccessfully ) {
68b44fb0c0ce Made it possible to define "stdin" to be used for an indenter calling. Also encoded the messages to be shown in an error message box as HTML so that < > and & will be displayed correctly. And from now on no longer merging stdout and stderr so that outputs to stderr will no longer make it into the to stdout returned formatted code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 648
diff changeset
616 // If the indenter results are written to stdout, read them from there...
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
617 if ( indentProcess.exitCode() == 0 && _outputFileParameter == "stdout" ) {
654
68b44fb0c0ce Made it possible to define "stdin" to be used for an indenter calling. Also encoded the messages to be shown in an error message box as HTML so that < > and & will be displayed correctly. And from now on no longer merging stdout and stderr so that outputs to stderr will no longer make it into the to stdout returned formatted code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 648
diff changeset
618 formattedSourceCode = indentProcess.readAllStandardOutput();
690
eec59baf5bee Added some more debug log outputs to the IndentHandler.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 687
diff changeset
619 qDebug() << __LINE__ << " " << __FUNCTION__ << ": Read indenter output from StdOut.";
654
68b44fb0c0ce Made it possible to define "stdin" to be used for an indenter calling. Also encoded the messages to be shown in an error message box as HTML so that < > and & will be displayed correctly. And from now on no longer merging stdout and stderr so that outputs to stderr will no longer make it into the to stdout returned formatted code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 648
diff changeset
620 }
68b44fb0c0ce Made it possible to define "stdin" to be used for an indenter calling. Also encoded the messages to be shown in an error message box as HTML so that < > and & will be displayed correctly. And from now on no longer merging stdout and stderr so that outputs to stderr will no longer make it into the to stdout returned formatted code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 648
diff changeset
621 // ... else read the output file generated by the indenter call.
68b44fb0c0ce Made it possible to define "stdin" to be used for an indenter calling. Also encoded the messages to be shown in an error message box as HTML so that < > and & will be displayed correctly. And from now on no longer merging stdout and stderr so that outputs to stderr will no longer make it into the to stdout returned formatted code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 648
diff changeset
622 else {
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
623 QFile outSrcFile(_tempDirctoryStr + "/" + _outputFileName + inputFileExtension);
690
eec59baf5bee Added some more debug log outputs to the IndentHandler.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 687
diff changeset
624 if ( outSrcFile.open(QFile::ReadOnly | QFile::Text) ) {
eec59baf5bee Added some more debug log outputs to the IndentHandler.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 687
diff changeset
625 QTextStream outSrcStrm(&outSrcFile);
eec59baf5bee Added some more debug log outputs to the IndentHandler.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 687
diff changeset
626 outSrcStrm.setCodec( QTextCodec::codecForName("UTF-8") );
eec59baf5bee Added some more debug log outputs to the IndentHandler.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 687
diff changeset
627 formattedSourceCode = outSrcStrm.readAll();
eec59baf5bee Added some more debug log outputs to the IndentHandler.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 687
diff changeset
628 outSrcFile.close();
eec59baf5bee Added some more debug log outputs to the IndentHandler.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 687
diff changeset
629 qDebug() << __LINE__ << " " << __FUNCTION__ << ": Read indenter output from file " << outSrcFile.fileName();
eec59baf5bee Added some more debug log outputs to the IndentHandler.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 687
diff changeset
630 }
eec59baf5bee Added some more debug log outputs to the IndentHandler.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 687
diff changeset
631 else {
eec59baf5bee Added some more debug log outputs to the IndentHandler.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 687
diff changeset
632 qCritical() << __LINE__ << " " << __FUNCTION__ << ": Couldn't read indenter output from file " << outSrcFile.fileName();
eec59baf5bee Added some more debug log outputs to the IndentHandler.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 687
diff changeset
633 }
654
68b44fb0c0ce Made it possible to define "stdin" to be used for an indenter calling. Also encoded the messages to be shown in an error message box as HTML so that < > and & will be displayed correctly. And from now on no longer merging stdout and stderr so that outputs to stderr will no longer make it into the to stdout returned formatted code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 648
diff changeset
634 }
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
635 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
636 else {
654
68b44fb0c0ce Made it possible to define "stdin" to be used for an indenter calling. Also encoded the messages to be shown in an error message box as HTML so that < > and & will be displayed correctly. And from now on no longer merging stdout and stderr so that outputs to stderr will no longer make it into the to stdout returned formatted code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 648
diff changeset
637 return sourceCode;
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
638 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
639
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
640 // Delete the temporary input and output files.
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
641 QFile::remove(_tempDirctoryStr + "/" + _outputFileName + inputFileExtension);
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
642 QFile::remove(_tempDirctoryStr + "/" + _inputFileName + inputFileExtension);
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
643
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
644 return formattedSourceCode;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
645 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
646
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
647
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
648 /*!
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
649 \brief Generates and returns a string with all parameters needed to call the indenter.
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
650 */
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
651 QString IndentHandler::getParameterString() {
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
652 QString parameterString = "";
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
653
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
654 // generate parameter string for all boolean values
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
655 foreach (ParamBoolean pBoolean, _paramBooleans) {
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
656 if ( pBoolean.checkBox->isChecked() ) {
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
657 if ( !pBoolean.trueString.isEmpty() ) {
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
658 parameterString += pBoolean.trueString + _cfgFileParameterEnding;
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
659 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
660 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
661 else {
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
662 if ( !pBoolean.falseString.isEmpty() ) {
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
663 parameterString += pBoolean.falseString + _cfgFileParameterEnding;
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
664 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
665 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
666 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
667
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
668 // generate parameter string for all numeric values
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
669 foreach (ParamNumeric pNumeric, _paramNumerics) {
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
670 if ( pNumeric.valueEnabledChkBox->isChecked() ) {
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
671 parameterString += pNumeric.paramCallName + QString::number( pNumeric.spinBox->value() ) + _cfgFileParameterEnding;
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
672 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
673 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
674
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
675 // generate parameter string for all string values
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
676 foreach (ParamString pString, _paramStrings) {
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
677 if ( !pString.lineEdit->text().isEmpty() && pString.valueEnabledChkBox->isChecked() ) {
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
678 // Create parameter definition for each value devided by a | sign.
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
679 foreach (QString paramValue, pString.lineEdit->text().split("|")) {
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
680 parameterString += pString.paramCallName + paramValue + _cfgFileParameterEnding;
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
681 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
682 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
683 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
684
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
685 // generate parameter string for all multiple choice values
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
686 foreach (ParamMultiple pMultiple, _paramMultiples) {
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
687 if ( pMultiple.valueEnabledChkBox->isChecked() ) {
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
688 parameterString += pMultiple.choicesStrings.at( pMultiple.comboBox->currentIndex () ) + _cfgFileParameterEnding;
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
689 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
690 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
691
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
692 return parameterString;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
693 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
694
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
695
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
696 /*!
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
697 \brief Write settings for the indenter to a config file.
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
698 */
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
699 void IndentHandler::saveConfigFile(QString filePathName, QString paramString) {
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
700 QFile::remove( filePathName );
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
701 QFile cfgFile( filePathName );
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
702
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
703 cfgFile.open( QFile::ReadWrite | QFile::Text );
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
704 cfgFile.write( paramString.toAscii() );
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
705 cfgFile.close();
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
706 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
707
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
708
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
709 /*!
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
710 \brief Load the config file for the indenter and apply the settings made there.
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
711 */
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
712 bool IndentHandler::loadConfigFile(QString filePathName) {
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
713 QFile cfgFile(filePathName);
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
714 int index;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
715 int crPos;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
716 int paramValue = 0;
716
b9123ff53106 Run cppcheck over the code and removed some possible problems.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 714
diff changeset
717 QString paramValueStr = "";
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
718 QString cfgFileData = "";
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
719
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
720 // If the to be loaded config file does not exist leave all values as they are and return false.
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
721 if ( !cfgFile.exists() ) {
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
722 return false;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
723 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
724 // else if the to be read config file exists, retrieve its whole content.
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
725 else {
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
726 // Open the config file and read all data
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
727 cfgFile.open( QFile::ReadOnly | QFile::Text );
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
728 cfgFileData = cfgFile.readAll();
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
729 cfgFile.close();
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
730 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
731
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
732 // Search for name of each boolean parameter and set its value if found.
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
733 foreach (ParamBoolean pBoolean, _paramBooleans) {
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
734 // boolean value that will be assigned to the checkbox
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
735 bool paramValue = false;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
736
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
737 // first search for the longer parameter string
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
738 // the true parameter string is longer than the false string
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
739 if ( pBoolean.trueString.length() > pBoolean.falseString.length() ) {
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
740 // search for the true string
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
741 index = cfgFileData.indexOf( pBoolean.trueString, 0, Qt::CaseInsensitive );
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
742 // if true string found set the parameter value to true
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
743 if ( index != -1 ) {
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
744 paramValue = true;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
745 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
746 // if true string not found, search for false string
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
747 else {
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
748 index = cfgFileData.indexOf( pBoolean.falseString, 0, Qt::CaseInsensitive );
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
749 // if false string found set the parameter value to false
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
750 if ( index != -1 ) {
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
751 paramValue = false;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
752 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
753 // neither true nor false parameter found so use default value
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
754 else {
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
755 paramValue = _indenterSettings->value(pBoolean.paramName + "/ValueDefault").toBool();
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
756 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
757 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
758 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
759 // the false parameter string is longer than the true string
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
760 else {
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
761 // search for the false string
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
762 index = cfgFileData.indexOf( pBoolean.falseString, 0, Qt::CaseInsensitive );
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
763 // if false string found set the parameter value to false
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
764 if ( index != -1 ) {
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
765 paramValue = false;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
766 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
767 // if false string not found, search for true string
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
768 else {
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
769 index = cfgFileData.indexOf( pBoolean.trueString, 0, Qt::CaseInsensitive );
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
770 // if true string found set the parameter value to true
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
771 if ( index != -1 ) {
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
772 paramValue = true;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
773 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
774 // neither true nor false parameter found so use default value
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
775 else {
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
776 paramValue = _indenterSettings->value(pBoolean.paramName + "/ValueDefault").toBool();
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
777 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
778 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
779 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
780 pBoolean.checkBox->setChecked(paramValue);
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
781 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
782
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
783 // Search for name of each numeric parameter and set the value found behind it.
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
784 foreach (ParamNumeric pNumeric, _paramNumerics) {
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
785 index = cfgFileData.indexOf( pNumeric.paramCallName, 0, Qt::CaseInsensitive );
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
786 // parameter was found in config file
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
787 if ( index != -1 ) {
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
788 // set index after the parameter name, so in front of the number
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
789 index += pNumeric.paramCallName.length();
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
790
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
791 // Find the end of the parameter by searching for set config file parameter ending. Most of time this is a carriage return.
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
792 crPos = cfgFileData.indexOf( _cfgFileParameterEnding, index+1 );
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
793
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
794 // get the number and convert it to int
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
795 QString test = cfgFileData.mid( index, crPos - index );
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
796 paramValue = cfgFileData.mid( index, crPos - index ).toInt(NULL);
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
797
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
798 // disable the signal-slot connection. Otherwise signal is emmitted each time when value is set
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
799 QObject::disconnect(pNumeric.spinBox, SIGNAL(valueChanged(int)), this, SLOT(handleChangedIndenterSettings()));
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
800 pNumeric.spinBox->setValue( paramValue );
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
801 pNumeric.valueEnabledChkBox->setChecked( true );
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
802 QObject::connect(pNumeric.spinBox, SIGNAL(valueChanged(int)), this, SLOT(handleChangedIndenterSettings()));
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
803 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
804 // parameter was not found in config file
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
805 else {
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
806 int defaultValue = _indenterSettings->value(pNumeric.paramName + "/ValueDefault").toInt();
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
807 pNumeric.spinBox->setValue( defaultValue );
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
808 pNumeric.valueEnabledChkBox->setChecked( false );
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
809 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
810 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
811
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
812 // Search for name of each string parameter and set it.
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
813 foreach (ParamString pString, _paramStrings) {
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
814 paramValueStr = "";
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
815 // The number of the found values for this parameter name.
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
816 int numberOfValues = 0;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
817 index = cfgFileData.indexOf( pString.paramCallName, 0, Qt::CaseInsensitive );
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
818 // If parameter was found in config file
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
819 if ( index != -1 ) {
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
820 while ( index != -1 ) {
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
821 numberOfValues++;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
822
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
823 // Set index after the parameter name, so it points to the front of the string value.
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
824 index += pString.paramCallName.length();
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
825
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
826 // Find the end of the parameter by searching for set config file parameter ending. Most of time this is a carriage return.
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
827 crPos = cfgFileData.indexOf( _cfgFileParameterEnding, index+1 );
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
828
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
829 // Get the string and remember it.
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
830 if ( numberOfValues < 2 ) {
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
831 paramValueStr = QString( cfgFileData.mid( index, crPos - index ) );
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
832 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
833 // If the same parameter has been set multiple times, concatenate the strings dvivided by a |.
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
834 else {
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
835 paramValueStr = paramValueStr + "|" + QString( cfgFileData.mid( index, crPos - index ) );
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
836 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
837
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
838 // Get next value for this setting, if one exists.
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
839 index = cfgFileData.indexOf( pString.paramCallName, crPos+1, Qt::CaseInsensitive );
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
840 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
841 // Set the text for the line edit.
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
842 pString.lineEdit->setText( paramValueStr );
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
843 pString.valueEnabledChkBox->setChecked( true );
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
844 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
845 // Parameter was not found in config file
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
846 else {
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
847 paramValueStr = _indenterSettings->value(pString.paramName + "/ValueDefault").toString();
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
848 pString.lineEdit->setText( paramValueStr );
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
849 pString.valueEnabledChkBox->setChecked( false );
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
850 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
851 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
852
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
853 // search for name of each multiple choice parameter and set it
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
854 foreach (ParamMultiple pMultiple, _paramMultiples) {
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
855 int i = 0;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
856 index = -1;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
857
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
858 // search for all parameter names of the multiple choice list
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
859 // if one is found, set it and leave the while loop
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
860 while ( i < pMultiple.choicesStrings.count() && index == -1 ) {
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
861 index = cfgFileData.indexOf( pMultiple.choicesStrings.at(i), 0, Qt::CaseInsensitive );
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
862 if ( index != -1 ) {
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
863 pMultiple.comboBox->setCurrentIndex( i );
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
864 pMultiple.valueEnabledChkBox->setChecked( true );
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
865 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
866 i++;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
867 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
868
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
869 // parameter was not set in config file, so use default value
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
870 if ( index == -1 ) {
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
871 int defaultValue = _indenterSettings->value(pMultiple.paramName + "/ValueDefault").toInt();
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
872 pMultiple.comboBox->setCurrentIndex( defaultValue );
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
873 pMultiple.valueEnabledChkBox->setChecked( false );
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
874 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
875 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
876
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
877 return true;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
878 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
879
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
880
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
881 /*!
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
882 \brief Sets all indenter parameters to their default values defined in the ini file.
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
883 */
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
884 void IndentHandler::resetToDefaultValues() {
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
885 // Search for name of each boolean parameter and set its value if found.
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
886 foreach (ParamBoolean pBoolean, _paramBooleans) {
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
887 // Boolean value that will be assigned to the checkbox.
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
888 bool defaultValue = _indenterSettings->value(pBoolean.paramName + "/ValueDefault").toBool();
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
889 pBoolean.checkBox->setChecked( defaultValue );
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
890 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
891
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
892 // Search for name of each numeric parameter and set the value found behind it.
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
893 foreach (ParamNumeric pNumeric, _paramNumerics) {
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
894 int defaultValue = _indenterSettings->value(pNumeric.paramName + "/ValueDefault").toInt();
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
895 pNumeric.spinBox->setValue( defaultValue );
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
896 pNumeric.valueEnabledChkBox->setChecked( _indenterSettings->value(pNumeric.paramName + "/Enabled").toBool() );
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
897 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
898
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
899 // Search for name of each string parameter and set it.
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
900 foreach (ParamString pString, _paramStrings) {
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
901 QString defaultValue = _indenterSettings->value(pString.paramName + "/ValueDefault").toString();
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
902 pString.lineEdit->setText( defaultValue );
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
903 pString.valueEnabledChkBox->setChecked( _indenterSettings->value(pString.paramName + "/Enabled").toBool() );
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
904 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
905
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
906 // Search for name of each multiple choice parameter and set it.
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
907 foreach (ParamMultiple pMultiple, _paramMultiples) {
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
908 int defaultValue = _indenterSettings->value(pMultiple.paramName + "/ValueDefault").toInt();
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
909 pMultiple.comboBox->setCurrentIndex( defaultValue );
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
910 pMultiple.valueEnabledChkBox->setChecked( _indenterSettings->value(pMultiple.paramName + "/Enabled").toBool() );
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
911 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
912 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
913
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
914
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
915 /*!
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
916 \brief Opens and parses the indenter ini file that is declared by \a iniFilePath.
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
917 */
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
918 void IndentHandler::readIndentIniFile(QString iniFilePath) {
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
919 Q_ASSERT_X( !iniFilePath.isEmpty(), "readIndentIniFile", "iniFilePath is empty" );
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
920
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
921 // open the ini-file that contains all available indenter settings with their additional infos
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
922 _indenterSettings = new UiGuiIniFileParser(iniFilePath);
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
923
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
924 QStringList categories;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
925 //QString indenterGroupString = "";
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
926 QString paramToolTip = "";
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
927
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
928
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
929 //
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
930 // parse ini file indenter header
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
931 //
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
932
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
933 _indenterName = _indenterSettings->value("header/indenterName").toString();
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
934 _indenterFileName = _indenterSettings->value("header/indenterFileName").toString();
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
935 _globalConfigFilename = _indenterSettings->value("header/configFilename").toString();
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
936 _useCfgFileParameter = _indenterSettings->value("header/useCfgFileParameter").toString();
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
937 _cfgFileParameterEnding = _indenterSettings->value("header/cfgFileParameterEnding").toString();
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
938 if ( _cfgFileParameterEnding == "cr" ) {
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
939 _cfgFileParameterEnding = "\n";
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
940 }
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
941 _indenterShowHelpParameter = _indenterSettings->value("header/showHelpParameter").toString();
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
942
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
943 if ( _indenterFileName.isEmpty() ) {
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
944 _errorMessageDialog->showMessage( tr("Indenter ini file header error"),
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
945 tr("The loaded indenter ini file \"%1\"has a faulty header. At least the indenters file name is not set.").arg(iniFilePath) );
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
946 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
947
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
948 // Read the parameter order. Possible values are (p=parameter[file] i=inputfile o=outputfile)
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
949 // pio, ipo, iop
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
950 _parameterOrder = _indenterSettings->value("header/parameterOrder", "pio").toString();
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
951 _inputFileParameter = _indenterSettings->value("header/inputFileParameter").toString();
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
952 _inputFileName = _indenterSettings->value("header/inputFileName").toString();
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
953 _outputFileParameter = _indenterSettings->value("header/outputFileParameter").toString();
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
954 _outputFileName = _indenterSettings->value("header/outputFileName").toString();
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
955 _fileTypes = _indenterSettings->value("header/fileTypes").toString();
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
956 _fileTypes.replace('|', " ");
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
957
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
958 // read the categories names which are separated by "|"
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
959 QString categoriesStr = _indenterSettings->value("header/categories").toString();
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
960 categories = categoriesStr.split("|");
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
961 // Assure that the category list is never empty. At least contain a "general" section.
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
962 if ( categories.isEmpty() ) {
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
963 categories.append("General");
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
964 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
965
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
966 IndenterParameterCategoryPage categoryPage;
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
967
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
968 // create a page for each category and store its references in a toolboxpage-array
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
969 foreach (QString category, categories) {
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
970 categoryPage.widget = new QWidget();
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
971 categoryPage.widget->setObjectName(category);
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
972 categoryPage.widget->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
973 categoryPage.vboxLayout = new QVBoxLayout(categoryPage.widget);
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
974 categoryPage.vboxLayout->setSpacing(6);
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
975 categoryPage.vboxLayout->setMargin(9);
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
976 categoryPage.vboxLayout->setObjectName(category);
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
977 _indenterParameterCategoryPages.append(categoryPage);
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
978 _indenterParameterCategoriesToolBox->addItem(categoryPage.widget, category);
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
979 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
980
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
981
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
982 //
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
983 // parse ini file indenter parameters
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
984 //
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
985
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
986 // read all possible parameters written in brackets []
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
987 _indenterParameters = _indenterSettings->childGroups();
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
988
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
989 // read each parameter to create the corresponding input field
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
990 foreach (QString indenterParameter, _indenterParameters) {
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
991 // if it is not the indent header definition read the parameter and add it to
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
992 // the corresponding category toolbox page
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
993 if ( indenterParameter != "header") {
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
994 // read to which category the parameter belongs
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
995 int category = _indenterSettings->value(indenterParameter + "/Category").toInt();
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
996 // Assure that the category number is never greater than the available categories.
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
997 if ( category > _indenterParameterCategoryPages.size()-1 ) {
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
998 category = _indenterParameterCategoryPages.size()-1;
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
999 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1000 // read which type of input field the parameter needs
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1001 QString editType = _indenterSettings->value(indenterParameter + "/EditorType").toString();
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1002
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1003 // edit type is numeric so create a spinbox with label
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1004 if ( editType == "numeric" ) {
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1005 // read the parameter name as it is used at the command line or in its config file
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1006 QString parameterCallName = _indenterSettings->value(indenterParameter + "/CallName").toString();
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1007
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1008 // create checkbox which enables or disables the parameter
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1009 QCheckBox *chkBox = new QCheckBox( _indenterParameterCategoryPages.at(category).widget );
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1010 chkBox->setChecked( _indenterSettings->value(indenterParameter + "/Enabled").toBool() );
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1011 chkBox->setToolTip( "Enables/disables the parameter. If disabled the indenters default value will be used." );
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1012 chkBox->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1013 int left, top, right, bottom;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1014 chkBox->getContentsMargins( &left, &top, &right, &bottom );
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1015 chkBox->setContentsMargins( left, top, 0, bottom );
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1016
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1017 // create the spinbox
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1018 QSpinBox *spinBox = new QSpinBox( _indenterParameterCategoryPages.at(category).widget );
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1019 paramToolTip = _indenterSettings->value(indenterParameter + "/Description").toString();
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1020 spinBox->setToolTip( paramToolTip );
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1021 spinBox->setMaximumWidth(50);
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1022 spinBox->setMinimumWidth(50);
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1023 if ( _mainWindow != NULL ) {
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1024 spinBox->installEventFilter( _mainWindow );
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1025 }
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1026 if ( _indenterSettings->value(indenterParameter + "/MinVal").toString() != "" ) {
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1027 spinBox->setMinimum( _indenterSettings->value(indenterParameter + "/MinVal").toInt() );
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1028 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1029 else {
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1030 spinBox->setMinimum( 0 );
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1031 }
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1032 if ( _indenterSettings->value(indenterParameter + "/MaxVal").toString() != "" ) {
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1033 spinBox->setMaximum( _indenterSettings->value(indenterParameter + "/MaxVal").toInt() );
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1034 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1035 else {
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1036 spinBox->setMaximum( 2000 );
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1037 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1038
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1039 // create the label
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1040 QLabel *label = new QLabel( _indenterParameterCategoryPages.at(category).widget );
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1041 label->setText(indenterParameter);
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1042 label->setBuddy(spinBox);
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1043 label->setToolTip( paramToolTip );
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1044 if ( _mainWindow != NULL ) {
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1045 label->installEventFilter( _mainWindow );
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1046 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1047
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1048 // put all into a layout and add it to the toolbox page
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1049 QHBoxLayout *hboxLayout = new QHBoxLayout();
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1050 hboxLayout->addWidget(chkBox);
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1051 hboxLayout->addWidget(spinBox);
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1052 hboxLayout->addWidget(label);
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1053 _indenterParameterCategoryPages.at(category).vboxLayout->addLayout(hboxLayout);
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1054
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1055 // remember parameter name and reference to its spinbox
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1056 ParamNumeric paramNumeric;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1057 paramNumeric.paramName = indenterParameter;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1058 paramNumeric.paramCallName = parameterCallName;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1059 paramNumeric.spinBox = spinBox;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1060 paramNumeric.label = label;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1061 paramNumeric.valueEnabledChkBox = chkBox;
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1062 paramNumeric.spinBox->setValue( _indenterSettings->value(paramNumeric.paramName + "/ValueDefault").toInt() );
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1063 _paramNumerics.append(paramNumeric);
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1064
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1065 QObject::connect(spinBox, SIGNAL(valueChanged(int)), this, SLOT(handleChangedIndenterSettings()));
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1066 QObject::connect(chkBox, SIGNAL(clicked()), this, SLOT(handleChangedIndenterSettings()));
646
b2bf2c268930 NPP Improved the update/repaint events a bit, so that the GUI reacts better on user inputs.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 638
diff changeset
1067 #ifdef UNIVERSALINDENTGUI_NPP_EXPORTS
b2bf2c268930 NPP Improved the update/repaint events a bit, so that the GUI reacts better on user inputs.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 638
diff changeset
1068 connect( spinBox, SIGNAL(valueChanged(int)), this, SLOT(updateDrawing()) );
b2bf2c268930 NPP Improved the update/repaint events a bit, so that the GUI reacts better on user inputs.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 638
diff changeset
1069 #endif // UNIVERSALINDENTGUI_NPP_EXPORTS
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1070 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1071 // edit type is boolean so create a checkbox
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1072 else if ( editType == "boolean" ) {
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1073 // create the checkbox, make its settings and add it to the toolbox page
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1074 QCheckBox *chkBox = new QCheckBox( _indenterParameterCategoryPages.at(category).widget );
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1075 chkBox->setText(indenterParameter);
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1076 paramToolTip = _indenterSettings->value(indenterParameter + "/Description").toString();
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1077 chkBox->setToolTip( paramToolTip );
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1078 if ( _mainWindow != NULL ) {
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1079 chkBox->installEventFilter( _mainWindow );
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1080 }
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1081 _indenterParameterCategoryPages.at(category).vboxLayout->addWidget(chkBox);
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1082
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1083 // remember parameter name and reference to its checkbox
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1084 ParamBoolean paramBoolean;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1085 paramBoolean.paramName = indenterParameter;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1086 paramBoolean.checkBox = chkBox;
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1087 QStringList trueFalseStrings = _indenterSettings->value(indenterParameter + "/TrueFalse").toString().split("|");
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1088 paramBoolean.trueString = trueFalseStrings.at(0);
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1089 paramBoolean.falseString = trueFalseStrings.at(1);
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1090 paramBoolean.checkBox->setChecked( _indenterSettings->value(paramBoolean.paramName + "/ValueDefault").toBool() );
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1091 _paramBooleans.append(paramBoolean);
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1092
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1093 QObject::connect(chkBox, SIGNAL(clicked()), this, SLOT(handleChangedIndenterSettings()));
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1094 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1095 // edit type is numeric so create a line edit with label
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1096 else if ( editType == "string" ) {
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1097 // read the parameter name as it is used at the command line or in its config file
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1098 QString parameterCallName = _indenterSettings->value(indenterParameter + "/CallName").toString();
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1099
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1100 // create check box which enables or disables the parameter
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1101 QCheckBox *chkBox = new QCheckBox( _indenterParameterCategoryPages.at(category).widget );
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1102 chkBox->setChecked( _indenterSettings->value(indenterParameter + "/Enabled").toBool() );
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1103 chkBox->setToolTip( "Enables/disables the parameter. If disabled the indenters default value will be used." );
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1104 chkBox->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1105 int left, top, right, bottom;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1106 chkBox->getContentsMargins( &left, &top, &right, &bottom );
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1107 chkBox->setContentsMargins( left, top, 0, bottom );
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1108
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1109 // create the line edit
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1110 QLineEdit *lineEdit = new QLineEdit( _indenterParameterCategoryPages.at(category).widget );
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1111 paramToolTip = _indenterSettings->value(indenterParameter + "/Description").toString();
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1112 lineEdit->setToolTip( paramToolTip );
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1113 lineEdit->setMaximumWidth(50);
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1114 lineEdit->setMinimumWidth(50);
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1115 if ( _mainWindow != NULL ) {
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1116 lineEdit->installEventFilter( _mainWindow );
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1117 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1118
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1119 // create the label
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1120 QLabel *label = new QLabel( _indenterParameterCategoryPages.at(category).widget );
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1121 label->setText(indenterParameter);
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1122 label->setBuddy(lineEdit);
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1123 label->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1124 label->setToolTip( paramToolTip );
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1125 if ( _mainWindow != NULL ) {
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1126 label->installEventFilter( _mainWindow );
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1127 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1128
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1129 // put all into a layout and add it to the toolbox page
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1130 QHBoxLayout *hboxLayout = new QHBoxLayout();
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1131 hboxLayout->addWidget(chkBox);
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1132 hboxLayout->addWidget(lineEdit);
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1133 hboxLayout->addWidget(label);
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1134 _indenterParameterCategoryPages.at(category).vboxLayout->addLayout(hboxLayout);
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1135
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1136 // remember parameter name and reference to its line edit
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1137 ParamString paramString;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1138 paramString.paramName = indenterParameter;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1139 paramString.paramCallName = parameterCallName;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1140 paramString.lineEdit = lineEdit;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1141 paramString.label = label;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1142 paramString.valueEnabledChkBox = chkBox;
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1143 paramString.lineEdit->setText( _indenterSettings->value(paramString.paramName + "/ValueDefault").toString() );
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1144 _paramStrings.append(paramString);
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1145
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1146 QObject::connect(lineEdit, SIGNAL(editingFinished()), this, SLOT(handleChangedIndenterSettings()));
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1147 QObject::connect(chkBox, SIGNAL(clicked()), this, SLOT(handleChangedIndenterSettings()));
646
b2bf2c268930 NPP Improved the update/repaint events a bit, so that the GUI reacts better on user inputs.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 638
diff changeset
1148 #ifdef UNIVERSALINDENTGUI_NPP_EXPORTS
b2bf2c268930 NPP Improved the update/repaint events a bit, so that the GUI reacts better on user inputs.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 638
diff changeset
1149 connect( lineEdit, SIGNAL(textChanged(const QString)), this, SLOT(updateDrawing()) );
b2bf2c268930 NPP Improved the update/repaint events a bit, so that the GUI reacts better on user inputs.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 638
diff changeset
1150 #endif // UNIVERSALINDENTGUI_NPP_EXPORTS
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1151 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1152 // edit type is multiple so create a combobox with label
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1153 else if ( editType == "multiple" ) {
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1154 // read the parameter name as it is used at the command line or in its config file
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1155 QString parameterCallName = _indenterSettings->value(indenterParameter + "/CallName").toString();
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1156
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1157 // create checkbox which enables or disables the parameter
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1158 QCheckBox *chkBox = new QCheckBox( _indenterParameterCategoryPages.at(category).widget );
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1159 chkBox->setChecked( _indenterSettings->value(indenterParameter + "/Enabled").toBool() );
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1160 chkBox->setToolTip( "Enables/disables the parameter. If disabled the indenters default value will be used." );
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1161 chkBox->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1162 int left, top, right, bottom;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1163 chkBox->getContentsMargins( &left, &top, &right, &bottom );
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1164 chkBox->setContentsMargins( left, top, 0, bottom );
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1165
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1166 // create the combo box
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1167 QComboBox *comboBox = new QComboBox( _indenterParameterCategoryPages.at(category).widget );
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1168 QStringList choicesStrings = _indenterSettings->value(indenterParameter + "/Choices").toString().split("|");
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1169 QStringList choicesStringsReadable = _indenterSettings->value(indenterParameter + "/ChoicesReadable").toString().split("|", QString::SkipEmptyParts);
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1170 if ( choicesStringsReadable.isEmpty() ) {
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1171 comboBox->addItems( choicesStrings );
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1172 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1173 else {
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1174 comboBox->addItems( choicesStringsReadable );
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1175 }
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1176 paramToolTip = _indenterSettings->value(indenterParameter + "/Description").toString();
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1177 comboBox->setToolTip( paramToolTip );
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1178 if ( _mainWindow != NULL ) {
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1179 comboBox->installEventFilter( _mainWindow );
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1180 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1181
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1182 // put all into a layout and add it to the toolbox page
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1183 QHBoxLayout *hboxLayout = new QHBoxLayout();
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1184 hboxLayout->addWidget(chkBox);
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1185 hboxLayout->addWidget(comboBox);
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1186 _indenterParameterCategoryPages.at(category).vboxLayout->addLayout(hboxLayout);
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1187
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1188 // remember parameter name and reference to its lineedit
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1189 ParamMultiple paramMultiple;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1190 paramMultiple.paramName = indenterParameter;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1191 paramMultiple.paramCallName = parameterCallName;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1192 paramMultiple.comboBox = comboBox;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1193 paramMultiple.choicesStrings = choicesStrings;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1194 paramMultiple.choicesStringsReadable = choicesStringsReadable;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1195 paramMultiple.valueEnabledChkBox = chkBox;
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1196 paramMultiple.comboBox->setCurrentIndex( _indenterSettings->value(paramMultiple.paramName + "/ValueDefault").toInt() );
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1197 _paramMultiples.append(paramMultiple);
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1198
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1199 QObject::connect(comboBox, SIGNAL(activated(int)), this, SLOT(handleChangedIndenterSettings()));
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1200 QObject::connect(chkBox, SIGNAL(clicked()), this, SLOT(handleChangedIndenterSettings()));
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1201 #ifdef UNIVERSALINDENTGUI_NPP_EXPORTS
646
b2bf2c268930 NPP Improved the update/repaint events a bit, so that the GUI reacts better on user inputs.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 638
diff changeset
1202 connect( comboBox, SIGNAL(activated(int)), this, SLOT(updateDrawing()) );
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1203 #endif // UNIVERSALINDENTGUI_NPP_EXPORTS
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1204 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1205 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1206 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1207
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1208 // put a spacer at each page end
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1209 foreach (IndenterParameterCategoryPage categoryPage, _indenterParameterCategoryPages) {
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1210 categoryPage.vboxLayout->addStretch();
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1211 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1212 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1213
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1214
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1215 /*!
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1216 \brief Searches and returns all indenters a configuration file is found for.
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1217
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1218 Opens all uigui ini files found in the list \a _indenterIniFileList, opens each ini file
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1219 and reads the there defined real name of the indenter. These names are being returned as QStringList.
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1220 */
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1221 QStringList IndentHandler::getAvailableIndenters() {
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1222 QStringList indenterNamesList;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1223
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1224 // Loop for every existing uigui ini file
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1225 foreach (QString indenterIniFile, _indenterIniFileList) {
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1226 // Open the ini file and search for the indenter name
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1227 QFile file(_indenterDirctoryStr + "/" + indenterIniFile);
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1228 if ( file.open(QIODevice::ReadOnly | QIODevice::Text) ) {
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1229 int index = -1;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1230 QByteArray line;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1231 // Search for the string "indenterName=" and get the following string until line end.
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1232 while ( index == -1 && !file.atEnd() ) {
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1233 line = file.readLine();
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1234 index = line.indexOf( "indenterName=", 0);
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1235 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1236
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1237 if ( index == 0 ) {
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1238 line = line.remove(0, 13);
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1239 indenterNamesList << line.trimmed();
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1240 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1241 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1242 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1243 return indenterNamesList;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1244 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1245
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1246
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1247 /*!
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1248 \brief Deletes all elements in the toolbox and initializes the indenter selected by \a indenterID.
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1249 */
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1250 void IndentHandler::setIndenter(int indenterID) {
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1251 QApplication::setOverrideCursor(Qt::WaitCursor);
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1252
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1253 #ifdef UNIVERSALINDENTGUI_NPP_EXPORTS
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1254 disconnect( _indenterParameterCategoriesToolBox, SIGNAL(currentChanged(int)), this, SLOT(updateDrawing()) );
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1255 #endif // UNIVERSALINDENTGUI_NPP_EXPORTS
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1256
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1257 // Generate the parameter string that will be saved to the indenters config file.
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1258 QString parameterString = getParameterString();
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1259 if ( !_indenterFileName.isEmpty() ) {
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1260 saveConfigFile( _settingsDirctoryStr + "/" + _indenterFileName + ".cfg", parameterString );
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1261 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1262
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1263 // Take care if the selected indenterID is smaller or greater than the number of existing indenters
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1264 if ( indenterID < 0 ) {
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1265 indenterID = 0;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1266 }
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1267 if ( indenterID >= _indenterIniFileList.count() ) {
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1268 indenterID = _indenterIniFileList.count() - 1;
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1269 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1270
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1271 // remove all pages from the toolbox
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1272 for (int i = 0; i < _indenterParameterCategoriesToolBox->count(); i++) {
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1273 _indenterParameterCategoriesToolBox->removeItem(i);
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1274 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1275
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1276 // delete all toolbox pages and by this its children
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1277 foreach (IndenterParameterCategoryPage categoryPage, _indenterParameterCategoryPages) {
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1278 delete categoryPage.widget;
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1279 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1280
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1281 // empty all lists, which stored infos for the toolbox pages and its widgets
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1282 _indenterParameterCategoryPages.clear();
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1283 _paramStrings.clear();
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1284 _paramNumerics.clear();
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1285 _paramBooleans.clear();
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1286 _paramMultiples.clear();
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1287 delete _indenterSettings;
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1288
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1289 #ifdef UNIVERSALINDENTGUI_NPP_EXPORTS
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1290 QWidget dummyWidget;
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1291 _indenterParameterCategoriesToolBox->addItem(&dummyWidget, "dummyText");
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1292 #endif
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1293
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1294 readIndentIniFile( _indenterDirctoryStr + "/" + _indenterIniFileList.at(indenterID) );
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1295
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1296 // Find out how the indenter can be executed.
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1297 createIndenterCallString();
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1298
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1299 // Load the users last settings made for this indenter.
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1300 loadConfigFile( _settingsDirctoryStr + "/" + _indenterFileName + ".cfg" );
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1301
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1302 handleChangedIndenterSettings();
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1303
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1304 QApplication::restoreOverrideCursor();
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1305
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1306 #ifdef UNIVERSALINDENTGUI_NPP_EXPORTS
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1307 connect( _indenterParameterCategoriesToolBox, SIGNAL(currentChanged(int)), this, SLOT(updateDrawing()) );
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1308 _indenterParameterCategoriesToolBox->removeItem( _indenterParameterCategoriesToolBox->indexOf(&dummyWidget) );
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1309 #endif // UNIVERSALINDENTGUI_NPP_EXPORTS
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1310 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1311
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1312
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1313 /*!
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1314 \brief Returns a string containing by the indenter supported file types/extensions divided by a space.
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1315 */
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1316 QString IndentHandler::getPossibleIndenterFileExtensions() {
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1317 return _fileTypes;
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1318 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1319
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1320
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1321 /*!
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1322 \brief Returns the path and filename of the current indenter config file.
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1323 */
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1324 QString IndentHandler::getIndenterCfgFile() {
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1325 QFileInfo fileInfo( _indenterDirctoryStr + "/" + _globalConfigFilename );
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1326 return fileInfo.absoluteFilePath();
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1327 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1328
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1329
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1330 /*!
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1331 \brief Tries to create a call path string for the indenter executable. If successful returns true.
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1332 */
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1333 bool IndentHandler::createIndenterCallString() {
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1334 QProcess indentProcess;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1335
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1336 if ( _indenterFileName.isEmpty() ) {
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1337 return false;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1338 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1339
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1340 // First try to call the indenter inside of the data dir, using some suffix
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1341 // ------------------------------------------------------------------------
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1342
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1343 // Set the directory for the indenter execution
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1344 indentProcess.setWorkingDirectory( QFileInfo(_indenterDirctoryStr).absoluteFilePath() );
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1345
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1346 foreach ( QString suffix, QStringList() << "" << ".exe" << ".bat" << ".com" << ".sh" ) {
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1347 _indenterExecutableSuffix = suffix;
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1348 _indenterExecutableCallString = QFileInfo(_indenterDirctoryStr).absoluteFilePath() + "/" + _indenterFileName;
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1349 _indenterExecutableCallString += suffix;
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1350
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1351 // Only try to call the indenter, if the file exists.
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1352 if ( QFile::exists(_indenterExecutableCallString) ) {
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1353 // Only try to call the indenter directly if it is no php file
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1354 if ( QFileInfo(_indenterExecutableCallString).suffix().toLower() != "php" ) {
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1355 indentProcess.start( "\"" + _indenterExecutableCallString + + "\" " + _indenterShowHelpParameter );
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1356 if ( indentProcess.waitForFinished(2000) ) {
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1357 _indenterExecutableCallString = "\"" + _indenterExecutableCallString + "\"";
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1358 return true;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1359 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1360 else if ( indentProcess.error() == QProcess::Timedout ) {
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1361 _indenterExecutableCallString = "\"" + _indenterExecutableCallString + "\"";
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1362 return true;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1363 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1364 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1365
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1366 // Test for needed interpreters
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1367 // ----------------------------
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1368 // If the file could not be executed, try to find a shebang at its start or test if its a php file.
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1369 QString interpreterName = "";
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1370 QFile indenterExecutable( _indenterExecutableCallString );
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1371
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1372 // If indenter executable file has .php as suffix, use php as default interpreter
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1373 if ( QFileInfo(_indenterExecutableCallString).suffix().toLower() == "php" ) {
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1374 interpreterName = "php -f";
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1375 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1376 // Else try to open the file and read the shebang.
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1377 else if ( indenterExecutable.open(QFile::ReadOnly) ) {
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1378 // Read the first line of the file.
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1379 QTextStream indenterExecutableContent(&indenterExecutable);
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1380 QString firstLineOfIndenterExe = indenterExecutableContent.readLine(75);
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1381 indenterExecutable.close();
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1382
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1383 // If the initial shebang is found, read the named intepreter. e.g. perl
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1384 if ( firstLineOfIndenterExe.startsWith("#!") ) {
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1385 // Get the rightmost word. by splitting the string into only full words.
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1386 interpreterName = firstLineOfIndenterExe.split( "/" ).last();
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1387 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1388 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1389
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1390 // Try to call the interpreter, if it exists.
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1391 if ( !interpreterName.isEmpty() ) {
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1392 _indenterExecutableCallString = interpreterName + " \"" + _indenterExecutableCallString + "\"";
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1393 indentProcess.start( interpreterName + " -h");
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1394 if ( indentProcess.waitForFinished(2000) ) {
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1395 return true;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1396 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1397 else if ( indentProcess.error() == QProcess::Timedout ) {
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1398 return true;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1399 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1400 // now we know an interpreter is needed but it could not be called, so inform the user.
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1401 else {
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1402 _errorMessageDialog->showMessage( tr("Interpreter needed"),
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1403 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) );
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1404 return true;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1405 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1406 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1407 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1408 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1409
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1410
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1411 // If unsuccessful try if the indenter executable is a JavaScript file
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1412 // -------------------------------------------------------------------
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1413 _indenterExecutableSuffix = ".js";
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1414 _indenterExecutableCallString = QFileInfo(_indenterDirctoryStr).absoluteFilePath() + "/" + _indenterFileName;
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1415 _indenterExecutableCallString += _indenterExecutableSuffix;
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1416 if ( QFile::exists(_indenterExecutableCallString) ) {
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1417 return true;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1418 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1419
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1420
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1421 // If unsuccessful try to call the indenter global, using some suffix
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1422 // ------------------------------------------------------------------
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1423 foreach ( QString suffix, QStringList() << "" << ".exe" << ".bat" << ".com" << ".sh" ) {
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1424 _indenterExecutableSuffix = suffix;
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1425 _indenterExecutableCallString = _indenterFileName + suffix;
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1426 indentProcess.start( _indenterExecutableCallString + " " + _indenterShowHelpParameter );
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1427 if ( indentProcess.waitForFinished(2000) ) {
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1428 return true;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1429 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1430 else if ( indentProcess.error() == QProcess::Timedout ) {
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1431 return true;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1432 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1433 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1434
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1435
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1436 // If even globally calling the indenter fails, try calling .com and .exe via wine
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1437 // -------------------------------------------------------------------------------
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1438 _indenterExecutableCallString = "\"" + QFileInfo(_indenterDirctoryStr).absoluteFilePath() + "/" + _indenterFileName;
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1439
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1440 foreach ( QString suffix, QStringList() << ".exe" << ".com" ) {
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1441 _indenterExecutableSuffix = suffix;
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1442 if ( QFile::exists(_indenterDirctoryStr + "/" + _indenterFileName + suffix) ) {
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1443 QProcess wineTestProcess;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1444 wineTestProcess.start("wine --version");
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1445 // if the process of wine was not callable assume that wine is not installed
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1446 if ( !wineTestProcess.waitForFinished(2000) ) {
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1447 _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.") );
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1448 _indenterExecutableCallString = "";
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1449 return false;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1450 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1451 else {
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1452 _indenterExecutableCallString = "\"" + QFileInfo(_indenterDirctoryStr).absoluteFilePath() + "/";
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1453 _indenterExecutableCallString += _indenterFileName + suffix + "\"";
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1454 _indenterExecutableCallString = "wine " + _indenterExecutableCallString;
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1455
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1456 return true;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1457 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1458 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1459 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1460
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1461 _indenterExecutableCallString = "";
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1462 _indenterExecutableSuffix = "";
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1463 return false;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1464 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1465
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1466
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1467 /*!
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1468 \brief Returns a string that points to where the indenters manual can be found.
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1469 */
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1470 QString IndentHandler::getManual() {
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1471 if ( _indenterSettings != NULL ) {
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1472 return _indenterSettings->value("header/manual").toString();
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1473 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1474 else {
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1475 return "";
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1476 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1477 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1478
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1479
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1480 /*!
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1481 \brief This slot gets the reference to the indenters manual and opens it.
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1482 */
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1483 void IndentHandler::showIndenterManual() {
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1484 QString manualReference = getManual();
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1485 QDesktopServices::openUrl( manualReference );
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1486 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1487
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1488
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1489 /*!
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1490 \brief Can be called to update all widgets text to the currently selected language.
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1491 */
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1492 void IndentHandler::retranslateUi() {
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1493 _indenterSelectionCombobox->setToolTip( tr("<html><head><meta name=\"qrichtext\" content=\"1\" /></head><body style=\" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;\"><p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Shows the currently chosen indenters name and lets you choose other available indenters</p></body></html>") );
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1494 _indenterParameterHelpButton->setToolTip( tr("Brings you to the online manual of the currently selected indenter, where you can get further help on the possible parameters.") );
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1495
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1496 _actionLoadIndenterConfigFile->setText(QApplication::translate("IndentHandler", "Load Indenter Config File", 0, QApplication::UnicodeUTF8));
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1497 _actionLoadIndenterConfigFile->setStatusTip(QApplication::translate("IndentHandler", "Opens a file dialog to load the original config file of the indenter.", 0, QApplication::UnicodeUTF8));
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1498 _actionLoadIndenterConfigFile->setShortcut(QApplication::translate("IndentHandler", "Alt+O", 0, QApplication::UnicodeUTF8));
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1499
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1500 _actionSaveIndenterConfigFile->setText(QApplication::translate("IndentHandler", "Save Indenter Config File", 0, QApplication::UnicodeUTF8));
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1501 _actionSaveIndenterConfigFile->setStatusTip(QApplication::translate("IndentHandler", "Opens a dialog to save the current indenter configuration to a file.", 0, QApplication::UnicodeUTF8));
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1502 _actionSaveIndenterConfigFile->setShortcut(QApplication::translate("IndentHandler", "Alt+S", 0, QApplication::UnicodeUTF8));
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1503
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1504 _actionCreateShellScript->setText(QApplication::translate("IndentHandler", "Create Indenter Call Shell Script", 0, QApplication::UnicodeUTF8));
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1505 _actionCreateShellScript->setToolTip(QApplication::translate("IndentHandler", "Create a shell script that calls the current selected indenter for formatting an as parameter given file with the current indent settings.", 0, QApplication::UnicodeUTF8));
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1506 _actionCreateShellScript->setStatusTip(QApplication::translate("IndentHandler", "Create a shell script that calls the current selected indenter for formatting an as parameter given file with the current indent settings.", 0, QApplication::UnicodeUTF8));
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1507
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1508 _actionResetIndenterParameters->setText(QApplication::translate("IndentHandler", "Reset indenter parameters", 0, QApplication::UnicodeUTF8));
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1509 _actionResetIndenterParameters->setToolTip(QApplication::translate("IndentHandler", "Resets all indenter parameters to the default values.", 0, QApplication::UnicodeUTF8));
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1510 _actionResetIndenterParameters->setStatusTip(QApplication::translate("IndentHandler", "Resets all indenter parameters to the default values.", 0, QApplication::UnicodeUTF8));
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1511 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1512
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1513
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1514 /*!
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1515 \brief Returns the name of the currently selected indenter.
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1516 */
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1517 QString IndentHandler::getCurrentIndenterName() {
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1518 QString currentIndenterName = _indenterSelectionCombobox->currentText();
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1519
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1520 // Remove the supported programming languages from indenters name, which are set in braces.
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1521 if ( currentIndenterName.indexOf("(") > 0 ) {
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1522 // Using index-1 to also leave out the blank before the brace.
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1523 currentIndenterName = currentIndenterName.left( currentIndenterName.indexOf("(")-1 );
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1524 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1525
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1526 return currentIndenterName;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1527 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1528
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1529
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1530 /*!
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1531 \brief Shows a file open dialog to open an existing config file for the currently selected indenter.
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1532
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1533 If the file was successfully opened the indent handler is called to load the settings and update itself.
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1534 */
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1535 void IndentHandler::openConfigFileDialog() {
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1536 QString configFilePath;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1537
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1538 configFilePath = QFileDialog::getOpenFileName( NULL, tr("Choose indenter config file"), getIndenterCfgFile(), "All files (*.*)" );
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1539
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1540 if (configFilePath != "") {
723
69e893792522 [fix] Bug ID 2942381: When loading an indenter configuration file, the settings displayed in th docking widget were correctly updated, but the code wasn't.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 716
diff changeset
1541 // If the config file was loaded successfully, inform any who is interested about it.
69e893792522 [fix] Bug ID 2942381: When loading an indenter configuration file, the settings displayed in th docking widget were correctly updated, but the code wasn't.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 716
diff changeset
1542 if ( loadConfigFile(configFilePath) )
69e893792522 [fix] Bug ID 2942381: When loading an indenter configuration file, the settings displayed in th docking widget were correctly updated, but the code wasn't.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 716
diff changeset
1543 handleChangedIndenterSettings();
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1544 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1545 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1546
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1547
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1548 /*!
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1549 \brief Calls the indenter config file save as dialog to save the config file under a chosen name.
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1550
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1551 If the file already exists and it should be overwritten, a warning is shown before.
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1552 */
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1553 void IndentHandler::saveasIndentCfgFileDialog() {
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1554 QString fileExtensions = tr("All files")+" (*.*)";
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1555
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1556 //QString openedSourceFileContent = openFileDialog( tr("Choose source code file"), "./", fileExtensions );
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1557 QString fileName = QFileDialog::getSaveFileName( this, tr("Save indent config file"), getIndenterCfgFile(), fileExtensions);
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1558
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1559 if (fileName != "") {
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1560 QFile::remove(fileName);
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1561 QFile outCfgFile(fileName);
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1562 outCfgFile.open( QFile::ReadWrite | QFile::Text );
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1563 outCfgFile.write( getParameterString().toAscii() );
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1564 outCfgFile.close();
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1565 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1566 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1567
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1568
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1569 /*!
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1570 \brief Invokes the indenter to create a shell script.
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1571
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1572 Lets the indenter create a shell script for calling the indenter out of any
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1573 other application and open a save dialog for saving the shell script.
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1574 */
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1575 void IndentHandler::createIndenterCallShellScript() {
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1576 QString shellScriptExtension;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1577 #if defined(Q_OS_WIN32)
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1578 shellScriptExtension = "bat";
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1579 #else
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1580 shellScriptExtension = "sh";
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1581 #endif
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1582
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1583 QString fileExtensions = tr("Shell Script")+" (*."+shellScriptExtension+");;"+tr("All files")+" (*.*)";
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1584
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1585 QString currentIndenterName = getCurrentIndenterName();
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1586 currentIndenterName = currentIndenterName.replace(" ", "_");
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1587
723
69e893792522 [fix] Bug ID 2942381: When loading an indenter configuration file, the settings displayed in th docking widget were correctly updated, but the code wasn't.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 716
diff changeset
1588 QString shellScriptFileName = QFileDialog::getSaveFileName( this, tr("Save shell script"), "call_"+currentIndenterName+"."+shellScriptExtension, fileExtensions);
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1589
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1590 // Saving has been canceled if the filename is empty
723
69e893792522 [fix] Bug ID 2942381: When loading an indenter configuration file, the settings displayed in th docking widget were correctly updated, but the code wasn't.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 716
diff changeset
1591 if ( shellScriptFileName.isEmpty() ) {
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1592 return;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1593 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1594
723
69e893792522 [fix] Bug ID 2942381: When loading an indenter configuration file, the settings displayed in th docking widget were correctly updated, but the code wasn't.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 716
diff changeset
1595 // Delete any old file, write the new contents and set executable permissions.
69e893792522 [fix] Bug ID 2942381: When loading an indenter configuration file, the settings displayed in th docking widget were correctly updated, but the code wasn't.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 716
diff changeset
1596 QFile::remove(shellScriptFileName);
69e893792522 [fix] Bug ID 2942381: When loading an indenter configuration file, the settings displayed in th docking widget were correctly updated, but the code wasn't.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 716
diff changeset
1597 QFile outSrcFile(shellScriptFileName);
69e893792522 [fix] Bug ID 2942381: When loading an indenter configuration file, the settings displayed in th docking widget were correctly updated, but the code wasn't.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 716
diff changeset
1598 if ( outSrcFile.open( QFile::ReadWrite | QFile::Text ) ) {
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1599 QString shellScriptConfigFilename = QFileInfo(shellScriptFileName).baseName() + "." + QFileInfo(_globalConfigFilename).suffix();
723
69e893792522 [fix] Bug ID 2942381: When loading an indenter configuration file, the settings displayed in th docking widget were correctly updated, but the code wasn't.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 716
diff changeset
1600
69e893792522 [fix] Bug ID 2942381: When loading an indenter configuration file, the settings displayed in th docking widget were correctly updated, but the code wasn't.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 716
diff changeset
1601 // Get the content of the shell/batch script.
69e893792522 [fix] Bug ID 2942381: When loading an indenter configuration file, the settings displayed in th docking widget were correctly updated, but the code wasn't.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 716
diff changeset
1602 QString indenterCallShellScript = generateShellScript(shellScriptConfigFilename);
69e893792522 [fix] Bug ID 2942381: When loading an indenter configuration file, the settings displayed in th docking widget were correctly updated, but the code wasn't.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 716
diff changeset
1603
69e893792522 [fix] Bug ID 2942381: When loading an indenter configuration file, the settings displayed in th docking widget were correctly updated, but the code wasn't.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 716
diff changeset
1604 // Replace placeholder for script name in script template.
69e893792522 [fix] Bug ID 2942381: When loading an indenter configuration file, the settings displayed in th docking widget were correctly updated, but the code wasn't.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 716
diff changeset
1605 indenterCallShellScript = indenterCallShellScript.replace( "__INDENTERCALLSTRINGSCRIPTNAME__", QFileInfo(shellScriptFileName).fileName() );
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1606
723
69e893792522 [fix] Bug ID 2942381: When loading an indenter configuration file, the settings displayed in th docking widget were correctly updated, but the code wasn't.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 716
diff changeset
1607 outSrcFile.write( indenterCallShellScript.toAscii() );
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1608 #if !defined(Q_OS_WIN32)
723
69e893792522 [fix] Bug ID 2942381: When loading an indenter configuration file, the settings displayed in th docking widget were correctly updated, but the code wasn't.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 716
diff changeset
1609 // For none Windows systems set the files executable flag
69e893792522 [fix] Bug ID 2942381: When loading an indenter configuration file, the settings displayed in th docking widget were correctly updated, but the code wasn't.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 716
diff changeset
1610 outSrcFile.setPermissions( outSrcFile.permissions() | QFile::ExeOwner | QFile::ExeUser| QFile::ExeGroup );
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1611 #endif
723
69e893792522 [fix] Bug ID 2942381: When loading an indenter configuration file, the settings displayed in th docking widget were correctly updated, but the code wasn't.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 716
diff changeset
1612 outSrcFile.close();
69e893792522 [fix] Bug ID 2942381: When loading an indenter configuration file, the settings displayed in th docking widget were correctly updated, but the code wasn't.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 716
diff changeset
1613
69e893792522 [fix] Bug ID 2942381: When loading an indenter configuration file, the settings displayed in th docking widget were correctly updated, but the code wasn't.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 716
diff changeset
1614 // Save the indenter config file to the same directory, where the shell srcipt was saved to,
69e893792522 [fix] Bug ID 2942381: When loading an indenter configuration file, the settings displayed in th docking widget were correctly updated, but the code wasn't.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 716
diff changeset
1615 // because the script will reference it there via "./".
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1616 if ( !_globalConfigFilename.isEmpty() ) {
723
69e893792522 [fix] Bug ID 2942381: When loading an indenter configuration file, the settings displayed in th docking widget were correctly updated, but the code wasn't.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 716
diff changeset
1617 saveConfigFile( QFileInfo(shellScriptFileName).path() + "/" + shellScriptConfigFilename, getParameterString() );
69e893792522 [fix] Bug ID 2942381: When loading an indenter configuration file, the settings displayed in th docking widget were correctly updated, but the code wasn't.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 716
diff changeset
1618 }
69e893792522 [fix] Bug ID 2942381: When loading an indenter configuration file, the settings displayed in th docking widget were correctly updated, but the code wasn't.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 716
diff changeset
1619 }
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1620 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1621
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1622
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1623 /*!
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1624 \brief Resets all parameters to the indenters default values as they are specified in the uigui ini file
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1625 but asks the user whether to do it really.
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1626 */
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1627 void IndentHandler::resetIndenterParameter() {
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1628 int messageBoxAnswer = QMessageBox::question(this, tr("Really reset parameters?"), tr("Do you really want to reset the indenter parameters to the default values?"), QMessageBox::Yes | QMessageBox::Abort );
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1629 if ( messageBoxAnswer == QMessageBox::Yes ) {
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1630 resetToDefaultValues();
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1631 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1632 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1633
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1634
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1635 /*!
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1636 \brief Catch some events and let some other be handled by the super class.
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1637
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1638 Is needed for use as Notepad++ plugin.
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1639 */
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1640 bool IndentHandler::event( QEvent *event ) {
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1641 if ( event->type() == QEvent::WindowActivate ) {
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1642 event->accept();
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1643 return true;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1644 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1645 else if ( event->type() == QEvent::WindowDeactivate ) {
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1646 event->accept();
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1647 return true;
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1648 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1649 else {
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1650 event->ignore();
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1651 return QWidget::event(event);
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1652 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1653 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1654
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1655
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1656 /*!
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1657 \brief Sets the function pointer \a _parameterChangedCallback to the given callback
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1658 function \a paramChangedCallback.
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1659
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1660 Is needed for use as Notepad++ plugin.
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1661 */
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1662 void IndentHandler::setParameterChangedCallback( void(*paramChangedCallback)(void) ) {
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1663 _parameterChangedCallback = paramChangedCallback;
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1664 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1665
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1666
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1667 /*!
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1668 \brief Emits the \a indenterSettingsChanged signal and if set executes the \a _parameterChangedCallback function.
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1669
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1670 Is needed for use as Notepad++ plugin.
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1671 */
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1672 void IndentHandler::handleChangedIndenterSettings() {
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1673 emit( indenterSettingsChanged() );
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1674
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1675 if ( _parameterChangedCallback != NULL ) {
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1676 _parameterChangedCallback();
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1677 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1678 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1679
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1680
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1681 /*!
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1682 \brief Sets a callback function that shall be called, when the this indenter parameter window gets closed.
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1683
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1684 Is needed for use as Notepad++ plugin.
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1685 */
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1686 void IndentHandler::setWindowClosedCallback( void(*winClosedCallback)(void) ) {
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1687 _windowClosedCallback = winClosedCallback;
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1688 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1689
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1690
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1691 /*!
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1692 \brief Is called on this indenter parameter window close and if set calls the function \a _windowClosedCallback.
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1693
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1694 Is needed for use as Notepad++ plugin.
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1695 */
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1696 void IndentHandler::closeEvent(QCloseEvent *event) {
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1697 if ( _windowClosedCallback != NULL ) {
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1698 _windowClosedCallback();
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1699 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1700 event->accept();
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1701 }
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1702
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1703
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1704 /*!
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1705 \brief Returns the id (list index) of the currently selected indenter.
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1706 */
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1707 int IndentHandler::getIndenterId() {
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1708 return _indenterSelectionCombobox->currentIndex();
638
94734b9eb54f Renamed the source files and some classes to have consistent names. What a nice kind of work.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
diff changeset
1709 }
646
b2bf2c268930 NPP Improved the update/repaint events a bit, so that the GUI reacts better on user inputs.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 638
diff changeset
1710
b2bf2c268930 NPP Improved the update/repaint events a bit, so that the GUI reacts better on user inputs.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 638
diff changeset
1711
b2bf2c268930 NPP Improved the update/repaint events a bit, so that the GUI reacts better on user inputs.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 638
diff changeset
1712 void IndentHandler::updateDrawing() {
b2bf2c268930 NPP Improved the update/repaint events a bit, so that the GUI reacts better on user inputs.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 638
diff changeset
1713 #ifdef UNIVERSALINDENTGUI_NPP_EXPORTS
b2bf2c268930 NPP Improved the update/repaint events a bit, so that the GUI reacts better on user inputs.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 638
diff changeset
1714 if ( isVisible() ) {
b2bf2c268930 NPP Improved the update/repaint events a bit, so that the GUI reacts better on user inputs.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 638
diff changeset
1715 QRect savedGeometry = geometry();
b2bf2c268930 NPP Improved the update/repaint events a bit, so that the GUI reacts better on user inputs.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 638
diff changeset
1716 setGeometry( savedGeometry.adjusted(0,0,0,1) );
b2bf2c268930 NPP Improved the update/repaint events a bit, so that the GUI reacts better on user inputs.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 638
diff changeset
1717 repaint();
b2bf2c268930 NPP Improved the update/repaint events a bit, so that the GUI reacts better on user inputs.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 638
diff changeset
1718 setGeometry( savedGeometry );
b2bf2c268930 NPP Improved the update/repaint events a bit, so that the GUI reacts better on user inputs.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 638
diff changeset
1719 }
b2bf2c268930 NPP Improved the update/repaint events a bit, so that the GUI reacts better on user inputs.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 638
diff changeset
1720 #endif // UNIVERSALINDENTGUI_NPP_EXPORTS
b2bf2c268930 NPP Improved the update/repaint events a bit, so that the GUI reacts better on user inputs.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 638
diff changeset
1721 }
b2bf2c268930 NPP Improved the update/repaint events a bit, so that the GUI reacts better on user inputs.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 638
diff changeset
1722
b2bf2c268930 NPP Improved the update/repaint events a bit, so that the GUI reacts better on user inputs.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 638
diff changeset
1723 void IndentHandler::wheelEvent( QWheelEvent *event ) {
b2bf2c268930 NPP Improved the update/repaint events a bit, so that the GUI reacts better on user inputs.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 638
diff changeset
1724 #ifdef UNIVERSALINDENTGUI_NPP_EXPORTS
b2bf2c268930 NPP Improved the update/repaint events a bit, so that the GUI reacts better on user inputs.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 638
diff changeset
1725 QWidget::wheelEvent( event );
b2bf2c268930 NPP Improved the update/repaint events a bit, so that the GUI reacts better on user inputs.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 638
diff changeset
1726 updateDrawing();
b2bf2c268930 NPP Improved the update/repaint events a bit, so that the GUI reacts better on user inputs.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 638
diff changeset
1727 #endif // UNIVERSALINDENTGUI_NPP_EXPORTS
b2bf2c268930 NPP Improved the update/repaint events a bit, so that the GUI reacts better on user inputs.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 638
diff changeset
1728 }
654
68b44fb0c0ce Made it possible to define "stdin" to be used for an indenter calling. Also encoded the messages to be shown in an error message box as HTML so that < > and & will be displayed correctly. And from now on no longer merging stdout and stderr so that outputs to stderr will no longer make it into the to stdout returned formatted code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 648
diff changeset
1729
68b44fb0c0ce Made it possible to define "stdin" to be used for an indenter calling. Also encoded the messages to be shown in an error message box as HTML so that < > and & will be displayed correctly. And from now on no longer merging stdout and stderr so that outputs to stderr will no longer make it into the to stdout returned formatted code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 648
diff changeset
1730
68b44fb0c0ce Made it possible to define "stdin" to be used for an indenter calling. Also encoded the messages to be shown in an error message box as HTML so that < > and & will be displayed correctly. And from now on no longer merging stdout and stderr so that outputs to stderr will no longer make it into the to stdout returned formatted code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 648
diff changeset
1731 /*!
68b44fb0c0ce Made it possible to define "stdin" to be used for an indenter calling. Also encoded the messages to be shown in an error message box as HTML so that < > and & will be displayed correctly. And from now on no longer merging stdout and stderr so that outputs to stderr will no longer make it into the to stdout returned formatted code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 648
diff changeset
1732 \brief Converts characters < > and & in the \a text to HTML codes &lt &gt and &amp.
68b44fb0c0ce Made it possible to define "stdin" to be used for an indenter calling. Also encoded the messages to be shown in an error message box as HTML so that < > and & will be displayed correctly. And from now on no longer merging stdout and stderr so that outputs to stderr will no longer make it into the to stdout returned formatted code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 648
diff changeset
1733 */
751
ac165b6ae67e Done some refactoring:
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 750
diff changeset
1734 //TODO: This function should go into a string helper/tool class/file.
654
68b44fb0c0ce Made it possible to define "stdin" to be used for an indenter calling. Also encoded the messages to be shown in an error message box as HTML so that < > and & will be displayed correctly. And from now on no longer merging stdout and stderr so that outputs to stderr will no longer make it into the to stdout returned formatted code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 648
diff changeset
1735 QString IndentHandler::encodeToHTML(const QString &text) {
68b44fb0c0ce Made it possible to define "stdin" to be used for an indenter calling. Also encoded the messages to be shown in an error message box as HTML so that < > and & will be displayed correctly. And from now on no longer merging stdout and stderr so that outputs to stderr will no longer make it into the to stdout returned formatted code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 648
diff changeset
1736 QString htmlText = text;
68b44fb0c0ce Made it possible to define "stdin" to be used for an indenter calling. Also encoded the messages to be shown in an error message box as HTML so that < > and & will be displayed correctly. And from now on no longer merging stdout and stderr so that outputs to stderr will no longer make it into the to stdout returned formatted code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 648
diff changeset
1737 htmlText.replace("&", "&amp;");
68b44fb0c0ce Made it possible to define "stdin" to be used for an indenter calling. Also encoded the messages to be shown in an error message box as HTML so that < > and & will be displayed correctly. And from now on no longer merging stdout and stderr so that outputs to stderr will no longer make it into the to stdout returned formatted code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 648
diff changeset
1738 htmlText.replace("<", "&lt;");
68b44fb0c0ce Made it possible to define "stdin" to be used for an indenter calling. Also encoded the messages to be shown in an error message box as HTML so that < > and & will be displayed correctly. And from now on no longer merging stdout and stderr so that outputs to stderr will no longer make it into the to stdout returned formatted code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 648
diff changeset
1739 htmlText.replace(">", "&gt;");
68b44fb0c0ce Made it possible to define "stdin" to be used for an indenter calling. Also encoded the messages to be shown in an error message box as HTML so that < > and & will be displayed correctly. And from now on no longer merging stdout and stderr so that outputs to stderr will no longer make it into the to stdout returned formatted code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 648
diff changeset
1740 htmlText.replace('"', "&quot;");
68b44fb0c0ce Made it possible to define "stdin" to be used for an indenter calling. Also encoded the messages to be shown in an error message box as HTML so that < > and & will be displayed correctly. And from now on no longer merging stdout and stderr so that outputs to stderr will no longer make it into the to stdout returned formatted code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 648
diff changeset
1741 htmlText.replace("'", "&#39;");
68b44fb0c0ce Made it possible to define "stdin" to be used for an indenter calling. Also encoded the messages to be shown in an error message box as HTML so that < > and & will be displayed correctly. And from now on no longer merging stdout and stderr so that outputs to stderr will no longer make it into the to stdout returned formatted code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 648
diff changeset
1742 htmlText.replace("^", "&circ;");
68b44fb0c0ce Made it possible to define "stdin" to be used for an indenter calling. Also encoded the messages to be shown in an error message box as HTML so that < > and & will be displayed correctly. And from now on no longer merging stdout and stderr so that outputs to stderr will no longer make it into the to stdout returned formatted code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 648
diff changeset
1743 htmlText.replace("~", "&tilde;");
684
aa29b98f5242 [fix] Bug ID 2791229: If UiGUI was located in a path containing Unicode characters or such a path needed to be handed over to a called indenter, the indenter could get confused on Windows. So using the Windows 8.3 short path notation.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 681
diff changeset
1744 htmlText.replace("€", "&euro;");
aa29b98f5242 [fix] Bug ID 2791229: If UiGUI was located in a path containing Unicode characters or such a path needed to be handed over to a called indenter, the indenter could get confused on Windows. So using the Windows 8.3 short path notation.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 681
diff changeset
1745 htmlText.replace("©", "&copy;");
654
68b44fb0c0ce Made it possible to define "stdin" to be used for an indenter calling. Also encoded the messages to be shown in an error message box as HTML so that < > and & will be displayed correctly. And from now on no longer merging stdout and stderr so that outputs to stderr will no longer make it into the to stdout returned formatted code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 648
diff changeset
1746 return htmlText;
68b44fb0c0ce Made it possible to define "stdin" to be used for an indenter calling. Also encoded the messages to be shown in an error message box as HTML so that < > and & will be displayed correctly. And from now on no longer merging stdout and stderr so that outputs to stderr will no longer make it into the to stdout returned formatted code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents: 648
diff changeset
1747 }