diff --git a/plotjuggler_app/multifile_prefix.cpp b/plotjuggler_app/multifile_prefix.cpp index 8d7bee897..fe380c361 100644 --- a/plotjuggler_app/multifile_prefix.cpp +++ b/plotjuggler_app/multifile_prefix.cpp @@ -11,6 +11,7 @@ #include #include #include +#include DialogMultifilePrefix::DialogMultifilePrefix(QStringList filenames, QWidget* parent) : QDialog(parent), ui(new Ui::DialogMultifilePrefix) @@ -31,6 +32,20 @@ DialogMultifilePrefix::DialogMultifilePrefix(QStringList filenames, QWidget* par int index = 0; for (QString filename : filenames) { + // look for = in the parent directory, if there is one the data is probably in a hive structure + std::filesystem::path path = filename.toStdString(); + std::string hive_path; + bool found_hive = false; + while (path.has_parent_path() && + path.parent_path().filename().string().find('=') != std::string::npos) + { + path = path.parent_path(); + std::string path_str = path.filename().string(); + hive_path.insert(0, path_str.erase(0, path_str.find("=") + 1)); + hive_path.insert(0, "/"); + found_hive = true; + } + auto label_file = new QLabel(filename, this); label_file->setTextInteractionFlags(Qt::TextSelectableByMouse); @@ -43,13 +58,20 @@ DialogMultifilePrefix::DialogMultifilePrefix(QStringList filenames, QWidget* par vlayout->insertWidget(index++, label_file); vlayout->insertLayout(index++, form_layout); - if (_previous_prefixes.count(filename)) + if (found_hive) { - line_edit->setText(_previous_prefixes[filename]); + line_edit->setText(hive_path.c_str()); } else { - line_edit->setText(QFileInfo(filename).baseName()); + if (_previous_prefixes.count(filename)) + { + line_edit->setText(_previous_prefixes[filename]); + } + else + { + line_edit->setText(QFileInfo(filename).baseName()); + } } _prefixes[filename] = line_edit->text(); _line_edits.insert({ filename, line_edit });