Logo Search packages:      
Sourcecode: palapeli version File versions  Download package

Palapeli::PatternConfiguration Class Reference

#include <Palapeli/PatternConfiguration>

Inheritance diagram for Palapeli::PatternConfiguration:

Palapeli::HexagonalPatternConfiguration Palapeli::JigsawPatternConfiguration Palapeli::RectangularPatternConfiguration

List of all members.

Detailed Description

This class is used in a Palapeli pattern plugin to handle the configuration of the pattern. Furthermore, it will have to create a Palapeli::Pattern instance which will then do the actual slicing.

To simplify the creation of arbitrary configurations, this class exposes to subclasses the ability to define properties with a range of different data types. These properties will then be used to construct configuration dialogs automatically. The following example shows how to define a property (this should be done in the constructor of your subclass):

addProperty("myprop", Palapeli::PatternConfiguration::Integer, i18n("My own property:"));
QVariantList range; range << 1 << 10;
addPropertyParameters("myprop", range); //set minimum and maximum value
setProperty("myprop", 3); //set default value

Instances of Palapeli::PatternConfiguration instances are created in the Palapeli::PatternPlugin::createInstances() method for the Palapeli::PatternPlugin subclass of the plugin.

Stefan Majewsky <majewsky@gmx.net>

Definition at line 56 of file pattern-configuration.h.

Public Types

enum  DataType { Variant = 0, String, Integer, Boolean }
 Defines acceptable data types for properties. Note that this does not affect the internal handling of values, these are always passed as QVariant (but it is ensured that they have a specific meta type). The data type defined through this enumeration mainly specifies which configuration widget is used to let the user manipulate this property. More...

Public Slots

void setProperty (const QByteArray &key, const QVariant &value)
 Sets a property to the given value.


void propertyChanged (const QByteArray &key, const QVariant &value)
 This signal is emitted whenever a defined property's value changed.

Public Member Functions

virtual PatterncreatePattern () const =0
 Creates a Pattern instance. You will have to implement this function in your subclass to create your own Palapeli::Pattern instance. This is also the point to pass any property values to your pattern.
 PatternConfiguration (const QString &patternName, const QString &displayName, const QString &iconName)
 Constructs a new PatternConfiguration object. This constructor creates the three properties "PatternName", "DisplayName" and "IconName" which are filled with the given values. You should not modify these properties after this initialisation.
void populateWidget (QWidget *widget)
QVariant property (const QByteArray &key) const
 Reads a property.
void readArguments (KConfigGroup *config)
 Loads parameters from a configuration. This function reads all defined properties from the passed config.
void writeArguments (KConfigGroup *config) const
 Saves parameters to a configuration. This function writes the values of all defined properties to the passed config.
virtual ~PatternConfiguration ()

Protected Member Functions

void addProperty (const QByteArray &key, DataType type, const QString &caption)
 Define a new property.
void addPropertyParameters (const QByteArray &key, const QVariantList &parameters)
 Add parameters to this property. It depends on the DataType of the property what these parameters do. For String properties, the parameters are understood as valid values; the input is then restricted to these options (by using a KComboBox instead of a KLineEdit in configuration dialogs). For Int properties, the first parameter is the minimum value (default is 0), and the second parameter is the maximum value (default is 100); any further parameters are discarded. For all other data types, all parameters are discarded.
virtual void readCustomArguments (KConfigGroup *config)
virtual void writeCustomArguments (KConfigGroup *config) const

Private Attributes

PatternConfigurationPrivate *const p

The documentation for this class was generated from the following files:

Generated by  Doxygen 1.6.0   Back to index