equal
deleted
inserted
replaced
24 #include "hgcontainer.h" |
24 #include "hgcontainer.h" |
25 #include "hgcoverflowcontainer.h" |
25 #include "hgcoverflowcontainer.h" |
26 #include "hgscrollbuffermanager.h" |
26 #include "hgscrollbuffermanager.h" |
27 #include "hgwidgetitem.h" |
27 #include "hgwidgetitem.h" |
28 #include "trace.h" |
28 #include "trace.h" |
29 #include "hgindexfeedback.h" |
29 //#include "hgindexfeedback.h" |
30 |
30 |
31 static const int INITIAL_SCROLLBAR_HIDE_TIMEOUT(4000); |
31 static const int INITIAL_SCROLLBAR_HIDE_TIMEOUT(4000); |
32 static const int DEFAULT_BUFFER_SIZE(30); |
32 static const int DEFAULT_BUFFER_SIZE(30); |
33 |
33 |
34 HgWidgetPrivate::HgWidgetPrivate() : |
34 HgWidgetPrivate::HgWidgetPrivate() : |
84 q, SIGNAL(longPressed(const QModelIndex&, const QPointF &))); |
84 q, SIGNAL(longPressed(const QModelIndex&, const QPointF &))); |
85 q->connect(mContainer, SIGNAL(scrollingStarted()), q, SIGNAL(scrollingStarted())); |
85 q->connect(mContainer, SIGNAL(scrollingStarted()), q, SIGNAL(scrollingStarted())); |
86 q->connect(mContainer, SIGNAL(scrollingEnded()), q, SIGNAL(scrollingEnded())); |
86 q->connect(mContainer, SIGNAL(scrollingEnded()), q, SIGNAL(scrollingEnded())); |
87 q->connect(mScrollBarHideTimer, SIGNAL(timeout()), q, SLOT(_q_hideScrollBars())); |
87 q->connect(mScrollBarHideTimer, SIGNAL(timeout()), q, SLOT(_q_hideScrollBars())); |
88 |
88 |
89 mIndexFeedback = new HgIndexFeedback(q); |
89 // mIndexFeedback = new HgIndexFeedback(q); |
90 mIndexFeedback->setWidget(q); |
90 // mIndexFeedback->setWidget(q); |
91 |
91 |
92 } |
92 } |
93 |
93 |
94 void HgWidgetPrivate::setModel( QAbstractItemModel *model ) |
94 void HgWidgetPrivate::setModel( QAbstractItemModel *model ) |
95 { |
95 { |
121 mDefaultSelectionModel = 0; |
121 mDefaultSelectionModel = 0; |
122 mContainer->setSelectionModel(selectionModel); |
122 mContainer->setSelectionModel(selectionModel); |
123 delete oldSelectionModel; |
123 delete oldSelectionModel; |
124 } |
124 } |
125 if (mContainer->selectionModel()) { |
125 if (mContainer->selectionModel()) { |
126 if (mIndexFeedback) { |
126 // if (mIndexFeedback) { |
127 delete mIndexFeedback; |
127 // delete mIndexFeedback; |
128 mIndexFeedback = 0; |
128 // mIndexFeedback = 0; |
129 } |
129 // } |
130 mIndexFeedback = new HgIndexFeedback(q); |
130 // mIndexFeedback = new HgIndexFeedback(q); |
131 mIndexFeedback->setWidget(q); |
131 // mIndexFeedback->setWidget(q); |
132 } |
132 } |
133 } |
133 } |
134 } |
134 } |
135 |
135 |
136 QItemSelectionModel *HgWidgetPrivate::selectionModel() const |
136 QItemSelectionModel *HgWidgetPrivate::selectionModel() const |
462 INFO("Insert rows" << start << "-" << end); |
462 INFO("Insert rows" << start << "-" << end); |
463 Q_UNUSED(parent) |
463 Q_UNUSED(parent) |
464 Q_Q(HgWidget); |
464 Q_Q(HgWidget); |
465 |
465 |
466 if (mContainer) { |
466 if (mContainer) { |
467 int oldItemCount = mContainer->itemCount(); |
467 const int oldItemCount = mContainer->itemCount(); |
|
468 if (oldItemCount == 0) { |
|
469 // rows have been inserted to empty model. This is a special case |
|
470 // that reset function should handle. |
|
471 _q_modelReset(); |
|
472 return; |
|
473 } |
|
474 |
468 mBufferManager->addItems(start, end); |
475 mBufferManager->addItems(start, end); |
469 mContainer->addItems(start, end); |
476 mContainer->addItems(start, end); |
470 // re-set model indexes for the items including and after the added indexes |
477 // re-set model indexes for the items including and after the added indexes |
471 QList<HgWidgetItem *> items = mContainer->items(); |
478 QList<HgWidgetItem *> items = mContainer->items(); |
472 int newItemCount = items.count(); |
479 int newItemCount = items.count(); |
672 |
679 |
673 void HgWidgetPrivate::orientationChanged(Qt::Orientation orientation) |
680 void HgWidgetPrivate::orientationChanged(Qt::Orientation orientation) |
674 { |
681 { |
675 Q_Q(HgWidget); |
682 Q_Q(HgWidget); |
676 if (mContainer->orientation() != orientation) { |
683 if (mContainer->orientation() != orientation) { |
677 mContainer->setOrientation(orientation); |
684 mContainer->setOrientation(orientation, q->isVisible()); |
678 if (!mStaticScrollDirection) { |
685 if (!mStaticScrollDirection) { |
679 createScrollBar(orientation); |
686 createScrollBar(orientation); |
680 } |
687 } |
681 q->repolish(); |
688 q->repolish(); |
682 adjustGeometry(); |
689 adjustGeometry(); |
721 return mContainer->getVisibleItemIndices(); |
728 return mContainer->getVisibleItemIndices(); |
722 } |
729 } |
723 |
730 |
724 void HgWidgetPrivate::setIndexFeedbackPolicy( HgWidget::IndexFeedbackPolicy policy) |
731 void HgWidgetPrivate::setIndexFeedbackPolicy( HgWidget::IndexFeedbackPolicy policy) |
725 { |
732 { |
726 mIndexFeedback->setIndexFeedbackPolicy(policy); |
733 // mIndexFeedback->setIndexFeedbackPolicy(policy); |
727 } |
734 } |
728 |
735 |
729 HgWidget::IndexFeedbackPolicy HgWidgetPrivate::indexFeedbackPolicy() const |
736 HgWidget::IndexFeedbackPolicy HgWidgetPrivate::indexFeedbackPolicy() const |
730 { |
737 { |
731 return mIndexFeedback->indexFeedbackPolicy(); |
738 // return mIndexFeedback->indexFeedbackPolicy(); |
|
739 return HgWidget::IndexFeedbackNone; |
732 } |
740 } |
733 |
741 |
734 void HgWidgetPrivate::setDefaultImage(QImage defaultImage) |
742 void HgWidgetPrivate::setDefaultImage(QImage defaultImage) |
735 { |
743 { |
736 mContainer->setDefaultImage(defaultImage); |
744 mContainer->setDefaultImage(defaultImage); |