UniversalIndentGUI 1.2.0
IndentHandler.h
Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2006-2012 by Thomas Schweitzer                          *
00003  *   thomas-schweitzer(at)arcor.de                                         *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License version 2.0 as   *
00007  *   published by the Free Software Foundation.                            *
00008  *                                                                         *
00009  *   This program is distributed in the hope that it will be useful,       *
00010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00012  *   GNU General Public License for more details.                          *
00013  *                                                                         *
00014  *   You should have received a copy of the GNU General Public License     *
00015  *   along with this program in the file LICENSE.GPL; if not, write to the *
00016  *   Free Software Foundation, Inc.,                                       *
00017  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00018  ***************************************************************************/
00019 
00020 #ifndef INDENTHANDLER_H
00021 #define INDENTHANDLER_H
00022 
00023 #include <QWidget>
00024 
00025 class UiGuiErrorMessage;
00026 class UiGuiIniFileParser;
00027 
00028 class QMenu;
00029 class QVBoxLayout;
00030 class QLabel;
00031 class QSpinBox;
00032 class QComboBox;
00033 class QCheckBox;
00034 class QLineEdit;
00035 class QToolButton;
00036 class QToolBox;
00037 
00038 
00039 class IndentHandler : public QWidget
00040 {
00041     Q_OBJECT
00042 
00043 public:
00044     IndentHandler(int indenterID, QWidget *mainWindow = NULL, QWidget *parent = NULL);
00045     ~IndentHandler();
00046 
00047     QString generateShellScript(const QString &configFilename);
00048     QString callIndenter(QString sourceCode, QString inputFileExtension);
00049     bool loadConfigFile(QString filePathName);
00050     void resetToDefaultValues();
00051     QStringList getAvailableIndenters();
00052     QString getPossibleIndenterFileExtensions();
00053     QString getParameterString();
00054     QString getIndenterCfgFile();
00055     QString getManual();
00056     void retranslateUi();
00057     QString getCurrentIndenterName();
00058     QMenu* getIndenterMenu();
00059     QList<QAction*> getIndenterMenuActions();
00060     void contextMenuEvent( QContextMenuEvent *event );
00061     void setParameterChangedCallback( void(*paramChangedCallback)(void) );
00062     void setWindowClosedCallback( void(*winClosedCallback)(void) );
00063     int getIndenterId();
00064 
00065 signals:
00066     void indenterSettingsChanged();
00067     void selectedIndenterIndexChanged(int index);
00068 
00069 protected:
00070     bool event( QEvent *event );
00071     void closeEvent(QCloseEvent *event);
00072     void wheelEvent( QWheelEvent *event );
00073 
00074 private slots:
00075     void setIndenter(int indenterID);
00076     void showIndenterManual();
00077     void openConfigFileDialog();
00078     void saveasIndentCfgFileDialog();
00079     void createIndenterCallShellScript();
00080     void resetIndenterParameter();
00081     void handleChangedIndenterSettings();
00082     void updateDrawing();
00083 
00084 private:
00085     QString callExecutableIndenter(QString sourceCode, QString inputFileExtension);
00086     QString callJavaScriptIndenter(QString sourceCode);
00087     void saveConfigFile(QString filePathName, QString parameterString);
00088     void readIndentIniFile(QString iniFilePath);
00089     bool createIndenterCallString();
00090     void initIndenterMenu();
00091 
00093     struct IndenterParameterCategoryPage {
00094         QWidget *widget;
00095         QVBoxLayout *vboxLayout;
00096     };
00097     QVector<IndenterParameterCategoryPage> _indenterParameterCategoryPages;
00098 
00100     struct ParamBoolean {
00101         QString paramName;
00102         QString trueString;
00103         QString falseString;
00104         QCheckBox *checkBox;
00105     };
00106     QVector<ParamBoolean> _paramBooleans;
00107 
00109     struct ParamString {
00110         QString paramName;
00111         QString paramCallName;
00112         QCheckBox *valueEnabledChkBox;
00113         QLineEdit *lineEdit;
00114         QLabel *label;
00115     };
00116     QVector<ParamString> _paramStrings;
00117 
00119     struct ParamNumeric {
00120         QString paramName;
00121         QString paramCallName;
00122         QCheckBox *valueEnabledChkBox;
00123         QSpinBox *spinBox;
00124         QLabel *label;
00125     };
00126     QVector<ParamNumeric> _paramNumerics;
00127 
00129     struct ParamMultiple {
00130         QString paramName;
00131         QString paramCallName;
00132         QCheckBox *valueEnabledChkBox;
00133         QComboBox *comboBox;
00134         QStringList choicesStrings;
00135         QStringList choicesStringsReadable;
00136     };
00137     QVector<ParamMultiple> _paramMultiples;
00138 
00139     QComboBox *_indenterSelectionCombobox;
00140     QToolButton *_indenterParameterHelpButton;
00142     QVBoxLayout *_toolBoxContainerLayout;
00143     QToolBox *_indenterParameterCategoriesToolBox;
00144     UiGuiIniFileParser *_indenterSettings;
00145     QStringList _indenterParameters;
00147     QString _indenterName;
00149     QString _indenterFileName;
00150     QString _indenterDirctoryStr;
00151     QString _tempDirctoryStr;
00152     QString _settingsDirctoryStr;
00153     QStringList _indenterIniFileList;
00154     QString _parameterOrder;
00155     QString _globalConfigFilename;
00156     QString _cfgFileParameterEnding;
00157     QString _inputFileParameter;
00158     QString _inputFileName;
00159     QString _outputFileParameter;
00160     QString _outputFileName;
00161     QString _fileTypes;
00162     QString _useCfgFileParameter;
00163     QString _indenterShowHelpParameter;
00164     QWidget *_mainWindow;
00165     UiGuiErrorMessage *_errorMessageDialog;
00166     QString _indenterExecutableCallString;
00167     QString _indenterExecutableSuffix;
00168 
00169     QMenu *_menuIndenter;
00170     QAction *_actionLoadIndenterConfigFile;
00171     QAction *_actionSaveIndenterConfigFile;
00172     QAction *_actionCreateShellScript;
00173     QAction *_actionResetIndenterParameters;
00175     void(*_parameterChangedCallback)(void);
00177     void(*_windowClosedCallback)(void);
00178 
00179     //TODO: This function should go into a string helper/tool class/file.
00180     QString encodeToHTML(const QString &text);
00181 };
00182 
00183 #endif // INDENTHANDLER_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines