Commit 00ea82be by Belákovics Ádám

changed template handling

parent a7659a8f
......@@ -24,6 +24,7 @@ bool Controller::login(std::string username, std::string password){
refresh(); //initialize data
return true;
}
OcciClient::Template::getTemplates(session);
return false;
}
......@@ -34,8 +35,9 @@ void Controller::refresh(){
allCompute.clear();
for(auto c : OcciClient::Compute::getComputeInstances(session))
allCompute.push_back(c);
OcciClient::Template::getTemplates(session); //test
allTemplate.clear();
for (auto t : OcciClient::getTemplates(session))
for (auto t : OcciClient::Template::getTemplates(session))
allTemplate.push_back(t);
}
......@@ -62,7 +64,7 @@ std::vector<std::string> Controller::getVMs(){
std::vector<std::string> Controller::getTemplates(){
std::vector<std::string> templates;
for(auto t : allTemplate){
templates.push_back(t);
templates.push_back(t->getTitle().c_str());
}
return templates;
}
......@@ -157,7 +159,7 @@ void Controller::sleepByID(std::string id){
* \brief Creates a new Compute by the Template
* \param id
*/
void Controller::newCompute(Template t){
OcciClient::Compute::createComputeInstance(session, t);
void Controller::newCompute(std::shared_ptr<OcciClient::Template> t){
OcciClient::Compute::createComputeInstance(session, t.get());
refresh();
}
......@@ -12,7 +12,7 @@ class Controller
public:
OcciClient::OcciSession* session;
std::vector<std::shared_ptr<OcciClient::Compute> > allCompute;
std::vector<Template> allTemplate;
std::vector<std::shared_ptr<OcciClient::Template> > allTemplate;
bool connect(std::string url);
......@@ -30,7 +30,7 @@ public:
void sleepByID(std::string id);
void newCompute(Template);
void newCompute(std::shared_ptr<OcciClient::Template>);
ComputeData getDataByID(std::string id);
......
libocci @ f6d8d3ae
Subproject commit 30b4a5c111538425007e4721c91c66ed0e73424d
Subproject commit f6d8d3aefac88d17c95d4aecbbfb76d7f71c8612
......@@ -229,8 +229,8 @@ void MainWindow::on_bNewVM_clicked()
{
VMChooserDialog* v = new VMChooserDialog(this);
v->setWindowTitle("New Virtual Machine");
v->set_templates(getTemplates(myController.session));
connect(v, SIGNAL(send_chosen_template(Template)), this, SLOT(receive_chosen_template(Template)));
v->set_templates(OcciClient::Template::getTemplates(myController.session));
connect(v, SIGNAL(send_chosen_template(OcciClient::Template)), this, SLOT(receive_chosen_template(OcciClient::Template)));
v->exec();
}
......@@ -238,7 +238,7 @@ void MainWindow::on_bNewVM_clicked()
* \brief Slot for dialog, creates new VM by the chosen template
* \param t
*/
void MainWindow::receive_chosen_template(Template t){
void MainWindow::receive_chosen_template(std::shared_ptr<OcciClient::Template> t){
myController.newCompute(t);
loadAllData();
}
......
......@@ -40,7 +40,7 @@ private slots:
void startshutdownClicked(std::string);
void wakeupsleepClicked(std::string);
void receive_chosen_template(Template);
void receive_chosen_template(std::shared_ptr<OcciClient::Template>);
void on_listWidget_clicked(const QModelIndex &index);
......
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>691</width>
<height>471</height>
<width>1064</width>
<height>514</height>
</rect>
</property>
<property name="palette">
......@@ -95,7 +95,7 @@
<enum>QTabWidget::Rounded</enum>
</property>
<property name="currentIndex">
<number>0</number>
<number>2</number>
</property>
<property name="iconSize">
<size>
......@@ -857,7 +857,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>691</width>
<width>1064</width>
<height>19</height>
</rect>
</property>
......
......@@ -21,10 +21,10 @@ void VMChooserDialog::on_buttonBox_rejected()
this->done(-1);
}
void VMChooserDialog::set_templates(std::vector<Template> _templates){
void VMChooserDialog::set_templates(std::vector<std::shared_ptr<OcciClient::Template> > _templates){
templates = _templates;
for(auto t : templates){
ui->lwTemplates->addItem(QString::fromUtf8(t.c_str()));
ui->lwTemplates->addItem(QString::fromUtf8(t->getTitle().c_str()));
}
}
......
......@@ -12,11 +12,11 @@ class VMChooserDialog : public QDialog
Q_OBJECT
public:
explicit VMChooserDialog(QWidget *parent = 0);
void set_templates(std::vector<Template> templates);
void set_templates(std::vector<std::shared_ptr<OcciClient::Template> > templates);
~VMChooserDialog();
signals:
void send_chosen_template(Template);
void send_chosen_template(std::shared_ptr<OcciClient::Template>);
private slots:
......@@ -26,7 +26,7 @@ private slots:
private:
Ui::VMChooserDialog* ui;
std::vector<Template> templates;
std::vector<std::shared_ptr<OcciClient::Template> > templates;
};
#endif // VMCHOOSERDIALOG_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment