summaryrefslogtreecommitdiff
path: root/noncore/apps/tableviewer
Unidiff
Diffstat (limited to 'noncore/apps/tableviewer') (more/less context) (show 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 @@
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include "xmlsource.h" 20#include "xmlsource.h"
21#include <qdict.h> 21#include <qdict.h>
22#include <stdlib.h> 22#include <stdlib.h>
23#include <qtextstream.h> 23#include <qtextstream.h>
24#include "../xmlencodeattr.h"
25
24 26
25 27
26DBXml::DBXml(DBStore *d) 28DBXml::DBXml(DBStore *d)
27{ 29{
28 dstore = d; 30 dstore = d;
29} 31}
30 32
31QString DBXml::type() 33QString DBXml::type()
32{ 34{
33 return "xml"; 35 return "xml";
34} 36}
35 37
@@ -59,25 +61,25 @@ bool DBXml::saveSource(QIODevice *outDev)
59 61
60 outstream << "<database name=\"" << dstore->getName() << "\">" << endl; 62 outstream << "<database name=\"" << dstore->getName() << "\">" << endl;
61 outstream << "<header>" << endl; 63 outstream << "<header>" << endl;
62 64
63 k = dstore->getKeys(); 65 k = dstore->getKeys();
64 KeyListIterator it(*k); 66 KeyListIterator it(*k);
65 while(it.current()) { 67 while(it.current()) {
66 if (!it.current()->delFlag()) { 68 if (!it.current()->delFlag()) {
67 outstream << "<key name=\"KEYID" << it.currentKey() << "\" "; 69 outstream << "<key name=\"KEYID" << it.currentKey() << "\" ";
68 outstream << "type=\"" 70 outstream << "type=\""
69 << TVVariant::typeToName(it.current()->type()) 71 << TVVariant::typeToName(it.current()->type())
70 << "\">"; 72 << "\">";
71 outstream << it.current()->name() << "</key>" << endl; 73 outstream << encodeAttr(it.current()->name()) << "</key>" << endl;
72 } 74 }
73 ++it; 75 ++it;
74 } 76 }
75 77
76 outstream << "</header>" << endl; 78 outstream << "</header>" << endl;
77 79
78 dstore->first(); 80 dstore->first();
79 81
80 do { 82 do {
81 elem = dstore->getCurrentData(); 83 elem = dstore->getCurrentData();
82 if (!elem) 84 if (!elem)
83 break; 85 break;
@@ -85,25 +87,25 @@ bool DBXml::saveSource(QIODevice *outDev)
85 it.toFirst(); 87 it.toFirst();
86 while (it.current()) { 88 while (it.current()) {
87 i = it.currentKey(); 89 i = it.currentKey();
88 if (elem->hasValidValue(i)) { 90 if (elem->hasValidValue(i)) {
89 outstream << "<KEYID" << i << ">"; 91 outstream << "<KEYID" << i << ">";
90 if (dstore->getKeyType(i) == TVVariant::Date) { 92 if (dstore->getKeyType(i) == TVVariant::Date) {
91 // dates in files are different from displayed dates 93 // dates in files are different from displayed dates
92 QDate date = elem->getField(i).toDate(); 94 QDate date = elem->getField(i).toDate();
93 outstream << date.day() << "/" 95 outstream << date.day() << "/"
94 << date.month() << "/" 96 << date.month() << "/"
95 << date.year(); 97 << date.year();
96 } else { 98 } else {
97 outstream << elem->toQString(i); 99 outstream << encodeAttr(elem->toQString(i));
98 } 100 }
99 outstream << "</KEYID" << i << ">" << endl; 101 outstream << "</KEYID" << i << ">" << endl;
100 } 102 }
101 ++it; 103 ++it;
102 } 104 }
103 outstream << "</record>" << endl; 105 outstream << "</record>" << endl;
104 } while(dstore->next()); 106 } while(dstore->next());
105 107
106 outstream << "</database>" << endl; 108 outstream << "</database>" << endl;
107 return TRUE; 109 return TRUE;
108} 110}
109 111
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 @@
1 TEMPLATE= app 1 TEMPLATE= app
2 CONFIG = qt warn_on debug 2 CONFIG = qt warn_on debug
3 DESTDIR = $(OPIEDIR)/bin 3 DESTDIR = $(OPIEDIR)/bin
4 SUBDIRS = db ui 4 SUBDIRS = db ui
5 HEADERS = tableviewer.h \ 5 HEADERS = tableviewer.h \
6 xmlencodeattr.h \
6 ui/commonwidgets.h \ 7 ui/commonwidgets.h \
7 ui/tvbrowseview.h \ 8 ui/tvbrowseview.h \
8 ui/tvlistview.h \ 9 ui/tvlistview.h \
9 ui/tvfilterview.h \ 10 ui/tvfilterview.h \
10 ui/tveditview.h \ 11 ui/tveditview.h \
11 ui/browsekeyentry.h \ 12 ui/browsekeyentry.h \
12 ui/filterkeyentry.h \ 13 ui/filterkeyentry.h \
13 ui/tvkeyedit.h \ 14 ui/tvkeyedit.h \
14 db/datacache.h \ 15 db/datacache.h \
15 db/common.h \ 16 db/common.h \
16 db/xmlsource.h \ 17 db/xmlsource.h \
17 db/csvsource.h 18 db/csvsource.h
18 SOURCES = main.cpp \ 19 SOURCES = main.cpp \
19 tableviewer.cpp \ 20 tableviewer.cpp \
21 xmlencodeattr.cpp \
20 ui/commonwidgets.cpp \ 22 ui/commonwidgets.cpp \
21 ui/tvbrowseview.cpp \ 23 ui/tvbrowseview.cpp \
22 ui/tvfilterview.cpp \ 24 ui/tvfilterview.cpp \
23 ui/browsekeyentry.cpp \ 25 ui/browsekeyentry.cpp \
24 ui/filterkeyentry.cpp \ 26 ui/filterkeyentry.cpp \
25 ui/tvlistview.cpp \ 27 ui/tvlistview.cpp \
26 ui/tveditview.cpp \ 28 ui/tveditview.cpp \
27 ui/tvkeyedit.cpp \ 29 ui/tvkeyedit.cpp \
28 db/datacache.cpp \ 30 db/datacache.cpp \
29 db/xmlsource.cpp \ 31 db/xmlsource.cpp \
30 db/csvsource.cpp \ 32 db/csvsource.cpp \
31 db/common.cpp 33 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 @@
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include "tvbrowseview.h" 20#include "tvbrowseview.h"
21#include "browsekeyentry.h" 21#include "browsekeyentry.h"
22#include <qtoolbutton.h> 22#include <qtoolbutton.h>
23#include <qtextview.h> 23#include <qtextview.h>
24#include <qtextbrowser.h> 24#include <qtextbrowser.h>
25#include <qlayout.h> 25#include <qlayout.h>
26#include "../xmlencodeattr.h"
26 27
27/*! 28/*!
28 \class TVBrowseView 29 \class TVBrowseView
29 \brief The widget describing how to draw the browse view user interface 30 \brief The widget describing how to draw the browse view user interface
30 31
31 This widget allows for the user to browse through the table, one element 32 This widget allows for the user to browse through the table, one element
32 at a time, or search on a single key. Its main goal is to show a 33 at a time, or search on a single key. Its main goal is to show a
33 single element in a readable format and make it easy for the user to 34 single element in a readable format and make it easy for the user to
34 rapidly find specific elements in the table. 35 rapidly find specific elements in the table.
35*/ 36*/
36 37
37/*! 38/*!
@@ -93,30 +94,30 @@ void TVBrowseView::reset()
93 sets the data element to be displayed to element 94 sets the data element to be displayed to element
94*/ 95*/
95void TVBrowseView::setDisplayText(const DataElem *element) 96void TVBrowseView::setDisplayText(const DataElem *element)
96{ 97{
97 QString rep = ""; 98 QString rep = "";
98 99
99 KeyListIterator it(*ts->kRep); 100 KeyListIterator it(*ts->kRep);
100 101
101 while (it.current()) { 102 while (it.current()) {
102 if (element->hasValidValue(it.currentKey())) { 103 if (element->hasValidValue(it.currentKey())) {
103 if(it.currentKey() == ts->current_column) { 104 if(it.currentKey() == ts->current_column) {
104 rep += "<A name=\"ckey\"></A><B><FONT COLOR=#FF0000>" 105 rep += "<A name=\"ckey\"></A><B><FONT COLOR=#FF0000>"
105 + it.current()->name() 106 + encodeAttr(it.current()->name())
106 + ":</FONT></B> "; 107 + ":</FONT></B> ";
107 } else { 108 } else {
108 rep += "<B>" + it.current()->name() + ":</B> "; 109 rep += "<B>" + encodeAttr(it.current()->name()) + ":</B> ";
109 } 110 }
110 rep += element->toQString(it.currentKey()) + "<BR>"; 111 rep += encodeAttr(element->toQString(it.currentKey())) + "<BR>";
111 } 112 }
112 ++it; 113 ++it;
113 } 114 }
114 115
115 textViewDisplay->setText(rep); 116 textViewDisplay->setText(rep);
116 textViewDisplay->scrollToAnchor("ckey"); 117 textViewDisplay->scrollToAnchor("ckey");
117} 118}
118 119
119void TVBrowseView::rebuildKeys() 120void TVBrowseView::rebuildKeys()
120{ 121{
121 keyEntry->rebuildKeys(); 122 keyEntry->rebuildKeys();
122} 123}
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 @@
1/*
2 * xmlencodeattr.h
3 *
4 * copyright : (c) 2003 by Joseph Wenninger
5 * except for a small modification it's identical to qdom.cpp:encodeAttr
6 * email : jowenn@handhelds.org
7 *
8 */
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#include "xmlencodeattr.h"
19QString encodeAttr( const QString& str )
20{
21 QString tmp( str );
22 uint len = tmp.length();
23 uint i = 0;
24 while ( i < len ) {
25 if ( tmp[(int)i] == '<' ) {
26 tmp.replace( i, 1, "&lt;" );
27 len += 3;
28 i += 4;
29 } else if ( tmp[(int)i] == '"' ) {
30 tmp.replace( i, 1, "&quot;" );
31 len += 5;
32 i += 6;
33 } else if ( tmp[(int)i] == '&' ) {
34 tmp.replace( i, 1, "&amp;" );
35 len += 4;
36 i += 5;
37 } else if ( tmp[(int)i] == '>' ) {
38 tmp.replace( i, 1, "&gt;" );
39 len += 3;
40 i += 4;
41 } else {
42 ++i;
43 }
44 }
45
46 return tmp;
47}
48
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 @@
1/*
2 * xmlencodeattr.h
3 *
4 * copyright : (c) 2003 by Joseph Wenninger
5 * except for a small modification it's identical to qdom.cpp:encodeAttr
6 * email : jowenn@handhelds.org
7 *
8 */
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifndef _XML_ENCODE_ATTR_
19#define _XML_ENCODE_ATTR_
20
21#include <qstring.h>
22
23QString encodeAttr( const QString& str );
24
25#endif
26