libyui
 
Loading...
Searching...
No Matches
YTableItem.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2000-2012 Novell, Inc
3 This library is free software; you can redistribute it and/or modify
4 it under the terms of the GNU Lesser General Public License as
5 published by the Free Software Foundation; either version 2.1 of the
6 License, or (at your option) version 3.0 of the License. This library
7 is distributed in the hope that it will be useful, but WITHOUT ANY
8 WARRANTY; without even the implied warranty of MERCHANTABILITY or
9 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
10 License for more details. You should have received a copy of the GNU
11 Lesser General Public License along with this library; if not, write
12 to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
13 Floor, Boston, MA 02110-1301 USA
14*/
15
16
17/*-/
18
19 File: YTableItem.h
20
21 Author: Stefan Hundhammer <shundhammer@suse.de>
22
23/-*/
24
25#ifndef YTableItem_h
26#define YTableItem_h
27
28#include "YTreeItem.h"
29
30
31class YTableCell;
32
33// without "documenting" the file, typedefs will be dropped
35
37typedef std::vector<YTableCell *> YTableCellCollection;
38
40typedef YTableCellCollection::iterator YTableCellIterator;
41
43typedef YTableCellCollection::const_iterator YTableCellConstIterator;
44
45
46
61class YTableItem: public YTreeItem
62{
63public:
64
68 YTableItem();
69
74 bool isOpen = false );
75
92 YTableItem( const std::string & label_0,
93 const std::string & label_1 = std::string(),
94 const std::string & label_2 = std::string(),
95 const std::string & label_3 = std::string(),
96 const std::string & label_4 = std::string(),
97 const std::string & label_5 = std::string(),
98 const std::string & label_6 = std::string(),
99 const std::string & label_7 = std::string(),
100 const std::string & label_8 = std::string(),
101 const std::string & label_9 = std::string() );
102
107 const std::string & label_0,
108 const std::string & label_1 = std::string(),
109 const std::string & label_2 = std::string(),
110 const std::string & label_3 = std::string(),
111 const std::string & label_4 = std::string(),
112 const std::string & label_5 = std::string(),
113 const std::string & label_6 = std::string(),
114 const std::string & label_7 = std::string(),
115 const std::string & label_8 = std::string(),
116 const std::string & label_9 = std::string() );
117
123 virtual ~YTableItem();
124
129 virtual const char * itemClass() const { return "YTableItem"; }
130
140 void addCell( YTableCell * cell_disown );
141
146 void addCell( const std::string & label,
147 const std::string & iconName = std::string(),
148 const std::string & sortKey = std::string() );
149
153 void addCells( const std::string & label_0,
154 const std::string & label_1,
155 const std::string & label_2 = std::string(),
156 const std::string & label_3 = std::string(),
157 const std::string & label_4 = std::string(),
158 const std::string & label_5 = std::string(),
159 const std::string & label_6 = std::string(),
160 const std::string & label_7 = std::string(),
161 const std::string & label_8 = std::string(),
162 const std::string & label_9 = std::string() );
163
167 void deleteCells();
168
172 YTableCellIterator cellsBegin() { return _cells.begin(); }
173 YTableCellConstIterator cellsBegin() const { return _cells.begin(); }
174
178 YTableCellIterator cellsEnd() { return _cells.end(); }
179 YTableCellConstIterator cellsEnd() const { return _cells.end(); }
180
185 const YTableCell * cell( int index ) const;
186 YTableCell * cell( int index );
187
191 int cellCount() const { return _cells.size(); }
192
197 bool hasCell( int index ) const;
198
203 std::string label( int index ) const;
204
209 std::string iconName( int index ) const;
210
215 bool hasIconName( int index ) const;
216
220 std::string label() const { return label(0); }
221
226 virtual std::string debugLabel() const;
227
228
229private:
230
231 // Disable unwanted base class methods. They don't make sense in this
232 // context since there is not just one single label or icon name, but one
233 // for each cell.
234
235 std::string iconName() const { return ""; }
236 bool hasIconName() const { return false; }
237 void setLabel ( const std::string & ) {}
238 void setIconName ( const std::string & ) {}
239
240
241 //
242 // Data members
243 //
244
246};
247
248
249
272{
273public:
279 YTableCell( const std::string & label, const std::string & iconName = "",
280 const std::string & sortKey = "" )
281 : _label( label )
282 , _iconName( iconName )
283 , _sortKey( sortKey )
284 , _parent( 0 )
285 , _column ( -1 )
286 {}
287
293 int column,
294 const std::string & label,
295 const std::string & iconName = "",
296 const std::string & sortKey = "" )
297 : _label( label )
298 , _iconName( iconName )
299 , _sortKey( sortKey )
300 , _parent( parent )
301 , _column ( column )
302 {}
303
310 virtual ~YTableCell() {}
311
316 std::string label() const { return _label; }
317
325 void setLabel( const std::string & newLabel ) { _label = newLabel; }
326
330 std::string iconName() const { return _iconName; }
331
335 bool hasIconName() const { return ! _iconName.empty(); }
336
344 void setIconName( const std::string & newIconName ) { _iconName = newIconName; }
345
349 std::string sortKey() const { return _sortKey; }
350
354 bool hasSortKey() const { return ! _sortKey.empty(); }
355
363 void setSortKey( const std::string & newSortKey ) { _sortKey = newSortKey; }
364
368 YTableItem * parent() const { return _parent; }
369
374 int column() const { return _column; }
375
380 int itemIndex() const { return _parent ? _parent->index() : -1; }
381
388 void reparent( YTableItem * parent, int column );
389
390
391private:
392
393 std::string _label;
394 std::string _iconName;
395 std::string _sortKey;
396 YTableItem * _parent;
397 int _column;
398};
399
400
401#endif // YTableItem_h
YTableCellCollection::const_iterator YTableCellConstIterator
Const iterator over YTableCellCollection.
Definition YTableItem.h:43
std::vector< YTableCell * > YTableCellCollection
Collection of pointers to YTableCell.
Definition YTableItem.h:37
YTableCellCollection::iterator YTableCellIterator
Mutable iterator over YTableCellCollection.
Definition YTableItem.h:40
int index() const
Definition YItem.h:153
Definition YTableItem.h:272
void setIconName(const std::string &newIconName)
Definition YTableItem.h:344
void reparent(YTableItem *parent, int column)
Definition YTableItem.cc:263
bool hasIconName() const
Definition YTableItem.h:335
void setLabel(const std::string &newLabel)
Definition YTableItem.h:325
bool hasSortKey() const
Definition YTableItem.h:354
int column() const
Definition YTableItem.h:374
std::string sortKey() const
Definition YTableItem.h:349
virtual ~YTableCell()
Definition YTableItem.h:310
YTableCell(YTableItem *parent, int column, const std::string &label, const std::string &iconName="", const std::string &sortKey="")
Definition YTableItem.h:292
YTableCell(const std::string &label, const std::string &iconName="", const std::string &sortKey="")
Definition YTableItem.h:279
std::string iconName() const
Definition YTableItem.h:330
YTableItem * parent() const
Definition YTableItem.h:368
int itemIndex() const
Definition YTableItem.h:380
void setSortKey(const std::string &newSortKey)
Definition YTableItem.h:363
std::string label() const
Definition YTableItem.h:316
Definition YTableItem.h:62
YTableItem(const std::string &label_0, const std::string &label_1=std::string(), const std::string &label_2=std::string(), const std::string &label_3=std::string(), const std::string &label_4=std::string(), const std::string &label_5=std::string(), const std::string &label_6=std::string(), const std::string &label_7=std::string(), const std::string &label_8=std::string(), const std::string &label_9=std::string())
int cellCount() const
Definition YTableItem.h:191
virtual std::string debugLabel() const
Definition YTableItem.cc:238
YTableCellIterator cellsBegin()
Definition YTableItem.h:172
std::string iconName(int index) const
Definition YTableItem.cc:224
YTableItem()
Definition YTableItem.cc:38
bool hasIconName(int index) const
Definition YTableItem.cc:231
void deleteCells()
Definition YTableItem.cc:111
virtual const char * itemClass() const
Definition YTableItem.h:129
virtual ~YTableItem()
Definition YTableItem.cc:104
void addCell(const std::string &label, const std::string &iconName=std::string(), const std::string &sortKey=std::string())
std::string label(int index) const
Definition YTableItem.cc:217
void addCell(YTableCell *cell_disown)
Definition YTableItem.cc:127
const YTableCell * cell(int index) const
Definition YTableItem.cc:201
YTableCellIterator cellsEnd()
Definition YTableItem.h:178
YTableItem(YTableItem *parent, const std::string &label_0, const std::string &label_1=std::string(), const std::string &label_2=std::string(), const std::string &label_3=std::string(), const std::string &label_4=std::string(), const std::string &label_5=std::string(), const std::string &label_6=std::string(), const std::string &label_7=std::string(), const std::string &label_8=std::string(), const std::string &label_9=std::string())
bool hasCell(int index) const
Definition YTableItem.cc:194
std::string label() const
Definition YTableItem.h:220
void addCells(const std::string &label_0, const std::string &label_1, const std::string &label_2=std::string(), const std::string &label_3=std::string(), const std::string &label_4=std::string(), const std::string &label_5=std::string(), const std::string &label_6=std::string(), const std::string &label_7=std::string(), const std::string &label_8=std::string(), const std::string &label_9=std::string())
Definition YTableItem.cc:149
virtual YTreeItem * parent() const
Definition YTreeItem.h:134
bool isOpen() const
Definition YTreeItem.cc:101
YTreeItem(const std::string &label, bool isOpen=false)