~ubuntu-branches/ubuntu/vivid/muon/vivid-proposed

« back to all changes in this revision

Viewing changes to installer/BreadcrumbWidget/BreadcrumbItem.cpp

  • Committer: Package Import Robot
  • Author(s): Scarlett Clark
  • Date: 2015-03-24 07:36:31 UTC
  • mto: This revision was merged to the branch mainline in revision 86.
  • Revision ID: package-import@ubuntu.com-20150324073631-7nmay5episnfkdlt
Tags: upstream-5.2.2
Import upstream version 5.2.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/***************************************************************************
2
 
 *   Copyright © 2010 Jonathan Thomas <echidnaman@kubuntu.org>             *
3
 
 *                                                                         *
4
 
 *   This program is free software; you can redistribute it and/or         *
5
 
 *   modify it under the terms of the GNU General Public License as        *
6
 
 *   published by the Free Software Foundation; either version 2 of        *
7
 
 *   the License or (at your option) version 3 or any later version        *
8
 
 *   accepted by the membership of KDE e.V. (or its successor approved     *
9
 
 *   by the membership of KDE e.V.), which shall act as a proxy            *
10
 
 *   defined in Section 14 of version 3 of the license.                    *
11
 
 *                                                                         *
12
 
 *   This program is distributed in the hope that it will be useful,       *
13
 
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
14
 
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
15
 
 *   GNU General Public License for more details.                          *
16
 
 *                                                                         *
17
 
 *   You should have received a copy of the GNU General Public License     *
18
 
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>. *
19
 
 ***************************************************************************/
20
 
 
21
 
#include "BreadcrumbItem.h"
22
 
 
23
 
#include <QtCore/QStringBuilder>
24
 
#include <QtWidgets/QPushButton>
25
 
 
26
 
#include "../AbstractViewBase.h"
27
 
#include "BreadcrumbItemButton.h"
28
 
 
29
 
BreadcrumbItem::BreadcrumbItem(QWidget *parent)
30
 
    : KHBox(parent)
31
 
    , m_hasChildren(false)
32
 
    , m_associatedView(nullptr)
33
 
{
34
 
    m_button = new BreadcrumbItemButton(this);
35
 
    hide();
36
 
 
37
 
    connect(m_button, SIGNAL(clicked()), this, SLOT(emitActivated()));
38
 
}
39
 
 
40
 
BreadcrumbItem::~BreadcrumbItem()
41
 
{
42
 
}
43
 
 
44
 
BreadcrumbItem *BreadcrumbItem::childItem() const
45
 
{
46
 
    return m_childItem;
47
 
}
48
 
 
49
 
AbstractViewBase *BreadcrumbItem::associatedView() const
50
 
{
51
 
    return m_associatedView;
52
 
}
53
 
 
54
 
bool BreadcrumbItem::hasChildren() const
55
 
{
56
 
    return m_hasChildren;
57
 
}
58
 
 
59
 
void BreadcrumbItem::setChildItem(BreadcrumbItem *child)
60
 
{
61
 
    // Only give an arrow if it has never had children. If it has, it will
62
 
    // already have one
63
 
    if (!m_hasChildren) {
64
 
        m_button->setText(m_button->text() % ' ' % QString::fromUtf8("➜"));
65
 
    }
66
 
 
67
 
    m_childItem = child;
68
 
    // Setting a null crumb pointer would technically make this false...
69
 
    m_hasChildren = true;
70
 
}
71
 
 
72
 
void BreadcrumbItem::setAssociatedView(AbstractViewBase *view)
73
 
{
74
 
    m_associatedView = view;
75
 
}
76
 
 
77
 
void BreadcrumbItem::setText(const QString &text)
78
 
{
79
 
    m_button->setText(text);
80
 
}
81
 
 
82
 
void BreadcrumbItem::setIcon(const QIcon &icon)
83
 
{
84
 
    m_button->setIcon(icon);
85
 
}
86
 
 
87
 
void BreadcrumbItem::setActive(bool active)
88
 
{
89
 
    m_button->setActive(active);
90
 
}
91
 
 
92
 
void BreadcrumbItem::emitActivated()
93
 
{
94
 
    emit activated(this);
95
 
}
96
 
 
97
 
#include "BreadcrumbItem.moc"