From 1d6ced38a89547aaf2cc3745876360f0e5086474 Mon Sep 17 00:00:00 2001 From: Gluzskiy Alexandr Date: Mon, 14 Sep 2015 12:31:13 +0300 Subject: protocol: added module field to client_download_add_request as required server: small handle_command redesign to avoid crashes client-qt: implemented all basic features of download add widget (working now, tested) --- client-qt/udm-client-qt/download_add_widget.cpp | 40 ++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) (limited to 'client-qt/udm-client-qt/download_add_widget.cpp') diff --git a/client-qt/udm-client-qt/download_add_widget.cpp b/client-qt/udm-client-qt/download_add_widget.cpp index 813ac7a..366c7d6 100644 --- a/client-qt/udm-client-qt/download_add_widget.cpp +++ b/client-qt/udm-client-qt/download_add_widget.cpp @@ -76,6 +76,16 @@ download_add_widget::download_add_widget(std::list &modules_, QWidg void download_add_widget::combo_modules_currentIndexChanged(QString module) { + current_module = module; + { + int rows = layout_settings->rowCount(), columns = layout_settings->columnCount(); + for(int i = 0; i < rows; i++) + { + for(int ii = 0; ii < columns; ii ++) + delete layout_settings->itemAtPosition(i, ii); + } + } + for (QLayoutItem *item = layout_settings->takeAt(0); item != 0; item = layout_settings->takeAt(0)) delete item; @@ -98,6 +108,7 @@ void download_add_widget::combo_modules_currentIndexChanged(QString module) { marked_class *edit = new marked_class; edit->set_mark(ui.id()); + edit->set_type(widget_type_e::QLineEdit_t); layout_settings->addWidget(edit, row, 2); } break; @@ -105,6 +116,7 @@ void download_add_widget::combo_modules_currentIndexChanged(QString module) { marked_class *edit = new marked_class; edit->set_mark(ui.id()); + edit->set_type(widget_type_e::QSpinBox_t); layout_settings->addWidget(edit, row, 2); } break; @@ -120,7 +132,33 @@ void download_add_widget::combo_modules_currentIndexChanged(QString module) void download_add_widget::btn_ok_clicked() { - + int rows = layout_settings->rowCount(); + std::map settings; + for (int i = 0; i < rows; ++i) + { + QWidget *w_ = layout_settings->itemAtPosition(i, 2)->widget(); + marked_class *w = static_cast *>(w_); + switch(w->get_type()) + { + case widget_type_e::QLineEdit_t: + { + marked_class *l = static_cast *>(w_); + settings[l->get_mark()] = l->text().toStdString(); + } + break; + case widget_type_e::QSpinBox_t: + { + marked_class *l = static_cast *>(w_); + settings[l->get_mark()] = l->text().toStdString(); + } + break; + default: + break; + } + } + emit got_download_settings(current_module.toStdString(), settings); + close(); + deleteLater(); } void download_add_widget::btn_cancel_clicked() -- cgit v1.2.3