summaryrefslogtreecommitdiffstats
path: root/seriestreewidget.cpp
diff options
context:
space:
mode:
authorArno <am@disconnect.de>2010-06-17 20:39:30 +0200
committerArno <am@disconnect.de>2010-06-17 20:39:30 +0200
commit93c3e2c912b548d7b81d06a988677ceedf54e83d (patch)
treed36c05e61e2ac5959fac3c308e9a9d1cc3eeb7dd /seriestreewidget.cpp
parenta4e40f771e7f6df9dc8d7e63c5460761eb0e33c0 (diff)
downloadSheMov-93c3e2c912b548d7b81d06a988677ceedf54e83d.tar.gz
SheMov-93c3e2c912b548d7b81d06a988677ceedf54e83d.tar.bz2
SheMov-93c3e2c912b548d7b81d06a988677ceedf54e83d.zip
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.
Diffstat (limited to 'seriestreewidget.cpp')
-rw-r--r--seriestreewidget.cpp7
1 files changed, 5 insertions, 2 deletions
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<QVariant> data;
- data << tr("<New series>") << -1 << -1 << 0 << SeriesTreeModel::NewSeries;
+ data << tr("<New series>") << 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) {}