00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <qdir.h>
00022
00023 #include <klocale.h>
00024 #include <kapplication.h>
00025 #include <kbookmarkmanager.h>
00026 #include <kdebug.h>
00027 #include <krun.h>
00028 #include <kprotocolinfo.h>
00029 #include <kiconloader.h>
00030 #include <klineeditdlg.h>
00031 #include <kglobalsettings.h>
00032 #include <kstandarddirs.h>
00033 #include <kxmlguifactory.h>
00034 #include <kxmlguibuilder.h>
00035 #include <kparts/componentfactory.h>
00036
00037 #include <assert.h>
00038
00039 #include <kfileshare.h>
00040 #include <kprocess.h>
00041
00042 #include "kpropertiesdialog.h"
00043 #include "knewmenu.h"
00044 #include "konq_popupmenu.h"
00045 #include "konq_operations.h"
00046
00047 class KonqPopupMenuGUIBuilder : public KXMLGUIBuilder
00048 {
00049 public:
00050 KonqPopupMenuGUIBuilder( QPopupMenu *menu )
00051 : KXMLGUIBuilder( 0 )
00052 {
00053 m_menu = menu;
00054 }
00055 virtual ~KonqPopupMenuGUIBuilder()
00056 {
00057 }
00058
00059 virtual QWidget *createContainer( QWidget *parent, int index,
00060 const QDomElement &element,
00061 int &id )
00062 {
00063 if ( !parent && element.attribute( "name" ) == "popupmenu" )
00064 return m_menu;
00065
00066 return KXMLGUIBuilder::createContainer( parent, index, element, id );
00067 }
00068
00069 QPopupMenu *m_menu;
00070 };
00071
00072 class KonqPopupMenu::KonqPopupMenuPrivate
00073 {
00074 public:
00075 KonqPopupMenuPrivate() : m_parentWidget(0) {}
00076 QString m_urlTitle;
00077 QWidget *m_parentWidget;
00078 };
00079
00080 KonqPopupMenu::ProtocolInfo::ProtocolInfo( )
00081 {
00082 m_Reading = false;
00083 m_Writing = false;
00084 m_Deleting = false;
00085 m_Moving = false;
00086 m_TrashIncluded = false;
00087 }
00088 bool KonqPopupMenu::ProtocolInfo::supportsReading() const
00089 {
00090 return m_Reading;
00091 }
00092 bool KonqPopupMenu::ProtocolInfo::supportsWriting() const
00093 {
00094 return m_Writing;
00095 }
00096 bool KonqPopupMenu::ProtocolInfo::supportsDeleting() const
00097 {
00098 return m_Deleting;
00099 }
00100 bool KonqPopupMenu::ProtocolInfo::supportsMoving() const
00101 {
00102 return m_Moving;
00103 }
00104 bool KonqPopupMenu::ProtocolInfo::trashIncluded() const
00105 {
00106 return m_TrashIncluded;
00107 }
00108
00109 KonqPopupMenu::KonqPopupMenu( KBookmarkManager *mgr, const KFileItemList &items,
00110 KURL viewURL,
00111 KActionCollection & actions,
00112 KNewMenu * newMenu,
00113 bool showPropertiesAndFileType )
00114 : QPopupMenu( 0L, "konq_popupmenu" ), m_actions( actions ), m_ownActions( static_cast<QObject *>( 0 ), "KonqPopupMenu::m_ownActions" ),
00115 m_pMenuNew( newMenu ), m_sViewURL(viewURL), m_lstItems(items), m_pManager(mgr)
00116 {
00117 d = new KonqPopupMenuPrivate;
00118 setup(showPropertiesAndFileType);
00119 }
00120
00121 KonqPopupMenu::KonqPopupMenu( KBookmarkManager *mgr, const KFileItemList &items,
00122 KURL viewURL,
00123 KActionCollection & actions,
00124 KNewMenu * newMenu,
00125 QWidget * parentWidget,
00126 bool showPropertiesAndFileType )
00127 : QPopupMenu( 0L, "konq_popupmenu" ), m_actions( actions ), m_ownActions( static_cast<QObject *>( 0 ), "KonqPopupMenu::m_ownActions" ),
00128 m_pMenuNew( newMenu ), m_sViewURL(viewURL), m_lstItems(items), m_pManager(mgr)
00129 {
00130 d = new KonqPopupMenuPrivate;
00131 d->m_parentWidget = parentWidget;
00132 setup(showPropertiesAndFileType);
00133 }
00134
00135 void KonqPopupMenu::setup(bool showPropertiesAndFileType)
00136 {
00137 assert( m_lstItems.count() >= 1 );
00138
00139 m_ownActions.setWidget( this );
00140
00141 bool currentDir = false;
00142 bool sReading = true;
00143 bool sWriting = true;
00144 bool sDeleting = true;
00145 bool sMoving = true;
00146 m_sMimeType = m_lstItems.first()->mimetype();
00147 mode_t mode = m_lstItems.first()->mode();
00148 bool bTrashIncluded = false;
00149 bool bCanChangeSharing = false;
00150 m_lstPopupURLs.clear();
00151 int id = 0;
00152 if( m_sMimeType=="inode/directory" && m_lstItems.first()->isLocalFile())
00153 bCanChangeSharing=true;
00154 setFont(KGlobalSettings::menuFont());
00155 m_pluginList.setAutoDelete( true );
00156 m_ownActions.setHighlightingEnabled( true );
00157
00158 attrName = QString::fromLatin1( "name" );
00159
00160 prepareXMLGUIStuff();
00161 m_builder = new KonqPopupMenuGUIBuilder( this );
00162 m_factory = new KXMLGUIFactory( m_builder );
00163
00164 KURL url;
00165 KFileItemListIterator it ( m_lstItems );
00166
00167 for ( ; it.current(); ++it )
00168 {
00169 url = (*it)->url();
00170
00171
00172 m_lstPopupURLs.append( url );
00173
00174
00175 if ( mode != (*it)->mode() )
00176 mode = 0;
00177
00178
00179 if ( m_sMimeType != (*it)->mimetype() )
00180 m_sMimeType = QString::null;
00181
00182 if ( !bTrashIncluded &&
00183 (*it)->url().isLocalFile() &&
00184 (*it)->url().path( 1 ) == KGlobalSettings::trashPath() )
00185 bTrashIncluded = true;
00186
00187 if ( sReading )
00188 sReading = KProtocolInfo::supportsReading( url );
00189
00190 if ( sWriting )
00191 sWriting = KProtocolInfo::supportsWriting( url );
00192
00193 if ( sDeleting )
00194 sDeleting = KProtocolInfo::supportsDeleting( url );
00195
00196 if ( sMoving )
00197 sMoving = KProtocolInfo::supportsMoving( url );
00198 }
00199
00200 if ( bTrashIncluded )
00201 {
00202 sMoving = false;
00203 sDeleting = false;
00204 }
00205
00206 url = m_sViewURL;
00207 url.cleanPath();
00208
00209 m_info.m_Reading = sReading;
00210 m_info.m_Writing = sWriting;
00211 m_info.m_Deleting = sDeleting;
00212 m_info.m_Moving = sMoving;
00213 m_info.m_TrashIncluded = bTrashIncluded;
00214
00215 bool isCurrentTrash = ( url.isLocalFile() &&
00216 url.path(1) == KGlobalSettings::trashPath() );
00217
00218
00219 if ( m_lstItems.count() == 1 )
00220 {
00221 KURL firstPopupURL ( m_lstItems.first()->url() );
00222 firstPopupURL.cleanPath();
00223
00224
00225 currentDir = firstPopupURL.cmp( url, true );
00226 }
00227
00228 clear();
00229
00231
00232 KAction * act;
00233
00234 addMerge( "konqueror" );
00235
00236 bool isKDesktop = QCString( kapp->name() ) == "kdesktop";
00237 QString openStr = isKDesktop ? i18n( "&Open" ) : i18n( "Open in New &Window" );
00238 KAction *actNewView = new KAction( openStr, "window_new", 0, this, SLOT( slotPopupNewView() ), &m_ownActions, "newview" );
00239 if ( !isKDesktop )
00240 actNewView->setStatusText( i18n( "Open the document in a new window" ) );
00241
00242 if ( ( isCurrentTrash && currentDir ) ||
00243 ( m_lstItems.count() == 1 && bTrashIncluded ) )
00244 {
00245 addAction( actNewView );
00246 addGroup( "tabhandling" );
00247 addSeparator();
00248
00249 act = new KAction( i18n( "&Empty Trash Bin" ), 0, this, SLOT( slotPopupEmptyTrashBin() ), &m_ownActions, "empytrash" );
00250 addAction( act );
00251 }
00252 else
00253 {
00254 if ( S_ISDIR(mode) && sWriting )
00255 {
00256 if ( currentDir && m_pMenuNew )
00257 {
00258
00259 m_pMenuNew->slotCheckUpToDate();
00260 m_pMenuNew->setPopupFiles( m_lstPopupURLs );
00261
00262 addAction( m_pMenuNew );
00263
00264 addSeparator();
00265 }
00266 else
00267 {
00268 KAction *actNewDir = new KAction( i18n( "Create Director&y..." ), "folder_new", 0, this, SLOT( slotPopupNewDir() ), &m_ownActions, "newdir" );
00269 addAction( actNewDir );
00270 addSeparator();
00271 }
00272 }
00273
00274
00275 bool httpPage = (m_sViewURL.protocol().find("http", 0, false) == 0);
00276
00277 if ( currentDir || httpPage )
00278 {
00279 addAction( "up" );
00280 addAction( "back" );
00281 addAction( "forward" );
00282 if ( currentDir )
00283 addAction( "reload" );
00284 addGroup( "reload" );
00285 addSeparator();
00286 }
00287
00288
00289 addAction( actNewView );
00290 addGroup( "tabhandling" );
00291 bool separatorAdded = false;
00292
00293 if ( !currentDir && sReading ) {
00294 addSeparator();
00295 separatorAdded = true;
00296 if ( sDeleting ) {
00297 addAction( "undo" );
00298 addAction( "cut" );
00299 }
00300 addAction( "copy" );
00301 }
00302
00303 if ( S_ISDIR(mode) && sWriting ) {
00304 if ( !separatorAdded )
00305 addSeparator();
00306 if ( currentDir )
00307 addAction( "paste" );
00308 else
00309 addAction( "pasteto" );
00310 }
00311
00312
00313
00314 addGroup( "find" );
00315
00316 if (!currentDir)
00317 {
00318 if ( sReading || sWriting )
00319 addSeparator();
00320
00321 if ( m_lstItems.count() == 1 && sWriting )
00322 addAction("rename");
00323
00324 if ( sMoving )
00325 addAction( "trash" );
00326
00327 if ( sDeleting ) {
00328 addAction( "del" );
00329
00330
00331 }
00332 }
00333 }
00334
00335 act = new KAction( i18n( "&Add to Bookmarks" ), "bookmark_add", 0, this, SLOT( slotPopupAddToBookmark() ), &m_ownActions, "bookmark_add" );
00336 if (kapp->authorizeKAction("bookmarks"))
00337 addAction( act );
00338
00340
00341 QValueList<KDEDesktopMimeType::Service> builtin;
00342 QValueList<KDEDesktopMimeType::Service> user;
00343
00344
00345 if ( m_sMimeType == "application/x-desktop" && m_lstItems.count() == 1 && m_lstItems.first()->url().isLocalFile() )
00346 {
00347
00348 builtin = KDEDesktopMimeType::builtinServices( m_lstItems.first()->url() );
00349 user = KDEDesktopMimeType::userDefinedServices( m_lstItems.first()->url().path(), url.isLocalFile() );
00350 }
00351
00352
00353 QStringList dirs = KGlobal::dirs()->findDirs( "data", "konqueror/servicemenus/" );
00354 QStringList::ConstIterator dIt = dirs.begin();
00355 QStringList::ConstIterator dEnd = dirs.end();
00356
00357 for (; dIt != dEnd; ++dIt )
00358 {
00359 QDir dir( *dIt );
00360
00361 QStringList entries = dir.entryList( QDir::Files );
00362 QStringList::ConstIterator eIt = entries.begin();
00363 QStringList::ConstIterator eEnd = entries.end();
00364
00365 for (; eIt != eEnd; ++eIt )
00366 {
00367 KSimpleConfig cfg( *dIt + *eIt, true );
00368
00369 cfg.setDesktopGroup();
00370
00371 if ( cfg.hasKey( "X-KDE-AuthorizeAction") )
00372 {
00373 bool ok = true;
00374 QStringList list = cfg.readListEntry("X-KDE-AuthorizeAction");
00375 if (kapp && !list.isEmpty())
00376 {
00377 for(QStringList::ConstIterator it = list.begin();
00378 it != list.end();
00379 ++it)
00380 {
00381 if (!kapp->authorize((*it).stripWhiteSpace()))
00382 {
00383 ok = false;
00384 break;
00385 }
00386 }
00387 }
00388 if (!ok)
00389 continue;
00390 }
00391
00392 if ( cfg.hasKey( "Actions" ) && cfg.hasKey( "ServiceTypes" ) )
00393 {
00394 QStringList types = cfg.readListEntry( "ServiceTypes" );
00395 bool ok = !m_sMimeType.isNull() && types.contains( m_sMimeType );
00396 if ( !ok ) {
00397 ok = (types[0] == "all/all" ||
00398 types[0] == "allfiles" );
00399 if ( !ok && types[0] == "all/allfiles" )
00400 {
00401 ok = (m_sMimeType != "inode/directory");
00402 }
00403 }
00404 if ( ok )
00405 {
00406 user += KDEDesktopMimeType::userDefinedServices( *dIt + *eIt, url.isLocalFile() );
00407 }
00408 }
00409 }
00410 }
00411
00412 KTrader::OfferList offers;
00413
00414 if (kapp->authorizeKAction("openwith"))
00415 {
00416
00417
00418 offers = KTrader::self()->query( m_sMimeType.isNull( ) ? QString::fromLatin1( "all/all" ) : m_sMimeType ,
00419 "Type == 'Application' and DesktopEntryName != 'kfmclient' and DesktopEntryName != 'kfmclient_dir' and DesktopEntryName != 'kfmclient_html'" );
00420 }
00421
00423
00424 m_mapPopup.clear();
00425 m_mapPopupServices.clear();
00426
00427 if ( !offers.isEmpty() )
00428 {
00429
00430 addSeparator();
00431
00432 id = 1;
00433
00434 QDomElement menu = m_menuElement;
00435
00436 if ( offers.count() > 1 )
00437 {
00438 menu = m_doc.createElement( "menu" );
00439 menu.setAttribute( "name", "openwith submenu" );
00440 m_menuElement.appendChild( menu );
00441 QDomElement text = m_doc.createElement( "text" );
00442 menu.appendChild( text );
00443 text.appendChild( m_doc.createTextNode( i18n("&Open With") ) );
00444 }
00445
00446 if ( menu == m_menuElement )
00447 {
00448 KAction *openWithAct = new KAction( i18n( "&Open With..." ), 0, this, SLOT( slotPopupOpenWith() ), &m_ownActions, "openwith" );
00449 addAction( openWithAct, menu );
00450 }
00451
00452 KTrader::OfferList::ConstIterator it = offers.begin();
00453 for( ; it != offers.end(); it++ )
00454 {
00455 QCString nam;
00456 nam.setNum( id );
00457
00458 act = new KAction( (*it)->name(), (*it)->pixmap( KIcon::Small ), 0,
00459 this, SLOT( slotRunService() ),
00460 &m_ownActions, nam.prepend( "appservice_" ) );
00461 addAction( act, menu );
00462
00463 m_mapPopup[ id++ ] = *it;
00464 }
00465
00466 if ( menu != m_menuElement )
00467 {
00468 addSeparator( menu );
00469 KAction *openWithAct = new KAction( i18n( "&Other..." ), 0, this, SLOT( slotPopupOpenWith() ), &m_ownActions, "openwith" );
00470 addAction( openWithAct, menu );
00471 }
00472 }
00473 else
00474 {
00475 addSeparator();
00476 act = new KAction( i18n( "Open With..." ), 0, this, SLOT( slotPopupOpenWith() ), &m_ownActions, "openwith" );
00477 addAction( act );
00478 }
00479
00480 addGroup( "preview" );
00481
00482 addSeparator();
00483
00484
00485 if ( !user.isEmpty() || !builtin.isEmpty() )
00486 {
00487 bool insertedOffer = false;
00488
00489 QValueList<KDEDesktopMimeType::Service>::Iterator it2 = user.begin();
00490 for( ; it2 != user.end(); ++it2 )
00491 {
00492 if ((*it2).m_display == true)
00493 {
00494 QCString nam;
00495 nam.setNum( id );
00496 act = new KAction( (*it2).m_strName, 0, this, SLOT( slotRunService() ), &m_ownActions, nam.prepend( "userservice_" ) );
00497
00498 if ( !(*it2).m_strIcon.isEmpty() )
00499 {
00500 QPixmap pix = SmallIcon( (*it2).m_strIcon );
00501 act->setIconSet( pix );
00502 }
00503
00504 addAction( act, m_menuElement );
00505
00506 m_mapPopupServices[ id++ ] = *it2;
00507 insertedOffer = true;
00508 }
00509 }
00510
00511 it2 = builtin.begin();
00512 for( ; it2 != builtin.end(); ++it2 )
00513 {
00514 QCString nam;
00515 nam.setNum( id );
00516
00517 act = new KAction( (*it2).m_strName, 0, this, SLOT( slotRunService() ), &m_ownActions, nam.prepend( "builtinservice_" ) );
00518
00519 if ( !(*it2).m_strIcon.isEmpty() )
00520 {
00521 QPixmap pix = SmallIcon( (*it2).m_strIcon );
00522 act->setIconSet( pix );
00523 }
00524
00525 addAction( act, m_menuElement );
00526
00527 m_mapPopupServices[ id++ ] = *it2;
00528 insertedOffer = true;
00529 }
00530
00531 if ( insertedOffer )
00532 addSeparator();
00533 }
00534 addPlugins( );
00535
00536 if ( !m_sMimeType.isEmpty() && showPropertiesAndFileType )
00537 {
00538 act = new KAction( i18n( "&Edit File Type..." ), 0, this, SLOT( slotPopupMimeType() ),
00539 &m_ownActions, "editfiletype" );
00540 addAction( act );
00541 }
00542
00543 if ( KPropertiesDialog::canDisplay( m_lstItems ) && showPropertiesAndFileType )
00544 {
00545 act = new KAction( i18n( "&Properties" ), 0, this, SLOT( slotPopupProperties() ),
00546 &m_ownActions, "properties" );
00547 addAction( act );
00548 }
00549
00550 while ( !m_menuElement.lastChild().isNull() &&
00551 m_menuElement.lastChild().toElement().tagName().lower() == "separator" )
00552 m_menuElement.removeChild( m_menuElement.lastChild() );
00553
00554 if( bCanChangeSharing)
00555 {
00556 if(KFileShare::authorization()==KFileShare::Authorized)
00557 {
00558 addSeparator();
00559 QString label;
00560 label=i18n("Share");
00561
00562 act = new KAction( label, 0, this, SLOT( slotOpenShareFileDialog() ),
00563 &m_ownActions, "sharefile" );
00564 addAction( act );
00565 }
00566 }
00567
00568
00569 addMerge( 0 );
00570
00571 m_factory->addClient( this );
00572 }
00573
00574 void KonqPopupMenu::slotOpenShareFileDialog()
00575 {
00576
00577
00578
00579
00580
00581 if ( m_lstItems.count() == 1 )
00582 {
00583 KFileItem * item = m_lstItems.first();
00584 if (item->entry().count() == 0)
00585 {
00586
00587 KPropertiesDialog*dlg= new KPropertiesDialog( item->url(), d->m_parentWidget );
00588 dlg->showFileSharingPage();
00589
00590 return;
00591 }
00592 }
00593 KPropertiesDialog*dlg=new KPropertiesDialog( m_lstItems, d->m_parentWidget );
00594 dlg->showFileSharingPage();
00595 }
00596
00597 KonqPopupMenu::~KonqPopupMenu()
00598 {
00599 m_pluginList.clear();
00600 delete m_factory;
00601 delete m_builder;
00602 delete d;
00603 kdDebug(1203) << "~KonqPopupMenu leave" << endl;
00604 }
00605
00606 void KonqPopupMenu::setURLTitle( const QString& urlTitle )
00607 {
00608 d->m_urlTitle = urlTitle;
00609 }
00610
00611 void KonqPopupMenu::slotPopupNewView()
00612 {
00613 KURL::List::ConstIterator it = m_lstPopupURLs.begin();
00614 for ( ; it != m_lstPopupURLs.end(); it++ )
00615 (void) new KRun(*it);
00616 }
00617
00618 void KonqPopupMenu::slotPopupNewDir()
00619 {
00620 KLineEditDlg l( i18n("Enter directory name:"), i18n("Directory"), d->m_parentWidget );
00621 l.setCaption(i18n("New Directory"));
00622 if ( l.exec() )
00623 {
00624 QString name = KIO::encodeFileName( l.text() );
00625 KURL::List::ConstIterator it = m_lstPopupURLs.begin();
00626 for ( ; it != m_lstPopupURLs.end(); it++ )
00627 {
00628 KURL url(*it);
00629 url.addPath( name );
00630 kdDebug() << "KonqPopupMenu::slotPopupNewDir creating dir " << url.url() << endl;
00631 KonqOperations::mkdir( 0L, url );
00632 }
00633 }
00634 }
00635
00636 void KonqPopupMenu::slotPopupEmptyTrashBin()
00637 {
00638 KonqOperations::emptyTrash();
00639 }
00640
00641 void KonqPopupMenu::slotPopupOpenWith()
00642 {
00643 KRun::displayOpenWithDialog( m_lstPopupURLs );
00644 }
00645
00646 void KonqPopupMenu::slotPopupAddToBookmark()
00647 {
00648 KBookmarkGroup root = m_pManager->root();
00649 if ( m_lstPopupURLs.count() == 1 ) {
00650 KURL url = m_lstPopupURLs.first();
00651 QString title = d->m_urlTitle.isEmpty() ? url.prettyURL() : d->m_urlTitle;
00652 root.addBookmark( m_pManager, title, url.url() );
00653 }
00654 else
00655 {
00656 KURL::List::ConstIterator it = m_lstPopupURLs.begin();
00657 for ( ; it != m_lstPopupURLs.end(); it++ )
00658 root.addBookmark( m_pManager, (*it).prettyURL(), (*it).url() );
00659 }
00660 m_pManager->emitChanged( root );
00661 }
00662
00663 void KonqPopupMenu::slotRunService()
00664 {
00665 QCString senderName = sender()->name();
00666 int id = senderName.mid( senderName.find( '_' ) + 1 ).toInt();
00667
00668
00669 QMap<int,KService::Ptr>::Iterator it = m_mapPopup.find( id );
00670 if ( it != m_mapPopup.end() )
00671 {
00672 KRun::run( **it, m_lstPopupURLs );
00673 return;
00674 }
00675
00676
00677 QMap<int,KDEDesktopMimeType::Service>::Iterator it2 = m_mapPopupServices.find( id );
00678 if ( it2 != m_mapPopupServices.end() )
00679 {
00680 KDEDesktopMimeType::executeService( m_lstPopupURLs, it2.data() );
00681 }
00682
00683 return;
00684 }
00685
00686 void KonqPopupMenu::slotPopupMimeType()
00687 {
00688 KonqOperations::editMimeType( m_sMimeType );
00689 }
00690
00691 void KonqPopupMenu::slotPopupProperties()
00692 {
00693
00694
00695
00696
00697 if ( m_lstItems.count() == 1 )
00698 {
00699 KFileItem * item = m_lstItems.first();
00700 if (item->entry().count() == 0)
00701 {
00702
00703 (void) new KPropertiesDialog( item->url(), d->m_parentWidget );
00704 return;
00705 }
00706 }
00707 (void) new KPropertiesDialog( m_lstItems, d->m_parentWidget );
00708 }
00709
00710 KAction *KonqPopupMenu::action( const QDomElement &element ) const
00711 {
00712 QCString name = element.attribute( attrName ).ascii();
00713
00714 KAction *res = m_ownActions.action( name );
00715
00716 if ( !res )
00717 res = m_actions.action( name );
00718
00719 if ( !res && m_pMenuNew && strcmp( name, m_pMenuNew->name() ) == 0 )
00720 return m_pMenuNew;
00721
00722 return res;
00723 }
00724 KActionCollection *KonqPopupMenu::actionCollection() const
00725 {
00726 return const_cast<KActionCollection *>( &m_ownActions );
00727 }
00728
00729 QString KonqPopupMenu::mimeType( ) const {
00730 return m_sMimeType;
00731 }
00732 KonqPopupMenu::ProtocolInfo KonqPopupMenu::protocolInfo() const
00733 {
00734 return m_info;
00735 }
00736 void KonqPopupMenu::addPlugins( ){
00737
00738
00739 KTrader::OfferList plugin_offers;
00740 unsigned int pluginCount = 0;
00741 plugin_offers = KTrader::self()->query( m_sMimeType.isNull() ? QString::fromLatin1( "all/all" ) : m_sMimeType , "'KonqPopupMenu/Plugin' in ServiceTypes");
00742 if ( plugin_offers.isEmpty() )
00743 return;
00744
00745 KTrader::OfferList::ConstIterator iterator = plugin_offers.begin( );
00746 KTrader::OfferList::ConstIterator end = plugin_offers.end( );
00747
00748 addGroup( "plugins" );
00749
00750 for(; iterator != end; ++iterator, ++pluginCount ){
00751 KonqPopupMenuPlugin *plugin =
00752 KParts::ComponentFactory::
00753 createInstanceFromLibrary<KonqPopupMenuPlugin>( (*iterator)->library().local8Bit(),
00754 this,
00755 (*iterator)->name().latin1() );
00756 if ( !plugin )
00757 continue;
00758 QString pluginClientName = QString::fromLatin1( "Plugin%1" ).arg( pluginCount );
00759 addMerge( pluginClientName );
00760 plugin->domDocument().documentElement().setAttribute( "name", pluginClientName );
00761 m_pluginList.append( plugin );
00762 insertChildClient( plugin );
00763 }
00764
00765 addMerge( "plugins" );
00766 addSeparator();
00767 }
00768 KURL KonqPopupMenu::url( ) const {
00769 return m_sViewURL;
00770 }
00771 KFileItemList KonqPopupMenu::fileItemList( ) const {
00772 return m_lstItems;
00773 }
00774 KURL::List KonqPopupMenu::popupURLList( ) const {
00775 return m_lstPopupURLs;
00776 }
00781 KonqPopupMenuPlugin::KonqPopupMenuPlugin( KonqPopupMenu *parent, const char *name )
00782 : QObject( parent, name ) {
00783 }
00784 KonqPopupMenuPlugin::~KonqPopupMenuPlugin( ){
00785
00786 }
00787 #include "konq_popupmenu.moc"