1 /****************************************************************************
2 ** ui.h extension file, included from the uic-generated form implementation.
4 ** If you want to add, delete, or rename functions or slots, use
5 ** Qt Designer to update this file, preserving your code.
7 ** You should not define a constructor or destructor in this file.
8 ** Instead, write your code in functions called init() and destroy().
9 ** These will automatically be called by the form's constructor and
11 *****************************************************************************/
18 #include <qfiledialog.h>
21 inline void extractDirNameBaseName(const QString & name,
22 QString & dir, QString & base )
26 s = strdup(name.latin1());
29 strcpy(s, name.latin1());
40 inline void extract_value( QString & Tq)
42 std::string t = Tq.latin1();
43 std::string::size_type p1, p2;
44 std::string spaces = " \t\n\r";
46 p1 = t.find_first_of('"');
47 if (p1 == std::string::npos) p1 = 0;
49 while ((p1 < t.length()) &&
50 (spaces.find(t[p1]) != std::string::npos))
53 p2 = t.find_last_of('"');
54 if (p2 == std::string::npos) p2 = t.length();
57 (spaces.find(t[p2]) != std::string::npos))
61 t = t.substr(p1, p2-p1+1);
67 void HXX2Salome::CloseButton_pressed()
73 void HXX2Salome::SourceTreeButton_pressed()
75 QString s = QFileDialog::getExistingDirectory(
78 "get existing directory",
83 SourceTreeText->setText(s);
88 void HXX2Salome::newComponentTree()
90 QString s = SourceTreeText->text();
91 if (!s.isEmpty()) CppDir = s;
95 void HXX2Salome::newIncludeFile()
97 QString s = IncludeText->text();
101 extractDirNameBaseName(s, dir, base);
109 void HXX2Salome::newSharedLibrary()
111 QString s = LibraryText->text();
115 extractDirNameBaseName(s, dir, base);
123 void HXX2Salome::newEnvFile()
125 QString s = EnvFileText->text();
126 if (!s.isEmpty()) EnvFile = s;
130 void HXX2Salome::newOutputTree()
132 QString s = OutputTreeText->text();
133 if (!s.isEmpty()) SalomeDir = s;
138 void HXX2Salome::OutputTreeButton_pressed()
140 QString s = QFileDialog::getExistingDirectory(
144 "Choose a directory",
148 OutputTreeText->setText(s);
152 void HXX2Salome::IncludeButton_pressed()
154 QString s = QFileDialog::getOpenFileName(
156 "Include files (*.h *.hh *.hxx *.hpp)",
159 "Choose a file to open" );
161 extractDirNameBaseName(s, CppIncDir, CppInc);
162 IncludeText->setText(CppInc);
167 void HXX2Salome::LibraryButton_pressed()
169 QString s = QFileDialog::getOpenFileName(
171 "Shared Libraries (*.so *.dll)",
174 "Choose a file to open" );
176 extractDirNameBaseName(s, CppLibDir, CppLib);
177 LibraryText->setText(CppLib);
182 void HXX2Salome::EnvFileButton_pressed()
184 QString s = QFileDialog::getSaveFileName(
186 "Environment files (*.csh *.sh)",
189 "Choose a script file to open" );
192 EnvFileText->setText(s);
198 void HXX2Salome::shellChanged(int n)
203 void HXX2Salome::GenerateButton_pressed()
206 command = "$HXX2SALOME_ROOT_DIR/hxx2salome ";
207 if (makeGUI->isChecked())
208 command += " \"-g\" ";
209 if (Compile->isChecked())
210 command += " \"-c\" ";
212 command += " -s csh ";
213 if (!EnvFile.isEmpty()) {
224 command += SalomeDir;
227 std::cerr << "command = " << command << std::endl;
228 QCursor QOld(Qt::ArrowCursor), QNew(Qt::WaitCursor);
229 this->setCursor(QNew);
230 std::system(command);
231 this->setCursor(QOld);
234 void HXX2Salome::init()
236 std::cerr << "HXX2Salome::init" << std::endl;
244 char *home = getenv("HOME");
245 std::string s(home), t;
248 std::ifstream f(s.c_str());
257 SourceTreeText->setText(CppDir);
259 else if (s == "CppInc") {
260 extractDirNameBaseName(Tq, CppIncDir, CppInc);
261 IncludeText->setText(CppInc);
263 else if (s == "CppLib") {
264 extractDirNameBaseName(Tq, CppLibDir, CppLib);
265 LibraryText->setText(CppLib);
267 else if (s == "EnvFile") {
269 EnvFileText->setText(EnvFile);
271 else if (s == "SalomeDir") {
273 OutputTreeText->setText(SalomeDir);
275 else if (s == "Shell") {
276 if (Tq == "bash") shell = 0;
277 else if (Tq == "csh") shell = 1;
278 ShellChoice->setCurrentItem(shell);
279 ShellChoice->setCurrentText(Tq);
288 void HXX2Salome::ShellChoice_activated( int n)
290 shell = ShellChoice->currentItem();
294 void HXX2Salome::destroy()
296 std::cerr << "HXX2Salome::destroy" << std::endl;
297 char *home = getenv("HOME");
300 std::ofstream f(s.c_str());
301 f << "CppDir " << "\"" << CppDir << "\"" << std::endl;
302 f << "CppInc " << "\"" << CppIncDir << CppInc << "\"" << std::endl;
303 f << "CppLib " << "\"" << CppLibDir << CppLib << "\"" << std::endl;
304 f << "SalomeDir " << "\"" << SalomeDir << "\"" << std::endl;
305 f << "EnvFile " << "\"" << EnvFile << "\"" << std::endl;
312 default: f << "bash";