Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor parsed output display in RequestBuilder.cpp #74

Merged
merged 1 commit into from
Jan 30, 2024
Merged
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
45 changes: 35 additions & 10 deletions src/ui/RequestBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -526,16 +526,41 @@ void RequestBuilder::show_response_dialog(const request_data_handler_response &r
QVBoxLayout *parsedOutputLayout = new QVBoxLayout;
parsedOutputGroupBox->setLayout(parsedOutputLayout);
if (response.body_parts_parsed.size() > 1) {
// Add a QTabWidget to show the parsed output parts
QTabWidget *tabWidget = new QTabWidget;
parsedOutputLayout->addWidget(tabWidget);
for (auto &parsedOutput : response.body_parts_parsed) {
// label each tab {outputN} where N is the index of the output part
tabWidget->addTab(
new QLabel(QString::fromStdString(parsedOutput)),
QString::fromStdString("{output" +
std::to_string(tabWidget->count()) +
"}"));
if (response.body_parts_parsed.size() > 3) {
// Use a dropdown to select the parsed output to show
QComboBox *parsedOutputComboBox = new QComboBox;
parsedOutputLayout->addWidget(parsedOutputComboBox);
for (size_t i = 0; i < response.body_parts_parsed.size(); i++) {
// add each parsed output to the dropdown
parsedOutputComboBox->addItem(
QString::number(i) + ": " +
QString::fromStdString(
response.body_parts_parsed[i]),
QVariant(QString::fromStdString(
response.body_parts_parsed[i])));
}
// Add a QLabel to show the selected parsed output
QLabel *parsedOutputLabel = new QLabel;
parsedOutputLayout->addWidget(parsedOutputLabel);
// Show the selected parsed output
connect(parsedOutputComboBox, &QComboBox::currentTextChanged, this,
[=]() {
parsedOutputLabel->setText(
parsedOutputComboBox->currentData()
.toString());
});
} else {
// Add a QTabWidget to show the parsed output parts
QTabWidget *tabWidget = new QTabWidget;
parsedOutputLayout->addWidget(tabWidget);
for (auto &parsedOutput : response.body_parts_parsed) {
// label each tab {outputN} where N is the index of the output part
tabWidget->addTab(
new QLabel(QString::fromStdString(parsedOutput)),
QString::fromStdString(
"{output" +
std::to_string(tabWidget->count()) + "}"));
}
}
} else {
QString parsed_output =
Expand Down
Loading