GroupListWidget Pile   version 0.0.1
The pile attempts to provide a widget that is capable of presenting
grouplistwidget.h
Go to the documentation of this file.
1 
10 #ifndef GUARD_GROUPLISTWIDGET_H_INCLUDE
11 #define GUARD_GROUPLISTWIDGET_H_INCLUDE
12 
13 #include <grouplistwidget/grouplistwidget-config.h>
14 #include <QTreeWidget>
15 #include <QListView>
16 
17 QT_BEGIN_NAMESPACE
18 class QAbstractItemModel;
19 QT_END_NAMESPACE
20 
21 class GroupSubModel;
22 class GroupModel;
23 class GroupListGroup;
24 class GrpTreeDeleg;
25 
27 class GROUPLISTWIDGET_EXPORT GroupListWidget : public QTreeWidget {
28  Q_OBJECT
29 
30  friend class GrpTreeDeleg;
31 
32 public:
33 
36  QWidget *parent = NULL);
37 
39  virtual ~GroupListWidget();
40 
42  void
43  setBaseModel (
44  QAbstractItemModel * model);
45 
47  QAbstractItemModel *
48  baseModel () const;
49 
51  void
52  setUnderModel (
53  GroupModel * model);
54 
56  GroupModel *
57  underModel () const {
58  return m_;
59  }
60 
62  GroupModel *
63  takeUnderModel (
64  GroupModel * other = NULL);
65 
67  void
68  appendToMenu (
69  QMenu * menu);
70 
72  void
73  appendGroupToMenu (
74  QMenu * menu);
75 
77  void
78  appendSortToMenu (
79  QMenu * menu);
80 
82  void
83  appendLayoutToMenu (
84  QMenu * menu);
85 
87  QListView::ViewMode
88  viewMode () const {
89  return list_view_mode_; }
90 
92  QListView::Flow
93  flow () const {
94  return list_flow_; }
95 
97  int
98  pixmapSize () const {
99  return pixmap_size_; }
100 
102  QSize
103  gridCell () {
104  if (grid_cell_.isNull()) {
105  grid_cell_ = computeGridCell ();
106  }
107  return grid_cell_;
108  }
109 
111  QSize
112  computeGridCell () const;
113 
115  QAbstractItemDelegate *
116  listDelegate () const {
117  return list_delegate_;
118  }
119 
121  void
122  setListDelegate (
123  QAbstractItemDelegate * value);
124 
126  QAbstractItemDelegate *
127  takeListDelegate (
128  QAbstractItemDelegate * value = NULL);
129 
130 public slots:
131 
133  void
134  setViewMode (
135  QListView::ViewMode value);
136 
138  void
139  setFlow (
140  QListView::Flow value);
141 
143  void
144  setPixmapSize (
145  int value);
146 
148  void
150  int new_size;
151  if (pixmap_size_ == -1) {
152  new_size = 48;
153  } else {
154  new_size = pixmap_size_ * 1.2;
155  }
156  setPixmapSize (new_size);
157  }
158 
160  void
162  int new_size;
163  if (pixmap_size_ == -1) {
164  new_size = 48;
165  } else {
166  new_size = pixmap_size_ * 0.8;
167  if (new_size < 16) new_size = 16;
168  }
169  setPixmapSize (new_size);
170  }
171 
172 signals:
173 
175  void
176  currentLVItemChanged (
177  int row);
178 
180  void
181  currentLVItemChangedEx (
182  int row_in_base,
183  int row_in_list,
184  int gsm);
185 
186 private slots:
187 
189  void
190  underModelAboutToBeReset ();
191 
193  void
194  underModelReset ();
195 
197  void
198  underGroupingChanged (
199  int column,
200  Qt::SortOrder);
201 
203  void
204  listViewSelChange (
205  const QModelIndex &current,
206  const QModelIndex &previous);
207 
209  void
210  genericSlot ();
211 
212 protected:
213 
215  void
216  contextMenuEvent (
217  QContextMenuEvent * event);
218 
220  void
221  resizeEvent (
222  QResizeEvent *e);
223 
225  void
226  wheelEvent (
227  QWheelEvent *);
228 
229 private:
230 
232  void
233  recreateFromGroup();
234 
236  void
237  installUnderModel (
238  GroupModel * value);
239 
241  void
242  uninstallUnderModel (
243  bool b_delete = false);
244 
247  createListView (
248  GroupSubModel *smdl,
249  QTreeWidgetItem *tvi);
250 
252  QMenu *
253  addColumnsToMenu (
254  QMenu *menu,
255  const QString &menu_label,
256  const QList<int> &gcol_lst,
257  const QStringList &gcol_lbl,
258  int crt_grp, const char *connect_to);
259 
261  void
262  arangeLists ();
263 
265  void
266  reinitDelegate ();
267 
268  QSize
269  gridCellFromDelegate (
270  QAbstractItemDelegate *delegate,
271  QStyleOptionViewItem & option) const;
272 
273 
274 
275  GroupModel * m_;
276  bool resize_guard_;
277  QListView::ViewMode list_view_mode_;
278  QListView::Flow list_flow_;
279  int pixmap_size_;
280  QAbstractItemDelegate * list_delegate_;
281  QSize grid_cell_;
282 }; // GroupListWidget
283 
284 #endif // GUARD_GROUPLISTWIDGET_H_INCLUDE
GroupModel * underModel() const
Retreive underlying model.
Definition: grouplistwidget.h:57
Represents a list widget inside the tree presenting the content of a group.
Definition: grouplistgroup.h:19
void decreasePixSize()
Change the size of the icons.
Definition: grouplistwidget.h:161
QAbstractItemDelegate * listDelegate() const
The delegate used with list items, if any.
Definition: grouplistwidget.h:116
A list widget that can group the items.
Definition: grouplistwidget.h:27
Delegate for QTreeWidget.
Definition: grouplistwidget.cc:62
void increasePixSize()
Change the size of the icons.
Definition: grouplistwidget.h:149
QListView::ViewMode viewMode() const
Place text to the right ("list") or to the bottom ("icon")
Definition: grouplistwidget.h:88
QSize gridCell()
Arrange items from left to right or from top to bottom.
Definition: grouplistwidget.h:103
int pixmapSize() const
Arrange items from left to right or from top to bottom.
Definition: grouplistwidget.h:98
A model representing a group that is used by the embedded lists.
Definition: groupsubmodel.h:25
QListView::Flow flow() const
Arrange items from left to right or from top to bottom.
Definition: grouplistwidget.h:93
A model that is to be installed into a GroupListWidget.
Definition: groupmodel.h:36