From kde-commits Fri Jan 07 18:43:58 2005 From: Jens Dagerbo Date: Fri, 07 Jan 2005 18:43:58 +0000 To: kde-commits Subject: kdevelop/lib/util Message-Id: <20050107184358.B6ECC1BB6E () office ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=110512345000330 CVS commit by dagerbo: Split some functionality to be able to utilize it from the appwizard M +6 -1 filetemplate.cpp 1.14 M +11 -0 filetemplate.h 1.11 --- kdevelop/lib/util/filetemplate.cpp #1.13:1.14 @@ -62,4 +61,9 @@ QString FileTemplate::readFile(KDevPlugi QString str = stream.read(); + return makeSubstitutions( dom, str ); +} + +QString FileTemplate::makeSubstitutions( QDomDocument & dom, const QString & text ) +{ QString author = DomUtil::readEntry(dom, "/general/author"); QString email = DomUtil::readEntry(dom, "/general/email"); @@ -68,4 +72,5 @@ QString FileTemplate::readFile(KDevPlugi QString year = QString::number(QDate::currentDate().year()); + QString str = text; str.replace(QRegExp("\\$EMAIL\\$"),email); str.replace(QRegExp("\\$AUTHOR\\$"),author); --- kdevelop/lib/util/filetemplate.h #1.10:1.11 @@ -24,4 +24,5 @@ class KDevPlugin; +class QDomDocument; /** @@ -49,4 +51,5 @@ public: */ static bool exists(KDevPlugin *part, const QString &name, Policy p = Default); + /** * Reads a template with the given name (e.g. "cpp") @@ -61,4 +65,11 @@ public: */ static QString readFile(KDevPlugin *part, const QString &fileName); + + /** + * Makes variable substitutions on a text, based on a specified QDomDocument + * describing a KDevelop project file. The resulting string is returned. + */ + static QString makeSubstitutions(QDomDocument &dom, const QString &text); + /** * Copies a file template with the given name to the