本文整理汇总了C++中ktrader::OfferList类的典型用法代码示例。如果您正苦于以下问题:C++ OfferList类的具体用法?C++ OfferList怎么用?C++ OfferList使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了OfferList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: KaffeineDVBsection
DVBevents::DVBevents( QString devType, int anum, int tnum, const QString &charset, EventTable *table )
: KaffeineDVBsection( anum, tnum, charset )
{
events = table;
KaffeineEpgPlugin *plug;
QString plugName;
int error;
KTrader::OfferList offers = KTrader::self()->query("KaffeineEpgPlugin");
KTrader::OfferList::Iterator end( offers.end() );
for ( KTrader::OfferList::Iterator it=offers.begin(); it!=end; ++it ) {
error = 0;
KService::Ptr ptr = (*it);
if ( !ptr->name().contains(devType) )
continue;
plug = KParts::ComponentFactory::createPartInstanceFromService<KaffeineEpgPlugin>(ptr, 0, ptr->name().ascii(), 0, 0, 0, &error );
plugName = ptr->desktopEntryName();
if (error > 0) {
fprintf( stderr, "Loading of EPG plugin %s failed: %s\n", plugName.ascii(), KLibLoader::self()->lastErrorMessage().ascii() );
plug = NULL;
}
else {
plugs.append( plug );
plug->setTable( table );
plug->initSection( anum, tnum, charset );
plugNames.append( plugName );
}
}
fprintf( stderr, "%d EPG plugins loaded for device %d:%d.\n", plugs.count(), anum, tnum );
}
示例2: QWidget
ksimoptsView::ksimoptsView(QWidget *parent)
: QWidget(parent),
DCOPObject("ksimoptsIface")
{
// setup our layout manager to automatically add our widgets
QHBoxLayout *top_layout = new QHBoxLayout(this);
top_layout->setAutoAdd(true);
// we want to look for all components that satisfy our needs. the
// trader will actually search through *all* registered KDE
// applications and components -- not just KParts. So we have to
// specify two things: a service type and a constraint
//
// the service type is like a mime type. we say that we want all
// applications and components that can handle HTML -- 'text/html'
//
// however, by itself, this will return such things as Netscape..
// not what we wanted. so we constrain it by saying that the
// string 'KParts/ReadOnlyPart' must be found in the ServiceTypes
// field. with this, only components of the type we want will be
// returned.
KTrader::OfferList offers = KTrader::self()->query("text/html", "'KParts/ReadWritePart' in ServiceTypes");
KLibFactory *factory = 0;
// in theory, we only care about the first one.. but let's try all
// offers just in case the first can't be loaded for some reason
KTrader::OfferList::Iterator it(offers.begin());
for( ; it != offers.end(); ++it)
{
KService::Ptr ptr = (*it);
// we now know that our offer can handle HTML and is a part.
// since it is a part, it must also have a library... let's try to
// load that now
factory = KLibLoader::self()->factory( ptr->library() );
if (factory)
{
m_html = static_cast<KParts::ReadWritePart *>(factory->create(this, ptr->name(), "KParts::ReadWritePart"));
break;
}
}
// if our factory is invalid, then we never found our component
// and we might as well just exit now
if (!factory)
{
KMessageBox::error(this, i18n("Could not find a suitable HTML component"));
return;
}
connect(m_html, SIGNAL(setWindowCaption(const QString&)),
this, SLOT(slotSetTitle(const QString&)));
connect(m_html, SIGNAL(setStatusBarText(const QString&)),
this, SLOT(slotOnURL(const QString&)));
}
示例3: displayPluginList
void ImportWizard::displayPluginList()
{
KTrader::OfferList plugins = KFTPAPI::getInstance()->pluginManager()->getImportPlugins();
KTrader::OfferList::ConstIterator end(plugins.end());
for (KTrader::OfferList::ConstIterator i(plugins.begin()); i != end; ++i) {
KService::Ptr service = *i;
new PluginListItem(m_pluginList, service);
}
}
示例4: Plugin
KHTMLPluginKTTSD::KHTMLPluginKTTSD(QObject *parent, const char *name, const QStringList &) : Plugin(parent, name)
{
// If KTTSD is not installed, hide action.
KTrader::OfferList offers = KTrader::self()->query("DCOP/Text-to-Speech", "Name == 'KTTSD'");
if(offers.count() > 0)
{
(void)new KAction(i18n("&Speak Text"), "kttsd", 0, this, SLOT(slotReadOut()), actionCollection(), "tools_kttsd");
}
else
kdDebug() << "KHTMLPLuginKTTSD::KHTMLPluginKTTSD: KTrader did not find KTTSD." << endl;
}
示例5: init
void PluginSelectDialog::init( )
{
const QValueList<KDevPlugin*> loadedPlugins = PluginController::getInstance()->loadedPlugins();
QStringList loadedPluginDesktopNames;
QValueList<KDevPlugin*>::ConstIterator it = loadedPlugins.begin();
while( it != loadedPlugins.end() )
{
loadedPluginDesktopNames << (*it)->instance()->instanceName();
++it;
}
kdDebug(9000) << " *** loadedPluginDesktopNames: " << loadedPluginDesktopNames << endl;
KTrader::OfferList localOffers;
if ( ProjectManager::getInstance()->projectLoaded() )
{
localOffers = PluginController::getInstance()->engine().offers(
PluginController::getInstance()->currentProfile(), ProfileEngine::Project );
}
KTrader::OfferList globalOffers = PluginController::getInstance()->engine().offers(
PluginController::getInstance()->currentProfile(), ProfileEngine::Global);
KTrader::OfferList offers = localOffers + globalOffers;
for (KTrader::OfferList::ConstIterator it = offers.begin(); it != offers.end(); ++it)
{
// parse out any existing url to make it clickable
QString Comment = (*it)->comment();
QRegExp re("\\bhttp://[\\S]*");
re.search( Comment );
Comment.replace( re, "" );
QString url;
if ( re.pos() > -1 )
{
url = re.cap();
}
PluginItem *item = new PluginItem( plugin_list, (*it)->desktopEntryName(), (*it)->genericName(), Comment, url );
item->setOn( loadedPluginDesktopNames.contains( (*it)->desktopEntryName() ) );
kdDebug(9000) << (*it)->desktopEntryName() << " : " << (loadedPluginDesktopNames.contains( (*it)->desktopEntryName() ) ? "YES" : "NO" ) << endl;
}
QListViewItem * first = plugin_list->firstChild();
if ( first )
{
plugin_list->setSelected( first, true );
}
}
示例6: openURL
bool KPartSaver::openURL( KURL url )
{
closeURL();
// find mime type
TQString mime = KMimeType::findByURL( url )->name();
// find fitting kparts
KTrader::OfferList offers;
offers = KTrader::self()->query( mime, "'KParts/ReadOnlyPart' in ServiceTypes" );
if( offers.count()==0 ) {
kdDebug() << "Can't find proper kpart for " << mime << endl;
return false;
}
// load kpart library
TQString lib = offers.first()->library();
KLibFactory *factory = KLibLoader::self()->factory( lib.latin1() );
if( !factory ) {
kdDebug() << "Library " << lib << " not found." << endl;
return false;
}
// create kpart
m_part = (KParts::ReadOnlyPart *)factory->create( TQT_TQOBJECT(this), "kpart", "KParts::ReadOnlyPart" );
if( !m_part ) {
kdDebug() << "Part for " << url.url() << " can't be constructed" << endl;
return false;
} else
embed( m_part->widget() );
// show kpart
delete m_back;
m_back = 0;
show();
m_part->widget()->show();
// load url
if( !m_part->openURL( url ) ) {
kdDebug() << "Can't load " << url.url() << endl;
closeURL();
return false;
}
return true;
}
示例7: insertOpenWithMenu
void BaseTreeView::insertOpenWithMenu(KPopupMenu *menu, int position)
{
if (m_openWithMenuId != -1)
menu->removeItem(m_openWithMenuId);
for (uint i = 0; i < m_openWithActions.count(); i++)
{
KAction *action = m_openWithActions[i];
delete action;
}
m_openWithActions.clear();
KURL urlToOpen = currentURL();
QString mimeType = KMimeType::findByURL(urlToOpen, 0, true, true)->name();
KTrader::OfferList offers = KTrader::self()->query(mimeType, "Type == 'Application'");
QDict<QuantaPlugin> plugins = QuantaPluginInterface::ref()->plugins();
m_pluginIds.clear();
if (offers.count() > 0 || plugins.count() > 0)
{
m_openWithMenu = new KPopupMenu(this);
if (offers.count() > 0)
{
KTrader::OfferList::Iterator it;
for (it = offers.begin(); it != offers.end(); ++it)
{
KAction *action = new KAction((*it)->name(), (*it)->icon(), 0, 0, QFile::encodeName((*it)->desktopEntryPath()).data());
connect(action, SIGNAL(activated()), this, SLOT(slotOpenWithApplication()));
action->plug(m_openWithMenu);
m_openWithActions.append(action);
}
m_openWithMenu->insertSeparator();
}
if (plugins.count() > 0)
{
m_openWithMenu->insertTitle(i18n("Plugins"));
QDictIterator<QuantaPlugin> it2(plugins);
for(;it2.current();++it2)
{
int id = m_openWithMenu->insertItem(KGlobal::iconLoader()->loadIconSet(it2.current()->icon(),KIcon::Small), it2.current()->name());
m_pluginIds[id] = it2.current();
}
connect(m_openWithMenu, SIGNAL(activated(int)), SLOT(slotOpenWithActivated(int)));
m_openWithMenu->insertSeparator();
}
m_openWithMenu->insertItem(i18n("&Other..."), this, SLOT(slotOpenWith()));
m_openWithMenuId = menu->insertItem(i18n("Open &With"), m_openWithMenu, -1, position);
} else
m_openWithMenuId = menu->insertItem(i18n("Open &With..."), this, SLOT(slotOpenWith()), 0, -1, position);
}
示例8: searchExtParts
void KDiffTextEdit::searchExtParts()
{
// only execute once
static bool init = false;
if ( init )
return;
init = true;
// search all parts that can handle text/x-diff
KTrader::OfferList offers = KTrader::self()->query("text/x-diff", "('KParts/ReadOnlyPart' in ServiceTypes) and ('text/x-diff' in ServiceTypes) and (DesktopEntryName != 'katepart')");
KTrader::OfferList::const_iterator it;
for ( it = offers.begin(); it != offers.end(); ++it ) {
KService::Ptr ptr = (*it);
extPartsTranslated << ptr->name();
extParts << ptr->desktopEntryName();
}
return;
}
示例9: loadPlugins
void XXPortManager::loadPlugins()
{
mXXPortObjects.clear();
const KTrader::OfferList plugins = KTrader::self()->query("KAddressBook/XXPort",
QString("[X-KDE-KAddressBook-XXPortPluginVersion] == %1").arg(KAB_XXPORT_PLUGIN_VERSION));
KTrader::OfferList::ConstIterator it;
for(it = plugins.begin(); it != plugins.end(); ++it)
{
if(!(*it)->hasServiceType("KAddressBook/XXPort"))
continue;
KLibFactory *factory = KLibLoader::self()->factory((*it)->library().latin1());
if(!factory)
{
kdDebug(5720) << "XXPortManager::loadExtensions(): Factory creation failed" << endl;
continue;
}
KAB::XXPortFactory *xxportFactory = static_cast<KAB::XXPortFactory *>(factory);
if(!xxportFactory)
{
kdDebug(5720) << "XXPortManager::loadExtensions(): Cast failed" << endl;
continue;
}
KAB::XXPort *obj = xxportFactory->xxportObject(mCore->addressBook(), mCore->widget());
if(obj)
{
if(mCore->guiClient())
mCore->guiClient()->insertChildClient(obj);
mXXPortObjects.insert(obj->identifier(), obj);
connect(obj, SIGNAL(exportActivated(const QString &, const QString &)),
this, SLOT(slotExport(const QString &, const QString &)));
connect(obj, SIGNAL(importActivated(const QString &, const QString &)),
this, SLOT(slotImport(const QString &, const QString &)));
obj->setKApplication(kapp);
}
}
}
示例10:
void
EditorSelection::readConfig()
{
m_editorsCombo->clear();
KTrader::OfferList editors = KTrader::self()->query(
QString::fromLatin1("Komposer/Editor"));
KTrader::OfferList::ConstIterator it;
int i = 0;
for(it = editors.begin(); it != editors.end(); ++it, ++i)
{
if(!(*it)->hasServiceType(QString::fromLatin1("Komposer/Editor")))
continue;
QString name = (*it)->property("X-KDE-KomposerIdentifier").toString();
m_editorsCombo->insertItem(name);
if(m_reference.contains(name))
m_editorsCombo->setCurrentItem(i);
}
}
示例11: block
Plugin*
PluginManager::createFromQuery( const QString &constraint )
{
Debug::Block block( __PRETTY_FUNCTION__ );
KTrader::OfferList offers = query( constraint );
if ( offers.isEmpty() ) {
warning() << k_funcinfo << "No matching plugin found.\n";
return 0;
}
// Select plugin with highest rank
int rank = 0;
uint current = 0;
for ( uint i = 0; i < offers.count(); i++ ) {
if ( offers[i]->property( "X-KDE-amaroK-rank" ).toInt() > rank )
current = i;
}
return createFromService( offers[current] );
}
示例12: QWidget
EditorChooser::EditorChooser(QWidget *parent, const char *name) : QWidget(parent, name)
{
d = new PrivateEditorChooser();
// sizemanagment
QGridLayout *grid = new QGridLayout(this, 1, 1);
d->chooser = new EditorChooser_UI(this, name);
grid->addWidget(d->chooser, 0, 0);
KTrader::OfferList offers = KTrader::self()->query("text/plain", "'KTextEditor/Document' in ServiceTypes");
KConfig *config = new KConfig("default_components");
config->setGroup("KTextEditor");
QString editor = config->readPathEntry("embeddedEditor");
if(editor.isEmpty())
editor = "katepart";
for(KTrader::OfferList::Iterator it = offers.begin(); it != offers.end(); ++it)
{
if((*it)->desktopEntryName().contains(editor))
{
d->chooser->editorCombo->insertItem(i18n("System Default (%1)").arg((*it)->name()));
break;
}
}
for(KTrader::OfferList::Iterator it = offers.begin(); it != offers.end(); ++it)
{
d->chooser->editorCombo->insertItem((*it)->name());
d->elements.append((*it)->desktopEntryName());
}
d->chooser->editorCombo->setCurrentItem(0);
}
示例13: reload
void ContactEditorWidgetManager::reload()
{
mFactories.clear();
kdDebug(5720) << "ContactEditorWidgetManager::reload()" << endl;
const KTrader::OfferList plugins = KTrader::self()->query("KAddressBook/ContactEditorWidget",
QString("[X-KDE-KAddressBook-CEWPluginVersion] == %1").arg(KAB_CEW_PLUGIN_VERSION));
KTrader::OfferList::ConstIterator it;
for(it = plugins.begin(); it != plugins.end(); ++it)
{
KLibFactory *factory = KLibLoader::self()->factory((*it)->library().latin1());
if(!factory)
{
kdDebug(5720) << "ContactEditorWidgetManager::reload(): Factory creation failed" << endl;
continue;
}
KAB::ContactEditorWidgetFactory *pageFactory =
static_cast<KAB::ContactEditorWidgetFactory *>(factory);
if(!pageFactory)
{
kdDebug(5720) << "ContactEditorWidgetManager::reload(): Cast failed" << endl;
continue;
}
mFactories.append(pageFactory);
}
// add all non-plugin contact editor factories
mFactories.append(new FreeBusyWidgetFactory);
mFactories.append(new ImageWidgetFactory);
mFactories.append(new SoundWidgetFactory);
mFactories.append(new GeoWidgetFactory);
mFactories.append(new CustomFieldsWidgetFactory);
}
示例14: insertOpenWithItems
int DolphinContextMenu::insertOpenWithItems(KPopupMenu* popup,
QValueVector<KService::Ptr>& openWithVector)
{
// Prepare 'Open With' sub menu. Usually a sub menu is created, where all applications
// are listed which are registered to open the item. As last entry "Other..." will be
// attached which allows to select a custom application. If no applications are registered
// no sub menu is created at all, only "Open With..." will be offered.
const KFileItemList* list = m_dolphinView->selectedItems();
assert(list != 0);
bool insertOpenWithItems = true;
const QString contextMimeType(m_fileInfo->mimetype());
KFileItemListIterator mimeIt(*list);
KFileItem* item = 0;
while (insertOpenWithItems && ((item = mimeIt.current()) != 0)) {
insertOpenWithItems = (contextMimeType == item->mimetype());
++mimeIt;
}
int openWithID = -1;
if (insertOpenWithItems) {
// fill the 'Open with' sub menu with application types
const KMimeType::Ptr mimePtr = KMimeType::findByURL(m_fileInfo->url());
KTrader::OfferList offers = KTrader::self()->query(mimePtr->name(),
"Type == 'Application'");
int index = openWithIDStart;
if (offers.count() > 0) {
KTrader::OfferList::Iterator it;
KPopupMenu* openWithMenu = new KPopupMenu();
for(it = offers.begin(); it != offers.end(); ++it) {
// The offer list from the KTrader returns duplicate
// application entries. Although this seems to be a configuration
// problem outside the scope of Dolphin, duplicated entries just
// will be skipped here.
const QString appName((*it)->name());
if (!containsEntry(openWithMenu, appName)) {
openWithMenu->insertItem((*it)->pixmap(KIcon::Small),
appName, index);
openWithVector.append(*it);
++index;
}
}
openWithMenu->insertSeparator();
openWithMenu->insertItem(i18n("&Other..."), index);
popup->insertItem(i18n("Open With"), openWithMenu);
}
else {
// No applications are registered, hence just offer
// a "Open With..." item instead of a sub menu containing
// only one entry.
popup->insertItem(i18n("Open With..."), openWithIDStart);
}
openWithID = index;
}
else {
// At least one of the selected items has a different MIME type. In this case
// just show a disabled "Open With..." entry.
popup->insertItem(i18n("Open With..."), openWithIDStart);
popup->setItemEnabled(openWithIDStart, false);
}
popup->setItemEnabled(openWithID, insertOpenWithItems);
return openWithID;
}
示例15: kgitViewbase
kgitView::kgitView(QWidget *parent)
: kgitViewbase(parent),
DCOPObject("kgitIface")
{
// setup our layout manager to automatically add our widgets
QHBoxLayout *top_layout = new QHBoxLayout(this);
top_layout->setAutoAdd(true);
// we want to look for all components that satisfy our needs. the
// trader will actually search through *all* registered KDE
// applications and components -- not just KParts. So we have to
// specify two things: a service type and a constraint
//
// the service type is like a mime type. we say that we want all
// applications and components that can handle HTML -- 'text/html'
//
// however, by itself, this will return such things as Netscape..
// not what we wanted. so we constrain it by saying that the
// string 'KParts/ReadOnlyPart' must be found in the ServiceTypes
// field. with this, only components of the type we want will be
// returned.
KTrader::OfferList offers = KTrader::self()->query("text/plain", "'KParts/ReadWritePart' in ServiceTypes");
KLibFactory *factory = 0;
// in theory, we only care about the first one.. but let's try all
// offers just in case the first can't be loaded for some reason
KTrader::OfferList::Iterator it(offers.begin());
for( ; it != offers.end(); ++it)
{
KService::Ptr ptr = (*it);
// we now know that our offer can handle HTML and is a part.
// since it is a part, it must also have a library... let's try to
// load that now
factory = KLibLoader::self()->factory( ptr->library() );
if (factory)
{
m_html = static_cast<KParts::ReadWritePart *>(factory->create(this/*(QWidget *)layout4->parent()*/, ptr->name(), "KParts::ReadWritePart"));
break;
}
}
// if our factory is invalid, then we never found our component
// and we might as well just exit now
if (!factory)
{
KMessageBox::error(this, i18n("Could not find a suitable HTML component"));
return;
}
//layout4->addWidget(m_html->widget());
m_html->widget()->hide();
connect(m_html, SIGNAL(setWindowCaption(const QString&)),
this, SLOT(slotSetTitle(const QString&)));
connect(m_html, SIGNAL(setStatusBarText(const QString&)),
this, SLOT(slotOnURL(const QString&)));
gitProc = new KProcIO;
connect((QObject *)CommitButton,SIGNAL(clicked()),this,SLOT(slotCommitCurrent()));
connect((QObject *)DiscardChangesButton,SIGNAL(clicked()),this,SLOT(slotDiscardChanges()));
connect((QObject *)UndoCommitButton,SIGNAL(clicked()),this,SLOT(slotUndoLastCommit()));
connect((QObject *)RevertCommitButton,SIGNAL(clicked()),this,SLOT(slotRevertCommit()));
connect((QObject *)CherryPickFromOtherButton,SIGNAL(clicked()),this,SLOT(slotCherryPickFromOther()));
connect((QObject *)SendPatchButton,SIGNAL(clicked()),this,SLOT(slotSendPatch()));
connect(comboBoxBranches, SIGNAL(activated(const QString&)),this,SLOT(slotGitChangeBranch(const QString&)));
connect(ShortLogList, SIGNAL(doubleClicked( QListViewItem *, const QPoint &, int ) ),this,SLOT(slotGitShowCommitDiff()));
ShortLogList->setSorting(-1);
connect(RepoTreeList, SIGNAL(selectionChanged()),this,SLOT(slotUpdateFilesToCommit()));
connect(FileListFilterText, SIGNAL(textChanged ( const QString & )),this,SLOT(slotFileFilter(const QString &)));
commit_files = new QStringList;
branches = new QStringList;
busyWaiting=0;
}