本文整理汇总了C++中BookmarkItem类的典型用法代码示例。如果您正苦于以下问题:C++ BookmarkItem类的具体用法?C++ BookmarkItem怎么用?C++ BookmarkItem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BookmarkItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Q_ASSERT
void LocationCompleter::indexShiftActivated(const QModelIndex &index)
{
Q_ASSERT(index.isValid());
if (index.data(LocationCompleterModel::BookmarkRole).toBool()) {
BookmarkItem* bookmark = static_cast<BookmarkItem*>(index.data(LocationCompleterModel::BookmarkItemRole).value<void*>());
bookmark->updateVisitCount();
}
const QUrl url = index.data(LocationCompleterModel::UrlRole).toUrl();
const int tabPos = index.data(LocationCompleterModel::TabPositionTabRole).toInt();
// Load url (instead of switching to tab) with shift activation
if (tabPos > -1) {
loadUrl(url);
return;
}
closePopup();
// Clear locationbar
emit clearCompletion();
// Open new window
mApp->createWindow(Qz::BW_NewWindow, url);
}
示例2: stream
bool
BookmarkModel::dropMimeData(const QMimeData *data, Qt::DropAction action,
int row, int column, const QModelIndex &parent)
{
if (action == Qt::IgnoreAction)
return true;
if (!data->hasFormat(MIMETYPE) || column > 0)
return false;
QByteArray ba = data->data(MIMETYPE);
QDataStream stream(&ba, QIODevice::ReadOnly);
while (stream.atEnd())
return false;
qint32 depth;
bool expanded;
QString name, url;
while (!stream.atEnd()) {
stream >> depth >> name >> url >> expanded;
if (insertRow(qMax(0, row), parent)) {
const QModelIndex ¤t = index(qMax(0, row), 0, parent);
if (current.isValid()) {
BookmarkItem* item = itemFromIndex(current);
item->setData(DataVector() << name << url << expanded);
}
}
}
return true;
}
示例3: 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);
}
示例4: if
LoadRequest LocationCompleter::createLoadRequest(const QModelIndex &index)
{
LoadRequest request;
BookmarkItem *bookmark = nullptr;
if (index.data(LocationCompleterModel::HistoryRole).toBool()) {
request = index.data(LocationCompleterModel::UrlRole).toUrl();
} else if (index.data(LocationCompleterModel::BookmarkRole).toBool()) {
bookmark = static_cast<BookmarkItem*>(index.data(LocationCompleterModel::BookmarkItemRole).value<void*>());
} else if (index.data(LocationCompleterModel::SearchSuggestionRole).toBool()) {
const QString text = index.data(LocationCompleterModel::TitleRole).toString();
request = mApp->searchEnginesManager()->searchResult(LocationBar::searchEngine(), text);
} else if (index.data(LocationCompleterModel::VisitSearchItemRole).toBool()) {
const auto action = LocationBar::loadAction(m_originalText);
switch (action.type) {
case LocationBar::LoadAction::Url:
case LocationBar::LoadAction::Search:
request = action.loadRequest;
break;
case LocationBar::LoadAction::Bookmark:
bookmark = action.bookmark;
break;
default:
break;
}
}
if (bookmark) {
bookmark->updateVisitCount();
request = bookmark->url();
}
return request;
}
示例5: text
LoadRequest LocationBar::createLoadRequest() const
{
LoadRequest req;
// Check for Search Engine shortcut
int firstSpacePos = text().indexOf(QLatin1Char(' '));
if (firstSpacePos != -1) {
const QString shortcut = text().left(firstSpacePos);
const QString searchedString = text().mid(firstSpacePos).trimmed();
SearchEngine en = mApp->searchEnginesManager()->engineForShortcut(shortcut);
if (!en.name.isEmpty()) {
req = mApp->searchEnginesManager()->searchResult(en, searchedString);
}
}
// Check for Bookmark keyword
QList<BookmarkItem*> items = mApp->bookmarks()->searchKeyword(text());
if (!items.isEmpty()) {
BookmarkItem* item = items.first();
item->updateVisitCount();
req.setUrl(item->url());
}
if (req.isEmpty()) {
const QUrl guessedUrl = WebView::guessUrlFromString(text());
if (!guessedUrl.isEmpty())
req.setUrl(guessedUrl);
else
req.setUrl(QUrl::fromEncoded(text().toUtf8()));
}
return req;
}
示例6: editBookmark
void MainWindow::editBookmark()
{
// search the model for the closest bookmark
BookmarkItem * bookmarkItem = 0;
QModelIndex bookmarkIndex = currentTreeItem;
do
{
bookmarkItem = 0; // qobject_cast<BookmarkItem *>(static_cast<TreeItem *>(bookmarkIndex.internalPointer()));
if (bookmarkItem)
break; // we found one!
// up one level
bookmarkIndex = bookmarkIndex.parent();
} while (bookmarkIndex.isValid());
// we found no bookmark!
if (!bookmarkItem)
return;
EditBookmarkDialog dlg(this);
dlg.setDir(bookmarkItem->name());
dlg.setAlias(bookmarkItem->alias());
if (dlg.exec())
model.updateBookmark(bookmarkIndex, dlg.dir(), dlg.alias());
}
示例7: addBookmark
void BookmarkEditDlg::OnItemModify(void)
{
if (mListCtrl.GetSelectedCount() > 0)
{
xpr_sint_t sIndex = mListCtrl.GetSelectionMark();
BookmarkItem *sBookmarkItem = (BookmarkItem *)mListCtrl.GetItemData(sIndex);
BookmarkItemEditDlg sDlg;
sDlg.add(sBookmarkItem);
if (sDlg.DoModal() == IDOK)
{
if (sDlg.mBookmark.mPath.empty() == XPR_FALSE)
{
sDlg.copyBookmark(sBookmarkItem);
sBookmarkItem->newSignature();
sBookmarkItem->destroyIcon();
mListCtrl.SetItemData(sIndex, XPR_NULL);
mListCtrl.DeleteItem(sIndex);
addBookmark(sBookmarkItem, IconReqShellIcon, sIndex);
setItemFocus(sIndex);
}
}
}
updateStatus();
}
示例8: GetCursorPos
xpr_bool_t BookmarkToolBar::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{
NMHDR *pnmhdr = (NMHDR *)lParam;
if (pnmhdr->code == TTN_GETDISPINFO)
{
if (gOpt->mConfig.mBookmarkTooltip == XPR_TRUE)
{
LPNMTTDISPINFO sNmTtDispInfo = (LPNMTTDISPINFO)pnmhdr;
CPoint sPoint;
GetCursorPos(&sPoint);
ScreenToClient(&sPoint);
xpr_sint_t sIndex = GetToolBarCtrl().HitTest(&sPoint);
BookmarkItem *sBookmarkItem = BookmarkMgr::instance().getBookmark(sIndex);
if (sBookmarkItem == XPR_NULL)
return XPR_FALSE;
sBookmarkItem->getTooltip(mToolTipText, !gOpt->mMain.mBookmarkBarText, XPR_TRUE);
sNmTtDispInfo->lpszText = mToolTipText;
}
}
return super::OnNotify(wParam, lParam, pResult);
}
示例9: Q_ASSERT
void ChromeImporter::readBookmarks(const QVariantList &list, BookmarkItem* parent)
{
Q_ASSERT(parent);
foreach (const QVariant &entry, list) {
const QVariantMap map = entry.toMap();
const QString typeString = map.value("type").toString();
BookmarkItem::Type type;
if (typeString == QLatin1String("url")) {
type = BookmarkItem::Url;
}
else if (typeString == QLatin1String("folder")) {
type = BookmarkItem::Folder;
}
else {
continue;
}
BookmarkItem* item = new BookmarkItem(type, parent);
item->setTitle(map.value("name").toString());
if (item->isUrl()) {
item->setUrl(QUrl::fromEncoded(map.value("url").toByteArray()));
}
if (map.contains("children")) {
readBookmarks(map.value("children").toList(), item);
}
}
}
示例10: BookmarkItem
void BookmarksManager::addBookmark()
{
BookmarkItem* item = new BookmarkItem(BookmarkItem::Url);
item->setTitle(tr("New Bookmark"));
item->setUrl(QUrl("http://"));
addBookmark(item);
}
示例11: slotExecuted
void BookmarkList::slotExecuted( QTreeWidgetItem * item )
{
BookmarkItem* bmItem = dynamic_cast<BookmarkItem*>( item );
if ( !bmItem || !bmItem->viewport().isValid() )
return;
goTo( bmItem );
}
示例12: item
int BookmarksModel::rowCount(const QModelIndex &parent) const
{
if (parent.column() > 0) {
return 0;
}
BookmarkItem* itm = item(parent);
return itm->children().count();
}
示例13: Q_ASSERT
void BookmarksManager::bookmarkEdited()
{
Q_ASSERT(ui->tree->selectedBookmarks().count() == 1);
BookmarkItem* item = ui->tree->selectedBookmarks().first();
item->setTitle(ui->title->text());
item->setUrl(QUrl::fromEncoded(ui->address->text().toUtf8()));
item->setKeyword(ui->keyword->text());
item->setDescription(ui->description->toPlainText());
m_bookmarks->changeBookmark(item);
}
示例14: startDrag
void BookmarksListBox::startDrag()
{
int currentItem = QListBox::currentItem();
if (currentItem != -1) {
BookmarkItem* bookmark = (BookmarkItem*)item(currentItem);
if (bookmark!=0){
KURL::List lst;
lst.append( bookmark->url() );
KURLDrag *drag = new KURLDrag(lst, this);
drag->drag();
}
}
}
示例15: BookmarkItem
BookmarkItem* IeImporter::importBookmarks()
{
BookmarkItem* root = new BookmarkItem(BookmarkItem::Folder);
root->setTitle("Internet Explorer Import");
foreach (QFileInfo file, urls) {
QSettings urlFile(file.absoluteFilePath(), QSettings::IniFormat, this);
QUrl url = urlFile.value("InternetShortcut/URL").toUrl();
BookmarkItem* b = new BookmarkItem(BookmarkItem::Url, root);
b->setTitle(file.baseName());
b->setUrl(url);
}