libyui-qt
 
Loading...
Searching...
No Matches
YQItemSelector.h
1/*
2 Copyright (C) 2019 SUSE LLC
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: YQItemSelector.h
20
21 Author: Stefan Hundhammer <shundhammer@suse.de>
22
23/-*/
24
25
26#ifndef YQItemSelector_h
27#define YQItemSelector_h
28
29#include <QScrollArea>
30#include <QMap>
31
32#include <yui/YItemSelector.h>
33
34class QScrollArea;
35class QHBoxLayout;
36class QVBoxLayout;
37class QButtonGroup;
38class QLabel;
40
41
42class YQItemSelector: public QScrollArea, public YItemSelector
43{
44 Q_OBJECT
45
46public:
47
51 YQItemSelector( YWidget * parent,
52 bool enforceSingleSelection = true );
53
54public:
55
59 virtual ~YQItemSelector();
60
66 virtual void addItem( YItem * item );
67
73 virtual void addItems( const YItemCollection & itemCollection );
74
80 virtual void selectItem( YItem * item, bool selected = true );
81
87 virtual void deselectAllItems();
88
94 virtual void deleteAllItems();
95
101 virtual void setEnabled( bool enabled );
102
108 virtual int preferredWidth();
109
115 virtual int preferredHeight();
116
122 virtual void setSize( int newWidth, int newHeight );
123
129 virtual bool setKeyboardFocus();
130
134 QWidget * itemContainer() const { return _itemContainer; }
135
140 QButtonGroup * buttonGroup() const { return _buttonGroup; }
141
146 void addItemWidget( YQSelectorItemWidget * itemWidget );
147
153 virtual void activateItem( YItem * item );
154
160 virtual void shortcutChanged();
161
162protected slots:
163
169 bool selected );
170
171
172
173protected:
174
181 YQItemSelector( YWidget * parent,
182 const YItemCustomStatusVector & customStates );
183
187 void init();
188
192 void deselectOtherItems( YItem * selectedItem );
193
194 //
195 // Data members
196 //
197
198 QWidget * _itemContainer;
199 QButtonGroup * _buttonGroup;
200 QVBoxLayout * _itemLayout;
201
202 QMap<YItem *, YQSelectorItemWidget *> _itemWidgets;
203
204}; // class YQItemSelector
205
206
207
211class YQSelectorItemWidget: public QFrame
212{
213 Q_OBJECT
214
215public:
216
221 YItem * item );
225 virtual ~YQSelectorItemWidget();
226
231 virtual void createWidgets();
232
237 virtual void setSelected( bool sel = true );
238
242 virtual bool selected() const;
243
247 bool singleSelection() const;
248
252 bool multiSelection() const { return ! singleSelection(); }
253
254
276 void setFirstItemProperty( bool value = true );
277
283 void setLabel( const QString & label );
284
290 QAbstractButton * headingToggle() const { return _headingToggle; }
291
292 //
293 // Getters
294 //
295
296 YQItemSelector * parent() const { return _parent; }
297 QLabel * descriptionLabel() const { return _descriptionLabel; }
298 QLabel * iconLabel() const { return _iconLabel; }
299 YItem * item() const { return _item; }
300
301signals:
302
303 void selectionChanged( YQSelectorItemWidget * itemWidget, bool selected );
304
305
306protected slots:
307
308 void slotSelectionChanged( bool selected );
309
310
311protected:
312
313 virtual void createWidgets( const std::string & label,
314 const std::string & description,
315 const std::string & iconName,
316 bool selected = false );
317
327 virtual QAbstractButton * createHeadingToggle( const std::string & label,
328 QWidget * parent );
329
333 virtual int itemDescriptionIndent() const;
334
335 //
336 // Data members
337 //
338
339 YQItemSelector * _parent;
340 YItem * _item;
341
342 QHBoxLayout * _hBox;
343 QVBoxLayout * _vBox;
344 QAbstractButton * _headingToggle;
345 QLabel * _descriptionLabel;
346 QLabel * _iconLabel;
347
348}; // class YQSelectorItemWidget
349
350
351
352#endif // YQItemSelector_h
Definition YQItemSelector.h:43
virtual void activateItem(YItem *item)
Definition YQItemSelector.cc:295
void addItemWidget(YQSelectorItemWidget *itemWidget)
Definition YQItemSelector.cc:98
virtual bool setKeyboardFocus()
Definition YQItemSelector.cc:247
QButtonGroup * buttonGroup() const
Definition YQItemSelector.h:140
void init()
Definition YQItemSelector.cc:67
virtual void deselectAllItems()
Definition YQItemSelector.cc:152
virtual int preferredWidth()
Definition YQItemSelector.cc:193
virtual ~YQItemSelector()
Definition YQItemSelector.cc:92
void slotSelectionChanged(YQSelectorItemWidget *itemWidget, bool selected)
Definition YQItemSelector.cc:264
YQItemSelector(YWidget *parent, bool enforceSingleSelection=true)
Definition YQItemSelector.cc:49
virtual void deleteAllItems()
Definition YQItemSelector.cc:176
virtual void setEnabled(bool enabled)
Definition YQItemSelector.cc:187
virtual void shortcutChanged()
Definition YQItemSelector.cc:302
virtual int preferredHeight()
Definition YQItemSelector.cc:206
QWidget * itemContainer() const
Definition YQItemSelector.h:134
virtual void selectItem(YItem *item, bool selected=true)
Definition YQItemSelector.cc:135
virtual void addItems(const YItemCollection &itemCollection)
Definition YQItemSelector.cc:128
virtual void addItem(YItem *item)
Definition YQItemSelector.cc:109
virtual void setSize(int newWidth, int newHeight)
Definition YQItemSelector.cc:241
void deselectOtherItems(YItem *selectedItem)
Definition YQItemSelector.cc:161
Definition YQItemSelector.h:212
virtual ~YQSelectorItemWidget()
Definition YQItemSelector.cc:331
void setLabel(const QString &label)
Definition YQItemSelector.cc:525
QAbstractButton * headingToggle() const
Definition YQItemSelector.h:290
YQSelectorItemWidget(YQItemSelector *parent, YItem *item)
Definition YQItemSelector.cc:318
virtual int itemDescriptionIndent() const
Definition YQItemSelector.cc:484
virtual QAbstractButton * createHeadingToggle(const std::string &label, QWidget *parent)
Definition YQItemSelector.cc:465
bool singleSelection() const
Definition YQItemSelector.cc:500
virtual void createWidgets()
Definition YQItemSelector.cc:337
virtual void setSelected(bool sel=true)
Definition YQItemSelector.cc:512
bool multiSelection() const
Definition YQItemSelector.h:252
virtual bool selected() const
Definition YQItemSelector.cc:506
void setFirstItemProperty(bool value=true)
Definition YQItemSelector.cc:531