fixed bug grid view when the current index is requested, if there are no comics then a invalid QModelIndex should be returned

This commit is contained in:
Luis Ángel San Martín 2016-01-03 13:10:04 +01:00
parent 1a8b629e71
commit 135f2432f1

View File

@ -219,13 +219,21 @@ void GridComicsView::setCurrentIndex(const QModelIndex &index)
QModelIndex GridComicsView::currentIndex()
{
QLOG_INFO() << "currentIndex";
QLOG_INFO() << "currentIndex";
if(!_selectionModel)
return QModelIndex();
QModelIndexList indexes = _selectionModel->selectedRows();
if(indexes.length()>0)
return indexes[0];
this->selectIndex(0);
return _selectionModel->selectedRows()[0];
indexes = _selectionModel->selectedRows();
if(indexes.length()>0)
return indexes[0];
else
return QModelIndex();
}
QItemSelectionModel *GridComicsView::selectionModel()