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

0001 /*
0002     SPDX-FileCopyrightText: 1998-2008 Sebastian Trueg <trueg@k3b.org>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 
0008 #ifndef _K3B_MEDIA_CONTENTS_VIEW_H_
0009 #define _K3B_MEDIA_CONTENTS_VIEW_H_
0010 
0011 #include "k3bcontentsview.h"
0012 #include "k3bthememanager.h"
0013 #include "k3bmedium.h"
0014 
0015 
0016 
0017 /**
0018  * Abstract class from which all cd views must be derived. The contents view automatically handles medium changes for
0019  * the selected device and reloads the contents if a new usable medium is inserted or disables the controls if the
0020  * medium is just ejected. For this to work the proper content types have to be set.
0021  *
0022  * TODO: how about giving this one a KActionCollection so it can handle the toolbar automatically
0023  */
0024 namespace K3b {
0025     class MediaContentsView : public ContentsView
0026     {
0027         Q_OBJECT
0028 
0029     public:
0030         ~MediaContentsView() override;
0031 
0032         Medium medium() const;
0033 
0034         /**
0035          * Equals medium().device()
0036          */
0037         Device::Device* device() const;
0038 
0039         /**
0040          * \return A bitwise or of Medium::ContentType which
0041          * represents the content types that can be displayed by this
0042          * medium view.
0043          */
0044         int supportedMediumContent() const;
0045         int supportedMediumTypes() const;
0046         int supportedMediumStates() const;
0047 
0048     public Q_SLOTS:
0049         /**
0050          * Does some internal stuff and calls reloadMedium.
0051          * Normally there is no need to call this manually.
0052          */
0053         void reload();
0054 
0055         /**
0056          * Has the same effect as reload( k3bappcore->mediaCache()->medium( dev ) );
0057          */
0058         void reload( K3b::Device::Device* dev );
0059 
0060         /**
0061          * Has the same effect as setMedium( m ), reload()
0062          */
0063         void reload( const K3b::Medium& m );
0064 
0065         /**
0066          * Enable or disable auto reloading when a new medium is inserted.
0067          * If enabled (the default) the view will be reloaded if a new usable
0068          * (as determined by the supportedXXX methods) medium has been inserted
0069          * into the current device.
0070          */
0071         void setAutoReload( bool b );
0072 
0073         /**
0074          * Enable or disable the controls of this view.
0075          * The default implementation simply disables the whole window
0076          */
0077         virtual void enableInteraction( bool enable );
0078 
0079     protected:
0080         MediaContentsView( bool withHeader,
0081                            int mediumContent,
0082                            int mediumTypes,
0083                            int mediumState,
0084                            QWidget* parent = 0 );
0085 
0086         /**
0087          * Changes the medium without reloading the contents.
0088          * Do not use, use reload( const Medium& ) instead.
0089          */
0090         void setMedium( const Medium& );
0091 
0092         /**
0093          * Called by reload. Reimplement to actually display
0094          * the contents of the medium.
0095          */
0096         virtual void reloadMedium() = 0;
0097 
0098     private Q_SLOTS:
0099         void slotMediumChanged( K3b::Device::Device* );
0100 
0101     private:
0102         class Private;
0103         Private* d;
0104     };
0105 }
0106 
0107 #endif