94 const std::string& example)
100 exists = fs::exists(exampleDir);
101 }
catch (std::exception&) {
106 addWidget(std::make_unique<WText>(
"No such example: " + exampleDir));
110 model_ = std::make_shared<WStandardItemModel>(0, 1);
118 std::unique_ptr<WText> title(std::make_unique<WText>(
120 title->setInternalPathEncoding(
true);
122 auto exampleView = std::make_unique<WTreeView>();
155 auto topLayout = std::make_unique<WVBoxLayout>();
156 topLayout->addWidget(std::move(title));
158 auto gitLayout = std::make_unique<WHBoxLayout>();
160 gitLayout->
addWidget(std::move(exampleView), 0);
161 gitLayout->addWidget(std::move(sourceView), 1);
162 topLayout->addLayout(std::move(gitLayout), 1);
191 const fs::path& path)
193 static const char *supportedFiles[] = {
194 ".C",
".cpp",
".h",
".css",
".xml",
".png",
".gif",
".csv",
".ico", 0
197 auto dir = std::make_unique<FileItem>(
"/icons/yellow-folder-open.png",
201 parent->appendRow(std::move(dir));
204 std::set<fs::path> paths;
206 fs::directory_iterator end_itr;
207 for (fs::directory_iterator i(path); i != end_itr; ++i)
210 std::vector<std::unique_ptr<FileItem>> classes, files;
211 std::vector<fs::path> dirs;
213 while (!paths.empty()) {
214 fs::path p = *paths.begin();
218 if (fs::is_symlink(p))
222 if (fs::is_regular_file(p)) {
223 std::string ext = p.extension().string();
224 bool supported =
false;
225 for (
const char **s = supportedFiles; *s != 0; ++s)
237 if (!companion.empty()) {
238 std::set<fs::path>::iterator it_companion = paths.find(companion);
240 if (it_companion != paths.end()) {
241 std::string className =
stem(p);
242 escapeText(className);
243 std::string label =
"<i>class</i> " + className;
245 std::unique_ptr<FileItem> classItem =
246 std::make_unique<FileItem>(
"/icons/cppclass.png", label, std::string());
250 = std::make_unique<FileItem>(
"/icons/document.png",
filename(p),
253 = std::make_unique<FileItem>(
"/icons/document.png",
255 (*it_companion).string());
256 classItem->appendRow(std::move(header));
257 classItem->appendRow(std::move(cpp));
259 classes.push_back(std::move(classItem));
260 paths.erase(it_companion);
263 = std::make_unique<FileItem>(
"/icons/document.png",
filename(p),
265 files.push_back(std::move(file));
267 }
else if (fs::is_directory(p)) {
271 = std::make_unique<FileItem>(
"/icons/document.png",
filename(p),
273 files.push_back(std::move(file));
279 for (
unsigned int i = 0; i < classes.size(); i++)
280 parent->appendRow(std::move(classes[i]));
282 for (
unsigned int i = 0; i < files.size(); i++)
283 parent->appendRow(std::move(files[i]));
285 for (
unsigned int i = 0; i < dirs.size(); i++)
287 }
catch (fs::filesystem_error& e) {
288 std::cerr << e.what() << std::endl;
293 const fs::path& srcPath,
294 const std::string packageName)
296 fs::directory_iterator end_itr;
299 for (fs::directory_iterator i(srcPath); i != end_itr; ++i) {
301 if (fs::is_regular_file(p)) {
303 auto item = std::make_unique<FileItem>(
"/icons/package.png", packageName,
"");
304 packageItem = item.get();
305 parent->appendRow(std::move(item));
309 = std::make_unique<FileItem>(
"/icons/javaclass.png",
filename(p),
315 for (fs::directory_iterator i(srcPath); i != end_itr; ++i) {
317 if (fs::is_directory(p)) {
318 std::string pn = packageName;
329 const fs::path& path)
332 = std::make_unique<FileItem>(
"/icons/yellow-folder-open.png",
335 parent->appendRow(std::move(dir));
338 std::vector<fs::path> files, dirs;
340 fs::directory_iterator end_itr;
341 for (fs::directory_iterator i(path); i != end_itr; ++i) {
343 if (fs::is_directory(p)) {
346 = std::make_unique<FileItem>(
"/icons/package-folder-open.png",
349 parent->appendRow(std::move(dir));
361 for (
auto item : dirs)
364 for (
auto item : files) {
366 = std::make_unique<FileItem>(
"/icons/document.png",
filename(item),
368 parent->appendRow(std::move(file));