File indexing completed on 2024-04-28 05:27:04

0001 /* This file is part of the KDE project
0002    SPDX-FileCopyrightText: 2003 Waldo Bastian <bastian@kde.org>
0003    SPDX-FileCopyrightText: 2003 David Faure <faure@kde.org>
0004    SPDX-FileCopyrightText: 2002 Daniel Molkentin <molkentin@kde.org>
0005 
0006    SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
0007 */
0008 
0009 #ifndef _KSERVICELISTWIDGET_H
0010 #define _KSERVICELISTWIDGET_H
0011 
0012 #include <QGroupBox>
0013 #include <QListWidget>
0014 
0015 #include <KPluginMetaData>
0016 #include <kpluginmetadata.h>
0017 #include <kservice.h>
0018 
0019 class QPushButton;
0020 
0021 class MimeTypeData;
0022 class KService;
0023 
0024 class KServiceListItem : public QListWidgetItem
0025 {
0026 public:
0027     explicit KServiceListItem(const KService::Ptr &pService);
0028     QString storageId;
0029     QString desktopPath;
0030     QString localPath;
0031 };
0032 
0033 class PluginListItem : public QListWidgetItem
0034 {
0035 public:
0036     PluginListItem(const KPluginMetaData &data);
0037     KPluginMetaData metaData;
0038 };
0039 
0040 /**
0041  * This widget holds a list of services, with 6 buttons to manage it.
0042  * It's a separate class so that it can be used by both tabs of the
0043  * module, once for applications and once for services.
0044  * The "kind" is determined by the argument given to the constructor.
0045  */
0046 class KServiceListWidget : public QGroupBox
0047 {
0048     Q_OBJECT
0049 public:
0050     enum Kind {
0051         SERVICELIST_APPLICATIONS,
0052         SERVICELIST_SERVICES,
0053     };
0054     explicit KServiceListWidget(Kind kind, QWidget *parent = nullptr);
0055 
0056     void setMimeTypeData(MimeTypeData *item);
0057 
0058     void allowMultiApply(bool allow);
0059 
0060 Q_SIGNALS:
0061     void changed(bool);
0062     void multiApply(int kind);
0063 
0064 protected Q_SLOTS:
0065     void promoteService();
0066     void demoteService();
0067     void addService();
0068     void editService();
0069     void removeService();
0070     void applyTo();
0071     void enableMoveButtons();
0072 
0073 protected:
0074     void updatePreferredServices();
0075 
0076 private:
0077     Kind m_kind;
0078     QListWidget *servicesLB;
0079     QPushButton *servUpButton, *servDownButton;
0080     QPushButton *servNewButton, *servEditButton, *servRemoveButton;
0081     QPushButton *servApplyToButton;
0082     MimeTypeData *m_mimeTypeData;
0083     bool m_allowMultiApply;
0084 };
0085 
0086 #endif