From e16d333ec2e8509fc665921ca106c25325bae9e0 Mon Sep 17 00:00:00 2001 From: kergoth Date: Sat, 09 Aug 2003 16:24:58 +0000 Subject: Merge from BRANCH_1_0 --- (limited to 'noncore/apps/tableviewer') diff --git a/noncore/apps/tableviewer/db/xmlsource.cpp b/noncore/apps/tableviewer/db/xmlsource.cpp index 7418a85..94fec36 100644 --- a/noncore/apps/tableviewer/db/xmlsource.cpp +++ b/noncore/apps/tableviewer/db/xmlsource.cpp @@ -21,6 +21,8 @@ #include #include #include +#include "../xmlencodeattr.h" + DBXml::DBXml(DBStore *d) @@ -68,7 +70,7 @@ bool DBXml::saveSource(QIODevice *outDev) outstream << "type=\"" << TVVariant::typeToName(it.current()->type()) << "\">"; - outstream << it.current()->name() << "" << endl; + outstream << encodeAttr(it.current()->name()) << "" << endl; } ++it; } @@ -94,7 +96,7 @@ bool DBXml::saveSource(QIODevice *outDev) << date.month() << "/" << date.year(); } else { - outstream << elem->toQString(i); + outstream << encodeAttr(elem->toQString(i)); } outstream << "" << endl; } diff --git a/noncore/apps/tableviewer/tableviewer.pro b/noncore/apps/tableviewer/tableviewer.pro index 6f73400..f047e0b 100644 --- a/noncore/apps/tableviewer/tableviewer.pro +++ b/noncore/apps/tableviewer/tableviewer.pro @@ -3,6 +3,7 @@ CONFIG = qt warn_on debug DESTDIR = $(OPIEDIR)/bin SUBDIRS = db ui HEADERS = tableviewer.h \ + xmlencodeattr.h \ ui/commonwidgets.h \ ui/tvbrowseview.h \ ui/tvlistview.h \ @@ -17,6 +18,7 @@ HEADERS = tableviewer.h \ db/csvsource.h SOURCES = main.cpp \ tableviewer.cpp \ + xmlencodeattr.cpp \ ui/commonwidgets.cpp \ ui/tvbrowseview.cpp \ ui/tvfilterview.cpp \ diff --git a/noncore/apps/tableviewer/ui/tvbrowseview.cpp b/noncore/apps/tableviewer/ui/tvbrowseview.cpp index f5f2555..22bac55 100644 --- a/noncore/apps/tableviewer/ui/tvbrowseview.cpp +++ b/noncore/apps/tableviewer/ui/tvbrowseview.cpp @@ -23,6 +23,7 @@ #include #include #include +#include "../xmlencodeattr.h" /*! \class TVBrowseView @@ -102,12 +103,12 @@ void TVBrowseView::setDisplayText(const DataElem *element) if (element->hasValidValue(it.currentKey())) { if(it.currentKey() == ts->current_column) { rep += "" - + it.current()->name() + + encodeAttr(it.current()->name()) + ": "; } else { - rep += "" + it.current()->name() + ": "; + rep += "" + encodeAttr(it.current()->name()) + ": "; } - rep += element->toQString(it.currentKey()) + "
"; + rep += encodeAttr(element->toQString(it.currentKey())) + "
"; } ++it; } diff --git a/noncore/apps/tableviewer/xmlencodeattr.cpp b/noncore/apps/tableviewer/xmlencodeattr.cpp new file mode 100644 index 0000000..de264f7 --- a/dev/null +++ b/noncore/apps/tableviewer/xmlencodeattr.cpp @@ -0,0 +1,48 @@ +/* + * xmlencodeattr.h + * + * copyright : (c) 2003 by Joseph Wenninger + * except for a small modification it's identical to qdom.cpp:encodeAttr + * email : jowenn@handhelds.org + * + */ +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "xmlencodeattr.h" +QString encodeAttr( const QString& str ) +{ + QString tmp( str ); + uint len = tmp.length(); + uint i = 0; + while ( i < len ) { + if ( tmp[(int)i] == '<' ) { + tmp.replace( i, 1, "<" ); + len += 3; + i += 4; + } else if ( tmp[(int)i] == '"' ) { + tmp.replace( i, 1, """ ); + len += 5; + i += 6; + } else if ( tmp[(int)i] == '&' ) { + tmp.replace( i, 1, "&" ); + len += 4; + i += 5; + } else if ( tmp[(int)i] == '>' ) { + tmp.replace( i, 1, ">" ); + len += 3; + i += 4; + } else { + ++i; + } + } + + return tmp; +} + diff --git a/noncore/apps/tableviewer/xmlencodeattr.h b/noncore/apps/tableviewer/xmlencodeattr.h new file mode 100644 index 0000000..5fd3b95 --- a/dev/null +++ b/noncore/apps/tableviewer/xmlencodeattr.h @@ -0,0 +1,26 @@ +/* + * xmlencodeattr.h + * + * copyright : (c) 2003 by Joseph Wenninger + * except for a small modification it's identical to qdom.cpp:encodeAttr + * email : jowenn@handhelds.org + * + */ +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef _XML_ENCODE_ATTR_ +#define _XML_ENCODE_ATTR_ + +#include + +QString encodeAttr( const QString& str ); + +#endif + -- cgit v0.9.0.2