summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Loibl <andreas@andreas-loibl.de>2011-10-02 22:16:11 +0200
committerAndreas Loibl <andreas@andreas-loibl.de>2011-10-02 22:16:11 +0200
commitecb5cc2be5527e84ae29239ec8fa789c3ee8587e (patch)
tree4c7c59827ea325c1999daa9160877b764c079756
parent17dd2d0281bf750768bb9820a677806980380c10 (diff)
downloadacritoxinstaller-ecb5cc2be5527e84ae29239ec8fa789c3ee8587e.zip
acritoxinstaller-ecb5cc2be5527e84ae29239ec8fa789c3ee8587e.tar.gz
use ListItems with formatted size info in frontend
-rw-r--r--backend.cpp14
-rw-r--r--backend.h1
-rw-r--r--backend/modules/bootloader10
-rw-r--r--backend/modules/partitions10
-rw-r--r--wizard/bootloader.cpp10
-rw-r--r--wizard/partmansel.cpp8
-rw-r--r--wizard/rootpartition.cpp9
7 files changed, 45 insertions, 17 deletions
diff --git a/backend.cpp b/backend.cpp
index 7580d19..977aaac 100644
--- a/backend.cpp
+++ b/backend.cpp
@@ -2,6 +2,7 @@
#include <QDebug>
#include <QTime>
#include <stdlib.h>
+#include <math.h>
#include "config.h"
Backend* Backend::_instance;
@@ -231,6 +232,19 @@ QString Backend::cleanUsername(const QString &username)
return result.replace(QRegExp("[^a-zA-Z0-9-_.]"), "");
}
+QString Backend::sizeToString(qlonglong size)
+{
+ float fSize = size;
+ int i = 0;
+ const char* units[] = {"B", "kB", "MB", "GB", "TB"};
+ while (fSize > 1024) {
+ fSize /= 1024.0;
+ i++;
+ }
+ fSize = round((fSize)*100)/100;
+ return QString::number(fSize)+" "+ units[i];
+}
+
void Backend::slotProcessExited()
{
emit processExited();
diff --git a/backend.h b/backend.h
index 997b580..c7d3313 100644
--- a/backend.h
+++ b/backend.h
@@ -19,6 +19,7 @@ public:
void exitBackend();
QString encryptPassword(QString password);
QString cleanUsername(const QString &username);
+ QString sizeToString(qlonglong size);
bool isBusy();
bool flag(QString flag);
void flag(QString flag, bool set);
diff --git a/backend/modules/bootloader b/backend/modules/bootloader
index 3621341..2180873 100644
--- a/backend/modules/bootloader
+++ b/backend/modules/bootloader
@@ -4,14 +4,14 @@
#
# This function lists all disks and the root-partition if it is suitable to install a bootloader on it.
# Output example:
-# /dev/sda:MBR:250059350016
-# /dev/sdb:MBR:400088457216
-# /dev/sdb1:Rootpartition:60003385344
+# /dev/sda 250059350016 Master Boot Record
+# /dev/sdb 400088457216 Master Boot Record
+# /dev/sdb1 60003385344 Rootpartition (filesysem ext4)
function list_bootloader_targets()
{
for disk in $(list_all_disks)
do
- echo "$disk - MBR $(blockdev --getsize64 $disk)"
+ echo "$disk $(blockdev --getsize64 $disk) Master Boot Record"
done
root_dev="$(hdmap_get device of mountpoint /)"
root_fs="$(hdmap_get filesystem of mountpoint /)"
@@ -19,7 +19,7 @@ function list_bootloader_targets()
case $root_fs in
reiserfs|ext2|ext3|ext4)
list_linux_partitions | grep -q "^$root_dev$" &&
- echo "$root_dev - Rootpartition $(blockdev --getsize64 $root_dev)"
+ echo "$root_dev $(blockdev --getsize64 $root_dev) Rootpartition (filesystem $root_fs)"
;;
esac
}
diff --git a/backend/modules/partitions b/backend/modules/partitions
index 211fdba..a64306a 100644
--- a/backend/modules/partitions
+++ b/backend/modules/partitions
@@ -93,7 +93,7 @@ function partitions_size_details()
while read part x
do
[ -e "$part" ] || continue
- echo "$part $(blockdev --getsize64 "$part")"
+ echo "$part $(blockdev --getsize64 "$part") $x"
done
}
@@ -229,15 +229,15 @@ function list_possible_root_partitions()
# Synopsis: send_possible_root_partitions
#
-# This script sends a list of all possible root-partitions with size-details to the frontend.
+# This script sends a list of all possible root-partitions with size- and usage-details to the frontend.
# Output example:
# <installer data> possible_root_partitions
-# /dev/sda4 10001908224
-# /dev/sdb1 64023257088
+# /dev/sda4 10001908224 filesystem ext3
+# /dev/sdb1 64023257088
function send_possible_root_partitions()
{
send data possible_root_partitions
- list_possible_root_partitions | partitions_size_details
+ list_possible_root_partitions | partitions_usage_details | partitions_size_details
}
# Synopsis: send_possible_root_filesystems
diff --git a/wizard/bootloader.cpp b/wizard/bootloader.cpp
index a066d05..0b4ccf8 100644
--- a/wizard/bootloader.cpp
+++ b/wizard/bootloader.cpp
@@ -11,7 +11,7 @@ wpBootloader::wpBootloader(QWidget *parent) : QWizardPage(parent)
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));
+ bootloaderTarget->setItemDelegate(new ListDelegate(this));
}
void wpBootloader::initializePage()
@@ -36,7 +36,11 @@ void wpBootloader::receivedDataLine(QString data, QString line)
}
if(data == "bootloader_targets")
{
- QListWidgetItem *item = new QListWidgetItem(QIcon::fromTheme("drive-harddisk"), line);
+ QString dev = line.section(" ",0,0);
+ qlonglong size = line.section(" ",1,1).toLongLong();
+ QString desc = QString("%1 (%L2)").arg(backend->sizeToString(size)).arg(size);
+ desc += "<br />" + line.section(" ",2);
+ QListWidgetItem *item = new ListItem(dev, desc, "drive-harddisk", dev);
bootloaderTarget->addItem(item);
}
}
@@ -69,6 +73,6 @@ 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());
+ backend->cfg("bootloader_target", bootloaderTarget->currentItem()->data(ListItem::ItemData).toString());
return true;
}
diff --git a/wizard/partmansel.cpp b/wizard/partmansel.cpp
index 3a3d78b..9c509e6 100644
--- a/wizard/partmansel.cpp
+++ b/wizard/partmansel.cpp
@@ -11,6 +11,7 @@ wpPartManSel::wpPartManSel(QWidget *parent) : QWizardPage(parent)
connect(partMan, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), this, SLOT(updateComplete()));
connect(partDisk, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), this, SLOT(updateComplete()));
partMan->setItemDelegate(new ListDelegate(this));
+ partDisk->setItemDelegate(new ListDelegate(this));
}
void wpPartManSel::initializePage()
@@ -67,7 +68,10 @@ void wpPartManSel::receivedDataLine(QString data, QString line)
}
if(data == "list_of_disks")
{
- QListWidgetItem *item = new QListWidgetItem(QIcon::fromTheme("drive-harddisk"), line);
+ QString dev = line.section(" ",0,0);
+ qlonglong size = line.section(" ",1,1).toLongLong();
+ QString desc = QString("%1 (%L2)").arg(backend->sizeToString(size)).arg(size);
+ QListWidgetItem *item = new ListItem(dev, desc, "drive-harddisk", dev);
partDisk->addItem(item);
}
}
@@ -88,6 +92,6 @@ 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));
+ backend->cfg("partman_disk", partDisk->currentItem()->data(ListItem::ItemData).toString());
return true;
}
diff --git a/wizard/rootpartition.cpp b/wizard/rootpartition.cpp
index 2b2b023..7a979d6 100644
--- a/wizard/rootpartition.cpp
+++ b/wizard/rootpartition.cpp
@@ -13,6 +13,7 @@ wpRootPartition::wpRootPartition(QWidget *parent) : QWizardPage(parent)
connect(backend, SIGNAL(finishedCommand(QString)), this, SLOT(backendFinishedCommand(QString)));
connect(rootPartitionDev, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), this, SLOT(updateComplete()));
connect(chkAdvanced, SIGNAL(stateChanged(int)), this, SLOT(updateComplete()));
+ rootPartitionDev->setItemDelegate(new ListDelegate(this));
checkPassed = false;
}
@@ -36,7 +37,11 @@ void wpRootPartition::receivedDataLine(QString data, QString line)
{
if(data == "possible_root_partitions")
{
- QListWidgetItem *item = new QListWidgetItem(QIcon::fromTheme("drive-harddisk"), line);
+ QString dev = line.section(" ",0,0);
+ qlonglong size = line.section(" ",1,1).toLongLong();
+ QString desc = QString("%1 (%L2)").arg(backend->sizeToString(size)).arg(size);
+ desc += "<br />" + line.section(" ",2);
+ QListWidgetItem *item = new ListItem(dev, desc, "drive-harddisk", dev);
rootPartitionDev->addItem(item);
}
if(data == "possible_root_filesystems")
@@ -83,7 +88,7 @@ bool wpRootPartition::validatePage()
}
if(rootPartitionDev->currentItem())
backend->exec(QString("hdmap_set %1:/:%2:auto")
- .arg(rootPartitionDev->currentItem()->text().section(" ",0,0))
+ .arg(rootPartitionDev->currentItem()->data(ListItem::ItemData).toString())
.arg(chkFormat->isChecked() ? rootPartitionFs->currentText() : ""));
backend->exec("fill_hdmap");