]> cloud.milkyroute.net Git - dolphin.git/blob - src/additionalinfomanager.cpp
If an information entry will be added to KFileItemDelegate (like done recently),...
[dolphin.git] / src / additionalinfomanager.cpp
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 #include "additionalinfomanager.h"
21
22 #include "dolphinmodel.h"
23 #include <kglobal.h>
24 #include <klocale.h>
25
26 class AdditionalInfoManagerSingleton
27 {
28 public:
29 AdditionalInfoManager instance;
30 };
31 K_GLOBAL_STATIC(AdditionalInfoManagerSingleton, s_additionalInfoManager)
32
33 AdditionalInfoManager& AdditionalInfoManager::instance()
34 {
35 return s_additionalInfoManager->instance;
36 }
37
38 KFileItemDelegate::InformationList AdditionalInfoManager::keys() const
39 {
40 return m_informations;
41 }
42
43 KFileItemDelegate::Information AdditionalInfoManager::keyForColumn(int columnIndex) const
44 {
45 KFileItemDelegate::Information info = KFileItemDelegate::NoInformation;
46
47 switch (columnIndex) {
48 case DolphinModel::Size: info = KFileItemDelegate::Size; break;
49 case DolphinModel::ModifiedTime: info = KFileItemDelegate::ModificationTime; break;
50 case DolphinModel::Permissions: info = KFileItemDelegate::Permissions; break;
51 case DolphinModel::Owner: info = KFileItemDelegate::Owner; break;
52 case DolphinModel::Group: info = KFileItemDelegate::OwnerAndGroup; break;
53 case DolphinModel::Type: info = KFileItemDelegate::FriendlyMimeType; break;
54 case DolphinModel::LinkDest: info = KFileItemDelegate::LinkDest; break;
55 case DolphinModel::LocalPathOrUrl: info = KFileItemDelegate::LocalPathOrUrl; break;
56 default: break;
57 }
58
59 return info;
60 }
61
62 QString AdditionalInfoManager::actionCollectionName(KFileItemDelegate::Information info) const
63 {
64 return QLatin1String(m_map[info]->actionCollectionName);
65 }
66
67 QString AdditionalInfoManager::translation(KFileItemDelegate::Information info) const
68 {
69 return i18n(m_map[info]->translation);
70 }
71
72 int AdditionalInfoManager::bitValue(KFileItemDelegate::Information info) const
73 {
74 return m_map[info]->bitValue;
75 }
76
77 AdditionalInfoManager::AdditionalInfoManager() :
78 m_informations(),
79 m_map()
80 {
81 static const AdditionalInfoManager::AdditionalInfo additionalInfos[] = {
82 { "size", I18N_NOOP2("@label", "Size"), 1 },
83 { "date", I18N_NOOP2("@label", "Date"), 2 },
84 { "permissions", I18N_NOOP2("@label", "Permissions"), 4 },
85 { "owner", I18N_NOOP2("@label", "Owner"), 8 },
86 { "group", I18N_NOOP2("@label", "Group"), 16 },
87 { "type", I18N_NOOP2("@label", "Type"), 32 },
88 { "destination", I18N_NOOP2("@label", "Destination"), 64 },
89 { "path", I18N_NOOP2("@label", "Path"), 128 }
90 };
91
92 m_map.insert(KFileItemDelegate::Size, &additionalInfos[0]);
93 m_map.insert(KFileItemDelegate::ModificationTime, &additionalInfos[1]);
94 m_map.insert(KFileItemDelegate::Permissions, &additionalInfos[2]);
95 m_map.insert(KFileItemDelegate::Owner, &additionalInfos[3]);
96 m_map.insert(KFileItemDelegate::OwnerAndGroup, &additionalInfos[4]);
97 m_map.insert(KFileItemDelegate::FriendlyMimeType, &additionalInfos[5]);
98 m_map.insert(KFileItemDelegate::LinkDest, &additionalInfos[6]);
99 m_map.insert(KFileItemDelegate::LocalPathOrUrl, &additionalInfos[7]);
100
101 m_informations = m_map.keys();
102 }
103
104 AdditionalInfoManager::~AdditionalInfoManager()
105 {
106 }
107