┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/kitemviews/kitemlistheader.h
diff options
context:
space:
mode:
authorPeter Penz <[email protected]>2012-03-23 22:26:17 +0100
committerPeter Penz <[email protected]>2012-03-23 22:31:55 +0100
commit3f88f79f862a570b68fe64781955cf7d14124127 (patch)
treeef9231ea05a90c495f2d59970f2c251204e97c22 /src/kitemviews/kitemlistheader.h
parent3fc96ef97bbea25418bb22a18e82f6b874eedb38 (diff)
Details view: Optionally remember user changed column-widths
If the user changed a column-width in the details-view, up to now the width got reset when changing a directory or when restarting Dolphin. Now the column-widths automatically get remembered for each directory in case if the user has modified the width. The automatic resizing is still turn on per default. The storing of the custom column-width can easily be reset by right clicking on the header and selecting "Automatic Column Widths" from the context-menu. Some finetuning is still necessary (e.g. the "Adjust View Properties" dialog currently is not aware about this setting) but this will be fixed during the next weeks. BUG: 264434 FIXED-IN: 4.9.0
Diffstat (limited to 'src/kitemviews/kitemlistheader.h')
-rw-r--r--src/kitemviews/kitemlistheader.h89
1 files changed, 89 insertions, 0 deletions
diff --git a/src/kitemviews/kitemlistheader.h b/src/kitemviews/kitemlistheader.h
new file mode 100644
index 000000000..d0aae7fc1
--- /dev/null
+++ b/src/kitemviews/kitemlistheader.h
@@ -0,0 +1,89 @@
+/***************************************************************************
+ * Copyright (C) 2012 by Peter Penz <[email protected]> *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
+ ***************************************************************************/
+
+#ifndef KITEMLISTHEADER_H
+#define KITEMLISTHEADER_H
+
+#include <libdolphin_export.h>
+#include <QHash>
+#include <QObject>
+
+class KItemListHeaderWidget;
+class KItemListView;
+
+/**
+ * @brief Provides access to the header of a KItemListView.
+ *
+ * Each column of the header represents a visible role
+ * accessible by KItemListView::visibleRoles().
+ */
+class LIBDOLPHINPRIVATE_EXPORT KItemListHeader : public QObject
+{
+ Q_OBJECT
+
+public:
+ virtual ~KItemListHeader();
+
+ /**
+ * If set to true, KItemListView will automatically adjust the
+ * widths of the columns. If set to false, the size can be
+ * manually adjusted by KItemListHeader::setColumnWidth().
+ */
+ void setAutomaticColumnResizing(bool automatic);
+ bool automaticColumnResizing() const;
+
+ /**
+ * Sets the width of the column for the given role. Note that
+ * the width only gets applied if KItemListHeader::automaticColumnResizing()
+ * has been turned off.
+ */
+ void setColumnWidth(const QByteArray& role, qreal width);
+ qreal columnWidth(const QByteArray& role) const;
+
+ /**
+ * Sets the widths of the columns for all roles. From a performance point of
+ * view calling this method should be preferred over several setColumnWidth()
+ * calls in case if the width of more than one column should be changed.
+ * Note that the widths only get applied if KItemListHeader::automaticColumnResizing()
+ * has been turned off.
+ */
+ void setColumnWidths(const QHash<QByteArray, qreal>& columnWidths);
+
+signals:
+ /**
+ * Is emitted if the width of a column has been adjusted by the user with the mouse
+ * (no signal is emitted if KItemListHeader::setColumnWidth() is invoked).
+ */
+ void columnWidthChanged(const QByteArray& role,
+ qreal currentWidth,
+ qreal previousWidth);
+
+private:
+ KItemListHeader(KItemListView* listView);
+
+private:
+ KItemListView* m_view;
+ KItemListHeaderWidget* m_headerWidget;
+
+ friend class KItemListView; // Constructs the KItemListHeader instance
+};
+
+#endif
+
+