本文整理汇总了C++中KBookmark::parentGroup方法的典型用法代码示例。如果您正苦于以下问题:C++ KBookmark::parentGroup方法的具体用法?C++ KBookmark::parentGroup怎么用?C++ KBookmark::parentGroup使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KBookmark
的用法示例。
在下文中一共展示了KBookmark::parentGroup方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: slotProperties
void KonqSidebarBookmarkModule::slotProperties(KonqSidebarBookmarkItem *bi)
{
if (!bi) {
bi = dynamic_cast<KonqSidebarBookmarkItem*>( tree()->selectedItem() );
if (!bi)
return;
}
KBookmark bookmark = bi->bookmark();
QString folder = bookmark.isGroup() ? QString::null : bookmark.url().pathOrURL();
BookmarkEditDialog dlg( bookmark.fullText(), folder, 0, 0,
i18n("Bookmark Properties") );
if ( dlg.exec() != KDialogBase::Accepted )
return;
makeTextNodeMod(bookmark, "title", dlg.finalTitle());
if ( !dlg.finalUrl().isNull() )
{
KURL u = KURL::fromPathOrURL(dlg.finalUrl());
bookmark.internalElement().setAttribute("href", u.url(0, 106));
}
KBookmarkGroup parentBookmark = bookmark.parentGroup();
KonqBookmarkManager::self()->emitChanged( parentBookmark );
}
示例2: removeBookmarkMessageButtonPressed
void WebBrowser::removeBookmarkMessageButtonPressed(const Plasma::MessageButton button)
{
if (button == Plasma::ButtonNo){
return;
}
const QModelIndexList list = m_bookmarkModel->match(m_bookmarkModel->index(0,0), BookmarkItem::UrlRole, m_url.prettyUrl());
if (!list.isEmpty()) {
const QModelIndex &index = list.first();
BookmarkItem *item = dynamic_cast<BookmarkItem *>(m_bookmarkModel->itemFromIndex(index));
if (item) {
KBookmark bookmark = item->bookmark();
bookmark.parentGroup().deleteBookmark(bookmark);
m_bookmarkManager->save();
}
if (item && item->parent()) {
item->parent()->removeRow(index.row());
} else {
m_bookmarkModel->removeRow(index.row());
}
}
m_addBookmark->setAction(m_addBookmarkAction);
}
示例3: slotDelete
void KonqSidebarBookmarkModule::slotDelete()
{
KonqSidebarBookmarkItem *bi = dynamic_cast<KonqSidebarBookmarkItem*>( tree()->selectedItem() );
if (!bi)
return;
KBookmark bookmark = bi->bookmark();
bool folder = bookmark.isGroup();
if (KMessageBox::warningYesNo(
tree(),
folder ? i18n("Are you sure you wish to remove the bookmark folder\n\"%1\"?").arg(bookmark.text())
: i18n("Are you sure you wish to remove the bookmark\n\"%1\"?").arg(bookmark.text()),
folder ? i18n("Bookmark Folder Deletion")
: i18n("Bookmark Deletion"),
KGuiItem( i18n("&Delete"), "editdelete"), KStdGuiItem::cancel())
!= KMessageBox::Yes
)
return;
KBookmarkGroup parentBookmark = bookmark.parentGroup();
parentBookmark.deleteBookmark( bookmark );
KonqBookmarkManager::self()->emitChanged( parentBookmark );
}
示例4: undo
void CreateCommand::undo()
{
KBookmark bk = m_model->bookmarkManager()->findByAddress(m_to);
Q_ASSERT(!bk.isNull() && !bk.parentGroup().isNull());
m_model->removeBookmark(bk);
}
示例5: slotDropped
void KonqSidebarBookmarkModule::slotDropped(KListView *, QDropEvent *e, QListViewItem *parent, QListViewItem *after)
{
if (!KBookmarkDrag::canDecode(e))
return;
KBookmark afterBookmark;
KonqSidebarBookmarkItem *afterItem = dynamic_cast<KonqSidebarBookmarkItem*>(after);
if (afterItem)
afterBookmark = afterItem->bookmark();
KBookmarkGroup parentGroup;
// try to get the parent group...
if (after) {
parentGroup = afterBookmark.parentGroup();
} else if (parent) {
if(KonqSidebarBookmarkItem *p = dynamic_cast<KonqSidebarBookmarkItem*>(parent))
{
if (!p)
return;
KBookmark bm = p->bookmark();
if (bm.isGroup())
parentGroup = bm.toGroup();
else
return;
}
else if(parent == m_topLevelItem)
{
parentGroup = KonqBookmarkManager::self()->root();
}
} else {
// it's most probably the root...
parentGroup = KonqBookmarkManager::self()->root();
}
QValueList<KBookmark> bookmarks = KBookmarkDrag::decode(e);
// copy
QValueList<KBookmark>::iterator it = bookmarks.begin();
for (;it != bookmarks.end(); ++it) {
// insert new item.
parentGroup.moveItem(*it, afterBookmark);
}
KonqBookmarkManager::self()->emitChanged( parentGroup );
}
示例6: slotDropped
void KonqSidebarBookmarkModule::slotDropped(K3ListView *, QDropEvent *e, Q3ListViewItem *parent, Q3ListViewItem *after)
{
if (!KBookmark::List::canDecode(e->mimeData()))
return;
KBookmark afterBookmark;
KonqSidebarBookmarkItem *afterItem = dynamic_cast<KonqSidebarBookmarkItem*>(after);
if (afterItem)
afterBookmark = afterItem->bookmark();
KBookmarkGroup parentGroup;
// try to get the parent group...
if (after) {
parentGroup = afterBookmark.parentGroup();
} else if (parent) {
if(KonqSidebarBookmarkItem *p = dynamic_cast<KonqSidebarBookmarkItem*>(parent))
{
if (!p)
return;
KBookmark bm = p->bookmark();
if (bm.isGroup())
parentGroup = bm.toGroup();
else
return;
} else if(parent == m_topLevelItem) {
parentGroup = s_bookmarkManager->root();
}
} else {
// it's most probably the root...
parentGroup = s_bookmarkManager->root();
}
QDomDocument parentDocument;
const KBookmark::List bookmarks = KBookmark::List::fromMimeData(e->mimeData(), parentDocument);
// copy
KBookmark::List::const_iterator it = bookmarks.constBegin();
for (;it != bookmarks.constEnd(); ++it) {
// insert new item.
parentGroup.moveBookmark(*it, afterBookmark);
}
s_bookmarkManager->emitChanged( parentGroup );
}
示例7: slotMoved
void KonqSidebarBookmarkModule::slotMoved(QListViewItem *i, QListViewItem*, QListViewItem *after)
{
KonqSidebarBookmarkItem *item = dynamic_cast<KonqSidebarBookmarkItem*>( i );
if (!item)
return;
KBookmark bookmark = item->bookmark();
KBookmark afterBookmark;
KonqSidebarBookmarkItem *afterItem = dynamic_cast<KonqSidebarBookmarkItem*>(after);
if (afterItem)
afterBookmark = afterItem->bookmark();
KBookmarkGroup oldParentGroup = bookmark.parentGroup();
KBookmarkGroup parentGroup;
// try to get the parent group (assume that the QListViewItem has been reparented by KListView)...
// if anything goes wrong, use the root.
if (item->parent()) {
bool error = false;
KonqSidebarBookmarkItem *parent = dynamic_cast<KonqSidebarBookmarkItem*>( (item->parent()) );
if (!parent) {
error = true;
} else {
if (parent->bookmark().isGroup())
parentGroup = parent->bookmark().toGroup();
else
error = true;
}
if (error)
parentGroup = KonqBookmarkManager::self()->root();
} else {
// No parent! This means the user dropped it before the top level item
// And KListView has moved the item there, we need to correct it
tree()->moveItem(item, m_topLevelItem, 0L);
parentGroup = KonqBookmarkManager::self()->root();
}
// remove the old reference.
oldParentGroup.deleteBookmark( bookmark );
// insert the new item.
parentGroup.moveItem(bookmark, afterBookmark);
// inform others about the changed groups. quite expensive, so do
// our best to update them in only one emitChanged call.
QString oldAddress = oldParentGroup.address();
QString newAddress = parentGroup.address();
if (oldAddress == newAddress) {
KonqBookmarkManager::self()->emitChanged( parentGroup );
} else {
int i = 0;
while (true) {
QChar c1 = oldAddress[i];
QChar c2 = newAddress[i];
if (c1 == QChar::null) {
// oldParentGroup is probably parent of parentGroup.
KonqBookmarkManager::self()->emitChanged( oldParentGroup );
break;
} else if (c2 == QChar::null) {
// parentGroup is probably parent of oldParentGroup.
KonqBookmarkManager::self()->emitChanged( parentGroup );
break;
} else {
if (c1 == c2) {
// step to the next character.
++i;
} else {
// ugh... need to update both groups separately.
KonqBookmarkManager::self()->emitChanged( oldParentGroup );
KonqBookmarkManager::self()->emitChanged( parentGroup );
break;
}
}
}
}
}
示例8: eventFilter
//.........这里部分代码省略.........
}
QAction *destAction = actionAt(dropEvent->pos());
if (destAction && destAction == m_dropAction)
{
if (actions().indexOf(m_dropAction) > 0)
{
destAction = actions().at(actions().indexOf(m_dropAction) - 1);
}
else
{
destAction = actions().at(1);
}
}
if (destAction)
{
KBookmarkActionInterface *destBookmarkAction = dynamic_cast<KBookmarkActionInterface *>(destAction);
QWidget *widgetAction = widgetForAction(destAction);
if (destBookmarkAction && !destBookmarkAction->bookmark().isNull() && widgetAction
&& bookmark.address() != destBookmarkAction->bookmark().address())
{
KBookmark destBookmark = destBookmarkAction->bookmark();
if (!destBookmark.isGroup())
{
if ((dropEvent->pos().x() - widgetAction->pos().x()) >= (widgetAction->width() / 2))
{
root.moveBookmark(bookmark, destBookmark);
}
else
{
root.moveBookmark(bookmark, destBookmark.parentGroup().previous(destBookmark));
}
}
else
{
if ((dropEvent->pos().x() - widgetAction->pos().x()) >= (widgetAction->width() * 0.75))
{
root.moveBookmark(bookmark, destBookmark);
}
else if ((dropEvent->pos().x() - widgetAction->pos().x()) <= (widgetAction->width() * 0.25))
{
root.moveBookmark(bookmark, destBookmark.parentGroup().previous(destBookmark));
}
else
{
destBookmark.toGroup().addBookmark(bookmark);
}
}
BookmarkManager::self()->emitChanged();
}
}
else
{
root.deleteBookmark(bookmark);
bookmark = root.addBookmark(bookmark);
if (dropEvent->pos().x() < widgetForAction(actions().first())->pos().x())
{
root.moveBookmark(bookmark, KBookmark());
}
BookmarkManager::self()->emitChanged();