diff options
author | Gluzskiy Alexandr <sss@sss.chaoslab.ru> | 2015-09-13 08:17:15 +0300 |
---|---|---|
committer | Gluzskiy Alexandr <sss@sss.chaoslab.ru> | 2015-09-13 08:17:15 +0300 |
commit | eb5bc25a3ce4eb9a650e433a5206f535c54b453c (patch) | |
tree | 913aaa9450937ebe6553195d853ed69b7a47bddc /client-qt/udm-client-qt/download_add_widget.cpp | |
parent | 53ecb7e48ede8dbfde85b6452d3fdbd7c56ae01e (diff) |
protocol:
added "data_required" field to module_download_ui_element_info for download creation ui
renamed download_children_menu to download_content_menu as it's more apropriate name
server:
added "data_required" field to module_download_ui_element_info_s for download creation ui
changed "id" field in module_download_menu_element_info_s from string to int
implemented helper functions to fill module_info protobuff structure
implemented most of module_info structures filling (tested, working)
client:
basic implementation of "download add widget"
"marked_class" template for adding module defined id's to ui elements
basic action buttons toolbar in main windows
Diffstat (limited to 'client-qt/udm-client-qt/download_add_widget.cpp')
-rw-r--r-- | client-qt/udm-client-qt/download_add_widget.cpp | 109 |
1 files changed, 109 insertions, 0 deletions
diff --git a/client-qt/udm-client-qt/download_add_widget.cpp b/client-qt/udm-client-qt/download_add_widget.cpp new file mode 100644 index 0000000..6dae8d0 --- /dev/null +++ b/client-qt/udm-client-qt/download_add_widget.cpp @@ -0,0 +1,109 @@ +#include "download_add_widget.h" +#include <QComboBox> +#include <QGridLayout> +#include <QVBoxLayout> +#include <QHBoxLayout> +#include <QLabel> +#include <QLineEdit> +#include <QPushButton> +#include <QSpacerItem> +#include <QSpinBox> + +#include "marked_class.h" + +download_add_widget::download_add_widget(std::list<module_info> &modules_, QWidget *parent) : QWidget(parent), modules(modules_) +{ + QGridLayout *l = new QGridLayout(this); + layout_settings = new QGridLayout; //must be created before first entry added to combobox to avoid crash + QLabel *lbl_modules = new QLabel(tr("module:")); + QComboBox *combo_modules = new QComboBox; + connect(combo_modules, SIGNAL(currentIndexChanged(QString)), this, SLOT(combo_modules_currentIndexChanged(QString))); + QHBoxLayout *layout_modules = new QHBoxLayout; + layout_modules->addWidget(lbl_modules); + QSpacerItem *spacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Expanding); + layout_modules->addItem(spacer); + layout_modules->addWidget(combo_modules); + l->addLayout(layout_modules, 0, 0, 1, 3); + for(auto m : modules) + { + if(m.type() == SERVER_MODULE_TYPE::SERVER_MODULE_DOWNLOADER) + combo_modules->addItem(m.name().c_str()); + } + + + l->addLayout(layout_settings, 1, 0, 1, 3); + + spacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Expanding); + l->addItem(spacer, 2, 0, 1, 3); + + + QPushButton *btn_ok = new QPushButton(tr("Ok")), *btn_cancel = new QPushButton(tr("Cancel")); + connect(btn_ok, SIGNAL(clicked(bool)), this, SLOT(btn_ok_clicked())); + connect(btn_cancel, SIGNAL(clicked(bool)), this, SLOT(btn_cancel_clicked())); + QHBoxLayout *layout_buttons = new QHBoxLayout; + layout_buttons->addWidget(btn_ok); + spacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Expanding); + layout_buttons->addItem(spacer); + layout_buttons->addWidget(btn_cancel); + l->addLayout(layout_buttons, 3, 0, 1, 3); + + + + setLayout(l); +} + +void download_add_widget::combo_modules_currentIndexChanged(QString module) +{ + for (QLayoutItem *item = layout_settings->takeAt(0); item != 0; item = layout_settings->takeAt(0)) + delete item; + + int row = 0; + for(auto m : modules) + { + if(m.name().c_str() == module) + { + for(auto ui : m.download_creation_ui()) + { + if(ui.type() == MODULE_UI_ELEMENT_TYPE::UI_STR || ui.type() == MODULE_UI_ELEMENT_TYPE::UI_INTEGER) + { + QLabel *l = new QLabel(ui.name().c_str()); + layout_settings->addWidget(l, row, 0); + QSpacerItem *spacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Expanding); + layout_settings->addItem(spacer, row, 1); + switch(ui.type()) + { + case MODULE_UI_ELEMENT_TYPE::UI_STR: + { + marked_class<QLineEdit> *edit = new marked_class<QLineEdit>; + edit->set_mark(ui.id()); + layout_settings->addWidget(edit, row, 2); + } + break; + case MODULE_UI_ELEMENT_TYPE::UI_INTEGER: + { + marked_class<QSpinBox> *edit = new marked_class<QSpinBox>; + edit->set_mark(ui.id()); + layout_settings->addWidget(edit, row, 2); + } + break; + default: + break; + } + ++row; + } + } + } + } +} + +void download_add_widget::btn_ok_clicked() +{ + +} + +void download_add_widget::btn_cancel_clicked() +{ + close(); + deleteLater(); //? +} + |