本文整理汇总了C++中kservice::List类的典型用法代码示例。如果您正苦于以下问题:C++ List类的具体用法?C++ List怎么用?C++ List使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了List类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadPlugins
void PluginManager::loadPlugins()
{
DEBUG_FUNC_NAME
KConfigGroup group = KGlobal::config()->group( "Plugins" );
KService::List offers = KServiceTypeTrader::self()->query(
QString::fromLatin1( "GluonCreator/Plugin" ),
QString( "[X-KDE-GluonCreatorPluginVersion] == %1" ).arg( GLUONCREATOR_PLUGIN_VERSION ) );
KService::List::const_iterator iter;
for( iter = offers.begin(); iter < offers.end(); ++iter )
{
QString error;
KService::Ptr service = *iter;
QString serviceName = service->desktopEntryName();
bool loadPlugin = group.readEntry<bool>( QString( "%1Enabled" ).arg( serviceName ), true );
if( !d->loadedPlugins.contains( serviceName ) && loadPlugin )
{
KPluginFactory* factory = KPluginLoader( service->library() ).factory();
if( !factory )
{
DEBUG_TEXT( QString( "KPluginFactory could not load the plugin: %1" ).arg( service->library() ) );
continue;
}
Plugin* plugin = factory->create<Plugin>( this );
if( plugin )
{
DEBUG_TEXT( QString( "Load plugin: %1" ).arg( service->name() ) );
plugin->load( d->mainWindow );
d->loadedPlugins.insert( serviceName, plugin );
}
else
{
DEBUG_TEXT( error );
}
}
else if( !loadPlugin && d->loadedPlugins.contains( serviceName ) )
{
Plugin* plugin = d->loadedPlugins.value( serviceName );
plugin->unload( d->mainWindow );
delete plugin;
d->loadedPlugins.remove( serviceName );
}
}
}
示例2: loadServices
void BackendSelection::loadServices(const KService::List &offers)
{
m_services.clear();
m_select->clear();
KService::List::const_iterator it = offers.begin();
const KService::List::const_iterator end = offers.end();
for (; it != end; ++it)
{
KService::Ptr service = *it;
m_select->addItem(service->name());
m_services[service->name()] = service;
}
m_select->setItemSelected(m_select->item(0), true);
}
示例3: canCreatePart
bool PartController::canCreatePart(const KUrl& url)
{
if (!url.isValid()) return false;
QString mimeType;
if ( url.isEmpty() )
mimeType = QString::fromLatin1("text/plain");
else
mimeType = KMimeType::findByUrl( url )->name();
KService::List offers = KMimeTypeTrader::self()->query(
mimeType,
"KParts/ReadOnlyPart" );
return offers.count() > 0;
}
示例4: offerListHasService
// Helper method for all the trader tests
static bool offerListHasService(const KService::List &offers,
const QString &entryPath)
{
bool found = false;
KService::List::const_iterator it = offers.begin();
for (; it != offers.end(); ++it) {
if ((*it)->entryPath() == entryPath) {
if (found) { // should be there only once
qWarning("ERROR: %s was found twice in the list", qPrintable(entryPath));
return false; // make test fail
}
found = true;
}
}
return found;
}
示例5: addPlugins
void KonqPopupMenuPrivate::addPlugins()
{
QString commonMimeType = m_popupItemProperties.mimeType();
if (commonMimeType.isEmpty()) {
commonMimeType = QLatin1String("application/octet-stream");
}
const KService::List fileItemPlugins = KMimeTypeTrader::self()->query(commonMimeType, QStringLiteral("KFileItemAction/Plugin"), QStringLiteral("exist Library"));
if (!fileItemPlugins.isEmpty()) {
const KConfig config(QStringLiteral("kservicemenurc"), KConfig::NoGlobals);
const KConfigGroup showGroup = config.group("Show");
foreach (const auto &service, fileItemPlugins) {
if (!showGroup.readEntry(service->desktopEntryName(), true)) {
// The plugin has been disabled
continue;
}
KAbstractFileItemActionPlugin *abstractPlugin = service->createInstance<KAbstractFileItemActionPlugin>();
if (abstractPlugin) {
abstractPlugin->setParent(q);
q->addActions(abstractPlugin->actions(m_popupItemProperties, m_parentWidget));
}
}
}
}
示例6: 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*)) );
}
示例7: testMimeTypeTraderForAlias
void KMimeTypeTest::testMimeTypeTraderForAlias()
{
if (!KSycoca::isAvailable()) {
QSKIP("ksycoca not available");
}
const KService::List referenceOffers = KMimeTypeTrader::self()->query("application/xml", "KParts/ReadOnlyPart");
QVERIFY(offerListHasService(referenceOffers, "faketextpart.desktop"));
QVERIFY(!offerListHasService(referenceOffers, "fakepatchpart.desktop"));
// Querying mimetype trader for services associated with text/xml, which is an alias for application/xml
const KService::List offers = KMimeTypeTrader::self()->query("text/xml", "KParts/ReadOnlyPart");
QVERIFY(offerListHasService(offers, "faketextpart.desktop"));
QVERIFY(!offerListHasService(offers, "fakepatchpart.desktop"));
QCOMPARE(offers.count(), referenceOffers.count());
}
示例8: openFilesWithDefaultApplication
void FileOperation::openFilesWithDefaultApplication(const QList<QUrl>& urls, QWidget* const parentWidget)
{
if (urls.isEmpty())
{
return;
}
// Create a map of service depending of type mimes to route and start only one instance of relevant application with all same type mime files.
QMap<KService::Ptr, QList<QUrl>> servicesMap;
foreach (const QUrl& url, urls)
{
const QString mimeType = QMimeDatabase().mimeTypeForFile(url.path(), QMimeDatabase::MatchExtension).name();
KService::List offers = KMimeTypeTrader::self()->query(mimeType, QLatin1String("Application"));
if (offers.isEmpty())
{
return;
}
KService::Ptr ptr = offers.first();
QMap<KService::Ptr, QList<QUrl>>::const_iterator it = servicesMap.constFind(ptr);
if (it != servicesMap.constEnd())
{
servicesMap[ptr] << url;
}
else
{
servicesMap.insert(ptr, QList<QUrl>() << url);
}
}
for (QMap<KService::Ptr, QList<QUrl>>::const_iterator it = servicesMap.constBegin();
it != servicesMap.constEnd(); ++it)
{
// Run the dedicated app to open the item.
#if KIO_VERSION < QT_VERSION_CHECK(5,6,0)
KRun::run(*it.key(), it.value(), parentWidget);
#else
KRun::runService(*it.key(), it.value(), parentWidget);
#endif
}
}
示例9: QueryContextMenu
STDMETHODIMP CShellExt::QueryContextMenu(HMENU hMenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags)
{
UINT idCmd = idCmdFirst;
BOOL bAppendItems=TRUE;
TCHAR szFileUserClickedOn[MAX_PATH];
FORMATETC fmte = {
CF_HDROP,
(DVTARGETDEVICE FAR *)NULL,
DVASPECT_CONTENT,
-1,
TYMED_HGLOBAL
};
HRESULT hres = m_pDataObj->GetData(&fmte, &m_stgMedium);
if (SUCCEEDED(hres)) {
if (m_stgMedium.hGlobal)
m_cbFiles = DragQueryFile((HDROP)m_stgMedium.hGlobal, (UINT)-1, 0, 0);
qDebug() << "number of files:" << m_cbFiles;
for (unsigned i = 0; i < m_cbFiles; i++) {
DragQueryFile((HDROP)m_stgMedium.hGlobal, i, szFileUserClickedOn, MAX_PATH);
qDebug() << "file to open:" << lptstr2QString(szFileUserClickedOn);
}
}
QString path = lptstr2QString(szFileUserClickedOn);
UINT nIndex = indexMenu++;
KMimeType::Ptr ptr = KMimeType::findByPath(path);
KService::List lst = KMimeTypeTrader::self()->query(ptr->name(), "Application");
if(lst.size() > 0)
{
TCHAR str[256];
wsprintf(str, TEXT("Open with %s"), (LPTSTR)lst.at(0)->name().utf16());
InsertMenu(hMenu, nIndex, MF_STRING|MF_BYPOSITION, idCmd++, str );
if (m_hKdeLogoBmp) {
SetMenuItemBitmaps(hMenu, nIndex, MF_BYPOSITION, m_hKdeLogoBmp, m_hKdeLogoBmp);
}
}
return ResultFromShort(idCmd-idCmdFirst);
}
示例10: QString
QString ibanBicData::iban2Bic(const QString& iban)
{
Q_ASSERT(iban.length() < 1 || iban.at(0).isLetterOrNumber());
Q_ASSERT(iban.length() < 2 || iban.at(1).isLetterOrNumber());
Q_ASSERT(iban == payeeIdentifiers::ibanBic::ibanToElectronic(iban));
if (iban.length() <= 4) // This iban is to short to extract a BIC
return QString("");
// Get bank identifier
const QString bankCode = extractBankIdentifier(iban);
if (bankCode.isEmpty())
return bankCode; // keep .isEmpty() or .isNull()
// Get countryCode
const QString countryCode = iban.left(2);
// Get services which support iban2bic and have a database entry
KService::List services = KServiceTypeTrader::self()->query("KMyMoney/IbanBicData",
QString("(\'%1' ~in [X-KMyMoney-CountryCodes] or '*' in [X-KMyMoney-CountryCodes]) and true == [X-KMyMoney-IBAN-2-BIC-supported] and exist [X-KMyMoney-Bankdata-Database]").arg(countryCode)
);
if (services.isEmpty())
return QString();
QSqlDatabase db = createDatabaseConnection(services.first()->property(QLatin1String("X-KMyMoney-Bankdata-Database"), QVariant::String).toString());
if (!db.isOpen()) // This is an error
return QString();
QSqlQuery query = QSqlQuery(db);
query.prepare("SELECT bic FROM institutions WHERE bankcode=? and country=?");
query.bindValue(0, bankCode);
query.bindValue(1, countryCode);
if (!query.exec()) {
qWarning() << QString("Could not execute query on \"%1\" to receive BIC. Error: %2").arg(db.databaseName()).arg(query.lastError().text());
return QString();
}
if (query.next()) {
return query.value(0).toString();
}
return QString("");
}
示例11: load
void FilterOptions::load()
{
KConfig config(KURISearchFilterEngine::self()->name() + QStringLiteral("rc"), KConfig::NoGlobals);
KConfigGroup group = config.group("General");
const QString defaultSearchEngine = group.readEntry("DefaultWebShortcut");
const QStringList favoriteEngines = group.readEntry("PreferredWebShortcuts", DEFAULT_PREFERRED_SEARCH_PROVIDERS);
QList<SearchProvider*> providers;
const KService::List services = KServiceTypeTrader::self()->query(QStringLiteral("SearchProvider"));
int defaultProviderIndex = services.size(); //default is "None", it is last in the list
Q_FOREACH(const KService::Ptr &service, services)
{
SearchProvider* provider = new SearchProvider(service);
if (defaultSearchEngine == provider->desktopEntryName())
defaultProviderIndex = providers.size();
providers.append(provider);
}
示例12: readSaver
//---------------------------------------------------------------------------
//
// Read the command line needed to run the screensaver given a .desktop file.
//
void ScreenSaverWindow::readSaver()
{
if (!m_saver.isEmpty())
{
QString entryName = m_saver;
if( entryName.endsWith( QLatin1String( ".desktop" ) ))
entryName = entryName.left( entryName.length() - 8 ); // strip it
const KService::List offers = KServiceTypeTrader::self()->query( QLatin1String( "ScreenSaver" ),
QLatin1String( "DesktopEntryName == '" ) + entryName.toLower() + QLatin1Char( '\'' ) );
if( offers.isEmpty() )
{
kDebug(1204) << "Cannot find screesaver: " << m_saver;
return;
}
const QString file = KStandardDirs::locate("services", offers.first()->entryPath());
const bool opengl = KAuthorized::authorizeKAction(QLatin1String( "opengl_screensavers" ));
const bool manipulatescreen = KAuthorized::authorizeKAction(QLatin1String( "manipulatescreen_screensavers" ));
KDesktopFile config( file );
KConfigGroup desktopGroup = config.desktopGroup();
foreach (const QString &type, desktopGroup.readEntry("X-KDE-Type").split(QLatin1Char(';'))) {
if (type == QLatin1String("ManipulateScreen")) {
if (!manipulatescreen) {
kDebug(1204) << "Screensaver is type ManipulateScreen and ManipulateScreen is forbidden";
m_forbidden = true;
}
} else if (type == QLatin1String("OpenGL")) {
m_openGLVisual = true;
if (!opengl) {
kDebug(1204) << "Screensaver is type OpenGL and OpenGL is forbidden";
m_forbidden = true;
}
}
}
kDebug(1204) << "m_forbidden: " << (m_forbidden ? "true" : "false");
if (config.hasActionGroup(QLatin1String( "InWindow" )))
{
m_saverExec = config.actionGroup(QLatin1String( "InWindow" )).readPathEntry("Exec", QString());
}
}
示例13: kde_open
bool ClientApp::kde_open(const KUrl& url, const QString& mimeType, bool allowExec)
{
if ( mimeType.isEmpty() ) {
kDebug() << url;
KRun * run = new KRun( url, 0 );
run->setRunExecutables(allowExec);
QObject::connect( run, SIGNAL( finished() ), this, SLOT( delayedQuit() ));
QObject::connect( run, SIGNAL( error() ), this, SLOT( delayedQuit() ));
this->exec();
return !krun_has_error;
} else {
KUrl::List urls;
urls.append( url );
const KService::List offers = KMimeTypeTrader::self()->query(
mimeType, QLatin1String( "Application" ) );
if (offers.isEmpty()) return 1;
KService::Ptr serv = offers.first();
return KRun::run( *serv, urls, 0 );
}
}
示例14: testMimeTypeTraderForTextPlain
void KMimeTypeTest::testMimeTypeTraderForTextPlain()
{
if ( !KSycoca::isAvailable() )
QSKIP( "ksycoca not available", SkipAll );
// Querying mimetype trader for services associated with text/plain
KService::List offers = KMimeTypeTrader::self()->query("text/plain", "KParts/ReadOnlyPart");
QVERIFY( offerListHasService( offers, "katepart.desktop" ) );
QVERIFY( offerListHasService( offers, "faketextpart.desktop" ) );
offers = KMimeTypeTrader::self()->query("text/plain", "KTextEditor/Plugin");
QVERIFY( offers.count() > 0 );
// We should have at least the fake text plugin that we created for this.
// (The actual plugins from kdelibs don't mention text/plain anymore)
QVERIFY( offerListHasService( offers, "faketextplugin.desktop" ) );
// We shouldn't have non-plugins
QVERIFY( !offerListHasService( offers, "katepart.desktop" ) );
}
示例15: createListForFileItem
QVariantList createListForFileItem(const KFileItem &fileItem)
{
QVariantList list;
if (fileItem.url() == KUrl("trash:/")) {
list << createEmptyTrashItem() << createSeparatorActionItem();
}
KService::List services = KMimeTypeTrader::self()->query(fileItem.mimetype(), "Application");
if (!services.isEmpty()) {
list << createTitleActionItem(i18n("Open with:"));
Q_FOREACH(const KService::Ptr service, services) {
const QString text = service->name().replace('&', "&&");
QVariantMap item = createActionItem(text, "_homerun_fileItem_openWith", service->entryPath());
QString iconName = service->icon();
if (!iconName.isEmpty()) {
item["icon"] = KIcon(service->icon());
}
list << item;
}
list << createSeparatorActionItem();
}