21 #include <QtCore/QFile>
22 #include <QtCore/QFileInfo>
23 #include <QtGui/QImageReader>
42 QDomElement fce = m_themeXml.firstChildElement(
"icondef");
47 QDomNodeList nl = fce.childNodes();
48 for (uint i = 0; i < nl.length(); i++) {
49 QDomElement de = nl.item(i).toElement();
50 if (!de.isNull() && de.tagName() ==
"icon") {
51 QDomNodeList snl = de.childNodes();
55 for (uint k = 0; k < snl.length(); k++) {
56 QDomElement sde = snl.item(k).toElement();
58 if (!sde.isNull() && sde.tagName() ==
"object" && sde.text() == emoticon) {
75 QDomElement fce = m_themeXml.firstChildElement(
"icondef");
81 QDomElement emoticon = m_themeXml.createElement(
"icon");
82 fce.appendChild(emoticon);
83 QStringList::const_iterator constIterator;
85 for (constIterator = splitted.begin(); constIterator != splitted.end(); ++constIterator) {
86 QDomElement emotext = m_themeXml.createElement(
"text");
87 QDomText txt = m_themeXml.createTextNode((*constIterator).trimmed());
88 emotext.appendChild(txt);
89 emoticon.appendChild(emotext);
92 QDomElement emoElement = m_themeXml.createElement(
"object");
94 emoElement.setAttribute(
"mime", mimePtr->name());
95 QDomText txt = m_themeXml.createTextNode(QFileInfo(emo).
fileName());
97 emoElement.appendChild(txt);
98 emoticon.appendChild(emoElement);
110 kWarning() << fp.fileName() <<
"doesn't exist!";
114 if (!fp.open(QIODevice::WriteOnly)) {
115 kWarning() << fp.fileName() <<
"can't open WriteOnly!";
119 QTextStream emoStream(&fp);
120 emoStream.setCodec(
"UTF-8" );
121 emoStream << m_themeXml.toString(4);
132 kWarning() << path <<
"doesn't exist!";
136 if (!fp.open(QIODevice::ReadOnly)) {
137 kWarning() << fp.fileName() <<
"can't open ReadOnly!";
143 if (!m_themeXml.setContent(&fp, &error, &eli, &eco)) {
144 kWarning() << fp.fileName() <<
"can't copy to xml!";
145 kWarning() << error <<
"line:" << eli <<
"column:" << eco;
152 QDomElement fce = m_themeXml.firstChildElement(
"icondef");
158 QDomNodeList nl = fce.childNodes();
162 for (uint i = 0; i < nl.length(); i++) {
163 QDomElement de = nl.item(i).toElement();
165 if (!de.isNull() && de.tagName() ==
"icon") {
166 QDomNodeList snl = de.childNodes();
170 mime <<
"image/png" <<
"image/gif" <<
"image/bmp" <<
"image/jpeg";
172 for (uint k = 0; k < snl.length(); k++) {
173 QDomElement sde = snl.item(k).toElement();
175 if (!sde.isNull() && sde.tagName() ==
"text") {
177 }
else if (!sde.isNull() && sde.tagName() ==
"object" && mime.contains(sde.attribute(
"mime"))) {
182 emo = KGlobal::dirs()->findResource(
"emoticons",
themeName() +
'/' + emo);
200 QFile fp(path +
'/' +
"icondef.xml");
202 if (!fp.open(QIODevice::WriteOnly)) {
203 kWarning() << fp.fileName() <<
"can't open WriteOnly!";
208 doc.appendChild(doc.createProcessingInstruction(
"xml",
"version=\"1.0\" encoding=\"UTF-8\""));
209 doc.appendChild(doc.createElement(
"icondef"));
211 QTextStream emoStream(&fp);
212 emoStream.setCodec(
"UTF-8" );
213 emoStream << doc.toString(4);