Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "QmitkLoadPresetDialog.h"
00019
00020 #include <qlineedit.h>
00021 #include <qpushbutton.h>
00022 #include <qlayout.h>
00023 #include <qlabel.h>
00024
00025 QmitkLoadPresetDialog::QmitkLoadPresetDialog(QWidget* parent, Qt::WindowFlags f, const char* name, std::list<std::string> presets)
00026 :QDialog(parent, f)
00027 {
00028 QDialog::setMinimumSize(250, 300);
00029 this->setObjectName(name);
00030
00031 QBoxLayout * verticalLayout = new QVBoxLayout( this );
00032 verticalLayout->setMargin(5);
00033 verticalLayout->setSpacing(5);
00034
00035
00036 lblPrompt = new QLabel( "Which preset do you want to load?", this );
00037 verticalLayout->addWidget( lblPrompt );
00038 lstPresets = new QListWidget( this );
00039 verticalLayout->addWidget( lstPresets );
00040
00041 std::list<std::string>::iterator iter;
00042 for( iter = presets.begin(); iter != presets.end(); iter++ )
00043 {
00044 std::string preset = *iter;
00045 new QListWidgetItem(preset.c_str(), lstPresets);
00046 }
00047
00048 lstPresets->setCurrentItem(0);
00049
00050 connect( lstPresets, SIGNAL(itemDoubleClicked (QListWidgetItem *)), this, SLOT(onPresetImmediatelySelected(QListWidgetItem *)) );
00051
00052
00053 btnOk = new QPushButton( tr("Ok"), this);
00054 btnOk->setObjectName("btnOk" );
00055 btnOk->setDefault(true);
00056 connect( btnOk, SIGNAL(clicked()), this, SLOT(accept()) );
00057
00058 QPushButton* btnCancel = new QPushButton( tr("Cancel"), this);
00059 btnCancel->setObjectName("btnCancel" );
00060 connect( btnCancel, SIGNAL(clicked()), this, SLOT(reject()) );
00061
00062 QWidget* buttonWidget = new QWidget(this);
00063 QBoxLayout * horizontalLayout = new QHBoxLayout( buttonWidget );
00064 horizontalLayout->setSpacing(5);
00065 horizontalLayout->addStretch();
00066 horizontalLayout->addWidget( btnOk );
00067 horizontalLayout->addWidget( btnCancel );
00068 verticalLayout->addWidget(buttonWidget);
00069 }
00070
00071 QmitkLoadPresetDialog::~QmitkLoadPresetDialog()
00072 {
00073 }
00074
00075 std::string QmitkLoadPresetDialog::GetPresetName()
00076 {
00077 std::string presetName = std::string(lstPresets->currentItem()->text().toAscii());
00078 return presetName;
00079 }
00080
00081 void QmitkLoadPresetDialog::onPresetImmediatelySelected(QListWidgetItem * )
00082 {
00083 if ( (signed)(lstPresets->row(lstPresets->currentItem())) != (signed)(lstPresets->count()-1) )
00084 {
00085 accept();
00086 }
00087 else
00088 {
00089
00090 }
00091 }
00092