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

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

sync with github

File size: 2.3 KB
Line 
1/* === This file is part of Calamares - <https://github.com/calamares> ===
2 *
3 *   Copyright 2014, 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 "ProgressTreeView.h"
20
21#include "ProgressTreeDelegate.h"
22#include "ViewManager.h"
23#include "Branding.h"
24
25ProgressTreeView* ProgressTreeView::s_instance = nullptr;
26
27ProgressTreeView*
28ProgressTreeView::instance()
29{
30    return s_instance;
31}
32
33ProgressTreeView::ProgressTreeView( QWidget* parent )
34    : QTreeView( parent )
35{
36    s_instance = this; //FIXME: should assert when s_instance gets written and it wasn't nullptr
37
38    this->setObjectName("sidebarMenuApp");
39    setFrameShape( QFrame::NoFrame );
40    setContentsMargins( 0, 0, 0, 0 );
41
42    setHeaderHidden( true );
43    setRootIsDecorated( true );
44    setExpandsOnDoubleClick( true );
45
46    setSelectionMode( QAbstractItemView::NoSelection );
47    setDragDropMode( QAbstractItemView::NoDragDrop );
48    setAcceptDrops( false );
49    setUniformRowHeights( false );
50
51    setIndentation( 0 );
52    setSortingEnabled( false );
53
54    m_delegate = new ProgressTreeDelegate( this );
55    setItemDelegate( m_delegate );
56
57    QPalette plt = palette();
58    plt.setColor( QPalette::Base, Calamares::Branding::instance()->
59        styleString( Calamares::Branding::SidebarBackground ) );
60    setPalette( plt );
61}
62
63
64ProgressTreeView::~ProgressTreeView()
65{
66}
67
68
69void
70ProgressTreeView::setModel( QAbstractItemModel* model )
71{
72    if ( ProgressTreeView::model() )
73        return;
74
75    QTreeView::setModel( model );
76    expandAll();
77
78    connect( Calamares::ViewManager::instance(),
79             &Calamares::ViewManager::currentStepChanged,
80             this, [this]()
81    {
82        viewport()->update();
83    },
84    Qt::UniqueConnection );
85}
Note: See TracBrowser for help on using the repository browser.