~ubuntu-branches/ubuntu/trusty/grantlee/trusty

« back to all changes in this revision

Viewing changes to templates/lib/typeaccessor.h

  • Committer: Package Import Robot
  • Author(s): Scott Kitterman
  • Date: 2012-11-21 11:04:39 UTC
  • mfrom: (1.1.5)
  • Revision ID: package-import@ubuntu.com-20121121110439-tzyjomgtnpmdnsxn
Tags: 0.3.0-0ubuntu1
* New upsteam release
  - Update libgrantlee-core0.symbols
* Add wildcards to *.install files to avoid unneeded build failures

Show diffs side-by-side

added added

removed removed

Lines of Context:
66
66
{
67
67
  static QVariant doLookUp( const Container &container, const QString &property )
68
68
  {
 
69
    if ( property == QLatin1String( "size" ) || property == QLatin1String( "count" ) ) {
 
70
      return QVariant::fromValue<int>( std::distance( container.begin(), container.end() ) );
 
71
    }
 
72
 
69
73
    bool ok = false;
70
74
    const size_t listIndex = ( size_t )property.toInt( &ok );
71
75
 
85
89
    if ( it != object.end() )
86
90
      return QVariant::fromValue( MappedValueGetter<Container>::get( it ) );
87
91
  }
 
92
  if ( property == QLatin1String( "size" ) || property == QLatin1String( "count" ) ) {
 
93
      return QVariant::fromValue<int>( std::distance( object.begin(), object.end() ) );
 
94
  }
88
95
  if ( property == QLatin1String( "items" ) ) {
89
96
    typename Container::const_iterator it = object.begin();
90
97
    const typename Container::const_iterator end = object.end();
146
153
template<typename T>                                                  \
147
154
struct TypeAccessor<Container<T>&>                                    \
148
155
{                                                                     \
149
 
  static QVariant lookUp( const Container<T> &, const QString &)      \
 
156
  static QVariant lookUp( const Container<T> &c, const QString &p)    \
150
157
  {                                                                   \
 
158
    if ( p == QLatin1String( "size" )                                 \
 
159
      || p == QLatin1String( "count" ) ) {                            \
 
160
      return QVariant::fromValue<int>(                                \
 
161
          std::distance( c.begin(), c.end() ) );                      \
 
162
    }                                                                 \
151
163
    return QVariant();                                                \
152
164
  }                                                                   \
153
165
};                                                                    \