本文整理汇总了C++中setRoleNames函数的典型用法代码示例。如果您正苦于以下问题:C++ setRoleNames函数的具体用法?C++ setRoleNames怎么用?C++ setRoleNames使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setRoleNames函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AbstractTwitterModel
AbstractStatusesModel::AbstractStatusesModel(QObject *parent)
: AbstractTwitterModel(parent)
, m_count(0)
, m_trim_user(false)
, m_include_entities(true)
, m_contributor_details(false)
{
QHash<int, QByteArray> roles;
roles[ContributorsRole] = "contributors";
roles[CoordinatesRole] = "coordinates";
roles[created_at_role] = "created_at";
roles[EntitiesRole] = "entities";
roles[FavoritedRole] = "favorited";
roles[GeoRole] = "geo";
roles[id_role] = "id";
roles[id_str_role] = "id_str";
roles[in_reply_to_screen_nameRole] = "in_reply_to_screen_name";
roles[in_reply_to_status_idRole] = "in_reply_to_status_id_str";
roles[InReplyTouser_idRole] = "in_reply_to_user_id_str";
roles[PlaceRole] = "place";
roles[possibly_sensitiveRole] = "possibly_sensitive";
roles[retweet_countRole] = "retweet_count";
roles[RetweetedRole] = "retweeted";
roles[retweeted_statusRole] = "retweeted_status";
roles[SourceRole] = "source";
roles[TextRole] = "text";
roles[plain_textRole] = "plain_text";
roles[rich_textRole] = "rich_text";
roles[TruncatedRole] = "truncated";
roles[UserRole] = "user";
roles[MediaRole] = "media";
setRoleNames(roles);
}
示例2: m_loading
CommandModel::CommandModel() :
m_loading(false)
{
QHash<int, QByteArray> names = roleNames();
names.insert(Qt::UserRole, "trigger");
setRoleNames(names);
}
示例3: QAbstractListModel
LanguageListModel::LanguageListModel(QObject *parent)
: QAbstractListModel(parent)
{
#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
setRoleNames(roleNames());
#endif
}
示例4: QAbstractListModel
PowerModel::PowerModel(QObject *parent)
: QAbstractListModel(parent)
{
QHash<int, QByteArray> roles;
roles.insert(Qt::DisplayRole, "label");
roles.insert(Qt::DecorationRole, "icon");
setRoleNames(roles);
PowerAction shutdown;
shutdown.name = i18nc("an action", "Shutdown");
shutdown.type = Shutdown;
shutdown.iconName = "system-shutdown";
m_powerList.append(shutdown);
PowerAction restart;
restart.name = i18nc("an action", "Restart");
restart.type = Restart;
restart.iconName = "system-reboot";
m_powerList.append(restart);
PowerAction suspend;
suspend.name = i18nc("an action", "Suspend");
suspend.type = Suspend;
suspend.iconName = "system-suspend";
m_powerList.append(suspend);
PowerAction hibernate;
hibernate.name = i18nc("an action", "Hibernate");
hibernate.type = Hibernate;
hibernate.iconName = "system-suspend-hibernate";
m_powerList.append(hibernate);
emit countChanged();
}
示例5: QAbstractListModel
TechnologyModel::TechnologyModel(QAbstractListModel* parent)
: QAbstractListModel(parent),
m_manager(NULL),
m_tech(NULL),
m_scanning(false),
m_changesInhibited(false),
m_uneffectedChanges(false),
m_scanResultsReady(false)
{
m_manager = NetworkManagerFactory::createInstance();
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
setRoleNames(roleNames());
#endif
connect(m_manager, SIGNAL(availabilityChanged(bool)),
this, SLOT(managerAvailabilityChanged(bool)));
connect(m_manager,
SIGNAL(technologiesChanged()),
this,
SLOT(updateTechnologies()));
connect(m_manager,
SIGNAL(servicesChanged()),
this,
SLOT(updateServiceList()));
}
示例6: QAbstractListModel
ReverseTranslationsModel::ReverseTranslationsModel(QObject *parent)
: QAbstractListModel(parent)
{
#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
setRoleNames(roleNames());
#endif
}
示例7: QAbstractListModel
AttachmentListModel::AttachmentListModel(QObject *parent) :
QAbstractListModel(parent)
, m_messageId(QMailMessageId())
{
roles.insert(ContentLocation, "contentLocation");
roles.insert(DisplayName, "displayName");
roles.insert(Downloaded, "downloaded");
roles.insert(MimeType, "mimeType");
roles.insert(Size, "size");
roles.insert(StatusInfo, "statusInfo");
roles.insert(Url, "url");
roles.insert(ProgressInfo, "progressInfo");
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
setRoleNames(roles);
#endif
connect(EmailAgent::instance(), SIGNAL(attachmentDownloadStatusChanged(QString,EmailAgent::AttachmentStatus)),
this, SLOT(onAttachmentDownloadStatusChanged(QString,EmailAgent::AttachmentStatus)));
connect(EmailAgent::instance(), SIGNAL(attachmentDownloadProgressChanged(QString,int)),
this, SLOT(onAttachmentDownloadProgressChanged(QString,int)));
connect(EmailAgent::instance(), SIGNAL(attachmentUrlChanged(QString,QString)),
this, SLOT(onAttachmentUrlChanged(QString,QString)));
}
示例8: QStringListModel
TranslationServicesModel::TranslationServicesModel(const QStringList &strings, QObject *parent)
: QStringListModel(strings, parent)
{
#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
setRoleNames(roleNames());
#endif
}
示例9: QAbstractListModel
BrowseModelPrivate::BrowseModelPrivate(ServiceProxyCall *call,
const QString &protocolInfo,
BrowseModel *parent)
: QAbstractListModel(parent)
, m_currentOffset(0)
, m_busy(true)
, m_done(false)
, m_protocolInfo(protocolInfo)
, m_lastIndex(-1)
, m_call(call)
, m_settings()
, q_ptr(parent)
{
QHash<int, QByteArray> roles;
roles[BrowseRoleTitle] = "title";
roles[BrowseRoleId] = "upnpId";
roles[BrowseRoleUPnPClass] = "upnpClass";
roles[BrowseRoleIcon] = "icon";
roles[BrowseRoleType] = "type";
roles[BrowseRoleDetail] = "detail";
roles[BrowseRoleURI] = "uri";
roles[BrowseRoleMetaData] = "metadata";
roles[BrowseRoleFilter] = "filter";
setRoleNames(roles);
qDebug() << "Created browse model";
if (m_call != 0) {
connect(m_call, SIGNAL(ready()), SLOT(onCallReady()));
m_call->setParent(this);
}
connect(&m_settings, SIGNAL(filterInDetailsChanged()), SLOT(onFilterInDetailsChanged()));
}
示例10: QAbstractListModel
DocumentListModel::DocumentListModel(QObject *parent)
: QAbstractListModel(parent), m_searchThread(0), m_groupBy(GroupByName), m_filter(UnknownType)
{
QHash<int, QByteArray> roleNames = QAbstractListModel::roleNames();
roleNames[FileNameRole] = "fileName";
roleNames[FilePathRole] = "filePath";
roleNames[DocTypeRole] = "docType";
roleNames[SectionCategoryRole] = "sectionCategory";
roleNames[FileSizeRole] = "fileSize";
roleNames[AuthorNameRole] = "authorName";
roleNames[AccessedTimeRole] = "accessedTime";
roleNames[ModifiedTimeRole] = "modifiedTime";
roleNames[UUIDRole] = "uuid";
setRoleNames(roleNames);
m_docTypes["odt"] = TextDocumentType;
m_docTypes["doc"] = TextDocumentType;
m_docTypes["docx"] = TextDocumentType;
m_docTypes["odp"] = PresentationType;
m_docTypes["ppt"] = PresentationType;
m_docTypes["pptx"] = PresentationType;
m_docTypes["ods"] = SpreadsheetType;
m_docTypes["xls"] = SpreadsheetType;
m_docTypes["xlsx"] = SpreadsheetType;
}
示例11: QAbstractItemModel
DirModel::DirModel(QObject *parent)
: QAbstractItemModel(parent)
, d(new DirModelPrivate(this))
{
// QThread* workerThread = new QThread(this);
// d->moveToThread(workerThread);
// workerThread->start();
QHash<int, QByteArray>roleNames;
roleNames[Qt::DecorationRole] = "decoration";
roleNames[DirModel::Name] = "Name";
// roleNames[DirModel::Size] = "Size";
roleNames[DirModel::ModifiedTime] = "ModifiedTime";
roleNames[DirModel::Permissions] = "Permissions";
roleNames[DirModel::Owner] = "Owner";
roleNames[DirModel::Group] = "Group";
roleNames[DirModel::Type] = "Type"; // Type == item.mimeComment() ... yeah, go figure that one out.
roleNames[DirModel::ColumnCount] = "ColumnCount";
roleNames[DirModel::UrlRole] = "Url";
roleNames[DirModel::MimeTypeRole] = "MimeType";
roleNames[DirModel::IconName] = "IconName";
roleNames[DirModel::BaseName] = "BaseName";
roleNames[DirModel::Extension] = "Extension";
roleNames[DirModel::TimeString] = "TimeString";
roleNames[DirModel::MimeOrThumb] = "MimeOrThumb";
setRoleNames(roleNames);
}
示例12: QAbstractListModel
HistoryModel::HistoryModel(QObject *parent)
: QAbstractListModel(parent)
{
// Set role names to access data from QML
QHash<int, QByteArray> roles;
roles[TimeRole] = "time";
roles[HeartRateRole] = "heartRate";
setRoleNames(roles);
// Read info file if is exists
QFile historyFile("/home/user/MyDocs/heartrate.csv");
if (historyFile.exists() && historyFile.open(QIODevice::ReadOnly)) {
QTextStream in(&historyFile);
while (!in.atEnd()) {
QString line = in.readLine();
QStringList values = line.split(" ");
if (values.length() > 1) {
QDateTime time = QDateTime::fromString(values[0], Qt::ISODate);
int value = values[1].toInt();
HeartRateMeasurement measurement(time, value);
m_data.append(measurement);
}
}
historyFile.close();
}
}
示例13: QAbstractListModel
KnotsDirectory::KnotsDirectory( QObject *parent )
: QAbstractListModel( parent )
, _xmlReader(0)
, _xmlSource(0)
, _currentDownload(0)
, _parser(0)
{
_roles[IdRole] = "id";
_roles[NameRole] = "name";
_roles[ImageRole] = "thumbnail";
_roles[WidthRole] = "width";
_roles[HeightRole] = "height";
_roles[ViewsRole] = "views";
_roles[AddedRole] = "addedOn";
_roles[DurationRole] = "duration";
_roles[LastViewedPositionRole] = "lastposition";
_roles[MediaIdRole] = "mediaId";
setRoleNames(_roles);
_parser = new SaxKnotsItemHandler();
_parser->setItemHandler(this);
connect(&Knots::instance().serverConnection(), SIGNAL(finished(QNetworkReply*)),SLOT(onDirectoryFetchFinished(QNetworkReply*)));
}
示例14: QAbstractListModel
ResultModel::ResultModel(QObject *parent)
: QAbstractListModel(parent), m_historyIndex(-1)
{
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
setRoleNames(roleNames());
#endif
}
示例15: QAbstractListModel
PlaceModel::PlaceModel(QObject *parent)
: QAbstractListModel(parent)
{
QList<QDesktopServices::StandardLocation> locations;
locations << QDesktopServices::DocumentsLocation;
locations << QDesktopServices::MusicLocation;
locations << QDesktopServices::MoviesLocation;
locations << QDesktopServices::PicturesLocation;
foreach (QDesktopServices::StandardLocation location, locations) {
const QString path = QDesktopServices::storageLocation(location);
QDir dir(path);
if (path.isEmpty() || dir == QDir::home())
continue;
// do not use "path" directly, on Windows it uses back slashes
// where the rest of Qt uses forward slashes
m_paths << dir.path();
}
// set role names
QHash<int, QByteArray> roleNames;
roleNames.insert(ChatModel::AvatarRole, "avatar");
roleNames.insert(ChatModel::NameRole, "name");
roleNames.insert(ChatModel::JidRole, "url");
setRoleNames(roleNames);
}