Changes to the debian packaging files.
[confmgr] / addprofile.cpp
1 #include "addprofile.h"
2 #include "ui_addprofile.h"
3 #include <QDebug>
4 #include <QMessageBox>
5
6 AddProfile::AddProfile(QWidget *parent) :
7     QWidget(parent),
8     ui(new Ui::AddProfile)
9 {
10     ui->setupUi(this);
11     connect(&mFrmAddStep, SIGNAL(StepAddedSuccessfully(Steps)),
12             this, SLOT(updateStepList(Steps)));
13     mFrmAddStep.setWindowFlags(mFrmAddStep.windowFlags() | Qt::Window);
14 }
15
16 AddProfile::~AddProfile()
17 {
18     delete ui;
19 }
20
21 void AddProfile::on_addProCancel_clicked()
22 {
23     this->close();
24 }
25
26 void AddProfile::on_addProSave_clicked()
27 {
28     Profile p;
29     p.mName = ui->addProName->text();
30     p.mNoOfSteps = ui->addProStepList->count();
31     p.mSteps = mSteps;
32     emit(ProfileAddedSuccessfully(p));
33     this->close();
34 }
35
36 void AddProfile::showStepsUI()
37 {
38     mFrmAddStep.setParent(this, Qt::Window);
39     mFrmAddStep.clear();
40     mFrmAddStep.setAttribute(Qt::WA_Maemo5StackedWindow);
41     mFrmAddStep.show();
42 }
43
44 void AddProfile::updateStepList(Steps step)
45 {
46     mSteps.append(step);
47     QString text = "Value: " + step.value();
48     text += " || Delay: " + QString::number(step.delay());
49     ui->addProStepList->addItem(text);
50     qDebug() << "updateStepList(): Text in List:  " << text;
51 }
52
53 void AddProfile::on_addProRemoveStep_clicked()
54 {
55     if(ui->addProStepList->count() <= 0 || ui->addProStepList->currentRow() < 0)
56     {
57         QMessageBox msg;
58         msg.setText("Please select a step first!");
59         msg.exec();
60         return;
61     }
62
63     mSteps.removeAt(ui->addProStepList->currentRow());
64     QString *pText = (QString*) ui->addProStepList->takeItem(ui->addProStepList->currentRow());
65     delete pText;
66 }
67
68 void AddProfile::clear()
69 {
70     ui->addProStepList->clear();
71     ui->addProName->setText(QString::null);
72 }
73
74 void AddProfile::showProfile(Profile &p)
75 {
76     ui->addProName->setText(p.mName);
77     for(unsigned int i = 0; i < p.mNoOfSteps; i++)
78     {
79         Steps step = p.mSteps.at(i);
80         QString text = "Value: " + step.value();
81         text += " || Delay: " + QString::number(step.delay());
82         ui->addProStepList->addItem(text);
83     }
84     this->show();
85 }