Expose icon and tooltip in DeviceModel.

main
Teo Mrnjavac 10 years ago
parent a98a4bb614
commit 4cadbf9b98

@ -1,6 +1,7 @@
/* === This file is part of Calamares - <http://github.com/calamares> === /* === This file is part of Calamares - <http://github.com/calamares> ===
* *
* Copyright 2014, Aurélien Gâteau <agateau@kde.org> * Copyright 2014, Aurélien Gâteau <agateau@kde.org>
* Copyright 2014, Teo Mrnjavac <teo@kde.org>
* *
* Calamares is free software: you can redistribute it and/or modify * Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -19,12 +20,16 @@
#include <core/PartitionModel.h> #include <core/PartitionModel.h>
#include "utils/CalamaresUtilsGui.h"
// CalaPM // CalaPM
#include <core/device.h> #include <core/device.h>
// KF5 // KF5
#include <KFormat> #include <KFormat>
#include <QIcon>
// STL // STL
#include <algorithm> #include <algorithm>
@ -67,6 +72,7 @@ DeviceModel::data( const QModelIndex& index, int role ) const
switch ( role ) switch ( role )
{ {
case Qt::DisplayRole: case Qt::DisplayRole:
case Qt::ToolTipRole:
if ( device->name().isEmpty() ) if ( device->name().isEmpty() )
return device->deviceNode(); return device->deviceNode();
else else
@ -74,6 +80,11 @@ DeviceModel::data( const QModelIndex& index, int role ) const
.arg( device->name() ) .arg( device->name() )
.arg( KFormat().formatByteSize( device->capacity() ) ) .arg( KFormat().formatByteSize( device->capacity() ) )
.arg( device->deviceNode() ); .arg( device->deviceNode() );
case Qt::DecorationRole:
return CalamaresUtils::defaultPixmap( CalamaresUtils::Partitions,
CalamaresUtils::Original,
QSize( CalamaresUtils::defaultIconSize().width() * 3,
CalamaresUtils::defaultIconSize().height() * 3 ) );
default: default:
return QVariant(); return QVariant();
} }

Loading…
Cancel
Save