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(); }
HtmlText IssueDetailsGenerator::formatChange( const ChangeEntity& change, HtmlText::Flags flags ) { HtmlText result( flags ); switch ( change.type() ) { case IssueCreated: result.appendText( tr( "Name:" ) ); result.appendText( " \"" ); result.appendParsed( change.newValue() ); result.appendText( "\"" ); break; case IssueRenamed: result.appendText( tr( "Name:" ) ); result.appendText( " \"" ); result.appendParsed( change.oldValue() ); result.appendText( QString::fromUtf8( "\" » \"" ) ); result.appendParsed( change.newValue() ); result.appendText( "\"" ); break; case ValueChanged: { result.appendText( change.name() ); result.appendText( tr( ":" ) ); result.appendText( " " ); Formatter formatter; DefinitionInfo info = change.definition(); QString oldValue = formatter.convertAttributeValue( info, change.oldValue(), false ); QString newValue = formatter.convertAttributeValue( info, change.newValue(), false ); if ( oldValue.isEmpty() ) { result.appendText( tr( "empty" ) ); } else { result.appendText( "\"" ); result.appendParsed( oldValue ); result.appendText( "\"" ); } result.appendText( QString::fromUtf8( " » " ) ); if ( newValue.isEmpty() ) { result.appendText( tr( "empty" ) ); } else { result.appendText( "\"" ); result.appendParsed( newValue ); result.appendText( "\"" ); } break; } case IssueMoved: result.appendText( tr( "Issue moved from" ) ); result.appendText( " " ); if ( change.fromFolder().isEmpty() ) { result.appendText( tr( "Unknown Folder" ) ); } else { result.appendText( "\"" ); result.appendText( change.fromFolder() ); result.appendText( "\"" ); } result.appendText( " " ); result.appendText( tr( "to" ) ); result.appendText( " " ); if ( change.toFolder().isEmpty() ) { result.appendText( tr( "Unknown Folder" ) ); } else { result.appendText( "\"" ); result.appendText( change.toFolder() ); result.appendText( "\"" ); } break; default: break; } return result; }