SpikeStream Application Library
0.2
|
00001 //SpikeStream includes 00002 #include "DescriptionDialog.h" 00003 using namespace spikestream; 00004 00005 //Qt includes 00006 #include <QDebug> 00007 #include <QLabel> 00008 #include <QLayout> 00009 #include <QPushButton> 00010 00011 00013 DescriptionDialog::DescriptionDialog(const QString& description, QWidget* parent) : QDialog(parent){ 00014 buildGUI(description); 00015 } 00016 00017 00019 DescriptionDialog::~DescriptionDialog(){ 00020 } 00021 00022 00024 QString DescriptionDialog::getDescription(){ 00025 QString descStr = descLineEdit->text(); 00026 if(descStr.isEmpty()) 00027 descStr = "Undescribed"; 00028 return descStr; 00029 } 00030 00031 00032 /*----------------------------------------------------------*/ 00033 /*----- PRIVATE SLOTS -----*/ 00034 /*----------------------------------------------------------*/ 00035 00037 void DescriptionDialog::cancelButtonPressed(){ 00038 this->reject(); 00039 } 00040 00041 00043 void DescriptionDialog::okButtonPressed(){ 00044 this->accept(); 00045 } 00046 00047 00048 /*----------------------------------------------------------*/ 00049 /*----- PRIVATE METHODS -----*/ 00050 /*----------------------------------------------------------*/ 00051 00053 void DescriptionDialog::buildGUI(const QString& description){ 00054 //Create layout managers 00055 QVBoxLayout* mainVBox = new QVBoxLayout(this); 00056 QGridLayout* gridLayout = new QGridLayout(); 00057 gridLayout->setMargin(10); 00058 00059 //Field to enter description 00060 gridLayout->addWidget(new QLabel("Description: "), 0, 0); 00061 descLineEdit = new QLineEdit(description); 00062 descLineEdit->setMinimumSize(250, 30); 00063 gridLayout->addWidget(descLineEdit, 0, 1); 00064 00065 mainVBox->addLayout(gridLayout); 00066 00067 //Add buttons 00068 QHBoxLayout* buttonBox = new QHBoxLayout(); 00069 QPushButton* okButton = new QPushButton("Ok"); 00070 connect(okButton, SIGNAL(clicked()), this, SLOT(okButtonPressed())); 00071 buttonBox->addWidget(okButton); 00072 QPushButton* cancelButton = new QPushButton("Cancel"); 00073 connect(cancelButton, SIGNAL(clicked()), this, SLOT(cancelButtonPressed())); 00074 buttonBox->addWidget(cancelButton); 00075 mainVBox->addLayout(buttonBox); 00076 } 00077