From 93c3e2c912b548d7b81d06a988677ceedf54e83d Mon Sep 17 00:00:00 2001 From: Arno Date: Thu, 17 Jun 2010 20:39:30 +0200 Subject: Finished New series in SeriesTreeWidget Another not so atomic commit. Inserting a new serie by triggering the action in the context menu now works. While at it I revamped setData and put the if/elses into functions. Also fixed a bug in setData: Use TypeRole instead of the Fields enum. --- seriestreewidget.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'seriestreewidget.cpp') diff --git a/seriestreewidget.cpp b/seriestreewidget.cpp index 5fb7d2c..816a293 100644 --- a/seriestreewidget.cpp +++ b/seriestreewidget.cpp @@ -58,11 +58,13 @@ SeriesTreeWidget::SeriesTreeWidget(QWidget *parent) : QWidget(parent){ void SeriesTreeWidget::newSeries(){ QList data; - data << tr("") << -1 << -1 << 0 << SeriesTreeModel::NewSeries; + data << tr("") << QVariant() << QVariant() << QVariant() << SeriesTreeModel::NewSeries; if(mModel->addRow(data, QModelIndex())){ QModelIndex newRow = mModel->index(mModel->rowCount(QModelIndex()) - 1, 0, QModelIndex()); if(newRow.isValid()){ - mView->edit(newRow); + QModelIndex proxyIndex = mProxy->mapFromSource(newRow); + mView->selectionModel()->setCurrentIndex(proxyIndex, QItemSelectionModel::ClearAndSelect); + mView->edit(proxyIndex); } } } @@ -73,6 +75,7 @@ void SeriesTreeWidget::filter(){ void SeriesTreeWidget::resort(){ mView->sortByColumn(0, mProxy->sortOrder()); + mView->scrollTo(mView->selectionModel()->currentIndex(), QAbstractItemView::PositionAtCenter); } SeriesTreeView::SeriesTreeView(QWidget *parent) : QTreeView(parent) {} -- cgit v1.2.3-70-g09d2