Make a branch to make krunner Good Enough For Aaron™.
[kdebase/uwolfer.git] / apps / konqueror / settings / css / template.cpp
blobf04af824b5ee653e33a8fd6737662b8abf79fa8b
2 // Own
3 #include "template.h"
5 // Qt
6 #include <QtCore/QFile>
7 #include <QtCore/QTextStream>
9 bool CSSTemplate::expand(const QString &destname, const QMap<QString,QString> &dict)
11 QFile inf(_filename);
12 if (!inf.open(QIODevice::ReadOnly))
13 return false;
14 QTextStream is(&inf);
16 QFile outf(destname);
17 if (!outf.open(QIODevice::WriteOnly))
18 return false;
19 QTextStream os(&outf);
21 QString line;
22 while (!is.atEnd())
24 line = is.readLine();
26 int start = line.indexOf('$');
27 if (start >= 0)
29 int end = line.indexOf('$', start+1);
30 if (end >= 0)
32 QString expr = line.mid(start+1, end-start-1);
33 QString res = dict[expr];
35 line.replace(start, end-start+1, res);
38 os << line << endl;
41 inf.close();
42 outf.close();
44 return true;