/usr/include/akonadi/collectionutils_p.h is in kdepimlibs5-dev 4:4.8.5-0ubuntu0.3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | /*
Copyright (c) 2008 Tobias Koenig <tokoe@kde.org>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This library 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 Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
#ifndef AKONADI_COLLECTIONUTILS_P_H
#define AKONADI_COLLECTIONUTILS_P_H
#include <QtCore/QStringList>
#include <akonadi/entitydisplayattribute.h>
#include <akonadi/collectionstatistics.h>
#include <akonadi/item.h>
namespace Akonadi {
/**
* @internal
*/
namespace CollectionUtils
{
inline bool isVirtualParent( const Collection &collection )
{
return (collection.parentCollection() == Collection::root() &&
( collection.resource() == QLatin1String( "akonadi_search_resource" ) || collection.resource() == QLatin1String( "akonadi_nepomuktag_resource" ) ) );
}
inline bool isVirtual( const Collection &collection )
{
return ( (collection.resource() == QLatin1String( "akonadi_search_resource" ) || collection.resource() == QLatin1String( "akonadi_nepomuktag_resource" ) ) );
}
inline bool isReadOnly( const Collection &collection )
{
return !(collection.rights() & Collection::CanCreateItem);
}
inline bool isRoot( const Collection &collection )
{
return (collection == Collection::root());
}
inline bool isResource( const Collection &collection )
{
return (collection.parentCollection() == Collection::root());
}
inline bool isStructural( const Collection &collection )
{
return collection.contentMimeTypes().isEmpty();
}
inline bool isFolder( const Collection &collection )
{
return (!isRoot( collection ) &&
!isResource( collection ) &&
!isStructural( collection ) &&
collection.resource() != QLatin1String( "akonadi_search_resource" ) &&
collection.resource() != QLatin1String( "akonadi_nepomuktag_resource" ));
}
inline QString defaultIconName( const Collection &col )
{
if ( CollectionUtils::isVirtualParent( col ) )
return QLatin1String( "edit-find" );
if ( CollectionUtils::isVirtual( col ) )
return QLatin1String( "document-preview" );
if ( CollectionUtils::isResource( col ) )
return QLatin1String( "network-server" );
if ( CollectionUtils::isStructural( col ) )
return QLatin1String( "folder-grey" );
if ( CollectionUtils::isReadOnly( col ) )
return QLatin1String( "folder-grey" );
const QStringList content = col.contentMimeTypes();
if ( content.size() == 1 || (content.size() == 2 && content.contains( Collection::mimeType() )) ) {
if ( content.contains( QLatin1String( "text/x-vcard" ) ) || content.contains( QLatin1String( "text/directory" ) )
|| content.contains( QLatin1String( "text/vcard" ) ) )
return QLatin1String( "x-office-address-book" );
// TODO: add all other content types and/or fix their mimetypes
if ( content.contains( QLatin1String( "akonadi/event" ) ) || content.contains( QLatin1String( "text/ical" ) ) )
return QLatin1String( "view-pim-calendar" );
if ( content.contains( QLatin1String( "akonadi/task" ) ) )
return QLatin1String( "view-pim-tasks" );
} else if ( content.isEmpty() ) {
return QLatin1String( "folder-grey" );
}
return QLatin1String( "folder" );
}
inline QString displayIconName( const Collection &col )
{
QString iconName = defaultIconName( col );
if ( col.hasAttribute<EntityDisplayAttribute>() &&
!col.attribute<EntityDisplayAttribute>()->iconName().isEmpty() ) {
if ( !col.attribute<EntityDisplayAttribute>()->activeIconName().isEmpty() && col.statistics().unreadCount()> 0) {
iconName = col.attribute<EntityDisplayAttribute>()->activeIconName();
}
else
iconName = col.attribute<EntityDisplayAttribute>()->iconName();
}
return iconName;
}
inline bool hasValidHierarchicalRID( const Collection &col )
{
if ( col == Collection::root() )
return true;
if ( col.remoteId().isEmpty() )
return false;
return hasValidHierarchicalRID( col.parentCollection() );
}
inline bool hasValidHierarchicalRID( const Item &item )
{
return !item.remoteId().isEmpty() && hasValidHierarchicalRID( item.parentCollection() );
}
}
}
#endif
|