KDE 4.9 PyKDE API Reference

- KDE's Python API

# CollectionPropertiesPage Class Reference

`from PyKDE4.akonadi import *`

Inherits: QWidget → QObject
Namespace: Akonadi

## Detailed Description

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.

     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 )

See also:
  Akonadi.CollectionPropertiesDialog, Akonadi.CollectionPropertiesPageFactory

Author:
  Volker Krause <vkrause@kde.org>

## Methods

| __init__ (self, QWidget parent=0)
bool | canHandle (self, Akonadi.Collection collection)
| load (self, Akonadi.Collection collection)
QString | pageTitle (self)
| save (self, Akonadi.Collection collection)
| setPageTitle (self, QString title)

## Method Documentation

__init__ | ( | self, |
|  | QWidget | parent=0
| ) |  |  |

Creates a new collection properties page.

Parameters:

  | parent | The parent widget.

bool canHandle | ( | self, |
|  | Akonadi.Collection | collection
| ) |  |  |

Checks if this page can actually handle the given collection.

Returns true if the collection can be handled, false otherwise The default implementation returns always true. When false is returned this page is not shown in the properties dialog.

Parameters:

  | collection | The collection to check.

load | ( | self, |
|  | Akonadi.Collection | collection
| ) |  |  |

Abstract method:
  This method is abstract and can be overridden but not called directly.

Loads the page content from the given collection.

Parameters:

  | collection | The collection to load.

QString pageTitle | ( |  | self ) |

Returns the page title.

save | ( | self, |
|  | Akonadi.Collection | collection
| ) |  |  |

Abstract method:
  This method is abstract and can be overridden but not called directly.

Saves page content to the given collection.

Parameters:

  | collection | Reference to the collection to save to.

setPageTitle | ( | self, |
|  | QString | title
| ) |  |  |

Sets the page title.

Parameters:

  | title | Translated, preferbly short tab title.