1 /***************************************************************************
2 * Copyright (C) 2012 by Peter Penz <peter.penz19@gmail.com> *
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. *
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. *
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 ***************************************************************************/
20 #ifndef KITEMLISTHEADER_H
21 #define KITEMLISTHEADER_H
23 #include "dolphin_export.h"
28 class KItemListHeaderWidget
;
32 * @brief Provides access to the header of a KItemListView.
34 * Each column of the header represents a visible role
35 * accessible by KItemListView::visibleRoles().
37 class DOLPHIN_EXPORT KItemListHeader
: public QObject
42 ~KItemListHeader() override
;
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().
49 void setAutomaticColumnResizing(bool automatic
);
50 bool automaticColumnResizing() const;
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.
57 void setColumnWidth(const QByteArray
& role
, qreal width
);
58 qreal
columnWidth(const QByteArray
& role
) const;
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.
67 void setColumnWidths(const QHash
<QByteArray
, qreal
>& columnWidths
);
70 * @return The column width that is required to show the role unclipped.
72 qreal
preferredColumnWidth(const QByteArray
& role
) const;
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).
79 void columnWidthChanged(const QByteArray
& role
,
84 * Is emitted if the user has released the mouse button after adjusting the
85 * width of a visible role.
87 void columnWidthChangeFinished(const QByteArray
& role
,
91 explicit KItemListHeader(KItemListView
* listView
);
94 KItemListView
* m_view
;
95 KItemListHeaderWidget
* m_headerWidget
;
97 friend class KItemListView
; // Constructs the KItemListHeader instance