void IssueDetailsGenerator::writeProperties( HtmlWriter* writer, const IssueEntity& issue )
{
    QStringList headers;
    QList<HtmlText> items;

    headers.append( tr( "ID:" ) );
    items.append( QString( "#%1" ).arg( issue.id() ) );

    FolderEntity folder = issue.folder();

    headers.append( tr( "Type:" ) );
    items.append( folder.type().name() );
    headers.append( tr( "Location:" ) );
    items.append( folder.project().name() + QString::fromUtf8( " — " ) + folder.name() );

    Formatter formatter;

    headers.append( tr( "Created:" ) );
    items.append( QString::fromUtf8( "%1 — %2" ).arg( formatter.formatDateTime( issue.createdDate(), true ), issue.createdUser() ) );
    headers.append( tr( "Last Modified:" ) );
    items.append( QString::fromUtf8( "%1 — %2" ).arg( formatter.formatDateTime( issue.modifiedDate(), true ), issue.modifiedUser() ) );

    writer->writeInfoList( headers, items, false );
}
HtmlText IssueDetailsGenerator::changeLinks( const ChangeEntity& change, HtmlText::Flags flags )
{
    HtmlText result( flags );

    if ( change.stampId() != change.id() ) {
        Formatter formatter;
        result.appendText( tr( "Last Edited:" ) );
        result.appendText( QString::fromUtf8( " %1 — %2" ).arg( formatter.formatDateTime( change.modifiedDate(), true ), change.modifiedUser() ) );
        result.appendText( " | " );
    }

    result.createAnchor( QString( "item%1" ).arg( change.id() ) );
    if ( flags.testFlag( HtmlText::NoInternalLinks ) ) {
        if ( change.type() == CommentAdded )
            result.appendText( tr( "Comment #%1" ).arg( change.id() ) );
        else
            result.appendText( tr( "Attachment #%1" ).arg( change.id() ) );
    } else {
        if ( change.type() == CommentAdded )
            result.appendImageAndText( "comment", tr( "Comment #%1" ).arg( change.id() ) );
        else
            result.appendImageAndText( "file-attach", tr( "Attachment #%1" ).arg( change.id() ) );
    }
    result.endAnchor();

    if ( !flags.testFlag( HtmlText::NoInternalLinks ) ) {
        if ( change.type() == CommentAdded ) {
            result.appendText( " | " );
            result.appendImageAndTextLink( "comment-reply", tr( "Reply" ), QString( "command://reply-comment/%1" ).arg( change.id() ) );
        }

        if ( m_isAdmin || change.createdUserId() == dataManager->currentUserId() ) {
            result.appendText( " | " );
            if ( change.type() == CommentAdded )
                result.appendImageAndTextLink( "edit-modify", tr( "Edit" ), QString( "command://edit-comment/%1" ).arg( change.id() ) );
            else
                result.appendImageAndTextLink( "edit-modify", tr( "Edit" ), QString( "command://edit-file/%1" ).arg( change.id() ) );

            result.appendText( " | " );
            if ( change.type() == CommentAdded )
                result.appendImageAndTextLink( "edit-delete", tr( "Delete" ), QString( "command://delete-comment/%1" ).arg( change.id() ) );
            else
                result.appendImageAndTextLink( "edit-delete", tr( "Delete" ), QString( "command://delete-file/%1" ).arg( change.id() ) );
        }
    }

    return result;
}
HtmlText IssueDetailsGenerator::descriptionLinks( const DescriptionEntity& description, HtmlText::Flags flags )
{
    HtmlText result( flags );

    Formatter formatter;
    result.appendText( tr( "Last Edited:" ) );
    result.appendText( QString::fromUtf8( " %1 — %2" ).arg( formatter.formatDateTime( description.modifiedDate(), true ), description.modifiedUser() ) );

    if ( !flags.testFlag( HtmlText::NoInternalLinks ) ) {
        result.appendText( " | " );
        result.appendImageAndTextLink( "comment-reply", tr( "Reply" ), "command://reply-description/" );
        if ( m_isOwner || m_isAdmin ) {
            result.appendText( " | " );
            result.appendImageAndTextLink( "edit-modify", tr( "Edit" ), "command://edit-description/" );
            result.appendText( " | " );
            result.appendImageAndTextLink( "edit-delete", tr( "Delete" ), "command://delete-description/" );
        }
    }

    return result;
}
예제 #4
0
QVariant FolderModel::data( const QModelIndex& index, int role ) const
{
    int level = levelOf( index );
    int row = mappedRow( index );

    if ( role == Qt::DisplayRole ) {
        QVariant value = rawData( level, row, mappedColumn( index ), role );

        int column = m_columns.value( index.column() );

        switch ( column ) {
            case Column_ID:
                return QString( "#%1" ).arg( value.toInt() );
            case Column_Name:
            case Column_CreatedBy:
            case Column_ModifiedBy:
                return value;
            case Column_CreatedDate:
            case Column_ModifiedDate: {
                QDateTime dateTime;
                dateTime.setTime_t( value.toInt() );
                Formatter formatter;
                return formatter.formatDateTime( dateTime, true );
            }
            case Column_Location:
                return rawData( level, row, m_columns.count() + 3 ).toString() + QString::fromUtf8( " — " ) + value.toString();
            default:
                if ( !value.isNull() ) {
                    int column = m_columns.value( index.column() );
                    if ( column > Column_UserDefined ) {
                        Formatter formatter;
                        IssueTypeCache* cache = dataManager->issueTypeCache( m_typeId );
                        DefinitionInfo info = cache->attributeDefinition( column - Column_UserDefined );
                        return formatter.convertAttributeValue( info, value.toString(), false );
                    }
                }
        }
    }

    if ( role == Qt::DecorationRole && index.column() == 1 ) {
        QString name, overlay;
        int readId = rawData( level, row, 2, Qt::DisplayRole ).toInt();
        if ( readId == 0 ) {
            name = "issue-unread";
        } else {
            int stampId = rawData( level, row, 1, Qt::DisplayRole ).toInt();
            if ( readId < stampId )
                name = "issue-modified";
            else
                name = "issue";
        }
        bool emailEnabled = dataManager->setting( "email_enabled" ).toInt();
        if ( emailEnabled ) {
            int subscriptionId = rawData( level, row, 3, Qt::DisplayRole ).toInt();
            if ( subscriptionId != 0 )
                overlay = "overlay-subscribed";
        }
        if ( !overlay.isEmpty() )
            return IconLoader::overlayedPixmap( name, overlay );
        else
            return IconLoader::pixmap( name );
    }

    if ( role == Qt::FontRole ) {
        bool bold = false;
        int readId = rawData( level, row, 2, Qt::DisplayRole ).toInt();
        if ( readId == 0 ) {
            bold = true;
        } else {
            int stampId = rawData( level, row, 1, Qt::DisplayRole ).toInt();
            if ( readId < stampId )
                bold = true;
        }
        if ( bold ) {
            QFont font;
            font.setBold( true );
            return font;
        }
    }

    return QVariant();
}
QString IssueDetailsGenerator::formatStamp( const ChangeEntity& change )
{
    Formatter formatter;
    return QString::fromUtf8( "%1 — %2" ).arg( formatter.formatDateTime( change.createdDate(), true ), change.createdUser() );
}