swift
Loading...
Searching...
No Matches
ecosystemcombobox.cpp
1// SPDX-FileCopyrightText: Copyright (C) 2017 swift Project Community / Contributors
2// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3
4#include "ecosystemcombobox.h"
5
7
8using namespace swift::misc::network;
9
10namespace swift::gui
11{
13
15 : QComboBox(parent), m_systems(systems)
16 {
17 this->initAllItems();
18 }
19
21 {
22 if (this->currentIndex() < 0 || this->currentIndex() >= m_systems.size())
23 {
24 return {};
25 }
26 return m_systems[this->currentIndex()];
27 }
28
30 {
31 if (m_systems.contains(ecosystem))
32 {
33 this->setCurrentText(ecosystem.getSystemString());
34 }
35 }
36
38 {
39 m_systems = systems;
40 this->initAllItems();
41 }
42
43 void CEcosystemComboBox::initAllItems()
44 {
45 this->clear();
46 for (const CEcosystem &e : m_systems)
47 {
48 this->addItem(e.getSystemString());
49 }
50 }
51} // namespace swift::gui
swift::misc::network::CEcosystem getSelectedEcosystem() const
The selected ecosystem.
CEcosystemComboBox(QWidget *parent=nullptr)
Constructor.
void setCurrentEcosystem(const swift::misc::network::CEcosystem &ecosystem)
Set current system.
void setEcosystems(const swift::misc::network::CEcosystemList &systems)
Set the supported systems.
Ecosystem of server belonging together.
Definition ecosystem.h:21
const QString & getSystemString() const
Get the system string.
Definition ecosystem.cpp:38
Value object encapsulating a list of voice rooms.
GUI related classes.
QComboBox(QWidget *parent)
void addItem(const QIcon &icon, const QString &text, const QVariant &userData)
void clear()
void setCurrentText(const QString &text)
QObject * parent() const const
QWidget(QWidget *parent, Qt::WindowFlags f)