views/dolphinviewactionhandler.cpp
views/draganddrophelper.cpp
views/renamedialog.cpp
- views/rolesaccessor.cpp
views/tooltips/filemetadatatooltip.cpp
views/tooltips/tooltipmanager.cpp
views/versioncontrol/updateitemstatesthread.cpp
bool KFileItemModel::supportsDropping(int index) const
{
const KFileItem item = fileItem(index);
- return item.isNull() ? false : item.isDir() || item.isDesktopFile();
+ return !item.isNull() && (item.isDir() || item.isDesktopFile());
}
QString KFileItemModel::roleDescription(const QByteArray& role) const
{
- QString descr;
-
- switch (roleIndex(role)) {
- case NameRole: descr = i18nc("@item:intable", "Name"); break;
- case SizeRole: descr = i18nc("@item:intable", "Size"); break;
- case DateRole: descr = i18nc("@item:intable", "Date"); break;
- case PermissionsRole: descr = i18nc("@item:intable", "Permissions"); break;
- case OwnerRole: descr = i18nc("@item:intable", "Owner"); break;
- case GroupRole: descr = i18nc("@item:intable", "Group"); break;
- case TypeRole: descr = i18nc("@item:intable", "Type"); break;
- case DestinationRole: descr = i18nc("@item:intable", "Destination"); break;
- case PathRole: descr = i18nc("@item:intable", "Path"); break;
- case CommentRole: descr = i18nc("@item:intable", "Comment"); break;
- case TagsRole: descr = i18nc("@item:intable", "Tags"); break;
- case RatingRole: descr = i18nc("@item:intable", "Rating"); break;
- case NoRole: break;
- case IsDirRole: break;
- case IsExpandedRole: break;
- case ExpandedParentsCountRole: break;
- default: Q_ASSERT(false); break;
+ static QHash<QByteArray, QString> description;
+ if (description.isEmpty()) {
+ int count = 0;
+ const RoleInfoMap* map = rolesInfoMap(count);
+ for (int i = 0; i < count; ++i) {
+ description.insert(map[i].role, map[i].roleTranslation);
+ }
}
- return descr;
+ return description.value(role);
}
QList<QPair<int, QVariant> > KFileItemModel::groups() const
QElapsedTimer timer;
timer.start();
#endif
- switch (roleIndex(sortRole())) {
+ switch (typeForRole(sortRole())) {
case NameRole: m_groups = nameRoleGroups(); break;
case SizeRole: m_groups = sizeRoleGroups(); break;
case DateRole: m_groups = dateRoleGroups(); break;
QSetIterator<QByteArray> it(roles);
while (it.hasNext()) {
const QByteArray& role = it.next();
- m_requestRole[roleIndex(role)] = true;
+ m_requestRole[typeForRole(role)] = true;
}
if (count() > 0) {
return m_filter.pattern();
}
+QList<KFileItemModel::RoleInfo> KFileItemModel::rolesInformation()
+{
+ static QList<RoleInfo> rolesInfo;
+ if (rolesInfo.isEmpty()) {
+ int count = 0;
+ const RoleInfoMap* map = rolesInfoMap(count);
+ for (int i = 0; i < count; ++i) {
+ if (map[i].roleType != NoRole) {
+ RoleInfo info;
+ info.role = map[i].role;
+ info.translation = map[i].roleTranslation;
+ info.group = map[i].groupTranslation;
+ rolesInfo.append(info);
+ }
+ }
+ }
+
+ return rolesInfo;
+}
+
void KFileItemModel::onGroupedSortingChanged(bool current)
{
Q_UNUSED(current);
void KFileItemModel::onSortRoleChanged(const QByteArray& current, const QByteArray& previous)
{
Q_UNUSED(previous);
- m_sortRole = roleIndex(current);
+ m_sortRole = typeForRole(current);
#ifdef KFILEITEMMODEL_DEBUG
if (!m_requestRole[m_sortRole]) {
}
}
-KFileItemModel::Role KFileItemModel::roleIndex(const QByteArray& role) const
-{
- static QHash<QByteArray, Role> rolesHash;
- if (rolesHash.isEmpty()) {
- rolesHash.insert("name", NameRole);
- rolesHash.insert("size", SizeRole);
- rolesHash.insert("date", DateRole);
- rolesHash.insert("permissions", PermissionsRole);
- rolesHash.insert("owner", OwnerRole);
- rolesHash.insert("group", GroupRole);
- rolesHash.insert("type", TypeRole);
- rolesHash.insert("destination", DestinationRole);
- rolesHash.insert("path", PathRole);
- rolesHash.insert("comment", CommentRole);
- rolesHash.insert("tags", TagsRole);
- rolesHash.insert("rating", RatingRole);
- rolesHash.insert("isDir", IsDirRole);
- rolesHash.insert("isExpanded", IsExpandedRole);
- rolesHash.insert("isExpandable", IsExpandableRole);
- rolesHash.insert("expandedParentsCount", ExpandedParentsCountRole);
- }
- return rolesHash.value(role, NoRole);
-}
-
-QByteArray KFileItemModel::roleByteArray(Role role) const
-{
- static const char* const roles[RolesCount] = {
- 0, // NoRole
- "name",
- "size",
- "date",
- "permissions",
- "owner",
- "group",
- "type",
- "destination",
- "path",
- "comment",
- "tags",
- "rating",
- "isDir",
- "isExpanded",
- "isExpandable",
- "expandedParentsCount"
+KFileItemModel::RoleType KFileItemModel::typeForRole(const QByteArray& role) const
+{
+ static QHash<QByteArray, RoleType> roles;
+ if (roles.isEmpty()) {
+ // Insert user visible roles that can be accessed with
+ // KFileItemModel::roleInformation()
+ int count = 0;
+ const RoleInfoMap* map = rolesInfoMap(count);
+ for (int i = 0; i < count; ++i) {
+ roles.insert(map[i].role, map[i].roleType);
+ }
+
+ // Insert internal roles (take care to synchronize the implementation
+ // with KFileItemModel::roleForType() in case if a change is done).
+ roles.insert("isDir", IsDirRole);
+ roles.insert("isExpanded", IsExpandedRole);
+ roles.insert("isExpandable", IsExpandableRole);
+ roles.insert("expandedParentsCount", ExpandedParentsCountRole);
+
+ Q_ASSERT(roles.count() == RolesCount);
+ }
+
+ return roles.value(role, NoRole);
+}
+
+QByteArray KFileItemModel::roleForType(RoleType roleType) const
+{
+ static QHash<RoleType, QByteArray> roles;
+ if (roles.isEmpty()) {
+ // Insert user visible roles that can be accessed with
+ // KFileItemModel::roleInformation()
+ int count = 0;
+ const RoleInfoMap* map = rolesInfoMap(count);
+ for (int i = 0; i < count; ++i) {
+ roles.insert(map[i].roleType, map[i].role);
+ }
+
+ // Insert internal roles (take care to synchronize the implementation
+ // with KFileItemModel::typeForRole() in case if a change is done).
+ roles.insert(IsDirRole, "isDir");
+ roles.insert(IsExpandedRole, "isExpanded");
+ roles.insert(IsExpandableRole, "isExpandable");
+ roles.insert(ExpandedParentsCountRole, "expandedParentsCount");
+
+ Q_ASSERT(roles.count() == RolesCount);
};
- return roles[role];
+
+ return roles.value(roleType);
}
QHash<QByteArray, QVariant> KFileItemModel::retrieveData(const KFileItem& item) const
case PathRole:
case CommentRole:
case TagsRole: {
- const QByteArray role = roleByteArray(m_sortRole);
+ const QByteArray role = roleForType(m_sortRole);
result = QString::compare(a->values.value(role).toString(),
b->values.value(role).toString());
break;
return items;
}
+const KFileItemModel::RoleInfoMap* KFileItemModel::rolesInfoMap(int& count)
+{
+ static const RoleInfoMap rolesInfoMap[] = {
+ // role roleType role translation group translation
+ { 0, NoRole, 0, 0, 0, 0 },
+ { "name", NameRole, I18N_NOOP2_NOSTRIP("@label", "Name"), 0, 0 },
+ { "size", SizeRole, I18N_NOOP2_NOSTRIP("@label", "Size"), 0, 0 },
+ { "date", DateRole, I18N_NOOP2_NOSTRIP("@label", "Date"), 0, 0 },
+ { "permissions", PermissionsRole, I18N_NOOP2_NOSTRIP("@label", "Permissions"), 0, 0 },
+ { "owner", OwnerRole, I18N_NOOP2_NOSTRIP("@label", "Owner"), 0, 0 },
+ { "group", GroupRole, I18N_NOOP2_NOSTRIP("@label", "Group"), 0, 0 },
+ { "type", TypeRole, I18N_NOOP2_NOSTRIP("@label", "Type"), 0, 0 },
+ { "destination", DestinationRole, I18N_NOOP2_NOSTRIP("@label", "Link Destination"), 0, 0 },
+ { "path", PathRole, I18N_NOOP2_NOSTRIP("@label", "Path"), 0, 0 },
+ { "comment", CommentRole, I18N_NOOP2_NOSTRIP("@label", "Comment"), 0, 0 },
+ { "tags", TagsRole, I18N_NOOP2_NOSTRIP("@label", "Tags"), 0, 0 },
+ { "rating", RatingRole, I18N_NOOP2_NOSTRIP("@label", "Rating"), 0, 0 }
+ };
+
+ count = sizeof(rolesInfoMap) / sizeof(RoleInfoMap);
+ return rolesInfoMap;
+}
+
#include "kfileitemmodel.moc"
virtual bool supportsDropping(int index) const;
/** @reimp */
- virtual QString roleDescription(const QByteArray& role) const;
+ virtual QString roleDescription(const QByteArray& typeForRole) const;
/** @reimp */
virtual QList<QPair<int, QVariant> > groups() const;
void setNameFilter(const QString& nameFilter);
QString nameFilter() const;
+ struct RoleInfo
+ { QByteArray role;
+ QString translation;
+ QString group;
+ };
+
+ static QList<RoleInfo> rolesInformation();
+
signals:
/**
* Is emitted after the loading of a directory has been completed or new
void dispatchPendingItemsToInsert();
private:
- enum Role {
+ enum RoleType {
NoRole,
NameRole,
SizeRole,
void resetRoles();
/**
- * @return Role-index for the given role byte-array.
+ * @return Role-type for the given role.
* Runtime complexity is O(1).
*/
- Role roleIndex(const QByteArray& role) const;
+ RoleType typeForRole(const QByteArray& role) const;
/**
- * @return Role-byte-array for the given role-index.
+ * @return Role-byte-array for the given role-type.
* Runtime complexity is O(1).
*/
- QByteArray roleByteArray(Role role) const;
+ QByteArray roleForType(RoleType roleType) const;
QHash<QByteArray, QVariant> retrieveData(const KFileItem& item) const;
QList<QPair<int, QVariant> > dateRoleGroups() const;
QList<QPair<int, QVariant> > permissionRoleGroups() const;
QList<QPair<int, QVariant> > ratingRoleGroups() const;
- QList<QPair<int, QVariant> > genericStringRoleGroups(const QByteArray& role) const;
+ QList<QPair<int, QVariant> > genericStringRoleGroups(const QByteArray& typeForRole) const;
/**
* Helper method for all xxxRoleGroups() methods to check whether the
*/
KFileItemList childItems(const KFileItem& item) const;
+ /**
+ * Maps the QByteArray-roles to RoleTypes and provides translation- and
+ * group-contexts.
+ */
+ struct RoleInfoMap
+ {
+ const char* const role;
+ const RoleType roleType;
+ const char* const roleTranslationContext;
+ const char* const roleTranslation;
+ const char* const groupTranslationContext;
+ const char* const groupTranslation;
+ };
+
+ /**
+ * @return Map of user visible roles that are accessible by KFileItemModel::rolesInformation().
+ */
+ static const RoleInfoMap* rolesInfoMap(int& count);
+
private:
QWeakPointer<KDirLister> m_dirLister;
bool m_naturalSorting;
bool m_sortFoldersFirst;
- Role m_sortRole;
+ RoleType m_sortRole;
QSet<QByteArray> m_roles;
Qt::CaseSensitivity m_caseSensitivity;
/***************************************************************************
- * Copyright (C) 2007 by Peter Penz (peter.penz@gmx.at) *
+ * Copyright (C) 2007-2012 by Peter Penz <peter.penz19@gmail.com> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
#include "additionalinfodialog.h"
#include <KLocale>
-
+#include "kitemviews/kfileitemmodel.h"
#include <QCheckBox>
#include <QLabel>
#include <QVBoxLayout>
-#include "views/rolesaccessor.h"
-
AdditionalInfoDialog::AdditionalInfoDialog(QWidget* parent,
const QList<QByteArray>& visibleRoles) :
KDialog(parent),
m_visibleRoles(visibleRoles),
- m_checkBoxes()
+ m_listWidget(0)
{
setCaption(i18nc("@title:window", "Additional Information"));
setButtons(Ok | Cancel);
QWidget* mainWidget = new QWidget(this);
mainWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum);
- QVBoxLayout* layout = new QVBoxLayout(mainWidget);
// Add header
QLabel* header = new QLabel(mainWidget);
header->setText(i18nc("@label", "Select which additional information should be shown:"));
header->setWordWrap(true);
- layout->addWidget(header);
// Add checkboxes
- const RolesAccessor& rolesAccessor = RolesAccessor::instance();
- const QList<QByteArray> roles = rolesAccessor.roles();
- foreach (const QByteArray& role, roles) {
- QCheckBox* checkBox = new QCheckBox(rolesAccessor.translation(role), mainWidget);
- checkBox->setChecked(visibleRoles.contains(role));
- layout->addWidget(checkBox);
- m_checkBoxes.append(checkBox);
+ m_listWidget = new QListWidget(mainWidget);
+ m_listWidget->setSelectionMode(QAbstractItemView::NoSelection);
+ const QList<KFileItemModel::RoleInfo> rolesInfo = KFileItemModel::rolesInformation();
+ foreach (const KFileItemModel::RoleInfo& info, rolesInfo) {
+ QListWidgetItem* item = new QListWidgetItem(info.translation, m_listWidget);
+ item->setCheckState(visibleRoles.contains(info.role) ? Qt::Checked : Qt::Unchecked);
}
+ QVBoxLayout* layout = new QVBoxLayout(mainWidget);
+ layout->addWidget(header);
+ layout->addWidget(m_listWidget);
layout->addStretch(1);
setMainWidget(mainWidget);
- const KConfigGroup dialogConfig(KSharedConfig::openConfig("dolphinrc"),
- "AdditionalInfoDialog");
+ const KConfigGroup dialogConfig(KSharedConfig::openConfig("dolphinrc"), "AdditionalInfoDialog");
restoreDialogSize(dialogConfig);
connect(this, SIGNAL(okClicked()), this, SLOT(slotOk()));
AdditionalInfoDialog::~AdditionalInfoDialog()
{
- KConfigGroup dialogConfig(KSharedConfig::openConfig("dolphinrc"),
- "AdditionalInfoDialog");
+ KConfigGroup dialogConfig(KSharedConfig::openConfig("dolphinrc"), "AdditionalInfoDialog");
saveDialogSize(dialogConfig, KConfigBase::Persistent);
}
{
m_visibleRoles.clear();
- const QList<QByteArray> roles = RolesAccessor::instance().roles();
int index = 0;
- foreach (const QByteArray& role, roles) {
- if (m_checkBoxes[index]->isChecked()) {
- m_visibleRoles.append(role);
+ const QList<KFileItemModel::RoleInfo> rolesInfo = KFileItemModel::rolesInformation();
+ foreach (const KFileItemModel::RoleInfo& info, rolesInfo) {
+ const QListWidgetItem* item = m_listWidget->item(index);
+ if (item->checkState() == Qt::Checked) {
+ m_visibleRoles.append(info.role);
}
++index;
}
/***************************************************************************
- * Copyright (C) 2007 by Peter Penz (peter.penz@gmx.at) *
+ * Copyright (C) 2007-2012 by Peter Penz <peter.penz19@gmail.com> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
#include <KDialog>
#include <QList>
+#include <QListWidget>
class QCheckBox;
private:
QList<QByteArray> m_visibleRoles;
- QList<QCheckBox*> m_checkBoxes;
+ QListWidget* m_listWidget;
};
#endif
#include "viewpropertiesdialog.h"
#include "additionalinfodialog.h"
-#include "views/rolesaccessor.h"
+#include "kitemviews/kfileitemmodel.h"
#include "views/dolphinview.h"
#include "dolphin_generalsettings.h"
#include "dolphin_iconsmodesettings.h"
m_sortOrder->addItem(i18nc("@item:inlistbox Sort", "Descending"));
m_sorting = new KComboBox(sortingBox);
- const RolesAccessor& rolesAccessor = RolesAccessor::instance();
- const QList<QByteArray> roles = rolesAccessor.roles();
- foreach (const QByteArray& role, roles) {
- m_sorting->addItem(rolesAccessor.translation(role), role);
+ const QList<KFileItemModel::RoleInfo> rolesInfo = KFileItemModel::rolesInformation();
+ foreach (const KFileItemModel::RoleInfo& info, rolesInfo) {
+ m_sorting->addItem(info.translation, info.role);
}
m_sortFoldersFirst = new QCheckBox(i18nc("@option:check", "Show folders first"));
const int sortOrderIndex = (m_viewProps->sortOrder() == Qt::AscendingOrder) ? 0 : 1;
m_sortOrder->setCurrentIndex(sortOrderIndex);
- const QList<QByteArray> roles = RolesAccessor::instance().roles();
- const int sortRoleIndex = roles.indexOf(m_viewProps->sortRole());
+ const QList<KFileItemModel::RoleInfo> rolesInfo = KFileItemModel::rolesInformation();
+ int sortRoleIndex = 0;
+ for (int i = 0; i < rolesInfo.count(); ++i)
+ foreach (const KFileItemModel::RoleInfo& info, rolesInfo) {
+ if (info.role == m_viewProps->sortRole()) {
+ sortRoleIndex = i;
+ break;
+ }
+ }
m_sorting->setCurrentIndex(sortRoleIndex);
m_sortFoldersFirst->setChecked(m_viewProps->sortFoldersFirst());
#include <KToggleAction>
#include <KUrl>
-#include "rolesaccessor.h"
#include "dolphindirlister.h"
#include "dolphinnewfilemenuobserver.h"
#include "dolphin_detailsmodesettings.h"
const QSet<QByteArray> visibleRolesSet = view->visibleRoles().toSet();
// Add all roles to the menu that can be shown or hidden by the user
- const RolesAccessor& rolesAccessor = RolesAccessor::instance();
- const QList<QByteArray> roles = rolesAccessor.roles();
- foreach (const QByteArray& role, roles) {
- if (role != "name") {
- const QString text = fileItemModel()->roleDescription(role);
+ const QList<KFileItemModel::RoleInfo> rolesInfo = KFileItemModel::rolesInformation();
+ foreach (const KFileItemModel::RoleInfo& info, rolesInfo) {
+ if (info.role != "name") {
+ const QString text = fileItemModel()->roleDescription(info.role);
QAction* action = menu.data()->addAction(text);
action->setCheckable(true);
- action->setChecked(visibleRolesSet.contains(role));
- action->setData(role);
+ action->setChecked(visibleRolesSet.contains(info.role));
+ action->setData(info.role);
}
}
ViewProperties props(url());
QList<QByteArray> visibleRoles = view->visibleRoles();
if (action->isChecked()) {
- const int index = roles.indexOf(selectedRole) + 1;
- visibleRoles.insert(index, selectedRole);
+ visibleRoles.append(selectedRole);
} else {
visibleRoles.removeOne(selectedRole);
}
#include "dolphinviewactionhandler.h"
-#include "rolesaccessor.h"
#include "settings/viewpropertiesdialog.h"
#include "views/dolphinview.h"
#include "views/zoomlevelinfo.h"
#include <KActionCollection>
#include <KActionMenu>
#include <KFileItemDelegate>
+#include <kitemviews/kfileitemmodel.h>
#include <KLocale>
#include <KNewFileMenu>
#include <KSelectAction>
showInformationMenu->setText(i18nc("@action:inmenu View", "Additional Information"));
showInformationMenu->setDelayed(false);
- const RolesAccessor& rolesAccessor = RolesAccessor::instance();
-
- const QList<QByteArray> roles = rolesAccessor.roles();
- foreach (const QByteArray& role, roles) {
- if (role == "name") {
+ const QList<KFileItemModel::RoleInfo> rolesInfo = KFileItemModel::rolesInformation();
+ foreach (const KFileItemModel::RoleInfo& info, rolesInfo) {
+ if (info.role == "name") {
// It should not be possible to hide the "name" role
continue;
}
- const QString name = QLatin1String("show_") + role;
+ const QString name = QLatin1String("show_") + info.role;
KToggleAction* action = m_actionCollection->add<KToggleAction>(name);
- action->setText(rolesAccessor.translation(role));
- action->setData(role);
+ action->setText(info.translation);
+ action->setData(info.role);
action->setActionGroup(additionalInfoGroup);
}
QActionGroup* sortByActionGroup = new QActionGroup(m_actionCollection);
sortByActionGroup->setExclusive(true);
- const RolesAccessor& rolesAccessor = RolesAccessor::instance();
- const QList<QByteArray> roles = rolesAccessor.roles();
- foreach (const QByteArray& role, roles) {
- const QString name = QLatin1String("sort_by_") + role;
+ const QList<KFileItemModel::RoleInfo> rolesInfo = KFileItemModel::rolesInformation();
+ foreach (const KFileItemModel::RoleInfo& info, rolesInfo) {
+ const QString name = QLatin1String("sort_by_") + info.role;
KToggleAction* action = m_actionCollection->add<KToggleAction>(name);
- action->setText(rolesAccessor.translation(role));
- action->setData(role);
+ action->setText(info.translation);
+ action->setData(info.role);
sortByActionGroup->addAction(action);
}
{
Q_UNUSED(previous);
- const RolesAccessor& rolesAccessor = RolesAccessor::instance();
-
const QSet<QByteArray> checkedRoles = current.toSet();
- const QList<QByteArray> roles = rolesAccessor.roles();
-
- foreach (const QByteArray& role, roles) {
- const QString name = QLatin1String("show_") + role;
+ const QList<KFileItemModel::RoleInfo> rolesInfo = KFileItemModel::rolesInformation();
+ foreach (const KFileItemModel::RoleInfo& info, rolesInfo) {
+ const QString name = QLatin1String("show_") + info.role;
QAction* action = m_actionCollection->action(name);
if (action) {
- action->setChecked(checkedRoles.contains(role));
+ action->setChecked(checkedRoles.contains(info.role));
}
}
}
+++ /dev/null
-/***************************************************************************
- * Copyright (C) 2010 by Peter Penz <peter.penz19@gmail.com> *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
- ***************************************************************************/
-
-#include "rolesaccessor.h"
-
-#include <KGlobal>
-#include <KLocale>
-
-class RolesAccessorSingleton
-{
-public:
- RolesAccessor instance;
-};
-K_GLOBAL_STATIC(RolesAccessorSingleton, s_rolesAccessor)
-
-RolesAccessor& RolesAccessor::instance()
-{
- return s_rolesAccessor->instance;
-}
-
-QList<QByteArray> RolesAccessor::roles() const
-{
- return m_roles;
-}
-
-QString RolesAccessor::translation(const QByteArray& role) const
-{
- return i18nc(m_translation[role]->roleTranslationContext, m_translation[role]->roleTranslation);
-}
-
-RolesAccessor::RolesAccessor() :
- m_roles(),
- m_translation()
-{
- static const RolesAccessor::Translation translations[] = {
- // role roleTranslationContext roleTranslation
- { "name", I18N_NOOP2_NOSTRIP("@label", "Name") },
- { "size", I18N_NOOP2_NOSTRIP("@label", "Size") },
- { "date", I18N_NOOP2_NOSTRIP("@label", "Date") },
- { "permissions", I18N_NOOP2_NOSTRIP("@label", "Permissions") },
- { "owner", I18N_NOOP2_NOSTRIP("@label", "Owner") },
- { "group", I18N_NOOP2_NOSTRIP("@label", "Group") },
- { "type", I18N_NOOP2_NOSTRIP("@label", "Type") },
- { "destination", I18N_NOOP2_NOSTRIP("@label", "Link Destination") },
- { "path", I18N_NOOP2_NOSTRIP("@label", "Path") }
- };
-
- for (unsigned int i = 0; i < sizeof(translations) / sizeof(Translation); ++i) {
- m_translation.insert(translations[i].role, &translations[i]);
- m_roles.append(translations[i].role);
- }
-}
-
-RolesAccessor::~RolesAccessor()
-{
-}
+++ /dev/null
-/***************************************************************************
- * Copyright (C) 2010 by Peter Penz <peter.penz19@gmail.com> *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
- ***************************************************************************/
-
-#ifndef ROLESACCESSOR_H
-#define ROLESACCESSOR_H
-
-#include <libdolphin_export.h>
-
-#include <QList>
-#include <QHash>
-
-/**
- * @brief Allows to access the available roles that can be shown in a view.
- */
-class LIBDOLPHINPRIVATE_EXPORT RolesAccessor
-{
-public:
- static RolesAccessor& instance();
-
- /**
- * @return List of all available roles.
- */
- QList<QByteArray> roles() const;
-
- /**
- * @return Translation of the role that can be shown e.g. in the header
- * of a view or as menu-entry.
- */
- QString translation(const QByteArray& role) const;
-
-protected:
- RolesAccessor();
- virtual ~RolesAccessor();
- friend class RolesAccessorSingleton;
-
-private:
- struct Translation {
- const char* const role;
- const char* const roleTranslationContext;
- const char* const roleTranslation;
- };
-
- QList<QByteArray> m_roles;
- QHash<QByteArray, const Translation*> m_translation;
-};
-
-#endif
-
#include "viewproperties.h"
-#include "rolesaccessor.h"
#include "dolphin_directoryviewpropertysettings.h"
#include "dolphin_generalsettings.h"