Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Toutes les fonctions  ·  Vues d'ensemble  · 

ThemeListModel Class Reference
[QtBaseModule]

The ThemeListModel class provides a list model that is used for list functionality in Qt Extended theming. More...

    #include <ThemeListModel>

Inherits QAbstractListModel.

Public Functions

Protected Functions

  • QList<ThemeListModelEntry *> items () const

Additional Inherited Members


Detailed Description

The ThemeListModel class provides a list model that is used for list functionality in Qt Extended theming.

List functionality in theming is implemented using Qt's model-view architecture and theme templates.

To use a ThemeListModel you pass in the associated ThemeListItem and ThemedView objects during construction, and then populate it with ThemeListModelEntry items using the addEntry() and removeEntry() functions. The ThemeListModel installs itself as the model for the ThemeListItem's QListView object during construction. From that point on communication between the QListView and the ThemeListModel occurs through Qt's model-view architecture.

Theme templates are used to describe the visual look of items in the ThemeListModel. As a list's items are added dynamically at runtime, they cannot be specified in the themed view XML. However, using theme templates, the visual appearance of a list item is defined instead, which is used to draw items as appropriate. Instances of these theme templates can be created at anytime using ThemeTemplateItem::createInstance().

An internal implementation of QItemDelegate called ThemeListDelegate exists to handle communication between the QListView of a ThemeListItem, and associated ThemeListModel/ThemeListModelEntry objects. It works completely under the hood, and so this information is given only to help the developer understand how the system works.

The ThemeListDelegate is installed using QListView::setItemDelegate() on the ThemeListItem's QListView. Qt's model-view architecture then asks the delegate to paint items in the QListView as required. When requested to repaint a particular QModelIndex in the QListView, the ThemeItemDelegate performs the following functions:

See the ThemeTemplateItem and ThemeListModelEntry documentation for more information.

The valuespace is used to communicate data from the system to items in the themed list. Normally a valuespace path can be assigned in the themed view XML to items using the vspath attribute of ThemeItem. However, as template definitions representing a theme list items' visual appearance are not actual instances, their vspath is dynamically determined and set at runtime when they are created using ThemeTemplateItem::createInstance(). ThemeTemplateItem::createInstance() takes a uid which is actually set to the vspath of the returned ThemeTemplateInstance. For template instances created by ThemeListModelEntry::templateInstance() the uid passed is the return value of ThemeListModelEntry::uid(). This acts as a unique association between a theme template instance and the ThemeListModelEntry, as well as a unique valuespace path for both to communicate under. A call to ThemeListModelEntry::setValue() set keys under this unique vspath. For example, given the following themed view XML definition:

    <list vspath="/UserInterface/MyList/">
        <template name="myListItem">
            <text name="titleMessage">@TitleMessage</text>
        </template>
    </list>

you could set the text of the element 'titleMessage' with the following:

    ThemeListModelEntry* myEntry; // assuming that myEntry->type() returns "myListItem"
    ..
    myEntry->setValue("TitleMessage", "Hello, World"); // expands to /UserInterface/MyList/<myEntry->uid()>/TitleMessage

See also Themed View Elements, ThemeTemplateItem, ThemeTemplateInstanceItem, and ThemeListModelEntry.


Member Function Documentation

ThemeListModel::ThemeListModel ( QObject * parent, ThemeListItem * listItem, ThemedView * view )

Constructs a ThemeListModel. parent is passed to QAbstractListModel, listItem is the ThemeListItem associated with this model and view is the ThemedView associated with this model. The model is installed on the ThemeListItem listItem using the ThemeListItem::setModel() function.

ThemeListModel::~ThemeListModel ()   [virtual]

Destroys the model. All items in the model are deleted.

void ThemeListModel::addEntry ( ThemeListModelEntry * item )

Adds item to the end of this model. ThemeListModel takes ownership of item and will delete it when it is removed.

void ThemeListModel::clear ()

Clears all items from the model. The items are deleted.

QModelIndex ThemeListModel::entryIndex ( const ThemeListModelEntry * entry ) const

Returns the index of the item entry in the model.

QList<ThemeListModelEntry *> ThemeListModel::items () const   [protected]

Returns a QList of all items in the model.

ThemeListItem * ThemeListModel::listItem () const

Returns the ThemeListItem instance associated with this model.

void ThemeListModel::removeEntry ( const QModelIndex & index )

Removes the item at index from the mdoel. The item is deleted.

ThemeListModelEntry * ThemeListModel::themeListModelEntry ( const QModelIndex & index ) const

Returns a pointer to the ThemeListModelEntry at index.

ThemedView * ThemeListModel::themedView () const

Returns the ThemedView instance associated with this model.

void ThemeListModel::triggerUpdate ()

Triggers an update in the view for all items in the model.

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 64
  2. Apercevoir la troisième dimension ou l'utilisation multithreadée d'OpenGL dans Qt, un article des Qt Quarterly traduit par Guillaume Belz 0
  3. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  4. BlackBerry 10 : premières images du prochain OS de RIM qui devrait intégrer des widgets et des tuiles inspirées de Windows Phone 0
  5. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  6. Adieu qmake, bienvenue qbs : Qt Building Suite, un outil déclaratif et extensible pour la compilation de projets Qt 17
  7. La rubrique Qt a besoin de vous ! 1
Page suivante

Le Qt Quarterly au hasard

Logo

Abusons de QMap

Qt Quarterly est la revue trimestrielle proposée par Nokia et à destination des développeurs Qt. Ces articles d'une grande qualité technique sont rédigés par des experts Qt. Lire l'article.

Communauté

Ressources

Liens utiles

Contact

  • Vous souhaitez rejoindre la rédaction ou proposer un tutoriel, une traduction, une question... ? Postez dans le forum Contribuez ou contactez-nous par MP ou par email (voir en bas de page).

Qt dans le magazine

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt qtextended4.4
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web