| 1206 | } |
| 1207 | |
| 1208 | void |
| 1209 | SequenceItemDelegate::paint(QPainter * painter, |
| 1210 | const QStyleOptionViewItem &option, |
| 1211 | const QModelIndex & index) const |
| 1212 | { |
| 1213 | assert( index.isValid() ); |
| 1214 | |
| 1215 | |
| 1216 | // get the proper subrect from the style |
| 1217 | QStyle *style = QApplication::style(); |
| 1218 | QRect geom = style->subElementRect(QStyle::SE_ItemViewItemText, &option); |
| 1219 | FileSystemModel* model = _fd->getFileSystemModel(); |
| 1220 | QModelIndex nameColumnIndex; |
| 1221 | if (index.column() == FileSystemModel::Name) { |
| 1222 | nameColumnIndex = index; |
| 1223 | } else { |
| 1224 | ///To get the file-path, first retrieve the item in the column 0 |
| 1225 | nameColumnIndex = model->index( index.row(), 0, index.parent() ); |
| 1226 | } |
| 1227 | |
| 1228 | if ( !index.isValid() ) { |
| 1229 | return QStyledItemDelegate::paint(painter, option, index); |
| 1230 | } |
| 1231 | |
| 1232 | FileSystemItem* item = model->getFileSystemItem(nameColumnIndex); |
| 1233 | if (!item) { |
| 1234 | return QStyledItemDelegate::paint(painter, option, index); |
| 1235 | } |
| 1236 | |
| 1237 | QString filename = item->getUserFriendlyFilename(); |
| 1238 | //QFont f(appFont,appFontSize); |
| 1239 | //painter->setFont(f); |
| 1240 | if (option.state & QStyle::State_Selected) { |
| 1241 | painter->fillRect( geom, option.palette.highlight() ); |
| 1242 | } |
| 1243 | |
| 1244 | QRect r; |
| 1245 | QRect textRect( geom.x() + 5, geom.y(), geom.width() - 5, geom.height() ); |
| 1246 | |
| 1247 | |
| 1248 | if ( (index.column() == FileSystemModel::Type) || (index.column() == FileSystemModel::DateModified) ) { |
| 1249 | ///Draw the item name column |
| 1250 | QString data = index.data().toString(); |
| 1251 | if ( data.isEmpty() ) { |
| 1252 | data = QString::fromUtf8("--"); |
| 1253 | } |
| 1254 | painter->drawText(textRect, Qt::TextSingleLine, data, &r); |
| 1255 | |
| 1256 | return; |
| 1257 | } |
| 1258 | |
| 1259 | bool isDir = item->isDir(); |
| 1260 | |
| 1261 | if (index.column() == FileSystemModel::Size) { |
| 1262 | quint64 size = index.data().toULongLong(); |
| 1263 | QString itemSizeText; |
| 1264 | if (!isDir) { |
| 1265 | itemSizeText = printAsRAM(size); |
nothing calls this directly
no test coverage detected