void IssueDetailsGenerator::writeHistory( HtmlWriter* writer, const IssueEntity& issue, HtmlText::Flags flags )
{
    Qt::SortOrder order = Qt::AscendingOrder;

    if ( dataManager->preferenceOrSetting( "history_order" ) == "desc" )
        order = Qt::DescendingOrder;

    QList<ChangeEntity> changes;
    if ( m_history == AllHistory )
        changes = issue.changes( order );
    else if ( m_history == OnlyComments )
        changes = issue.comments( order );
    else if ( m_history == OnlyFiles )
        changes = issue.files( order );
    else if ( m_history == CommentsAndFiles )
        changes = issue.commentsAndFiles( order );

    QList<HtmlText> list;

    int lastUserId = 0;
    QDateTime lastDate;

    for ( int i = 0; i < changes.count(); i++ ) {
        const ChangeEntity& change = changes.at( i );

        if ( change.type() == ValueChanged && change.attributeId() == 0 )
            continue;

        if ( change.type() <= ValueChanged && list.count() > 0 ) {
            if ( change.createdUserId() == lastUserId && lastDate.secsTo( change.createdDate() ) < 180 ) {
                list.append( formatChange( change, flags ) );
                continue;
            }
        }

        if ( list.count() > 0 ) {
            writer->writeBulletList( list );
            writer->endHistoryItem();
            list.clear();
        }

        switch ( change.type() ) {
            case IssueCreated:
            case IssueRenamed:
            case ValueChanged:
                lastUserId = change.createdUserId();
                lastDate = change.createdDate();
                writer->beginHistoryItem();
                writer->writeBlock( formatStamp( change ), HtmlWriter::Header4Block );
                list.append( formatChange( change, flags ) );
                break;

            case CommentAdded:
                writer->beginHistoryItem();
                writer->writeBlock( changeLinks( change, flags ), HtmlWriter::HistoryInfoBlock );
                writer->writeBlock( formatStamp( change ), HtmlWriter::Header4Block );
                writer->writeBlock( commentText( change.comment(), flags ), HtmlWriter::CommentBlock );
                writer->endHistoryItem();
                m_commentsCount++;
                break;

            case FileAdded:
                writer->beginHistoryItem();
                writer->writeBlock( changeLinks( change, flags ), HtmlWriter::HistoryInfoBlock );
                writer->writeBlock( formatStamp( change ), HtmlWriter::Header4Block );
                writer->writeBlock( formatFile( change.file(), flags ), HtmlWriter::AttachmentBlock );
                writer->endHistoryItem();
                m_filesCount++;
                break;

            case IssueMoved:
                writer->beginHistoryItem();
                writer->writeBlock( formatStamp( change ), HtmlWriter::Header4Block );
                writer->writeBulletList( QList<HtmlText>() << formatChange( change, flags ) );
                writer->endHistoryItem();
                break;
        }
    }

    if ( list.count() > 0 ) {
        writer->writeBulletList( list );
        writer->endHistoryItem();
    }

    if ( changes.count() == 0 ) {
        if ( m_history == OnlyComments )
            writer->writeBlock( tr( "There are no comments." ), HtmlWriter::NoItemsBlock );
        else if ( m_history == OnlyFiles )
            writer->writeBlock( tr( "There are no attachments." ), HtmlWriter::NoItemsBlock );
        else if ( m_history == CommentsAndFiles )
            writer->writeBlock( tr( "There are no comments or attachments." ), HtmlWriter::NoItemsBlock );
    }
}
示例#2
0
void MainWindow::selectionChange(){
    int s = mLeftPanel->selectedItems().at(0)->row();
    mRightPanelCommit->setText(mList.at(s).at(5));
    QString c = getDiff(mList.at(s+1).at(0),mList.at(s).at(0));
    mRightPanelEdit->setHtml(formatChange(s,c));
}