2 * SPDX-FileCopyrightText: 2012 Peter Penz <peter.penz19@gmail.com>
4 * SPDX-License-Identifier: GPL-2.0-or-later
7 #ifndef PLACESITEMLISTWIDGET_H
8 #define PLACESITEMLISTWIDGET_H
10 #include "kitemviews/kstandarditemlistwidget.h"
12 #include <QDeadlineTimer>
15 #include <QStyleOptionGraphicsItem>
18 #include <KIO/FileSystemFreeSpaceJob>
21 // The free space / capacity bar is based on KFilePlacesView.
22 // https://invent.kde.org/frameworks/kio/-/commit/933887dc334f3498505af7a86d25db7faae91019
23 struct PlaceFreeSpaceInfo
25 QDeadlineTimer lastUpdated
;
26 KIO::filesize_t used
= 0;
27 KIO::filesize_t size
= 0;
29 QPointer
<KIO::FileSystemFreeSpaceJob
> job
;
34 * @brief Extends KStandardItemListWidget to interpret the hidden
35 * property of the PlacesModel and use the right text color.
37 class PlacesItemListWidget
: public KStandardItemListWidget
42 PlacesItemListWidget(KItemListWidgetInformant
* informant
, QGraphicsItem
* parent
);
43 ~PlacesItemListWidget() override
;
45 void paint(QPainter
* painter
, const QStyleOptionGraphicsItem
* option
, QWidget
* widget
= nullptr) override
;
46 void polishEvent() override
;
49 bool isHidden() const override
;
50 QPalette::ColorRole
normalTextColorRole() const override
;
51 void updateCapacityBar();
52 void resetCapacityBar();
55 bool m_drawCapacityBar
;
56 PlaceFreeSpaceInfo m_freeSpaceInfo
;