Static Public Member Functions | List of all members
FilterPaginate Class Reference

The implementation of the "paginate" filter. More...

Static Public Member Functions

static TemplateVariant apply (const TemplateVariant &v, const TemplateVariant &args)
 

Detailed Description

The implementation of the "paginate" filter.

Definition at line 1046 of file template.cpp.

Member Function Documentation

static TemplateVariant FilterPaginate::apply ( const TemplateVariant v,
const TemplateVariant args 
)
inlinestatic

Definition at line 1049 of file template.cpp.

1050  {
1051  if (v.isValid() && v.type()==TemplateVariant::List &&
1052  args.isValid() && args.type()==TemplateVariant::Integer)
1053  {
1054  int pageSize = args.toInt();
1055  TemplateListIntf *list = v.toList();
1058  TemplateVariant item;
1059  TemplateList *pageList=0;
1060  int i = 0;
1061  for (it->toFirst();(it->current(item));it->toNext())
1062  {
1063  if (pageList==0)
1064  {
1065  pageList = TemplateList::alloc();
1066  result->append(pageList);
1067  }
1068  pageList->append(item);
1069  i++;
1070  if (i==pageSize) // page is full start a new one
1071  {
1072  pageList=0;
1073  i=0;
1074  }
1075  }
1076  delete it;
1077  return result;
1078  }
1079  else // wrong arguments
1080  {
1081  return v;
1082  }
1083  }
static TemplateList * alloc()
Definition: template.cpp:420
static QCString result
virtual bool current(TemplateVariant &v) const =0
TemplateListIntf * toList() const
Definition: template.h:256
Default implementation of a context value of type list.
Definition: template.h:376
virtual void append(const TemplateVariant &v)
Definition: template.cpp:343
int toInt() const
Definition: template.cpp:222
Abstract interface for a iterator of a list.
Definition: template.h:333
bool isValid() const
Definition: template.h:161
virtual TemplateListIntf::ConstIterator * createIterator() const =0
Variant type which can hold one value of a fixed set of types.
Definition: template.h:90
Type type() const
Definition: template.h:142
Abstract read-only interface for a context value of type list.
Definition: template.h:329

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