mirror of
https://github.com/YACReader/yacreader
synced 2025-07-26 00:44:59 -04:00
fixed more selection issues in grid view
This commit is contained in:
@ -102,6 +102,7 @@ void GridComicsView::setModel(ComicModel *model)
|
||||
void GridComicsView::setCurrentIndex(const QModelIndex &index)
|
||||
{
|
||||
QLOG_INFO() << "setCurrentIndex";
|
||||
_selectionModel->clear();
|
||||
_selectionModel->select(index, QItemSelectionModel::Select | QItemSelectionModel::Rows);
|
||||
view->rootContext()->setContextProperty("dummyValue", true);
|
||||
}
|
||||
@ -206,7 +207,24 @@ void GridComicsView::selectIndex(int index)
|
||||
{
|
||||
QLOG_INFO() << "selectIndex" << index;
|
||||
if(_selectionModel != NULL && model!=NULL)
|
||||
{
|
||||
_selectionModel->select(model->index(index,0),QItemSelectionModel::Select | QItemSelectionModel::Rows);
|
||||
view->rootContext()->setContextProperty("dummyValue", true);
|
||||
}
|
||||
}
|
||||
|
||||
void GridComicsView::setCurrentIndex(int index)
|
||||
{
|
||||
setCurrentIndex(model->index(index,0));
|
||||
}
|
||||
|
||||
void GridComicsView::deselectIndex(int index)
|
||||
{
|
||||
if(_selectionModel != NULL && model!=NULL)
|
||||
{
|
||||
_selectionModel->select(model->index(index,0),QItemSelectionModel::Deselect | QItemSelectionModel::Rows);
|
||||
view->rootContext()->setContextProperty("dummyValue", true);
|
||||
}
|
||||
}
|
||||
|
||||
bool GridComicsView::isSelectedIndex(int index)
|
||||
@ -237,6 +255,27 @@ void GridComicsView::selectedItem(int index)
|
||||
emit doubleClicked(model->index(index,0));
|
||||
}
|
||||
|
||||
int GridComicsView::numItemsSelected()
|
||||
{
|
||||
if(_selectionModel != NULL)
|
||||
{
|
||||
return _selectionModel->selectedRows().length();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int GridComicsView::lastSelectedIndex()
|
||||
{
|
||||
if(_selectionModel != NULL)
|
||||
{
|
||||
QLOG_INFO() << "last selected index " << _selectionModel->selectedRows().last().row();
|
||||
return _selectionModel->selectedRows().last().row();
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
void GridComicsView::setShowMarks(bool show)
|
||||
{
|
||||
QLOG_INFO() << "setShowMarks";
|
||||
|
Reference in New Issue
Block a user