- popup->addAction(renameAction);
-
- // insert 'Move to Trash' and (optionally) 'Delete'
- KConfigGroup kdeConfig(KGlobal::config(), "KDE");
- bool showDeleteCommand = kdeConfig.readEntry("ShowDeleteCommand", false);
- const KUrl& url = m_mainWindow->activeViewContainer()->url();
- if (url.isLocalFile()) {
- QAction* moveToTrashAction = collection->action("move_to_trash");
- popup->addAction(moveToTrashAction);
- } else {
- showDeleteCommand = true;
- }
-
- if (showDeleteCommand) {
- QAction* deleteAction = collection->action("delete");
- popup->addAction(deleteAction);
- }
-}
-
-QList<QAction*> DolphinContextMenu::insertOpenWithItems(KMenu* popup,
- QVector<KService::Ptr>& openWithVector)
-{
- // Parts of the following code have been taken
- // from the class KonqOperations located in
- // libqonq/konq_operations.h of Konqueror.
- // (Copyright (C) 2000 David Faure <faure@kde.org>)
-
- // Prepare 'Open With' sub menu. Usually a sub menu is created, where all applications
- // are listed which are registered to open the item. As last entry "Other..." will be
- // attached which allows to select a custom application. If no applications are registered
- // no sub menu is created at all, only "Open With..." will be offered.
- bool insertOpenWithItems = true;
- const QString contextMimeType(m_fileInfo.mimetype());
-
- QListIterator<KFileItem> mimeIt(m_selectedItems);
- while (insertOpenWithItems && mimeIt.hasNext()) {
- KFileItem item = mimeIt.next();
- insertOpenWithItems = (contextMimeType == item.mimetype());
- }
-
- QList<QAction*> openWithActions;
- if (insertOpenWithItems) {
- // fill the 'Open with' sub menu with application types
- const KMimeType::Ptr mimePtr = KMimeType::findByUrl(m_fileInfo.url());
- KService::List offers = KMimeTypeTrader::self()->query(mimePtr->name(),
- "Application",
- "Type == 'Application'");
- if (offers.count() > 0) {
- KService::List::Iterator it;
- KMenu* openWithMenu = new KMenu(i18nc("@title:menu", "Open With"));
- for (it = offers.begin(); it != offers.end(); ++it) {
- // The offer list from the KTrader returns duplicate
- // application entries. Although this seems to be a configuration
- // problem outside the scope of Dolphin, duplicated entries just
- // will be skipped here.
- const QString appName((*it)->name());
- if (!containsEntry(openWithMenu, appName)) {
- const KIcon icon((*it)->icon());
- QAction* action = openWithMenu->addAction(icon, appName);
- openWithVector.append(*it);
- openWithActions << action;
- }
- }