| 67 | } |
| 68 | |
| 69 | void SyncOverwriteDialog::readTree(const QString& path, |
| 70 | DirectoryEntry* directoryStructure, |
| 71 | QTreeWidgetItem* subTree) |
| 72 | { |
| 73 | QDir overwrite(path); |
| 74 | overwrite.setFilter(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot); |
| 75 | QDirIterator dirIter(overwrite); |
| 76 | while (dirIter.hasNext()) { |
| 77 | dirIter.next(); |
| 78 | QFileInfo fileInfo = dirIter.fileInfo(); |
| 79 | |
| 80 | QString file = fileInfo.fileName(); |
| 81 | if (file == "meta.ini") { |
| 82 | continue; |
| 83 | } |
| 84 | |
| 85 | QTreeWidgetItem* newItem = new QTreeWidgetItem(subTree, QStringList(file)); |
| 86 | |
| 87 | if (fileInfo.isDir()) { |
| 88 | DirectoryEntry* subDir = directoryStructure->findSubDirectory(ToWString(file)); |
| 89 | if (subDir != nullptr) { |
| 90 | readTree(fileInfo.absoluteFilePath(), subDir, newItem); |
| 91 | } else { |
| 92 | log::error("no directory structure for {}?", file); |
| 93 | delete newItem; |
| 94 | newItem = nullptr; |
| 95 | } |
| 96 | } else { |
| 97 | const FileEntryPtr entry = directoryStructure->findFile(ToWString(file)); |
| 98 | QComboBox* combo = new QComboBox(ui->syncTree); |
| 99 | combo->addItem(tr("<don't sync>"), -1); |
| 100 | if (entry.get() != nullptr) { |
| 101 | bool ignore; |
| 102 | int origin = entry->getOrigin(ignore); |
| 103 | addToComboBox(combo, |
| 104 | ToQString(m_DirectoryStructure->getOriginByID(origin).getName()), |
| 105 | origin); |
| 106 | const auto& alternatives = entry->getAlternatives(); |
| 107 | for (const auto& alt : alternatives) { |
| 108 | addToComboBox( |
| 109 | combo, |
| 110 | ToQString(m_DirectoryStructure->getOriginByID(alt.originID()).getName()), |
| 111 | alt.originID()); |
| 112 | } |
| 113 | combo->setCurrentIndex(combo->count() - 1); |
| 114 | } else { |
| 115 | combo->setCurrentIndex(0); |
| 116 | } |
| 117 | ui->syncTree->setItemWidget(newItem, 1, combo); |
| 118 | } |
| 119 | if (newItem != nullptr) { |
| 120 | subTree->addChild(newItem); |
| 121 | } |
| 122 | } |
| 123 | } |
| 124 | |
| 125 | void SyncOverwriteDialog::refresh(const QString& path) |
| 126 | { |
nothing calls this directly
no test coverage detected