1 #include "mainwindow.h"
2 #include "ui_mainwindow.h"
4 #include "aboutdialog.h"
8 MainWindow::MainWindow(QWidget *parent) :
10 ui(new Ui::MainWindow)
13 connect(&mFrmAddProfile, SIGNAL(ProfileAddedSuccessfully(Profile)),
14 this, SLOT(updateProfileList(Profile)));
16 connect(&ui->mainMenuAbout, SIGNAL(Triggered(QAction*)),
17 this, SLOT(mainAboutClickedSlot()));
22 MainWindow::~MainWindow()
24 mConfig.writeAllProfiles();
25 mConfig.closeConfig();
29 void MainWindow::Initialize()
32 for(int i = 0; i < mConfig.getNoOfProfiles(); i++)
34 Profile p = mConfig.profileList.at(i);
35 QString text = "Name: " + p.mName + " || Steps: " + QString::number(p.mNoOfSteps);
36 ui->mainProfileList->addItem(text);
38 ui->centralWidget->setAttribute(Qt::WA_Maemo5StackedWindow);
39 mFrmAddProfile.setWindowFlags(mFrmAddProfile.windowFlags() | Qt::Window);
42 void MainWindow::on_mainPBAdd_clicked()
44 bIsProfileEdited = false;
45 mFrmAddProfile.setParent(this, Qt::Window);
46 mFrmAddProfile.clear();
47 mFrmAddProfile.setAttribute(Qt::WA_Maemo5StackedWindow);
48 mFrmAddProfile.show();
51 void MainWindow::updateProfileList(Profile p)
55 // Delete previous profile and write this new one
56 QString *pText = (QString *) ui->mainProfileList->takeItem(ui->mainProfileList->currentRow());
58 mConfig.removeProfile(p);
60 qDebug() << Xmlutil::generateProfileXML(p);
61 mConfig.addProfile(p);
62 QString text = "Name: " + p.mName + " || Steps: " + QString::number(p.mNoOfSteps);
63 ui->mainProfileList->addItem(text);
66 void MainWindow::on_mainPBDelete_clicked()
68 if(ui->mainProfileList->count() <= 0 || ui->mainProfileList->currentRow() < 0)
71 msg.setText("Please select a profile first!");
76 Profile p = mConfig.profileList.at(ui->mainProfileList->currentRow());
77 qDebug() << "Profile to be deleted: " << endl << Xmlutil::generateProfileXML(p);
78 QString *pText = (QString *) ui->mainProfileList->takeItem(ui->mainProfileList->currentRow());
80 mConfig.removeProfile(p);
83 void MainWindow::on_btnmainStartConference_clicked()
85 if(ui->mainProfileList->count() <= 0 || ui->mainProfileList->currentRow() < 0)
88 msg.setText("Please select a profile first!");
92 Profile p = mConfig.profileList.at(ui->mainProfileList->currentRow());
93 qDebug() << "Profile To Dial: " << endl << Xmlutil::generateProfileXML(p);
94 mConfMgr.setProfile(p);
95 mConfMgr.startConference();
98 void MainWindow::on_mainPBEditProfile_clicked()
100 if(ui->mainProfileList->count() <= 0 || ui->mainProfileList->currentRow() < 0)
103 msg.setText("Please select a profile first!");
107 bIsProfileEdited = true;
108 Profile p = mConfig.profileList.at(ui->mainProfileList->currentRow());
109 qDebug() << "Profile to be Edited: " << endl << Xmlutil::generateProfileXML(p);
110 mFrmAddProfile.setParent(this, Qt::Window);
111 mFrmAddProfile.setAttribute(Qt::WA_Maemo5StackedWindow);
112 mFrmAddProfile.clear();
113 mFrmAddProfile.showProfile(p);
116 void MainWindow::on_mainPBQuit_clicked()
118 mConfig.writeAllProfiles();
119 mConfig.closeConfig();
123 void MainWindow::on_actionAbout_triggered()
129 void MainWindow::on_actionAdd_Templated_Profile_triggered()
132 msg.setText("Placeholder for a nice function yet to be implemented!");