Messagelib

dkimmanagerkeywidget.cpp
1/*
2 SPDX-FileCopyrightText: 2018-2024 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "dkimmanagerkeywidget.h"
8#include "dkimmanagerkey.h"
9#include "dkimmanagerkeymodel.h"
10#include "dkimmanagerkeytreeview.h"
11
12#include <KLineEditEventHandler>
13#include <KLocalizedString>
14#include <QHeaderView>
15#include <QLineEdit>
16#include <QVBoxLayout>
17
18using namespace MessageViewer;
19DKIMManagerKeyWidget::DKIMManagerKeyWidget(QWidget *parent)
20 : QWidget(parent)
21 , mDKIMManagerKeyTreeView(new DKIMManagerKeyTreeView(this))
22{
23 auto mainLayout = new QVBoxLayout(this);
24 mainLayout->setObjectName(QLatin1StringView("mainlayout"));
25 mainLayout->setContentsMargins({});
26
27 mDKIMManagerKeyTreeView->setObjectName(QLatin1StringView("mDKIMManagerKeyTreeView"));
28
29 auto searchLineEdit = new QLineEdit(this);
31 searchLineEdit->setObjectName(QLatin1StringView("searchlineedit"));
32 searchLineEdit->setClearButtonEnabled(true);
33 searchLineEdit->setPlaceholderText(i18nc("@info:placeholder", "Search..."));
34 mainLayout->addWidget(searchLineEdit);
35 connect(searchLineEdit, &QLineEdit::textChanged, mDKIMManagerKeyTreeView, &DKIMManagerKeyTreeView::setFilterStr);
36
37 mainLayout->addWidget(mDKIMManagerKeyTreeView);
38}
39
40DKIMManagerKeyWidget::~DKIMManagerKeyWidget() = default;
41
42QByteArray DKIMManagerKeyWidget::saveHeaders() const
43{
44 return mDKIMManagerKeyTreeView->header()->saveState();
45}
46
47void DKIMManagerKeyWidget::restoreHeaders(const QByteArray &header)
48{
49 mDKIMManagerKeyTreeView->header()->restoreState(header);
50}
51
52void DKIMManagerKeyWidget::loadKeys()
53{
54 auto model = new DKIMManagerKeyModel(this);
55 model->setKeyInfos(DKIMManagerKey::self()->keys());
56 mDKIMManagerKeyTreeView->setKeyModel(model);
57}
58
59void DKIMManagerKeyWidget::saveKeys()
60{
61 DKIMManagerKey::self()->saveKeys(mDKIMManagerKeyTreeView->keyInfos());
62}
63
64void DKIMManagerKeyWidget::resetKeys()
65{
66 mDKIMManagerKeyTreeView->clear();
67 loadKeys();
68}
69
70#include "moc_dkimmanagerkeywidget.cpp"
QString i18nc(const char *context, const char *text, const TYPE &arg...)
void catchReturnKey(QObject *lineEdit)
bool restoreState(const QByteArray &state)
QByteArray saveState() const const
void textChanged(const QString &text)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
QHeaderView * header() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jul 12 2024 11:49:56 by doxygen 1.11.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.