diff --git a/src/modules/partition/DeviceModel.cpp b/src/modules/partition/DeviceModel.cpp index 308fa96aa..8197e6915 100644 --- a/src/modules/partition/DeviceModel.cpp +++ b/src/modules/partition/DeviceModel.cpp @@ -21,6 +21,9 @@ // CalaPM #include +// KF5 +#include + DeviceModel::DeviceModel( QObject* parent ) : QAbstractListModel( parent ) { @@ -59,7 +62,10 @@ DeviceModel::data( const QModelIndex& index, int role ) const if ( device->name().isEmpty() ) return device->deviceNode(); else - return device->name() + " " + device->deviceNode(); + return tr( "%1 - %2 (%3)" ) + .arg( device->name() ) + .arg( KFormat().formatByteSize( device->capacity() ) ) + .arg( device->deviceNode() ); default: return QVariant(); } diff --git a/src/modules/partition/PartitionPage.cpp b/src/modules/partition/PartitionPage.cpp index 04459fe49..5f53b6872 100644 --- a/src/modules/partition/PartitionPage.cpp +++ b/src/modules/partition/PartitionPage.cpp @@ -45,12 +45,13 @@ PartitionPage::PartitionPage( PartitionCoreModule* core, QWidget* parent ) , m_core( core ) { m_ui->setupUi( this ); - m_ui->deviceListView->setModel( m_core->deviceModel() ); + m_ui->deviceComboBox->setModel( m_core->deviceModel() ); updateButtons(); - connect( m_ui->deviceListView->selectionModel(), &QItemSelectionModel::currentChanged, - [ this ]( const QModelIndex& index, const QModelIndex& oldIndex ) + connect( m_ui->deviceComboBox, &QComboBox::currentTextChanged, + [ this ]( const QString& /* text */ ) { + QModelIndex index = m_ui->deviceComboBox->view()->currentIndex(); Device* device = m_core->deviceModel()->deviceForIndex( index ); PartitionModel* model = m_core->partitionModelForDevice( device ); m_ui->partitionTreeView->setModel( model ); @@ -111,13 +112,13 @@ PartitionPage::updateButtons() m_ui->editButton->setEnabled( edit ); m_ui->deleteButton->setEnabled( del ); - m_ui->newPartitionTableButton->setEnabled( m_ui->deviceListView->currentIndex().isValid() ); + m_ui->newPartitionTableButton->setEnabled( m_ui->deviceComboBox->currentIndex() >= 0 ); } void PartitionPage::onNewPartitionTableClicked() { - QModelIndex index = m_ui->deviceListView->currentIndex(); + QModelIndex index = m_ui->deviceComboBox->view()->currentIndex(); Q_ASSERT( index.isValid() ); Device* device = m_core->deviceModel()->deviceForIndex( index ); diff --git a/src/modules/partition/PartitionPage.ui b/src/modules/partition/PartitionPage.ui index 74e80b477..bcb43a7ed 100644 --- a/src/modules/partition/PartitionPage.ui +++ b/src/modules/partition/PartitionPage.ui @@ -13,15 +13,61 @@ Form - - + + + + + + + Disk: + + + deviceComboBox + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + [Disk preview goes here] - + + + + false + + + true + + + false + + + false + + + + @@ -66,34 +112,16 @@ - - - - - 0 - 0 - - - - - - - - false - - - true - - - false - - - false - - - + + deviceComboBox + partitionTreeView + newPartitionTableButton + createButton + editButton + deleteButton +