当前位置: 首页>>代码示例>>C++>>正文


C++ BookmarksItem::data方法代码示例

本文整理汇总了C++中BookmarksItem::data方法的典型用法代码示例。如果您正苦于以下问题:C++ BookmarksItem::data方法的具体用法?C++ BookmarksItem::data怎么用?C++ BookmarksItem::data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BookmarksItem的用法示例。


在下文中一共展示了BookmarksItem::data方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: if

QList<BookmarksItem*> BookmarksModel::findUrls(const QUrl &url, QStandardItem *branch) const
{
	if (!branch)
	{
		branch = item(0, 0);
	}

	QList<BookmarksItem*> items;

	for (int i = 0; i < branch->rowCount(); ++i)
	{
		BookmarksItem *item = dynamic_cast<BookmarksItem*>(branch->child(i));

		if (item)
		{
			const BookmarkType type = static_cast<BookmarkType>(item->data(TypeRole).toInt());

			if (type == FolderBookmark)
			{
				items.append(findUrls(url, item));
			}
			else if (type == UrlBookmark && item->data(UrlRole).toUrl() == url)
			{
				items.append(item);
			}
		}
	}

	return items;
}
开发者ID:testmana2,项目名称:otter-browser,代码行数:30,代码来源:BookmarksModel.cpp

示例2: restoreBookmark

void BookmarksModel::restoreBookmark(BookmarksItem *bookmark)
{
	if (!bookmark)
	{
		return;
	}

	BookmarksItem *formerParent = (m_trash.contains(bookmark) ? getBookmark(m_trash[bookmark].first) : getRootItem());

	if (!formerParent || static_cast<BookmarkType>(formerParent->data(TypeRole).toInt()) != FolderBookmark)
	{
		formerParent = getRootItem();
	}

	if (m_trash.contains(bookmark))
	{
		formerParent->insertRow(m_trash[bookmark].second, bookmark->parent()->takeRow(bookmark->row()));

		m_trash.remove(bookmark);
	}
	else
	{
		formerParent->appendRow(bookmark->parent()->takeRow(bookmark->row()));
	}

	readdBookmarkUrl(bookmark);

	BookmarksItem *trashItem = getTrashItem();

	trashItem->setEnabled(trashItem->rowCount() > 0);

	emit bookmarkModified(bookmark);
	emit bookmarkRestored(bookmark);
	emit modelModified();
}
开发者ID:testmana2,项目名称:otter-browser,代码行数:35,代码来源:BookmarksModel.cpp

示例3: flags

// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
Qt::ItemFlags BookmarksModel::flags(const QModelIndex& index) const
{
  if (!index.isValid())
  { return 0; }

  Qt::ItemFlags defaultFlags = QAbstractItemModel::flags(index);

  BookmarksItem* item = getItem(index);
  QString name = item->data(BookmarksItem::Name).toString();
  if (item->data(BookmarksItem::Path).toString().isEmpty())
  {
    // This is a node
    return (defaultFlags | Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled);
  }
  else
  {
    // This is a leaf
    return (defaultFlags | Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsDragEnabled);
  }
}
开发者ID:kglowins,项目名称:DREAM3D,代码行数:23,代码来源:BookmarksModel.cpp

示例4: pasteNote

void WebWidget::pasteNote(QAction *action)
{
	if (action && action->data().isValid())
	{
		BookmarksItem *note = NotesManager::getModel()->bookmarkFromIndex(action->data().toModelIndex());

		if (note)
		{
			pasteText(note->data(BookmarksModel::DescriptionRole).toString());
		}
	}
}
开发者ID:DoctorJellyface,项目名称:otter-browser,代码行数:12,代码来源:WebWidget.cpp

示例5: getLastUsedFolder

BookmarksItem* BookmarksManager::getLastUsedFolder()
{
	BookmarksItem *folder = getModel()->getBookmark(m_lastUsedFolder);

	return ((!folder || static_cast<BookmarksModel::BookmarkType>(folder->data(BookmarksModel::TypeRole).toInt()) != BookmarksModel::FolderBookmark) ? getModel()->getRootItem() : folder);
}
开发者ID:sietse,项目名称:otter-browser,代码行数:6,代码来源:BookmarksManager.cpp

示例6: data

// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
QVariant BookmarksModel::data(const QModelIndex& index, int role) const
{
  if (!index.isValid())
  {
    return QVariant();
  }

  BookmarksItem* item = getItem(index);

  if (role == Qt::DisplayRole)
  {
    return item->data(index.column());
  }
  else if (role == Qt::UserRole)
  {
    return item->getItemHasErrors();
  }
  else if (role == Qt::BackgroundRole)
  {
    if (item->getItemHasErrors() == true)
    {
      return QColor(235, 110, 110);
    }
    else
    {
      return QVariant();
    }
  }
  else if (role == Qt::ForegroundRole)
  {
    if (item->getItemHasErrors() == true)
    {
      return QColor(240, 240, 240);
    }
    else
    {
      return QColor(Qt::black);
    }
  }
  else if (role == Qt::ToolTipRole)
  {
    QString tooltip = "'" + this->index(index.row(), BookmarksItem::Path, index.parent()).data().toString() + "' was not found on the file system.\nYou can either locate the file or delete the entry from the table.";

    if (item->getItemHasErrors() == true)
    {
      return tooltip;
    }
    else
    {
      return "";
    }
  }
  else if (role == Qt::DecorationRole)
  {
    QModelIndex nameIndex = this->index(index.row(), BookmarksItem::Name, index.parent());
    if (nameIndex == index)
    {
      BookmarksItem* item = getItem(index);
      return item->getIcon();
    }
    else
    {
      return QVariant();
    }
  }
  else
  {
    return QVariant();
  }
}
开发者ID:kglowins,项目名称:DREAM3D,代码行数:73,代码来源:BookmarksModel.cpp

示例7: createEntry

QStandardItem* ToolBarDialog::createEntry(const QString &identifier)
{
	QStandardItem *item = new QStandardItem();
	item->setData(identifier, Qt::UserRole);
	item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDragEnabled);

	if (identifier == QLatin1String("separator"))
	{
		item->setText(tr("--- separator ---"));
	}
	else if (identifier == QLatin1String("spacer"))
	{
		item->setText(tr("--- spacer ---"));
	}
	else if (identifier == QLatin1String("AddressWidget"))
	{
		item->setText(tr("Address Field"));
	}
	else if (identifier == QLatin1String("ClosedWindowsWidget"))
	{
		item->setText(tr("List of Closed Windows and Tabs"));
	}
	else if (identifier == QLatin1String("MenuBarWidget"))
	{
		item->setText(tr("Menu Bar"));
	}
	else if (identifier == QLatin1String("MenuButtonWidget"))
	{
		item->setText(tr("Menu Button"));
	}
	else if (identifier == QLatin1String("PanelChooserWidget"))
	{
		item->setText(tr("Sidebar Panel Chooser"));
	}
	else if (identifier == QLatin1String("SearchWidget"))
	{
		item->setText(tr("Search Field"));
	}
	else if (identifier == QLatin1String("StatusMessageWidget"))
	{
		item->setText(tr("Status Message Field"));
	}
	else if (identifier == QLatin1String("TabBarWidget"))
	{
		item->setText(tr("Tab Bar"));
	}
	else if (identifier == QLatin1String("ZoomWidget"))
	{
		item->setText(tr("Zoom Slider"));
	}
	else if (identifier.startsWith(QLatin1String("bookmarks:")))
	{
		BookmarksItem *bookmark = (identifier.startsWith(QLatin1String("bookmarks:/")) ? BookmarksManager::getModel()->getItem(identifier.mid(11)) : BookmarksManager::getBookmark(identifier.mid(10).toULongLong()));

		if (bookmark)
		{
			item->setText(bookmark->data(BookmarksModel::TitleRole).isValid() ? bookmark->data(BookmarksModel::TitleRole).toString() : tr("(Untitled)"));
			item->setIcon(bookmark->data(Qt::DecorationRole).value<QIcon>());
		}
		else
		{
			item->setText(tr("Invalid Bookmark"));
		}
	}
	else if (identifier.endsWith(QLatin1String("Action")))
	{
		const int actionIdentifier = ActionsManager::getActionIdentifier(identifier.left(identifier.length() - 6));

		if (actionIdentifier < 0)
		{
			item->setText(tr("Invalid Entry"));
		}
		else
		{
			const ActionDefinition definition = ActionsManager::getActionDefinition(actionIdentifier);

			item->setText(QCoreApplication::translate("actions", (definition.description.isEmpty() ? definition.text : definition.description).toUtf8().constData()));
			item->setIcon(definition.icon);
		}
	}
	else
	{
		item->setText(tr("Invalid Entry"));
	}

	return item;
}
开发者ID:eryngion,项目名称:otter-browser,代码行数:87,代码来源:ToolBarDialog.cpp


注:本文中的BookmarksItem::data方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。