-rw-r--r-- | noncore/apps/tableviewer/ui/commonwidgets.cpp | 2 | ||||
-rw-r--r-- | noncore/apps/tableviewer/ui/tvbrowseview.cpp | 4 | ||||
-rw-r--r-- | noncore/apps/tableviewer/ui/tvfilterview.cpp | 2 | ||||
-rw-r--r-- | noncore/apps/tableviewer/ui/tvlistview.cpp | 4 |
4 files changed, 6 insertions, 6 deletions
diff --git a/noncore/apps/tableviewer/ui/commonwidgets.cpp b/noncore/apps/tableviewer/ui/commonwidgets.cpp index 4c47951..e82018c 100644 --- a/noncore/apps/tableviewer/ui/commonwidgets.cpp +++ b/noncore/apps/tableviewer/ui/commonwidgets.cpp | |||
@@ -1,88 +1,88 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 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 | 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 | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 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. | 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 | 20 | ||
21 | #include <qlineedit.h> | 21 | #include <qlineedit.h> |
22 | #include <qlayout.h> | 22 | #include <qlayout.h> |
23 | #include <qlabel.h> | 23 | #include <qlabel.h> |
24 | #include <qcombobox.h> | 24 | #include <qcombobox.h> |
25 | 25 | ||
26 | #include <qpe/datebookmonth.h> | 26 | #include <qpe/datebookmonth.h> |
27 | #include <qpopupmenu.h> | 27 | #include <qpopupmenu.h> |
28 | #include <qspinbox.h> | 28 | #include <qspinbox.h> |
29 | #include "commonwidgets.h" | 29 | #include "commonwidgets.h" |
30 | 30 | ||
31 | DateEdit::DateEdit( QWidget *parent, const char *name, WFlags f ) | 31 | DateEdit::DateEdit( QWidget *parent, const char *name, WFlags f ) |
32 | : QToolButton(parent, name) | 32 | : QToolButton(parent, name) |
33 | { | 33 | { |
34 | QPopupMenu *m1 = new QPopupMenu(this); | 34 | QPopupMenu *m1 = new QPopupMenu(this); |
35 | dateSelector = new DateBookMonth(m1, 0, TRUE); | 35 | dateSelector = new DateBookMonth(m1, 0, TRUE); |
36 | m1->insertItem(dateSelector); | 36 | m1->insertItem(dateSelector); |
37 | setPopup(m1); | 37 | setPopup(m1); |
38 | setPopupDelay(0); | 38 | setPopupDelay(0); |
39 | 39 | ||
40 | connect(dateSelector, SIGNAL(dateClicked(int, int, int)), | 40 | connect(dateSelector, SIGNAL(dateClicked(int,int,int)), |
41 | this, SLOT(subValueChanged())); | 41 | this, SLOT(subValueChanged())); |
42 | 42 | ||
43 | setText(dateSelector->selectedDate().toString()); | 43 | setText(dateSelector->selectedDate().toString()); |
44 | } | 44 | } |
45 | 45 | ||
46 | 46 | ||
47 | DateEdit::~DateEdit() {} | 47 | DateEdit::~DateEdit() {} |
48 | 48 | ||
49 | QDate DateEdit::date() const | 49 | QDate DateEdit::date() const |
50 | { | 50 | { |
51 | return dateSelector->selectedDate(); | 51 | return dateSelector->selectedDate(); |
52 | } | 52 | } |
53 | 53 | ||
54 | void DateEdit::setDate(QDate d) | 54 | void DateEdit::setDate(QDate d) |
55 | { | 55 | { |
56 | dateSelector->setDate(d.year(), d.month(), d.day()); | 56 | dateSelector->setDate(d.year(), d.month(), d.day()); |
57 | setText(d.toString()); | 57 | setText(d.toString()); |
58 | } | 58 | } |
59 | 59 | ||
60 | QSizePolicy DateEdit::sizePolicy() const | 60 | QSizePolicy DateEdit::sizePolicy() const |
61 | { | 61 | { |
62 | QSizePolicy sp; | 62 | QSizePolicy sp; |
63 | sp.setHorData(QToolButton::sizePolicy().horData()); | 63 | sp.setHorData(QToolButton::sizePolicy().horData()); |
64 | sp.setVerData(QSizePolicy::Fixed); | 64 | sp.setVerData(QSizePolicy::Fixed); |
65 | 65 | ||
66 | return sp; | 66 | return sp; |
67 | } | 67 | } |
68 | 68 | ||
69 | void DateEdit::clear() | 69 | void DateEdit::clear() |
70 | { | 70 | { |
71 | QDate today = QDate::currentDate(); | 71 | QDate today = QDate::currentDate(); |
72 | 72 | ||
73 | dateSelector->setDate(today.year(), today.month(), today.day()); | 73 | dateSelector->setDate(today.year(), today.month(), today.day()); |
74 | setText(today.toString()); | 74 | setText(today.toString()); |
75 | } | 75 | } |
76 | 76 | ||
77 | void DateEdit::subValueChanged() | 77 | void DateEdit::subValueChanged() |
78 | { | 78 | { |
79 | QDate current = dateSelector->selectedDate(); | 79 | QDate current = dateSelector->selectedDate(); |
80 | 80 | ||
81 | setText(current.toString()); | 81 | setText(current.toString()); |
82 | emit valueChanged(current); | 82 | emit valueChanged(current); |
83 | } | 83 | } |
84 | 84 | ||
85 | TimeEdit::TimeEdit( QWidget *parent, const char *name, WFlags f ) | 85 | TimeEdit::TimeEdit( QWidget *parent, const char *name, WFlags f ) |
86 | : QWidget(parent, name, f) | 86 | : QWidget(parent, name, f) |
87 | { | 87 | { |
88 | QHBoxLayout *layout = new QHBoxLayout(this, 0); | 88 | QHBoxLayout *layout = new QHBoxLayout(this, 0); |
diff --git a/noncore/apps/tableviewer/ui/tvbrowseview.cpp b/noncore/apps/tableviewer/ui/tvbrowseview.cpp index 22bac55..8a65ed1 100644 --- a/noncore/apps/tableviewer/ui/tvbrowseview.cpp +++ b/noncore/apps/tableviewer/ui/tvbrowseview.cpp | |||
@@ -9,98 +9,98 @@ | |||
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 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. | 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 "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 | #include "../xmlencodeattr.h" |
27 | 27 | ||
28 | /*! | 28 | /*! |
29 | \class TVBrowseView | 29 | \class TVBrowseView |
30 | \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 |
31 | 31 | ||
32 | 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 |
33 | 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 |
34 | 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 |
35 | rapidly find specific elements in the table. | 35 | rapidly find specific elements in the table. |
36 | */ | 36 | */ |
37 | 37 | ||
38 | /*! | 38 | /*! |
39 | Constructs a new TVBrowseView widget | 39 | Constructs a new TVBrowseView widget |
40 | */ | 40 | */ |
41 | TVBrowseView::TVBrowseView(TableState *t, QWidget* parent, const char *name, | 41 | TVBrowseView::TVBrowseView(TableState *t, QWidget* parent, const char *name, |
42 | WFlags fl ) | 42 | WFlags fl ) |
43 | { | 43 | { |
44 | if (!name) | 44 | if (!name) |
45 | setName("BrowseView"); | 45 | setName("BrowseView"); |
46 | 46 | ||
47 | // setSizePolicy(QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding, 0, 0, sizePolicy().hasHeightForWidth() ) ); | 47 | // setSizePolicy(QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding, 0, 0, sizePolicy().hasHeightForWidth() ) ); |
48 | QVBoxLayout *vlayout = new QVBoxLayout(this); | 48 | QVBoxLayout *vlayout = new QVBoxLayout(this); |
49 | textViewDisplay = new QTextBrowser(this, "textViewDisplay"); | 49 | textViewDisplay = new QTextBrowser(this, "textViewDisplay"); |
50 | vlayout->addWidget( textViewDisplay ); | 50 | vlayout->addWidget( textViewDisplay ); |
51 | 51 | ||
52 | keyEntry = new TVBrowseKeyEntry(this, "keyEntry"); | 52 | keyEntry = new TVBrowseKeyEntry(this, "keyEntry"); |
53 | vlayout->addWidget( keyEntry ); | 53 | vlayout->addWidget( keyEntry ); |
54 | 54 | ||
55 | /* connect the signals down */ | 55 | /* connect the signals down */ |
56 | 56 | ||
57 | connect(keyEntry, SIGNAL(searchOnKey(int, TVVariant)), | 57 | connect(keyEntry, SIGNAL(searchOnKey(int,TVVariant)), |
58 | this, SIGNAL(searchOnKey(int, TVVariant))); | 58 | this, SIGNAL(searchOnKey(int,TVVariant))); |
59 | connect(keyEntry, SIGNAL(sortChanged(int)), | 59 | connect(keyEntry, SIGNAL(sortChanged(int)), |
60 | this, SIGNAL(sortChanged(int))); | 60 | this, SIGNAL(sortChanged(int))); |
61 | 61 | ||
62 | ts = t; | 62 | ts = t; |
63 | keyEntry->setTableState(t); | 63 | keyEntry->setTableState(t); |
64 | } | 64 | } |
65 | 65 | ||
66 | /*! | 66 | /*! |
67 | Destroys the TVBrowseView widget | 67 | Destroys the TVBrowseView widget |
68 | */ | 68 | */ |
69 | TVBrowseView::~TVBrowseView() | 69 | TVBrowseView::~TVBrowseView() |
70 | { | 70 | { |
71 | } | 71 | } |
72 | 72 | ||
73 | void TVBrowseView::rebuildData() | 73 | void TVBrowseView::rebuildData() |
74 | { | 74 | { |
75 | if(!ts) | 75 | if(!ts) |
76 | return; | 76 | return; |
77 | if(!ts->current_elem) { | 77 | if(!ts->current_elem) { |
78 | /* also disable buttons */ | 78 | /* also disable buttons */ |
79 | textViewDisplay->setText(""); | 79 | textViewDisplay->setText(""); |
80 | return; | 80 | return; |
81 | } | 81 | } |
82 | 82 | ||
83 | setDisplayText(ts->current_elem); | 83 | setDisplayText(ts->current_elem); |
84 | } | 84 | } |
85 | 85 | ||
86 | /* Reset to initial state */ | 86 | /* Reset to initial state */ |
87 | void TVBrowseView::reset() | 87 | void TVBrowseView::reset() |
88 | { | 88 | { |
89 | textViewDisplay->setText(""); | 89 | textViewDisplay->setText(""); |
90 | keyEntry->reset(); | 90 | keyEntry->reset(); |
91 | } | 91 | } |
92 | 92 | ||
93 | /*! | 93 | /*! |
94 | sets the data element to be displayed to element | 94 | sets the data element to be displayed to element |
95 | */ | 95 | */ |
96 | void TVBrowseView::setDisplayText(const DataElem *element) | 96 | void TVBrowseView::setDisplayText(const DataElem *element) |
97 | { | 97 | { |
98 | QString rep = ""; | 98 | QString rep = ""; |
99 | 99 | ||
100 | KeyListIterator it(*ts->kRep); | 100 | KeyListIterator it(*ts->kRep); |
101 | 101 | ||
102 | while (it.current()) { | 102 | while (it.current()) { |
103 | if (element->hasValidValue(it.currentKey())) { | 103 | if (element->hasValidValue(it.currentKey())) { |
104 | if(it.currentKey() == ts->current_column) { | 104 | if(it.currentKey() == ts->current_column) { |
105 | rep += "<A name=\"ckey\"></A><B><FONT COLOR=#FF0000>" | 105 | rep += "<A name=\"ckey\"></A><B><FONT COLOR=#FF0000>" |
106 | + encodeAttr(it.current()->name()) | 106 | + encodeAttr(it.current()->name()) |
diff --git a/noncore/apps/tableviewer/ui/tvfilterview.cpp b/noncore/apps/tableviewer/ui/tvfilterview.cpp index b03e846..22f1fb7 100644 --- a/noncore/apps/tableviewer/ui/tvfilterview.cpp +++ b/noncore/apps/tableviewer/ui/tvfilterview.cpp | |||
@@ -44,97 +44,97 @@ TVFilterView::TVFilterView(TableState *t, QWidget* parent, | |||
44 | display->header()->setResizeEnabled(FALSE); | 44 | display->header()->setResizeEnabled(FALSE); |
45 | 45 | ||
46 | vlayout->addWidget(display); | 46 | vlayout->addWidget(display); |
47 | 47 | ||
48 | QHBoxLayout *hlayout = new QHBoxLayout; | 48 | QHBoxLayout *hlayout = new QHBoxLayout; |
49 | hlayout->addItem(new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum)); | 49 | hlayout->addItem(new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum)); |
50 | 50 | ||
51 | newFilterButton = new QPushButton(this, "new Filter"); | 51 | newFilterButton = new QPushButton(this, "new Filter"); |
52 | newFilterButton->setMaximumSize(QSize(50, 32767)); | 52 | newFilterButton->setMaximumSize(QSize(50, 32767)); |
53 | newFilterButton->setText("New"); | 53 | newFilterButton->setText("New"); |
54 | hlayout->addWidget(newFilterButton); | 54 | hlayout->addWidget(newFilterButton); |
55 | 55 | ||
56 | deleteFilterButton = new QPushButton(this, "delete Filter"); | 56 | deleteFilterButton = new QPushButton(this, "delete Filter"); |
57 | deleteFilterButton->setMaximumSize(QSize(50, 32767)); | 57 | deleteFilterButton->setMaximumSize(QSize(50, 32767)); |
58 | deleteFilterButton->setText("Delete"); | 58 | deleteFilterButton->setText("Delete"); |
59 | hlayout->addWidget(deleteFilterButton); | 59 | hlayout->addWidget(deleteFilterButton); |
60 | 60 | ||
61 | clearFilterButton = new QPushButton(this, "delete Filter"); | 61 | clearFilterButton = new QPushButton(this, "delete Filter"); |
62 | clearFilterButton->setMaximumSize(QSize(60, 32767)); | 62 | clearFilterButton->setMaximumSize(QSize(60, 32767)); |
63 | clearFilterButton->setText("Clear All"); | 63 | clearFilterButton->setText("Clear All"); |
64 | hlayout->addWidget(clearFilterButton); | 64 | hlayout->addWidget(clearFilterButton); |
65 | 65 | ||
66 | vlayout->addLayout(hlayout); | 66 | vlayout->addLayout(hlayout); |
67 | 67 | ||
68 | QHBoxLayout *hlayout2 = new QHBoxLayout; | 68 | QHBoxLayout *hlayout2 = new QHBoxLayout; |
69 | 69 | ||
70 | keyNameCombo = new QComboBox(FALSE, this, "key name"); | 70 | keyNameCombo = new QComboBox(FALSE, this, "key name"); |
71 | keyNameCombo->setEnabled(FALSE); | 71 | keyNameCombo->setEnabled(FALSE); |
72 | hlayout2->addWidget(keyNameCombo); | 72 | hlayout2->addWidget(keyNameCombo); |
73 | 73 | ||
74 | QLabel *label = new QLabel(this); | 74 | QLabel *label = new QLabel(this); |
75 | label->setText("has value"); | 75 | label->setText("has value"); |
76 | hlayout2->addWidget(label); | 76 | hlayout2->addWidget(label); |
77 | 77 | ||
78 | keyEntry = new TVFilterKeyEntry(this, "key entry"); | 78 | keyEntry = new TVFilterKeyEntry(this, "key entry"); |
79 | keyEntry->setEnabled(FALSE); | 79 | keyEntry->setEnabled(FALSE); |
80 | 80 | ||
81 | vlayout->addLayout(hlayout2); | 81 | vlayout->addLayout(hlayout2); |
82 | vlayout->addWidget(keyEntry); | 82 | vlayout->addWidget(keyEntry); |
83 | 83 | ||
84 | connect(newFilterButton, SIGNAL( clicked() ), this, SLOT( newTerm() )); | 84 | connect(newFilterButton, SIGNAL( clicked() ), this, SLOT( newTerm() )); |
85 | connect(deleteFilterButton, SIGNAL( clicked() ), this, SLOT( deleteTerm())); | 85 | connect(deleteFilterButton, SIGNAL( clicked() ), this, SLOT( deleteTerm())); |
86 | connect(clearFilterButton, SIGNAL( clicked() ), this, SLOT( clearTerms())); | 86 | connect(clearFilterButton, SIGNAL( clicked() ), this, SLOT( clearTerms())); |
87 | 87 | ||
88 | connect(keyEntry, SIGNAL(valueChanged()), this, SLOT( updateTerm() )); | 88 | connect(keyEntry, SIGNAL(valueChanged()), this, SLOT( updateTerm() )); |
89 | connect(keyNameCombo, SIGNAL(activated(int)), this, SLOT( updateTerm() )); | 89 | connect(keyNameCombo, SIGNAL(activated(int)), this, SLOT( updateTerm() )); |
90 | 90 | ||
91 | connect(display, SIGNAL(selectionChanged(QListViewItem*)), this, | 91 | connect(display, SIGNAL(selectionChanged(QListViewItem*)), this, |
92 | SLOT(setTerm(QListViewItem *))); | 92 | SLOT(setTerm(QListViewItem*))); |
93 | 93 | ||
94 | ts = t; | 94 | ts = t; |
95 | current = 0; | 95 | current = 0; |
96 | terms.setAutoDelete(true); | 96 | terms.setAutoDelete(true); |
97 | do_filter = false; | 97 | do_filter = false; |
98 | 98 | ||
99 | #ifdef Q_WS_QWS | 99 | #ifdef Q_WS_QWS |
100 | QPEApplication::showDialog( this ); | 100 | QPEApplication::showDialog( this ); |
101 | #endif | 101 | #endif |
102 | } | 102 | } |
103 | 103 | ||
104 | /*! | 104 | /*! |
105 | Destroys the TVFilterView widget | 105 | Destroys the TVFilterView widget |
106 | */ | 106 | */ |
107 | TVFilterView::~TVFilterView() | 107 | TVFilterView::~TVFilterView() |
108 | { | 108 | { |
109 | } | 109 | } |
110 | 110 | ||
111 | void TVFilterView::rebuildData() | 111 | void TVFilterView::rebuildData() |
112 | { | 112 | { |
113 | } | 113 | } |
114 | 114 | ||
115 | void TVFilterView::reset() | 115 | void TVFilterView::reset() |
116 | { | 116 | { |
117 | keyNameCombo->clear(); | 117 | keyNameCombo->clear(); |
118 | keyIds.clear(); | 118 | keyIds.clear(); |
119 | } | 119 | } |
120 | 120 | ||
121 | void TVFilterView::rebuildKeys() | 121 | void TVFilterView::rebuildKeys() |
122 | { | 122 | { |
123 | int i; | 123 | int i; |
124 | 124 | ||
125 | if (!ts) return; | 125 | if (!ts) return; |
126 | if(!ts->kRep) return; | 126 | if(!ts->kRep) return; |
127 | keyEntry->setTableState(ts); | 127 | keyEntry->setTableState(ts); |
128 | 128 | ||
129 | /* set up the list of keys that can be compared on */ | 129 | /* set up the list of keys that can be compared on */ |
130 | keyNameCombo->clear(); | 130 | keyNameCombo->clear(); |
131 | KeyListIterator it(*ts->kRep); | 131 | KeyListIterator it(*ts->kRep); |
132 | 132 | ||
133 | i = 0; | 133 | i = 0; |
134 | while(it.current()) { | 134 | while(it.current()) { |
135 | if(ts->kRep->validIndex(it.currentKey())) { | 135 | if(ts->kRep->validIndex(it.currentKey())) { |
136 | keyNameCombo->insertItem(it.current()->name()); | 136 | keyNameCombo->insertItem(it.current()->name()); |
137 | keyIds.insert(i, it.currentKey()); | 137 | keyIds.insert(i, it.currentKey()); |
138 | ++i; | 138 | ++i; |
139 | } | 139 | } |
140 | ++it; | 140 | ++it; |
diff --git a/noncore/apps/tableviewer/ui/tvlistview.cpp b/noncore/apps/tableviewer/ui/tvlistview.cpp index b25e813..b10ff1d 100644 --- a/noncore/apps/tableviewer/ui/tvlistview.cpp +++ b/noncore/apps/tableviewer/ui/tvlistview.cpp | |||
@@ -59,98 +59,98 @@ public: | |||
59 | } | 59 | } |
60 | QString key(int i, bool a) const | 60 | QString key(int i, bool a) const |
61 | { | 61 | { |
62 | return data_reference->toSortableQString(i); | 62 | return data_reference->toSortableQString(i); |
63 | } | 63 | } |
64 | 64 | ||
65 | void setDataElem(DataElem *d) | 65 | void setDataElem(DataElem *d) |
66 | { | 66 | { |
67 | data_reference = d; | 67 | data_reference = d; |
68 | } | 68 | } |
69 | 69 | ||
70 | DataElem *getDataElem() { | 70 | DataElem *getDataElem() { |
71 | return data_reference; | 71 | return data_reference; |
72 | } | 72 | } |
73 | private: | 73 | private: |
74 | DataElem *data_reference; | 74 | DataElem *data_reference; |
75 | }; | 75 | }; |
76 | 76 | ||
77 | TVListViewItem::TVListViewItem(QListView *parent, DataElem *d) | 77 | TVListViewItem::TVListViewItem(QListView *parent, DataElem *d) |
78 | : QListViewItem(parent) | 78 | : QListViewItem(parent) |
79 | { | 79 | { |
80 | data_reference = d; | 80 | data_reference = d; |
81 | } | 81 | } |
82 | 82 | ||
83 | TVListViewItem::~TVListViewItem() | 83 | TVListViewItem::~TVListViewItem() |
84 | { | 84 | { |
85 | data_reference = 0; | 85 | data_reference = 0; |
86 | } | 86 | } |
87 | 87 | ||
88 | TVListView::TVListView(TableState *t, QWidget* parent, | 88 | TVListView::TVListView(TableState *t, QWidget* parent, |
89 | const char *name, WFlags fl ) : QWidget(parent, name, fl) | 89 | const char *name, WFlags fl ) : QWidget(parent, name, fl) |
90 | { | 90 | { |
91 | if (!name) | 91 | if (!name) |
92 | setName("TVListView"); | 92 | setName("TVListView"); |
93 | 93 | ||
94 | // the next two lines need to be rationalized. | 94 | // the next two lines need to be rationalized. |
95 | resize(318,457); | 95 | resize(318,457); |
96 | setSizePolicy(QSizePolicy((QSizePolicy::SizeType)7, | 96 | setSizePolicy(QSizePolicy((QSizePolicy::SizeType)7, |
97 | (QSizePolicy::SizeType)7, sizePolicy().hasHeightForWidth())); | 97 | (QSizePolicy::SizeType)7, sizePolicy().hasHeightForWidth())); |
98 | setCaption(tr("List View")); | 98 | setCaption(tr("List View")); |
99 | 99 | ||
100 | QVBoxLayout *layout = new QVBoxLayout(this); | 100 | QVBoxLayout *layout = new QVBoxLayout(this); |
101 | layout->setSpacing(0); | 101 | layout->setSpacing(0); |
102 | layout->setMargin(0); | 102 | layout->setMargin(0); |
103 | 103 | ||
104 | listViewDisplay = new TVListViewPrivate(this, "listViewDisplay"); | 104 | listViewDisplay = new TVListViewPrivate(this, "listViewDisplay"); |
105 | layout->addWidget(listViewDisplay); | 105 | layout->addWidget(listViewDisplay); |
106 | 106 | ||
107 | connect(listViewDisplay, SIGNAL(currentChanged(QListViewItem *)), this, | 107 | connect(listViewDisplay, SIGNAL(currentChanged(QListViewItem*)), this, |
108 | SLOT(setCurrent(QListViewItem *))); | 108 | SLOT(setCurrent(QListViewItem*))); |
109 | connect(listViewDisplay, SIGNAL(sortChanged(int)), this, | 109 | connect(listViewDisplay, SIGNAL(sortChanged(int)), this, |
110 | SLOT(setSorting(int))); | 110 | SLOT(setSorting(int))); |
111 | 111 | ||
112 | listViewDisplay->setShowSortIndicator(true); | 112 | listViewDisplay->setShowSortIndicator(true); |
113 | 113 | ||
114 | it = new QListViewItemIterator(listViewDisplay); | 114 | it = new QListViewItemIterator(listViewDisplay); |
115 | ts = t; | 115 | ts = t; |
116 | } | 116 | } |
117 | 117 | ||
118 | TVListView::~TVListView() | 118 | TVListView::~TVListView() |
119 | { | 119 | { |
120 | } | 120 | } |
121 | 121 | ||
122 | void TVListView::addItem(DataElem *d) | 122 | void TVListView::addItem(DataElem *d) |
123 | { | 123 | { |
124 | TVListViewItem *i = new TVListViewItem(listViewDisplay, d); | 124 | TVListViewItem *i = new TVListViewItem(listViewDisplay, d); |
125 | 125 | ||
126 | delete it; | 126 | delete it; |
127 | it = new QListViewItemIterator(i); | 127 | it = new QListViewItemIterator(i); |
128 | } | 128 | } |
129 | 129 | ||
130 | /* remove current (it) item */ | 130 | /* remove current (it) item */ |
131 | void TVListView::removeItem() | 131 | void TVListView::removeItem() |
132 | { | 132 | { |
133 | QListViewItemIterator other(*it); | 133 | QListViewItemIterator other(*it); |
134 | 134 | ||
135 | QListViewItemIterator tmp = *it; | 135 | QListViewItemIterator tmp = *it; |
136 | (*it)++; | 136 | (*it)++; |
137 | if (!it->current()) { | 137 | if (!it->current()) { |
138 | *it = tmp; | 138 | *it = tmp; |
139 | (*it)--; | 139 | (*it)--; |
140 | if (!it->current()) { | 140 | if (!it->current()) { |
141 | delete it; | 141 | delete it; |
142 | it = 0; | 142 | it = 0; |
143 | } | 143 | } |
144 | } | 144 | } |
145 | 145 | ||
146 | delete other.current(); | 146 | delete other.current(); |
147 | } | 147 | } |
148 | 148 | ||
149 | void TVListView::clearItems() | 149 | void TVListView::clearItems() |
150 | { | 150 | { |
151 | /* This is ok since the destructor for TVListItem does not know about | 151 | /* This is ok since the destructor for TVListItem does not know about |
152 | the data_reference pointer.. and hence will leave it alone */ | 152 | the data_reference pointer.. and hence will leave it alone */ |
153 | listViewDisplay->clear(); | 153 | listViewDisplay->clear(); |
154 | delete it; | 154 | delete it; |
155 | it = new QListViewItemIterator(listViewDisplay); | 155 | it = new QListViewItemIterator(listViewDisplay); |
156 | } | 156 | } |