From kde-commits Sun Dec 31 20:25:23 2006 From: Klaas Freitag Date: Sun, 31 Dec 2006 20:25:23 +0000 To: kde-commits Subject: playground/office/kraft/src Message-Id: <1167596723.411541.7580.nullmailer () svn ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=116759673703268 SVN commit 618267 by freitag: Load invoice.trml in case no specific template is found M +20 -14 reportgenerator.cpp --- trunk/playground/office/kraft/src/reportgenerator.cpp #618266:618267 @@ -89,27 +89,33 @@ QString templFileName = QString( type ).lower()+ ".trml"; QString findFile = "kraft/reports/" + templFileName; - QString tmplFile = stdDirs.findResource( "data", templFileName ); + QString tmplFile = stdDirs.findResource( "data", findFile ); QString re; if ( tmplFile.isEmpty() ) { - KMessageBox::error( 0, i18n("A document template named %1 could not be loaded." - "Please check the installation." ).arg( templFileName ) , - i18n( "Template not found" ) ); - return QString(); - } else { - - kdDebug() << "Loading create file from " << findFile << endl; - QFile f( tmplFile ); - if ( !f.open( IO_ReadOnly ) ) { - kdError() << "Could not open " << tmplFile << endl; + findFile = "kraft/reports/invoice.trml"; + tmplFile = stdDirs.findResource( "data", findFile ); + if ( tmplFile.isEmpty() ) { + KMessageBox::error( 0, i18n("A document template named %1 could not be loaded." + "Please check the installation." ).arg( templFileName ) , + i18n( "Template not found" ) ); return QString(); + } else { + kdDebug() << templFileName << " not found, reverting to invoice.trml" << endl; } + } - QTextStream ts( &f ); - re = ts.read(); - f.close(); + kdDebug() << "Loading create file from " << findFile << endl; + QFile f( tmplFile ); + if ( !f.open( IO_ReadOnly ) ) { + kdError() << "Could not open " << tmplFile << endl; + return QString(); } + + QTextStream ts( &f ); + re = ts.read(); + f.close(); + return re; }