summaryrefslogtreecommitdiff
path: root/noncore/apps/tableviewer/ui/tvbrowseview.cpp
Unidiff
Diffstat (limited to 'noncore/apps/tableviewer/ui/tvbrowseview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/tableviewer/ui/tvbrowseview.cpp122
1 files changed, 122 insertions, 0 deletions
diff --git a/noncore/apps/tableviewer/ui/tvbrowseview.cpp b/noncore/apps/tableviewer/ui/tvbrowseview.cpp
new file mode 100644
index 0000000..f6da7b1
--- a/dev/null
+++ b/noncore/apps/tableviewer/ui/tvbrowseview.cpp
@@ -0,0 +1,122 @@
1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3**
4** This file is part of Qtopia Environment.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20#include "tvbrowseview.h"
21#include "browsekeyentry.h"
22#include <qtoolbutton.h>
23#include <qtextview.h>
24#include <qtextbrowser.h>
25#include <qlayout.h>
26
27/*!
28 \class TVBrowseView
29 \brief The widget describing how to draw the browse view user interface
30
31 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 single element in a readable format and make it easy for the user to
34 rapidly find specific elements in the table.
35*/
36
37/*!
38 Constructs a new TVBrowseView widget
39*/
40TVBrowseView::TVBrowseView(TableState *t, QWidget* parent = 0, const char *name = 0,
41 WFlags fl =0)
42{
43 if (!name)
44 setName("BrowseView");
45
46 setSizePolicy(QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding, 0, 0, sizePolicy().hasHeightForWidth() ) );
47 QVBoxLayout *vlayout = new QVBoxLayout(this);
48 textViewDisplay = new QTextBrowser(this, "textViewDisplay");
49 vlayout->addWidget( textViewDisplay );
50
51 keyEntry = new TVBrowseKeyEntry(this, "keyEntry");
52 vlayout->addWidget( keyEntry );
53
54 /* connect the signals down */
55
56 connect(keyEntry, SIGNAL(searchOnKey(int, TVVariant)),
57 this, SIGNAL(searchOnKey(int, TVVariant)));
58 connect(keyEntry, SIGNAL(sortChanged(int)),
59 this, SIGNAL(sortChanged(int)));
60
61 ts = t;
62 keyEntry->setTableState(t);
63}
64
65/*!
66 Destroys the TVBrowseView widget
67*/
68TVBrowseView::~TVBrowseView()
69{
70}
71
72void TVBrowseView::rebuildData()
73{
74 if(!ts)
75 return;
76 if(!ts->current_elem) {
77 /* also disable buttons */
78 textViewDisplay->setText("");
79 return;
80 }
81
82 setDisplayText(ts->current_elem);
83}
84
85/* Reset to initial state */
86void TVBrowseView::reset()
87{
88 textViewDisplay->setText("");
89 keyEntry->reset();
90}
91
92/*!
93 sets the data element to be displayed to element
94*/
95void TVBrowseView::setDisplayText(const DataElem *element)
96{
97 QString rep = "";
98
99 KeyListIterator it(*ts->kRep);
100
101 while (it.current()) {
102 if (element->hasValidValue(it.currentKey())) {
103 if(it.currentKey() == ts->current_column) {
104 rep += "<A name=\"ckey\"></A><B><FONT COLOR=#FF0000>"
105 + it.current()->name()
106 + ":</FONT></B> ";
107 } else {
108 rep += "<B>" + it.current()->name() + ":</B> ";
109 }
110 rep += element->toQString(it.currentKey()) + "<BR>";
111 }
112 ++it;
113 }
114
115 textViewDisplay->setText(rep);
116 textViewDisplay->scrollToAnchor("ckey");
117}
118
119void TVBrowseView::rebuildKeys()
120{
121 keyEntry->rebuildKeys();
122}