本文整理汇总了C++中ktrader::OfferList::count方法的典型用法代码示例。如果您正苦于以下问题:C++ OfferList::count方法的具体用法?C++ OfferList::count怎么用?C++ OfferList::count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ktrader::OfferList
的用法示例。
在下文中一共展示了OfferList::count方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
示例2: 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;
}
示例3: 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;
}
示例4: 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] );
}
示例5: 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;
}