+++ /dev/null
-/****************************************************************************
-** ui.h extension file, included from the uic-generated form implementation.
-**
-** If you want to add, delete, or rename functions or slots, use
-** Qt Designer to update this file, preserving your code.
-**
-** You should not define a constructor or destructor in this file.
-** Instead, write your code in functions called init() and destroy().
-** These will automatically be called by the form's constructor and
-** destructor.
-*****************************************************************************/
-
-#include <iostream>
-#include <fstream>
-#include <string>
-#include <cstdlib>
-#include <libgen.h>
-#include <qfiledialog.h>
-
-static
-inline void extractDirNameBaseName(const QString & name,
- QString & dir, QString & base )
-{
- if (name != "") {
- char *s;
- s = strdup(name.latin1());
- dir = dirname(s);
- dir += "/";
- strcpy(s, name.latin1());
- base = basename(s);
- free(s);
- }
- else {
- base = "";
- dir = "";
- }
-}
-
-static
-inline void extract_value( QString & Tq)
-{
- std::string t = Tq.latin1();
- std::string::size_type p1, p2;
- std::string spaces = " \t\n\r";
-
- p1 = t.find_first_of('"');
- if (p1 == std::string::npos) p1 = 0;
- else p1++;
- while ((p1 < t.length()) &&
- (spaces.find(t[p1]) != std::string::npos))
- p1++;
-
- p2 = t.find_last_of('"');
- if (p2 == std::string::npos) p2 = t.length();
- else p2--;
- while ((p2 >= 0) &&
- (spaces.find(t[p2]) != std::string::npos))
- p2--;
-
- if (p1 <= p2)
- t = t.substr(p1, p2-p1+1);
- else
- t = "";
- Tq = t.c_str();
-}
-
-void HXX2Salome::CloseButton_pressed()
-{
- close();
-}
-
-
-void HXX2Salome::SourceTreeButton_pressed()
-{
- QString s = QFileDialog::getExistingDirectory(
- CppDir,
- this,
- "get existing directory",
- "Choose a directory",
- TRUE );
- if (!s.isEmpty()) {
- CppDir = s;
- SourceTreeText->setText(s);
- }
-}
-
-
-void HXX2Salome::newComponentTree()
-{
- QString s = SourceTreeText->text();
- if (!s.isEmpty()) CppDir = s;
-}
-
-
-void HXX2Salome::newIncludeFile()
-{
- QString s = IncludeText->text();
- QString dir, base;
-
- if (!s.isEmpty()) {
- extractDirNameBaseName(s, dir, base);
- CppInc = base;
- if (dir != "./")
- CppIncDir = dir;
- }
-}
-
-
-void HXX2Salome::newSharedLibrary()
-{
- QString s = LibraryText->text();
- QString dir, base;
-
- if (!s.isEmpty()) {
- extractDirNameBaseName(s, dir, base);
- CppLib = base;
- if (dir != "./")
- CppLibDir = dir;
- }
-}
-
-
-void HXX2Salome::newEnvFile()
-{
- QString s = EnvFileText->text();
- if (!s.isEmpty()) EnvFile = s;
-}
-
-
-void HXX2Salome::newOutputTree()
-{
- QString s = OutputTreeText->text();
- if (!s.isEmpty()) SalomeDir = s;
-
-}
-
-
-void HXX2Salome::OutputTreeButton_pressed()
-{
- QString s = QFileDialog::getExistingDirectory(
- SalomeDir,
- this,
- "get directory",
- "Choose a directory",
- TRUE );
- if (!s.isEmpty()) {
- SalomeDir = s;
- OutputTreeText->setText(s);
- }
-}
-
-void HXX2Salome::IncludeButton_pressed()
-{
- QString s = QFileDialog::getOpenFileName(
- CppIncDir + CppInc,
- "Include files (*.h *.hh *.hxx *.hpp)",
- this,
- "C++ include file",
- "Choose a file to open" );
- if (!s.isEmpty()) {
- extractDirNameBaseName(s, CppIncDir, CppInc);
- IncludeText->setText(CppInc);
- }
-}
-
-
-void HXX2Salome::LibraryButton_pressed()
-{
- QString s = QFileDialog::getOpenFileName(
- CppLibDir + CppLib,
- "Shared Libraries (*.so *.dll)",
- this,
- "Library file",
- "Choose a file to open" );
- if (!s.isEmpty()) {
- extractDirNameBaseName(s, CppLibDir, CppLib);
- LibraryText->setText(CppLib);
- }
-}
-
-
-void HXX2Salome::EnvFileButton_pressed()
-{
- QString s = QFileDialog::getSaveFileName(
- EnvFile,
- "Environment files (*.csh *.sh)",
- this,
- "Environment file",
- "Choose a script file to open" );
- if (!s.isEmpty()) {
- EnvFile = s;
- EnvFileText->setText(s);
- }
-
-}
-
-
-void HXX2Salome::shellChanged(int n)
-{
-}
-
-
-void HXX2Salome::GenerateButton_pressed()
-{
- QString command;
- command = "$HXX2SALOME_ROOT_DIR/hxx2salome ";
- if (makeGUI->isChecked())
- command += " \"-g\" ";
- if (Compile->isChecked())
- command += " \"-c\" ";
- if (shell == 1)
- command += " -s csh ";
- if (!EnvFile.isEmpty()) {
- command += " -e ";
- command += EnvFile;
- command += " ";
- }
- command += CppDir;
- command += " \"";
- command += CppInc;
- command += "\" \"";
- command += CppLib;
- command += "\" \"";
- command += SalomeDir;
- command += "\"";
-
- std::cerr << "command = " << command << std::endl;
- QCursor QOld(Qt::ArrowCursor), QNew(Qt::WaitCursor);
- this->setCursor(QNew);
- std::system(command);
- this->setCursor(QOld);
-}
-
-void HXX2Salome::init()
-{
- std::cerr << "HXX2Salome::init" << std::endl;
- shell = 0;
- CppDir = "";
- CppInc = "";
- CppLib = "";
- EnvFile = "";
- SalomeDir = "";
-
- char *home = getenv("HOME");
- std::string s(home), t;
- QString Tq;
- s += "/.hxx2salome";
- std::ifstream f(s.c_str());
- while (f.good()) {
-
- f >> s;
- getline(f, t);
- Tq = t.c_str();
- extract_value(Tq);
- if (s == "CppDir") {
- CppDir = Tq;
- SourceTreeText->setText(CppDir);
- }
- else if (s == "CppInc") {
- extractDirNameBaseName(Tq, CppIncDir, CppInc);
- IncludeText->setText(CppInc);
- }
- else if (s == "CppLib") {
- extractDirNameBaseName(Tq, CppLibDir, CppLib);
- LibraryText->setText(CppLib);
- }
- else if (s == "EnvFile") {
- EnvFile = Tq;
- EnvFileText->setText(EnvFile);
- }
- else if (s == "SalomeDir") {
- SalomeDir = Tq;
- OutputTreeText->setText(SalomeDir);
- }
- else if (s == "Shell") {
- if (Tq == "bash") shell = 0;
- else if (Tq == "csh") shell = 1;
- ShellChoice->setCurrentItem(shell);
- ShellChoice->setCurrentText(Tq);
- }
- if (f.eof()) break;
- }
-
- f.close();
-}
-
-
-void HXX2Salome::ShellChoice_activated( int n)
-{
- shell = ShellChoice->currentItem();
-}
-
-
-void HXX2Salome::destroy()
-{
- std::cerr << "HXX2Salome::destroy" << std::endl;
- char *home = getenv("HOME");
- std::string s(home);
- s += "/.hxx2salome";
- std::ofstream f(s.c_str());
- f << "CppDir " << "\"" << CppDir << "\"" << std::endl;
- f << "CppInc " << "\"" << CppIncDir << CppInc << "\"" << std::endl;
- f << "CppLib " << "\"" << CppLibDir << CppLib << "\"" << std::endl;
- f << "SalomeDir " << "\"" << SalomeDir << "\"" << std::endl;
- f << "EnvFile " << "\"" << EnvFile << "\"" << std::endl;
- f << "Shell ";
- switch (shell) {
- case 0 : f<< "bash";
- break;
- case 1: f << "csh";
- break;
- default: f << "bash";
- break;
- }
- f << std::endl;
- f.close();
-}
-