swift
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 
8 using namespace swift::misc::network;
9 
10 namespace swift::gui
11 {
12  CEcosystemComboBox::CEcosystemComboBox(QWidget *parent) : QComboBox(parent) { this->initAllItems(); }
13 
14  CEcosystemComboBox::CEcosystemComboBox(const CEcosystemList &systems, QWidget *parent)
15  : QComboBox(parent), m_systems(systems)
16  {
17  this->initAllItems();
18  }
19 
21  {
22  if (this->currentIndex() < 0 || this->currentIndex() >= m_systems.size()) { return CEcosystem(); }
23  return m_systems[this->currentIndex()];
24  }
25 
27  {
28  if (m_systems.contains(ecosystem)) { this->setCurrentText(ecosystem.getSystemString()); }
29  }
30 
32  {
33  m_systems = systems;
34  this->initAllItems();
35  }
36 
37  void CEcosystemComboBox::initAllItems()
38  {
39  this->clear();
40  for (const CEcosystem &e : m_systems) { this->addItem(e.getSystemString()); }
41  }
42 } // 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.
bool contains(const T &object) const
Return true if there is an element equal to given object. Uses the most efficient implementation avai...
Definition: range.h:109
size_type size() const
Returns number of elements in the sequence.
Definition: sequence.h:273
Ecosystem of server belonging together.
Definition: ecosystem.h:21
const QString & getSystemString() const
Get the system string.
Definition: ecosystem.cpp:50
Value object encapsulating a list of voice rooms.
Definition: ecosystemlist.h:25
GUI related classes.