Skip to content

Commit da9aa0a

Browse files
committed
Added checkbox to clear existing data when merging timeseries
1 parent 738977f commit da9aa0a

File tree

4 files changed

+25
-5
lines changed

4 files changed

+25
-5
lines changed

plotjuggler_app/mainwindow.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1373,7 +1373,7 @@ bool MainWindow::loadDataFromFiles(QStringList filenames)
13731373
{
13741374
filenames.sort();
13751375
std::map<QString, QString> filename_prefix;
1376-
bool mergeFiles = false;
1376+
bool mergeFiles = false, clearExisting = true;
13771377

13781378
if (filenames.size() > 1 || ui->checkBoxAddPrefixAndMerge->isChecked())
13791379
{
@@ -1385,6 +1385,7 @@ bool MainWindow::loadDataFromFiles(QStringList filenames)
13851385
}
13861386
filename_prefix = dialog.getPrefixes();
13871387
mergeFiles = dialog.mergeFiles;
1388+
clearExisting = dialog.clearExisting;
13881389
}
13891390

13901391
std::unordered_set<std::string> previous_names = _mapped_plot_data.getAllNames();
@@ -1400,7 +1401,7 @@ bool MainWindow::loadDataFromFiles(QStringList filenames)
14001401
{
14011402
info.prefix = filename_prefix[info.filename];
14021403
}
1403-
auto added_names = loadDataFromFile(info, mergeFiles);
1404+
auto added_names = loadDataFromFile(info, mergeFiles && !(i == 0 && clearExisting));
14041405
if (!added_names.empty())
14051406
{
14061407
loaded_filenames.push_back(filenames[i]);

plotjuggler_app/multifile_prefix.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,16 @@ DialogMultifilePrefix::DialogMultifilePrefix(QStringList filenames, QWidget* par
3232
ui->mergeFilesCheckbox->setChecked(
3333
settings.value("DialogMultifilePrefix::mergeFiles", false).toBool());
3434

35+
ui->checkBoxClearExisting->setChecked(
36+
settings.value("DialogMultifilePrefix::clearExisting", true).toBool());
37+
38+
ui->checkBoxClearExisting->setDisabled(!ui->mergeFilesCheckbox->isChecked());
39+
connect(ui->mergeFilesCheckbox, &QCheckBox::toggled, this,
40+
[this](bool checked) {
41+
ui->checkBoxClearExisting->setDisabled(!checked);
42+
});
43+
44+
3545
int index = 0;
3646
for (QString filename : filenames)
3747
{
@@ -60,6 +70,7 @@ DialogMultifilePrefix::DialogMultifilePrefix(QStringList filenames, QWidget* par
6070
}
6171

6272
this->mergeFilesCheckbox = ui->mergeFilesCheckbox;
73+
this->clearExistingCheckbox = ui->checkBoxClearExisting;
6374
}
6475

6576
std::map<QString, QString> DialogMultifilePrefix::getPrefixes() const
@@ -93,9 +104,10 @@ void DialogMultifilePrefix::accept()
93104
}
94105

95106
this->mergeFiles = this->mergeFilesCheckbox->isChecked();
107+
this->clearExisting = this->clearExistingCheckbox->isChecked();
96108

97109
settings.setValue("DialogMultifilePrefix::previous", prev_prefixes);
98110
settings.setValue("DialogMultifilePrefix::mergeFiles", this->mergeFiles);
99-
111+
settings.setValue("DialogMultifilePrefix::clearExisting", this->clearExisting);
100112
QDialog::accept();
101113
}

plotjuggler_app/multifile_prefix.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class DialogMultifilePrefix : public QDialog
2323
public:
2424
explicit DialogMultifilePrefix(QStringList filenames, QWidget* parent = nullptr);
2525

26-
bool mergeFiles;
26+
bool mergeFiles, clearExisting;
2727
std::map<QString, QString> getPrefixes() const;
2828

2929
~DialogMultifilePrefix();
@@ -35,7 +35,7 @@ class DialogMultifilePrefix : public QDialog
3535
std::map<QString, QLineEdit*> _line_edits;
3636
std::map<QString, QString> _previous_prefixes;
3737
std::map<QString, QString> _prefixes;
38-
QCheckBox *mergeFilesCheckbox;
38+
QCheckBox *mergeFilesCheckbox, *clearExistingCheckbox;
3939
};
4040

4141
#endif // MULTIFILE_PREFIX_H

plotjuggler_app/multifile_prefix.ui

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,13 @@
6464
</property>
6565
</widget>
6666
</item>
67+
<item>
68+
<widget class="QCheckBox" name="checkBoxClearExisting">
69+
<property name="text">
70+
<string>clear already present data</string>
71+
</property>
72+
</widget>
73+
</item>
6774
<item>
6875
<widget class="QDialogButtonBox" name="buttonBox">
6976
<property name="orientation">

0 commit comments

Comments
 (0)