本文整理汇总了C++中Place::name方法的典型用法代码示例。如果您正苦于以下问题:C++ Place::name方法的具体用法?C++ Place::name怎么用?C++ Place::name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Place
的用法示例。
在下文中一共展示了Place::name方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QVariant
QVariant
PlaceListModel::data (const QModelIndex &index, int role) const
{
int idx = index.row ();
if (idx < 0 || m_data.count () <= idx)
return QVariant();
Place *place = m_data[idx];
switch (role)
{
case NAME:
return place->name ();
case PUBKEY:
return place->pubKeyString ();
case TYPE:
return place->type ();
case DESC:
return place->desc ();
case THREADS:
return &m_threads[idx];
default:
return QVariant();
}
}
示例2: data
/*!
From QAbstractListModel.
Returns data from model by \a index by \a role.
*/
QVariant PlacesModel::data(const QModelIndex &index,
int role /* Qt::DisplayRole */) const
{
if (!index.isValid()) {
return QVariant();
}
const int itemIndex(index.row());
const int placesCount(mPlaces.count());
int virtualIndex(0);
Place *place = 0;
// Skip all invisible places
for (int i = 0; i < placesCount; ++i) {
if (mPlaces[i]->visible()) {
if (itemIndex == virtualIndex) {
place = mPlaces[i];
break;
}
else {
virtualIndex++;
}
}
}
if (!place) {
return QVariant();
}
QVariant value = QVariant();
switch (role) {
case NameRole:
value = QVariant::fromValue(place->name());
break;
case StreetAddressRole:
value = QVariant::fromValue(place->address().street());
break;
case LatitudeRole:
value = QVariant::fromValue(place->coordinate().latitude());
break;
case LongitudeRole:
value = QVariant::fromValue(place->coordinate().longitude());
break;
case IconUrlRole:
value = QVariant::fromValue(place->iconUrl());
break;
case PlaceObjectRole:
value = QVariant::fromValue((QObject*)place);
break;
default:
break;
}
return value;
}