File indexing completed on 2024-10-06 05:14:11

0001 /*
0002     SPDX-FileCopyrightText: 1998 Michael Kropfberger <michael.kropfberger@gmx.net>
0003     SPDX-FileCopyrightText: 2009 Dario Andres Rodriguez <andresbajotierra@gmail.com>
0004 
0005     SPDX-License-Identifier: GPL-2.0-or-later
0006 */
0007 
0008 #ifndef KDFWIDGET_H
0009 #define KDFWIDGET_H
0010 
0011 #include "kdfprivate_export.h"
0012 #include "disks.h"
0013 #include "disklist.h"
0014 #include "mntconfig.h"
0015 #include "kdfconfig.h"
0016 #include "stdoption.h"
0017 #include "kdfitemdelegate.h"
0018 #include "kdfsortproxymodel.h"
0019 
0020 class QTreeView;
0021 class QTimer;
0022 class COptionDialog;
0023 
0024 class QStandardItemModel;
0025 
0026 /* Column class (id, column number, column name) */
0027 class Column
0028 {
0029     public:
0030 
0031     Column(const QString& _name, const QString& _columnName, int _defaultWidth, int _number)
0032     {
0033         name = _name;
0034         columnName = _columnName;
0035         defaultWidth = _defaultWidth;
0036         number = _number;
0037     }
0038 
0039     QString name;
0040     QString columnName;
0041     int defaultWidth;
0042     int number;
0043 
0044 };
0045 
0046 class KDFPRIVATE_EXPORT KDFWidget : public QWidget
0047 {
0048     Q_OBJECT
0049 
0050     public:
0051         explicit KDFWidget( QWidget *parent=nullptr, bool init=false);
0052         ~KDFWidget( ) override;
0053 
0054         enum ColumnNumber{
0055             IconCol = 0,
0056             DeviceCol = 1,
0057             TypeCol = 2,
0058             SizeCol = 3,
0059             MountPointCol = 4,
0060             FreeCol = 5,
0061             FullCol = 6,
0062             UsageBarCol = 7
0063         };
0064 
0065     public Q_SLOTS:
0066         void settingsChanged( void );
0067         void loadSettings( void );
0068         void applySettings( void );
0069         void updateDF( void );
0070         void updateDFDone( void );
0071         void settingsBtnClicked( void );
0072 
0073     private Q_SLOTS:
0074         void criticallyFull( DiskEntry *disk );
0075         void contextMenuRequested ( const QPoint &p );
0076         void setUpdateFrequency( int frequency );
0077         void invokeHelp( void );
0078 
0079     protected:
0080         void timerEvent( QTimerEvent * ) override;
0081         void closeEvent( QCloseEvent * ) override;
0082 
0083     private:
0084         void makeColumns( void );
0085         DiskEntry *selectedDisk( const QModelIndex &index );
0086         QIcon generateIcon( const QString &iconName , bool mode, bool mounted);
0087 
0088         bool readingDF;
0089         COptionDialog *mOptionDialog = nullptr;
0090         QMenu    *mPopup = nullptr;
0091         QTimer        *mTimer = nullptr;
0092         DiskList   mDiskList;
0093         bool       mIsTopLevel;
0094         CStdOption mStd;
0095 
0096         QTreeView * m_listWidget = nullptr;
0097         KDFItemDelegate * m_itemDelegate = nullptr;
0098         QList<Column> m_columnList;
0099 
0100         QStandardItemModel * m_listModel = nullptr;
0101         KDFSortFilterProxyModel * m_sortModel = nullptr;
0102 };
0103 
0104 #endif
0105