本文整理汇总了C++中KBookmark::text方法的典型用法代码示例。如果您正苦于以下问题:C++ KBookmark::text方法的具体用法?C++ KBookmark::text怎么用?C++ KBookmark::text使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KBookmark
的用法示例。
在下文中一共展示了KBookmark::text方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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\"?", bookmark.text())
: i18n("Are you sure you wish to remove the bookmark\n\"%1\"?", bookmark.text()),
folder ? i18nc("@title:window", "Bookmark Folder Deletion")
: i18nc("@title:window", "Bookmark Deletion"),
KStandardGuiItem::del(), KStandardGuiItem::cancel())
!= KMessageBox::Yes
)
return;
KBookmarkGroup parentBookmark = bookmark.parentGroup();
parentBookmark.deleteBookmark( bookmark );
s_bookmarkManager->emitChanged( parentBookmark );
}
示例2: KActionMenu
KBookmarkActionMenu::KBookmarkActionMenu(const KBookmark &bm, QObject *parent)
: KActionMenu(QIcon::fromTheme(bm.icon()), bm.text().replace('&', QLatin1String("&&")), parent),
KBookmarkActionInterface(bm)
{
setToolTip(bm.description());
setIconText(text());
}
示例3: bookmarkMatch
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;
}
示例4: slotEditButtonClicked
void BookmarksSettingsPage::slotEditButtonClicked()
{
QListViewItem* item = m_listView->selectedItem();
assert(item != 0); // 'edit' may not get invoked when having no items
KBookmark bookmark = EditBookmarkDialog::getBookmark(i18n("Edit Bookmark"),
item->text(NameIdx),
KURL(item->text(URLIdx)),
item->text(IconIdx));
if (!bookmark.isNull()) {
item->setPixmap(PixmapIdx, SmallIcon(bookmark.icon()));
item->setText(NameIdx, bookmark.text());
item->setText(URLIdx, bookmark.url().prettyURL());
item->setText(IconIdx, bookmark.icon());
}
}
示例5: slotAddButtonClicked
void BookmarksSettingsPage::slotAddButtonClicked()
{
KBookmark bookmark = EditBookmarkDialog::getBookmark(i18n("Add Bookmark"),
i18n("New bookmark"),
KURL(),
"bookmark");
if (!bookmark.isNull()) {
// insert bookmark into listview
QListViewItem* item = new QListViewItem(m_listView);
item->setPixmap(PixmapIdx, SmallIcon(bookmark.icon()));
item->setText(NameIdx, bookmark.text());
item->setText(URLIdx, bookmark.url().prettyURL());
item->setText(IconIdx, bookmark.icon());
m_listView->insertItem(item);
QListViewItem* lastItem = m_listView->lastChild();
if (lastItem != 0) {
item->moveItem(lastItem);
}
m_listView->setSelected(item, true);
updateButtons();
}
}
示例6: buttonSizePolicy
BookmarksSettingsPage::BookmarksSettingsPage(QWidget*parent) :
SettingsPageBase(parent),
m_addButton(0),
m_removeButton(0),
m_moveUpButton(0),
m_moveDownButton(0)
{
QVBoxLayout* topLayout = new QVBoxLayout(parent, 2, KDialog::spacingHint());
const int spacing = KDialog::spacingHint();
QHBox* hBox = new QHBox(parent);
hBox->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
hBox->setSpacing(spacing);
hBox->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Ignored);
m_listView = new KListView(hBox);
m_listView->addColumn(i18n("Icon"));
m_listView->addColumn(i18n("Name"));
m_listView->addColumn(i18n("Location"));
m_listView->setResizeMode(QListView::LastColumn);
m_listView->setColumnAlignment(0, Qt::AlignHCenter);
m_listView->setAllColumnsShowFocus(true);
m_listView->setSorting(-1);
connect(m_listView, SIGNAL(selectionChanged()),
this, SLOT(updateButtons()));
connect(m_listView, SIGNAL(pressed(QListViewItem*)),
this, SLOT(slotBookmarkPressed(QListViewItem*)));
connect(m_listView, SIGNAL(doubleClicked(QListViewItem*, const QPoint&, int)),
this, SLOT(slotBookmarkDoubleClicked(QListViewItem*, const QPoint&, int)));
QVBox* buttonBox = new QVBox(hBox);
buttonBox->setSpacing(spacing);
const QSizePolicy buttonSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
m_addButton = new KPushButton(i18n("Add..."), buttonBox);
connect(m_addButton, SIGNAL(clicked()),
this, SLOT(slotAddButtonClicked()));
m_addButton->setSizePolicy(buttonSizePolicy);
m_editButton = new KPushButton(i18n("Edit..."), buttonBox);
connect(m_editButton, SIGNAL(clicked()),
this, SLOT(slotEditButtonClicked()));
m_editButton->setSizePolicy(buttonSizePolicy);
m_removeButton = new KPushButton(i18n("Remove"), buttonBox);
connect(m_removeButton, SIGNAL(clicked()),
this, SLOT(slotRemoveButtonClicked()));
m_removeButton->setSizePolicy(buttonSizePolicy);
m_moveUpButton = new KPushButton(i18n("Move Up"), buttonBox);
connect(m_moveUpButton, SIGNAL(clicked()),
this, SLOT(slotMoveUpButtonClicked()));
m_moveUpButton->setSizePolicy(buttonSizePolicy);
m_moveDownButton = new KPushButton(i18n("Move Down"), buttonBox);
connect(m_moveDownButton, SIGNAL(clicked()),
this, SLOT(slotMoveDownButtonClicked()));
m_moveDownButton->setSizePolicy(buttonSizePolicy);
// Add a dummy widget with no restriction regarding a vertical resizing.
// This assures that the spacing between the buttons is not increased.
new QWidget(buttonBox);
topLayout->addWidget(hBox);
// insert all editable bookmarks.
KBookmarkGroup root = DolphinSettings::instance().bookmarkManager()->root();
KBookmark bookmark = root.first();
QListViewItem* prev = 0;
while (!bookmark.isNull()) {
QListViewItem* item = new QListViewItem(m_listView);
item->setPixmap(PixmapIdx, SmallIcon(bookmark.icon()));
item->setText(NameIdx, bookmark.text());
item->setText(URLIdx, bookmark.url().prettyURL());
// add hidden column to be able to retrieve the icon name again
item->setText(IconIdx, bookmark.icon());
m_listView->insertItem(item);
if (prev != 0) {
item->moveItem(prev);
}
prev = item;
bookmark = root.next(bookmark);
}
m_listView->setSelected(m_listView->firstChild(), true);
updateButtons();
}
示例7: echoBookmark
void BookmarksProtocol::echoBookmark( const KBookmark &bm)
{
QString descriptionAsTitle = bm.description().toHtmlEscaped();
if (!descriptionAsTitle.isEmpty())
descriptionAsTitle.prepend(QLatin1String("\" title=\""));
echo ("<li class=\"link\"><a href=\"" + bm.url().url() + descriptionAsTitle + "\"><img src=\"/icon/" + bm.icon() + "\"/>" + bm.text().toHtmlEscaped() + "</a></li>");
}
示例8: updateContent
//.........这里部分代码省略.........
}
// delete all existing URL navigator buttons
QPtrList<QWidget> deleteList;
while ((object = it.current()) != 0) {
if (object->inherits("URLNavigatorButton")) {
// Don't close and delete the navigator button immediatly, otherwise
// the iterator won't work anymore and an object would get deleted more
// than once (-> crash).
deleteList.append(static_cast<QWidget*>(object));
}
++it;
}
// now close and delete all unused navigator buttons
QPtrListIterator<QWidget> deleteIter(deleteList);
QWidget* widget = 0;
while ((widget = deleteIter.current()) != 0) {
widget->close();
widget->deleteLater();
++deleteIter;
}
m_bookmarkSelector->updateSelection(url());
QToolTip::remove(m_toggleButton);
QString path(url().prettyURL());
if (m_toggleButton->state() == QButton::On) {
// TODO: don't hardcode the shortcut as part of the text
QToolTip::add(m_toggleButton, i18n("Browse (Ctrl+B, Escape)"));
setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
m_pathBox->show();
m_pathBox->setURL(url());
}
else {
// TODO: don't hardcode the shortcut as part of the text
QToolTip::add(m_toggleButton, i18n("Edit location (Ctrl+L)"));
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
m_pathBox->hide();
QString dir_name;
// get the data from the currently selected bookmark
KBookmark bookmark = m_bookmarkSelector->selectedBookmark();
//int bookmarkIndex = m_bookmarkSelector->selectedIndex();
QString bookmarkPath;
if (bookmark.isNull()) {
// No bookmark is a part of the current URL.
// The following code tries to guess the bookmark
// path. E. g. "fish://[email protected]/var/lib" writes
// "fish://[email protected]" to 'bookmarkPath', which leads to the
// navigation indication 'Custom Path > var > lib".
int idx = path.find(QString("//"));
idx = path.find("/", (idx < 0) ? 0 : idx + 2);
bookmarkPath = (idx < 0) ? path : path.left(idx);
}
else {
bookmarkPath = bookmark.url().prettyURL();
}
const uint len = bookmarkPath.length();
// calculate the start point for the URL navigator buttons by counting
// the slashs inside the bookmark URL
int slashCount = 0;
for (uint i = 0; i < len; ++i) {
if (bookmarkPath.at(i) == QChar('/')) {
++slashCount;
}
}
if ((len > 0) && bookmarkPath.at(len - 1) == QChar('/')) {
assert(slashCount > 0);
--slashCount;
}
// create URL navigator buttons
int idx = slashCount;
bool hasNext = true;
do {
dir_name = path.section('/', idx, idx);
const bool isFirstButton = (idx == slashCount);
hasNext = isFirstButton || !dir_name.isEmpty();
if (hasNext) {
URLNavigatorButton* button = new URLNavigatorButton(idx, this);
if (isFirstButton) {
// the first URL navigator button should get the name of the bookmark
// instead of the directory name
QString text = bookmark.text();
if (text.isEmpty()) {
text = bookmarkPath;
}
button->setText(text);
}
button->show();
++idx;
}
} while (hasNext);
}
}
示例9: KonqSidebarTreeItem
KonqSidebarBookmarkItem::KonqSidebarBookmarkItem( KonqSidebarTreeItem *parentItem, KonqSidebarTreeTopLevelItem *topLevelItem, const KBookmark & bk, int key )
: KonqSidebarTreeItem( parentItem, topLevelItem ), m_bk(bk), m_key(key)
{
setText( 0, bk.text() );
setPixmap( 0, SmallIcon(bk.icon()) );
}
示例10: slotContextMenuRequested
void BookmarksSidebarPage::slotContextMenuRequested(QListBoxItem* item,
const QPoint& pos)
{
const int insertID = 1;
const int editID = 2;
const int deleteID = 3;
const int addID = 4;
QPopupMenu* popup = new QPopupMenu();
if (item == 0) {
popup->insertItem(SmallIcon("filenew"), i18n("Add Bookmark..."), addID);
}
else {
popup->insertItem(SmallIcon("filenew"), i18n("Insert Bookmark..."), insertID);
popup->insertItem(SmallIcon("edit"), i18n("Edit..."), editID);
popup->insertItem(SmallIcon("editdelete"), i18n("Delete"), deleteID);
}
KBookmarkManager* manager = DolphinSettings::instance().bookmarkManager();
KBookmarkGroup root = manager->root();
const int index = m_bookmarksList->index(m_bookmarksList->selectedItem());
const int result = popup->exec(pos);
switch (result) {
case insertID: {
KBookmark newBookmark = EditBookmarkDialog::getBookmark(i18n("Insert Bookmark"),
i18n("New bookmark"),
KURL(),
"bookmark");
if (!newBookmark.isNull()) {
root.addBookmark(manager, newBookmark);
if (index > 0) {
KBookmark prevBookmark = DolphinSettings::instance().bookmark(index - 1);
root.moveItem(newBookmark, prevBookmark);
}
else {
// insert bookmark at first position (is a little bit tricky as KBookmarkGroup
// only allows to move items after existing items)
KBookmark firstBookmark = root.first();
root.moveItem(newBookmark, firstBookmark);
root.moveItem(firstBookmark, newBookmark);
}
manager->emitChanged(root);
}
break;
}
case editID: {
KBookmark oldBookmark = DolphinSettings::instance().bookmark(index);
KBookmark newBookmark = EditBookmarkDialog::getBookmark(i18n("Edit Bookmark"),
oldBookmark.text(),
oldBookmark.url(),
oldBookmark.icon());
if (!newBookmark.isNull()) {
root.addBookmark(manager, newBookmark);
root.moveItem(newBookmark, oldBookmark);
root.deleteBookmark(oldBookmark);
manager->emitChanged(root);
}
break;
}
case deleteID: {
KBookmark bookmark = DolphinSettings::instance().bookmark(index);
root.deleteBookmark(bookmark);
manager->emitChanged(root);
break;
}
case addID: {
KBookmark bookmark = EditBookmarkDialog::getBookmark(i18n("Add Bookmark"),
"New bookmark",
KURL(),
"bookmark");
if (!bookmark.isNull()) {
root.addBookmark(manager, bookmark);
manager->emitChanged(root);
}
}
default: break;
}
delete popup;
popup = 0;
DolphinView* view = Dolphin::mainWin().activeView();
adjustSelection(view->url());
}