File indexing completed on 2024-10-06 04:26:01

0001 /*
0002     SPDX-FileCopyrightText: 2005-2009 Sebastian Trueg <trueg@k3b.org>
0003     SPDX-FileCopyrightText: 1998-2009 Sebastian Trueg <trueg@k3b.org>
0004 
0005     SPDX-License-Identifier: GPL-2.0-or-later
0006 */
0007 
0008 #ifndef _K3B_MEDIA_SELECTION_COMBOBOX_H_
0009 #define _K3B_MEDIA_SELECTION_COMBOBOX_H_
0010 
0011 #include "k3bmedium.h"
0012 #include <KComboBox>
0013 #include <QList>
0014 
0015 namespace K3b {
0016     namespace Device {
0017         class Device;
0018         class DeviceManager;
0019     }
0020     class Msf;
0021 
0022     /**
0023      * Combo box which allows one to select a media (in comparison
0024      * to the DeviceComboBox which allows one to select a device.
0025      *
0026      * This class uses the MediaCache to update it's status.
0027      */
0028     class MediaSelectionComboBox : public KComboBox
0029     {
0030         Q_OBJECT
0031 
0032     public:
0033         explicit MediaSelectionComboBox( QWidget* parent );
0034         ~MediaSelectionComboBox() override;
0035 
0036         /**
0037          * Although the widget allows selection of media this
0038          * results in a device being selected.
0039          */
0040         Device::Device* selectedDevice() const;
0041 
0042         QList<Device::Device*> allDevices() const;
0043 
0044         Device::MediaTypes wantedMediumType() const;
0045         Device::MediaStates wantedMediumState() const;
0046         Medium::MediumContents wantedMediumContent() const;
0047         K3b::Msf wantedMediumSize() const;
0048 
0049     Q_SIGNALS:
0050         /**
0051          * Be aware that his signal will also be emitted in case
0052          * no medium is available with a null pointer.
0053          */
0054         void selectionChanged( K3b::Device::Device* );
0055 
0056         /**
0057          * This signal is emitted if the selection of media changed.
0058          * This includes a change due to changing the wanted medium state.
0059          */
0060         void newMedia();
0061 
0062         void newMedium( K3b::Device::Device* dev );
0063 
0064     public Q_SLOTS:
0065         /**
0066          * Only works in case the device actually contains a usable medium.
0067          * Otherwise the currently selected medium stays selected.
0068          */
0069         void setSelectedDevice( K3b::Device::Device* );
0070 
0071         /**
0072          * Set the wanted medium type. Defaults to writable CD.
0073          *
0074          * \param type a bitwise combination of the Device::MediaType enum
0075          */
0076         void setWantedMediumType( K3b::Device::MediaTypes type );
0077 
0078         /**
0079          * Set the wanted medium state. Defaults to empty media.
0080          *
0081          * \param state a bitwise combination of the Device::State enum
0082          */
0083         void setWantedMediumState( K3b::Device::MediaStates state );
0084 
0085         /**
0086          * Set the wanted medium content type. The default is Medium::ContentAll.
0087          *
0088          * \param content A bitwise or of Medium::MediumContent
0089          */
0090         void setWantedMediumContent( K3b::Medium::MediumContents content );
0091 
0092         /**
0093          * Set the wanted medium size. Defaults to 0 which means
0094          * that the size should be irgnored.
0095          */
0096         void setWantedMediumSize( const K3b::Msf& minSize );
0097 
0098         /**
0099          * Set the device to ignore. This device will not be checked for
0100          * wanted media. This is many useful for media copy.
0101          *
0102          * \param dev The device to ignore or 0 to not ignore any device.
0103          */
0104         void setIgnoreDevice( K3b::Device::Device* dev );
0105 
0106     private Q_SLOTS:
0107         void slotMediumChanged( K3b::Device::Device* );
0108         void slotDeviceManagerChanged( K3b::Device::DeviceManager* );
0109         void slotActivated( int i );
0110         void slotUpdateToolTip( K3b::Device::Device* );
0111 
0112     protected:
0113         void updateMedia();
0114         virtual bool showMedium( const Medium& ) const;
0115         virtual QString mediumString( const Medium& ) const;
0116         virtual QString mediumToolTip( const Medium& ) const;
0117         virtual QString noMediumMessage() const;
0118         QStringList noMediumMessages() const;
0119 
0120     private:
0121         void updateMedium( Device::Device* );
0122         void addMedium( Device::Device* );
0123         void showNoMediumMessage();
0124         void clear();
0125 
0126         class Private;
0127         Private* d;
0128     };
0129 }
0130 
0131 #endif