Blackberry のリストの項目をクリックできるようにする方法を見つけようとしています。QML、C++、QT、および Blackberry 10 Cascades を使用しています。リスト ビューを実装してから、この Twitter タイムラインの例を見て、リストの項目をクリックできるようにしようとしました (ところで、例を実行できませんでした)。
私がやっていることはうまくいきません。listView_->setListItemManager(new CustomerListItemManager(customerListContainer_)) を呼び出すと、リスト ビューが空白になります (そのコードを追加する前に、リスト ビューが表示されました)。
したがって、基本的に、リスト上の項目をクリックして応答させる機能を取得する方法は次のとおりです。
とにかく - ここに私がこれまでに試したことの関連コードがあります:
Container {
id: customersListContainer
objectName: "customersListContainer"
ListView {
id: customersList
objectName: "customersList"
listItemComponents: [
ListItemComponent {
type: "item"
Container {
HeaderListItem {
title: ListItemData.firstName + " " + ListItemData.lastName
}
StandardListItem {
title: ListItemData.officePhone + "\t" + ListItemData.cellPhone
description: ListItemData.email
}
]
}
}
CustomerListItemManager.cpp:
CustomerListItemManager::CustomerListItemManager() {}
CustomerListItemManager::~CustomerListItemManager() {}
VisualNode *CustomerListItemManager::createItem(ListView *list, const QString &type)
{
//the CustomerList::getInstance()->customerListContainer returns the customersListContainer (see the qml code above)
//
return new CustomerItem(CustomerList::getInstance()->customerListContainer());
}
void CustomerListItemManager::updateItem(ListView *list, VisualNode *control, const QString &type, const QVariantList &indexPath, const QVariant &data)
{
QObject* obj = qvariant_cast<QObject *>(data);
CustomerData* customer = qobject_cast<CustomerData *>(obj);
}
CustomerItem.cpp:
CustomerItem::CustomerItem(Container *parent) : CustomControl(parent) {}
CustomerItem::~CustomerItem() {}
void CustomerItem::updateItem(const QString text, QDateTime date) {}
void CustomerItem::select(bool select) {
// Is this where you handle the response to clicking on an item on the list???
//
if (select) qDebug() << "item selected";
else;
}
void CustomerItem::reset(bool selected, bool activated) {
select(selected);
}
void CustomerItem::activate(bool activate) { Q_UNUSED(activate); }
リストを別のファイルに取り込む:
for (int i = 0; i < customers->length(); ++i) {
groupDataModel_.insert(customers->at(i)
}
listView_->setDataModel(&groupDataModel_);
//the customerListContainer_ is the customersListContainer (see the qml code above)
//
listView_->setListItemManager(new ListItemManager(customerListContainer_);