From 1ad6c7e8ac9fa93166ce0955a1d0cca7ea560834 Mon Sep 17 00:00:00 2001
From: Teo Mrnjavac <teo@kde.org>
Date: Thu, 3 Dec 2015 19:40:06 +0100
Subject: [PATCH] Use new Labels view.

---
 src/modules/partition/gui/AlongsidePage.cpp   |  5 +++-
 src/modules/partition/gui/AlongsidePage.h     |  2 ++
 src/modules/partition/gui/ChoicePage.cpp      | 15 ++++++++----
 .../partition/gui/PartitionViewStep.cpp       | 23 +++++++++++++++----
 4 files changed, 36 insertions(+), 9 deletions(-)

diff --git a/src/modules/partition/gui/AlongsidePage.cpp b/src/modules/partition/gui/AlongsidePage.cpp
index 2c4c4f2800..986b81dfb6 100644
--- a/src/modules/partition/gui/AlongsidePage.cpp
+++ b/src/modules/partition/gui/AlongsidePage.cpp
@@ -26,6 +26,7 @@
 #include "core/PartitionIterator.h"
 #include "gui/PartitionSplitterWidget.h"
 #include "gui/PartitionBarsView.h"
+#include "gui/PartitionLabelsView.h"
 
 #include "JobQueue.h"
 #include "GlobalStorage.h"
@@ -65,8 +66,9 @@ AlongsidePage::AlongsidePage( QWidget* parent )
     partitionsComboLayout->addStretch();
 
     m_previewWidget = new PartitionBarsView;
-    m_previewWidget->setLabelsVisible( true );
+    m_previewLabels = new PartitionLabelsView;
     mainLayout->addWidget( m_previewWidget );
+    mainLayout->addWidget( m_previewLabels );
 
     QLabel* allocateSpaceLabel = new QLabel();
     mainLayout->addWidget( allocateSpaceLabel );
@@ -194,6 +196,7 @@ AlongsidePage::onPartitionSelected( int comboBoxIndex )
             partitionModelBefore->setParent( m_previewWidget );
 
             m_previewWidget->setModel( partitionModelBefore );
+            m_previewLabels->setModel( partitionModelBefore );
             m_splitterWidget->init( allPartitionItems );
 
             m_splitterWidget->setSplitPartition( candidate->partitionPath(),
diff --git a/src/modules/partition/gui/AlongsidePage.h b/src/modules/partition/gui/AlongsidePage.h
index a2e013ded1..f68ca5ff82 100644
--- a/src/modules/partition/gui/AlongsidePage.h
+++ b/src/modules/partition/gui/AlongsidePage.h
@@ -29,6 +29,7 @@ class PartitionCoreModule;
 class PartitionSplitterWidget;
 class Partition;
 class PartitionBarsView;
+class PartitionLabelsView;
 class Device;
 
 class AlongsidePage : public QWidget
@@ -55,6 +56,7 @@ private:
     QComboBox* m_partitionsComboBox;
     PartitionSplitterWidget* m_splitterWidget;
     PartitionBarsView* m_previewWidget;
+    PartitionLabelsView* m_previewLabels;
     QLabel* m_sizeLabel;
 
     QLabel* m_efiLabel;
diff --git a/src/modules/partition/gui/ChoicePage.cpp b/src/modules/partition/gui/ChoicePage.cpp
index e35037a8a7..b61db0b498 100644
--- a/src/modules/partition/gui/ChoicePage.cpp
+++ b/src/modules/partition/gui/ChoicePage.cpp
@@ -29,6 +29,7 @@
 #include "PrettyRadioButton.h"
 #include "ExpandableRadioButton.h"
 #include "PartitionBarsView.h"
+#include "PartitionLabelsView.h"
 #include "DeviceInfoWidget.h"
 
 #include "utils/CalamaresUtilsGui.h"
@@ -479,10 +480,11 @@ ChoicePage::updateDeviceStatePreview( Device* currentDevice )
 
     QVBoxLayout* layout = new QVBoxLayout;
     m_previewBeforeFrame->setLayout( layout );
-    layout->setMargin( 0 );
+    CalamaresUtils::unmarginLayout( layout );
+    layout->setSpacing( 6 );
 
     PartitionBarsView* preview = new PartitionBarsView( m_previewBeforeFrame );
-    preview->setLabelsVisible( true );
+    PartitionLabelsView* previewLabels = new PartitionLabelsView( m_previewBeforeFrame );
 
     Device* deviceBefore = m_core->createImmutableDeviceCopy( currentDevice );
 
@@ -495,7 +497,9 @@ ChoicePage::updateDeviceStatePreview( Device* currentDevice )
     model->setParent( preview );
 
     preview->setModel( model );
+    previewLabels->setModel( model );
     layout->addWidget( preview );
+    layout->addWidget( previewLabels );
 }
 
 
