QVariant FeedbackModel::data( const QModelIndex& index, int role ) const { if ( index.isValid() ) { const Feedback feedback = this->feedback( index ); switch ( role ) { case Qt::DisplayRole: case Qt::EditRole: { switch ( index.column() ) { case 0: return feedback.dateTime().toString( Qt::DefaultLocaleLongDate ); case 1: return feedback.message(); } break; } case Qt::ToolTipRole: case Qt::WhatsThisRole: { return QString( "<b>%1:</b> %2\n<b>%3:</b> %4" ) .arg( tr( "Date time" ) ) .arg( feedback.dateTime().toString( Qt::DefaultLocaleLongDate ) ) .arg( tr( "Message" ) ) .arg( feedback.message() ) .replace( "\n", "<br />" ) ; } case FeedbackModel::DateTimeRole: { return feedback.dateTime(); } case FeedbackModel::MessageRole: { return feedback.message(); } case FeedbackModel::FeedbackRole: { return feedback; } } } return QVariant(); }
static bool greaterThanMessage( const Feedback& left, const Feedback& right ) { return left.message().compare( right.message(), Qt::CaseInsensitive ) > 0; }