QVariant IWFileTreeModel::displayData(Node* n,const QModelIndex & index) const { if (tc->getStats().multi_file_torrent && n->file) { const bt::TorrentFileInterface* file = n->file; switch (index.column()) { case 2: return PriorityString(file); case 3: if (file->isMultimedia()) { if (file->isPreviewAvailable()) return i18nc("preview available", "Available"); else return i18nc("Preview pending", "Pending"); } else return i18nc("No preview available", "No"); case 4: if (file->getPriority() == ONLY_SEED_PRIORITY || file->getPriority() == EXCLUDED) return QVariant(); else return ki18n("%1 %").subs(n->percentage, 0, 'f', 2).toString(); default: return QVariant(); } } else if (!tc->getStats().multi_file_torrent) { switch (index.column()) { case 2: return QVariant(); case 3: if (mmfile) { if (tc->readyForPreview()) return i18nc("Preview available", "Available"); else return i18nc("Preview pending", "Pending"); } else return i18nc("No preview available", "No"); case 4: return ki18n("%1 %").subs(bt::Percentage(tc->getStats()), 0, 'f', 2).toString(); default: return QVariant(); } } else if (tc->getStats().multi_file_torrent && index.column() == 4) { return ki18n("%1 %").subs(n->percentage, 0, 'f', 2).toString(); } return QVariant(); }
QVariant IWFileListModel::displayData(const QModelIndex& index) const { if (tc->getStats().multi_file_torrent) { const bt::TorrentFileInterface* file = &tc->getTorrentFile(index.row()); switch (index.column()) { case 2: return PriorityString(file); case 3: if (file->isMultimedia()) { if (file->isPreviewAvailable()) return i18nc("Preview available", "Available"); else return i18nc("Preview pending", "Pending"); } else return i18nc("No preview available", "No"); case 4: { float percent = file->getDownloadPercentage(); return ki18n("%1 %").subs(percent, 0, 'f', 2).toString(); } default: return QVariant(); } } else { switch (index.column()) { case 2: return QVariant(); case 3: if (mmfile) { if (tc->readyForPreview()) return i18nc("Preview available", "Available"); else return i18nc("Preview pending", "Pending"); } else return i18nc("No preview available", "No"); case 4: { double percent = bt::Percentage(tc->getStats()); return ki18n("%1 %").subs(percent, 0, 'f', 2).toString(); } default: return QVariant(); } } return QVariant(); }