summaryrefslogtreecommitdiffstats
path: root/kcontrol/css/template.cpp
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit4aed2c8219774f5d797760606b8489a92ddc5163 (patch)
tree3f8c130f7d269626bf6a9447407ef6c35954426a /kcontrol/css/template.cpp
downloadtdebase-4aed2c8219774f5d797760606b8489a92ddc5163.tar.gz
tdebase-4aed2c8219774f5d797760606b8489a92ddc5163.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebase@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kcontrol/css/template.cpp')
-rw-r--r--kcontrol/css/template.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/kcontrol/css/template.cpp b/kcontrol/css/template.cpp
new file mode 100644
index 000000000..94eba6053
--- /dev/null
+++ b/kcontrol/css/template.cpp
@@ -0,0 +1,45 @@
+
+
+#include <qfile.h>
+
+
+#include "template.h"
+
+
+bool CSSTemplate::expand(QString destname, const QMap<QString,QString> &dict)
+{
+ QFile inf(_filename);
+ if (!inf.open(IO_ReadOnly))
+ return false;
+ QTextStream is(&inf);
+
+ QFile outf(destname);
+ if (!outf.open(IO_WriteOnly))
+ return false;
+ QTextStream os(&outf);
+
+ QString line;
+ while (!is.eof())
+ {
+ line = is.readLine();
+
+ int start = line.find('$');
+ if (start >= 0)
+ {
+ int end = line.find('$', start+1);
+ if (end >= 0)
+ {
+ QString expr = line.mid(start+1, end-start-1);
+ QString res = dict[expr];
+
+ line.replace(start, end-start+1, res);
+ }
+ }
+ os << line << endl;
+ }
+
+ inf.close();
+ outf.close();
+
+ return true;
+}