moved manual to OpenOffice
[engrid.git] / src / filetemplate.h
bloba2feb51429df4b7234530ab68fcc4dde0c6f9fb0
1 //
2 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 // + +
4 // + This file is part of enGrid. +
5 // + +
6 // + Copyright 2008,2009 Oliver Gloth +
7 // + +
8 // + enGrid is free software: you can redistribute it and/or modify +
9 // + it under the terms of the GNU General Public License as published by +
10 // + the Free Software Foundation, either version 3 of the License, or +
11 // + (at your option) any later version. +
12 // + +
13 // + enGrid is distributed in the hope that it will be useful, +
14 // + but WITHOUT ANY WARRANTY; without even the implied warranty of +
15 // + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +
16 // + GNU General Public License for more details. +
17 // + +
18 // + You should have received a copy of the GNU General Public License +
19 // + along with enGrid. If not, see <http://www.gnu.org/licenses/>. +
20 // + +
21 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
23 #ifndef FILETEMPLATE_H
24 #define FILETEMPLATE_H
26 #include <QString>
27 #include <QVector>
28 #include <QFileInfo>
29 #include <QDialog>
30 #include <QtGui>
31 #include <QApplication>
32 #include <QStringList>
33 #include <QVBoxLayout>
34 #include <QHBoxLayout>
35 #include <QPair>
37 int fileTemplateTest( int argc, char ** argv );
38 int fileTemplateTest();
40 ///\todo Improve class structure
42 class TemplateLine
44 public:
45 QString m_Type;
46 QString m_Name;
47 QString m_Options;
48 QString m_DefaultValueEgc;
49 QString m_DefaultValueOpenFOAM;
50 int m_Position;
51 public:
52 void print();
53 QString getDefaultValue();
56 class FileTemplate
58 public:
59 QFileInfo m_FileInfo;
60 QVector <TemplateLine> m_Lines;
61 QString m_InText;
62 QString m_OutText;
63 QString m_Section;
65 private:
66 int processTemplate();
67 QString getContents();
68 void getValuesFromEgc();
70 public:
71 FileTemplate();
72 FileTemplate( QString filename, QString section );
73 void print();
74 QVector <TemplateLine> getLines();
75 void setLines( QVector <TemplateLine> lines );
77 public:
78 int open( QString filename, QString section );
79 int saveEgc();
80 int exportToOpenFOAM( QString filename );
83 class TemplateFormLayout : public QFormLayout
85 Q_OBJECT;
87 private:
88 QVector <FileTemplate> m_FileTemplate;
90 QVector <QComboBox*> m_ComboBoxVector;
91 QVector <QStringList> m_ComboboxValues;
92 QVector <QLineEdit*> m_IntLineEditVector;
93 QVector <QLineEdit*> m_DoubleLineEditVector;
94 QVector <QLineEdit*> m_TextLineEditVector;
95 QVector <QCheckBox*> m_CheckBoxVector;
96 QVector < QPair <QString, QString> > m_CheckBoxValues;
97 QVector <QSpinBox*> m_SpinBoxVector;
98 QVector <QDoubleSpinBox*> m_DoubleSpinBoxVector;
100 public:
101 TemplateFormLayout( QVector <QString> filename, QString section, char *name = 0, QWidget *parent = 0 );
103 void addComboBox( TemplateLine line );
104 void addIntLineEdit( TemplateLine line );
105 void addDoubleLineEdit( TemplateLine line );
106 void addTextLineEdit( TemplateLine line );
107 void addCheckBox( TemplateLine line );
108 void addSpinBox( TemplateLine line );
109 void addDoubleSpinBox( TemplateLine line );
111 QString readComboBox( int idx );
112 QString readIntLineEdit( int idx );
113 QString readDoubleLineEdit( int idx );
114 QString readTextLineEdit( int idx );
115 QString readCheckBox( int idx );
116 QString readSpinBox( int idx );
117 QString readDoubleSpinBox( int idx );
119 public:
120 void saveEgc();
123 class TemplateDialog : public QDialog
125 Q_OBJECT;
127 public:
128 TemplateDialog( QVector <QString> files, QString section, QWidget *parent = 0 );
129 private:
130 QVector <QFileInfo> m_FileInfo;
131 QVector <TemplateFormLayout*> m_TemplateFormLayoutVector;
132 private slots:
133 void saveEgc();
136 #endif