diff options
author | Marius Bugge Monsen <mmonsen@trolltech.com> | 2009-06-04 15:44:41 +0200 |
---|---|---|
committer | Marius Bugge Monsen <mmonsen@trolltech.com> | 2009-06-04 15:44:41 +0200 |
commit | b7565ee4774b30ef3ca6afb0a0d2153cb7cd34af (patch) | |
tree | 6b0d5018ed22398eeeda4342174c5ec0e8126757 | |
parent | 2d40b2a2b38a9c55ffe1aedc3d936c05a387b60d (diff) |
Remove the index from QtGraphicsTreeViewItem. It is not needed and just clutters the api.
-rw-r--r-- | src/qgraphicstreeview.cpp | 29 | ||||
-rw-r--r-- | src/qgraphicstreeview.h | 11 |
2 files changed, 9 insertions, 31 deletions
diff --git a/src/qgraphicstreeview.cpp b/src/qgraphicstreeview.cpp index 85490cd..305dd65 100644 --- a/src/qgraphicstreeview.cpp +++ b/src/qgraphicstreeview.cpp @@ -44,7 +44,7 @@ /*! */ -QtGraphicsTreeViewItem::QtGraphicsTreeViewItem(const QtTreeModelIterator &it, int index, QtGraphicsTreeView *view) +QtGraphicsTreeViewItem::QtGraphicsTreeViewItem(const QtTreeModelIterator &it, QtGraphicsTreeView *view) : QGraphicsWidget(view, 0), d_ptr(new QtGraphicsTreeViewItemPrivate) { Q_D(QtGraphicsTreeViewItem); @@ -53,7 +53,6 @@ QtGraphicsTreeViewItem::QtGraphicsTreeViewItem(const QtTreeModelIterator &it, in d->view = view; d->header = view->header(); d->it = it; - d->index = index; } /*! @@ -84,22 +83,6 @@ void QtGraphicsTreeViewItem::setIterator(const QtTreeModelIterator &it) /*! */ -int QtGraphicsTreeViewItem::index() const -{ - Q_D(const QtGraphicsTreeViewItem); - return d->index; -} - -/*! - */ -void QtGraphicsTreeViewItem::setIndex(int index) -{ - Q_D(QtGraphicsTreeViewItem); - d->index = index; -} - -/*! - */ QSizeF QtGraphicsTreeViewItem::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const { Q_D(const QtGraphicsTreeViewItem); @@ -237,10 +220,9 @@ QtGraphicsTreeViewItemCreatorBase::~QtGraphicsTreeViewItemCreatorBase() { } -QtGraphicsTreeViewItem *QtGraphicsTreeViewItemCreatorBase::reassign(const QtTreeModelIterator &it, int index, QtGraphicsTreeViewItem *item) +QtGraphicsTreeViewItem *QtGraphicsTreeViewItemCreatorBase::reassign(const QtTreeModelIterator &it, QtGraphicsTreeViewItem *item) { Q_ASSERT(item); - item->setIndex(index); item->setIterator(it); return item; } @@ -1147,10 +1129,10 @@ void QtGraphicsTreeView::doLayout() QtGraphicsTreeViewItem *item = unused.take(it); if (!item) { // if the item did not exist if (unused.isEmpty()) { - item = d->creator->create(it, index, this); + item = d->creator->create(it, this); } else { // take another random item (idealy we should take from the bottom, since this kicks in early when scolling up) QHash<QtTreeModelBase::iterator_base, QtGraphicsTreeViewItem*>::iterator random = unused.begin(); - item = d->creator->reassign(it, index, random.value()); + item = d->creator->reassign(it, random.value()); unused.erase(random); } } @@ -1160,7 +1142,6 @@ void QtGraphicsTreeView::doLayout() // next item y += size.height(); d->next(it, stack); - ++index; } // while // recycle any unused items left @@ -1173,7 +1154,7 @@ void QtGraphicsTreeView::doLayout() */ QtTreeModelIterator QtGraphicsTreeView::itemAt(const QPointF &position, int *index, QRectF *rect) const { - // works only inside the view + // works only inside the view area Q_D(const QtGraphicsTreeView); QStyleOptionViewItemV4 option; initStyleOption(&option); diff --git a/src/qgraphicstreeview.h b/src/qgraphicstreeview.h index 3ed889c..244ffda 100644 --- a/src/qgraphicstreeview.h +++ b/src/qgraphicstreeview.h @@ -54,12 +54,9 @@ class QWidget; class QtGraphicsTreeViewItem : public QGraphicsWidget { public: - QtGraphicsTreeViewItem(const QtTreeModelIterator &it, int index, QtGraphicsTreeView *view); + QtGraphicsTreeViewItem(const QtTreeModelIterator &it, QtGraphicsTreeView *view); ~QtGraphicsTreeViewItem(); - int index() const; - void setIndex(int index); - QtTreeModelIterator iterator() const; void setIterator(const QtTreeModelIterator &it); @@ -86,8 +83,8 @@ class QtGraphicsTreeViewItemCreatorBase { public: virtual ~QtGraphicsTreeViewItemCreatorBase(); - virtual QtGraphicsTreeViewItem *create(const QtTreeModelIterator &it, int index, QtGraphicsTreeView *view) = 0; - virtual QtGraphicsTreeViewItem *reassign(const QtTreeModelIterator &it, int index, QtGraphicsTreeViewItem *item); + virtual QtGraphicsTreeViewItem *create(const QtTreeModelIterator &it, QtGraphicsTreeView *view) = 0; + virtual QtGraphicsTreeViewItem *reassign(const QtTreeModelIterator &it, QtGraphicsTreeViewItem *item); virtual void recycle(QtGraphicsTreeViewItem *item); }; @@ -95,7 +92,7 @@ template <class T> class QtGraphicsTreeViewItemCreator : public QtGraphicsTreeViewItemCreatorBase { public: - inline QtGraphicsTreeViewItem *create(const QtTreeModelIterator &it, int index, QtGraphicsTreeView *view) { return new T(it, index, view); } + inline QtGraphicsTreeViewItem *create(const QtTreeModelIterator &it, QtGraphicsTreeView *view) { return new T(it, view); } }; |