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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
#include <QtGui>
#include "partmansel.h"
#include "../listdelegate.h"
#include "../listitem.h"
wpPartManSel::wpPartManSel(QWidget *parent) : QWizardPage(parent)
{
setupUi(this);
backend = Backend::instance();
connect(backend, SIGNAL(receivedDataLine(QString,QString)), this, SLOT(receivedDataLine(QString,QString)));
connect(partMan, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), this, SLOT(updateComplete()));
connect(partDisk, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), this, SLOT(updateComplete()));
partMan->setItemDelegate(new ListDelegate(this));
}
void wpPartManSel::initializePage()
{
clearPage();
}
void wpPartManSel::clearPage()
{
backend->exec("send_partition_managers");
partMan->clear();
backend->exec("send_list_of_disks");
partDisk->clear();
}
void wpPartManSel::receivedDataLine(QString data, QString line)
{
if(data == "partition_managers")
{
QString app = line.section(" ",0,0);
QString title, desc, icon;
if(app == "cfdisk")
{
title = tr("cfdisk");
desc = tr("cfdisk is a curses-based partition editor. It is text-only (curses), but it is easy to use [recommended]");
icon = "terminal";
}
else if(app == "fdisk")
{
title = tr("fdisk");
desc = tr("fdisk is a classic partition table manipulator for Linux. It has a Command Line Interface.");
icon = "terminal";
}
else if(app == "gparted")
{
title = tr("GParted");
desc = tr("GParted is the Gnome Partition Editor application. It has a Graphical User Interface.");
icon = "gparted";
}
else if(app == "qtparted")
{
title = tr("QtParted");
desc = tr("QTParted is a Partition Magic clone, so it has a GUI. Sometimes it's a bit buggy, so it is not recommended to use for huge changes on the partition table.");
icon = "qtparted";
}
else
{
title = app;
desc = tr("No description available...");
icon = "partitionmanager";
}
QListWidgetItem *item = new ListItem(title, desc, icon, app);
partMan->addItem(item);
}
if(data == "list_of_disks")
{
QListWidgetItem *item = new QListWidgetItem(QIcon::fromTheme("drive-harddisk"), line);
partDisk->addItem(item);
}
}
void wpPartManSel::updateComplete()
{
emit completeChanged();
}
bool wpPartManSel::isComplete() const
{
if(!partMan->currentItem()) return false;
if(!partDisk->currentItem()) return false;
return true;
}
bool wpPartManSel::validatePage()
{
if(!isComplete()) return false;
backend->cfg("partman_program", partMan->currentItem()->data(ListItem::ItemData).toString());
backend->cfg("partman_disk", partDisk->currentItem()->text().section(" ",0,0));
return true;
}
|