- bool ok = true;
-
- QWidget* parent = (QWidget*)this;
-
- FileEntryMap::ConstIterator it;
- for ( it = myEntries.begin(); it != myEntries.end() && ok; ++it )
- {
- const FileEntry& entry = it.data();
- QFileInfo fileInfo( entry.edit->text() );
- if ( entry.edit->text().isEmpty() )
- {
- QMessageBox::critical( parent, caption(), tr( "File name not specified" ),
- QMessageBox::Ok, QMessageBox::NoButton );
- ok = false;
- }
- else switch ( entry.mode )
- {
- case OpenFile:
- if ( !fileInfo.exists() )
- {
- QMessageBox::critical( parent, caption(), tr( "File \"%1\" does not exist" ).arg( fileInfo.filePath() ),
- QMessageBox::Ok, QMessageBox::NoButton );
- ok = false;
- }
- break;
- case SaveFile:
- if ( fileInfo.exists() )
- ok = QMessageBox::warning( parent, caption(), tr( "File \"%1\" already exist. Do you want to overwrite it?" ).arg( fileInfo.filePath() ),
- QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes;
- break;
- case OpenDir:
- if ( !fileInfo.exists() || !fileInfo.isDir() )
- {
- QMessageBox::critical( parent, caption(), tr( "Directory \"%1\" does not exist" ).arg( fileInfo.filePath() ),
- QMessageBox::Ok, QMessageBox::NoButton );
- ok = false;
- }
- break;
- case SaveDir:
- if ( fileInfo.exists() && !fileInfo.isDir() )
- {
- QMessageBox::critical( parent, caption(), tr( "Directory \"%1\" can't be created because file with the same name exist" ).arg( fileInfo.filePath() ),
- QMessageBox::Ok, QMessageBox::NoButton );
- ok = false;
- }
- break;
- case NewDir:
- if ( fileInfo.exists() )
- {
- if ( !fileInfo.isDir() )
- {
- QMessageBox::critical( parent, caption(), tr( "Directory \"%1\" can't be created because file with the same name exist" ).arg( fileInfo.filePath() ),
- QMessageBox::Ok, QMessageBox::NoButton );
- ok = false;
- }
- else if ( QDir( fileInfo.filePath() ).count() > 2 )
- ok = QMessageBox::warning( parent, caption(), tr( "Directory \"%1\" not empty. Do you want to remove all files in this directory?" ).arg( fileInfo.filePath() ),
- QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes;
- }
- break;
- default:
- break;
- }
-
- if ( !ok )
- entry.edit->setFocus();
- }
-
- return ok;
+ bool ok = true;
+
+ QWidget* parent = (QWidget*)this;
+
+ FileEntryMap::ConstIterator it;
+ for ( it = myEntries.begin(); it != myEntries.end() && ok; ++it )
+ {
+ const FileEntry& entry = it.value();
+ QFileInfo fileInfo( entry.edit->text() );
+ if ( entry.edit->text().isEmpty() )
+ {
+ QMessageBox::critical( parent, windowTitle(), tr( "File name not specified" ),
+ QMessageBox::Ok, QMessageBox::NoButton );
+ ok = false;
+ }
+ else switch ( entry.mode )
+ {
+ case OpenFile:
+ if ( !fileInfo.exists() )
+ {
+ QMessageBox::critical( parent, windowTitle(), tr( "File \"%1\" does not exist" ).arg( fileInfo.filePath() ),
+ QMessageBox::Ok, QMessageBox::NoButton );
+ ok = false;
+ }
+ break;
+ case SaveFile:
+ if ( fileInfo.exists() )
+ ok = QMessageBox::warning( parent, windowTitle(), tr( "File \"%1\" already exist. Do you want to overwrite it?" ).arg( fileInfo.filePath() ),
+ QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes;
+ break;
+ case OpenDir:
+ if ( !fileInfo.exists() || !fileInfo.isDir() )
+ {
+ QMessageBox::critical( parent, windowTitle(), tr( "Directory \"%1\" does not exist" ).arg( fileInfo.filePath() ),
+ QMessageBox::Ok, QMessageBox::NoButton );
+ ok = false;
+ }
+ break;
+ case SaveDir:
+ if ( fileInfo.exists() && !fileInfo.isDir() )
+ {
+ QMessageBox::critical( parent, windowTitle(), tr( "Directory \"%1\" can't be created because file with the same name exist" ).arg( fileInfo.filePath() ),
+ QMessageBox::Ok, QMessageBox::NoButton );
+ ok = false;
+ }
+ break;
+ case NewDir:
+ if ( fileInfo.exists() )
+ {
+ if ( !fileInfo.isDir() )
+ {
+ QMessageBox::critical( parent, windowTitle(), tr( "Directory \"%1\" can't be created because file with the same name exist" ).arg( fileInfo.filePath() ),
+ QMessageBox::Ok, QMessageBox::NoButton );
+ ok = false;
+ }
+ else if ( QDir( fileInfo.filePath() ).count() > 2 )
+ ok = QMessageBox::warning( parent, windowTitle(), tr( "Directory \"%1\" not empty. Do you want to remove all files in this directory?" ).arg( fileInfo.filePath() ),
+ QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes;
+ }
+ break;
+ default:
+ break;
+ }
+
+ if ( !ok )
+ entry.edit->setFocus();
+ }
+
+ return ok;