source: calamares/trunk/fuentes/src/calamares/progresstree/ViewStepItem.cpp @ 7538

Last change on this file since 7538 was 7538, checked in by kbut, 13 months ago

sync with github

File size: 2.9 KB
Line 
1/* === This file is part of Calamares - <https://github.com/calamares> ===
2 *
3 *   Copyright 2014-2015, Teo Mrnjavac <teo@kde.org>
4 *
5 *   Calamares is free software: you can redistribute it and/or modify
6 *   it under the terms of the GNU General Public License as published by
7 *   the Free Software Foundation, either version 3 of the License, or
8 *   (at your option) any later version.
9 *
10 *   Calamares is distributed in the hope that it will be useful,
11 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 *   GNU General Public License for more details.
14 *
15 *   You should have received a copy of the GNU General Public License
16 *   along with Calamares. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#include "ViewStepItem.h"
20
21#include "ProgressTreeModel.h"
22#include "Settings.h"
23#include "ViewManager.h"
24#include "viewpages/ViewStep.h"
25
26
27ViewStepItem::ViewStepItem( std::function< QString() > prettyName,
28                            std::function< const Calamares::ViewStep*() > accessor,
29                            ProgressTreeItem* parent )
30    : ProgressTreeItem( parent )
31    , m_step( nullptr )
32{
33    m_prettyName = prettyName;
34    m_accessor = accessor;
35}
36
37
38ViewStepItem::ViewStepItem( const Calamares::ViewStep* step,
39                            ProgressTreeItem* parent )
40    : ProgressTreeItem( parent )
41{
42    m_step = step;
43}
44
45void
46ViewStepItem::appendChild( ProgressTreeItem* item )
47{
48    Q_ASSERT( false );
49    Q_UNUSED( item );
50}
51
52
53QVariant
54ViewStepItem::data( int role ) const
55{
56    if ( role == ProgressTreeModel::ProgressTreeItemRole )
57        return this;
58    if ( role == Qt::DisplayRole )
59    {
60        return m_step ? m_step->prettyName()
61                      : m_prettyName();
62    }
63    if ( Calamares::Settings::instance()->debugMode() && role == Qt::ToolTipRole )
64    {
65        QString toolTip( "<b>Debug information</b>" );
66        if ( m_step )
67        {
68            toolTip.append( "<br/>Type:\tViewStep" );
69            toolTip.append( QString( "<br/>Pretty:\t%1" ).arg( m_step->prettyName() ) );
70            toolTip.append( QString( "<br/>Status:\t%1" ).arg( m_step->prettyStatus() ) );
71            toolTip.append( QString( "<br/>Source:\t%1" ).arg(
72                                m_step->moduleInstanceKey().isEmpty() ? "built-in"
73                                                                      : m_step->moduleInstanceKey() ) );
74        }
75        else
76        {
77            toolTip.append( "<br/>Type:\tDelegate" );
78            toolTip.append( QString( "<br/>Pretty:\t%1" ).arg( m_prettyName() ) );
79        }
80        return toolTip;
81    }
82    if ( role == ProgressTreeModel::ProgressTreeItemCurrentRole )
83        return m_step ?
84                    ( Calamares::ViewManager::instance()->currentStep() == m_step ) :
85                    ( Calamares::ViewManager::instance()->currentStep() == m_accessor() );
86    return QVariant();
87}
Note: See TracBrowser for help on using the repository browser.