本文整理汇总了C++中KBookmark::file方法的典型用法代码示例。如果您正苦于以下问题:C++ KBookmark::file方法的具体用法?C++ KBookmark::file怎么用?C++ KBookmark::file使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KBookmark
的用法示例。
在下文中一共展示了KBookmark::file方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: checkLocalProperties
//------------------------------------------------------------------------
void KfmView::checkLocalProperties (const char *_url)
{
// Here we read properties. We check if this is a dir with .directory
// then if this is the bookmarked url, last if this is on the desktop
if (!KRootWidget::pKRootWidget) // No desktop : the window is being restored
// by session management. Then use SM values, not local properties.
return;
// check if this options are enabled:
if (!pkfm->isURLPropesEnabled ())
return;
int isADir;
// Check if this is a dir. If it is writable, write it.
isADir = strncmp (_url, "file:", 5);
if (!isADir)
{
if (access(&_url[5], R_OK)==0) // we need if we can read (sven)
{
QString configname(&_url[5]);
configname.append("/.directory");
if (access(configname.data(), F_OK)==0)
{
KSimpleConfig cfg(configname.data(), true); // be read only
gui->loadProperties((KConfig *) &cfg);
return;
}
}
}
//.directory not readable or not found. See if it is bookmarked
KBookmark *bm = gui->getBookmarkManager()->findBookmark(_url);
if (bm)
{
KSimpleConfig cfg(bm->file(), true); //RO
gui->loadProperties((KConfig *) &cfg); // will sync on end
return;
}
// .directory not readable or not found and not bookmarked.
// See if it is on desktop
for (KRootIcon *i = IconList.first(); i; i = IconList.next())
{
QString kurl = i->getURL();
KURL::decodeURL(kurl); // Decode kdelnk filename
if (kurl.contains(".kdelnk"))
{
KSimpleConfig cfg(&(kurl.data())[5], true); // RO, #inline, so it's fast
cfg.setGroup("KDE Desktop Entry");
if (!strcmp (cfg.readEntry("URL").data(), _url))
{
gui->loadProperties((KConfig *) &cfg); // will sync on end
return;
}
}
}
// Not found or not readable:
// Tell gui that there is no URL properties!!!!
gui->setHasLocal(false);
}
示例2: slotSaveLocalProperties
//----------------------------------------------------------------------------
void KfmView::slotSaveLocalProperties()
{
int isADir;
// Check if this is a dir. If it is writable, write it.
const char *_url = manager->getURL();
isADir = strncmp (_url, "file:", 5);
if (!isADir)
{
// No way do find out is it writable; have to check:
if (access(&_url[5], W_OK)==0)
{
QString configname(&_url[5]);
configname.append("/.directory");
KSimpleConfig cfg(configname.data());
gui->writeProperties((KConfig *) &cfg); // will sync on end
return;
}
}
//Dir not writable or not a file: url. See if it is bookmarked
KBookmark *bm = gui->getBookmarkManager()->findBookmark(_url);
if (bm)
{
KSimpleConfig cfg(bm->file());
gui->writeProperties((KConfig *) &cfg); // will sync on end
return;
}
//Dir not writable or not a file: url. See if it is on desktop
if (KRootWidget::pKRootWidget) // if there is one. DF.
{
QString s1, s2, kurl;
s1 = _url;
if (s1.right( 1 ) == "/")
s1.resize(s1.length());
for (KRootIcon *i = IconList.first(); i; i = IconList.next())
{
kurl = i->getURL();
KURL::decodeURL(kurl); // Decode kdelnk filename
if (kurl.contains(".kdelnk"))
{
debug ("Got a kdelnk: %s", &(kurl.data())[5]);
KSimpleConfig cfg(&(kurl.data())[5], true); //RO, #inline, so it's fast
cfg.setGroup("KDE Desktop Entry");
s2 = cfg.readEntry("URL").data();
if (s2.right( 1 ) == "/")
s2.resize(s2.length());
if (s1 == s2)
{
KSimpleConfig wcfg(&(kurl.data())[5]); //rw
gui->writeProperties((KConfig *) &wcfg); // will sync on end
return;
}
}
}
}
// Not found or not writable:
if (!isADir )
QMessageBox::warning(0, klocale->translate( "KFM Error" ),
klocale->translate("Can not save properties because\nthis directory is neither writable nor bookmarked.\n\n Bookmark this location first, or make kdelnk to it on desktop.") );
else
QMessageBox::warning(0, klocale->translate( "KFM Error" ),
klocale->translate("Can not save properties because\nthis URL is neither bookmarked nor on desktop.\n\n Bookmark this location first, or make kdelnk to it on desktop."));
}