diff options
author | Thierry Bastian <thierry.bastian@nokia.com> | 2009-07-07 15:13:44 +0200 |
---|---|---|
committer | Thierry Bastian <thierry.bastian@nokia.com> | 2009-07-07 15:14:58 +0200 |
commit | e5e2f9fd5c1554337a576374ec6744f953d2404d (patch) | |
tree | f64fffb41f469a5318267d233cad4890b860006a /src/gui/itemviews/qcolumnview.cpp | |
parent | f5392a4290e5f7ae2bdf268c1fa8c037e776fdae (diff) | |
download | qt4-tools-e5e2f9fd5c1554337a576374ec6744f953d2404d.tar.gz |
QColumnView: didn't react to addition of rows/cols in the current view
Task-number: 246999
Diffstat (limited to 'src/gui/itemviews/qcolumnview.cpp')
-rw-r--r-- | src/gui/itemviews/qcolumnview.cpp | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/src/gui/itemviews/qcolumnview.cpp b/src/gui/itemviews/qcolumnview.cpp index 1662fa87f1..ff201633ca 100644 --- a/src/gui/itemviews/qcolumnview.cpp +++ b/src/gui/itemviews/qcolumnview.cpp @@ -52,7 +52,6 @@ #include <qscrollbar.h> #include <qpainter.h> #include <qdebug.h> -#include <qpainterpath.h> QT_BEGIN_NAMESPACE @@ -896,6 +895,15 @@ QList<int> QColumnView::columnWidths() const /*! \reimp */ +void QColumnView::rowsInserted(const QModelIndex &parent, int start, int end) +{ + QAbstractItemView::rowsInserted(parent, start, end); + d_func()->checkColumnCreation(parent); +} + +/*! + \reimp +*/ void QColumnView::currentChanged(const QModelIndex ¤t, const QModelIndex &previous) { Q_D(QColumnView); @@ -1048,6 +1056,41 @@ QColumnViewPrivate::~QColumnViewPrivate() /*! \internal + + */ +void QColumnViewPrivate::_q_columnsInserted(const QModelIndex &parent, int start, int end) +{ + QAbstractItemViewPrivate::_q_columnsInserted(parent, start, end); + checkColumnCreation(parent); +} + +/*! + \internal + + Makes sure we create a corresponding column as a result of changing the model. + + */ +void QColumnViewPrivate::checkColumnCreation(const QModelIndex &parent) +{ + if (parent == q_func()->currentIndex() && model->hasChildren(parent)) { + //the parent has children and is the current + //let's try to find out if there is already a mapping that is good + for (int i = 0; i < columns.count(); ++i) { + QAbstractItemView *view = columns.at(i); + if (view->rootIndex() == parent) { + if (view == previewColumn) { + //let's recreate the parent + closeColumns(parent, false); + createColumn(parent, true /*show*/); + } + break; + } + } + } +} + +/*! + \internal Place all of the columns where they belong inside of the viewport, resize as necessary. */ void QColumnViewPrivate::doLayout() |