summaryrefslogtreecommitdiff
path: root/noncore/apps/tableviewer/ui/tvlistview.cpp
Unidiff
Diffstat (limited to 'noncore/apps/tableviewer/ui/tvlistview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/tableviewer/ui/tvlistview.cpp4
1 files changed, 2 insertions, 2 deletions
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 }
73private: 73private:
74 DataElem *data_reference; 74 DataElem *data_reference;
75}; 75};
76 76
77TVListViewItem::TVListViewItem(QListView *parent, DataElem *d) 77TVListViewItem::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
83TVListViewItem::~TVListViewItem() 83TVListViewItem::~TVListViewItem()
84{ 84{
85 data_reference = 0; 85 data_reference = 0;
86} 86}
87 87
88TVListView::TVListView(TableState *t, QWidget* parent, 88TVListView::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
118TVListView::~TVListView() 118TVListView::~TVListView()
119{ 119{
120} 120}
121 121
122void TVListView::addItem(DataElem *d) 122void 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 */
131void TVListView::removeItem() 131void 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
149void TVListView::clearItems() 149void 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}