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