]> cloud.milkyroute.net Git - dolphin.git/blob - src/kitemviews/kitemlistheader.h
Move the KVersionControlPlugin2 interface from konqlib to Dolphin and remove the...
[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 #include <QHash>
25 #include <QObject>
26
27 class KItemListHeaderWidget;
28 class KItemListView;
29
30 /**
31 * @brief Provides access to the header of a KItemListView.
32 *
33 * Each column of the header represents a visible role
34 * accessible by KItemListView::visibleRoles().
35 */
36 class DOLPHIN_EXPORT KItemListHeader : public QObject
37 {
38 Q_OBJECT
39
40 public:
41 virtual ~KItemListHeader();
42
43 /**
44 * If set to true, KItemListView will automatically adjust the
45 * widths of the columns. If set to false, the size can be
46 * manually adjusted by KItemListHeader::setColumnWidth().
47 */
48 void setAutomaticColumnResizing(bool automatic);
49 bool automaticColumnResizing() const;
50
51 /**
52 * Sets the width of the column for the given role. Note that
53 * the width only gets applied if KItemListHeader::automaticColumnResizing()
54 * has been turned off.
55 */
56 void setColumnWidth(const QByteArray& role, qreal width);
57 qreal columnWidth(const QByteArray& role) const;
58
59 /**
60 * Sets the widths of the columns for all roles. From a performance point of
61 * view calling this method should be preferred over several setColumnWidth()
62 * calls in case if the width of more than one column should be changed.
63 * Note that the widths only get applied if KItemListHeader::automaticColumnResizing()
64 * has been turned off.
65 */
66 void setColumnWidths(const QHash<QByteArray, qreal>& columnWidths);
67
68 /**
69 * @return The column width that is required to show the role unclipped.
70 */
71 qreal preferredColumnWidth(const QByteArray& role) const;
72
73 signals:
74 /**
75 * Is emitted if the width of a column has been adjusted by the user with the mouse
76 * (no signal is emitted if KItemListHeader::setColumnWidth() is invoked).
77 */
78 void columnWidthChanged(const QByteArray& role,
79 qreal currentWidth,
80 qreal previousWidth);
81
82 private:
83 KItemListHeader(KItemListView* listView);
84
85 private:
86 KItemListView* m_view;
87 KItemListHeaderWidget* m_headerWidget;
88
89 friend class KItemListView; // Constructs the KItemListHeader instance
90 };
91
92 #endif
93
94