File indexing completed on 2024-12-08 04:34:24
0001 /* 0002 SPDX-FileCopyrightText: 2023-2024 Laurent Montel <montel.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "serverscombobox.h" 0008 #include <KLocalizedString> 0009 0010 ServersComboBox::ServersComboBox(QWidget *parent) 0011 : QComboBox(parent) 0012 { 0013 connect(this, &QComboBox::activated, this, &ServersComboBox::slotSelectAccount); 0014 } 0015 0016 ServersComboBox::~ServersComboBox() = default; 0017 0018 void ServersComboBox::addServerList(const QStringList &serverNames) 0019 { 0020 addItem(i18n("Filter Account..."), QString()); 0021 for (const auto &account : serverNames) { 0022 addItem(account, account); 0023 } 0024 setSizeAdjustPolicy(QComboBox::AdjustToContents); 0025 } 0026 0027 void ServersComboBox::slotSelectAccount(int index) 0028 { 0029 if (index != -1) { 0030 const QString accountName = itemData(index).toString(); 0031 Q_EMIT accountSelected(accountName); 0032 } 0033 } 0034 0035 #include "moc_serverscombobox.cpp"