void KBookmarkBar::slotBookmarksChanged( const QString & group )
{
    KBookmarkGroup tb = getToolbar(); // heavy for non cached toolbar version
    kDebug(7043) << "KBookmarkBar::slotBookmarksChanged( " << group << " )";

    if ( tb.isNull() )
        return;

    if( d->m_filteredToolbar )
    {
        clear();
        fillBookmarkBar( tb );
    }
    else if ( KBookmark::commonParent(group, tb.address()) == group)  // Is group a parent of tb.address?
    {
        clear();
        fillBookmarkBar( tb );
    }
    else
    {
        // Iterate recursively into child menus
        for ( QList<KBookmarkMenu *>::ConstIterator smit = m_lstSubMenus.constBegin(), smend = m_lstSubMenus.constEnd();
              smit != smend; ++smit )
        {
            (*smit)->slotBookmarksChanged( group );
        }
    }
}
예제 #2
0
KBookmark BookmarkManager::bookmarkForUrl(const KUrl &url)
{
    KBookmarkGroup root = rootGroup();
    if (root.isNull())
        return KBookmark();

    return bookmarkForUrl(root, url);
}
예제 #3
0
QList<KBookmark> BookmarkManager::find(const QString &text)
{
    QList<KBookmark> list;

    KBookmarkGroup root = rootGroup();
    if (!root.isNull())
        for (KBookmark bookmark = root.first(); !bookmark.isNull(); bookmark = root.next(bookmark))
            find(&list, bookmark, text);

    return list;
}
예제 #4
0
void KBookmarkMenu::slotNewFolder()
{
    if (!m_pOwner) {
        return;    // this view doesn't handle bookmarks...
    }
    KBookmarkGroup parentBookmark = m_pManager->findByAddress(m_parentAddress).toGroup();
    Q_ASSERT(!parentBookmark.isNull());
    KBookmarkDialog *dlg = m_pOwner->bookmarkDialog(m_pManager, QApplication::activeWindow());
    dlg->createNewFolder(QLatin1String(""), parentBookmark);
    delete dlg;
}
예제 #5
0
void KBookmarkMenu::fillBookmarks()
{
    KBookmarkGroup parentBookmark = m_pManager->findByAddress(m_parentAddress).toGroup();
    Q_ASSERT(!parentBookmark.isNull());

    if (m_bIsRoot && !parentBookmark.first().isNull()) { // at least one bookmark
        m_parentMenu->addSeparator();
    }

    for (KBookmark bm = parentBookmark.first(); !bm.isNull();  bm = parentBookmark.next(bm)) {
        m_parentMenu->addAction(actionForBookmark(bm));
    }
}
예제 #6
0
void KonqSidebarBookmarkModule::slotBookmarksChanged( const QString & groupAddress )
{
    m_ignoreOpenChange = true;

    // update the right part of the tree
    KBookmarkGroup group = KonqBookmarkManager::self()->findByAddress( groupAddress ).toGroup();
    KonqSidebarBookmarkItem * item = findByAddress( groupAddress );
    Q_ASSERT(!group.isNull());
    Q_ASSERT(item);
    if (!group.isNull() && item)
    {
        // Delete all children of item
        QListViewItem * child = item->firstChild();
        while( child ) {
            QListViewItem * next = child->nextSibling();
            delete child;
            child = next;
        }
        fillGroup( item, group );
    }

    m_ignoreOpenChange = false;
}
예제 #7
0
KEBMacroCommand* CmdGen::setAsToolbar(KBookmarkModel* model, const KBookmark &bk)
{
    KEBMacroCommand *mcmd = new KEBMacroCommand(i18nc("(qtundo-format)", "Set as Bookmark Toolbar"));

    KBookmarkGroup oldToolbar = model->bookmarkManager()->toolbar();
    if (!oldToolbar.isNull())
    {
        new EditCommand(model, oldToolbar.address(), -2, "no", mcmd); //toolbar
        new EditCommand(model, oldToolbar.address(), -1, "", mcmd); //icon
    }

    new EditCommand(model, bk.address(), -2, "yes", mcmd);
    new EditCommand(model, bk.address(), -1, "bookmark-toolbar", mcmd);

    return mcmd;
}
예제 #8
0
void SortCommand::redo()
{
    if (childCount() == 0) {
        KBookmarkGroup grp = m_model->bookmarkManager()->findByAddress(m_groupAddress).toGroup();
        Q_ASSERT(!grp.isNull());
        SortItem firstChild(grp.first());
        // this will call moveAfter, which will add
        // the subcommands for moving the items
        kInsertionSort<SortItem, SortByName, QString, SortCommand>
            (firstChild, (*this));

    } else {
        // don't redo for second time on addCommand(cmd)
        KEBMacroCommand::redo();
    }
}
void KBookmarkBar::fillBookmarkBar(const KBookmarkGroup & parent)
{
    if (parent.isNull())
        return;

    for (KBookmark bm = parent.first(); !bm.isNull(); bm = parent.next(bm))
    {
        // Filtered special cases
        if(d->m_filteredToolbar)
        {
            if(bm.isGroup() && !bm.showInToolbar() )
		fillBookmarkBar(bm.toGroup());

	    if(!bm.showInToolbar())
		continue;
        }


        if (!bm.isGroup())
        {
	    if ( bm.isSeparator() )
                m_toolBar->addSeparator();
            else
            {
                KAction *action = new KBookmarkAction( bm, m_pOwner, 0 );
                m_toolBar->addAction(action);
                d->m_actions.append( action );
            }
        }
        else
        {
            KBookmarkActionMenu *action = new KBookmarkActionMenu(bm, 0);
            action->setDelayed( false );
            m_toolBar->addAction(action);
            d->m_actions.append( action );
            KBookmarkMenu *menu = new KonqBookmarkMenu(m_pManager, m_pOwner, action, bm.address());
            m_lstSubMenus.append( menu );
        }
    }
}