| 301 | } |
| 302 | |
| 303 | QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override |
| 304 | { |
| 305 | if(index.isValid()) |
| 306 | { |
| 307 | FSNode *node = getNode(index); |
| 308 | |
| 309 | switch(role) |
| 310 | { |
| 311 | case Qt::DisplayRole: |
| 312 | { |
| 313 | switch(index.column()) |
| 314 | { |
| 315 | case 0: |
| 316 | { |
| 317 | return node->file.filename; |
| 318 | } |
| 319 | case 1: |
| 320 | { |
| 321 | if(node->file.flags & PathProperty::Directory) |
| 322 | return QVariant(); |
| 323 | return qulonglong(node->file.size); |
| 324 | } |
| 325 | case 2: |
| 326 | { |
| 327 | if(node->file.flags & PathProperty::Directory) |
| 328 | return tr("Directory"); |
| 329 | else if(node->file.flags & PathProperty::Executable) |
| 330 | return tr("Executable file"); |
| 331 | else |
| 332 | return tr("File"); |
| 333 | } |
| 334 | case 3: |
| 335 | { |
| 336 | if(node->file.lastmod == 0) |
| 337 | return QVariant(); |
| 338 | return QDateTime(QDate(1970, 1, 1), QTime(0, 0, 0), Qt::UTC).addSecs(node->file.lastmod); |
| 339 | } |
| 340 | default: break; |
| 341 | } |
| 342 | break; |
| 343 | } |
| 344 | case Qt::DecorationRole: |
| 345 | if(index.column() == 0) |
| 346 | { |
| 347 | int hideIndex = (node->file.flags & PathProperty::Hidden) ? 1 : 0; |
| 348 | |
| 349 | if(node->file.flags & PathProperty::Directory) |
| 350 | return dirIcon[hideIndex]; |
| 351 | else if(node->file.flags & PathProperty::Executable) |
| 352 | return exeIcon[hideIndex]; |
| 353 | else |
| 354 | return fileIcon[hideIndex]; |
| 355 | } |
| 356 | break; |
| 357 | case Qt::TextAlignmentRole: |
| 358 | if(index.column() == 1) |
| 359 | return Qt::AlignRight; |
| 360 | break; |
no test coverage detected