Messagelib

remotecontentstatustypecombobox.cpp
1/*
2 SPDX-FileCopyrightText: 2021-2024 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6#include "remotecontentstatustypecombobox.h"
7#include <KLocalizedString>
8using namespace MessageViewer;
9RemoteContentStatusTypeComboBox::RemoteContentStatusTypeComboBox(QWidget *parent)
10 : QComboBox(parent)
11{
12 addItem(i18n("Authorized"), QVariant::fromValue(RemoteContentInfo::RemoteContentInfoStatus::Authorized));
13 addItem(i18n("Blocked"), QVariant::fromValue(RemoteContentInfo::RemoteContentInfoStatus::Blocked));
14}
15
16RemoteContentStatusTypeComboBox::~RemoteContentStatusTypeComboBox() = default;
17
18void RemoteContentStatusTypeComboBox::setStatus(MessageViewer::RemoteContentInfo::RemoteContentInfoStatus type)
19{
20 const int index = findData(QVariant::fromValue(type));
21 if (index != -1) {
22 setCurrentIndex(index);
23 }
24}
25
26RemoteContentInfo::RemoteContentInfoStatus RemoteContentStatusTypeComboBox::status() const
27{
28 return currentData().value<RemoteContentInfo::RemoteContentInfoStatus>();
29}
30
31#include "moc_remotecontentstatustypecombobox.cpp"
QString i18n(const char *text, const TYPE &arg...)
void setCurrentIndex(int index)
int findData(const QVariant &data, int role, Qt::MatchFlags flags) const const
QVariant fromValue(T &&value)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:07:25 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.