/usr/include/akonadi/collectionpropertiespage.h is in kdepimlibs5-dev 4:4.14.10-7+b2.
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 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 | /*
Copyright (c) 2008 Volker Krause <vkrause@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_COLLECTIONPROPERTIESPAGE_H
#define AKONADI_COLLECTIONPROPERTIESPAGE_H
#include "akonadi_export.h"
#include <QWidget>
namespace Akonadi {
class Collection;
/**
* @short A single page in a collection properties dialog.
*
* The collection properties dialog can be extended by custom
* collection properties pages, which provide gui elements for
* viewing and changing collection attributes.
*
* The following example shows how to create a simple collection
* properties page for the secrecy attribute from the Akonadi::Attribute
* example.
*
* @code
*
* class SecrecyPage : public CollectionPropertiesPage
* {
* public:
* SecrecyPage( QWidget *parent = 0 )
* : CollectionPropertiesPage( parent )
* {
* QVBoxLayout *layout = new QVBoxLayout( this );
*
* mSecrecy = new QComboBox( this );
* mSecrecy->addItem( "Public" );
* mSecrecy->addItem( "Private" );
* mSecrecy->addItem( "Confidential" );
*
* layout->addWidget( new QLabel( "Secrecy:" ) );
* layout->addWidget( mSecrecy );
*
* setPageTitle( i18n( "Secrecy" ) );
* }
*
* void load( const Collection &collection )
* {
* SecrecyAttribute *attr = collection.attribute( "secrecy" );
*
* switch ( attr->secrecy() ) {
* case SecrecyAttribute::Public: mSecrecy->setCurrentIndex( 0 ); break;
* case SecrecyAttribute::Private: mSecrecy->setCurrentIndex( 1 ); break;
* case SecrecyAttribute::Confidential: mSecrecy->setCurrentIndex( 2 ); break;
* }
* }
*
* void save( Collection &collection )
* {
* SecrecyAttribute *attr = collection.attribute( "secrecy" );
*
* switch ( mSecrecy->currentIndex() ) {
* case 0: attr->setSecrecy( SecrecyAttribute::Public ); break;
* case 1: attr->setSecrecy( SecrecyAttribute::Private ); break;
* case 2: attr->setSecrecy( SecrecyAttribute::Confidential ); break;
* }
* }
*
* bool canHandle( const Collection &collection ) const
* {
* return collection.hasAttribute( "secrecy" );
* }
* };
*
* AKONADI_COLLECTION_PROPERTIES_PAGE_FACTORY( SecrecyPageFactory, SecrecyPage )
*
* @endcode
*
* @see Akonadi::CollectionPropertiesDialog, Akonadi::CollectionPropertiesPageFactory
*
* @author Volker Krause <vkrause@kde.org>
*/
class AKONADI_EXPORT CollectionPropertiesPage : public QWidget
{
Q_OBJECT
public:
/**
* Creates a new collection properties page.
*
* @param parent The parent widget.
*/
explicit CollectionPropertiesPage(QWidget *parent = 0);
/**
* Destroys the collection properties page.
*/
~CollectionPropertiesPage();
/**
* Loads the page content from the given collection.
*
* @param collection The collection to load.
*/
virtual void load(const Collection &collection) = 0;
/**
* Saves page content to the given collection.
*
* @param collection Reference to the collection to save to.
*/
virtual void save(Collection &collection) = 0;
/**
* Checks if this page can actually handle the given collection.
*
* Returns @c true if the collection can be handled, @c false otherwise
* The default implementation returns always @c true. When @c false is returned
* this page is not shown in the properties dialog.
* @param collection The collection to check.
*/
virtual bool canHandle(const Collection &collection) const;
/**
* Sets the page title.
*
* @param title Translated, preferbly short tab title.
*/
void setPageTitle(const QString &title);
/**
* Returns the page title.
*/
QString pageTitle() const;
private:
//@cond PRIVATE
class Private;
Private *const d;
//@endcond
};
/**
* @short A factory class for collection properties dialog pages.
*
* The factory encapsulates the creation of the collection properties
* dialog page.
* You can use the AKONADI_COLLECTION_PROPERTIES_PAGE_FACTORY macro
* to create a factory class automatically.
*
* @author Volker Krause <vkrause@kde.org>
*/
class AKONADI_EXPORT CollectionPropertiesPageFactory
{
public:
/**
* Destroys the collection properties page factory.
*/
virtual ~CollectionPropertiesPageFactory();
/**
* Returns the actual page widget.
*
* @param parent The parent widget.
*/
virtual CollectionPropertiesPage *createWidget(QWidget *parent = 0) const = 0;
};
/**
* @def AKONADI_COLLECTION_PROPERTIES_PAGE_FACTORY
*
* The AKONADI_COLLECTION_PROPERTIES_PAGE_FACTORY macro can be used to
* create a factory for a custom collection properties page.
*
* @code
*
* class MyPage : public Akonadi::CollectionPropertiesPage
* {
* ...
* }
*
* AKONADI_COLLECTION_PROPERTIES_PAGE_FACTORY( MyPageFactory, MyPage )
*
* @endcode
*
* The macro takes two arguments, where the first one is the name of the
* factory class that shall be created and the second arguments is the name
* of the custom collection properties page class.
*
* @ingroup AkonadiMacros
*/
#define AKONADI_COLLECTION_PROPERTIES_PAGE_FACTORY(factoryName, className) \
class factoryName : public Akonadi::CollectionPropertiesPageFactory \
{ \
public: \
inline Akonadi::CollectionPropertiesPage *createWidget( QWidget *parent = 0 ) const \
{ \
return new className( parent ); \
} \
};
}
#endif
|