本文整理汇总了C++中roleNames函数的典型用法代码示例。如果您正苦于以下问题:C++ roleNames函数的具体用法?C++ roleNames怎么用?C++ roleNames使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了roleNames函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: qDebug
QVariant BluetoothDevicesModel::data(const QModelIndex &index, int role) const
{
qDebug()<<"requested role: "<<roleNames()[role];
if(!index.isValid() || index.row() < 0)
{
qDebug()<<"index is not valid: "<<index.row()<<","<<index.column();
return QVariant(); ///this is retarded but it has to be done.
}
if(roleNames()[role] == "bluetoothDevice")
{
return QVariant::fromValue<QObject*>((QObject*)m_devices[index.row()]);
}
QString roleName = roleNames()[role];
QMetaObject object = BluetoothDevice::staticMetaObject;
for(int i=0; i<object.propertyCount(); i++)
{
if(object.property(i).name() == roleName)
{
return object.property(i).read(m_devices[index.row()]);
}
}
return QVariant();
}
开发者ID:LongChair,项目名称:libbluez-qt,代码行数:28,代码来源:bluetoothdevicemodel.cpp
示例2: index
QVariantHash DefaultItemFilterProxyModel::get(int row) const
{
QModelIndex idx = index(row, 0);
QVariantHash hash;
QHash<int, QByteArray>::const_iterator i;
for (i = roleNames().constBegin(); i != roleNames().constEnd(); ++i) {
hash[i.value()] = data(idx, i.key());
}
return hash;
}
开发者ID:cmacq2,项目名称:plasma-workspace,代码行数:12,代码来源:kcategorizeditemsviewmodels.cpp
示例3: roleNames
bool CheckedListModel::allChecked()
{
int roleIndex = roleNames().key("checked");
if (roleNames().contains(roleIndex))
{
for (int row=0; row<m_list.size(); ++row)
{
if (!m_list.at(row)->data(roleIndex).toBool())
return false;
}
}
return true;
}
开发者ID:robby31,项目名称:QmlApplication,代码行数:15,代码来源:checkedlistmodel.cpp
示例4: 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()));
}
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:27,代码来源:technologymodel.cpp
示例5: QAbstractListModel
ReverseTranslationsModel::ReverseTranslationsModel(QObject *parent)
: QAbstractListModel(parent)
{
#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
setRoleNames(roleNames());
#endif
}
开发者ID:leppa,项目名称:taot,代码行数:7,代码来源:reversetranslationsmodel.cpp
示例6: QAbstractListModel
PlaylistModel::PlaylistModel(QObject* parent):
QAbstractListModel(parent),
d(new Private)
{
KConfigGroup cfgGroup = KGlobal::config()->group("General");
setRandom(cfgGroup.readEntry("randomplaylist",false));
QString dirPath = KGlobal::dirs()->saveLocation("data") + KCmdLineArgs::appName();
QDir().mkdir(dirPath);
d->filePath = dirPath + "/playlist";
if (QFile::exists(d->filePath)) {
QFile file(d->filePath);
if (file.open(QIODevice::ReadOnly)) {
QTextStream in(&file);
while (!in.atEnd()) {
QString line = in.readLine();
d->musicList.append(PlaylistItem::fromString(line));
}
}
file.close();
}
d->currentIndex = -1;
setRoleNames(MediaCenter::appendAdditionalMediaRoles(roleNames()));
qsrand(QDateTime::currentMSecsSinceEpoch());
}
开发者ID:akshayratan,项目名称:plasmamediacenter,代码行数:26,代码来源:playlistmodel.cpp
示例7: disconnect
void SectionDataModel::setModel(QAbstractItemModel *model)
{
if (model == m_model)
return;
if (m_model) {
disconnect(m_model, SIGNAL(modelReset()), this, SLOT(buildSectionMap()));
disconnect(m_model, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(handleRowsInserted(QModelIndex,int,int)));
disconnect(m_model, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)), this, SLOT(handleRowsMoved(QModelIndex,int,int,QModelIndex,int)));
disconnect(m_model, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(handleRowsRemoved(QModelIndex,int,int)));
disconnect(m_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(handleDataChanged(QModelIndex,QModelIndex)));
}
m_model = model;
if (m_model) {
connect(m_model, SIGNAL(modelReset()), SLOT(buildSectionMap()));
connect(m_model, SIGNAL(rowsInserted(QModelIndex,int,int)), SLOT(handleRowsInserted(QModelIndex,int,int)));
connect(m_model, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)), SLOT(handleRowsMoved(QModelIndex,int,int,QModelIndex,int)));
connect(m_model, SIGNAL(rowsRemoved(QModelIndex,int,int)), SLOT(handleRowsRemoved(QModelIndex,int,int)));
connect(m_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), SLOT(handleDataChanged(QModelIndex,QModelIndex)));
setRoleNames(m_model->roleNames());
} else {
setRoleNames(QHash<int, QByteArray>());
}
if (!m_sectionKey.isEmpty()) {
m_sectionRole = roleNames().key(m_sectionKey.toLatin1());
}
emit modelChanged();
buildSectionMap();
}
开发者ID:khorben,项目名称:sudoku-united,代码行数:35,代码来源:sectiondatamodel.cpp
示例8: QAbstractListModel
ResultModel::ResultModel(QObject *parent)
: QAbstractListModel(parent), m_historyIndex(-1)
{
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
setRoleNames(roleNames());
#endif
}
开发者ID:KDE,项目名称:abakus,代码行数:7,代码来源:resultmodel.cpp
示例9: QAbstractListModel
PicasaModel::PicasaModel(QObject* parent, const QString& username, const QString& password): QAbstractListModel(parent)
{
m_flag = false;
m_expandable = false;
setRoleNames(MediaCenter::appendAdditionalMediaRoles(roleNames()));
getTokenAndQuery(username, password,"album");
}
开发者ID:akshayratan,项目名称:plasmamediacenter,代码行数:7,代码来源:picasamodel.cpp
示例10: QAbstractListModel
UsersModel::UsersModel(QObject *parent) :
QAbstractListModel(parent),
d_ptr(new UsersModelPrivate(this))
{
Q_D(UsersModel);
// Extend roleNames (we want to keep the "display" role)
QHash<int, QByteArray> roles = roleNames();
roles[NameRole] = "name";
roles[RealNameRole] = "realName";
roles[LoggedInRole] = "loggedIn";
roles[BackgroundRole] = "background";
roles[BackgroundPathRole] = "backgroundPath";
roles[SessionRole] = "session";
roles[HasMessagesRole] = "hasMessages";
roles[ImagePathRole] = "imagePath";
setRoleNames(roles);
// Now modify our mock user backgrounds
QDir bgdir = QDir(QStringLiteral("/usr/share/demo-assets/shell/backgrounds/"));
QStringList backgrounds = bgdir.entryList(QDir::Files | QDir::NoDotAndDotDot);
for (int i = 0, j = 0; i < d->entries.size(); i++) {
Entry &entry = d->entries[i];
if (entry.background.isNull() && !backgrounds.isEmpty()) {
entry.background = bgdir.filePath(backgrounds[j++]);
if (j >= backgrounds.length()) {
j = 0;
}
}
}
}
开发者ID:jonjahren,项目名称:unity8,代码行数:32,代码来源:UsersModel.cpp
示例11: QAbstractListModel
DictionaryModel::DictionaryModel(QObject *parent) :
QAbstractListModel(parent)
{
#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
setRoleNames(roleNames());
#endif
}
开发者ID:trajkopetko,项目名称:taot,代码行数:7,代码来源:dictionarymodel.cpp
示例12: m_loading
CommandModel::CommandModel() :
m_loading(false)
{
QHash<int, QByteArray> names = roleNames();
names.insert(Qt::UserRole, "trigger");
setRoleNames(names);
}
开发者ID:KDE,项目名称:simon-tools,代码行数:7,代码来源:commandmodel.cpp
示例13: foreach
QVariantMap FileModel::get(int idx) const {
QVariantMap map;
foreach(int k, roleNames().keys()) {
map[roleNames().value(k)] = data(index(idx, 0), k);
}
return map;
}
开发者ID:rstanislav,项目名称:brummbeere,代码行数:7,代码来源:filemodel.cpp
示例14: getProperty
bool SalesModel::setProperty(int rowIndex, const QString &property, const QVariant &value)
{
QVariantMap rowValues = getProperty(rowIndex);
const char * UPDATE_STAMENT="UPDATE items_sales set price = :price WHERE prov = :prov and ref = :ref "
"and size = :size and color = :color and sales_date = :sales_date;";
m_updateQuery.prepare(UPDATE_STAMENT);
m_updateQuery.bindValue(":ref",rowValues["ref"]);
m_updateQuery.bindValue(":size",rowValues["size"]);
m_updateQuery.bindValue(":color",rowValues["color"]);
m_updateQuery.bindValue(":prov",rowValues["prov"]);
m_updateQuery.bindValue(":sales_date",rowValues["date"]);
m_updateQuery.bindValue(":price", value);
if(!m_updateQuery.exec()){
qWarning()<<"could no update sales "<<m_updateQuery.lastQuery();
return false;
}
qDebug()<<"price updated "<<value;
QHash<int, QByteArray> roles = roleNames();
QModelIndex ind = index(rowIndex,roles.key("price"));
QSqlQuery q = query();
q.exec();
setQuery(q);
emit dataChanged(ind,ind);
return true;
}
开发者ID:IvanFaja,项目名称:EasyTrack,代码行数:29,代码来源:salesmodel.cpp
示例15: QStringListModel
TranslationServicesModel::TranslationServicesModel(const QStringList &strings, QObject *parent)
: QStringListModel(strings, parent)
{
#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
setRoleNames(roleNames());
#endif
}
开发者ID:trajkopetko,项目名称:taot,代码行数:7,代码来源:translationservicesmodel.cpp
示例16: foreach
QVariantMap GameLibraryModel::get(int inx)
{
QVariantMap map;
foreach (int i, roleNames().keys()) {
map[roleNames().value(i)] = data(index(inx, 0), i);
}
return map;
}
开发者ID:Gu1,项目名称:Phoenix,代码行数:8,代码来源:gamelibrarymodel.cpp
示例17: QSqlQueryModel
CMLibraryModel::CMLibraryModel(QObject *parent)
: QSqlQueryModel(parent)
{
#if QT_VERSION < 0x050000
setRoleNames(roleNames());
#endif
refresh();
}
开发者ID:oniongarlic,项目名称:qtsidplayer-test,代码行数:8,代码来源:cmlibrarymodel.cpp
示例18: QAbstractItemModel
CategoriesModel::CategoriesModel(QObject* parent): QAbstractItemModel(parent)
{
m_categories.append(Category("All Songs", "audio", Category::AllMusic));
m_categories.append(Category("Artists", "user-identity", Category::Artists));
m_categories.append(Category("Albums", "tools-media-optical-copy", Category::Albums));
setRoleNames(MediaCenter::appendAdditionalMediaRoles(roleNames()));
}
开发者ID:akshayratan,项目名称:plasmamediacenter,代码行数:8,代码来源:categoriesmodel.cpp
示例19: HueModel
Rules::Rules(QObject *parent):
HueModel(parent),
m_busy(false)
{
#if QT_VERSION < 0x050000
setRoleNames(roleNames());
#endif
}
开发者ID:mzanetti,项目名称:shine,代码行数:8,代码来源:rules.cpp
示例20: QAbstractListModel
OcFeedsModelNew::OcFeedsModelNew(QObject *parent) :
QAbstractListModel(parent)
{
m_folderId = -999;
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
setRoleNames(roleNames());
#endif
}
开发者ID:Buschtrommel,项目名称:ocNews,代码行数:9,代码来源:ocfeedsmodelnew.cpp
注:本文中的roleNames函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论