summaryrefslogtreecommitdiff
path: root/noncore/apps/tableviewer
Side-by-side diff
Diffstat (limited to 'noncore/apps/tableviewer') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/tableviewer/db/xmlsource.cpp6
-rw-r--r--noncore/apps/tableviewer/tableviewer.pro2
-rw-r--r--noncore/apps/tableviewer/ui/tvbrowseview.cpp7
-rw-r--r--noncore/apps/tableviewer/xmlencodeattr.cpp48
-rw-r--r--noncore/apps/tableviewer/xmlencodeattr.h26
5 files changed, 84 insertions, 5 deletions
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
@@ -12,24 +12,26 @@
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#include "xmlsource.h"
#include <qdict.h>
#include <stdlib.h>
#include <qtextstream.h>
+#include "../xmlencodeattr.h"
+
DBXml::DBXml(DBStore *d)
{
dstore = d;
}
QString DBXml::type()
{
return "xml";
}
@@ -59,25 +61,25 @@ bool DBXml::saveSource(QIODevice *outDev)
outstream << "<database name=\"" << dstore->getName() << "\">" << endl;
outstream << "<header>" << endl;
k = dstore->getKeys();
KeyListIterator it(*k);
while(it.current()) {
if (!it.current()->delFlag()) {
outstream << "<key name=\"KEYID" << it.currentKey() << "\" ";
outstream << "type=\""
<< TVVariant::typeToName(it.current()->type())
<< "\">";
- outstream << it.current()->name() << "</key>" << endl;
+ outstream << encodeAttr(it.current()->name()) << "</key>" << endl;
}
++it;
}
outstream << "</header>" << endl;
dstore->first();
do {
elem = dstore->getCurrentData();
if (!elem)
break;
@@ -85,25 +87,25 @@ bool DBXml::saveSource(QIODevice *outDev)
it.toFirst();
while (it.current()) {
i = it.currentKey();
if (elem->hasValidValue(i)) {
outstream << "<KEYID" << i << ">";
if (dstore->getKeyType(i) == TVVariant::Date) {
// dates in files are different from displayed dates
QDate date = elem->getField(i).toDate();
outstream << date.day() << "/"
<< date.month() << "/"
<< date.year();
} else {
- outstream << elem->toQString(i);
+ outstream << encodeAttr(elem->toQString(i));
}
outstream << "</KEYID" << i << ">" << endl;
}
++it;
}
outstream << "</record>" << endl;
} while(dstore->next());
outstream << "</database>" << endl;
return TRUE;
}
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
@@ -1,31 +1,33 @@
TEMPLATE = app
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 \
ui/tvfilterview.h \
ui/tveditview.h \
ui/browsekeyentry.h \
ui/filterkeyentry.h \
ui/tvkeyedit.h \
db/datacache.h \
db/common.h \
db/xmlsource.h \
db/csvsource.h
SOURCES = main.cpp \
tableviewer.cpp \
+ xmlencodeattr.cpp \
ui/commonwidgets.cpp \
ui/tvbrowseview.cpp \
ui/tvfilterview.cpp \
ui/browsekeyentry.cpp \
ui/filterkeyentry.cpp \
ui/tvlistview.cpp \
ui/tveditview.cpp \
ui/tvkeyedit.cpp \
db/datacache.cpp \
db/xmlsource.cpp \
db/csvsource.cpp \
db/common.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
@@ -14,24 +14,25 @@
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#include "tvbrowseview.h"
#include "browsekeyentry.h"
#include <qtoolbutton.h>
#include <qtextview.h>
#include <qtextbrowser.h>
#include <qlayout.h>
+#include "../xmlencodeattr.h"
/*!
\class TVBrowseView
\brief The widget describing how to draw the browse view user interface
This widget allows for the user to browse through the table, one element
at a time, or search on a single key. Its main goal is to show a
single element in a readable format and make it easy for the user to
rapidly find specific elements in the table.
*/
/*!
@@ -93,30 +94,30 @@ void TVBrowseView::reset()
sets the data element to be displayed to element
*/
void TVBrowseView::setDisplayText(const DataElem *element)
{
QString rep = "";
KeyListIterator it(*ts->kRep);
while (it.current()) {
if (element->hasValidValue(it.currentKey())) {
if(it.currentKey() == ts->current_column) {
rep += "<A name=\"ckey\"></A><B><FONT COLOR=#FF0000>"
- + it.current()->name()
+ + encodeAttr(it.current()->name())
+ ":</FONT></B> ";
} else {
- rep += "<B>" + it.current()->name() + ":</B> ";
+ rep += "<B>" + encodeAttr(it.current()->name()) + ":</B> ";
}
- rep += element->toQString(it.currentKey()) + "<BR>";
+ rep += encodeAttr(element->toQString(it.currentKey())) + "<BR>";
}
++it;
}
textViewDisplay->setText(rep);
textViewDisplay->scrollToAnchor("ckey");
}
void TVBrowseView::rebuildKeys()
{
keyEntry->rebuildKeys();
}
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, "&lt;" );
+ len += 3;
+ i += 4;
+ } else if ( tmp[(int)i] == '"' ) {
+ tmp.replace( i, 1, "&quot;" );
+ len += 5;
+ i += 6;
+ } else if ( tmp[(int)i] == '&' ) {
+ tmp.replace( i, 1, "&amp;" );
+ len += 4;
+ i += 5;
+ } else if ( tmp[(int)i] == '>' ) {
+ tmp.replace( i, 1, "&gt;" );
+ 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.h>
+
+QString encodeAttr( const QString& str );
+
+#endif
+