1 /***************************************************************************
2 * Copyright (C) 2010 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 ADDITIONALINFOACCESSOR_H
21 #define ADDITIONALINFOACCESSOR_H
23 #include <libdolphin_export.h>
24 #include <KFileItemDelegate>
25 #include <views/dolphinview.h>
31 * @brief Allows to access the information that is available by KFileItemDelegate::Information.
33 * The information that is available by KFileItemDelegate::Information will be shown
34 * in Dolphin the following way:
35 * - As additional columns in the details view
36 * - As additional lines in the icons view
37 * - As menu entries in the "Sort By" and "Additional Information" groups
38 * - As popup menu entries in the details view header popup
39 * - As checkable entries in the View Properties dialog
41 * The AdditionalInfoAccessor provides a central place to get all available keys,
42 * the corresponding translations, action names, etc., so that modifications or
43 * extensions in KFileItemDelegate only require adjustments in the implementation
46 class LIBDOLPHINPRIVATE_EXPORT AdditionalInfoAccessor
49 enum ActionCollectionType
{
50 /// Action collection from "View -> Sort By"
52 /// Action collection from "View -> Additional Information"
56 static AdditionalInfoAccessor
& instance();
59 * @return List of all available information entries of KFileItemDelegate.
60 * All entries of this list are keys for accessing the corresponding
61 * data (see actionCollectionName(), translation(), bitValue()).
63 QList
<DolphinView::AdditionalInfo
> keys() const;
65 QByteArray
role(DolphinView::AdditionalInfo info
) const;
67 DolphinView::AdditionalInfo
additionalInfo(const QByteArray
& role
) const;
69 QString
actionCollectionName(DolphinView::AdditionalInfo info
, ActionCollectionType type
) const;
71 QString
translation(DolphinView::AdditionalInfo info
) const;
74 * @return String representation of the value that is stored in the .directory
77 // TODO Dolphin 3.0: Deprecate - just use role() instead.
78 QString
value(DolphinView::AdditionalInfo info
) const;
80 DolphinView::Sorting
sorting(DolphinView::AdditionalInfo info
) const;
83 AdditionalInfoAccessor();
84 virtual ~AdditionalInfoAccessor();
85 friend class AdditionalInfoAccessorSingleton
;
88 struct AdditionalInfo
{
89 const char* const role
;
90 const char* const roleTranslationContext
;
91 const char* const roleTranslation
;
92 const char* const value
; // TODO Dolphin 3.0: Deprecate and use role instead
93 const DolphinView::Sorting sorting
;
96 QMap
<DolphinView::AdditionalInfo
, const AdditionalInfo
*> m_map
;
97 QHash
<QByteArray
, DolphinView::AdditionalInfo
> m_infoForRole
;