コード例 #1
0
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;
}
コード例 #2
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 &) ) );
}
コード例 #3
0
KonqHistoryDialog::KonqHistoryDialog(KonqMainWindow *parent)
    : KDialog(parent), m_mainWindow(parent)
{
    setCaption(i18nc("@title:window", "History"));
    setButtons(KDialog::Close);

    QVBoxLayout *mainLayout = new QVBoxLayout(mainWidget());
    mainLayout->setMargin(0);

    m_historyView = new KonqHistoryView(mainWidget());
    connect(m_historyView->treeView(), SIGNAL(doubleClicked(QModelIndex)), this, SLOT(slotOpenWindowForIndex(QModelIndex)));
    connect(m_historyView, SIGNAL(openUrlInNewWindow(KUrl)), this, SLOT(slotOpenWindow(KUrl)));
    connect(m_historyView, SIGNAL(openUrlInNewTab(KUrl)), this, SLOT(slotOpenTab(KUrl)));

    KActionCollection* collection = m_historyView->actionCollection();

    QToolBar *toolBar = new QToolBar(mainWidget());
    toolBar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
    QToolButton *sortButton = new QToolButton(toolBar);
    sortButton->setText(i18nc("@action:inmenu Parent of 'By Name' and 'By Date'", "Sort"));
    sortButton->setIcon(KIcon("view-sort-ascending"));
    sortButton->setPopupMode(QToolButton::InstantPopup);
    sortButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
    QMenu *sortMenu = new QMenu(sortButton);
    sortMenu->addAction(collection->action("byName"));
    sortMenu->addAction(collection->action("byDate"));
    sortButton->setMenu(sortMenu);
    toolBar->addWidget(sortButton);
    toolBar->addSeparator();
    toolBar->addAction(collection->action("preferences"));

    mainLayout->addWidget(toolBar);
    mainLayout->addWidget(m_historyView);

    restoreDialogSize(KGlobal::config()->group("History Dialog"));

    // give focus to the search line edit when opening the dialog (#240513)
    m_historyView->lineEdit()->setFocus();
}