From d3f55af51ee4a311db0b44ea83a8b672f312647b Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 10 Mar 2020 14:13:18 -0500 Subject: [PATCH] [calamares] Clean up progress tree model - It's still not a real tree - Remove unused classes / files - Apply coding style --- src/calamares/CMakeLists.txt | 1 - .../progresstree/ProgressTreeItem.cpp | 92 ------------------- src/calamares/progresstree/ProgressTreeItem.h | 60 ------------ .../progresstree/ProgressTreeModel.cpp | 21 ++--- .../progresstree/ProgressTreeModel.h | 4 - 5 files changed, 10 insertions(+), 168 deletions(-) delete mode 100644 src/calamares/progresstree/ProgressTreeItem.cpp delete mode 100644 src/calamares/progresstree/ProgressTreeItem.h diff --git a/src/calamares/CMakeLists.txt b/src/calamares/CMakeLists.txt index cb460f14b..5ae4449a7 100644 --- a/src/calamares/CMakeLists.txt +++ b/src/calamares/CMakeLists.txt @@ -7,7 +7,6 @@ set( calamaresSources VariantModel.cpp progresstree/ProgressTreeDelegate.cpp - progresstree/ProgressTreeItem.cpp progresstree/ProgressTreeModel.cpp progresstree/ProgressTreeView.cpp ) diff --git a/src/calamares/progresstree/ProgressTreeItem.cpp b/src/calamares/progresstree/ProgressTreeItem.cpp deleted file mode 100644 index 4c5b5b0c3..000000000 --- a/src/calamares/progresstree/ProgressTreeItem.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/* === This file is part of Calamares - === - * - * Copyright 2014, Teo Mrnjavac - * - * Calamares is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Calamares is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Calamares. If not, see . - */ - -#include "ProgressTreeItem.h" - -#include "ProgressTreeModel.h" - - -ProgressTreeItem::ProgressTreeItem( ProgressTreeItem* parent ) -{ - m_parentItem = parent; -} - - -ProgressTreeItem::~ProgressTreeItem() -{ - qDeleteAll( m_childItems ); -} - - -void -ProgressTreeItem::appendChild( ProgressTreeItem* item ) -{ - m_childItems.append( item ); -} - - -ProgressTreeItem* -ProgressTreeItem::child( int row ) -{ - return m_childItems.value( row ); -} - - -int -ProgressTreeItem::childCount() const -{ - return m_childItems.count(); -} - - -int -ProgressTreeItem::columnCount() const -{ - return 1; -} - - -int -ProgressTreeItem::row() const -{ - if ( m_parentItem ) - { - return m_parentItem->m_childItems.indexOf( const_cast< ProgressTreeItem* >( this ) ); - } - return 0; -} - - -ProgressTreeItem* -ProgressTreeItem::parent() -{ - return m_parentItem; -} - - -ProgressTreeRoot::ProgressTreeRoot() - : ProgressTreeItem() -{ -} - - -QVariant -ProgressTreeRoot::data( int ) const -{ - return QVariant(); -} diff --git a/src/calamares/progresstree/ProgressTreeItem.h b/src/calamares/progresstree/ProgressTreeItem.h deleted file mode 100644 index fd93ab0ef..000000000 --- a/src/calamares/progresstree/ProgressTreeItem.h +++ /dev/null @@ -1,60 +0,0 @@ -/* === This file is part of Calamares - === - * - * Copyright 2014, Teo Mrnjavac - * - * Calamares is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Calamares is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Calamares. If not, see . - */ - -#ifndef PROGRESSTREEITEM_H -#define PROGRESSTREEITEM_H - -#include -#include - - -/** - * @brief The ProgressTreeItem class represents an item in the - * ProgressTreeModel/ProgressTreeView. - * Each item generally represents a ViewStep. - */ -class ProgressTreeItem -{ -public: - explicit ProgressTreeItem( ProgressTreeItem* parent = nullptr ); - - virtual ~ProgressTreeItem(); - - virtual void appendChild( ProgressTreeItem* item ); - - virtual ProgressTreeItem* child( int row ); - virtual int childCount() const; - virtual int columnCount() const; - virtual QVariant data( int role ) const = 0; - virtual int row() const; - virtual ProgressTreeItem* parent(); - -private: - QList< ProgressTreeItem* > m_childItems; - ProgressTreeItem* m_parentItem; -}; - -class ProgressTreeRoot : public ProgressTreeItem -{ -public: - explicit ProgressTreeRoot(); - - virtual QVariant data( int role ) const; -}; - -#endif // PROGRESSTREEITEM_H diff --git a/src/calamares/progresstree/ProgressTreeModel.cpp b/src/calamares/progresstree/ProgressTreeModel.cpp index 00f2884a3..9127398e8 100644 --- a/src/calamares/progresstree/ProgressTreeModel.cpp +++ b/src/calamares/progresstree/ProgressTreeModel.cpp @@ -27,11 +27,7 @@ ProgressTreeModel::ProgressTreeModel( QObject* parent ) { } - -ProgressTreeModel::~ProgressTreeModel() -{ -} - +ProgressTreeModel::~ProgressTreeModel() {} QVariant ProgressTreeModel::data( const QModelIndex& index, int role ) const @@ -42,14 +38,18 @@ ProgressTreeModel::data( const QModelIndex& index, int role ) const } const Calamares::ViewManager* vm = Calamares::ViewManager::instance(); - if ( !vm) + if ( !vm ) + { return QVariant(); + } const auto steps = vm->viewSteps(); - if ( (index.row() < 0 ) || (index.row() >= steps.length() ) ) + if ( ( index.row() < 0 ) || ( index.row() >= steps.length() ) ) + { return QVariant(); + } - const auto* step = steps.at(index.row()); + const auto* step = steps.at( index.row() ); if ( role == Qt::DisplayRole ) { @@ -65,7 +65,7 @@ ProgressTreeModel::data( const QModelIndex& index, int role ) const toolTip.append( QString( "
Status:\t%1" ).arg( step->prettyStatus() ) ); toolTip.append( QString( "
Source:\t%1" ) .arg( step->moduleInstanceKey().isValid() ? step->moduleInstanceKey().toString() - : QStringLiteral( "built-in" ) ) ); + : QStringLiteral( "built-in" ) ) ); } else { @@ -75,13 +75,12 @@ ProgressTreeModel::data( const QModelIndex& index, int role ) const } if ( role == ProgressTreeModel::ProgressTreeItemCurrentRole ) { - return step && (Calamares::ViewManager::instance()->currentStep() == step); + return step && ( Calamares::ViewManager::instance()->currentStep() == step ); } return QVariant(); } - int ProgressTreeModel::rowCount( const QModelIndex& parent ) const { diff --git a/src/calamares/progresstree/ProgressTreeModel.h b/src/calamares/progresstree/ProgressTreeModel.h index 51f1f4126..e52ecf189 100644 --- a/src/calamares/progresstree/ProgressTreeModel.h +++ b/src/calamares/progresstree/ProgressTreeModel.h @@ -22,10 +22,6 @@ #include -class ProgressTreeRoot; -class ProgressTreeItem; - - /** * @brief The ProgressTreeModel class implements a model for the ProgressTreeView. */