| 42 | |
| 43 | |
| 44 | QSize sizeHintForHtml( const QString& html, QSize maxSize ) { |
| 45 | QTextDocument doc; |
| 46 | doc.setHtml( html ); |
| 47 | |
| 48 | QSize ret; |
| 49 | if( doc.idealWidth() > maxSize.width() ) { |
| 50 | doc.setPageSize( QSize( maxSize.width(), 30 ) ); |
| 51 | ret.setWidth( maxSize.width() ); |
| 52 | }else{ |
| 53 | ret.setWidth( doc.idealWidth() ); |
| 54 | } |
| 55 | ret.setHeight( doc.size().height() ); |
| 56 | if( ret.height() > maxSize.height() ) |
| 57 | ret.setHeight( maxSize.height() ); |
| 58 | return ret; |
| 59 | } |
| 60 | |
| 61 | } |
| 62 |
no test coverage detected