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 #include "additionalinfomanager.h"
22 #include "dolphinmodel.h"
26 class AdditionalInfoManagerSingleton
29 AdditionalInfoManager instance
;
31 K_GLOBAL_STATIC(AdditionalInfoManagerSingleton
, s_additionalInfoManager
)
33 AdditionalInfoManager
& AdditionalInfoManager::instance()
35 return s_additionalInfoManager
->instance
;
38 KFileItemDelegate::InformationList
AdditionalInfoManager::keys() const
40 return m_informations
;
43 KFileItemDelegate::Information
AdditionalInfoManager::keyForColumn(int columnIndex
) const
45 KFileItemDelegate::Information info
= KFileItemDelegate::NoInformation
;
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;
62 QString
AdditionalInfoManager::actionCollectionName(KFileItemDelegate::Information info
) const
64 return QLatin1String(m_map
[info
]->actionCollectionName
);
67 QString
AdditionalInfoManager::translation(KFileItemDelegate::Information info
) const
69 return i18n(m_map
[info
]->translation
);
72 int AdditionalInfoManager::bitValue(KFileItemDelegate::Information info
) const
74 return m_map
[info
]->bitValue
;
77 AdditionalInfoManager::AdditionalInfoManager() :
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 }
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]);
101 m_informations
= m_map
.keys();
104 AdditionalInfoManager::~AdditionalInfoManager()