MailTransport

transporttreeview.cpp
1/*
2 SPDX-FileCopyrightText: 2024 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "transporttreeview.h"
8#include "transportmodel.h"
9#include "transportsortproxymodel.h"
10#include "transporttreedelegate.h"
11#include <QHeaderView>
12
13using namespace MailTransport;
14TransportTreeView::TransportTreeView(QWidget *parent)
15 : QTreeView(parent)
16 , mTransportSortProxyModel(new TransportSortProxyModel(this))
17{
18 setAlternatingRowColors(true);
19 setSelectionMode(SingleSelection);
20 setContextMenuPolicy(Qt::CustomContextMenu);
21 setSelectionBehavior(QAbstractItemView::SelectRows);
22 setRootIsDecorated(false);
23 setSortingEnabled(true);
24 setEditTriggers(QAbstractItemView::EditKeyPressed);
25 setAllColumnsShowFocus(true);
26 header()->setSectionsMovable(false);
27 header()->setSectionResizeMode(QHeaderView::ResizeToContents);
28
29 auto model = new MailTransport::TransportModel(this);
30
31 model->setShowDefault(true);
32 mTransportSortProxyModel->setSourceModel(model);
33 setModel(mTransportSortProxyModel);
34
35 setColumnHidden(MailTransport::TransportModel::TransportIdentifierRole, true);
36 setColumnHidden(MailTransport::TransportModel::DefaultRole, true);
37 setColumnHidden(MailTransport::TransportModel::ActivitiesRole, true);
38 setColumnHidden(MailTransport::TransportModel::EnabledActivitiesRole, true);
39 setItemDelegateForColumn(MailTransport::TransportModel::NameRole, new TransportTreeDelegate(this));
40 setUniformRowHeights(true);
41}
42
43TransportTreeView::~TransportTreeView() = default;
44
45TransportActivitiesAbstract *TransportTreeView::transportActivitiesAbstract() const
46{
47 return mTransportSortProxyModel->transportActivitiesAbstract();
48}
49
50void TransportTreeView::setTransportActivitiesAbstract(TransportActivitiesAbstract *activitiesAbstract)
51{
52 mTransportSortProxyModel->setTransportActivitiesAbstract(activitiesAbstract);
53}
54
55TransportSortProxyModel *TransportTreeView::transportSortProxyModel() const
56{
57 return mTransportSortProxyModel;
58}
59
60bool TransportTreeView::enablePlasmaActivities() const
61{
62 return mTransportSortProxyModel->enablePlasmaActivities();
63}
64
65void TransportTreeView::setEnablePlasmaActivities(bool newEnablePlasmaActivities)
66{
67 mTransportSortProxyModel->setEnablePlasmaActivities(newEnablePlasmaActivities);
68}
69
70#include "moc_transporttreeview.cpp"
CustomContextMenu
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 22 2024 12:07:33 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.