summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSimon Rettberg2017-03-31 12:24:01 +0200
committerSimon Rettberg2017-03-31 12:24:01 +0200
commitaeffac3139c13270c97d1ef85576ac1a7f7902a6 (patch)
tree8334af7adafc7279ff9f6631f64548bd1dd5eb73 /src
parentImplement --pvs option (diff)
downloadvmchooser2-aeffac3139c13270c97d1ef85576ac1a7f7902a6.tar.gz
vmchooser2-aeffac3139c13270c97d1ef85576ac1a7f7902a6.tar.xz
vmchooser2-aeffac3139c13270c97d1ef85576ac1a7f7902a6.zip
Add support for <can_edit> XML entry
Diffstat (limited to 'src')
-rw-r--r--src/dialog.cpp13
-rw-r--r--src/vsession.h5
2 files changed, 18 insertions, 0 deletions
diff --git a/src/dialog.cpp b/src/dialog.cpp
index 8c316b5..2fa629a 100644
--- a/src/dialog.cpp
+++ b/src/dialog.cpp
@@ -84,6 +84,7 @@ Dialog::Dialog(int defaultTab, bool examMode, QWidget *parent)
//ui->tabButtonAllClasses->setChecked(true);
ui->chkAdminMode->setVisible(g_allowVmEdit);
+ ui->chkAdminMode->setEnabled(false);
// TODO: Implement bug report dialog :)
ui->buttonBugReport->setEnabled(false);
@@ -447,6 +448,16 @@ void Dialog::addSessionsAfterDownload(QNetworkReply* reply) {
qSort(sessions.begin(), sessions.end(), myLessThan);
this->addItems(sessions, TAB_ALL_VMS);
// TODO: Filter user's classes and add to tab[TAB_MY_COURSES]
+ bool showEdit = false;
+ for (QList<Session*>::const_iterator it = sessions.begin(); it != sessions.end(); ++it) {
+ if (((VSession*)(*it))->canEdit()) {
+ showEdit = true;
+ break;
+ }
+ }
+ if (showEdit) {
+ ui->chkAdminMode->setVisible(true);
+ }
} else {
this->addStatusString(STR_NO_ITEMS);
}
@@ -489,6 +500,8 @@ void Dialog::treeView_selectionChanged(const QModelIndex& current, const QModelI
ui->label_platform->setText(vs->getAttribute("virtualizer_name", "param"));
ui->label_platform->setToolTip(vs->getAttribute("virtualizer_name", "param"));
+ ui->chkAdminMode->setEnabled(vs->canEdit());
+
if (vs->keywords().length() > 0) {
description = "\n\nKeywords: ";
for (int i = 0; i < vs->keywords().length(); ++i) {
diff --git a/src/vsession.h b/src/vsession.h
index 2b00206..2ded3ae 100644
--- a/src/vsession.h
+++ b/src/vsession.h
@@ -23,6 +23,7 @@ class VSession : public Session {
bool isActive() const;
bool isLocked() const;
bool isValid() const;
+
int priority() const;
bool isTemplate() const {
@@ -33,6 +34,10 @@ class VSession : public Session {
return getAttribute("for_location").toInt() != 0;
}
+ bool canEdit() const {
+ return getAttribute("allow_edit").toInt() != 0;
+ }
+
QString shortDescription() const {
return getAttribute("short_description");
}