MCPcopy Create free account
hub / github.com/ModOrganizer2/modorganizer / readTree

Method readTree

src/syncoverwritedialog.cpp:69–123  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

67}
68
69void 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
125void SyncOverwriteDialog::refresh(const QString& path)
126{

Callers

nothing calls this directly

Calls 12

ToWStringFunction · 0.85
addToComboBoxFunction · 0.85
findSubDirectoryMethod · 0.80
addItemMethod · 0.80
countMethod · 0.80
addChildMethod · 0.80
nextMethod · 0.45
findFileMethod · 0.45
getMethod · 0.45
getOriginMethod · 0.45
getNameMethod · 0.45
originIDMethod · 0.45

Tested by

no test coverage detected