]> icculus.org git repositories - duncan/yast2-qt4.git/blob - src/YQTable.h
drawContent is no more
[duncan/yast2-qt4.git] / src / YQTable.h
1 /*---------------------------------------------------------------------\
2 |                                                                      |
3 |                      __   __    ____ _____ ____                      |
4 |                      \ \ / /_ _/ ___|_   _|___ \                     |
5 |                       \ V / _` \___ \ | |   __) |                    |
6 |                        | | (_| |___) || |  / __/                     |
7 |                        |_|\__,_|____/ |_| |_____|                    |
8 |                                                                      |
9 |                               core system                            |
10 |                                                        (C) SuSE GmbH |
11 \----------------------------------------------------------------------/
12
13   File:       YQTable.h
14
15   Author:     Stefan Hundhammer <sh@suse.de>
16
17 /-*/
18
19 #ifndef YQTable_h
20 #define YQTable_h
21
22 #include <QFrame>
23 #include <ycp/YCPString.h>
24
25 #include "YTable.h"
26
27
28 class QY2ListView;
29 class QTreeWidgetItem;
30 class YQListViewItem;
31
32 class YQTable : public QFrame, public YTable
33 {
34     Q_OBJECT
35
36 public:
37
38     /**
39      * Constructor.
40      **/
41     YQTable( YWidget * parent, YTableHeader * header );
42
43     /**
44      * Destructor.
45      **/
46     virtual ~YQTable();
47
48     /**
49      * Switch between sorting by item insertion order (keepSorting: true) or
50      * allowing the user to sort by an arbitrary column (by clicking on the
51      * column header).
52      *
53      * Reimplemented from YTable.
54      **/
55     virtual void setKeepSorting( bool keepSorting );
56
57     /**
58      * Add an item.
59      *
60      * Reimplemented from YSelectionWidget.
61      **/
62     virtual void addItem( YItem * item );
63
64     /**
65      * Select or deselect an item.
66      *
67      * Reimplemented from YSelectionWidget.
68      **/
69     virtual void selectItem( YItem * item, bool selected = true );
70
71     /**
72      * Deselect all items.
73      *
74      * Reimplemented from YSelectionWidget.
75      **/
76     virtual void deselectAllItems();
77
78     /**
79      * Delete all items.
80      *
81      * Reimplemented from YSelectionWidget.
82      **/
83     virtual void deleteAllItems();
84
85     /**
86      * Notification that a cell (its text and/or its icon) was changed from the
87      * outside. Applications are required to call this whenever a table cell is
88      * changed after adding the corresponding table item (the row) to the table
89      * widget.
90      *
91      * Reimplemented from YTable.
92      **/
93     virtual void cellChanged( const YTableCell * cell );
94
95     /**
96      * Set enabled/disabled state.
97      *
98      * Reimplemented from YWidget.
99      **/
100     virtual void setEnabled( bool enabled );
101
102     /**
103      * Preferred width of the widget.
104      *
105      * Reimplemented from YWidget.
106      **/
107     virtual int preferredWidth();
108
109     /**
110      * Preferred height of the widget.
111      *
112      * Reimplemented from YWidget.
113      **/
114     virtual int preferredHeight();
115
116     /**
117      * Set the new size of the widget.
118      *
119      * Reimplemented from YWidget.
120      **/
121     virtual void setSize( int newWidth, int newHeight );
122
123     /**
124      * Accept the keyboard focus.
125      *
126      * Reimplemented from YWidget.
127      **/
128     virtual bool setKeyboardFocus();
129
130
131 protected slots:
132
133     /**
134      * Notification that an item is selected (single click or keyboard).
135      **/
136     void slotSelected( QTreeWidgetItem * );
137
138     /**
139      * Notification that an item is activated (double click or keyboard).
140      **/
141     void slotActivated( QTreeWidgetItem * );
142
143
144 protected:
145
146     /**
147      * Select the original item (the YTableItem) that corresponds to the
148      * specified listViewItem.
149      **/
150     void selectOrigItem( QTreeWidgetItem * listViewItem );
151
152     //
153     // Data members
154     //
155
156     QY2ListView * _qt_listView;
157 };
158
159
160
161 /**
162  * Visual representation of a YTableItem.
163  **/
164 class YQTableListViewItem: public QY2ListViewItem
165 {
166 public:
167
168     /**
169      * Constructor.
170      **/
171     YQTableListViewItem( YQTable     *  table,
172                          QY2ListView *  parent,
173                          YTableItem  *  origItem );
174
175     /**
176      * Return the parent table widget.
177      **/
178     YQTable * table() const { return _table; }
179
180     /**
181      * Return the corresponding YTableItem.
182      **/
183     YTableItem * origItem() const { return _origItem; }
184
185     /**
186      * Update this item's display with the content of 'cell'.
187      **/
188     void updateCell( const YTableCell * cell );
189
190 protected:
191
192     YQTable *    _table;
193     YTableItem * _origItem;
194 };
195
196
197
198 #endif // YQLabel_h