File indexing completed on 2024-05-19 16:31:57
0001 /* 0002 * SPDX-FileCopyrightText: 2009 David Hubner <hubnerd@ntlworld.com> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 * 0006 */ 0007 0008 #ifndef DEVICELISTING 0009 #define DEVICELISTING 0010 0011 // QT 0012 #include <QMap> 0013 #include <QTreeWidget> 0014 #include <QTreeWidgetItemIterator> 0015 0016 // Local 0017 #include "soldevice.h" 0018 0019 // Kde 0020 0021 class InfoPanel; 0022 class DevInfoPlugin; 0023 class QContextMenuEvent; 0024 class QAction; 0025 0026 class DeviceListing : public QTreeWidget 0027 { 0028 Q_OBJECT 0029 0030 private: 0031 enum show { 0032 ALL = 0, 0033 RELEVANT, 0034 }; 0035 0036 public: 0037 DeviceListing(QWidget *, InfoPanel *, DevInfoPlugin *); 0038 ~DeviceListing() override; 0039 0040 static QTreeWidgetItem *getTreeWidgetItemFromUdi(QTreeWidget *widget, const QString &udi) 0041 { 0042 QTreeWidgetItemIterator treeWidget(widget); 0043 while (*treeWidget) { 0044 SolDevice *item = static_cast<SolDevice *>(*treeWidget); 0045 if (item->udi() == udi) { 0046 return *treeWidget; 0047 } 0048 ++treeWidget; 0049 } 0050 return nullptr; 0051 } 0052 0053 private: 0054 void populateListing(const show = RELEVANT); 0055 QTreeWidgetItem *createListItems(const Solid::DeviceInterface::Type &); 0056 void contextMenuEvent(QContextMenuEvent *) override; 0057 void createMenuActions(); 0058 0059 QMap<Solid::DeviceInterface::Type, SolDevice *> deviceMap; 0060 InfoPanel *iPanel = nullptr; 0061 QAction *colAct = nullptr; 0062 QAction *expAct = nullptr; 0063 QAction *allAct = nullptr; 0064 QAction *relAct = nullptr; 0065 DevInfoPlugin *status = nullptr; 0066 // NicSignals *nicSig; 0067 0068 public Q_SLOTS: 0069 void currentItemChangedSlot(QTreeWidgetItem *, QTreeWidgetItem *); 0070 void deviceAddedSlot(const QString &); 0071 void deviceRemovedSlot(const QString &); 0072 void collapseAllDevicesSlot(); 0073 void expandAllDevicesSlot(); 0074 void showAllDevicesSlot(); 0075 void showRelevantDevicesSlot(); 0076 }; 0077 0078 #endif // DEVICELISTING