本文整理汇总了C++中SourceFile::save方法的典型用法代码示例。如果您正苦于以下问题:C++ SourceFile::save方法的具体用法?C++ SourceFile::save怎么用?C++ SourceFile::save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SourceFile
的用法示例。
在下文中一共展示了SourceFile::save方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: save
void Project::save( bool onlyProjectFile )
{
bool anythingModified = FALSE;
// save sources and forms
if ( !onlyProjectFile ) {
saveConnections();
for ( SourceFile *sf = sourcefiles.first(); sf; sf = sourcefiles.next() ) {
anythingModified = anythingModified || sf->isModified();
if ( !sf->save() )
return;
}
for ( FormFile *ff = formfiles.first(); ff; ff = formfiles.next() ) {
anythingModified = anythingModified || ff->isModified();
if ( !ff->save() )
return;
}
}
if ( isDummy() || filename.isEmpty() )
return;
if ( !modified ) {
if ( singleProjectMode() ) {
LanguageInterface *iface = MetaDataBase::languageInterface( language() );
if ( iface && iface->supports( LanguageInterface::CompressProject ) )
iface->compressProject( makeAbsolute( filename ), singleProFileName, anythingModified );
}
return;
}
QFile f( filename );
QString original = "";
// read the existing file
bool hasPreviousContents = FALSE;
if ( f.open( IO_ReadOnly ) ) {
QTextStream ts( &f );
original = ts.read();
f.close();
hasPreviousContents = TRUE;
remove_contents( original, "{SOURCES+=" ); // ### compatibility with early 3.0 betas
remove_contents( original, "DBFILE" );
remove_contents( original, "LANGUAGE" );
remove_contents( original, "TEMPLATE" );
removePlatformSettings( original, "CONFIG" );
removePlatformSettings( original, "DEFINES" );
removePlatformSettings( original, "LIBS" );
removePlatformSettings( original, "INCLUDEPATH" );
removePlatformSettings( original, "SOURCES" );
removePlatformSettings( original, "HEADERS" );
remove_multiline_contents( original, "FORMS" );
remove_multiline_contents( original, "INTERFACES" ); // compatibility
remove_multiline_contents( original, "IMAGES" );
for ( QStringList::Iterator it = csList.begin(); it != csList.end(); ++it )
remove_contents( original, *it );
}
if (!original.isEmpty()) {
// Removes any new lines at the beginning of the file
while (original.startsWith("\n"))
original.remove(0, 1);
}
// the contents of the saved file
QString contents;
// template
contents += "TEMPLATE\t= " + templ + "\n";
// language
contents += "LANGUAGE\t= " + lang + "\n";
contents += "\n";
// config
writePlatformSettings( contents, "CONFIG", cfg );
LanguageInterface *iface = MetaDataBase::languageInterface( lang );
if ( iface ) {
QStringList sourceKeys;
iface->sourceProjectKeys( sourceKeys );
for ( QStringList::Iterator spit = sourceKeys.begin(); spit != sourceKeys.end(); ++spit )
remove_multiline_contents( contents, *spit );
}
// libs, defines, includes
writePlatformSettings( contents, "LIBS", lbs );
writePlatformSettings( contents, "DEFINES", defs );
writePlatformSettings( contents, "INCLUDEPATH", inclPath );
writePlatformSettings( contents, "SOURCES", sources );
writePlatformSettings( contents, "HEADERS", headers );
// unix
if ( !hasPreviousContents ) {
contents +=
"unix|os2 {\n"
" UI_DIR = .ui\n"
" MOC_DIR = .moc\n"
//.........这里部分代码省略.........