MCPcopy Create free account
hub / github.com/NatronGitHub/Natron / paint

Method paint

Gui/SequenceFileDialog.cpp:1196–1292  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 15

printAsRAMFunction · 0.85
getFileSystemModelMethod · 0.80
columnMethod · 0.80
parentMethod · 0.80
getFileSystemItemMethod · 0.80
isDirMethod · 0.80
appendMethod · 0.80
setBoldMethod · 0.80
setFontMethod · 0.80
iconMethod · 0.80
isValidMethod · 0.45
indexMethod · 0.45

Tested by

no test coverage detected