File indexing completed on 2024-04-28 05:46:32

0001 /*
0002     SPDX-FileCopyrightText: 2009-2010 Volker Lanz <vl@fidra.de>
0003     SPDX-FileCopyrightText: 2014-2017 Andrius Štikonas <andrius@stikonas.eu>
0004     SPDX-FileCopyrightText: 2019 Yuri Chornoivan <yurchor@ukr.net>
0005 
0006     SPDX-License-Identifier: GPL-3.0-or-later
0007 */
0008 
0009 #if !defined(LISTDEVICES_H)
0010 
0011 #define LISTDEVICES_H
0012 
0013 #include <core/operationstack.h>
0014 
0015 #include "ui_listdevicesbase.h"
0016 
0017 #include <QWidget>
0018 
0019 class Device;
0020 class QPoint;
0021 class KActionCollection;
0022 
0023 /** A list of devices.
0024     @author Volker Lanz <vl@fidra.de>
0025 */
0026 class ListDevices : public QWidget, public Ui::ListDevicesBase
0027 {
0028     Q_OBJECT
0029     Q_DISABLE_COPY(ListDevices)
0030 
0031 public:
0032     explicit ListDevices(QWidget* parent = nullptr);
0033 
0034 Q_SIGNALS:
0035     void selectionChanged(const QString& device_node);
0036     void deviceDoubleClicked(const QString& device_node);
0037 
0038 public:
0039     void setActionCollection(KActionCollection* coll) {
0040         m_ActionCollection = coll;
0041     }
0042 
0043     // Selects the device specified by the device node, such as /dev/sda
0044     bool setSelectedDevice(const QString& device_node);
0045 
0046     void updateDevices(const OperationStack::Devices& devices);
0047 
0048     QListWidget& listDevices() {
0049         Q_ASSERT(m_ListDevices);
0050         return *m_ListDevices;
0051     }
0052 protected:
0053     const QListWidget& listDevices() const {
0054         Q_ASSERT(m_ListDevices);
0055         return *m_ListDevices;
0056     }
0057     KActionCollection* actionCollection() {
0058         return m_ActionCollection;
0059     }
0060 
0061     void customContextMenuRequested(const QPoint& pos);
0062 
0063 protected Q_SLOTS:
0064     void on_m_ListDevices_itemSelectionChanged();
0065     void on_m_ListDevices_itemDoubleClicked(QListWidgetItem* list_item);
0066 
0067 private:
0068     KActionCollection* m_ActionCollection;
0069 };
0070 
0071 #endif
0072