diff options
author | Marius Bugge Monsen <mmonsen@trolltech.com> | 2009-06-05 10:22:44 +0200 |
---|---|---|
committer | Marius Bugge Monsen <mmonsen@trolltech.com> | 2009-06-05 10:22:44 +0200 |
commit | 63ca79ec8816c94bf54bbc7b4ad25a36e0251f1b (patch) | |
tree | e715baab7a81327bc36df565f9a04f355e4d13a4 /src | |
parent | 6bc4e40c716a7a3db4f4fa8dc9431aa4c502bddd (diff) |
Add QtGraphicsTableView::itemForCell(int,int). Change the test to use this function when checking the item geometry.
Diffstat (limited to 'src')
-rw-r--r-- | src/qgraphicstableview.cpp | 18 | ||||
-rw-r--r-- | src/qgraphicstableview.h | 2 |
2 files changed, 17 insertions, 3 deletions
diff --git a/src/qgraphicstableview.cpp b/src/qgraphicstableview.cpp index f21fd0f..4c0557c 100644 --- a/src/qgraphicstableview.cpp +++ b/src/qgraphicstableview.cpp @@ -936,9 +936,21 @@ void QtGraphicsTableView::setItemCreator(QtGraphicsTableViewItemCreatorBase *cre } /*! + Returns the visible item for the given \a row and \a column, or null if the item + is not visible. + */ +QtGraphicsTableViewItem *QtGraphicsTableView::itemForCell(int row, int column) const +{ + Q_D(const QtGraphicsTableView); + const int columnCount = d->model ? d->model->columnCount() : 0; + return d->items.value((row * columnCount) + column); +} + +/*! */ void QtGraphicsTableView::updateLayout() { + // ### FIXME: do delayed layout doLayout(); } @@ -1061,10 +1073,10 @@ void QtGraphicsTableView::doLayout() const int index = (row * columnCount) + column; QtGraphicsTableViewItem *item = d->items.value(index); if (!item) { - if (!unused.isEmpty()) - item = d->creator->reassign(row, column, unused.pop()); - else + if (unused.isEmpty()) item = d->creator->create(row, column, this); + else + item = d->creator->reassign(row, column, unused.pop()); d->items.insert(index, item); } item->setGeometry(x, y, width, height); diff --git a/src/qgraphicstableview.h b/src/qgraphicstableview.h index 9c561f6..63556e1 100644 --- a/src/qgraphicstableview.h +++ b/src/qgraphicstableview.h @@ -171,6 +171,8 @@ public: QtGraphicsTableViewItemCreatorBase *itemCreator() const; void setItemCreator(QtGraphicsTableViewItemCreatorBase *creator); + QtGraphicsTableViewItem *itemForCell(int row, int column) const; + virtual void doLayout(); virtual int rowAt(const QPointF &position, const QTransform &transform = QTransform()) const; virtual int columnAt(const QPointF &position, const QTransform &transform = QTransform()) const; |