]> cloud.milkyroute.net Git - dolphin.git/blob - src/additionalinfoaccessor.h
Rename AdditionalInfoManager to AdditionalInfoAccessor
[dolphin.git] / src / additionalinfoaccessor.h
1 /***************************************************************************
2 * Copyright (C) 2010 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 ADDITIONALINFOACCESSOR_H
21 #define ADDITIONALINFOACCESSOR_H
22
23 #include <libdolphin_export.h>
24 #include <kfileitemdelegate.h>
25
26 #include <QList>
27 #include <QMap>
28
29 /**
30 * @brief Allows to access the information that is available by KFileItemDelegate::Information.
31 *
32 * The information that is available by KFileItemDelegate::Information will be shown
33 * in Dolphin the following way:
34 * - As additional columns in the details view
35 * - As additional lines in the icons view
36 * - As menu entries in the "Sort By" and "Additional Information" groups
37 * - As popup menu entries in the details view header popup
38 * - As checkable entries in the View Properties dialog
39 *
40 * The AdditionalInfoAccessor provides a central place to get all available keys,
41 * the corresponding translations, action names, etc., so that modifications or
42 * extensions in KFileItemDelegate only require adjustments in the implementation
43 * of this class.
44 */
45 class LIBDOLPHINPRIVATE_EXPORT AdditionalInfoAccessor
46 {
47 public:
48 static AdditionalInfoAccessor& instance();
49
50 /**
51 * @return List of all available information entries of KFileItemDelegate.
52 * All entries of this list are keys for accessing the corresponding
53 * data (see actionCollectionName(), translation(), bitValue()).
54 */
55 KFileItemDelegate::InformationList keys() const;
56
57 /**
58 * @return Key for the model column with the index \p columnIndex.
59 */
60 KFileItemDelegate::Information keyForColumn(int columnIndex) const;
61
62 QString actionCollectionName(KFileItemDelegate::Information info) const;
63
64 QString translation(KFileItemDelegate::Information info) const;
65
66 /**
67 * @return Bitvalue for \p info that is stored in a ViewProperties instance.
68 */
69 int bitValue(KFileItemDelegate::Information info) const;
70
71 protected:
72 AdditionalInfoAccessor();
73 virtual ~AdditionalInfoAccessor();
74 friend class AdditionalInfoAccessorSingleton;
75
76 private:
77 struct AdditionalInfo {
78 const char* const actionCollectionName;
79 const char* const translation;
80 const int bitValue;
81 };
82
83 KFileItemDelegate::InformationList m_informations;
84 QMap<KFileItemDelegate::Information, const AdditionalInfo*> m_map;
85 };
86
87 #endif
88