| 32 | {} |
| 33 | |
| 34 | void VcsItemEventModel::addItemEvents( const QList<KDevelop::VcsItemEvent>& list ) |
| 35 | { |
| 36 | if(rowCount()==0) |
| 37 | setColumnCount(2); |
| 38 | |
| 39 | bool copySource = false; |
| 40 | QMimeDatabase mimeDataBase; |
| 41 | for (const KDevelop::VcsItemEvent& ev : list) { |
| 42 | |
| 43 | KDevelop::VcsItemEvent::Actions act = ev.actions(); |
| 44 | QStringList actionStrings; |
| 45 | if( act & KDevelop::VcsItemEvent::Added ) |
| 46 | actionStrings << i18nc("@item", "Added"); |
| 47 | else if( act & KDevelop::VcsItemEvent::Deleted ) |
| 48 | actionStrings << i18nc("@item", "Deleted"); |
| 49 | else if( act & KDevelop::VcsItemEvent::Modified ) |
| 50 | actionStrings << i18nc("@item", "Modified"); |
| 51 | else if( act & KDevelop::VcsItemEvent::Copied ) |
| 52 | actionStrings << i18nc("@item", "Copied"); |
| 53 | else if( act & KDevelop::VcsItemEvent::Replaced ) |
| 54 | actionStrings << i18nc("@item", "Replaced"); |
| 55 | QUrl repoUrl = QUrl::fromLocalFile(ev.repositoryLocation()); |
| 56 | QMimeType mime = repoUrl.isLocalFile() |
| 57 | ? mimeDataBase.mimeTypeForFile(repoUrl.toLocalFile(), QMimeDatabase::MatchExtension) |
| 58 | : mimeDataBase.mimeTypeForUrl(repoUrl); |
| 59 | QList<QStandardItem*> rowItems{ |
| 60 | new QStandardItem(QIcon::fromTheme(mime.iconName()), ev.repositoryLocation()), |
| 61 | new QStandardItem(actionStrings.join(i18nc("separates an action list", ", "))), |
| 62 | }; |
| 63 | QString loc = ev.repositoryCopySourceLocation(); |
| 64 | if(!loc.isEmpty()) { //according to the documentation, those are optional. don't force them on the UI |
| 65 | rowItems << new QStandardItem(ev.repositoryCopySourceLocation()); |
| 66 | VcsRevision rev = ev.repositoryCopySourceRevision(); |
| 67 | if(rev.revisionType()!=VcsRevision::Invalid) { |
| 68 | rowItems << new QStandardItem(ev.repositoryCopySourceRevision().revisionValue().toString()); |
| 69 | } |
| 70 | copySource = true; |
| 71 | } |
| 72 | |
| 73 | rowItems.first()->setData(QVariant::fromValue(ev)); |
| 74 | appendRow(rowItems); |
| 75 | } |
| 76 | if(copySource) |
| 77 | setColumnCount(4); |
| 78 | } |
| 79 | |
| 80 | QVariant VcsItemEventModel::headerData(int section, Qt::Orientation orientation, int role) const |
| 81 | { |
no test coverage detected