[calamares] Clean up progress tree model

- It's still not a real tree
- Remove unused classes / files
- Apply coding style
This commit is contained in:
Adriaan de Groot 2020-03-10 14:13:18 -05:00
parent 76144fb3dc
commit d3f55af51e
5 changed files with 10 additions and 168 deletions

View File

@ -7,7 +7,6 @@ set( calamaresSources
VariantModel.cpp
progresstree/ProgressTreeDelegate.cpp
progresstree/ProgressTreeItem.cpp
progresstree/ProgressTreeModel.cpp
progresstree/ProgressTreeView.cpp
)

View File

@ -1,92 +0,0 @@
/* === This file is part of Calamares - <https://github.com/calamares> ===
*
* Copyright 2014, Teo Mrnjavac <teo@kde.org>
*
* 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 <http://www.gnu.org/licenses/>.
*/
#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();
}

View File

@ -1,60 +0,0 @@
/* === This file is part of Calamares - <https://github.com/calamares> ===
*
* Copyright 2014, Teo Mrnjavac <teo@kde.org>
*
* 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 <http://www.gnu.org/licenses/>.
*/
#ifndef PROGRESSTREEITEM_H
#define PROGRESSTREEITEM_H
#include <QList>
#include <QVariant>
/**
* @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

View File

@ -27,11 +27,7 @@ ProgressTreeModel::ProgressTreeModel( QObject* parent )
{
}
ProgressTreeModel::~ProgressTreeModel()
{
}
ProgressTreeModel::~ProgressTreeModel() {}
QVariant
ProgressTreeModel::data( const QModelIndex& index, int role ) const
@ -43,11 +39,15 @@ ProgressTreeModel::data( const QModelIndex& index, int role ) const
const Calamares::ViewManager* vm = Calamares::ViewManager::instance();
if ( !vm )
{
return QVariant();
}
const auto steps = vm->viewSteps();
if ( ( index.row() < 0 ) || ( index.row() >= steps.length() ) )
{
return QVariant();
}
const auto* step = steps.at( index.row() );
@ -81,7 +81,6 @@ ProgressTreeModel::data( const QModelIndex& index, int role ) const
}
int
ProgressTreeModel::rowCount( const QModelIndex& parent ) const
{

View File

@ -22,10 +22,6 @@
#include <QAbstractListModel>
class ProgressTreeRoot;
class ProgressTreeItem;
/**
* @brief The ProgressTreeModel class implements a model for the ProgressTreeView.
*/