KDE 4.9 PyKDE API Reference

- KDE's Python API

# TagWidget Class Reference

`from PyKDE4.nepomuk import *`

Inherits: QWidget
Namespace: Nepomuk

## Detailed Description

\class TagWidget tagwidget.h Nepomuk/TagWidget

Allows to change a selection of tags.

TagWidget provides a simple GUI interface to assign tags. It has two basic modes:

- If resources are set via setTaggedResource() or setTaggedResources()
the changes in the tag selection are automatically assigned to the selected resources.
- If no resources have been set the widget simply emits the selectionChanged()
signal.

Author:
  Sebastian Trueg <trueg@kde.org>

## Enumerations

ModeFlag | { MiniMode, StandardMode, ReadOnly, DisableTagClicking }

## Signals

| selectionChanged ([Nepomuk.Tag] tags)
| tagClicked (Nepomuk.Tag a0)

## Methods

| __init__ (self, Nepomuk.Resource resource, QWidget parent=0)
| __init__ (self, QWidget parent=0)
Qt::Alignment | alignment (self)
[Nepomuk.Tag] | assignedTags (self)
int | maxTagsShown (self)
Nepomuk.TagWidget.ModeFlags | modeFlags (self)
[Nepomuk.Tag] | selectedTags (self)
| setAlignment (self, Qt::Alignment alignment)
| setAssignedTags (self, [Nepomuk.Tag] tags)
| setMaxTagsShown (self, int max)
| setModeFlags (self, Nepomuk.TagWidget.ModeFlags flags)
| setSelectedTags (self, [Nepomuk.Tag] tags)
| setTaggedResource (self, Nepomuk.Resource resource)
| setTaggedResources (self, [Nepomuk.Resource] resources)
[Nepomuk.Resource] | taggedResources (self)

## Signal Documentation

selectionChanged | ( | [Nepomuk.Tag] | tags
| ) |  |  |

Emitted whenever the selection of tags changes.

Since:
  4.5

Signal syntax:
  `QObject.connect(source, SIGNAL("selectionChanged(const QList<Nepomuk::Tag>&)"), target_slot)`

tagClicked | ( | Nepomuk.Tag | a0
| ) |  |  |

This signal is emitted whenever a tag is clicked.

Signal syntax:
  `QObject.connect(source, SIGNAL("tagClicked(Nepomuk::Tag)"), target_slot)`

## Method Documentation

__init__ | ( | self, |
|  | Nepomuk.Resource | resource,
|  | QWidget | parent=0
| ) |  |  |

Creates a new TagWidget for resource. The assigned tags are loaded instantly.

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

Constructor

Qt::Alignment alignment | ( |  | self ) |

The alignment of the tags in the widget.

Since:
  4.5

[Nepomuk.Tag] assignedTags | ( |  | self ) |

Deprecated:
  use selectedTags() instead

int maxTagsShown | ( |  | self ) |

By default the TagWidget shows the most often used tags in the main window and allows access to all tags via an additional button. This is the maximum number of tags that should be shown unless they are selected.

\sa setMaxTagsShown()

Since:
  4.5

Nepomuk.TagWidget.ModeFlags modeFlags | ( |  | self ) |

Flags the widget is configured with.

\sa setModeFlags()

Since:
  4.5

[Nepomuk.Tag] selectedTags | ( |  | self ) |

The list of selected tags.

Returns:
  The list of all tags that are currently selected. In case resources to be tagged have been selected this list matches the tags assigned to the resources.

\sa setTaggedResource, taggedResource, Resource.getTags

Since:
  4.5

setAlignment | ( | self, |
|  | Qt::Alignment | alignment
| ) |  |  |

Set the alignment to use. Only horizontal alignment flags make a difference.

Since:
  4.5

setAssignedTags | ( | self, |
|  | [Nepomuk.Tag] | tags
| ) |  |  |

Deprecated:
  use setSelectedTags() instead

setMaxTagsShown | ( | self, |
|  | int | max
| ) |  |  |

By default the TagWidget shows the most often used tags in the main window and allows access to all tags via an additional button.

The number of tags that are shown by default can be changed.

Parameters:

  | max | The maximum number of tags that should be shown in the main window. Set to 0 for no limit. Be aware that more tags might be shown since selected tags are always shown.

Since:
  4.5

setModeFlags | ( | self, |
|  | Nepomuk.TagWidget.ModeFlags | flags
| ) |  |  |

Set flags to change the behaviour and look of the tag widget.

Since:
  4.5

setSelectedTags | ( | self, |
|  | [Nepomuk.Tag] | tags
| ) |  |  |

Set the list of selected tags. In case resources have been set via setTaggedResource() or setTaggedResources() their list of tags is changed automatically.

Since:
  4.5

setTaggedResource | ( | self, |
|  | Nepomuk.Resource | resource
| ) |  |  |

Set the Resource to be tagged. The assigned tags will be loaded instantly.

setTaggedResources | ( | self, |
|  | [Nepomuk.Resource] | resources
| ) |  |  |

Set the resources to be tagged. If the list of resources is empty TagWidget will only emit the selectionChanged() signal.

[Nepomuk.Resource] taggedResources | ( |  | self ) |

Returns:
  The resources that are supposed to be tagged or an empty list if none have been set.

## Enumeration Documentation

ModeFlag

Flags to configure the widget.

Since:
  4.5

Enumerator:

  MiniMode = 0x1 |
  StandardMode = 0x2 |
  ReadOnly = 0x4 |
  DisableTagClicking = 0x8 |