QVariant VcsEventModel::data( const QModelIndex& idx, int role ) const { if( !idx.isValid() || role != Qt::DisplayRole ) return QVariant(); if( idx.row() < 0 || idx.row() >= rowCount() || idx.column() < 0 || idx.column() >= columnCount() ) return QVariant(); KDevelop::VcsEvent ev = d->m_events.at( idx.row() ); switch( idx.column() ) { case 0: return QVariant( ev.revision().revisionValue() ); break; case 1: return QVariant( ev.author() ); break; case 2: return QVariant( ev.date() ); break; case 3: return QVariant( ev.message() ); break; default: break; } return QVariant(); }
void VcsEventWidgetPrivate::eventViewClicked( const QModelIndex &index ) { KDevelop::VcsEvent ev = m_logModel->eventForIndex( index ); m_detailModel->removeRows(0, m_detailModel->rowCount()); if( ev.revision().revisionType() != KDevelop::VcsRevision::Invalid ) { m_ui->itemEventView->setEnabled(true); m_ui->message->setEnabled(true); m_ui->message->setPlainText( ev.message() ); m_detailModel->addItemEvents( ev.items() ); }else { m_ui->itemEventView->setEnabled(false); m_ui->message->setEnabled(false); m_ui->message->clear(); } QHeaderView* header = m_ui->itemEventView->header(); header->setSectionResizeMode(QHeaderView::ResizeToContents); header->setStretchLastSection(true); }