[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:
parent
76144fb3dc
commit
d3f55af51e
@ -7,7 +7,6 @@ set( calamaresSources
|
|||||||
VariantModel.cpp
|
VariantModel.cpp
|
||||||
|
|
||||||
progresstree/ProgressTreeDelegate.cpp
|
progresstree/ProgressTreeDelegate.cpp
|
||||||
progresstree/ProgressTreeItem.cpp
|
|
||||||
progresstree/ProgressTreeModel.cpp
|
progresstree/ProgressTreeModel.cpp
|
||||||
progresstree/ProgressTreeView.cpp
|
progresstree/ProgressTreeView.cpp
|
||||||
)
|
)
|
||||||
|
@ -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();
|
|
||||||
}
|
|
@ -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
|
|
@ -27,11 +27,7 @@ ProgressTreeModel::ProgressTreeModel( QObject* parent )
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ProgressTreeModel::~ProgressTreeModel() {}
|
||||||
ProgressTreeModel::~ProgressTreeModel()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QVariant
|
QVariant
|
||||||
ProgressTreeModel::data( const QModelIndex& index, int role ) const
|
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();
|
const Calamares::ViewManager* vm = Calamares::ViewManager::instance();
|
||||||
if ( !vm)
|
if ( !vm )
|
||||||
|
{
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
}
|
||||||
|
|
||||||
const auto steps = vm->viewSteps();
|
const auto steps = vm->viewSteps();
|
||||||
if ( (index.row() < 0 ) || (index.row() >= steps.length() ) )
|
if ( ( index.row() < 0 ) || ( index.row() >= steps.length() ) )
|
||||||
|
{
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
}
|
||||||
|
|
||||||
const auto* step = steps.at(index.row());
|
const auto* step = steps.at( index.row() );
|
||||||
|
|
||||||
if ( role == Qt::DisplayRole )
|
if ( role == Qt::DisplayRole )
|
||||||
{
|
{
|
||||||
@ -65,7 +65,7 @@ ProgressTreeModel::data( const QModelIndex& index, int role ) const
|
|||||||
toolTip.append( QString( "<br/>Status:\t%1" ).arg( step->prettyStatus() ) );
|
toolTip.append( QString( "<br/>Status:\t%1" ).arg( step->prettyStatus() ) );
|
||||||
toolTip.append( QString( "<br/>Source:\t%1" )
|
toolTip.append( QString( "<br/>Source:\t%1" )
|
||||||
.arg( step->moduleInstanceKey().isValid() ? step->moduleInstanceKey().toString()
|
.arg( step->moduleInstanceKey().isValid() ? step->moduleInstanceKey().toString()
|
||||||
: QStringLiteral( "built-in" ) ) );
|
: QStringLiteral( "built-in" ) ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -75,13 +75,12 @@ ProgressTreeModel::data( const QModelIndex& index, int role ) const
|
|||||||
}
|
}
|
||||||
if ( role == ProgressTreeModel::ProgressTreeItemCurrentRole )
|
if ( role == ProgressTreeModel::ProgressTreeItemCurrentRole )
|
||||||
{
|
{
|
||||||
return step && (Calamares::ViewManager::instance()->currentStep() == step);
|
return step && ( Calamares::ViewManager::instance()->currentStep() == step );
|
||||||
}
|
}
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
ProgressTreeModel::rowCount( const QModelIndex& parent ) const
|
ProgressTreeModel::rowCount( const QModelIndex& parent ) const
|
||||||
{
|
{
|
||||||
|
@ -22,10 +22,6 @@
|
|||||||
|
|
||||||
#include <QAbstractListModel>
|
#include <QAbstractListModel>
|
||||||
|
|
||||||
class ProgressTreeRoot;
|
|
||||||
class ProgressTreeItem;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The ProgressTreeModel class implements a model for the ProgressTreeView.
|
* @brief The ProgressTreeModel class implements a model for the ProgressTreeView.
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user