1 #include "mainwindow.h"
2 #include "ui_mainwindow.h"
7 MainWindow::MainWindow(QWidget *parent) :
12 connect(&mFrmAddProfile, SIGNAL(ProfileAddedSuccessfully(Profile)),
13 this, SLOT(updateProfileList(Profile)));
17 MainWindow::~MainWindow()
19 mConfig.writeAllProfiles();
20 mConfig.closeConfig();
24 void MainWindow::Initialize()
27 for(int i = 0; i < mConfig.getNoOfProfiles(); i++)
29 Profile p = mConfig.profileList.at(i);
30 QString text = "Name: " + p.mName + " || Steps: " + QString::number(p.mNoOfSteps);
31 ui->mainProfileList->addItem(text);
33 ui->centralWidget->setAttribute(Qt::WA_Maemo5StackedWindow);
34 mFrmAddProfile.setWindowFlags(mFrmAddProfile.windowFlags() | Qt::Window);
37 void MainWindow::on_mainPBAdd_clicked()
39 bIsProfileEdited = false;
40 mFrmAddProfile.setParent(this, Qt::Window);
41 mFrmAddProfile.clear();
42 mFrmAddProfile.setAttribute(Qt::WA_Maemo5StackedWindow);
43 mFrmAddProfile.show();
46 void MainWindow::updateProfileList(Profile p)
50 // Delete previous profile and write this new one
51 QString *pText = (QString *) ui->mainProfileList->takeItem(ui->mainProfileList->currentRow());
53 mConfig.removeProfile(p);
55 qDebug() << Xmlutil::generateProfileXML(p);
56 mConfig.addProfile(p);
57 QString text = "Name: " + p.mName + " || Steps: " + QString::number(p.mNoOfSteps);
58 ui->mainProfileList->addItem(text);
61 void MainWindow::on_mainPBDelete_clicked()
63 if(ui->mainProfileList->count() <= 0 || ui->mainProfileList->currentRow() < 0)
66 msg.setText("Please select a profile first!");
71 Profile p = mConfig.profileList.at(ui->mainProfileList->currentRow());
72 qDebug() << "Profile to be deleted: " << endl << Xmlutil::generateProfileXML(p);
73 QString *pText = (QString *) ui->mainProfileList->takeItem(ui->mainProfileList->currentRow());
75 mConfig.removeProfile(p);
78 void MainWindow::on_btnmainStartConference_clicked()
80 if(ui->mainProfileList->count() <= 0 || ui->mainProfileList->currentRow() < 0)
83 msg.setText("Please select a profile first!");
87 Profile p = mConfig.profileList.at(ui->mainProfileList->currentRow());
88 qDebug() << "Profile To Dial: " << endl << Xmlutil::generateProfileXML(p);
89 mConfMgr.setProfile(p);
90 mConfMgr.startConference();
93 void MainWindow::on_mainPBEditProfile_clicked()
95 if(ui->mainProfileList->count() <= 0 || ui->mainProfileList->currentRow() < 0)
98 msg.setText("Please select a profile first!");
102 bIsProfileEdited = true;
103 Profile p = mConfig.profileList.at(ui->mainProfileList->currentRow());
104 qDebug() << "Profile to be Edited: " << endl << Xmlutil::generateProfileXML(p);
105 mFrmAddProfile.setParent(this, Qt::Window);
106 mFrmAddProfile.setAttribute(Qt::WA_Maemo5StackedWindow);
107 mFrmAddProfile.clear();
108 mFrmAddProfile.showProfile(p);
111 void MainWindow::on_mainPBAbout_clicked()
114 msg.setText("A nice screen yet to be implemented!");
119 void MainWindow::on_mainPBQuit_clicked()
121 mConfig.writeAllProfiles();
122 mConfig.closeConfig();