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