void KonqSidebarTree::showToplevelContextMenu() { KonqSidebarTreeTopLevelItem *item = 0; KonqSidebarTreeItem *treeItem = currentItem(); if (treeItem && treeItem->isTopLevelItem()) item = static_cast<KonqSidebarTreeTopLevelItem *>(treeItem); if (!m_collection) { m_collection = new KActionCollection( this, "bookmark actions" ); (void) new KAction( i18n("&Create New Folder..."), "folder_new", 0, this, SLOT( slotCreateFolder() ), m_collection, "create_folder"); (void) new KAction( i18n("Delete Folder"), "editdelete", 0, this, SLOT( slotDelete() ), m_collection, "delete_folder"); (void) new KAction( i18n("Rename"), 0, this, SLOT( slotRename() ), m_collection, "rename"); (void) new KAction( i18n("Delete Link"), "editdelete", 0, this, SLOT( slotDelete() ), m_collection, "delete_link"); (void) new KAction( i18n("Properties"), "edit", 0, this, SLOT( slotProperties() ), m_collection, "item_properties"); (void) new KAction( i18n("Open in New Window"), "window_new", 0, this, SLOT( slotOpenNewWindow() ), m_collection, "open_window"); (void) new KAction( i18n("Open in New Tab"), "tab_new", 0, this, SLOT( slotOpenTab() ), m_collection, "open_tab"); (void) new KAction( i18n("Copy Link Address"), "editcopy", 0, this, SLOT( slotCopyLocation() ), m_collection, "copy_location"); } QPopupMenu *menu = new QPopupMenu; if (item) { if (item->isTopLevelGroup()) { m_collection->action("rename")->plug(menu); m_collection->action("delete_folder")->plug(menu); menu->insertSeparator(); m_collection->action("create_folder")->plug(menu); } else { if (tabSupport()) m_collection->action("open_tab")->plug(menu); m_collection->action("open_window")->plug(menu); m_collection->action("copy_location")->plug(menu); menu->insertSeparator(); m_collection->action("rename")->plug(menu); m_collection->action("delete_link")->plug(menu); } menu->insertSeparator(); m_collection->action("item_properties")->plug(menu); } else { m_collection->action("create_folder")->plug(menu); } m_currentTopLevelItem = item; menu->exec( QCursor::pos() ); delete menu; m_currentTopLevelItem = 0; }
KonqSidebarBookmarkModule::KonqSidebarBookmarkModule( KonqSidebarTree * parentTree ) : QObject( 0L ), KonqSidebarTreeModule( parentTree ), m_topLevelItem( 0L ), m_ignoreOpenChange(true) { // formats handled by KBookmarkDrag: QStringList formats; formats << "text/uri-list" << "application/x-xbel" << "text/plain"; tree()->setDropFormats(formats); connect(tree(), SIGNAL(moved(QListViewItem*,QListViewItem*,QListViewItem*)), this, SLOT(slotMoved(QListViewItem*,QListViewItem*,QListViewItem*))); connect(tree(), SIGNAL(dropped(KListView*,QDropEvent*,QListViewItem*,QListViewItem*)), this, SLOT(slotDropped(KListView*,QDropEvent*,QListViewItem*,QListViewItem*))); connect(tree(), SIGNAL(expanded(QListViewItem*)), this, SLOT(slotOpenChange(QListViewItem*))); connect(tree(), SIGNAL(collapsed(QListViewItem*)), this, SLOT(slotOpenChange(QListViewItem*))); m_collection = new KActionCollection( this, "bookmark actions" ); (void) new KAction( i18n("&Create New Folder"), "folder_new", 0, this, SLOT( slotCreateFolder() ), m_collection, "create_folder"); (void) new KAction( i18n("Delete Folder"), "editdelete", 0, this, SLOT( slotDelete() ), m_collection, "delete_folder"); (void) new KAction( i18n("Delete Bookmark"), "editdelete", 0, this, SLOT( slotDelete() ), m_collection, "delete_bookmark"); (void) new KAction( i18n("Properties"), "edit", 0, this, SLOT( slotProperties() ), m_collection, "item_properties"); (void) new KAction( i18n("Open in New Window"), "window_new", 0, this, SLOT( slotOpenNewWindow() ), m_collection, "open_window"); (void) new KAction( i18n("Open in New Tab"), "tab_new", 0, this, SLOT( slotOpenTab() ), m_collection, "open_tab"); (void) new KAction( i18n("Open Folder in Tabs"), "tab_new", 0, this, SLOT( slotOpenTab() ), m_collection, "folder_open_tabs"); (void) new KAction( i18n("Copy Link Address"), "editcopy", 0, this, SLOT( slotCopyLocation() ), m_collection, "copy_location"); KStdAction::editBookmarks( KonqBookmarkManager::self(), SLOT( slotEditBookmarks() ), m_collection, "edit_bookmarks" ); connect( KonqBookmarkManager::self(), SIGNAL(changed(const QString &, const QString &) ), SLOT( slotBookmarksChanged(const QString &) ) ); }