File indexing completed on 2024-04-28 16:44:26

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 <kservice.h>
0017 
0018 class QPushButton;
0019 
0020 class MimeTypeData;
0021 class KService;
0022 
0023 class KServiceListItem : public QListWidgetItem
0024 {
0025 public:
0026     KServiceListItem(const KService::Ptr &pService, int kind);
0027     QString storageId;
0028     QString desktopPath;
0029     QString localPath;
0030 };
0031 
0032 class PluginListItem : public QListWidgetItem
0033 {
0034 public:
0035     PluginListItem(const KPluginMetaData &metaData);
0036 };
0037 
0038 /**
0039  * This widget holds a list of services, with 5 buttons to manage it.
0040  * It's a separate class so that it can be used by both tabs of the
0041  * module, once for applications and once for services.
0042  * The "kind" is determined by the argument given to the constructor.
0043  */
0044 class KServiceListWidget : public QGroupBox
0045 {
0046     Q_OBJECT
0047 public:
0048     enum {
0049         SERVICELIST_APPLICATIONS,
0050         SERVICELIST_SERVICES,
0051     };
0052     explicit KServiceListWidget(int kind, QWidget *parent = nullptr);
0053 
0054     void setMimeTypeData(MimeTypeData *item);
0055 
0056 Q_SIGNALS:
0057     void changed(bool);
0058 
0059 protected Q_SLOTS:
0060     void promoteService();
0061     void demoteService();
0062     void addService();
0063     void editService();
0064     void removeService();
0065     void enableMoveButtons();
0066 
0067 protected:
0068     void updatePreferredServices();
0069 
0070 private:
0071     int m_kind;
0072     QListWidget *servicesLB;
0073     QPushButton *servUpButton, *servDownButton;
0074     QPushButton *servNewButton, *servEditButton, *servRemoveButton;
0075     MimeTypeData *m_mimeTypeData;
0076 };
0077 
0078 #endif