本文整理汇总了C++中kservice::Ptr::storageId方法的典型用法代码示例。如果您正苦于以下问题:C++ Ptr::storageId方法的具体用法?C++ Ptr::storageId怎么用?C++ Ptr::storageId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kservice::Ptr
的用法示例。
在下文中一共展示了Ptr::storageId方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: selectApplicationClicked
void MenuentryActionWidget::selectApplicationClicked()
{
KOpenWithDialog dlg;
dlg.exec();
KService::Ptr service = dlg.service();
if (service)
{
ui.application->setText( service->name() );
storage_id = service->storageId();
}
}
示例2: PanelButton
ServiceButton::ServiceButton(const KService::Ptr &service, QWidget* parent)
: PanelButton(parent, "ServiceButton"),
_service(service),
_id(service->storageId())
{
if (_id.startsWith("/"))
{
QString tmp = KGlobal::dirs()->relativeLocation("appdata", _id);
if (!tmp.startsWith("/"))
_id = ":"+tmp;
}
initialize();
}
示例3: doCopyFromObject
void MenuentryActionWidget::doCopyFromObject()
{
Q_ASSERT(action());
KService::Ptr service = action()->service();
if (service)
{
ui.application->setText( service->name() );
storage_id = service->storageId();
}
else
{
ui.application->setText(QString());
storage_id = QString();
}
}
示例4: data
QVariant FavoriteAppsModel::data(const QModelIndex &index, int role) const
{
KService::Ptr service = m_favoriteList.value(index.row()).service;
if (service.isNull()) {
return QVariant();
}
if (role == Qt::DisplayRole) {
return service->name();
} else if (role == Qt::DecorationRole) {
return KIcon(service->icon());
} else if (role == FavoriteIdRole) {
return QVariant("app:" + service->storageId());
} else {
kWarning() << "Unhandled role" << role;
return QVariant();
}
}
示例5:
Menuentry_shortcut_action_data *khotkeys_get_menu_entry_internal2(const Action_data_group *data_P, const QString &entry_P)
{
if(!data_P->enabled(false))
return NULL;
for(Action_data_group::Iterator it = data_P->first_child(); it; ++it)
{
if(!(*it)->enabled(true))
continue;
if(Menuentry_shortcut_action_data *entry = dynamic_cast< Menuentry_shortcut_action_data * >(*it))
{
KService::Ptr service = entry->action() ? entry->action()->service() : KService::Ptr(0);
if(service && (service->storageId() == entry_P))
return entry;
}
if(Action_data_group *group = dynamic_cast< Action_data_group * >(*it))
{
Menuentry_shortcut_action_data *data = khotkeys_get_menu_entry_internal2(group, entry_P);
if(data != NULL)
return data;
}
}
return NULL;
}
示例6: if
//.........这里部分代码省略.........
//qDebug() << "Clearing hashtable...";
for (unsigned int i=0; i < sz; i++)
{
hashTable[i].entry = 0;
hashTable[i].duplicates = 0;
}
//qDebug() << "Filling hashtable...";
for(KSycocaDictStringList::const_iterator it = d->stringlist->constBegin(); it != d->stringlist->constEnd(); ++it)
{
string_entry* entry = *it;
//qDebug() << "entry keyStr=" << entry->keyStr << entry->payload.data() << entry->payload->entryPath();
int hash = entry->hash % sz;
if (!hashTable[hash].entry)
{ // First entry
hashTable[hash].entry = entry;
}
else
{
if (!hashTable[hash].duplicates)
{ // Second entry, build duplicate list.
hashTable[hash].duplicates = new QList<string_entry*>;
hashTable[hash].duplicates->append(hashTable[hash].entry);
hashTable[hash].duplicate_offset = 0;
}
hashTable[hash].duplicates->append(entry);
}
}
str << d->hashTableSize;
str << d->hashList;
d->offset = str.device()->pos(); // d->offset points to start of hashTable
//qDebug() << QString("Start of Hash Table, offset = %1").arg(d->offset,8,16);
// Write the hashtable + the duplicates twice.
// The duplicates are after the normal hashtable, but the offset of each
// duplicate entry is written into the normal hashtable.
for(int pass = 1; pass <= 2; pass++)
{
str.device()->seek(d->offset);
//qDebug() << QString("Writing hash table (pass #%1)").arg(pass);
for(uint i=0; i < d->hashTableSize; i++)
{
qint32 tmpid;
if (!hashTable[i].entry)
tmpid = (qint32) 0;
else if (!hashTable[i].duplicates)
tmpid = (qint32) hashTable[i].entry->payload->offset(); // Positive ID
else
tmpid = (qint32) -hashTable[i].duplicate_offset; // Negative ID
str << tmpid;
//qDebug() << QString("Hash table : %1").arg(tmpid,8,16);
}
//qDebug() << QString("End of Hash Table, offset = %1").arg(str.device()->at(),8,16);
//qDebug() << QString("Writing duplicate lists (pass #%1)").arg(pass);
for(uint i=0; i < d->hashTableSize; i++)
{
const QList<string_entry*> *dups = hashTable[i].duplicates;
if (dups)
{
hashTable[i].duplicate_offset = str.device()->pos();
/*qDebug() << QString("Duplicate lists: Offset = %1 list_size = %2") .arg(hashTable[i].duplicate_offset,8,16).arg(dups->count());
*/
for(QList<string_entry*>::ConstIterator dup = dups->begin(); dup != dups->end(); ++dup)
{
const qint32 offset = (*dup)->payload->offset();
if (!offset) {
const QString storageId = (*dup)->payload->storageId();
qDebug() << "about to assert! dict=" << this << "storageId=" << storageId << (*dup)->payload.data();
if ((*dup)->payload->isType(KST_KService)) {
KService::Ptr service = KService::Ptr::staticCast((*dup)->payload);
qDebug() << service->storageId() << service->entryPath();
}
// save() must have been called on the entry
Q_ASSERT_X( offset, "KSycocaDict::save",
QByteArray("entry offset is 0, save() was not called on "
+ (*dup)->payload->storageId().toLatin1()
+ " entryPath="
+ (*dup)->payload->entryPath().toLatin1())
);
}
str << offset ; // Positive ID
str << (*dup)->keyStr; // Key (QString)
}
str << (qint32) 0; // End of list marker (0)
}
}
//qDebug() << QString("End of Dict, offset = %1").arg(str.device()->at(),8,16);
}
//qDebug() << "Cleaning up hash table.";
for(uint i=0; i < d->hashTableSize; i++)
{
delete hashTable[i].duplicates;
}
delete [] hashTable;
}
示例7: loader
ContainmentActions *PluginLoader::loadContainmentActions(Containment *parent, const QString &name, const QVariantList &args)
{
if (name.isEmpty()) {
return 0;
}
ContainmentActions *actions = d->isDefaultLoader ? 0 : internalLoadContainmentActions(parent, name, args);
if (actions) {
return actions;
}
// Look for C++ plugins first
auto filter = [&name](const KPluginMetaData &md) -> bool
{
return md.pluginId() == name;
};
QVector<KPluginMetaData> plugins = KPluginLoader::findPlugins(PluginLoaderPrivate::s_containmentActionsPluginDir, filter);
if (plugins.count()) {
KPluginInfo::List lst = KPluginInfo::fromMetaData(plugins);
KPluginLoader loader(lst.first().libraryPath());
const QVariantList argsWithMetaData = QVariantList() << loader.metaData().toVariantMap();
KPluginFactory *factory = loader.factory();
if (factory) {
actions = factory->create<Plasma::ContainmentActions>(0, argsWithMetaData);
}
}
if (actions) {
return actions;
}
//FIXME: this is only for backwards compatibility, but probably will have to stay
//for the time being
QString constraint = QStringLiteral("[X-KDE-PluginInfo-Name] == '%1'").arg(name);
KService::List offers = KServiceTypeTrader::self()->query(QStringLiteral("Plasma/ContainmentActions"), constraint);
if (offers.isEmpty()) {
#ifndef NDEBUG
qCDebug(LOG_PLASMA) << "offers is empty for " << name;
#endif
return 0;
}
KService::Ptr offer = offers.first();
KPluginLoader plugin(*offer);
if (!Plasma::isPluginVersionCompatible(plugin.pluginVersion())) {
return 0;
}
QVariantList allArgs;
allArgs << offer->storageId() << args;
QString error;
actions = offer->createInstance<Plasma::ContainmentActions>(parent, allArgs, &error);
if (!actions) {
#ifndef NDEBUG
// qCDebug(LOG_PLASMA) << "Couldn't load containmentActions \"" << name << "\"! reason given: " << error;
#endif
}
return actions;
}