00001
00012
00013
00014 #include <QLabel>
00015 #include <QString>
00016 #include <QHBoxLayout>
00017 #include <QVBoxLayout>
00018 #include <QPushButton>
00019
00020
00021 #include "choose_datasets_dialog.h"
00022
00023
00024 namespace imedgine {
00025
00026
00027
00028 ChooseDatasetsDialog::ChooseDatasetsDialog(QWidget* parent,
00029 dataset_key_container_type loaded_datasets)
00030 : QDialog(parent)
00031 {
00032 dataset_key_container_type::iterator dataset_name_iterator = loaded_datasets.begin();
00033
00034
00035 QVBoxLayout* vertical_layout = new QVBoxLayout(this);
00036
00037 while(dataset_name_iterator != loaded_datasets.end())
00038 {
00039 QCheckBox* temp_check_box = new QCheckBox();
00040
00041 QString temp_string = temp_string.fromStdString(*dataset_name_iterator);
00042 temp_check_box->setText(temp_string);
00043
00044 vertical_layout->addWidget(temp_check_box);
00045
00046 dataset_checkbox_map_.insert(std::make_pair(temp_check_box, *dataset_name_iterator));
00047 dataset_name_iterator++;
00048 }
00049
00050 QHBoxLayout* button_layout = new QHBoxLayout();
00051
00052 cancel_push_button_ = new QPushButton();
00053 cancel_push_button_->setText(tr("Cancel"));
00054
00055 ok_push_button_ = new QPushButton();
00056 ok_push_button_->setText(tr("OK"));
00057
00058 button_layout->addWidget(cancel_push_button_);
00059 button_layout->addWidget(ok_push_button_);
00060
00061 vertical_layout->addLayout(button_layout);
00062
00063 connect(ok_push_button_, SIGNAL(clicked()),
00064 this, SLOT(datasetSelectionDone()));
00065
00066 connect(cancel_push_button_, SIGNAL(clicked()),
00067 this, SLOT(reject()));
00068 }
00069
00070
00071
00072 ChooseDatasetsDialog::~ChooseDatasetsDialog()
00073 {
00074 }
00075
00076
00077
00078 dataset_key_container_type ChooseDatasetsDialog::getDatasetsToSave()
00079 {
00080 return(datasets_to_save_);
00081 }
00082
00083
00084
00085 void ChooseDatasetsDialog::datasetSelectionDone()
00086 {
00087 dataset_checkbox_type::iterator checkbox_iterator = dataset_checkbox_map_.begin();
00088
00089 while(checkbox_iterator != dataset_checkbox_map_.end())
00090 {
00091 if((*checkbox_iterator).first->isChecked())
00092 {
00093 datasets_to_save_.push_back((*checkbox_iterator).second);
00094 }
00095 checkbox_iterator++;
00096 }
00097 this->accept();
00098 }
00099 }