Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 25 additions & 3 deletions plotjuggler_app/multifile_prefix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <QFormLayout>
#include <QFileInfo>
#include <QSettings>
#include <filesystem>

DialogMultifilePrefix::DialogMultifilePrefix(QStringList filenames, QWidget* parent)
: QDialog(parent), ui(new Ui::DialogMultifilePrefix)
Expand All @@ -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);

Expand All @@ -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 });
Expand Down
Loading