summaryrefslogtreecommitdiff
path: root/wizard/bootloader.cpp
blob: a066d05056adef917c2a966f78b73e2e84248910 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include <QtGui>
#include "bootloader.h"
#include "../listdelegate.h"
#include "../listitem.h"

wpBootloader::wpBootloader(QWidget *parent) : QWizardPage(parent)
{
  setupUi(this);
  backend = Backend::instance();
  connect(backend, SIGNAL(receivedDataLine(QString,QString)), this, SLOT(receivedDataLine(QString,QString)));
  connect(backend, SIGNAL(finishedCommand(QString)), this, SLOT(backendFinishedCommand(QString)));
  connect(bootloader, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), this, SLOT(updateComplete()));
  connect(bootloaderTarget, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), this, SLOT(updateComplete()));
  //bootloader->setItemDelegate(new ListDelegate(this));
}

void wpBootloader::initializePage()
{
  clearPage();
}

void wpBootloader::clearPage()
{
  backend->exec("send_bootloaders");
  bootloader->clear();
  backend->exec("send_bootloader_targets");
  bootloaderTarget->clear();
}

void wpBootloader::receivedDataLine(QString data, QString line)
{
  if(data == "bootloaders")
  {
    QListWidgetItem *item = new QListWidgetItem(QIcon::fromTheme("system-run"), line);
    bootloader->addItem(item);
  }
  if(data == "bootloader_targets")
  {
    QListWidgetItem *item = new QListWidgetItem(QIcon::fromTheme("drive-harddisk"), line);
    bootloaderTarget->addItem(item);
  }
}

void wpBootloader::backendFinishedCommand(QString command)
{
  if(command == "send_bootloaders")
  {
    bootloader->setCurrentRow(0);
  }
  if(command == "send_bootloader_targets")
  {
    bootloaderTarget->setCurrentRow(0);
  }
}

void wpBootloader::updateComplete()
{
  emit completeChanged();
}

bool wpBootloader::isComplete() const
{
  if(!bootloader->currentItem()) return false;
  if(!bootloaderTarget->currentItem()) return false;
  return true;
}

bool wpBootloader::validatePage()
{
  if(!isComplete()) return false;
  backend->cfg("bootloader", bootloader->currentItem()->text().section(" ",0,0).toLower());
  backend->cfg("bootloader_target", bootloaderTarget->currentItem()->text().section(" ",0,0).toLower());
  return true;
}