app.cpp Example File
filtereddatamodel/src/app.cpp
#include <bb/cascades/AbstractPane>
#include <bb/cascades/Application>
#include <bb/cascades/QmlDocument>
#include "app.hpp"
#include "filtereddatamodel.hpp"
#include "vegetablesdatamodel.hpp"
using namespace bb::cascades;
App::App(QObject *parent)
: QObject(parent)
, m_model(0)
{
VegetablesDataModel *vegetablesModel = new VegetablesDataModel(this);
m_model = new FilteredDataModel(vegetablesModel, this);
QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);
qml->setContextProperty("_model", m_model);
qml->setContextProperty("_app", this);
AbstractPane* root = qml->createRootObject<AbstractPane>();
Application::instance()->setScene(root);
}
void App::selectionChanged(const QVariantList &indexPath, bool selected)
{
if (indexPath.size() != 1 || !selected)
return;
const int selection = indexPath[0].toInt();
m_model->expandHeader(selection, !m_model->isHeaderExpanded(selection));
}