Container *LightningCrossfadeApp::setUpImageContainer()
{
    // In this function a Container containing two images are set up.
    // A dock layout is used to align the images.
    Container* nightAndDayContainer = new Container();
    nightAndDayContainer->setLayout(new DockLayout());

    // The first image is the night image, taken at the same
    // position as the day one, but further from the viewer.
    ImageView* night = ImageView::create("asset:///images/night.jpg");

    // Center it using alignment.
    night->setHorizontalAlignment(HorizontalAlignment::Center);
    night->setVerticalAlignment(VerticalAlignment::Center);
    // Add A11y description to the image
    night->accessibility()->setDescription(
            "This is the night image. Change it with the slider in the bottom of the screen.");

    // Now, we will overlay the day image on top of the night image.
    // Since the day image is on top of the night one, we can show the
    // night image with changing the opacity value of this image.
    ImageView* day = ImageView::create("asset:///images/day.jpg").opacity(0);

    // Center it using alignment.
    day->setHorizontalAlignment(HorizontalAlignment::Center);
    day->setVerticalAlignment(VerticalAlignment::Center);
    // Add A11y description to the image
    day->accessibility()->setDescription(
            "This is the day image. Change it with the slider in the bottom of the screen");

    // The day image is attached to the slider later. We need to be able to
    // find the object at a later point in time so an object name is assigned.
    day->setObjectName("dayImage");

    // Now add all the images to the Container and the alignment will be
    // automatically done by the layout system.
    nightAndDayContainer->add(night);
    nightAndDayContainer->add(day);

    return nightAndDayContainer;
}
NSRTocPage::NSRTocPage (bb::cascades::NavigationPane *naviPane, QObject *parent) :
	Page (parent),
	_translator (NULL),
	_toc (NULL),
	_naviPane (naviPane),
	_listView (NULL),
	_model (NULL),
	_emptyContainer (NULL),
	_noTocLabel (NULL),
	_noFileLabel (NULL)
{
	_translator = new NSRTranslator (this);

	Container *rootContainer = Container::create().horizontal(HorizontalAlignment::Fill)
						      .vertical(VerticalAlignment::Fill)
						      .layout(DockLayout::create ());

	_listView = new ListView ();
	_listView->setVerticalAlignment (VerticalAlignment::Fill);
	_listView->setHorizontalAlignment (HorizontalAlignment::Fill);
	_listView->setListItemProvider (new NSRTocItemFactory ());

	bool ok = connect (_listView, SIGNAL (triggered (QVariantList)), this, SLOT (onListItemTriggered (QVariantList)));
	Q_UNUSED (ok);
	Q_ASSERT (ok);

	Label *emptyLabel = Label::create().horizontal(HorizontalAlignment::Center)
					   .vertical(VerticalAlignment::Center)
					   .multiline(true)
					   .text(trUtf8 ("No contents", "List of contents related to opened file"));
	emptyLabel->textStyle()->setFontSize (FontSize::Large);
	emptyLabel->textStyle()->setTextAlign (TextAlign::Center);

	_noTocLabel = Label::create().horizontal(HorizontalAlignment::Center)
				     .vertical(VerticalAlignment::Center)
				     .multiline(true)
				     .text(trUtf8 ("No contents to display"));
	_noTocLabel->textStyle()->setFontSize (FontSize::Medium);
	_noTocLabel->textStyle()->setTextAlign (TextAlign::Center);

	_noFileLabel = Label::create().horizontal(HorizontalAlignment::Center)
					   .vertical(VerticalAlignment::Center)
					   .multiline(true)
					   .text(trUtf8 ("Open file to display contents"));
	_noFileLabel->textStyle()->setFontSize (FontSize::Medium);
	_noFileLabel->textStyle()->setTextAlign (TextAlign::Center);

	ImageView *emptyImage = ImageView::create().horizontal(HorizontalAlignment::Center)
						   .vertical(VerticalAlignment::Center)
						   .imageSource(QUrl ("asset:///contents-area.png"));

#if BBNDK_VERSION_AT_LEAST(10,2,0)
	emptyImage->accessibility()->setName (trUtf8 ("Image of contents"));
#endif

	_emptyContainer = Container::create().horizontal(HorizontalAlignment::Center)
					     .vertical(VerticalAlignment::Center)
					     .layout(StackLayout::create ());

#if BBNDK_VERSION_AT_LEAST(10,3,1)
	_emptyContainer->setLeftPadding (ui()->sddu (2));
	_emptyContainer->setRightPadding (ui()->sddu (2));
#elif BBNDK_VERSION_AT_LEAST(10,3,0)
	_emptyContainer->setLeftPadding (ui()->sdu (2));
	_emptyContainer->setRightPadding (ui()->sdu (2));
#else
	_emptyContainer->setLeftPadding (20);
	_emptyContainer->setRightPadding (20);
#endif

	_emptyContainer->add (emptyImage);
	_emptyContainer->add (emptyLabel);
	_emptyContainer->add (_noTocLabel);
	_emptyContainer->add (_noFileLabel);

	rootContainer->add (_listView);
	rootContainer->add (_emptyContainer);
	rootContainer->setBackground (NSRThemeSupport::instance()->getBackground ());

	setContent (rootContainer);
	setTitleBar (TitleBar::create().title(trUtf8 ("Contents", "Title for window with contents")));

	_translator->addTranslatable ((UIObject *) emptyLabel,
				      NSRTranslator::NSR_TRANSLATOR_TYPE_LABEL,
				      QString ("NSRTocPage"),
				      QString ("No contents"));
	_translator->addTranslatable ((UIObject *) _noTocLabel,
				      NSRTranslator::NSR_TRANSLATOR_TYPE_LABEL,
				      QString ("NSRTocPage"),
				      QString ("No contents to display"));
	_translator->addTranslatable ((UIObject *) _noFileLabel,
				      NSRTranslator::NSR_TRANSLATOR_TYPE_LABEL,
				      QString ("NSRTocPage"),
				      QString ("Open file to display contents"));
	_translator->addTranslatable ((UIObject *) titleBar (),
				      NSRTranslator::NSR_TRANSLATOR_TYPE_TITLEBAR,
				      QString ("NSRTocPage"),
				      QString ("Contents"));

#if BBNDK_VERSION_AT_LEAST(10,2,0)
	_translator->addTranslatable ((UIObject *) emptyImage->accessibility (),
				      NSRTranslator::NSR_TRANSLATOR_TYPE_A11Y,
				      QString ("NSRTocPage"),
				      QString ("Image of contents"));
#endif

#if BBNDK_VERSION_AT_LEAST(10,1,0)
	_listView->setScrollRole (ScrollRole::Main);
#endif

	ok = connect (NSRGlobalNotifier::instance (), SIGNAL (languageChanged ()),
		      _translator, SLOT (translate ()));
	Q_ASSERT (ok);

#if BBNDK_VERSION_AT_LEAST(10,3,1)
	ok = connect (ui (), SIGNAL (dduFactorChanged (float)),
		      this, SLOT (onDynamicDUFactorChanged (float)));
	Q_ASSERT (ok);
#endif

	_model = new GroupDataModel ();
	_model->setGrouping (ItemGrouping::None);
	_model->setSortingKeys (QStringList ("page-number"));

	_listView->setDataModel (_model);

	/* Show empty label and image */
	unloadDataUi ();
}