File indexing completed on 2024-09-22 04:47:57

0001 /*
0002   SPDX-FileCopyrightText: 2006-2007 Volker Krause <vkrause@kde.org>
0003 
0004   SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "mailtransport_export.h"
0010 #include "transport.h"
0011 #include "transportbase.h"
0012 
0013 #include <QComboBox>
0014 
0015 #include <memory>
0016 
0017 class TransportComboBoxPrivate;
0018 
0019 namespace MailTransport
0020 {
0021 /**
0022   A combo-box for selecting a mail transport.
0023   It is updated automatically when transports are added, changed, or removed.
0024 */
0025 class MAILTRANSPORT_EXPORT TransportComboBox : public QComboBox
0026 {
0027     Q_OBJECT
0028 public:
0029     /**
0030       Creates a new mail transport selection combo box.
0031       @param parent The paren widget.
0032     */
0033     explicit TransportComboBox(QWidget *parent = nullptr);
0034 
0035     ~TransportComboBox() override;
0036 
0037     /**
0038       Returns identifier of the currently selected mail transport.
0039     */
0040     [[nodiscard]] int currentTransportId() const;
0041 
0042     /**
0043       Selects the given transport.
0044       @param transportId The transport identifier.
0045       @return return true if we success to find transportId
0046     */
0047     bool setCurrentTransport(int transportId);
0048 
0049     /**
0050       Returns the type of the selected transport.
0051     */
0052     [[nodiscard]] QString transportType() const;
0053 
0054 Q_SIGNALS:
0055     void transportRemoved(Transport::Id id, const QString &name);
0056 
0057 protected:
0058     void setTransportList(const QList<int> &transportList);
0059 
0060 public Q_SLOTS:
0061     /**
0062      * @since 4.11
0063      */
0064     void updateComboboxList();
0065 
0066 private:
0067     std::unique_ptr<TransportComboBoxPrivate> const d;
0068 };
0069 } // namespace MailTransport