add some comments
[makneto-zunavac1.git] / src / ui-kde / plugins / pollplugincreate.cpp
blob1f13ba081ed9d8004cbd1f9d60a9bdea18538015
1 #include "pollplugincreate.h"
3 #include <QtGui/QGridLayout>
4 #include <QtGui/QLabel>
5 #include <QtGui/QLineEdit>
6 #include <QtGui/QPushButton>
7 #include <QtGui/QDialogButtonBox>
8 #include <QtCore/QMap>
10 PollPluginCreate::PollPluginCreate()
12 QVBoxLayout *topLayout = new QVBoxLayout(this);
13 layout = new QGridLayout(0);
14 topLayout->addLayout(layout);
16 addLine();
18 addButton = new QPushButton("Add question", this);
19 layout->addWidget(addButton, 0, 2);
20 connect(addButton, SIGNAL(pressed()), this, SLOT(addQuestion()));
22 QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this);
23 topLayout->addWidget(buttonBox);
24 connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
25 connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
28 QMap<int, QString> PollPluginCreate::getQuestions()
30 QMap<int, QString> l;
31 for (int i = 0; i < questions.size(); i++)
33 l.insert(i, questions[i]->text());
35 return l;
38 void PollPluginCreate::addLine()
40 int row = questions.size();
41 QLabel *label = new QLabel(QString("Question #%1").arg(row + 1), this);
42 layout->addWidget(label, row, 0);
43 QLineEdit *question = new QLineEdit(this);
44 layout->addWidget(question, row, 1);
45 label->setBuddy(question);
46 questions << question;
49 void PollPluginCreate::addQuestion()
51 layout->removeWidget(addButton);
52 addLine();
53 layout->addWidget(addButton, questions.size() - 1, 2);