FtpListItem.cpp Example File
qftp/src/FtpListItem.cpp
#include "FtpListItem.hpp"
#include <bb/cascades/Container>
#include <bb/cascades/DockLayout>
#include <bb/cascades/FontSize>
#include <bb/cascades/ImageView>
#include <bb/cascades/Image>
#include <bb/cascades/Label>
#include <bb/cascades/StackLayout>
#include <bb/cascades/StackLayoutProperties>
#include <bb/cascades/SystemDefaults>
#include <bb/cascades/TextStyle>
using namespace bb::cascades;
FtpListItem::FtpListItem(Container *parent)
: CustomControl(parent)
{
Container *contents = new Container();
StackLayout *contentsLayout = new StackLayout();
contentsLayout->setOrientation(LayoutOrientation::LeftToRight);
contents->setLayout(contentsLayout);
Container *backgroundContainer = new Container();
backgroundContainer->setPreferredHeight(141);
DockLayout *backgroundLayout = new DockLayout();
backgroundContainer->setLayout(backgroundLayout);
backgroundContainer->setHorizontalAlignment(HorizontalAlignment::Fill);
m_highlighContainer = new ImageView();
m_highlighContainer->setImage(Image(QUrl("asset:///images/highlighted.png")));
m_highlighContainer->setOpacity(0.0);
m_itemImage = new ImageView();
m_itemImage->setLayoutProperties(StackLayoutProperties::create());
m_itemImage->setMinWidth(128.0f);
m_itemImage->setMinHeight(128.0f);
Container *textContents = new Container();
m_itemTitle = Label::create();
m_itemTitle->textStyle()->setBase(SystemDefaults::TextStyles::titleText());
m_itemTitle->textStyle()->setColor(Color::Black);
m_itemDescription = Label::create();
m_itemDescription->textStyle()->setBase(SystemDefaults::TextStyles::smallText());
m_itemDescription->textStyle()->setColor(Color::Black);
m_itemDescription->textStyle()->setFontSize(FontSize::Medium);
contents->add(m_itemImage);
contents->add(textContents);
textContents->add(m_itemTitle);
textContents->add(m_itemDescription);
backgroundContainer->add(m_highlighContainer);
backgroundContainer->add(contents);
setRoot(backgroundContainer);
}
void FtpListItem::setImage(const Image &image)
{
m_itemImage->setImageSource(image.source());
}
void FtpListItem::setTitleText(const QString &title)
{
m_itemTitle->setText(title);
}
void FtpListItem::setStatusText(const QString &status)
{
m_itemDescription->setText(status);
}
void FtpListItem::select(bool select)
{
if (select) {
m_highlighContainer->setOpacity(1.0f);
} else {
m_highlighContainer->setOpacity(0.0f);
}
}
void FtpListItem::reset(bool selected, bool activated)
{
Q_UNUSED(activated);
select(selected);
}
void FtpListItem::activate(bool activate)
{
select(activate);
}