Mercurial > retraceit
comparison src/metadataview.cpp @ 53:28d5a77db9fb 0.9.1
Ensure that the first row is properly set after filtering
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Mon, 18 May 2015 12:06:01 +0200 |
parents | 73e6b6b12412 |
children | 23672cbc3e5f |
comparison
equal
deleted
inserted
replaced
52:f38e4cd95d52 | 53:28d5a77db9fb |
---|---|
42 QVBoxLayout *baseLayout = new QVBoxLayout; | 42 QVBoxLayout *baseLayout = new QVBoxLayout; |
43 | 43 |
44 FilterWidget *filterWidget = new FilterWidget(mSortModel); | 44 FilterWidget *filterWidget = new FilterWidget(mSortModel); |
45 connect(filterWidget, &FilterWidget::filterHasChanged, | 45 connect(filterWidget, &FilterWidget::filterHasChanged, |
46 this, &MetaDataView::applyDefaultSort); | 46 this, &MetaDataView::applyDefaultSort); |
47 connect(filterWidget, &FilterWidget::filterHasChanged, | |
48 this, &MetaDataView::selectFirstRow); | |
47 baseLayout->addWidget(filterWidget); | 49 baseLayout->addWidget(filterWidget); |
48 | 50 |
49 mView = new QTableView; | 51 mView = new QTableView; |
50 mView->setModel(mSortModel); | 52 mView->setModel(mSortModel); |
51 | 53 |
126 emit selectionChanged(idx.data().toString(), idx.row(), mSortModel->rowCount() - 1, | 128 emit selectionChanged(idx.data().toString(), idx.row(), mSortModel->rowCount() - 1, |
127 timestamp, selected.indexes()[0].data().toInt()); | 129 timestamp, selected.indexes()[0].data().toInt()); |
128 qDebug() << "Selection changed: " << idx.data(); | 130 qDebug() << "Selection changed: " << idx.data(); |
129 } | 131 } |
130 | 132 |
133 void MetaDataView::selectFirstRow() { | |
134 qDebug() << "Selecting first row"; | |
135 selectRow(0); | |
136 } | |
137 | |
131 void MetaDataView::selectRow(int row) { | 138 void MetaDataView::selectRow(int row) { |
132 QItemSelectionModel *selection = mView->selectionModel(); | 139 QItemSelectionModel *selection = mView->selectionModel(); |
133 if (!mSortModel->hasIndex(row, 0)) { | 140 if (!mSortModel->hasIndex(row, 0)) { |
134 qDebug() << "Invalid row: " << row; | 141 qDebug() << "Invalid row: " << row; |
135 return; | 142 return; |
136 } | 143 } |
137 QModelIndex newIdx = mSortModel->index(row, 0); | 144 QModelIndex newIdx = mSortModel->index(row, 0); |
138 selection->select(newIdx, QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows); | 145 selection->select(newIdx, QItemSelectionModel::Clear | QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows); |
139 } | 146 } |
140 | 147 |
141 void MetaDataView::selectPrevRow() { | 148 void MetaDataView::selectPrevRow() { |
142 QItemSelectionModel *selection = mView->selectionModel(); | 149 QItemSelectionModel *selection = mView->selectionModel(); |
143 QModelIndexList selected = selection->selectedIndexes(); | 150 QModelIndexList selected = selection->selectedIndexes(); |