Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
user-client
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
A prog2-höz tartozó friss repo anyagok itt elérhetőek:
https://git.iit.bme.hu/
Commit
a354a4a4
authored
Jun 06, 2017
by
Belákovics Ádám
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace mainwindow.cpp
parent
48592d0a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
85 additions
and
0 deletions
+85
-0
mainwindow.cpp
+85
-0
No files found.
mainwindow.cpp
View file @
a354a4a4
...
@@ -6,9 +6,94 @@ MainWindow::MainWindow(QWidget *parent) :
...
@@ -6,9 +6,94 @@ MainWindow::MainWindow(QWidget *parent) :
ui
(
new
Ui
::
MainWindow
)
ui
(
new
Ui
::
MainWindow
)
{
{
ui
->
setupUi
(
this
);
ui
->
setupUi
(
this
);
ui
->
tabWidget
->
setTabEnabled
(
1
,
false
);
ui
->
tabWidget
->
setTabEnabled
(
2
,
false
);
myController
.
connect
();
}
void
MainWindow
::
addVM
(
std
::
string
id
,
std
::
string
name
){
QListWidgetItem
*
item
=
new
QListWidgetItem
(
ui
->
listWidget
);
ComputeWidget
*
cw
=
new
ComputeWidget
();
cw
->
setID
(
id
);
cw
->
setName
(
name
);
connect
(
cw
,
SIGNAL
(
renew
(
std
::
string
)),
this
,
SLOT
(
renewClicked
(
std
::
string
)));
connect
(
cw
,
SIGNAL
(
start
(
std
::
string
)),
this
,
SLOT
(
startClicked
(
std
::
string
)));
connect
(
cw
,
SIGNAL
(
wakeup
(
std
::
string
)),
this
,
SLOT
(
wakeupClicked
(
std
::
string
)));
connect
(
cw
,
SIGNAL
(
sleep
(
std
::
string
)),
this
,
SLOT
(
sleepClicked
(
std
::
string
)));
item
->
setSizeHint
(
cw
->
minimumSize
());
ui
->
listWidget
->
addItem
(
item
);
ui
->
listWidget
->
setItemWidget
(
item
,
cw
);
}
}
MainWindow
::~
MainWindow
()
MainWindow
::~
MainWindow
()
{
{
delete
ui
;
delete
ui
;
}
}
void
MainWindow
::
loadData
(){
VM_names
=
myController
.
getVMs
();
ui
->
listWidget
->
clear
();
for
(
size_t
i
=
0
;
i
<
VM_names
.
size
();
i
++
)
addVM
(
std
::
to_string
(
i
),
VM_names
.
at
(
i
));
for
(
auto
t
:
getTemplates
(
myController
.
session
))
ui
->
lwTemplates
->
addItem
(
t
.
c_str
());
}
void
MainWindow
::
on_bLogin_clicked
()
{
std
::
string
username
=
ui
->
iUsername
->
text
().
toStdString
();
std
::
string
password
=
ui
->
iPassword
->
text
().
toStdString
();
if
(
!
myController
.
login
(
username
,
password
)){
ui
->
lInfo
->
setText
(
"Invalid username or password..."
);
return
;
}
ui
->
tabWidget
->
setTabEnabled
(
1
,
true
);
ui
->
tabWidget
->
setTabEnabled
(
2
,
true
);
loadData
();
ui
->
tabWidget
->
setCurrentIndex
(
1
);
}
void
MainWindow
::
renewClicked
(
std
::
string
id
){
myController
.
renewByID
(
id
);
}
void
MainWindow
::
startClicked
(
std
::
string
id
){
myController
.
startByID
(
id
);
}
void
MainWindow
::
wakeupClicked
(
std
::
string
id
){
myController
.
wakeupByID
(
id
);
}
void
MainWindow
::
sleepClicked
(
std
::
string
id
){
myController
.
sleepByID
(
id
);
}
void
MainWindow
::
on_listWidget_clicked
(
const
QModelIndex
&
index
)
{
ui
->
lStatus
->
setText
(
myController
.
getState
(
std
::
to_string
(
index
.
row
())).
c_str
());
ComputeData
data
=
myController
.
getDataByID
(
std
::
to_string
(
index
.
row
()).
c_str
());
ui
->
lCPU
->
setText
(
std
::
to_string
(
data
.
cpu
).
c_str
());
ui
->
lMemory
->
setText
(
std
::
to_string
(
data
.
memory
).
c_str
());
ui
->
lCores
->
setText
(
std
::
to_string
(
data
.
cores
).
c_str
());
ui
->
lHostname
->
setText
((
data
.
hostname
+
":21231"
).
c_str
());
//TODO
ui
->
lUsername
->
setText
(
data
.
username
.
c_str
());
ui
->
lPassword
->
setText
(
data
.
password
.
c_str
());
}
void
MainWindow
::
on_bRefresh_clicked
()
{
myController
.
refresh
();
loadData
();
}
void
MainWindow
::
receive_chosen_template
(
Template
t
){
myController
.
newCompute
(
t
);
}
void
MainWindow
::
on_bNewVM_clicked
()
{
VMChooserDialog
*
v
=
new
VMChooserDialog
(
this
);
emit
send_templates
(
getTemplates
(
myController
.
session
));
connect
(
v
,
SIGNAL
(
send_chosen_template
(
Template
)),
this
,
SLOT
(
receive_chosen_template
(
Template
)));
v
->
exec
();
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment