void KonqSidebarTree::loadTopLevelItem( KonqSidebarTreeItem *parent, const QString &filename ) { KDesktopFile cfg( filename, true ); cfg.setDollarExpansion(true); QFileInfo inf( filename ); QString path = filename; QString name = KIO::decodeFileName( inf.fileName() ); if ( name.length() > 8 && name.right( 8 ) == ".desktop" ) name.truncate( name.length() - 8 ); if ( name.length() > 7 && name.right( 7 ) == ".kdelnk" ) name.truncate( name.length() - 7 ); name = cfg.readEntry( "Name", name ); KonqSidebarTreeModule * module = 0L; // Here's where we need to create the right module... // ### TODO: make this KTrader/KLibrary based. QString moduleName = cfg.readEntry( "X-KDE-TreeModule" ); QString showHidden=cfg.readEntry("X-KDE-TreeModule-ShowHidden"); if (moduleName.isEmpty()) moduleName="Directory"; kdDebug(1201) << "##### Loading module: " << moduleName << " file: " << filename << endl; getModule func; func = getPluginFactory(moduleName); if (func!=0) { kdDebug(1201)<<"showHidden: "<<showHidden<<endl; module=func(this,showHidden.upper()=="TRUE"); } if (module==0) {kdDebug()<<"No Module loaded"<<endl; return;} KonqSidebarTreeTopLevelItem *item; if ( parent ) item = new KonqSidebarTreeTopLevelItem( parent, module, path ); else item = new KonqSidebarTreeTopLevelItem( this, module, path ); item->setText( 0, name ); item->setPixmap( 0, SmallIcon( cfg.readIcon() )); module->addTopLevelItem( item ); m_topLevelItems.append( item ); m_lstModules.append( module ); bool open = cfg.readBoolEntry( "Open", false ); if ( open && item->isExpandable() ) item->setOpen( true ); }
void KonqSidebarTree::loadTopLevelItem(KonqSidebarTreeItem *parent, const QString &path) { KDesktopFile cfg( path ); KConfigGroup desktopGroup = cfg.desktopGroup(); const QString name = cfg.readName(); // Here's where we need to create the right module... // ### TODO: make this KTrader/KLibrary based. const QString moduleName = desktopGroup.readPathEntry( "X-KDE-TreeModule", QString("Directory") ); const QString showHidden = desktopGroup.readEntry("X-KDE-TreeModule-ShowHidden"); kDebug(1201) << "##### Loading module: " << moduleName << " file: " << path; KonqSidebarTreeModule * module = NULL; getModule func = getPluginFactory(moduleName); if (func) { kDebug(1201)<<"showHidden: "<<showHidden; module=func(this,showHidden.toUpper()=="TRUE"); } if (!module) { kDebug() << "No Module loaded for" << moduleName; return; } KonqSidebarTreeTopLevelItem *item; if ( parent ) item = new KonqSidebarTreeTopLevelItem( parent, module, path ); else item = new KonqSidebarTreeTopLevelItem( this, module, path ); item->setText( 0, name ); item->setPixmap( 0, SmallIcon( cfg.readIcon() )); module->addTopLevelItem( item ); m_topLevelItems.append( item ); m_lstModules.append( module ); bool open = desktopGroup.readEntry( "Open", false); if ( open && item->isExpandable() ) item->setOpen( true ); }