void KonqSidebarBookmarkModule::slotOpenTab() { KonqSidebarBookmarkItem *bi = dynamic_cast<KonqSidebarBookmarkItem*>( tree()->selectedItem() ); KBookmark bookmark; if (bi) { bookmark = bi->bookmark(); } else if(tree()->selectedItem() == m_topLevelItem) bookmark = KonqBookmarkManager::self()->root(); else return; DCOPRef ref(kapp->dcopClient()->appId(), tree()->topLevelWidget()->name()); if (bookmark.isGroup()) { KBookmarkGroup group = bookmark.toGroup(); bookmark = group.first(); while (!bookmark.isNull()) { if (!bookmark.isGroup() && !bookmark.isSeparator()) ref.call( "newTab(QString)", bookmark.url().url() ); bookmark = group.next(bookmark); } } else { ref.call( "newTab(QString)", bookmark.url().url() ); } }
void KonqSidebarBookmarkModule::slotOpenTab() { KonqSidebarBookmarkItem *bi = dynamic_cast<KonqSidebarBookmarkItem*>( tree()->selectedItem() ); KBookmark bookmark; if (bi) { bookmark = bi->bookmark(); } else if(tree()->selectedItem() == m_topLevelItem) bookmark = s_bookmarkManager->root(); else return; KParts::OpenUrlArguments args; args.setActionRequestedByUser(true); KParts::BrowserArguments browserArguments; browserArguments.setNewTab(true); if (bookmark.isGroup()) { KBookmarkGroup group = bookmark.toGroup(); bookmark = group.first(); while (!bookmark.isNull()) { if (!bookmark.isGroup() && !bookmark.isSeparator()) { emit tree()->createNewWindow(bookmark.url(), args, browserArguments); } bookmark = group.next(bookmark); } } else { emit tree()->createNewWindow(bookmark.url(), args, browserArguments); } }
QList< BookmarkMatch > KDEBrowser::match(const QString& term, bool addEverything) { KBookmarkGroup bookmarkGroup = m_bookmarkManager->root(); QList< BookmarkMatch > matches; QStack<KBookmarkGroup> groups; KBookmark bookmark = bookmarkGroup.first(); while (!bookmark.isNull()) { // if (!context.isValid()) { // return; // } TODO: restore? if (bookmark.isSeparator()) { bookmark = bookmarkGroup.next(bookmark); continue; } if (bookmark.isGroup()) { // descend //kDebug (kdbg_code) << "descending into" << bookmark.text(); groups.push(bookmarkGroup); bookmarkGroup = bookmark.toGroup(); bookmark = bookmarkGroup.first(); while (bookmark.isNull() && !groups.isEmpty()) { // if (!context.isValid()) { // return; // } TODO: restore? bookmark = bookmarkGroup; bookmarkGroup = groups.pop(); bookmark = bookmarkGroup.next(bookmark); } continue; } BookmarkMatch bookmarkMatch(m_favicon, term, bookmark.text(), bookmark.url().url() ); bookmarkMatch.addTo(matches, addEverything); bookmark = bookmarkGroup.next(bookmark); while (bookmark.isNull() && !groups.isEmpty()) { // if (!context.isValid()) { // return; // } // TODO: restore? bookmark = bookmarkGroup; bookmarkGroup = groups.pop(); //kDebug(kdbg_code) << "ascending from" << bookmark.text() << "to" << bookmarkGroup.text(); bookmark = bookmarkGroup.next(bookmark); } } return matches; }
void BookmarkMenu::addOpenFolderInTabs() { KBookmarkGroup group = manager()->findByAddress(parentAddress()).toGroup(); if (!group.first().isNull()) { KBookmark bookmark = group.first(); while (bookmark.isGroup() || bookmark.isSeparator()) { bookmark = group.next(bookmark); } if (!bookmark.isNull()) { parentMenu()->addAction(rApp->bookmarkManager()->owner()->createAction(group, BookmarkOwner::OPEN_FOLDER)); } } }
void DeleteCommand::redo() { KBookmark bk = m_model->bookmarkManager()->findByAddress(m_from); Q_ASSERT(!bk.isNull()); if (m_contentOnly) { QDomElement groupRoot = bk.internalElement(); QDomNode n = groupRoot.firstChild(); while (!n.isNull()) { QDomElement e = n.toElement(); if (!e.isNull()) { // kDebug() << e.tagName(); } QDomNode next = n.nextSibling(); groupRoot.removeChild(n); n = next; } return; } // TODO - bug - unparsed xml is lost after undo, // we must store it all therefore //FIXME this removes the comments, that's bad! if (!m_cmd) { if (bk.isGroup()) { m_cmd = new CreateCommand(m_model, m_from, bk.fullText(), bk.icon(), bk.internalElement().attribute("folded") == "no"); m_subCmd = deleteAll(m_model, bk.toGroup()); m_subCmd->redo(); } else { m_cmd = (bk.isSeparator()) ? new CreateCommand(m_model, m_from) : new CreateCommand(m_model, m_from, bk.fullText(), bk.icon(), bk.url()); } } m_cmd->undo(); }
void HTMLExporter::visit(const KBookmark &bk) { // //qDebug() << "visit(" << bk.text() << ")"; if(bk.isSeparator()) { m_out << bk.fullText() << "<br>"<<endl; } else { if(m_showAddress) { m_out << bk.fullText() <<"<br>"<< endl; m_out << "<i><div style =\"margin-left: 1em\">" << bk.url().url().toUtf8() << "</div></i>"; } else { m_out << "<a href=\"" << bk.url().url().toUtf8() << "\">"; m_out << bk.fullText() << "</a><br>" << endl; } } }
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 ); } } }
void BookmarksContextMenu::addFolderActions() { KBookmarkGroup group = bookmark().toGroup(); if (bookmark().internalElement().attributeNode("toolbar").value() == "yes") { addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::UNSET_TOOLBAR_FOLDER)); } else { addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::SET_TOOLBAR_FOLDER)); } if (!group.first().isNull()) { KBookmark child = group.first(); while (child.isGroup() || child.isSeparator()) { child = group.next(child); } if (!child.isNull()) { addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::OPEN_FOLDER)); addSeparator(); } } addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::BOOKMARK_PAGE)); addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::NEW_FOLDER)); addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::NEW_SEPARATOR)); addSeparator(); addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::EDIT)); addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::DELETE)); }
void BookmarksProtocol::echoFolder( const KBookmarkGroup &folder ) { if (sizeOfGroup(folder.toGroup(), true) > 1) { QString descriptionAsTitle = folder.description(); if (!descriptionAsTitle.isEmpty()) descriptionAsTitle.prepend(QLatin1String("\" title=\"")); if (folder.parentGroup() == tree) { if (config.readEntry("ShowBackgrounds", true)) echo("<ul style=\"background-image: url(/background/" + folder.icon() + ")\">"); else echo("<ul>"); echo ("<li class=\"title" + descriptionAsTitle + "\">" + folder.fullText() + "</li>"); } else { echo("<ul>"); echo ("<li class=\"title" + descriptionAsTitle + "\"><img src=\"/icon/" + folder.icon() + "\"/>" + folder.text() + "</li>"); } indent++; for (KBookmark bm = folder.first(); !bm.isNull(); bm = folder.next(bm)) { if (bm.isGroup()) echoFolder(bm.toGroup()); else if (bm.isSeparator()) echoSeparator(); else echoBookmark(bm); } indent--; echo("</ul>"); } }
void KonqSidebarBookmarkModule::fillGroup( KonqSidebarTreeItem * parentItem, KBookmarkGroup group ) { int n = 0; for ( KBookmark bk = group.first() ; !bk.isNull() ; bk = group.next(bk), ++n ) { KonqSidebarBookmarkItem * item = new KonqSidebarBookmarkItem( parentItem, m_topLevelItem, bk, n ); if ( bk.isGroup() ) { KBookmarkGroup grp = bk.toGroup(); fillGroup( item, grp ); QString address(grp.address()); if (m_folderOpenState.contains(address)) item->setOpen(m_folderOpenState[address]); else item->setOpen(false); } else if ( bk.isSeparator() ) item->setVisible( false ); else item->setExpandable( false ); } }
// SHUFFLE all these functions around, the order is just plain stupid void BookmarkInfoWidget::showBookmark(const KBookmark &bk) { // Fast exit if already shown, otherwise editing a title leads to a command after each keypress if (m_bk == bk) return; commitChanges(); m_bk = bk; if (m_bk.isNull()) { // all read only and blank m_title_le->setReadOnly(true); m_title_le->setText(QString()); m_url_le->setReadOnly(true); m_url_le->setText(QString()); m_comment_le->setReadOnly(true); m_comment_le->setText(QString()); m_visitdate_le->setReadOnly(true); m_visitdate_le->setText(QString()); m_credate_le->setReadOnly(true); m_credate_le->setText(QString()); m_visitcount_le->setReadOnly(true); m_visitcount_le->setText(QString()); return; } // read/write fields m_title_le->setReadOnly( (bk.isSeparator()|| !bk.hasParent() )? true : false); if (bk.fullText() != m_title_le->text()) m_title_le->setText(bk.fullText()); m_url_le->setReadOnly(bk.isGroup() || bk.isSeparator()); if (bk.isGroup()) { m_url_le->setText(QString()); } else { // Update the text if and only if the text represents a different URL to that // of the current bookmark - the old method, "m_url_le->text() != bk.url().pathOrUrl()", // created difficulties due to the ambiguity of converting URLs to text. (#172647) if (QUrl::fromUserInput(m_url_le->text()) != bk.url()) { const int cursorPosition = m_url_le->cursorPosition(); m_url_le->setText(bk.url().url(QUrl::PreferLocalFile)); m_url_le->setCursorPosition(cursorPosition); } } m_comment_le->setReadOnly((bk.isSeparator()|| !bk.hasParent()) ? true : false ); QString commentText = bk.description(); if (m_comment_le->text() != commentText) { const int cursorPosition = m_comment_le->cursorPosition(); m_comment_le->setText(commentText); m_comment_le->setCursorPosition(cursorPosition); } // readonly fields updateStatus(); }
bool TestLinkItr::isApplicable(const KBookmark &bk) const { return !bk.isGroup() && !bk.isSeparator(); }