]> cloud.milkyroute.net Git - dolphin.git/blob - src/views/dolphinitemlistview.h
25476290f60ff2c2e39302ff9b84e12c36f5a8aa
[dolphin.git] / src / views / dolphinitemlistview.h
1 /*
2 * SPDX-FileCopyrightText: 2011 Peter Penz <peter.penz19@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
7 #ifndef DOLPHINITEMLISTVIEW_H
8 #define DOLPHINITEMLISTVIEW_H
9
10 #include "dolphin_export.h"
11 #include "kitemviews/kfileitemlistview.h"
12
13 class KFileItemListView;
14
15 /**
16 * @brief Dolphin specific view-implementation.
17 *
18 * Offers zoom-level support and takes care for translating
19 * the view-properties into the corresponding KItemListView
20 * properties.
21 */
22 class DOLPHIN_EXPORT DolphinItemListView : public KFileItemListView
23 {
24 Q_OBJECT
25
26 public:
27 explicit DolphinItemListView(QGraphicsWidget* parent = nullptr);
28 ~DolphinItemListView() override;
29
30 void setZoomLevel(int level);
31 int zoomLevel() const;
32
33 enum SelectionTogglesEnabled {
34 True,
35 False,
36 FollowSetting
37 };
38 /**
39 * Sets whether the items in this view should show a small selection toggle area on mouse hover.
40 * The default for this view is to follow the "showSelectionToggle" setting but this method can
41 * be used to ignore that setting and force a different value.
42 */
43 void setEnabledSelectionToggles(SelectionTogglesEnabled selectionTogglesEnabled);
44
45 void readSettings();
46 void writeSettings();
47
48 protected:
49 KItemListWidgetCreatorBase* defaultWidgetCreator() const override;
50 /** Overwriting in the Dolphin-specific class because we want this to be user-configurable.
51 * @see KStandardItemListView::itemLayoutHighlightEntireRow */
52 bool itemLayoutHighlightEntireRow(ItemLayout layout) const override;
53 bool itemLayoutSupportsItemExpanding(ItemLayout layout) const override;
54 void onItemLayoutChanged(ItemLayout current, ItemLayout previous) override;
55 void onPreviewsShownChanged(bool shown) override;
56 void onVisibleRolesChanged(const QList<QByteArray>& current,
57 const QList<QByteArray>& previous) override;
58
59 void updateFont() override;
60
61 private:
62 void updateGridSize();
63
64 using KItemListView::setEnabledSelectionToggles; // Makes sure that the setEnabledSelectionToggles() declaration above doesn't hide
65 // the one from the base class so we can still use it privately.
66 SelectionTogglesEnabled m_selectionTogglesEnabled = FollowSetting;
67
68 private:
69 int m_zoomLevel;
70 };
71
72 #endif