#include "hxx2salome.h"
+// VSR: uncomment for debug mode
+// #define __DEBUG__
+
static QString quote( const QString& val )
{
QString v = val;
return v;
}
+static QString relFileNameFromDir( const QString& dir, const QString& filename )
+{
+#ifdef __DEBUG__
+ printf( "0. dir: %s, filename: %s\n", qPrintable( dir ), qPrintable( filename ) );
+#endif
+ if ( !filename.isEmpty() ) {
+ QString dirpath = QFileInfo( dir.isEmpty() ? QDir::currentPath() : dir ).absoluteFilePath();
+ QString filepath = QFileInfo( filename ).absoluteFilePath();
+#ifdef __DEBUG__
+ printf( "1. dirpath: %s, filepath: %s\n", qPrintable( dirpath ), qPrintable( filepath ) );
+#endif
+ if ( filepath.startsWith( dirpath ) ) {
+ QString fpath = filepath.mid( dirpath.length() );
+ if ( fpath.startsWith( "/" ) ) fpath.remove( 0, 1 );
+#ifdef __DEBUG__
+ printf( "2. fpath: %s\n", qPrintable( fpath ) );
+#endif
+ return fpath;
+ }
+ }
+ return filename;
+}
+
HXX2Salome::HXX2Salome() : QDialog()
{
setupUi( this );
IncludeText->text(),
tr( "Include files (*.h *.hh *.hxx *.hpp)" ) );
if ( !s.isEmpty() ) {
- QString CppDir = SourceTreeText->text().trimmed();
- QFileInfo fid( CppDir.isEmpty() ? QString( "." ) : CppDir );
- QFileInfo fif( s );
- IncludeText->setText( fid.canonicalFilePath() == fif.canonicalPath() ? fif.fileName() : s );
+ IncludeText->setText( relFileNameFromDir( SourceTreeText->text().trimmed(), s ) );
}
}
LibraryText->text(),
tr( "Shared Libraries (*.so *.dll)" ) );
if ( !s.isEmpty() ) {
- QString CppDir = SourceTreeText->text().trimmed();
- QFileInfo fid( CppDir.isEmpty() ? QString( "." ) : CppDir );
- QFileInfo fif( s );
- LibraryText->setText( fid.canonicalFilePath() == fif.canonicalPath() ? fif.fileName() : s );
+ LibraryText->setText( relFileNameFromDir( SourceTreeText->text().trimmed(), s ) );
}
}
tr( "Component C++ include file is not specified!" ) );
return;
}
- QFileInfo fifinc( CppInc );
- if ( fifinc.fileName() != CppInc && fid.canonicalFilePath() != fifinc.canonicalPath() ) {
+ if ( QFileInfo( CppInc ).isAbsolute() ) CppInc = relFileNameFromDir( CppDir, CppInc );
+ if ( QFileInfo( CppInc ).isAbsolute() ) {
QMessageBox::critical( this,
tr( "Error" ),
tr( "Component C++ include file is specified in directory other than\n%1!" ).arg( CppDir ) );
tr( "Component shared library is not specified!" ) );
return;
}
- QFileInfo fiflib( CppLib );
- if ( fiflib.fileName() != CppLib && fid.canonicalFilePath() != fiflib.canonicalPath() ) {
+ if ( QFileInfo( CppLib ).isAbsolute() ) CppLib = relFileNameFromDir( CppDir, CppLib );
+ if ( QFileInfo( CppLib ).isAbsolute() ) {
QMessageBox::critical( this,
tr( "Error" ),
tr( "Component shared library is specified in directory other than\n%1!" ).arg( CppDir ) );
cmdlist << quote( fienv.absoluteFilePath() );
}
cmdlist << quote( fid.absoluteFilePath() );
- cmdlist << quote( fifinc.fileName() );
- cmdlist << quote( fiflib.fileName() );
+ cmdlist << quote( CppInc );
+ cmdlist << quote( CppLib );
cmdlist << quote( fis.absoluteFilePath() );
QString command = cmdlist.join( " " );
// execute command
+#ifdef __DEBUG__
+ printf( "command: %s\n", qPrintable( command ) );
+#endif
QApplication::setOverrideCursor( Qt::WaitCursor );
std::system( command.toLatin1().constData() );
QApplication::restoreOverrideCursor();