本文整理汇总了C++中kservice::Ptr::isValid方法的典型用法代码示例。如果您正苦于以下问题:C++ Ptr::isValid方法的具体用法?C++ Ptr::isValid怎么用?C++ Ptr::isValid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kservice::Ptr
的用法示例。
在下文中一共展示了Ptr::isValid方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: KService
void
KCustomMenuEditor::load(KConfigBase *cfg)
{
cfg->setGroup(QString::null);
int count = cfg->readNumEntry("NrOfItems");
QListViewItem *last = 0;
for(int i = 0; i < count; i++)
{
QString entry = cfg->readPathEntry(QString("Item%1").arg(i+1));
if (entry.isEmpty())
continue;
// Try KSycoca first.
KService::Ptr menuItem = KService::serviceByDesktopPath( entry );
if (!menuItem)
menuItem = KService::serviceByDesktopName( entry );
if (!menuItem)
menuItem = new KService( entry );
if (!menuItem->isValid())
continue;
QListViewItem *item = new Item(m_listView, menuItem);
item->moveItem(last);
last = item;
}
}
示例2: stat
void ApplicationsProtocol::stat(const KUrl& url)
{
KIO::UDSEntry entry;
QString servicePath( url.path( KUrl::AddTrailingSlash ) );
servicePath.remove(0, 1); // remove starting '/'
KServiceGroup::Ptr grp = KServiceGroup::group(servicePath);
if (grp && grp->isValid()) {
createDirEntry(entry, ((m_runMode==ApplicationsMode) ? i18n("Applications") : i18n("Programs")),
url.url(), "inode/directory",grp->icon() );
} else {
KService::Ptr service = KService::serviceByDesktopName( url.fileName() );
if (service && service->isValid()) {
createFileEntry(entry, service, url );
} else {
error(KIO::ERR_SLAVE_DEFINED,i18n("Unknown application folder"));
return;
}
}
statEntry(entry);
finished();
}
示例3: get
void ApplicationsProtocol::get( const KUrl & url )
{
KService::Ptr service = KService::serviceByDesktopName(url.fileName());
if (service && service->isValid()) {
KUrl redirUrl(KStandardDirs::locate("apps", service->entryPath()));
redirection(redirUrl);
finished();
} else {
error( KIO::ERR_IS_DIRECTORY, url.prettyUrl() );
}
}
示例4: startWizard
void RemoteMenu::startWizard()
{
KURL url;
KService::Ptr service = KService::serviceByDesktopName(WIZARD_SERVICE);
if (service && service->isValid())
{
url.setPath(locate("apps", service->desktopEntryPath()));
new KRun(url, 0, true); // will delete itself
}
}
示例5: loadActions
void RemotePlugin::loadActions(DOM::HTMLElement node)
{
KService::Ptr service = KService::serviceByDesktopName("knetattach");
if(service && service->isValid()){
DOM::DOMString innerHTML;
MetabarWidget::addEntry(innerHTML, i18n("Add a Network Folder"), "desktop://" + locate("apps", service->desktopEntryPath()), "wizard");
node.setInnerHTML(innerHTML);
m_functions->show("actions");
}
else{
m_functions->hide("actions");
}
}
示例6: createNoteLinkOrLauncher
Note* NoteFactory::createNoteLinkOrLauncher(const KUrl &url, Basket *parent)
{
// IMPORTANT: we create the service ONLY if the extension is ".desktop".
// Otherwise, KService take a long time to analyse all the file
// and output such things to stdout:
// "Invalid entry (missing '=') at /my/file.ogg:11984"
// "Invalid entry (missing ']') at /my/file.ogg:11984"...
KService::Ptr service;
if (url.fileName().endsWith(".desktop"))
service = new KService(url.path());
// If link point to a .desktop file then add a launcher, otherwise it's a link
if (service && service->isValid())
return createNoteLauncher(url, parent);
else
return createNoteLink(url, parent);
}
示例7: dlg
void
KCustomMenuEditor::slotNewItem()
{
QListViewItem *item = m_listView->currentItem();
KOpenWithDlg dlg(this);
dlg.setSaveNewApplications(true);
if (dlg.exec())
{
KService::Ptr s = dlg.service();
if (s && s->isValid())
{
Item *newItem = new Item(m_listView, s);
newItem->moveItem(item);
}
refreshButton();
}
}
示例8: KConfigDialog
SettingsDialog::SettingsDialog(QWidget *parent, const char *name,KConfigSkeleton *config)
: KConfigDialog(parent, name, config),
cddb(0), cddbChanged(false)
{
addPage(new General(0, "General"), i18n("General"), "package_settings",
i18n("General Configuration"));
addPage(new CdConfig(0, "CD"), i18n("CD"), "package_system",
i18n("CD Configuration"));
// Because WE don't segfault on our users...
KService::Ptr libkcddb = KService::serviceByDesktopName("libkcddb");
if (libkcddb && libkcddb->isValid())
{
cddb = KCModuleLoader::loadModule(QString("libkcddb"), KCModuleLoader::Inline);
if (cddb)
{
cddb->load();
addPage(cddb, i18n("CDDB"), "cdaudio_mount", i18n("CDDB Configuration"), false);
connect(cddb, SIGNAL(changed(bool)), this, SLOT(slotCddbChanged(bool)));
}
}
示例9: get
void ThumbnailProtocol::get(const KURL &url)
{
m_mimeType = metaData("mimeType");
kdDebug(7115) << "Wanting MIME Type:" << m_mimeType << endl;
#ifdef THUMBNAIL_HACK
// ### HACK
bool direct=false;
if (m_mimeType.isEmpty())
{
kdDebug(7115) << "PATH: " << url.path() << endl;
TQFileInfo info(url.path());
if (info.isDir())
{
// We cannot process a directory
error(TDEIO::ERR_IS_DIRECTORY,url.path());
return;
}
else if (!info.exists())
{
// The file does not exist
error(TDEIO::ERR_DOES_NOT_EXIST,url.path());
return;
}
else if (!info.isReadable())
{
// The file is not readable!
error(TDEIO::ERR_COULD_NOT_READ,url.path());
return;
}
m_mimeType = KMimeType::findByURL(url)->name();
kdDebug(7115) << "Guessing MIME Type:" << m_mimeType << endl;
direct=true; // thumbnail: was probably called from Konqueror
}
#endif
if (m_mimeType.isEmpty())
{
error(TDEIO::ERR_INTERNAL, i18n("No MIME Type specified."));
return;
}
m_width = metaData("width").toInt();
m_height = metaData("height").toInt();
int iconSize = metaData("iconSize").toInt();
if (m_width < 0 || m_height < 0)
{
error(TDEIO::ERR_INTERNAL, i18n("No or invalid size specified."));
return;
}
#ifdef THUMBNAIL_HACK
else if (!m_width || !m_height)
{
kdDebug(7115) << "Guessing height, width, icon size!" << endl;
m_width=128;
m_height=128;
iconSize=128;
}
#endif
if (!iconSize)
iconSize = TDEGlobal::iconLoader()->currentSize(TDEIcon::Desktop);
if (iconSize != m_iconSize)
m_iconDict.clear();
m_iconSize = iconSize;
m_iconAlpha = metaData("iconAlpha").toInt();
if (m_iconAlpha)
m_iconAlpha = (m_iconAlpha << 24) | 0xffffff;
TQImage img;
TDEConfigGroup group( TDEGlobal::config(), "PreviewSettings" );
// ### KFMI
bool kfmiThumb = false;
if (group.readBoolEntry( "UseFileThumbnails", true )) {
KService::Ptr service =
KServiceTypeProfile::preferredService( m_mimeType, "KFilePlugin");
if ( service && service->isValid() && /*url.isLocalFile() && */
service->property("SupportsThumbnail").toBool())
{
KFileMetaInfo info(url.path(), m_mimeType, KFileMetaInfo::Thumbnail);
if (info.isValid())
{
KFileMetaInfoItem item = info.item(KFileMimeTypeInfo::Thumbnail);
if (item.isValid() && item.value().type() == TQVariant::Image)
{
img = item.value().toImage();
kdDebug(7115) << "using KFMI for the thumbnail\n";
kfmiThumb = true;
}
}
}
}
ThumbCreator::Flags flags = ThumbCreator::None;
if (!kfmiThumb)
//.........这里部分代码省略.........