summaryrefslogtreecommitdiff
path: root/client-qt/udm-client-qt/download_add_widget.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'client-qt/udm-client-qt/download_add_widget.cpp')
-rw-r--r--client-qt/udm-client-qt/download_add_widget.cpp109
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(); //?
+}
+