]> cloud.milkyroute.net Git - dolphin.git/blob - src/views/rolesaccessor.cpp
Provide backward compatibility with older .directory versions
[dolphin.git] / src / views / rolesaccessor.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 "rolesaccessor.h"
21
22 #include <KGlobal>
23 #include <KLocale>
24
25 class RolesAccessorSingleton
26 {
27 public:
28 RolesAccessor instance;
29 };
30 K_GLOBAL_STATIC(RolesAccessorSingleton, s_rolesAccessor)
31
32 RolesAccessor& RolesAccessor::instance()
33 {
34 return s_rolesAccessor->instance;
35 }
36
37 QList<QByteArray> RolesAccessor::roles() const
38 {
39 return m_roles;
40 }
41
42 QString RolesAccessor::translation(const QByteArray& role) const
43 {
44 return i18nc(m_translation[role]->roleTranslationContext, m_translation[role]->roleTranslation);
45 }
46
47 RolesAccessor::RolesAccessor() :
48 m_roles(),
49 m_translation()
50 {
51 static const RolesAccessor::Translation translations[] = {
52 // role roleTranslationContext roleTranslation
53 { "name", I18N_NOOP2_NOSTRIP("@label", "Name") },
54 { "size", I18N_NOOP2_NOSTRIP("@label", "Size") },
55 { "date", I18N_NOOP2_NOSTRIP("@label", "Date") },
56 { "permissions", I18N_NOOP2_NOSTRIP("@label", "Permissions") },
57 { "owner", I18N_NOOP2_NOSTRIP("@label", "Owner") },
58 { "group", I18N_NOOP2_NOSTRIP("@label", "Group") },
59 { "type", I18N_NOOP2_NOSTRIP("@label", "Type") },
60 { "destination", I18N_NOOP2_NOSTRIP("@label", "Link Destination") },
61 { "path", I18N_NOOP2_NOSTRIP("@label", "Path") }
62 };
63
64 for (unsigned int i = 0; i < sizeof(translations) / sizeof(Translation); ++i) {
65 m_translation.insert(translations[i].role, &translations[i]);
66 m_roles.append(translations[i].role);
67 }
68 }
69
70 RolesAccessor::~RolesAccessor()
71 {
72 }