]> cloud.milkyroute.net Git - dolphin.git/blob - src/kitemviews/kitemlistheader.h
Remove unused #include
[dolphin.git] / src / kitemviews / kitemlistheader.h
1 /***************************************************************************
2 * Copyright (C) 2012 by Peter Penz <peter.penz19@gmail.com> *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
19
20 #ifndef KITEMLISTHEADER_H
21 #define KITEMLISTHEADER_H
22
23 #include "dolphin_export.h"
24
25 #include <QHash>
26 #include <QObject>
27
28 class KItemListHeaderWidget;
29 class KItemListView;
30
31 /**
32 * @brief Provides access to the header of a KItemListView.
33 *
34 * Each column of the header represents a visible role
35 * accessible by KItemListView::visibleRoles().
36 */
37 class DOLPHIN_EXPORT KItemListHeader : public QObject
38 {
39 Q_OBJECT
40
41 public:
42 ~KItemListHeader() override;
43
44 /**
45 * If set to true, KItemListView will automatically adjust the
46 * widths of the columns. If set to false, the size can be
47 * manually adjusted by KItemListHeader::setColumnWidth().
48 */
49 void setAutomaticColumnResizing(bool automatic);
50 bool automaticColumnResizing() const;
51
52 /**
53 * Sets the width of the column for the given role. Note that
54 * the width only gets applied if KItemListHeader::automaticColumnResizing()
55 * has been turned off.
56 */
57 void setColumnWidth(const QByteArray& role, qreal width);
58 qreal columnWidth(const QByteArray& role) const;
59
60 /**
61 * Sets the widths of the columns for all roles. From a performance point of
62 * view calling this method should be preferred over several setColumnWidth()
63 * calls in case if the width of more than one column should be changed.
64 * Note that the widths only get applied if KItemListHeader::automaticColumnResizing()
65 * has been turned off.
66 */
67 void setColumnWidths(const QHash<QByteArray, qreal>& columnWidths);
68
69 /**
70 * @return The column width that is required to show the role unclipped.
71 */
72 qreal preferredColumnWidth(const QByteArray& role) const;
73
74 signals:
75 /**
76 * Is emitted if the width of a column has been adjusted by the user with the mouse
77 * (no signal is emitted if KItemListHeader::setColumnWidth() is invoked).
78 */
79 void columnWidthChanged(const QByteArray& role,
80 qreal currentWidth,
81 qreal previousWidth);
82
83 /**
84 * Is emitted if the user has released the mouse button after adjusting the
85 * width of a visible role.
86 */
87 void columnWidthChangeFinished(const QByteArray& role,
88 qreal currentWidth);
89
90 private:
91 explicit KItemListHeader(KItemListView* listView);
92
93 private:
94 KItemListView* m_view;
95 KItemListHeaderWidget* m_headerWidget;
96
97 friend class KItemListView; // Constructs the KItemListHeader instance
98 };
99
100 #endif
101
102