26 #include "hbtreeview.h" |
26 #include "hbtreeview.h" |
27 #include "hbtreeview_p.h" |
27 #include "hbtreeview_p.h" |
28 #include "hbtreeitemcontainer_p.h" |
28 #include "hbtreeitemcontainer_p.h" |
29 #include "hbtreeviewitem.h" |
29 #include "hbtreeviewitem.h" |
30 #include "hbtreeitemselectionmodel_p.h" |
30 #include "hbtreeitemselectionmodel_p.h" |
31 #include <hbwidgetfeedback.h> |
|
32 #include "hbtreemodeliterator_p.h" |
31 #include "hbtreemodeliterator_p.h" |
33 |
32 |
34 #include <QItemSelection> |
33 #include <QItemSelection> |
35 #include <QGraphicsSceneMouseEvent> |
34 #include <QGraphicsSceneMouseEvent> |
36 |
|
37 // for QMAP_INT__ITEM_STATE_DEPRECATED's sake |
|
38 #include <hbabstractviewitem.h> |
|
39 |
35 |
40 /*! |
36 /*! |
41 @alpha |
37 @alpha |
42 @hbwidgets |
38 @hbwidgets |
43 \class HbTreeView |
39 \class HbTreeView |
165 d->mContainer->setModelIndexes(newIndex); |
161 d->mContainer->setModelIndexes(newIndex); |
166 } |
162 } |
167 } |
163 } |
168 } |
164 } |
169 HbAbstractItemView::scrollTo(newIndex, hint); |
165 HbAbstractItemView::scrollTo(newIndex, hint); |
170 } |
|
171 |
|
172 /*! |
|
173 \deprecated HbTreeView::indexCount() const |
|
174 is deprecated. Use \a HbModelIterator::indexCount() const |
|
175 |
|
176 \reimp |
|
177 |
|
178 Children of collapsed parents are not taken into account. |
|
179 */ |
|
180 int HbTreeView::indexCount() const |
|
181 { |
|
182 qWarning("HbTreeView::indexCount() const is deprecated! Use HbModelIterator::indexCount() const."); |
|
183 |
|
184 return modelIterator()->indexCount(); |
|
185 } |
|
186 |
|
187 /*! |
|
188 \deprecated HbTreeView::indexPosition(const QModelIndex&) const |
|
189 is deprecated. Use \a HbModelIterator::indexPosition(const QModelIndex&) const |
|
190 |
|
191 \reimp |
|
192 */ |
|
193 int HbTreeView::indexPosition(const QModelIndex &index) const |
|
194 { |
|
195 qWarning("HbTreeView::indexPosition(const QModelIndex&) const is deprecated! Use HbModelIterator::indexPosition(const QModelIndex&) const."); |
|
196 |
|
197 return modelIterator()->indexPosition(index); |
|
198 } |
|
199 |
|
200 /*! |
|
201 \deprecated HbTreeView::nextIndex(const QModelIndex&) const |
|
202 is deprecated. Use \a HbModelIterator::nextIndex(const QModelIndex&) const |
|
203 |
|
204 \reimp |
|
205 |
|
206 Next index for valid index is determined in following way: |
|
207 |
|
208 - If index has children and it is expanded then first child is returned |
|
209 - Otherwise if index has next sibling then that is returned |
|
210 - Otherwise next valid sibling for parent is returned |
|
211 - Otherwise QModelIndex is returned |
|
212 */ |
|
213 QModelIndex HbTreeView::nextIndex(const QModelIndex &index) const |
|
214 { |
|
215 qWarning("HbTreeView::nextIndex(const QModelIndex&) const is deprecated! Use HbModelIterator::nextIndex(const QModelIndex&) const."); |
|
216 |
|
217 return modelIterator()->nextIndex(index); |
|
218 } |
|
219 |
|
220 /*! |
|
221 \deprecated HbTreeView::previousIndex(const QModelIndex&) const |
|
222 is deprecated. Use \a HbModelIterator::previousIndex(const QModelIndex&) const |
|
223 |
|
224 \reimp |
|
225 |
|
226 Previous index for valid index is determined in following way: |
|
227 |
|
228 - If index has previous sibling last child from it is returned |
|
229 - Otherwise previous sibling is returned |
|
230 - Otherwise parent index is returned |
|
231 - Otherwise QModelIndex is returned |
|
232 */ |
|
233 QModelIndex HbTreeView::previousIndex(const QModelIndex &index) const |
|
234 { |
|
235 qWarning("HbTreeView::previousIndex(const QModelIndex&) const is deprecated! Use HbModelIterator::previousIndex(const QModelIndex&) const."); |
|
236 |
|
237 return modelIterator()->previousIndex(index); |
|
238 } |
166 } |
239 |
167 |
240 /*! |
168 /*! |
241 \reimp |
169 \reimp |
242 */ |
170 */ |
530 HbAbstractViewItem *item = d->mContainer->itemByIndex(iterator.key()); |
458 HbAbstractViewItem *item = d->mContainer->itemByIndex(iterator.key()); |
531 if (item) { |
459 if (item) { |
532 item->setCheckState(iterator.value()); |
460 item->setCheckState(iterator.value()); |
533 } |
461 } |
534 |
462 |
535 #ifndef QMAP_INT__ITEM_STATE_DEPRECATED |
|
536 d->mContainer->setItemStateValue(iterator.key(), HbAbstractViewItem::CheckStateKey, iterator.value()); |
|
537 #endif |
|
538 d->mContainer->setItemTransientStateValue(iterator.key(), "checkState", iterator.value()); |
463 d->mContainer->setItemTransientStateValue(iterator.key(), "checkState", iterator.value()); |
539 iterator++; |
464 iterator++; |
540 } |
465 } |
541 |
466 |
542 d->mSelectionStarted = false; |
467 d->mSelectionStarted = false; |
544 } |
469 } |
545 |
470 |
546 /*! |
471 /*! |
547 Sets the item referred to by \a index to either collapse or expanded, depending on the value of \a expanded. |
472 Sets the item referred to by \a index to either collapse or expanded, depending on the value of \a expanded. |
548 |
473 |
549 \sa isExpanded |
474 \sa isExpanded() |
550 */ |
475 */ |
551 void HbTreeView::setExpanded(const QModelIndex &index, bool expanded) |
476 void HbTreeView::setExpanded(const QModelIndex &index, bool expanded) |
552 { |
477 { |
553 Q_D(HbTreeView); |
478 Q_D(HbTreeView); |
554 |
479 |
555 if (isExpanded(index) != expanded) { |
480 if (isExpanded(index) != expanded) { |
556 d->mInSetExpanded = true; |
481 d->mInSetExpanded = true; |
557 d->treeModelIterator()->itemExpansionChanged(index); |
482 d->treeModelIterator()->itemExpansionChanged(index); |
558 |
483 |
559 #ifndef QMAP_INT__ITEM_STATE_DEPRECATED |
|
560 d->mContainer->setItemStateValue(index, HbTreeViewItem::ExpansionKey, expanded); |
|
561 #endif |
|
562 d->mContainer->setItemTransientStateValue(index, "expanded", expanded); |
484 d->mContainer->setItemTransientStateValue(index, "expanded", expanded); |
563 |
485 |
564 int childCount = d->treeModelIterator()->childCount(index) - 1; |
486 int childCount = d->treeModelIterator()->childCount(index) - 1; |
565 |
487 |
566 if (expanded) { |
488 if (expanded) { |
602 indentation * level pixels. |
524 indentation * level pixels. |
603 Level is count of parent items between item itself and root item. |
525 Level is count of parent items between item itself and root item. |
604 |
526 |
605 If negative value is set, then indentation from style sheet is used. |
527 If negative value is set, then indentation from style sheet is used. |
606 |
528 |
607 \sa indentation |
529 \sa indentation() |
608 */ |
530 */ |
609 void HbTreeView::setIndentation(qreal indentation) |
531 void HbTreeView::setIndentation(qreal indentation) |
610 { |
532 { |
611 Q_ASSERT_X(qobject_cast<HbTreeItemContainer*>(container()), "HbTreeView::setIndentation", "wrong container type"); |
533 Q_D(HbTreeView); |
612 qobject_cast<HbTreeItemContainer*>(container())->setIndentation(indentation); |
534 Q_ASSERT_X(qobject_cast<HbTreeItemContainer*>(d->mContainer), "HbTreeView::setIndentation", "wrong container type"); |
|
535 qobject_cast<HbTreeItemContainer*>(d->mContainer)->setIndentation(indentation); |
613 } |
536 } |
614 |
537 |
615 /*! |
538 /*! |
616 Returns indentation of tree view items. |
539 Returns indentation of tree view items. |
617 The returned value is either default value or set by setIndentation(). |
540 The returned value is either default value or set by setIndentation(). |
618 |
541 |
619 Default value is -1. In this case indentation from style sheet is used. |
542 Default value is -1. In this case indentation from style sheet is used. |
620 |
543 |
621 \sa setIndentation |
544 \sa setIndentation() |
622 */ |
545 */ |
623 qreal HbTreeView::indentation() const |
546 qreal HbTreeView::indentation() const |
624 { |
547 { |
625 Q_ASSERT_X(qobject_cast<HbTreeItemContainer*>(container()), "HbTreeView::indentation", "wrong container type"); |
548 Q_D(const HbTreeView); |
626 return qobject_cast<HbTreeItemContainer*>(container())->indentation(); |
549 Q_ASSERT_X(qobject_cast<HbTreeItemContainer*>(d->mContainer), "HbTreeView::indentation", "wrong container type"); |
|
550 return qobject_cast<HbTreeItemContainer*>(d->mContainer)->indentation(); |
627 } |
551 } |
628 |
552 |
629 /*! |
553 /*! |
630 \reimp |
554 \reimp |
631 */ |
555 */ |