fixed bug in ModelIndex creation in channel post view, and implemented arrow key navigation

This commit is contained in:
csoler 2023-09-04 21:58:45 +02:00
parent 0ed32eb597
commit 8a20ab33b4
5 changed files with 48 additions and 1 deletions

View file

@ -504,6 +504,30 @@ GxsChannelPostsWidgetWithModel::GxsChannelPostsWidgetWithModel(const RsGxsGroupI
}, mEventHandlerId, RsEventType::GXS_CHANNELS );
}
void GxsChannelPostsWidgetWithModel::keyPressEvent(QKeyEvent *e)
{
QModelIndex index = ui->postsTree->selectionModel()->currentIndex();
if(index.isValid() && mChannelPostsModel->getMode() == RsGxsChannelPostsModel::TREE_MODE_GRID)
{
int n = mChannelPostsModel->columnCount(index.row())-1;
if(e->key() == Qt::Key_Left && index.column()==0)
{
ui->postsTree->setCurrentIndex(index.siblingAtColumn(n));
e->accept();
return;
}
if(e->key() == Qt::Key_Right && index.column()==n)
{
ui->postsTree->setCurrentIndex(index.siblingAtColumn(0));
e->accept();
return;
}
}
GxsMessageFrameWidget::keyPressEvent(e);
}
void GxsChannelPostsWidgetWithModel::resizeEvent(QResizeEvent *e)
{
GxsMessageFrameWidget::resizeEvent(e);