Make a branch to make krunner Good Enough For Aaron™.
[kdebase/uwolfer.git] / apps / lib / konq / konq_popupmenu.cpp
blob5e2f980e052eaf269e169d82ba175a35a5dc5c04
1 /* This file is part of the KDE project
2 Copyright (C) 1998-2006 David Faure <faure@kde.org>
3 Copyright (C) 2001 Holger Freyther <freyther@yahoo.com>
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
21 #include "konq_popupmenu.h"
22 #include "konq_menuactions.h"
23 #include "kpropertiesdialog.h"
24 #include "knewmenu.h"
25 #include "konq_operations.h"
27 #include <klocale.h>
28 #include <kbookmarkmanager.h>
29 #include <kbookmarkdialog.h>
30 #include <kdebug.h>
31 #include <krun.h>
32 #include <kprotocolmanager.h>
33 #include <kicon.h>
34 #include <kiconloader.h>
35 #include <kinputdialog.h>
36 #include <kglobalsettings.h>
37 #include <kmimetypetrader.h>
38 #include <kstandarddirs.h>
39 #include <kconfiggroup.h>
40 #include <kdesktopfile.h>
41 #include <kfileshare.h>
42 #include <kauthorized.h>
43 #include <kglobal.h>
45 #include <QDir>
46 #include <QApplication>
47 #include <QPixmap>
50 Test cases:
51 iconview file: background
52 iconview file: file (with and without servicemenus)
53 iconview file: directory
54 iconview remote protocol (e.g. ftp: or fish:)
55 iconview trash:/
56 sidebar directory tree
57 sidebar Devices / Hard Disc
58 khtml background
59 khtml link
60 khtml image (www.kde.org RMB on K logo)
61 khtmlimage (same as above, then choose View image, then RMB)
62 selected text in khtml
63 embedded katepart
64 kdesktop folder
65 trash link on desktop
66 trashed file or directory
67 application .desktop file
68 Then the same after uninstalling kdeaddons/konq-plugins (kuick and arkplugin in particular)
71 class KonqPopupMenuPrivate
73 public:
74 KonqPopupMenuPrivate(KonqPopupMenu* qq, KActionCollection & actions)
75 : q(qq),
76 m_parentWidget(0),
77 m_itemFlags(KParts::BrowserExtension::DefaultPopupItems),
78 m_actions(actions),
79 m_ownActions(static_cast<QWidget *>(0)),
80 m_runServiceActionGroup(q)
83 void addNamedAction(const QString& name);
84 void addGroup(const QString& name);
85 void addPlugins();
86 void setup(KonqPopupMenu::Flags kpf);
88 void slotPopupNewDir();
89 void slotPopupNewView();
90 void slotPopupEmptyTrashBin();
91 void slotPopupRestoreTrashedItems();
92 void slotPopupOpenWith();
93 void slotPopupAddToBookmark();
94 void slotRunService(QAction*);
95 void slotPopupMimeType();
96 void slotPopupProperties();
97 void slotOpenShareFileDialog();
99 KonqPopupMenu* q;
100 QString m_urlTitle;
101 QWidget *m_parentWidget;
102 KParts::BrowserExtension::PopupFlags m_itemFlags;
103 KNewMenu *m_pMenuNew;
104 KUrl m_sViewURL;
105 QString m_sMimeType;
106 KFileItemList m_lstItems;
107 KUrl::List m_lstPopupURLs;
108 QMap<QAction*,KService::Ptr> m_mapPopup;
109 KonqMenuActions m_menuActions;
110 bool m_bHandleEditOperations;
111 QString m_attrName;
112 // KonqPopupMenu::ProtocolInfo m_info;
113 KBookmarkManager* m_bookmarkManager;
114 KActionCollection &m_actions;
115 KActionCollection m_ownActions; // TODO connect to statusbar for help on actions
116 QActionGroup m_runServiceActionGroup;
117 KParts::BrowserExtension::ActionGroupMap m_actionGroups;
120 #if 0
121 KonqPopupMenu::ProtocolInfo::ProtocolInfo()
123 m_Reading = false;
124 m_Writing = false;
125 m_Deleting = false;
126 m_Moving = false;
127 m_TrashIncluded = false;
130 bool KonqPopupMenu::ProtocolInfo::supportsReading() const
132 return m_Reading;
135 bool KonqPopupMenu::ProtocolInfo::supportsWriting() const
137 return m_Writing;
140 bool KonqPopupMenu::ProtocolInfo::supportsDeleting() const
142 return m_Deleting;
145 bool KonqPopupMenu::ProtocolInfo::supportsMoving() const
147 return m_Moving;
150 bool KonqPopupMenu::ProtocolInfo::trashIncluded() const
152 return m_TrashIncluded;
154 #endif
156 //////////////////
158 KonqPopupMenu::KonqPopupMenu(const KFileItemList &items,
159 const KUrl& viewURL,
160 KActionCollection & actions,
161 KNewMenu * newMenu,
162 Flags kpf,
163 KParts::BrowserExtension::PopupFlags flags,
164 QWidget * parentWidget,
165 KBookmarkManager *mgr,
166 const KParts::BrowserExtension::ActionGroupMap& actionGroups)
167 : QMenu( parentWidget ),
168 d(new KonqPopupMenuPrivate(this, actions))
170 d->m_actionGroups = actionGroups;
171 d->m_pMenuNew = newMenu;
172 d->m_sViewURL = viewURL;
173 d->m_lstItems = items;
174 d->m_bookmarkManager = mgr;
175 init(parentWidget, kpf, flags);
178 void KonqPopupMenu::init (QWidget * parentWidget, Flags kpf, KParts::BrowserExtension::PopupFlags flags)
180 d->m_ownActions.setObjectName("KonqPopupMenu::m_ownActions");
181 d->m_parentWidget = parentWidget;
182 d->m_itemFlags = flags;
183 setFont(KGlobalSettings::menuFont());
184 QObject::connect(&d->m_runServiceActionGroup, SIGNAL(triggered(QAction*)),
185 this, SLOT(slotRunService(QAction*)));
186 d->setup(kpf);
189 void KonqPopupMenuPrivate::addNamedAction(const QString& name)
191 QAction* act = m_actions.action(name);
192 if (act)
193 q->addAction(act);
196 void KonqPopupMenuPrivate::setup(KonqPopupMenu::Flags kpf)
198 Q_ASSERT( m_lstItems.count() >= 1 );
200 const bool bIsLink = (m_itemFlags & KParts::BrowserExtension::IsLink);
201 bool currentDir = false;
202 bool sReading = true;
203 bool sDeleting = (m_itemFlags & KParts::BrowserExtension::NoDeletion) == 0;
204 bool sMoving = sDeleting;
205 bool sWriting = sDeleting && m_lstItems.first().isWritable();
206 m_sMimeType = m_lstItems.first().mimetype();
207 QString mimeGroup = m_sMimeType.left(m_sMimeType.indexOf('/'));
208 mode_t mode = m_lstItems.first().mode();
209 bool bTrashIncluded = false;
210 bool mediaFiles = false;
211 bool isLocal = m_lstItems.first().isLocalFile()
212 || m_lstItems.first().url().protocol()=="media"
213 || m_lstItems.first().url().protocol()=="system";
214 bool isTrashLink = false;
215 m_lstPopupURLs.clear();
216 int id = 0;
218 m_attrName = QLatin1String( "name" );
220 KUrl url;
221 KFileItemList::const_iterator it = m_lstItems.begin();
222 const KFileItemList::const_iterator kend = m_lstItems.end();
223 QStringList mimeTypeList;
224 for ( ; it != kend; ++it )
226 url = (*it).url();
228 // Build the list of URLs
229 m_lstPopupURLs.append( url );
231 // Determine if common mode among all URLs
232 if ( mode != (*it).mode() )
233 mode = 0; // modes are different => reset to 0
235 // Determine if common mimetype among all URLs
236 if ( m_sMimeType != (*it).mimetype() )
238 m_sMimeType.clear(); // mimetypes are different => null
240 if ( mimeGroup != (*it).mimetype().left((*it).mimetype().indexOf('/')))
241 mimeGroup.clear(); // mimetype groups are different as well!
244 if ( mimeTypeList.indexOf( (*it).mimetype() ) == -1 )
245 mimeTypeList << (*it).mimetype();
247 if ( isLocal && !url.isLocalFile() && url.protocol() != "media" && url.protocol() != "system" )
248 isLocal = false;
250 if ( !bTrashIncluded && (
251 ( url.protocol() == "trash" && url.path().length() <= 1 )
252 || url.url() == "system:/trash" || url.url() == "system:/trash/" ) ) {
253 bTrashIncluded = true;
254 isLocal = false;
257 if ( sReading )
258 sReading = KProtocolManager::supportsReading( url );
260 if ( sWriting )
261 sWriting = KProtocolManager::supportsWriting( url ) && (*it).isWritable();
263 if ( sDeleting )
264 sDeleting = KProtocolManager::supportsDeleting( url );
266 if ( sMoving )
267 sMoving = KProtocolManager::supportsMoving( url );
268 if ( (*it).mimetype().startsWith("media/") )
269 mediaFiles = true;
271 const bool isDirectory = S_ISDIR(mode);
272 url = m_sViewURL;
273 url.cleanPath();
275 //check if url is current directory
276 if ( m_lstItems.count() == 1 )
278 KUrl firstPopupURL( m_lstItems.first().url() );
279 firstPopupURL.cleanPath();
280 //kDebug(1203) << "View path is " << url.url();
281 //kDebug(1203) << "First popup path is " << firstPopupURL.url();
282 currentDir = firstPopupURL.equals( url, KUrl::CompareWithoutTrailingSlash );
283 if ( isLocal && m_sMimeType == "application/x-desktop" ) {
284 KDesktopFile desktopFile( firstPopupURL.path() );
285 const KConfigGroup cfg = desktopFile.desktopGroup();
286 isTrashLink = ( cfg.readEntry("Type") == "Link" && cfg.readEntry("URL") == "trash:/" );
289 if ( isTrashLink ) {
290 sDeleting = false;
294 #if 0
295 m_info.m_Reading = sReading;
296 m_info.m_Writing = sWriting;
297 m_info.m_Deleting = sDeleting;
298 m_info.m_Moving = sMoving;
299 m_info.m_TrashIncluded = bTrashIncluded;
300 #endif
302 // isCurrentTrash: popup on trash:/ itself, or on the trash.desktop link
303 bool isCurrentTrash = ( m_lstItems.count() == 1 && bTrashIncluded ) || isTrashLink;
304 bool isIntoTrash = ( url.protocol() == "trash" || url.url().startsWith( "system:/trash" ) ) && !isCurrentTrash; // trashed file, not trash:/ itself
305 //kDebug() << "isLocal=" << isLocal << " url=" << url << " isCurrentTrash=" << isCurrentTrash << " isIntoTrash=" << isIntoTrash << " bTrashIncluded=" << bTrashIncluded;
306 bool isSingleMedium = m_lstItems.count() == 1 && mediaFiles;
308 //////////////////////////////////////////////////////////////////////////
310 addGroup( "topactions" ); // used e.g. for ShowMenuBar. includes a separator at the end
312 QAction * act;
314 bool isKDesktop = false; //QByteArray( kapp->objectName().toUtf8() ) == "kdesktop";
315 QAction *actNewWindow = 0;
317 #if 0
318 if (( flags & KParts::BrowserExtension::ShowProperties ) && isKDesktop &&
319 !KAuthorized::authorizeKAction("editable_desktop_icons"))
321 flags &= ~KParts::BrowserExtension::ShowProperties; // remove flag
323 #endif
325 // Either 'newview' is in the actions we're given (probably in the tabhandling group)
326 // or we need to insert it ourselves (e.g. for kdesktop). In the first case, actNewWindow must remain 0.
327 if ( ((kpf & KonqPopupMenu::ShowNewWindow) != 0) && sReading )
329 QString openStr = isKDesktop ? i18n( "&Open" ) : i18n( "Open in New &Window" );
330 actNewWindow = m_ownActions.addAction( "newview" );
331 actNewWindow->setIcon( KIcon("window-new") );
332 actNewWindow->setText( openStr );
333 QObject::connect(actNewWindow, SIGNAL(triggered()), q, SLOT(slotPopupNewView()));
336 if ( actNewWindow && !isKDesktop )
338 if (isCurrentTrash)
339 actNewWindow->setToolTip( i18n( "Open the trash in a new window" ) );
340 else if (isSingleMedium)
341 actNewWindow->setToolTip( i18n( "Open the medium in a new window") );
342 else
343 actNewWindow->setToolTip( i18n( "Open the document in a new window" ) );
346 if ( isDirectory && sWriting && !isCurrentTrash ) // A dir, and we can create things into it
348 if ( currentDir && m_pMenuNew ) // Current dir -> add the "new" menu
350 // As requested by KNewMenu :
351 m_pMenuNew->slotCheckUpToDate();
352 m_pMenuNew->setPopupFiles( m_lstPopupURLs );
354 q->addAction( m_pMenuNew );
355 q->addSeparator();
357 else
359 if (m_itemFlags & KParts::BrowserExtension::ShowCreateDirectory)
361 QAction *actNewDir = m_ownActions.addAction( "newdir" );
362 actNewDir->setIcon( KIcon("folder-new") );
363 actNewDir->setText( i18n( "Create &Folder..." ) );
364 QObject::connect(actNewDir, SIGNAL(triggered()), q, SLOT(slotPopupNewDir()));
365 q->addAction( actNewDir );
366 q->addSeparator();
369 } else if ( isIntoTrash ) {
370 // Trashed item, offer restoring
371 act = m_ownActions.addAction( "restore" );
372 act->setText( i18n( "&Restore" ) );
373 QObject::connect(act, SIGNAL(triggered()), q, SLOT(slotPopupRestoreTrashedItems()));
374 q->addAction(act);
377 if (m_itemFlags & KParts::BrowserExtension::ShowNavigationItems)
379 if (m_itemFlags & KParts::BrowserExtension::ShowUp)
380 addNamedAction( "go_up" );
381 addNamedAction( "go_back" );
382 addNamedAction( "go_forward" );
383 if (m_itemFlags & KParts::BrowserExtension::ShowReload)
384 addNamedAction( "reload" );
385 q->addSeparator();
388 // "open in new window" is either provided by us, or by the tabhandling group
389 if (actNewWindow) {
390 q->addAction(actNewWindow);
391 q->addSeparator();
393 addGroup( "tabhandling" ); // includes a separator at the end
395 if (m_itemFlags & KParts::BrowserExtension::ShowUrlOperations) {
396 if ( !currentDir && sReading ) {
397 if ( sDeleting ) {
398 addNamedAction( "cut" );
400 addNamedAction( "copy" );
403 if ( isDirectory && sWriting ) {
404 if ( currentDir )
405 addNamedAction( "paste" );
406 else
407 addNamedAction( "pasteto" );
410 if ( isCurrentTrash )
412 act = m_ownActions.addAction( "emptytrash" );
413 act->setIcon( KIcon("trash-empty") );
414 act->setText( i18n( "&Empty Trash Bin" ) );
415 KConfig trashConfig( "trashrc", KConfig::SimpleConfig);
416 act->setEnabled( !trashConfig.group("Status").readEntry( "Empty", true ) );
417 QObject::connect(act, SIGNAL(triggered()), q, SLOT(slotPopupEmptyTrashBin()));
418 q->addAction(act);
421 // This is used by KHTML, see khtml_popupmenu.rc (copy, selectAll, searchProvider etc.)
422 // and by DolphinPart (rename, trash, delete)
423 addGroup( "editactions" );
425 if (m_itemFlags & KParts::BrowserExtension::ShowTextSelectionItems) {
426 // OK, we have to stop here.
428 // Anything else that is provided by the part
429 addGroup( "partactions" );
430 return;
433 if ( !isCurrentTrash && !isIntoTrash && (m_itemFlags & KParts::BrowserExtension::ShowBookmark))
435 QString caption;
436 if (currentDir)
438 const bool httpPage = m_sViewURL.protocol().startsWith("http", Qt::CaseInsensitive);
439 if (httpPage)
440 caption = i18n("&Bookmark This Page");
441 else
442 caption = i18n("&Bookmark This Location");
444 else if (isDirectory)
445 caption = i18n("&Bookmark This Folder");
446 else if (bIsLink)
447 caption = i18n("&Bookmark This Link");
448 else
449 caption = i18n("&Bookmark This File");
451 act = m_ownActions.addAction( "bookmark_add" );
452 act->setIcon( KIcon("bookmark-new") );
453 act->setText( caption );
454 QObject::connect(act, SIGNAL(triggered()), q, SLOT(slotPopupAddToBookmark()));
455 if (m_lstItems.count() > 1)
456 act->setEnabled(false);
457 if (KAuthorized::authorizeKAction("bookmarks"))
458 q->addAction( act );
459 if (bIsLink)
460 addGroup( "linkactions" ); // see khtml
463 //////////////////////////////////////////////////////
465 if ( sReading ) {
466 KService::List offers;
467 if (KAuthorized::authorizeKAction("openwith")) {
468 QString constraint = "DesktopEntryName != 'kfmclient' and DesktopEntryName != 'kfmclient_dir' and DesktopEntryName != 'kfmclient_html'";
469 QString subConstraint = " and '%1' in ServiceTypes";
471 QStringList::ConstIterator it = mimeTypeList.begin();
472 QStringList::ConstIterator end = mimeTypeList.end();
473 Q_ASSERT( it != end );
474 QString first = *it;
475 ++it;
476 while ( it != end ) {
477 constraint += subConstraint.arg( *it );
478 ++it;
481 offers = KMimeTypeTrader::self()->query( first, "Application", constraint );
484 //// Ok, we have everything, now insert
486 m_mapPopup.clear();
487 // "Open With..." for folders is really not very useful, especially for remote folders.
488 // (media:/something, or trash:/, or ftp://...)
489 if ( !isDirectory || isLocal ) {
490 if ( !q->actions().isEmpty() )
491 q->addSeparator();
493 if ( !offers.isEmpty() ) {
494 // First block, app and preview offers
495 id = 1;
497 QMenu* menu = q;
499 if ( offers.count() > 1 ) { // submenu 'open with'
500 menu = new QMenu(i18n("&Open With"), q);
501 menu->menuAction()->setObjectName("openWith_submenu"); // for the unittest
502 q->addMenu(menu);
504 kDebug() << offers.count() << "offers" << q << menu;
506 KService::List::ConstIterator it = offers.begin();
507 for( ; it != offers.end(); it++ ) {
508 KService::Ptr service = (*it);
510 // Skip OnlyShowIn=Foo and NotShowIn=KDE entries,
511 // but still offer NoDisplay=true entries, that's the
512 // whole point of such desktop files. This is why we don't
513 // use service->noDisplay() here.
514 const QString onlyShowIn = service->property("OnlyShowIn", QVariant::String).toString();
515 if ( !onlyShowIn.isEmpty() ) {
516 const QStringList aList = onlyShowIn.split(';', QString::SkipEmptyParts);
517 if (!aList.contains("KDE"))
518 continue;
520 const QString notShowIn = service->property("NotShowIn", QVariant::String).toString();
521 if ( !notShowIn.isEmpty() ) {
522 const QStringList aList = notShowIn.split(';', QString::SkipEmptyParts);
523 if (aList.contains("KDE"))
524 continue;
527 QString actionName( service->name().replace( '&', "&&" ) );
528 if ( menu == q ) // no submenu -> prefix single offer
529 actionName = i18n( "Open with %1", actionName );
531 act = new QAction(&m_ownActions);
532 act->setIcon( KIcon( service->icon() ) );
533 act->setText( actionName );
534 m_runServiceActionGroup.addAction(act);
535 menu->addAction(act);
537 m_mapPopup.insert(act, *it);
540 QString openWithActionName;
541 if ( menu != q ) { // submenu
542 menu->addSeparator();
543 openWithActionName = i18n( "&Other..." );
544 } else {
545 openWithActionName = i18n( "&Open With..." );
547 QAction *openWithAct = m_ownActions.addAction( "openwith" );
548 openWithAct->setText( openWithActionName );
549 QObject::connect(openWithAct, SIGNAL(triggered()), q, SLOT(slotPopupOpenWith()));
550 menu->addAction(openWithAct);
552 else // no app offers -> Open With...
554 act = m_ownActions.addAction( "openwith" );
555 act->setText( i18n( "&Open With..." ) );
556 QObject::connect(act, SIGNAL(triggered()), q, SLOT(slotPopupOpenWith()));
557 q->addAction(act);
561 QList<QAction *> previewActions = m_actionGroups.value("preview");
562 if (!previewActions.isEmpty()) {
563 if (previewActions.count() == 1) {
564 q->addAction(previewActions.first());
565 } else {
566 QMenu* subMenu = new QMenu(i18n("Preview In"), q);
567 subMenu->menuAction()->setObjectName("preview_submenu"); // for the unittest
568 q->addMenu(subMenu);
569 subMenu->addActions(previewActions);
574 // Second block, builtin + user
575 m_menuActions.setItems(m_lstItems);
576 if ( m_menuActions.addActionsTo(q) > 0 ) {
577 q->addSeparator();
580 if ( !isCurrentTrash && !isIntoTrash && !mediaFiles && sReading )
581 addPlugins(); // now it's time to add plugins
583 if ( (m_itemFlags & KParts::BrowserExtension::ShowProperties) && KPropertiesDialog::canDisplay( m_lstItems ) ) {
584 act = m_ownActions.addAction( "properties" );
585 act->setText( i18n( "&Properties" ) );
586 QObject::connect(act, SIGNAL(triggered()), q, SLOT(slotPopupProperties()));
587 q->addAction(act);
590 while ( !q->actions().isEmpty() &&
591 q->actions().last()->isSeparator() )
592 delete q->actions().last();
594 if ( isDirectory && isLocal ) {
595 if ( KFileShare::authorization() == KFileShare::Authorized ) {
596 q->addSeparator();
597 act = m_ownActions.addAction( "sharefile" );
598 act->setText( i18n("Share") );
599 QObject::connect(act, SIGNAL(triggered()), q, SLOT(slotOpenShareFileDialog()));
600 q->addAction(act);
604 // Anything else that is provided by the part
605 addGroup( "partactions" );
608 void KonqPopupMenuPrivate::slotOpenShareFileDialog()
610 KPropertiesDialog* dlg = new KPropertiesDialog( m_lstItems, m_parentWidget );
611 dlg->showFileSharingPage();
612 dlg->exec();
615 KonqPopupMenu::~KonqPopupMenu()
617 delete d;
618 //kDebug(1203) << "~KonqPopupMenu leave";
621 void KonqPopupMenu::setURLTitle( const QString& urlTitle )
623 d->m_urlTitle = urlTitle;
626 void KonqPopupMenuPrivate::slotPopupNewView()
628 KUrl::List::ConstIterator it = m_lstPopupURLs.begin();
629 for ( ; it != m_lstPopupURLs.end(); it++ )
630 (void) new KRun(*it, m_parentWidget);
633 void KonqPopupMenuPrivate::slotPopupNewDir()
635 if (m_lstPopupURLs.empty())
636 return;
638 KonqOperations::newDir(m_parentWidget, m_lstPopupURLs.first());
641 void KonqPopupMenuPrivate::slotPopupEmptyTrashBin()
643 KonqOperations::emptyTrash( m_parentWidget );
646 void KonqPopupMenuPrivate::slotPopupRestoreTrashedItems()
648 KonqOperations::restoreTrashedItems( m_lstPopupURLs, m_parentWidget );
651 void KonqPopupMenuPrivate::slotPopupOpenWith()
653 KRun::displayOpenWithDialog( m_lstPopupURLs, m_parentWidget );
656 void KonqPopupMenuPrivate::slotPopupAddToBookmark()
658 KBookmarkGroup root;
659 if ( m_lstPopupURLs.count() == 1 ) {
660 KUrl url = m_lstPopupURLs.first();
661 QString title = m_urlTitle.isEmpty() ? url.prettyUrl() : m_urlTitle;
662 KBookmarkDialog dlg(m_bookmarkManager, m_parentWidget);
663 dlg.addBookmark(title, url.url());
665 else
667 root = m_bookmarkManager->root();
668 KUrl::List::ConstIterator it = m_lstPopupURLs.begin();
669 for ( ; it != m_lstPopupURLs.end(); it++ )
670 root.addBookmark( (*it).prettyUrl(), (*it) );
671 m_bookmarkManager->emitChanged( root );
675 void KonqPopupMenuPrivate::slotRunService(QAction* act)
677 // Is it a usual service (application)
678 QMap<QAction*,KService::Ptr>::Iterator it = m_mapPopup.find(act);
679 if (it != m_mapPopup.end()) {
680 KRun::run(**it, m_lstPopupURLs, m_parentWidget);
684 void KonqPopupMenuPrivate::slotPopupMimeType()
686 KonqOperations::editMimeType( m_sMimeType, m_parentWidget );
689 void KonqPopupMenuPrivate::slotPopupProperties()
691 KPropertiesDialog::showDialog( m_lstItems, m_parentWidget );
694 QString KonqPopupMenu::mimeType() const
696 return d->m_sMimeType;
699 #if 0
700 KonqPopupMenu::ProtocolInfo KonqPopupMenu::protocolInfo() const
702 return d->m_info;
704 #endif
706 void KonqPopupMenuPrivate::addGroup(const QString& name)
708 QList<QAction *> actions = m_actionGroups.value(name);
709 q->addActions(actions);
712 void KonqPopupMenuPrivate::addPlugins()
714 #if 0
715 //search for a plugin with the right protocol
716 KService::List plugin_offers;
717 unsigned int pluginCount = 0;
718 plugin_offers = KMimeTypeTrader::self()->query( m_sMimeType.isNull() ? QLatin1String( "all/all" ) : m_sMimeType, "KonqPopupMenu/Plugin" );
719 if ( plugin_offers.isEmpty() )
720 return; // no plugins installed do not bother about it
722 KService::List::ConstIterator iterator = plugin_offers.begin();
723 const KService::List::ConstIterator end = plugin_offers.end();
725 //addGroup( "plugins" );
726 // travers the offerlist
727 for(; iterator != end; ++iterator, ++pluginCount ) {
728 //kDebug() << (*iterator)->library();
729 KonqPopupMenuPlugin *plugin =
730 KLibLoader::createInstance<KonqPopupMenuPlugin>( QFile::encodeName( (*iterator)->library() ),
731 q );
732 if ( !plugin )
733 continue;
734 plugin->setObjectName( (*iterator)->name() );
735 // This made the kuick plugin insert its items at the right place
736 // ### TODO replace with new mechanism (e.g. addAction(QAction *) in the plugin code),
737 // if plugins are kept
738 QString pluginClientName = QString::fromLatin1( "Plugin%1" ).arg( pluginCount );
739 addMerge( pluginClientName );
740 plugin->domDocument().documentElement().setAttribute( "name", pluginClientName );
741 insertChildClient( plugin );
743 #endif
746 KUrl KonqPopupMenu::url() const // ### should be viewURL()
748 return d->m_sViewURL;
751 KFileItemList KonqPopupMenu::fileItemList() const
753 return d->m_lstItems;
756 KUrl::List KonqPopupMenu::popupURLList() const
758 return d->m_lstPopupURLs;
761 #if 0
763 Plugin
766 KonqPopupMenuPlugin::KonqPopupMenuPlugin( KonqPopupMenu *parent )
767 : QObject( parent )
771 KonqPopupMenuPlugin::~KonqPopupMenuPlugin()
774 #endif
776 #include "konq_popupmenu.moc"