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

« back to all changes in this revision

Viewing changes to corelib/metatype.cpp

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2011-12-08 22:46:54 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20111208224654-n2vxap05cxp0i2v7
Tags: 0.2.0-0ubuntu1
* New upstream release
* Merge with Debian, remaining changes:
 - conflict/replace old libgrantlee0
* Remove missing symbols from .symbols files, upstream says they are no longer
  all virtual but they are inline

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
  This file is part of the Grantlee template system.
3
 
 
4
 
  Copyright (c) 2010 Michael Jansen <kde@michael-jansen.biz>
5
 
  Copyright (c) 2010 Stephen Kelly <steveire@gmail.com>
6
 
 
7
 
  This library is free software; you can redistribute it and/or
8
 
  modify it under the terms of the GNU Lesser General Public
9
 
  License as published by the Free Software Foundation; either version
10
 
  2.1 of the Licence, or (at your option) any later version.
11
 
 
12
 
  This library is distributed in the hope that it will be useful,
13
 
  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
 
  Lesser General Public License for more details.
16
 
 
17
 
  You should have received a copy of the GNU Lesser General Public
18
 
  License along with this library.  If not, see <http://www.gnu.org/licenses/>.
19
 
 
20
 
*/
21
 
 
22
 
#include "metatype.h"
23
 
 
24
 
#include "customtyperegistry_p.h"
25
 
 
26
 
#include <QtCore/QDebug>
27
 
 
28
 
using namespace Grantlee;
29
 
 
30
 
Q_GLOBAL_STATIC(CustomTypeRegistry, customTypes)
31
 
 
32
 
 
33
 
void Grantlee::MetaType::internalLock()
34
 
{
35
 
  return customTypes()->mutex.lock();
36
 
}
37
 
 
38
 
void Grantlee::MetaType::internalUnlock()
39
 
{
40
 
  return customTypes()->mutex.unlock();
41
 
}
42
 
 
43
 
void Grantlee::MetaType::registerLookUpOperator( int id, LookupFunction f )
44
 
{
45
 
  Q_ASSERT(id>0);
46
 
  Q_ASSERT(f);
47
 
  if ( id < 0 ) {
48
 
    qWarning() << "registerTypeOperators() called with invalid arguments";
49
 
    return;
50
 
  }
51
 
  customTypes()->registerLookupOperator( id, f );
52
 
}
53
 
 
54
 
void Grantlee::MetaType::registerToVariantListOperator( int id, ToVariantListFunction f )
55
 
{
56
 
  Q_ASSERT(id>0);
57
 
  Q_ASSERT(f);
58
 
  if ( id < 0 ) {
59
 
    qWarning() << "registerTypeOperators() called with invalid arguments";
60
 
    return;
61
 
  }
62
 
  customTypes()->registerToListOperator( id, f );
63
 
}
64
 
 
65
 
QVariant Grantlee::MetaType::lookup( const QVariant &object, const QString &property )
66
 
{
67
 
  {
68
 
    static const int i = MetaType::initBuiltins();
69
 
    Q_UNUSED(i)
70
 
  }
71
 
  return customTypes()->lookup( object, property );
72
 
}
73
 
 
74
 
QVariantList Grantlee::MetaType::toVariantList( const QVariant &obj )
75
 
{
76
 
  {
77
 
    static const int i = MetaType::initBuiltins();
78
 
    Q_UNUSED(i)
79
 
  }
80
 
  return customTypes()->toVariantList( obj );
81
 
}
82
 
 
83
 
bool Grantlee::MetaType::lookupAlreadyRegistered( int id )
84
 
{
85
 
  return customTypes()->lookupAlreadyRegistered( id );
86
 
}
87
 
 
88
 
bool Grantlee::MetaType::toListAlreadyRegistered( int id )
89
 
{
90
 
  return customTypes()->toListAlreadyRegistered( id );
91
 
}