//------------------------------------------------------------------------ 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); }
//---------------------------------------------------------------------------- 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.")); }