@@ -518,7 +522,8 @@ ChoicePage::updateActionChoicePreview( Device* currentDevice, ChoicePage::Choice
 
     QVBoxLayout* layout = new QVBoxLayout;
     m_previewAfterFrame->setLayout( layout );
-    layout->setMargin( 0 );
+    CalamaresUtils::unmarginLayout( layout );
+    layout->setSpacing( 6 );
 
     switch ( choice )
     {
@@ -531,7 +536,7 @@ ChoicePage::updateActionChoicePreview( Device* currentDevice, ChoicePage::Choice
     case Replace:
         {
             PartitionBarsView* preview = new PartitionBarsView( m_previewAfterFrame );
-            preview->setLabelsVisible( true );
+            PartitionLabelsView* previewLabels = new PartitionLabelsView( m_previewAfterFrame );
 
             PartitionModel* model = new PartitionModel( preview );
             model->init( currentDevice );
@@ -540,7 +545,9 @@ ChoicePage::updateActionChoicePreview( Device* currentDevice, ChoicePage::Choice
             // see qDeleteAll above.
             model->setParent( preview );
             preview->setModel( model );
+            previewLabels->setModel( model );
             layout->addWidget( preview );
+            layout->addWidget( previewLabels );
 
             m_previewAfterFrame->show();
             break;
diff --git a/src/modules/partition/gui/PartitionViewStep.cpp b/src/modules/partition/gui/PartitionViewStep.cpp
index d9c2386e4c..2f840b1722 100644
--- a/src/modules/partition/gui/PartitionViewStep.cpp
+++ b/src/modules/partition/gui/PartitionViewStep.cpp
@@ -29,6 +29,7 @@
 #include "gui/AlongsidePage.h"
 #include "gui/PartitionPage.h"
 #include "gui/PartitionBarsView.h"
+#include "gui/PartitionLabelsView.h"
 
 #include "CalamaresVersion.h"
 #include "utils/CalamaresUtilsGui.h"
@@ -210,18 +211,32 @@ PartitionViewStep::createSummaryWidget() const
         formLayout->addRow( diskInfoLabel );
 
         PartitionBarsView* preview;
+        PartitionLabelsView* previewLabels;
+        QVBoxLayout* field;
 
         preview = new PartitionBarsView;
-        preview->setLabelsVisible( true );
+        previewLabels = new PartitionLabelsView;
         preview->setModel( info.partitionModelBefore );
+        previewLabels->setModel( info.partitionModelBefore );
         info.partitionModelBefore->setParent( widget );
-        formLayout->addRow( tr( "Before:" ), preview );
+        field = new QVBoxLayout;
+        CalamaresUtils::unmarginLayout( field );
+        field->setSpacing( 6 );
+        field->addWidget( preview );
+        field->addWidget( previewLabels );
+        formLayout->addRow( tr( "Current state:" ), field );
 
         preview = new PartitionBarsView;
-        preview->setLabelsVisible( true );
+        previewLabels = new PartitionLabelsView;
         preview->setModel( info.partitionModelAfter );
+        previewLabels->setModel( info.partitionModelAfter );
         info.partitionModelAfter->setParent( widget );
-        formLayout->addRow( tr( "After:" ), preview );
+        field = new QVBoxLayout;
+        CalamaresUtils::unmarginLayout( field );
+        field->setSpacing( 6 );
+        field->addWidget( preview );
+        field->addWidget( previewLabels );
+        formLayout->addRow( tr( "Your changes:" ), field );
     }
     QStringList jobsLines;
     foreach ( const Calamares::job_ptr& job, jobs() )
-- 
GitLab