本文整理汇总了C++中kservice::List::erase方法的典型用法代码示例。如果您正苦于以下问题:C++ List::erase方法的具体用法?C++ List::erase怎么用?C++ List::erase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kservice::List
的用法示例。
在下文中一共展示了List::erase方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getViewer
KService::Ptr ArkViewer::getViewer(const QString &mimeType)
{
// No point in even trying to find anything for application/octet-stream
if (mimeType == QStringLiteral("application/octet-stream")) {
return KService::Ptr();
}
// Try to get a read-only kpart for the internal viewer
KService::List offers = KMimeTypeTrader::self()->query(mimeType, QStringLiteral("KParts/ReadOnlyPart"));
auto arkPartIt = std::find_if(offers.begin(), offers.end(), [](KService::Ptr service) {
return service->storageId() == QLatin1String("ark_part.desktop");
});
// Use the Ark part only when the mime type matches an archive type directly.
// Many file types (e.g. Open Document) are technically just archives
// but browsing their internals is typically not what the user wants.
if (arkPartIt != offers.end()) {
// Not using hasMimeType() as we're explicitly not interested in inheritance.
if (!(*arkPartIt)->mimeTypes().contains(mimeType)) {
offers.erase(arkPartIt);
}
}
// If we can't find a kpart, try to get an external application
if (offers.isEmpty()) {
offers = KMimeTypeTrader::self()->query(mimeType, QStringLiteral("Application"));
}
if (!offers.isEmpty()) {
return offers.first();
} else {
return KService::Ptr();
}
}
示例2: QObject
ToggleViewGUIClient::ToggleViewGUIClient( KonqMainWindow *mainWindow )
: QObject( mainWindow )
{
m_mainWindow = mainWindow;
KService::List offers = KServiceTypeTrader::self()->query( "Browser/View" );
KService::List::Iterator it = offers.begin();
while ( it != offers.end() )
{
QVariant prop = (*it)->property( "X-KDE-BrowserView-Toggable" );
QVariant orientation = (*it)->property( "X-KDE-BrowserView-ToggableView-Orientation" );
if ( !prop.isValid() || !prop.toBool() ||
!orientation.isValid() || orientation.toString().isEmpty() )
{
offers.erase( it );
it = offers.begin();
}
else
++it;
}
m_empty = ( offers.count() == 0 );
if ( m_empty )
return;
KService::List::ConstIterator cIt = offers.constBegin();
KService::List::ConstIterator cEnd = offers.constEnd();
for (; cIt != cEnd; ++cIt )
{
QString description = i18n( "Show %1" , (*cIt)->name() );
QString name = (*cIt)->desktopEntryName();
//kDebug() << "ToggleViewGUIClient: name=" << name;
KToggleAction *action = new KToggleAction( description, this );
mainWindow->actionCollection()->addAction( name.toLatin1(), action );
// HACK
if ( (*cIt)->icon() != "unknown" )
action->setIcon( KIcon((*cIt)->icon()) );
connect( action, SIGNAL(toggled(bool)),
this, SLOT(slotToggleView(bool)) );
m_actions.insert( name, action );
QVariant orientation = (*cIt)->property( "X-KDE-BrowserView-ToggableView-Orientation" );
bool horizontal = orientation.toString().toLower() == "horizontal";
m_mapOrientation.insert( name, horizontal );
}
connect( m_mainWindow, SIGNAL(viewAdded(KonqView*)),
this, SLOT(slotViewAdded(KonqView*)) );
connect( m_mainWindow, SIGNAL(viewRemoved(KonqView*)),
this, SLOT(slotViewRemoved(KonqView*)) );
}
示例3: match
void KJiebaRunner::match(Plasma::RunnerContext &context)
{
const QString term = context.query();
QList<Plasma::QueryMatch> matches;
QSet<QString> seen;
if (term.length() > 1) {
#if DEBUG
qDebug() << "DEBUG:" << __PRETTY_FUNCTION__ << term;
#endif
KService::List services = KServiceTypeTrader::self()->query("Application");
services.erase(std::remove_if(services.begin(),
services.end(),
[=](QExplicitlySharedDataPointer<KService> it) {
return it->exec().isEmpty() ||
(!kjiebaPtr->query(it->genericName()).contains(term) &&
!kjiebaPtr->topinyin(it->genericName()).contains(term) &&
!kjiebaPtr->topinyin(it->genericName(), false).contains(term) &&
!kjiebaPtr->query(it->name()).contains(term) &&
!kjiebaPtr->topinyin(it->name()).contains(term) &&
!kjiebaPtr->topinyin(it->name(), false).contains(term));
}), services.end());
if (!services.isEmpty()) {
Q_FOREACH (const KService::Ptr &service, services) {
if (!service->noDisplay() &&
service->property(QStringLiteral("NotShowIn"), QVariant::String) != "KDE") {
Plasma::QueryMatch match(this);
match.setType(Plasma::QueryMatch::ExactMatch);
const QString name = service->name();
#if DEBUG
qDebug() << "DEBUG:" << name;
#endif
match.setText(name);
match.setData(service->storageId());
if (!service->genericName().isEmpty() && service->genericName() != name)
match.setSubtext(service->genericName());
else if (!service->comment().isEmpty())
match.setSubtext(service->comment());
if (!service->icon().isEmpty())
match.setIcon(QIcon::fromTheme(service->icon()));
match.setRelevance(1);
matches << match;
seen.insert(service->storageId());
seen.insert(service->exec());
}
}
}
示例4: servicesForOpenWith
KService::List FileOperation::servicesForOpenWith(const QList<QUrl>& urls)
{
// This code is inspired by KonqMenuActions:
// kdebase/apps/lib/konq/konq_menuactions.cpp
QStringList mimeTypes;
KService::List offers;
foreach(const QUrl& item, urls)
{
const QString mimeType = QMimeDatabase().mimeTypeForFile(item.path(), QMimeDatabase::MatchExtension).name();
if (!mimeTypes.contains(mimeType))
{
mimeTypes << mimeType;
}
}
if (!mimeTypes.isEmpty())
{
// Query trader
const QString firstMimeType = mimeTypes.takeFirst();
const QString constraintTemplate = QLatin1String("'%1' in ServiceTypes");
QStringList constraints;
foreach(const QString& mimeType, mimeTypes)
{
constraints << constraintTemplate.arg(mimeType);
}
offers = KMimeTypeTrader::self()->query(firstMimeType, QLatin1String("Application"), constraints.join(QLatin1String(" and ")));
// remove duplicate service entries
QSet<QString> seenApps;
for (KService::List::iterator it = offers.begin(); it != offers.end();)
{
const QString appName((*it)->name());
if (!seenApps.contains(appName))
{
seenApps.insert(appName);
++it;
}
else
{
it = offers.erase(it);
}
}
}